mq200.c revision 1.2.2.5 1 1.2.2.5 bouyer /* $NetBSD: mq200.c,v 1.2.2.5 2001/02/11 19:10:29 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.5 bouyer if (mq200_fbinit(&sc->sc_fbconf) != 0) {
138 1.2.2.5 bouyer /* just return so that hpcfb will not be attached */
139 1.2.2.5 bouyer return;
140 1.2.2.5 bouyer }
141 1.2.2.5 bouyer
142 1.2.2.3 bouyer sc->sc_fbconf.hf_baseaddr = (u_long)bootinfo->fb_addr;
143 1.2.2.4 bouyer sc->sc_fbconf.hf_offset = (u_long)sc->sc_fbconf.hf_baseaddr -
144 1.2.2.3 bouyer MIPS_PHYS_TO_KSEG1(mips_ptob(mips_btop(sc->sc_baseaddr)));
145 1.2.2.3 bouyer DPRINTF(("hf_baseaddr=%lx\n", sc->sc_fbconf.hf_baseaddr));
146 1.2.2.3 bouyer DPRINTF(("hf_offset=%lx\n", sc->sc_fbconf.hf_offset));
147 1.2.2.2 bouyer
148 1.2.2.2 bouyer if (console && hpcfb_cnattach(&sc->sc_fbconf) != 0) {
149 1.2.2.2 bouyer panic("mq200_attach: can't init fb console");
150 1.2.2.2 bouyer }
151 1.2.2.2 bouyer
152 1.2.2.2 bouyer ha.ha_console = console;
153 1.2.2.2 bouyer ha.ha_accessops = &mq200_ha;
154 1.2.2.2 bouyer ha.ha_accessctx = sc;
155 1.2.2.2 bouyer ha.ha_curfbconf = 0;
156 1.2.2.2 bouyer ha.ha_nfbconf = 1;
157 1.2.2.2 bouyer ha.ha_fbconflist = &sc->sc_fbconf;
158 1.2.2.2 bouyer ha.ha_curdspconf = 0;
159 1.2.2.2 bouyer ha.ha_ndspconf = 1;
160 1.2.2.2 bouyer ha.ha_dspconflist = &sc->sc_dspconf;
161 1.2.2.2 bouyer
162 1.2.2.2 bouyer config_found(&sc->sc_dev, &ha, hpcfbprint);
163 1.2.2.2 bouyer
164 1.2.2.2 bouyer #if NBIVIDEO > 0
165 1.2.2.2 bouyer /*
166 1.2.2.2 bouyer * bivideo is no longer need
167 1.2.2.2 bouyer */
168 1.2.2.2 bouyer bivideo_dont_attach = 1;
169 1.2.2.2 bouyer #endif /* NBIVIDEO > 0 */
170 1.2.2.2 bouyer }
171 1.2.2.2 bouyer
172 1.2.2.2 bouyer static void
173 1.2.2.2 bouyer mq200_power(why, arg)
174 1.2.2.2 bouyer int why;
175 1.2.2.2 bouyer void *arg;
176 1.2.2.2 bouyer {
177 1.2.2.2 bouyer #if 0
178 1.2.2.2 bouyer struct mq200_softc *sc = arg;
179 1.2.2.2 bouyer
180 1.2.2.2 bouyer switch (why) {
181 1.2.2.2 bouyer case PWR_SUSPEND:
182 1.2.2.2 bouyer sc->sc_powerstate = MQ200_POWERSTATE_D2;
183 1.2.2.2 bouyer break;
184 1.2.2.2 bouyer case PWR_STANDBY:
185 1.2.2.2 bouyer sc->sc_powerstate = MQ200_POWERSTATE_D3;
186 1.2.2.2 bouyer break;
187 1.2.2.2 bouyer case PWR_RESUME:
188 1.2.2.2 bouyer sc->sc_powerstate = MQ200_POWERSTATE_D0;
189 1.2.2.2 bouyer break;
190 1.2.2.2 bouyer }
191 1.2.2.2 bouyer
192 1.2.2.2 bouyer printf("MQ200_PMCSR=%08x\n", sc->sc_powerstate);
193 1.2.2.2 bouyer bus_space_write_4(sc->sc_iot, sc->sc_ioh,
194 1.2.2.2 bouyer MQ200_PMCSR, sc->sc_powerstate);
195 1.2.2.2 bouyer #endif
196 1.2.2.2 bouyer }
197 1.2.2.2 bouyer
198 1.2.2.2 bouyer static int
199 1.2.2.2 bouyer mq200_hardpower(ctx, type, id, msg)
200 1.2.2.2 bouyer void *ctx;
201 1.2.2.2 bouyer int type;
202 1.2.2.2 bouyer long id;
203 1.2.2.2 bouyer void *msg;
204 1.2.2.2 bouyer {
205 1.2.2.2 bouyer struct mq200_softc *sc = ctx;
206 1.2.2.2 bouyer int why = (int)msg;
207 1.2.2.2 bouyer
208 1.2.2.2 bouyer switch (why) {
209 1.2.2.2 bouyer case PWR_SUSPEND:
210 1.2.2.2 bouyer sc->sc_powerstate = MQ200_POWERSTATE_D2;
211 1.2.2.2 bouyer break;
212 1.2.2.2 bouyer case PWR_STANDBY:
213 1.2.2.2 bouyer sc->sc_powerstate = MQ200_POWERSTATE_D3;
214 1.2.2.2 bouyer break;
215 1.2.2.2 bouyer case PWR_RESUME:
216 1.2.2.2 bouyer sc->sc_powerstate = MQ200_POWERSTATE_D0;
217 1.2.2.2 bouyer break;
218 1.2.2.2 bouyer }
219 1.2.2.2 bouyer
220 1.2.2.2 bouyer bus_space_write_4(sc->sc_iot, sc->sc_ioh,
221 1.2.2.2 bouyer MQ200_PMCSR, sc->sc_powerstate);
222 1.2.2.2 bouyer
223 1.2.2.2 bouyer /*
224 1.2.2.2 bouyer * you should wait until the
225 1.2.2.2 bouyer * power state transit sequence will end.
226 1.2.2.2 bouyer */
227 1.2.2.2 bouyer {
228 1.2.2.2 bouyer unsigned long tmp;
229 1.2.2.2 bouyer do {
230 1.2.2.2 bouyer tmp = bus_space_read_4(sc->sc_iot, sc->sc_ioh,
231 1.2.2.2 bouyer MQ200_PMCSR);
232 1.2.2.2 bouyer } while ((tmp & 0x3) != (sc->sc_powerstate & 0x3));
233 1.2.2.2 bouyer delay(100000); /* XXX */
234 1.2.2.2 bouyer }
235 1.2.2.2 bouyer
236 1.2.2.2 bouyer return (0);
237 1.2.2.2 bouyer }
238 1.2.2.2 bouyer
239 1.2.2.2 bouyer
240 1.2.2.2 bouyer static int
241 1.2.2.2 bouyer mq200_fbinit(fb)
242 1.2.2.2 bouyer struct hpcfb_fbconf *fb;
243 1.2.2.2 bouyer {
244 1.2.2.2 bouyer
245 1.2.2.2 bouyer /*
246 1.2.2.2 bouyer * get fb settings from bootinfo
247 1.2.2.2 bouyer */
248 1.2.2.2 bouyer if (bootinfo == NULL ||
249 1.2.2.2 bouyer bootinfo->fb_addr == 0 ||
250 1.2.2.2 bouyer bootinfo->fb_line_bytes == 0 ||
251 1.2.2.2 bouyer bootinfo->fb_width == 0 ||
252 1.2.2.2 bouyer bootinfo->fb_height == 0) {
253 1.2.2.2 bouyer printf("no frame buffer infomation.\n");
254 1.2.2.2 bouyer return (-1);
255 1.2.2.2 bouyer }
256 1.2.2.2 bouyer
257 1.2.2.2 bouyer /* zero fill */
258 1.2.2.2 bouyer bzero(fb, sizeof(*fb));
259 1.2.2.2 bouyer
260 1.2.2.2 bouyer fb->hf_conf_index = 0; /* configuration index */
261 1.2.2.2 bouyer fb->hf_nconfs = 1; /* how many configurations */
262 1.2.2.2 bouyer strcpy(fb->hf_name, "built-in video");
263 1.2.2.2 bouyer /* frame buffer name */
264 1.2.2.2 bouyer strcpy(fb->hf_conf_name, "default");
265 1.2.2.2 bouyer /* configuration name */
266 1.2.2.2 bouyer fb->hf_height = bootinfo->fb_height;
267 1.2.2.2 bouyer fb->hf_width = bootinfo->fb_width;
268 1.2.2.2 bouyer fb->hf_baseaddr = mips_ptob(mips_btop(bootinfo->fb_addr));
269 1.2.2.2 bouyer fb->hf_offset = (u_long)bootinfo->fb_addr - fb->hf_baseaddr;
270 1.2.2.2 bouyer /* frame buffer start offset */
271 1.2.2.2 bouyer fb->hf_bytes_per_line = bootinfo->fb_line_bytes;
272 1.2.2.2 bouyer fb->hf_nplanes = 1;
273 1.2.2.2 bouyer fb->hf_bytes_per_plane = bootinfo->fb_height *
274 1.2.2.2 bouyer bootinfo->fb_line_bytes;
275 1.2.2.2 bouyer
276 1.2.2.2 bouyer fb->hf_access_flags |= HPCFB_ACCESS_BYTE;
277 1.2.2.2 bouyer fb->hf_access_flags |= HPCFB_ACCESS_WORD;
278 1.2.2.2 bouyer fb->hf_access_flags |= HPCFB_ACCESS_DWORD;
279 1.2.2.2 bouyer
280 1.2.2.2 bouyer switch (bootinfo->fb_type) {
281 1.2.2.2 bouyer /*
282 1.2.2.2 bouyer * gray scale
283 1.2.2.2 bouyer */
284 1.2.2.2 bouyer case BIFB_D2_M2L_3:
285 1.2.2.2 bouyer case BIFB_D2_M2L_3x2:
286 1.2.2.2 bouyer fb->hf_access_flags |= HPCFB_ACCESS_REVERSE;
287 1.2.2.2 bouyer /* fall through */
288 1.2.2.2 bouyer case BIFB_D2_M2L_0:
289 1.2.2.2 bouyer case BIFB_D2_M2L_0x2:
290 1.2.2.2 bouyer fb->hf_class = HPCFB_CLASS_GRAYSCALE;
291 1.2.2.2 bouyer fb->hf_access_flags |= HPCFB_ACCESS_STATIC;
292 1.2.2.2 bouyer fb->hf_pack_width = 8;
293 1.2.2.2 bouyer fb->hf_pixels_per_pack = 4;
294 1.2.2.2 bouyer fb->hf_pixel_width = 2;
295 1.2.2.2 bouyer fb->hf_class_data_length = sizeof(struct hf_gray_tag);
296 1.2.2.2 bouyer fb->hf_u.hf_gray.hf_flags = 0; /* reserved for future use */
297 1.2.2.2 bouyer break;
298 1.2.2.2 bouyer
299 1.2.2.5 bouyer case BIFB_D4_M2L_F:
300 1.2.2.5 bouyer case BIFB_D4_M2L_Fx2:
301 1.2.2.5 bouyer fb->hf_access_flags |= HPCFB_ACCESS_REVERSE;
302 1.2.2.5 bouyer /* fall through */
303 1.2.2.5 bouyer case BIFB_D4_M2L_0:
304 1.2.2.5 bouyer case BIFB_D4_M2L_0x2:
305 1.2.2.5 bouyer fb->hf_class = HPCFB_CLASS_GRAYSCALE;
306 1.2.2.5 bouyer fb->hf_access_flags |= HPCFB_ACCESS_STATIC;
307 1.2.2.5 bouyer fb->hf_pack_width = 8;
308 1.2.2.5 bouyer fb->hf_pixels_per_pack = 2;
309 1.2.2.5 bouyer fb->hf_pixel_width = 4;
310 1.2.2.5 bouyer fb->hf_class_data_length = sizeof(struct hf_gray_tag);
311 1.2.2.5 bouyer fb->hf_u.hf_gray.hf_flags = 0; /* reserved for future use */
312 1.2.2.5 bouyer break;
313 1.2.2.5 bouyer
314 1.2.2.2 bouyer /*
315 1.2.2.2 bouyer * indexed color
316 1.2.2.2 bouyer */
317 1.2.2.2 bouyer case BIFB_D8_FF:
318 1.2.2.2 bouyer fb->hf_access_flags |= HPCFB_ACCESS_REVERSE;
319 1.2.2.2 bouyer /* fall through */
320 1.2.2.2 bouyer case BIFB_D8_00:
321 1.2.2.2 bouyer fb->hf_class = HPCFB_CLASS_INDEXCOLOR;
322 1.2.2.2 bouyer fb->hf_access_flags |= HPCFB_ACCESS_STATIC;
323 1.2.2.2 bouyer fb->hf_pack_width = 8;
324 1.2.2.2 bouyer fb->hf_pixels_per_pack = 1;
325 1.2.2.2 bouyer fb->hf_pixel_width = 8;
326 1.2.2.2 bouyer fb->hf_class_data_length = sizeof(struct hf_indexed_tag);
327 1.2.2.2 bouyer fb->hf_u.hf_indexed.hf_flags = 0; /* reserved for future use */
328 1.2.2.2 bouyer break;
329 1.2.2.2 bouyer
330 1.2.2.2 bouyer /*
331 1.2.2.2 bouyer * RGB color
332 1.2.2.2 bouyer */
333 1.2.2.2 bouyer case BIFB_D16_FFFF:
334 1.2.2.2 bouyer fb->hf_access_flags |= HPCFB_ACCESS_REVERSE;
335 1.2.2.2 bouyer /* fall through */
336 1.2.2.2 bouyer case BIFB_D16_0000:
337 1.2.2.2 bouyer fb->hf_class = HPCFB_CLASS_RGBCOLOR;
338 1.2.2.2 bouyer fb->hf_access_flags |= HPCFB_ACCESS_STATIC;
339 1.2.2.2 bouyer #if BYTE_ORDER == LITTLE_ENDIAN
340 1.2.2.2 bouyer fb->hf_swap_flags = HPCFB_SWAP_BYTE;
341 1.2.2.2 bouyer #endif
342 1.2.2.2 bouyer fb->hf_pack_width = 16;
343 1.2.2.2 bouyer fb->hf_pixels_per_pack = 1;
344 1.2.2.2 bouyer fb->hf_pixel_width = 16;
345 1.2.2.2 bouyer
346 1.2.2.2 bouyer fb->hf_class_data_length = sizeof(struct hf_rgb_tag);
347 1.2.2.2 bouyer fb->hf_u.hf_rgb.hf_flags = 0; /* reserved for future use */
348 1.2.2.2 bouyer
349 1.2.2.2 bouyer fb->hf_u.hf_rgb.hf_red_width = 5;
350 1.2.2.2 bouyer fb->hf_u.hf_rgb.hf_red_shift = 11;
351 1.2.2.2 bouyer fb->hf_u.hf_rgb.hf_green_width = 6;
352 1.2.2.2 bouyer fb->hf_u.hf_rgb.hf_green_shift = 5;
353 1.2.2.2 bouyer fb->hf_u.hf_rgb.hf_blue_width = 5;
354 1.2.2.2 bouyer fb->hf_u.hf_rgb.hf_blue_shift = 0;
355 1.2.2.2 bouyer fb->hf_u.hf_rgb.hf_alpha_width = 0;
356 1.2.2.2 bouyer fb->hf_u.hf_rgb.hf_alpha_shift = 0;
357 1.2.2.2 bouyer break;
358 1.2.2.2 bouyer
359 1.2.2.2 bouyer default:
360 1.2.2.2 bouyer printf("unknown type (=%d).\n", bootinfo->fb_type);
361 1.2.2.2 bouyer return (-1);
362 1.2.2.2 bouyer break;
363 1.2.2.2 bouyer }
364 1.2.2.2 bouyer
365 1.2.2.2 bouyer return (0); /* no error */
366 1.2.2.2 bouyer }
367 1.2.2.2 bouyer
368 1.2.2.2 bouyer int
369 1.2.2.2 bouyer mq200_ioctl(v, cmd, data, flag, p)
370 1.2.2.2 bouyer void *v;
371 1.2.2.2 bouyer u_long cmd;
372 1.2.2.2 bouyer caddr_t data;
373 1.2.2.2 bouyer int flag;
374 1.2.2.2 bouyer struct proc *p;
375 1.2.2.2 bouyer {
376 1.2.2.2 bouyer struct mq200_softc *sc = (struct mq200_softc *)v;
377 1.2.2.2 bouyer struct hpcfb_fbconf *fbconf;
378 1.2.2.2 bouyer struct hpcfb_dspconf *dspconf;
379 1.2.2.2 bouyer struct wsdisplay_cmap *cmap;
380 1.2.2.4 bouyer struct wsdisplay_param *dispparam;
381 1.2.2.2 bouyer
382 1.2.2.2 bouyer switch (cmd) {
383 1.2.2.2 bouyer case WSDISPLAYIO_GETCMAP:
384 1.2.2.2 bouyer cmap = (struct wsdisplay_cmap*)data;
385 1.2.2.2 bouyer
386 1.2.2.2 bouyer if (sc->sc_fbconf.hf_class != HPCFB_CLASS_INDEXCOLOR ||
387 1.2.2.2 bouyer sc->sc_fbconf.hf_pack_width != 8 ||
388 1.2.2.2 bouyer 256 <= cmap->index ||
389 1.2.2.2 bouyer 256 < (cmap->index + cmap->count))
390 1.2.2.2 bouyer return (EINVAL);
391 1.2.2.2 bouyer
392 1.2.2.2 bouyer #if 0
393 1.2.2.2 bouyer if (!uvm_useracc(cmap->red, cmap->count, B_WRITE) ||
394 1.2.2.2 bouyer !uvm_useracc(cmap->green, cmap->count, B_WRITE) ||
395 1.2.2.2 bouyer !uvm_useracc(cmap->blue, cmap->count, B_WRITE))
396 1.2.2.2 bouyer return (EFAULT);
397 1.2.2.2 bouyer
398 1.2.2.2 bouyer copyout(&bivideo_cmap_r[cmap->index], cmap->red, cmap->count);
399 1.2.2.2 bouyer copyout(&bivideo_cmap_g[cmap->index], cmap->green,cmap->count);
400 1.2.2.2 bouyer copyout(&bivideo_cmap_b[cmap->index], cmap->blue, cmap->count);
401 1.2.2.2 bouyer #endif
402 1.2.2.2 bouyer
403 1.2.2.2 bouyer return (0);
404 1.2.2.2 bouyer
405 1.2.2.2 bouyer case WSDISPLAYIO_PUTCMAP:
406 1.2.2.2 bouyer /*
407 1.2.2.2 bouyer * This driver can't set color map.
408 1.2.2.2 bouyer */
409 1.2.2.2 bouyer return (EINVAL);
410 1.2.2.2 bouyer
411 1.2.2.4 bouyer case WSDISPLAYIO_GETPARAM:
412 1.2.2.4 bouyer dispparam = (struct wsdisplay_param*)data;
413 1.2.2.4 bouyer switch (dispparam->param) {
414 1.2.2.4 bouyer case WSDISPLAYIO_PARAM_BACKLIGHT:
415 1.2.2.4 bouyer VPRINTF(("mq200_ioctl: GETPARAM:BACKLIGHT\n"));
416 1.2.2.4 bouyer return (EINVAL);
417 1.2.2.4 bouyer case WSDISPLAYIO_PARAM_CONTRAST:
418 1.2.2.4 bouyer VPRINTF(("mq200_ioctl: GETPARAM:CONTRAST\n"));
419 1.2.2.4 bouyer return (EINVAL);
420 1.2.2.4 bouyer case WSDISPLAYIO_PARAM_BRIGHTNESS:
421 1.2.2.4 bouyer VPRINTF(("mq200_ioctl: GETPARAM:BRIGHTNESS\n"));
422 1.2.2.4 bouyer return (EINVAL);
423 1.2.2.4 bouyer default:
424 1.2.2.4 bouyer return (EINVAL);
425 1.2.2.4 bouyer }
426 1.2.2.4 bouyer return (0);
427 1.2.2.4 bouyer
428 1.2.2.4 bouyer case WSDISPLAYIO_SETPARAM:
429 1.2.2.4 bouyer dispparam = (struct wsdisplay_param*)data;
430 1.2.2.4 bouyer switch (dispparam->param) {
431 1.2.2.4 bouyer case WSDISPLAYIO_PARAM_BACKLIGHT:
432 1.2.2.4 bouyer VPRINTF(("mq200_ioctl: GETPARAM:BACKLIGHT\n"));
433 1.2.2.4 bouyer return (EINVAL);
434 1.2.2.4 bouyer case WSDISPLAYIO_PARAM_CONTRAST:
435 1.2.2.4 bouyer VPRINTF(("mq200_ioctl: GETPARAM:CONTRAST\n"));
436 1.2.2.4 bouyer return (EINVAL);
437 1.2.2.4 bouyer case WSDISPLAYIO_PARAM_BRIGHTNESS:
438 1.2.2.4 bouyer VPRINTF(("mq200_ioctl: GETPARAM:BRIGHTNESS\n"));
439 1.2.2.4 bouyer return (EINVAL);
440 1.2.2.4 bouyer default:
441 1.2.2.4 bouyer return (EINVAL);
442 1.2.2.4 bouyer }
443 1.2.2.4 bouyer return (0);
444 1.2.2.4 bouyer
445 1.2.2.2 bouyer case HPCFBIO_GCONF:
446 1.2.2.2 bouyer fbconf = (struct hpcfb_fbconf *)data;
447 1.2.2.2 bouyer if (fbconf->hf_conf_index != 0 &&
448 1.2.2.2 bouyer fbconf->hf_conf_index != HPCFB_CURRENT_CONFIG) {
449 1.2.2.2 bouyer return (EINVAL);
450 1.2.2.2 bouyer }
451 1.2.2.2 bouyer *fbconf = sc->sc_fbconf; /* structure assignment */
452 1.2.2.2 bouyer return (0);
453 1.2.2.2 bouyer case HPCFBIO_SCONF:
454 1.2.2.2 bouyer fbconf = (struct hpcfb_fbconf *)data;
455 1.2.2.2 bouyer if (fbconf->hf_conf_index != 0 &&
456 1.2.2.2 bouyer fbconf->hf_conf_index != HPCFB_CURRENT_CONFIG) {
457 1.2.2.2 bouyer return (EINVAL);
458 1.2.2.2 bouyer }
459 1.2.2.2 bouyer /*
460 1.2.2.2 bouyer * nothing to do because we have only one configration
461 1.2.2.2 bouyer */
462 1.2.2.2 bouyer return (0);
463 1.2.2.2 bouyer case HPCFBIO_GDSPCONF:
464 1.2.2.2 bouyer dspconf = (struct hpcfb_dspconf *)data;
465 1.2.2.2 bouyer if ((dspconf->hd_unit_index != 0 &&
466 1.2.2.2 bouyer dspconf->hd_unit_index != HPCFB_CURRENT_UNIT) ||
467 1.2.2.2 bouyer (dspconf->hd_conf_index != 0 &&
468 1.2.2.2 bouyer dspconf->hd_conf_index != HPCFB_CURRENT_CONFIG)) {
469 1.2.2.2 bouyer return (EINVAL);
470 1.2.2.2 bouyer }
471 1.2.2.2 bouyer *dspconf = sc->sc_dspconf; /* structure assignment */
472 1.2.2.2 bouyer return (0);
473 1.2.2.2 bouyer case HPCFBIO_SDSPCONF:
474 1.2.2.2 bouyer dspconf = (struct hpcfb_dspconf *)data;
475 1.2.2.2 bouyer if ((dspconf->hd_unit_index != 0 &&
476 1.2.2.2 bouyer dspconf->hd_unit_index != HPCFB_CURRENT_UNIT) ||
477 1.2.2.2 bouyer (dspconf->hd_conf_index != 0 &&
478 1.2.2.2 bouyer dspconf->hd_conf_index != HPCFB_CURRENT_CONFIG)) {
479 1.2.2.2 bouyer return (EINVAL);
480 1.2.2.2 bouyer }
481 1.2.2.2 bouyer /*
482 1.2.2.2 bouyer * nothing to do
483 1.2.2.2 bouyer * because we have only one unit and one configration
484 1.2.2.2 bouyer */
485 1.2.2.2 bouyer return (0);
486 1.2.2.2 bouyer case HPCFBIO_GOP:
487 1.2.2.2 bouyer case HPCFBIO_SOP:
488 1.2.2.2 bouyer /*
489 1.2.2.2 bouyer * curently not implemented...
490 1.2.2.2 bouyer */
491 1.2.2.2 bouyer return (EINVAL);
492 1.2.2.2 bouyer }
493 1.2.2.2 bouyer
494 1.2.2.2 bouyer return (ENOTTY);
495 1.2.2.2 bouyer }
496 1.2.2.2 bouyer
497 1.2.2.2 bouyer paddr_t
498 1.2.2.2 bouyer mq200_mmap(ctx, offset, prot)
499 1.2.2.2 bouyer void *ctx;
500 1.2.2.2 bouyer off_t offset;
501 1.2.2.2 bouyer int prot;
502 1.2.2.2 bouyer {
503 1.2.2.2 bouyer struct mq200_softc *sc = (struct mq200_softc *)ctx;
504 1.2.2.2 bouyer
505 1.2.2.3 bouyer if (offset < 0 || MQ200_MAPSIZE <= offset)
506 1.2.2.2 bouyer return -1;
507 1.2.2.2 bouyer
508 1.2.2.3 bouyer return mips_btop(sc->sc_baseaddr + offset);
509 1.2.2.2 bouyer }
510