mq200.c revision 1.2.2.2 1 1.2.2.2 bouyer /* $NetBSD: mq200.c,v 1.2.2.2 2000/11/20 20:46:04 bouyer Exp $ */
2 1.2.2.2 bouyer
3 1.2.2.2 bouyer /*-
4 1.2.2.2 bouyer * Copyright (c) 2000 Takemura Shin
5 1.2.2.2 bouyer * All rights reserved.
6 1.2.2.2 bouyer *
7 1.2.2.2 bouyer * Redistribution and use in source and binary forms, with or without
8 1.2.2.2 bouyer * modification, are permitted provided that the following conditions
9 1.2.2.2 bouyer * are met:
10 1.2.2.2 bouyer * 1. Redistributions of source code must retain the above copyright
11 1.2.2.2 bouyer * notice, this list of conditions and the following disclaimer.
12 1.2.2.2 bouyer * 2. Redistributions in binary form must reproduce the above copyright
13 1.2.2.2 bouyer * notice, this list of conditions and the following disclaimer in the
14 1.2.2.2 bouyer * documentation and/or other materials provided with the distribution.
15 1.2.2.2 bouyer * 3. The name of the author may not be used to endorse or promote products
16 1.2.2.2 bouyer * derived from this software without specific prior written permission.
17 1.2.2.2 bouyer *
18 1.2.2.2 bouyer * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19 1.2.2.2 bouyer * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 1.2.2.2 bouyer * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 1.2.2.2 bouyer * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22 1.2.2.2 bouyer * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 1.2.2.2 bouyer * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 1.2.2.2 bouyer * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 1.2.2.2 bouyer * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 1.2.2.2 bouyer * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 1.2.2.2 bouyer * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 1.2.2.2 bouyer * SUCH DAMAGE.
29 1.2.2.2 bouyer *
30 1.2.2.2 bouyer */
31 1.2.2.2 bouyer
32 1.2.2.2 bouyer #include <sys/param.h>
33 1.2.2.2 bouyer #include <sys/kernel.h>
34 1.2.2.2 bouyer #include <sys/device.h>
35 1.2.2.2 bouyer #include <sys/systm.h>
36 1.2.2.2 bouyer #include <sys/reboot.h>
37 1.2.2.2 bouyer
38 1.2.2.2 bouyer #include <uvm/uvm_extern.h>
39 1.2.2.2 bouyer
40 1.2.2.2 bouyer #include <dev/wscons/wsconsio.h>
41 1.2.2.2 bouyer
42 1.2.2.2 bouyer #include <machine/bootinfo.h>
43 1.2.2.2 bouyer #include <machine/bus.h>
44 1.2.2.2 bouyer #include <machine/autoconf.h>
45 1.2.2.2 bouyer #include <machine/config_hook.h>
46 1.2.2.2 bouyer #include <machine/platid.h>
47 1.2.2.2 bouyer #include <machine/platid_mask.h>
48 1.2.2.2 bouyer
49 1.2.2.2 bouyer #include <hpcmips/dev/mq200reg.h>
50 1.2.2.2 bouyer #include <hpcmips/dev/mq200var.h>
51 1.2.2.2 bouyer #include "bivideo.h"
52 1.2.2.2 bouyer #if NBIVIDEO > 0
53 1.2.2.2 bouyer #include <hpcmips/dev/bivideovar.h>
54 1.2.2.2 bouyer #endif
55 1.2.2.2 bouyer
56 1.2.2.2 bouyer #define MQ200DEBUG
57 1.2.2.2 bouyer #ifdef MQ200DEBUG
58 1.2.2.2 bouyer #ifndef MQ200DEBUG_CONF
59 1.2.2.2 bouyer #define MQ200DEBUG_CONF 0
60 1.2.2.2 bouyer #endif
61 1.2.2.2 bouyer int mq200_debug = MQ200DEBUG_CONF;
62 1.2.2.2 bouyer #define DPRINTF(arg) do { if (mq200_debug) printf arg; } while(0);
63 1.2.2.2 bouyer #define DPRINTFN(n, arg) do { if (mq200_debug > (n)) printf arg; } while (0);
64 1.2.2.2 bouyer #define VPRINTF(arg) do { if (bootverbose || mq200_debug) printf arg; } while(0);
65 1.2.2.2 bouyer #define VPRINTFN(n, arg) do { if (bootverbose || mq200_debug > (n)) printf arg; } while (0);
66 1.2.2.2 bouyer #else
67 1.2.2.2 bouyer #define DPRINTF(arg) do { } while (0);
68 1.2.2.2 bouyer #define DPRINTFN(n, arg) do { } while (0);
69 1.2.2.2 bouyer #define VPRINTF(arg) do { if (bootverbose) printf arg; } while(0);
70 1.2.2.2 bouyer #define VPRINTFN(n, arg) do { if (bootverbose) printf arg; } while (0);
71 1.2.2.2 bouyer #endif
72 1.2.2.2 bouyer
73 1.2.2.2 bouyer /*
74 1.2.2.2 bouyer * function prototypes
75 1.2.2.2 bouyer */
76 1.2.2.2 bouyer static void mq200_power __P((int, void *));
77 1.2.2.2 bouyer static int mq200_hardpower __P((void *, int, long, void *));
78 1.2.2.2 bouyer static int mq200_fbinit __P((struct hpcfb_fbconf *));
79 1.2.2.2 bouyer static int mq200_ioctl __P((void *, u_long, caddr_t, int, struct proc *));
80 1.2.2.2 bouyer static paddr_t mq200_mmap __P((void *, off_t offset, int));
81 1.2.2.2 bouyer
82 1.2.2.2 bouyer /*
83 1.2.2.2 bouyer * static variables
84 1.2.2.2 bouyer */
85 1.2.2.2 bouyer struct hpcfb_accessops mq200_ha = {
86 1.2.2.2 bouyer mq200_ioctl, mq200_mmap
87 1.2.2.2 bouyer };
88 1.2.2.2 bouyer
89 1.2.2.2 bouyer int
90 1.2.2.2 bouyer mq200_probe(iot, ioh)
91 1.2.2.2 bouyer bus_space_tag_t iot;
92 1.2.2.2 bouyer bus_space_handle_t ioh;
93 1.2.2.2 bouyer {
94 1.2.2.2 bouyer unsigned long regval;
95 1.2.2.2 bouyer
96 1.2.2.2 bouyer #if NBIVIDEO > 0
97 1.2.2.2 bouyer if (bivideo_dont_attach) /* some video driver already attached */
98 1.2.2.2 bouyer return (0);
99 1.2.2.2 bouyer #endif /* NBIVIDEO > 0 */
100 1.2.2.2 bouyer
101 1.2.2.2 bouyer regval = bus_space_read_4(iot, ioh, MQ200_PC00R);
102 1.2.2.2 bouyer VPRINTF(("mq200 probe: vendor id=%04lx product id=%04lx\n",
103 1.2.2.2 bouyer regval & 0xffff, (regval >> 16) & 0xffff));
104 1.2.2.2 bouyer if (regval != ((MQ200_PRODUCT_ID << 16) | MQ200_VENDOR_ID))
105 1.2.2.2 bouyer return (0);
106 1.2.2.2 bouyer
107 1.2.2.2 bouyer return (1);
108 1.2.2.2 bouyer }
109 1.2.2.2 bouyer
110 1.2.2.2 bouyer void
111 1.2.2.2 bouyer mq200_attach(sc)
112 1.2.2.2 bouyer struct mq200_softc *sc;
113 1.2.2.2 bouyer {
114 1.2.2.2 bouyer unsigned long regval;
115 1.2.2.2 bouyer struct hpcfb_attach_args ha;
116 1.2.2.2 bouyer int console = (bootinfo->bi_cnuse & BI_CNUSE_SERIAL) ? 0 : 1;
117 1.2.2.2 bouyer
118 1.2.2.2 bouyer regval = bus_space_read_4(sc->sc_iot, sc->sc_ioh, MQ200_PC08R);
119 1.2.2.2 bouyer printf(": MQ200 Rev.%02lx video controller\n", regval & 0xff);
120 1.2.2.2 bouyer
121 1.2.2.2 bouyer /* Add a power hook to power saving */
122 1.2.2.2 bouyer sc->sc_powerstate = MQ200_POWERSTATE_D0;
123 1.2.2.2 bouyer sc->sc_powerhook = powerhook_establish(mq200_power, sc);
124 1.2.2.2 bouyer if (sc->sc_powerhook == NULL)
125 1.2.2.2 bouyer printf("%s: WARNING: unable to establish power hook\n",
126 1.2.2.2 bouyer sc->sc_dev.dv_xname);
127 1.2.2.2 bouyer
128 1.2.2.2 bouyer /* Add a hard power hook to power saving */
129 1.2.2.2 bouyer sc->sc_hardpowerhook = config_hook(CONFIG_HOOK_PMEVENT,
130 1.2.2.2 bouyer CONFIG_HOOK_PMEVENT_HARDPOWER,
131 1.2.2.2 bouyer CONFIG_HOOK_SHARE,
132 1.2.2.2 bouyer mq200_hardpower, sc);
133 1.2.2.2 bouyer if (sc->sc_hardpowerhook == NULL)
134 1.2.2.2 bouyer printf("%s: WARNING: unable to establish hard power hook\n",
135 1.2.2.2 bouyer sc->sc_dev.dv_xname);
136 1.2.2.2 bouyer
137 1.2.2.2 bouyer mq200_fbinit(&sc->sc_fbconf);
138 1.2.2.2 bouyer
139 1.2.2.2 bouyer if (console && hpcfb_cnattach(&sc->sc_fbconf) != 0) {
140 1.2.2.2 bouyer panic("mq200_attach: can't init fb console");
141 1.2.2.2 bouyer }
142 1.2.2.2 bouyer
143 1.2.2.2 bouyer ha.ha_console = console;
144 1.2.2.2 bouyer ha.ha_accessops = &mq200_ha;
145 1.2.2.2 bouyer ha.ha_accessctx = sc;
146 1.2.2.2 bouyer ha.ha_curfbconf = 0;
147 1.2.2.2 bouyer ha.ha_nfbconf = 1;
148 1.2.2.2 bouyer ha.ha_fbconflist = &sc->sc_fbconf;
149 1.2.2.2 bouyer ha.ha_curdspconf = 0;
150 1.2.2.2 bouyer ha.ha_ndspconf = 1;
151 1.2.2.2 bouyer ha.ha_dspconflist = &sc->sc_dspconf;
152 1.2.2.2 bouyer
153 1.2.2.2 bouyer config_found(&sc->sc_dev, &ha, hpcfbprint);
154 1.2.2.2 bouyer
155 1.2.2.2 bouyer #if NBIVIDEO > 0
156 1.2.2.2 bouyer /*
157 1.2.2.2 bouyer * bivideo is no longer need
158 1.2.2.2 bouyer */
159 1.2.2.2 bouyer bivideo_dont_attach = 1;
160 1.2.2.2 bouyer #endif /* NBIVIDEO > 0 */
161 1.2.2.2 bouyer }
162 1.2.2.2 bouyer
163 1.2.2.2 bouyer static void
164 1.2.2.2 bouyer mq200_power(why, arg)
165 1.2.2.2 bouyer int why;
166 1.2.2.2 bouyer void *arg;
167 1.2.2.2 bouyer {
168 1.2.2.2 bouyer #if 0
169 1.2.2.2 bouyer struct mq200_softc *sc = arg;
170 1.2.2.2 bouyer
171 1.2.2.2 bouyer switch (why) {
172 1.2.2.2 bouyer case PWR_SUSPEND:
173 1.2.2.2 bouyer sc->sc_powerstate = MQ200_POWERSTATE_D2;
174 1.2.2.2 bouyer break;
175 1.2.2.2 bouyer case PWR_STANDBY:
176 1.2.2.2 bouyer sc->sc_powerstate = MQ200_POWERSTATE_D3;
177 1.2.2.2 bouyer break;
178 1.2.2.2 bouyer case PWR_RESUME:
179 1.2.2.2 bouyer sc->sc_powerstate = MQ200_POWERSTATE_D0;
180 1.2.2.2 bouyer break;
181 1.2.2.2 bouyer }
182 1.2.2.2 bouyer
183 1.2.2.2 bouyer printf("MQ200_PMCSR=%08x\n", sc->sc_powerstate);
184 1.2.2.2 bouyer bus_space_write_4(sc->sc_iot, sc->sc_ioh,
185 1.2.2.2 bouyer MQ200_PMCSR, sc->sc_powerstate);
186 1.2.2.2 bouyer #endif
187 1.2.2.2 bouyer }
188 1.2.2.2 bouyer
189 1.2.2.2 bouyer static int
190 1.2.2.2 bouyer mq200_hardpower(ctx, type, id, msg)
191 1.2.2.2 bouyer void *ctx;
192 1.2.2.2 bouyer int type;
193 1.2.2.2 bouyer long id;
194 1.2.2.2 bouyer void *msg;
195 1.2.2.2 bouyer {
196 1.2.2.2 bouyer struct mq200_softc *sc = ctx;
197 1.2.2.2 bouyer int why = (int)msg;
198 1.2.2.2 bouyer
199 1.2.2.2 bouyer switch (why) {
200 1.2.2.2 bouyer case PWR_SUSPEND:
201 1.2.2.2 bouyer sc->sc_powerstate = MQ200_POWERSTATE_D2;
202 1.2.2.2 bouyer break;
203 1.2.2.2 bouyer case PWR_STANDBY:
204 1.2.2.2 bouyer sc->sc_powerstate = MQ200_POWERSTATE_D3;
205 1.2.2.2 bouyer break;
206 1.2.2.2 bouyer case PWR_RESUME:
207 1.2.2.2 bouyer sc->sc_powerstate = MQ200_POWERSTATE_D0;
208 1.2.2.2 bouyer break;
209 1.2.2.2 bouyer }
210 1.2.2.2 bouyer
211 1.2.2.2 bouyer bus_space_write_4(sc->sc_iot, sc->sc_ioh,
212 1.2.2.2 bouyer MQ200_PMCSR, sc->sc_powerstate);
213 1.2.2.2 bouyer
214 1.2.2.2 bouyer /*
215 1.2.2.2 bouyer * you should wait until the
216 1.2.2.2 bouyer * power state transit sequence will end.
217 1.2.2.2 bouyer */
218 1.2.2.2 bouyer {
219 1.2.2.2 bouyer unsigned long tmp;
220 1.2.2.2 bouyer do {
221 1.2.2.2 bouyer tmp = bus_space_read_4(sc->sc_iot, sc->sc_ioh,
222 1.2.2.2 bouyer MQ200_PMCSR);
223 1.2.2.2 bouyer } while ((tmp & 0x3) != (sc->sc_powerstate & 0x3));
224 1.2.2.2 bouyer delay(100000); /* XXX */
225 1.2.2.2 bouyer }
226 1.2.2.2 bouyer
227 1.2.2.2 bouyer return (0);
228 1.2.2.2 bouyer }
229 1.2.2.2 bouyer
230 1.2.2.2 bouyer
231 1.2.2.2 bouyer static int
232 1.2.2.2 bouyer mq200_fbinit(fb)
233 1.2.2.2 bouyer struct hpcfb_fbconf *fb;
234 1.2.2.2 bouyer {
235 1.2.2.2 bouyer
236 1.2.2.2 bouyer /*
237 1.2.2.2 bouyer * get fb settings from bootinfo
238 1.2.2.2 bouyer */
239 1.2.2.2 bouyer if (bootinfo == NULL ||
240 1.2.2.2 bouyer bootinfo->fb_addr == 0 ||
241 1.2.2.2 bouyer bootinfo->fb_line_bytes == 0 ||
242 1.2.2.2 bouyer bootinfo->fb_width == 0 ||
243 1.2.2.2 bouyer bootinfo->fb_height == 0) {
244 1.2.2.2 bouyer printf("no frame buffer infomation.\n");
245 1.2.2.2 bouyer return (-1);
246 1.2.2.2 bouyer }
247 1.2.2.2 bouyer
248 1.2.2.2 bouyer /* zero fill */
249 1.2.2.2 bouyer bzero(fb, sizeof(*fb));
250 1.2.2.2 bouyer
251 1.2.2.2 bouyer fb->hf_conf_index = 0; /* configuration index */
252 1.2.2.2 bouyer fb->hf_nconfs = 1; /* how many configurations */
253 1.2.2.2 bouyer strcpy(fb->hf_name, "built-in video");
254 1.2.2.2 bouyer /* frame buffer name */
255 1.2.2.2 bouyer strcpy(fb->hf_conf_name, "default");
256 1.2.2.2 bouyer /* configuration name */
257 1.2.2.2 bouyer fb->hf_height = bootinfo->fb_height;
258 1.2.2.2 bouyer fb->hf_width = bootinfo->fb_width;
259 1.2.2.2 bouyer fb->hf_baseaddr = mips_ptob(mips_btop(bootinfo->fb_addr));
260 1.2.2.2 bouyer fb->hf_offset = (u_long)bootinfo->fb_addr - fb->hf_baseaddr;
261 1.2.2.2 bouyer /* frame buffer start offset */
262 1.2.2.2 bouyer fb->hf_bytes_per_line = bootinfo->fb_line_bytes;
263 1.2.2.2 bouyer fb->hf_nplanes = 1;
264 1.2.2.2 bouyer fb->hf_bytes_per_plane = bootinfo->fb_height *
265 1.2.2.2 bouyer bootinfo->fb_line_bytes;
266 1.2.2.2 bouyer
267 1.2.2.2 bouyer fb->hf_access_flags |= HPCFB_ACCESS_BYTE;
268 1.2.2.2 bouyer fb->hf_access_flags |= HPCFB_ACCESS_WORD;
269 1.2.2.2 bouyer fb->hf_access_flags |= HPCFB_ACCESS_DWORD;
270 1.2.2.2 bouyer
271 1.2.2.2 bouyer switch (bootinfo->fb_type) {
272 1.2.2.2 bouyer /*
273 1.2.2.2 bouyer * gray scale
274 1.2.2.2 bouyer */
275 1.2.2.2 bouyer case BIFB_D2_M2L_3:
276 1.2.2.2 bouyer case BIFB_D2_M2L_3x2:
277 1.2.2.2 bouyer fb->hf_access_flags |= HPCFB_ACCESS_REVERSE;
278 1.2.2.2 bouyer /* fall through */
279 1.2.2.2 bouyer case BIFB_D2_M2L_0:
280 1.2.2.2 bouyer case BIFB_D2_M2L_0x2:
281 1.2.2.2 bouyer fb->hf_class = HPCFB_CLASS_GRAYSCALE;
282 1.2.2.2 bouyer fb->hf_access_flags |= HPCFB_ACCESS_STATIC;
283 1.2.2.2 bouyer fb->hf_pack_width = 8;
284 1.2.2.2 bouyer fb->hf_pixels_per_pack = 4;
285 1.2.2.2 bouyer fb->hf_pixel_width = 2;
286 1.2.2.2 bouyer fb->hf_class_data_length = sizeof(struct hf_gray_tag);
287 1.2.2.2 bouyer fb->hf_u.hf_gray.hf_flags = 0; /* reserved for future use */
288 1.2.2.2 bouyer break;
289 1.2.2.2 bouyer
290 1.2.2.2 bouyer /*
291 1.2.2.2 bouyer * indexed color
292 1.2.2.2 bouyer */
293 1.2.2.2 bouyer case BIFB_D8_FF:
294 1.2.2.2 bouyer fb->hf_access_flags |= HPCFB_ACCESS_REVERSE;
295 1.2.2.2 bouyer /* fall through */
296 1.2.2.2 bouyer case BIFB_D8_00:
297 1.2.2.2 bouyer fb->hf_class = HPCFB_CLASS_INDEXCOLOR;
298 1.2.2.2 bouyer fb->hf_access_flags |= HPCFB_ACCESS_STATIC;
299 1.2.2.2 bouyer fb->hf_pack_width = 8;
300 1.2.2.2 bouyer fb->hf_pixels_per_pack = 1;
301 1.2.2.2 bouyer fb->hf_pixel_width = 8;
302 1.2.2.2 bouyer fb->hf_class_data_length = sizeof(struct hf_indexed_tag);
303 1.2.2.2 bouyer fb->hf_u.hf_indexed.hf_flags = 0; /* reserved for future use */
304 1.2.2.2 bouyer break;
305 1.2.2.2 bouyer
306 1.2.2.2 bouyer /*
307 1.2.2.2 bouyer * RGB color
308 1.2.2.2 bouyer */
309 1.2.2.2 bouyer case BIFB_D16_FFFF:
310 1.2.2.2 bouyer fb->hf_access_flags |= HPCFB_ACCESS_REVERSE;
311 1.2.2.2 bouyer /* fall through */
312 1.2.2.2 bouyer case BIFB_D16_0000:
313 1.2.2.2 bouyer fb->hf_class = HPCFB_CLASS_RGBCOLOR;
314 1.2.2.2 bouyer fb->hf_access_flags |= HPCFB_ACCESS_STATIC;
315 1.2.2.2 bouyer #if BYTE_ORDER == LITTLE_ENDIAN
316 1.2.2.2 bouyer fb->hf_swap_flags = HPCFB_SWAP_BYTE;
317 1.2.2.2 bouyer #endif
318 1.2.2.2 bouyer fb->hf_pack_width = 16;
319 1.2.2.2 bouyer fb->hf_pixels_per_pack = 1;
320 1.2.2.2 bouyer fb->hf_pixel_width = 16;
321 1.2.2.2 bouyer
322 1.2.2.2 bouyer fb->hf_class_data_length = sizeof(struct hf_rgb_tag);
323 1.2.2.2 bouyer fb->hf_u.hf_rgb.hf_flags = 0; /* reserved for future use */
324 1.2.2.2 bouyer
325 1.2.2.2 bouyer fb->hf_u.hf_rgb.hf_red_width = 5;
326 1.2.2.2 bouyer fb->hf_u.hf_rgb.hf_red_shift = 11;
327 1.2.2.2 bouyer fb->hf_u.hf_rgb.hf_green_width = 6;
328 1.2.2.2 bouyer fb->hf_u.hf_rgb.hf_green_shift = 5;
329 1.2.2.2 bouyer fb->hf_u.hf_rgb.hf_blue_width = 5;
330 1.2.2.2 bouyer fb->hf_u.hf_rgb.hf_blue_shift = 0;
331 1.2.2.2 bouyer fb->hf_u.hf_rgb.hf_alpha_width = 0;
332 1.2.2.2 bouyer fb->hf_u.hf_rgb.hf_alpha_shift = 0;
333 1.2.2.2 bouyer break;
334 1.2.2.2 bouyer
335 1.2.2.2 bouyer default:
336 1.2.2.2 bouyer printf("unknown type (=%d).\n", bootinfo->fb_type);
337 1.2.2.2 bouyer return (-1);
338 1.2.2.2 bouyer break;
339 1.2.2.2 bouyer }
340 1.2.2.2 bouyer
341 1.2.2.2 bouyer return (0); /* no error */
342 1.2.2.2 bouyer }
343 1.2.2.2 bouyer
344 1.2.2.2 bouyer int
345 1.2.2.2 bouyer mq200_ioctl(v, cmd, data, flag, p)
346 1.2.2.2 bouyer void *v;
347 1.2.2.2 bouyer u_long cmd;
348 1.2.2.2 bouyer caddr_t data;
349 1.2.2.2 bouyer int flag;
350 1.2.2.2 bouyer struct proc *p;
351 1.2.2.2 bouyer {
352 1.2.2.2 bouyer struct mq200_softc *sc = (struct mq200_softc *)v;
353 1.2.2.2 bouyer struct hpcfb_fbconf *fbconf;
354 1.2.2.2 bouyer struct hpcfb_dspconf *dspconf;
355 1.2.2.2 bouyer struct wsdisplay_cmap *cmap;
356 1.2.2.2 bouyer
357 1.2.2.2 bouyer switch (cmd) {
358 1.2.2.2 bouyer case WSDISPLAYIO_GETCMAP:
359 1.2.2.2 bouyer cmap = (struct wsdisplay_cmap*)data;
360 1.2.2.2 bouyer
361 1.2.2.2 bouyer if (sc->sc_fbconf.hf_class != HPCFB_CLASS_INDEXCOLOR ||
362 1.2.2.2 bouyer sc->sc_fbconf.hf_pack_width != 8 ||
363 1.2.2.2 bouyer 256 <= cmap->index ||
364 1.2.2.2 bouyer 256 < (cmap->index + cmap->count))
365 1.2.2.2 bouyer return (EINVAL);
366 1.2.2.2 bouyer
367 1.2.2.2 bouyer #if 0
368 1.2.2.2 bouyer if (!uvm_useracc(cmap->red, cmap->count, B_WRITE) ||
369 1.2.2.2 bouyer !uvm_useracc(cmap->green, cmap->count, B_WRITE) ||
370 1.2.2.2 bouyer !uvm_useracc(cmap->blue, cmap->count, B_WRITE))
371 1.2.2.2 bouyer return (EFAULT);
372 1.2.2.2 bouyer
373 1.2.2.2 bouyer copyout(&bivideo_cmap_r[cmap->index], cmap->red, cmap->count);
374 1.2.2.2 bouyer copyout(&bivideo_cmap_g[cmap->index], cmap->green,cmap->count);
375 1.2.2.2 bouyer copyout(&bivideo_cmap_b[cmap->index], cmap->blue, cmap->count);
376 1.2.2.2 bouyer #endif
377 1.2.2.2 bouyer
378 1.2.2.2 bouyer return (0);
379 1.2.2.2 bouyer
380 1.2.2.2 bouyer case WSDISPLAYIO_PUTCMAP:
381 1.2.2.2 bouyer /*
382 1.2.2.2 bouyer * This driver can't set color map.
383 1.2.2.2 bouyer */
384 1.2.2.2 bouyer return (EINVAL);
385 1.2.2.2 bouyer
386 1.2.2.2 bouyer case HPCFBIO_GCONF:
387 1.2.2.2 bouyer fbconf = (struct hpcfb_fbconf *)data;
388 1.2.2.2 bouyer if (fbconf->hf_conf_index != 0 &&
389 1.2.2.2 bouyer fbconf->hf_conf_index != HPCFB_CURRENT_CONFIG) {
390 1.2.2.2 bouyer return (EINVAL);
391 1.2.2.2 bouyer }
392 1.2.2.2 bouyer *fbconf = sc->sc_fbconf; /* structure assignment */
393 1.2.2.2 bouyer return (0);
394 1.2.2.2 bouyer case HPCFBIO_SCONF:
395 1.2.2.2 bouyer fbconf = (struct hpcfb_fbconf *)data;
396 1.2.2.2 bouyer if (fbconf->hf_conf_index != 0 &&
397 1.2.2.2 bouyer fbconf->hf_conf_index != HPCFB_CURRENT_CONFIG) {
398 1.2.2.2 bouyer return (EINVAL);
399 1.2.2.2 bouyer }
400 1.2.2.2 bouyer /*
401 1.2.2.2 bouyer * nothing to do because we have only one configration
402 1.2.2.2 bouyer */
403 1.2.2.2 bouyer return (0);
404 1.2.2.2 bouyer case HPCFBIO_GDSPCONF:
405 1.2.2.2 bouyer dspconf = (struct hpcfb_dspconf *)data;
406 1.2.2.2 bouyer if ((dspconf->hd_unit_index != 0 &&
407 1.2.2.2 bouyer dspconf->hd_unit_index != HPCFB_CURRENT_UNIT) ||
408 1.2.2.2 bouyer (dspconf->hd_conf_index != 0 &&
409 1.2.2.2 bouyer dspconf->hd_conf_index != HPCFB_CURRENT_CONFIG)) {
410 1.2.2.2 bouyer return (EINVAL);
411 1.2.2.2 bouyer }
412 1.2.2.2 bouyer *dspconf = sc->sc_dspconf; /* structure assignment */
413 1.2.2.2 bouyer return (0);
414 1.2.2.2 bouyer case HPCFBIO_SDSPCONF:
415 1.2.2.2 bouyer dspconf = (struct hpcfb_dspconf *)data;
416 1.2.2.2 bouyer if ((dspconf->hd_unit_index != 0 &&
417 1.2.2.2 bouyer dspconf->hd_unit_index != HPCFB_CURRENT_UNIT) ||
418 1.2.2.2 bouyer (dspconf->hd_conf_index != 0 &&
419 1.2.2.2 bouyer dspconf->hd_conf_index != HPCFB_CURRENT_CONFIG)) {
420 1.2.2.2 bouyer return (EINVAL);
421 1.2.2.2 bouyer }
422 1.2.2.2 bouyer /*
423 1.2.2.2 bouyer * nothing to do
424 1.2.2.2 bouyer * because we have only one unit and one configration
425 1.2.2.2 bouyer */
426 1.2.2.2 bouyer return (0);
427 1.2.2.2 bouyer case HPCFBIO_GOP:
428 1.2.2.2 bouyer case HPCFBIO_SOP:
429 1.2.2.2 bouyer /*
430 1.2.2.2 bouyer * curently not implemented...
431 1.2.2.2 bouyer */
432 1.2.2.2 bouyer return (EINVAL);
433 1.2.2.2 bouyer }
434 1.2.2.2 bouyer
435 1.2.2.2 bouyer return (ENOTTY);
436 1.2.2.2 bouyer }
437 1.2.2.2 bouyer
438 1.2.2.2 bouyer paddr_t
439 1.2.2.2 bouyer mq200_mmap(ctx, offset, prot)
440 1.2.2.2 bouyer void *ctx;
441 1.2.2.2 bouyer off_t offset;
442 1.2.2.2 bouyer int prot;
443 1.2.2.2 bouyer {
444 1.2.2.2 bouyer struct mq200_softc *sc = (struct mq200_softc *)ctx;
445 1.2.2.2 bouyer
446 1.2.2.2 bouyer if (offset < 0 ||
447 1.2.2.2 bouyer (sc->sc_fbconf.hf_bytes_per_plane +
448 1.2.2.2 bouyer sc->sc_fbconf.hf_offset) < offset)
449 1.2.2.2 bouyer return -1;
450 1.2.2.2 bouyer
451 1.2.2.2 bouyer return mips_btop(sc->sc_fbconf.hf_baseaddr + offset);
452 1.2.2.2 bouyer }
453