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