igsfb.c revision 1.7 1 1.7 uwe /* $NetBSD: igsfb.c,v 1.7 2003/01/12 21:37:59 uwe Exp $ */
2 1.1 uwe
3 1.1 uwe /*
4 1.1 uwe * Copyright (c) 2002 Valeriy E. Ushakov
5 1.1 uwe * All rights reserved.
6 1.1 uwe *
7 1.1 uwe * Redistribution and use in source and binary forms, with or without
8 1.1 uwe * modification, are permitted provided that the following conditions
9 1.1 uwe * are met:
10 1.1 uwe * 1. Redistributions of source code must retain the above copyright
11 1.1 uwe * notice, this list of conditions and the following disclaimer.
12 1.1 uwe * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 uwe * notice, this list of conditions and the following disclaimer in the
14 1.1 uwe * documentation and/or other materials provided with the distribution.
15 1.1 uwe * 3. The name of the author may not be used to endorse or promote products
16 1.1 uwe * derived from this software without specific prior written permission
17 1.1 uwe *
18 1.1 uwe * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 1.1 uwe * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 1.1 uwe * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 1.1 uwe * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 1.1 uwe * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 1.1 uwe * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 1.1 uwe * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 1.1 uwe * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 1.1 uwe * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 1.1 uwe * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 1.1 uwe */
29 1.1 uwe
30 1.1 uwe /*
31 1.4 uwe * Integraphics Systems IGA 168x and CyberPro series.
32 1.4 uwe * Only tested on IGA 1682 in Krups JavaStation-NC.
33 1.1 uwe */
34 1.1 uwe #include <sys/cdefs.h>
35 1.7 uwe __KERNEL_RCSID(0, "$NetBSD: igsfb.c,v 1.7 2003/01/12 21:37:59 uwe Exp $");
36 1.1 uwe
37 1.1 uwe #include <sys/param.h>
38 1.1 uwe #include <sys/systm.h>
39 1.1 uwe #include <sys/kernel.h>
40 1.1 uwe #include <sys/device.h>
41 1.1 uwe #include <sys/malloc.h>
42 1.2 uwe #include <sys/ioctl.h>
43 1.1 uwe #include <sys/buf.h>
44 1.2 uwe #include <uvm/uvm_extern.h>
45 1.1 uwe
46 1.1 uwe #include <machine/bus.h>
47 1.1 uwe
48 1.1 uwe #include <dev/wscons/wsdisplayvar.h>
49 1.1 uwe #include <dev/rasops/rasops.h>
50 1.1 uwe #include <dev/wsfont/wsfont.h>
51 1.2 uwe #include <dev/wscons/wsconsio.h>
52 1.1 uwe
53 1.1 uwe #include <dev/ic/igsfbreg.h>
54 1.1 uwe #include <dev/ic/igsfbvar.h>
55 1.1 uwe
56 1.1 uwe
57 1.1 uwe /*
58 1.1 uwe * wsscreen
59 1.1 uwe */
60 1.1 uwe
61 1.1 uwe /* filled from rasops_info in igsfb_common_init */
62 1.1 uwe static struct wsscreen_descr igsfb_stdscreen = {
63 1.1 uwe "std", /* name */
64 1.1 uwe 0, 0, /* ncols, nrows */
65 1.1 uwe NULL, /* textops */
66 1.1 uwe 0, 0, /* fontwidth, fontheight */
67 1.1 uwe 0 /* capabilities */
68 1.1 uwe };
69 1.1 uwe
70 1.1 uwe static const struct wsscreen_descr *_igsfb_scrlist[] = {
71 1.1 uwe &igsfb_stdscreen,
72 1.1 uwe };
73 1.1 uwe
74 1.1 uwe static const struct wsscreen_list igsfb_screenlist = {
75 1.1 uwe sizeof(_igsfb_scrlist) / sizeof(struct wsscreen_descr *),
76 1.1 uwe _igsfb_scrlist
77 1.1 uwe };
78 1.1 uwe
79 1.1 uwe
80 1.1 uwe /*
81 1.1 uwe * wsdisplay_accessops
82 1.1 uwe */
83 1.1 uwe
84 1.1 uwe static int igsfb_ioctl(void *, u_long, caddr_t, int, struct proc *);
85 1.1 uwe static paddr_t igsfb_mmap(void *, off_t, int);
86 1.1 uwe
87 1.1 uwe static int igsfb_alloc_screen(void *, const struct wsscreen_descr *,
88 1.1 uwe void **, int *, int *, long *);
89 1.1 uwe static void igsfb_free_screen(void *, void *);
90 1.1 uwe static int igsfb_show_screen(void *, void *, int,
91 1.1 uwe void (*) (void *, int, int), void *);
92 1.1 uwe
93 1.1 uwe static const struct wsdisplay_accessops igsfb_accessops = {
94 1.1 uwe igsfb_ioctl,
95 1.1 uwe igsfb_mmap,
96 1.1 uwe igsfb_alloc_screen,
97 1.1 uwe igsfb_free_screen,
98 1.1 uwe igsfb_show_screen,
99 1.1 uwe NULL /* load_font */
100 1.1 uwe };
101 1.1 uwe
102 1.1 uwe
103 1.1 uwe /*
104 1.1 uwe * internal functions
105 1.1 uwe */
106 1.1 uwe static void igsfb_common_init(struct igsfb_softc *);
107 1.1 uwe static void igsfb_init_bit_tables(struct igsfb_softc *);
108 1.1 uwe static void igsfb_blank_screen(struct igsfb_softc *, int);
109 1.1 uwe static int igsfb_get_cmap(struct igsfb_softc *, struct wsdisplay_cmap *);
110 1.1 uwe static int igsfb_set_cmap(struct igsfb_softc *, struct wsdisplay_cmap *);
111 1.1 uwe static void igsfb_update_cmap(struct igsfb_softc *sc, u_int, u_int);
112 1.1 uwe static void igsfb_set_curpos(struct igsfb_softc *,
113 1.1 uwe struct wsdisplay_curpos *);
114 1.1 uwe static void igsfb_update_curpos(struct igsfb_softc *);
115 1.1 uwe static int igsfb_get_cursor(struct igsfb_softc *,
116 1.1 uwe struct wsdisplay_cursor *);
117 1.1 uwe static int igsfb_set_cursor(struct igsfb_softc *,
118 1.1 uwe struct wsdisplay_cursor *);
119 1.1 uwe static void igsfb_update_cursor(struct igsfb_softc *, u_int);
120 1.1 uwe static void igsfb_convert_cursor_data(struct igsfb_softc *, u_int, u_int);
121 1.1 uwe
122 1.1 uwe /*
123 1.1 uwe * bit expanders
124 1.1 uwe */
125 1.1 uwe static u_int16_t igsfb_spread_bits_8(u_int8_t);
126 1.1 uwe
127 1.4 uwe static struct igs_bittab *igsfb_bittab = NULL;
128 1.4 uwe static struct igs_bittab *igsfb_bittab_bswap = NULL;
129 1.1 uwe
130 1.1 uwe
131 1.1 uwe /*
132 1.1 uwe * Finish off the attach. Bus specific attach method should have
133 1.1 uwe * enabled io and memory accesses and mapped io and cop registers.
134 1.1 uwe */
135 1.1 uwe void
136 1.1 uwe igsfb_common_attach(sc, isconsole)
137 1.1 uwe struct igsfb_softc *sc;
138 1.1 uwe int isconsole;
139 1.1 uwe {
140 1.4 uwe bus_space_handle_t tmph;
141 1.4 uwe u_int8_t *p;
142 1.4 uwe int need_bswap;
143 1.4 uwe char *bswap_msg;
144 1.4 uwe bus_addr_t fbaddr;
145 1.1 uwe bus_addr_t craddr;
146 1.1 uwe off_t croffset;
147 1.1 uwe struct rasops_info *ri;
148 1.1 uwe struct wsemuldisplaydev_attach_args waa;
149 1.1 uwe u_int8_t busctl, curctl;
150 1.1 uwe
151 1.1 uwe busctl = igs_ext_read(sc->sc_iot, sc->sc_ioh, IGS_EXT_BUS_CTL);
152 1.1 uwe if (busctl & 0x2)
153 1.4 uwe sc->sc_vmemsz = 4 << 20;
154 1.1 uwe else if (busctl & 0x1)
155 1.4 uwe sc->sc_vmemsz = 2 << 20;
156 1.1 uwe else
157 1.4 uwe sc->sc_vmemsz = 1 << 20;
158 1.4 uwe
159 1.4 uwe /*
160 1.4 uwe * Check for endianness mismatch by writing a word at the end
161 1.4 uwe * of video memory (off-screen) and reading it back byte-by-byte.
162 1.4 uwe */
163 1.4 uwe if (bus_space_map(sc->sc_memt,
164 1.4 uwe sc->sc_memaddr + sc->sc_vmemsz - sizeof(u_int32_t),
165 1.4 uwe sizeof(u_int32_t),
166 1.4 uwe sc->sc_memflags | BUS_SPACE_MAP_LINEAR,
167 1.4 uwe &tmph) != 0)
168 1.4 uwe {
169 1.4 uwe printf("unable to map video memory for endianness test\n");
170 1.4 uwe return;
171 1.4 uwe }
172 1.4 uwe
173 1.4 uwe p = bus_space_vaddr(sc->sc_memt, tmph);
174 1.4 uwe #if BYTE_ORDER == BIG_ENDIAN
175 1.4 uwe *((u_int32_t *)p) = 0x12345678;
176 1.4 uwe #else
177 1.4 uwe *((u_int32_t *)p) = 0x78563412;
178 1.4 uwe #endif
179 1.4 uwe if (p[0] == 0x12 && p[1] == 0x34 && p[2] == 0x56 && p[3] == 0x78)
180 1.4 uwe need_bswap = 0;
181 1.4 uwe else
182 1.4 uwe need_bswap = 1;
183 1.4 uwe
184 1.4 uwe bus_space_unmap(sc->sc_memt, tmph, sizeof(u_int32_t));
185 1.4 uwe
186 1.4 uwe /*
187 1.4 uwe * On CyberPro we can use magic bswap bit in linear address.
188 1.4 uwe */
189 1.4 uwe fbaddr = sc->sc_memaddr;
190 1.4 uwe if (need_bswap)
191 1.4 uwe if (sc->sc_is2k) {
192 1.4 uwe fbaddr |= IGS_MEM_BE_SELECT;
193 1.4 uwe bswap_msg = ", hw bswap";
194 1.4 uwe } else {
195 1.4 uwe sc->sc_hwflags |= IGSFB_HW_BSWAP;
196 1.4 uwe bswap_msg = ", sw bswap"; /* sic! */
197 1.4 uwe }
198 1.4 uwe else
199 1.4 uwe bswap_msg = "";
200 1.1 uwe
201 1.1 uwe /*
202 1.1 uwe * Don't map in all N megs, just the amount we need for wsscreen
203 1.1 uwe */
204 1.1 uwe sc->sc_fbsz = 1024 * 768; /* XXX: 8bpp specific */
205 1.4 uwe if (bus_space_map(sc->sc_memt, fbaddr, sc->sc_fbsz,
206 1.1 uwe sc->sc_memflags | BUS_SPACE_MAP_LINEAR,
207 1.1 uwe &sc->sc_fbh) != 0)
208 1.1 uwe {
209 1.4 uwe bus_space_unmap(sc->sc_iot, sc->sc_ioh, IGS_REG_SIZE);
210 1.1 uwe printf("unable to map framebuffer\n");
211 1.1 uwe return;
212 1.1 uwe }
213 1.1 uwe
214 1.1 uwe /*
215 1.4 uwe * 1Kb for cursor sprite data at the very end of video memory
216 1.1 uwe */
217 1.4 uwe croffset = sc->sc_vmemsz - IGS_CURSOR_DATA_SIZE;
218 1.4 uwe craddr = fbaddr + croffset;
219 1.1 uwe if (bus_space_map(sc->sc_memt, craddr, IGS_CURSOR_DATA_SIZE,
220 1.1 uwe sc->sc_memflags | BUS_SPACE_MAP_LINEAR,
221 1.1 uwe &sc->sc_crh) != 0)
222 1.1 uwe {
223 1.4 uwe bus_space_unmap(sc->sc_iot, sc->sc_ioh, IGS_REG_SIZE);
224 1.1 uwe bus_space_unmap(sc->sc_memt, sc->sc_fbh, sc->sc_fbsz);
225 1.1 uwe printf("unable to map cursor sprite region\n");
226 1.1 uwe return;
227 1.1 uwe }
228 1.1 uwe
229 1.1 uwe /*
230 1.1 uwe * Tell device where cursor sprite data are located in linear
231 1.1 uwe * space (it takes data offset in 1k units).
232 1.1 uwe */
233 1.1 uwe croffset >>= 10;
234 1.1 uwe igs_ext_write(sc->sc_iot, sc->sc_ioh,
235 1.1 uwe IGS_EXT_SPRITE_DATA_LO, croffset & 0xff);
236 1.1 uwe igs_ext_write(sc->sc_iot, sc->sc_ioh,
237 1.1 uwe IGS_EXT_SPRITE_DATA_HI, (croffset >> 8) & 0xf);
238 1.1 uwe
239 1.1 uwe memset(&sc->sc_cursor, 0, sizeof(struct igs_hwcursor));
240 1.1 uwe memset(bus_space_vaddr(sc->sc_memt, sc->sc_crh),
241 1.1 uwe 0xaa, IGS_CURSOR_DATA_SIZE); /* transparent */
242 1.1 uwe
243 1.1 uwe curctl = igs_ext_read(sc->sc_iot, sc->sc_ioh, IGS_EXT_SPRITE_CTL);
244 1.1 uwe curctl |= IGS_EXT_SPRITE_64x64;
245 1.1 uwe curctl &= ~IGS_EXT_SPRITE_VISIBLE;
246 1.1 uwe igs_ext_write(sc->sc_iot, sc->sc_ioh, IGS_EXT_SPRITE_CTL, curctl);
247 1.1 uwe
248 1.1 uwe /* bit expanders for cursor sprite data */
249 1.1 uwe igsfb_init_bit_tables(sc);
250 1.1 uwe
251 1.1 uwe /* alloc and cross-link raster ops */
252 1.1 uwe ri = malloc(sizeof(struct rasops_info), M_DEVBUF, M_NOWAIT | M_ZERO);
253 1.1 uwe if (ri == NULL)
254 1.1 uwe panic("unable to allocate rasops");
255 1.1 uwe ri->ri_hw = sc;
256 1.1 uwe sc->sc_ri = ri;
257 1.1 uwe
258 1.1 uwe igsfb_common_init(sc);
259 1.1 uwe
260 1.1 uwe /*
261 1.1 uwe * XXX: console attachment needs rethinking
262 1.1 uwe */
263 1.7 uwe sc->sc_nscreens = 0;
264 1.1 uwe if (isconsole) {
265 1.1 uwe long defattr;
266 1.7 uwe
267 1.7 uwe sc->sc_nscreens = 1;
268 1.3 junyoung (*ri->ri_ops.allocattr)(ri, 0, 0, 0, &defattr);
269 1.1 uwe wsdisplay_cnattach(&igsfb_stdscreen, ri, 0, 0, defattr);
270 1.1 uwe }
271 1.1 uwe
272 1.1 uwe
273 1.6 uwe printf("%s: %dMB%s, %dx%d, %dbpp\n",
274 1.4 uwe sc->sc_dev.dv_xname,
275 1.4 uwe (u_int32_t)(sc->sc_vmemsz >> 20),
276 1.4 uwe bswap_msg,
277 1.4 uwe ri->ri_width, ri->ri_height, ri->ri_depth);
278 1.1 uwe
279 1.1 uwe /* attach wsdisplay */
280 1.1 uwe waa.console = isconsole;
281 1.1 uwe waa.scrdata = &igsfb_screenlist;
282 1.1 uwe waa.accessops = &igsfb_accessops;
283 1.1 uwe waa.accesscookie = sc;
284 1.1 uwe
285 1.1 uwe config_found(&sc->sc_dev, &waa, wsemuldisplaydevprint);
286 1.1 uwe }
287 1.1 uwe
288 1.1 uwe
289 1.1 uwe /*
290 1.4 uwe * Helper function for igsfb_init_bit_tables().
291 1.4 uwe */
292 1.4 uwe static u_int16_t
293 1.4 uwe igsfb_spread_bits_8(b)
294 1.4 uwe u_int8_t b;
295 1.4 uwe {
296 1.4 uwe u_int16_t s = b;
297 1.4 uwe
298 1.4 uwe s = ((s & 0x00f0) << 4) | (s & 0x000f);
299 1.4 uwe s = ((s & 0x0c0c) << 2) | (s & 0x0303);
300 1.4 uwe s = ((s & 0x2222) << 1) | (s & 0x1111);
301 1.4 uwe return (s);
302 1.4 uwe }
303 1.4 uwe
304 1.4 uwe
305 1.4 uwe /*
306 1.1 uwe * Cursor sprite data are in 2bpp. Incoming image/mask are in 1bpp.
307 1.1 uwe * Prebuild tables to expand 1bpp->2bpp with bswapping if neccessary.
308 1.1 uwe */
309 1.1 uwe static void
310 1.1 uwe igsfb_init_bit_tables(sc)
311 1.1 uwe struct igsfb_softc *sc;
312 1.1 uwe {
313 1.1 uwe struct igs_bittab *tab;
314 1.1 uwe u_int i;
315 1.1 uwe
316 1.1 uwe if (sc->sc_hwflags & IGSFB_HW_BSWAP) {
317 1.1 uwe if (igsfb_bittab_bswap == NULL) {
318 1.1 uwe tab = malloc(sizeof(struct igs_bittab),
319 1.1 uwe M_DEVBUF, M_NOWAIT);
320 1.1 uwe for (i = 0; i < 256; ++i) {
321 1.1 uwe u_int16_t s = igsfb_spread_bits_8(i);
322 1.1 uwe tab->iexpand[i] = bswap16(s);
323 1.1 uwe tab->mexpand[i] = bswap16((s << 1) | s);
324 1.1 uwe }
325 1.1 uwe igsfb_bittab_bswap = tab;
326 1.1 uwe }
327 1.1 uwe sc->sc_bittab = igsfb_bittab_bswap;
328 1.1 uwe } else {
329 1.1 uwe if (igsfb_bittab == NULL) {
330 1.1 uwe tab = malloc(sizeof(struct igs_bittab),
331 1.1 uwe M_DEVBUF, M_NOWAIT);
332 1.1 uwe for (i = 0; i < 256; ++i) {
333 1.1 uwe u_int16_t s = igsfb_spread_bits_8(i);
334 1.1 uwe tab->iexpand[i] = s;
335 1.1 uwe tab->mexpand[i] = (s << 1) | s;
336 1.1 uwe }
337 1.1 uwe igsfb_bittab = tab;
338 1.1 uwe }
339 1.1 uwe sc->sc_bittab = igsfb_bittab;
340 1.1 uwe }
341 1.1 uwe }
342 1.1 uwe
343 1.1 uwe /*
344 1.1 uwe * I/O and memory are mapped, video enabled, structures allocated.
345 1.1 uwe */
346 1.1 uwe static void
347 1.1 uwe igsfb_common_init(sc)
348 1.1 uwe struct igsfb_softc *sc;
349 1.1 uwe {
350 1.1 uwe bus_space_tag_t iot = sc->sc_iot;
351 1.1 uwe bus_space_handle_t ioh = sc->sc_ioh;
352 1.1 uwe struct rasops_info *ri = sc->sc_ri;
353 1.1 uwe int wsfcookie;
354 1.1 uwe const u_int8_t *p;
355 1.1 uwe int i;
356 1.1 uwe
357 1.1 uwe sc->sc_blanked = 0;
358 1.1 uwe
359 1.1 uwe ri->ri_flg = RI_CENTER | RI_CLEAR;
360 1.1 uwe if (sc->sc_hwflags & IGSFB_HW_BSWAP)
361 1.1 uwe ri->ri_flg |= RI_BSWAP;
362 1.1 uwe
363 1.6 uwe /* XXX: deduce these from chip registers */
364 1.1 uwe ri->ri_depth = 8;
365 1.1 uwe ri->ri_width = 1024;
366 1.1 uwe ri->ri_height = 768;
367 1.6 uwe
368 1.1 uwe ri->ri_stride = 1024;
369 1.1 uwe ri->ri_bits = (u_char *)sc->sc_fbh;
370 1.1 uwe
371 1.1 uwe /*
372 1.1 uwe * Initialize wsfont related stuff.
373 1.1 uwe */
374 1.1 uwe wsfont_init();
375 1.1 uwe
376 1.1 uwe /* prefer gallant that is identical to the one the prom uses */
377 1.1 uwe wsfcookie = wsfont_find("Gallant", 12, 22, 0,
378 1.1 uwe WSDISPLAY_FONTORDER_L2R,
379 1.1 uwe WSDISPLAY_FONTORDER_L2R);
380 1.1 uwe if (wsfcookie <= 0) {
381 1.1 uwe #ifdef DIAGNOSTIC
382 1.1 uwe printf("%s: unable to find font Gallant 12x22\n",
383 1.1 uwe sc->sc_dev.dv_xname);
384 1.1 uwe #endif
385 1.1 uwe /* any font at all? */
386 1.1 uwe wsfcookie = wsfont_find(NULL, 0, 0, 0,
387 1.1 uwe WSDISPLAY_FONTORDER_L2R,
388 1.1 uwe WSDISPLAY_FONTORDER_L2R);
389 1.1 uwe }
390 1.1 uwe
391 1.1 uwe if (wsfcookie <= 0) {
392 1.1 uwe printf("%s: unable to find any fonts\n", sc->sc_dev.dv_xname);
393 1.1 uwe return;
394 1.1 uwe }
395 1.1 uwe
396 1.1 uwe if (wsfont_lock(wsfcookie, &ri->ri_font) != 0) {
397 1.1 uwe printf("%s: unable to lock font\n", sc->sc_dev.dv_xname);
398 1.1 uwe return;
399 1.1 uwe }
400 1.1 uwe ri->ri_wsfcookie = wsfcookie;
401 1.1 uwe
402 1.1 uwe
403 1.1 uwe /*
404 1.1 uwe * Initialize colormap related stuff.
405 1.1 uwe */
406 1.1 uwe
407 1.1 uwe /* ANSI color map */
408 1.1 uwe p = rasops_cmap;
409 1.1 uwe for (i = 0; i < IGS_CMAP_SIZE; ++i, p += 3) { /* software copy */
410 1.1 uwe sc->sc_cmap.r[i] = p[0];
411 1.1 uwe sc->sc_cmap.g[i] = p[1];
412 1.1 uwe sc->sc_cmap.b[i] = p[2];
413 1.1 uwe }
414 1.1 uwe igsfb_update_cmap(sc, 0, IGS_CMAP_SIZE);
415 1.1 uwe
416 1.1 uwe /* set overscan color r/g/b (XXX: use defattr's rgb?) */
417 1.1 uwe igs_ext_write(iot, ioh, IGS_EXT_OVERSCAN_RED, 0);
418 1.1 uwe igs_ext_write(iot, ioh, IGS_EXT_OVERSCAN_GREEN, 0);
419 1.1 uwe igs_ext_write(iot, ioh, IGS_EXT_OVERSCAN_BLUE, 0);
420 1.1 uwe
421 1.1 uwe
422 1.1 uwe /* TODO: compute term size based on font dimensions? */
423 1.1 uwe rasops_init(ri, 34, 80);
424 1.1 uwe
425 1.1 uwe igsfb_stdscreen.nrows = ri->ri_rows;
426 1.1 uwe igsfb_stdscreen.ncols = ri->ri_cols;
427 1.1 uwe igsfb_stdscreen.textops = &ri->ri_ops;
428 1.1 uwe igsfb_stdscreen.capabilities = ri->ri_caps;
429 1.1 uwe }
430 1.1 uwe
431 1.1 uwe
432 1.1 uwe /*
433 1.1 uwe * wsdisplay_accessops: mmap()
434 1.4 uwe * XXX: allow mmapping i/o mapped i/o regs if INSECURE???
435 1.1 uwe */
436 1.1 uwe static paddr_t
437 1.1 uwe igsfb_mmap(v, offset, prot)
438 1.1 uwe void *v;
439 1.1 uwe off_t offset;
440 1.1 uwe int prot;
441 1.1 uwe {
442 1.1 uwe struct igsfb_softc *sc = v;
443 1.1 uwe
444 1.1 uwe if (offset >= sc->sc_memsz || offset < 0)
445 1.1 uwe return (-1);
446 1.1 uwe
447 1.1 uwe return (bus_space_mmap(sc->sc_memt, sc->sc_memaddr, offset, prot,
448 1.1 uwe sc->sc_memflags | BUS_SPACE_MAP_LINEAR));
449 1.1 uwe }
450 1.1 uwe
451 1.1 uwe
452 1.1 uwe /*
453 1.1 uwe * wsdisplay_accessops: ioctl()
454 1.1 uwe */
455 1.1 uwe static int
456 1.1 uwe igsfb_ioctl(v, cmd, data, flag, p)
457 1.1 uwe void *v;
458 1.1 uwe u_long cmd;
459 1.1 uwe caddr_t data;
460 1.1 uwe int flag;
461 1.1 uwe struct proc *p;
462 1.1 uwe {
463 1.1 uwe struct igsfb_softc *sc = v;
464 1.1 uwe struct rasops_info *ri = sc->sc_ri;
465 1.1 uwe int turnoff;
466 1.1 uwe
467 1.1 uwe switch (cmd) {
468 1.1 uwe
469 1.1 uwe case WSDISPLAYIO_GTYPE:
470 1.1 uwe *(u_int *)data = WSDISPLAY_TYPE_PCIMISC;
471 1.1 uwe return (0);
472 1.1 uwe
473 1.1 uwe case WSDISPLAYIO_GINFO:
474 1.1 uwe #define wsd_fbip ((struct wsdisplay_fbinfo *)data)
475 1.1 uwe wsd_fbip->height = ri->ri_height;
476 1.1 uwe wsd_fbip->width = ri->ri_width;
477 1.1 uwe wsd_fbip->depth = ri->ri_depth;
478 1.1 uwe wsd_fbip->cmsize = IGS_CMAP_SIZE;
479 1.1 uwe #undef wsd_fbip
480 1.1 uwe return (0);
481 1.1 uwe
482 1.1 uwe case WSDISPLAYIO_GVIDEO:
483 1.1 uwe *(u_int *)data = sc->sc_blanked ?
484 1.1 uwe WSDISPLAYIO_VIDEO_OFF : WSDISPLAYIO_VIDEO_ON;
485 1.1 uwe return (0);
486 1.1 uwe
487 1.1 uwe case WSDISPLAYIO_SVIDEO:
488 1.1 uwe turnoff = (*(u_int *)data == WSDISPLAYIO_VIDEO_OFF);
489 1.1 uwe if (sc->sc_blanked != turnoff) {
490 1.1 uwe sc->sc_blanked = turnoff;
491 1.1 uwe igsfb_blank_screen(sc, sc->sc_blanked);
492 1.1 uwe }
493 1.1 uwe return (0);
494 1.1 uwe
495 1.1 uwe case WSDISPLAYIO_GETCMAP:
496 1.1 uwe return (igsfb_get_cmap(sc, (struct wsdisplay_cmap *)data));
497 1.1 uwe
498 1.1 uwe case WSDISPLAYIO_PUTCMAP:
499 1.1 uwe return (igsfb_set_cmap(sc, (struct wsdisplay_cmap *)data));
500 1.1 uwe
501 1.1 uwe case WSDISPLAYIO_GCURMAX:
502 1.1 uwe ((struct wsdisplay_curpos *)data)->x = IGS_CURSOR_MAX_SIZE;
503 1.1 uwe ((struct wsdisplay_curpos *)data)->y = IGS_CURSOR_MAX_SIZE;
504 1.1 uwe return (0);
505 1.1 uwe
506 1.1 uwe case WSDISPLAYIO_GCURPOS:
507 1.1 uwe *(struct wsdisplay_curpos *)data = sc->sc_cursor.cc_pos;
508 1.1 uwe return (0);
509 1.1 uwe
510 1.1 uwe case WSDISPLAYIO_SCURPOS:
511 1.1 uwe igsfb_set_curpos(sc, (struct wsdisplay_curpos *)data);
512 1.1 uwe return (0);
513 1.1 uwe
514 1.1 uwe case WSDISPLAYIO_GCURSOR:
515 1.1 uwe return (igsfb_get_cursor(sc, (struct wsdisplay_cursor *)data));
516 1.1 uwe
517 1.1 uwe case WSDISPLAYIO_SCURSOR:
518 1.1 uwe return (igsfb_set_cursor(sc, (struct wsdisplay_cursor *)data));
519 1.1 uwe }
520 1.1 uwe
521 1.1 uwe return (EPASSTHROUGH);
522 1.1 uwe }
523 1.1 uwe
524 1.1 uwe
525 1.1 uwe /*
526 1.1 uwe * wsdisplay_accessops: ioctl(WSDISPLAYIO_SVIDEO)
527 1.1 uwe */
528 1.1 uwe static void
529 1.1 uwe igsfb_blank_screen(sc, blank)
530 1.1 uwe struct igsfb_softc *sc;
531 1.1 uwe int blank;
532 1.1 uwe {
533 1.1 uwe
534 1.1 uwe igs_ext_write(sc->sc_iot, sc->sc_ioh,
535 1.1 uwe IGS_EXT_SYNC_CTL,
536 1.1 uwe blank ? IGS_EXT_SYNC_H0 | IGS_EXT_SYNC_V0
537 1.1 uwe : 0);
538 1.1 uwe }
539 1.1 uwe
540 1.1 uwe
541 1.1 uwe /*
542 1.1 uwe * wsdisplay_accessops: ioctl(WSDISPLAYIO_GETCMAP)
543 1.1 uwe * Served from software cmap copy.
544 1.1 uwe */
545 1.1 uwe static int
546 1.1 uwe igsfb_get_cmap(sc, p)
547 1.1 uwe struct igsfb_softc *sc;
548 1.1 uwe struct wsdisplay_cmap *p;
549 1.1 uwe {
550 1.1 uwe u_int index = p->index, count = p->count;
551 1.1 uwe
552 1.5 itojun if (index >= IGS_CMAP_SIZE || count > IGS_CMAP_SIZE - index)
553 1.1 uwe return (EINVAL);
554 1.1 uwe
555 1.1 uwe if (!uvm_useracc(p->red, count, B_WRITE) ||
556 1.1 uwe !uvm_useracc(p->green, count, B_WRITE) ||
557 1.1 uwe !uvm_useracc(p->blue, count, B_WRITE))
558 1.1 uwe return (EFAULT);
559 1.1 uwe
560 1.1 uwe copyout(&sc->sc_cmap.r[index], p->red, count);
561 1.1 uwe copyout(&sc->sc_cmap.g[index], p->green, count);
562 1.1 uwe copyout(&sc->sc_cmap.b[index], p->blue, count);
563 1.1 uwe
564 1.1 uwe return (0);
565 1.1 uwe }
566 1.1 uwe
567 1.1 uwe
568 1.1 uwe /*
569 1.1 uwe * wsdisplay_accessops: ioctl(WSDISPLAYIO_SETCMAP)
570 1.1 uwe * Set software cmap copy and propagate changed range to device.
571 1.1 uwe */
572 1.1 uwe static int
573 1.1 uwe igsfb_set_cmap(sc, p)
574 1.1 uwe struct igsfb_softc *sc;
575 1.1 uwe struct wsdisplay_cmap *p;
576 1.1 uwe {
577 1.1 uwe u_int index = p->index, count = p->count;
578 1.1 uwe
579 1.5 itojun if (index >= IGS_CMAP_SIZE || count > IGS_CMAP_SIZE - index)
580 1.1 uwe return (EINVAL);
581 1.1 uwe
582 1.1 uwe if (!uvm_useracc(p->red, count, B_READ) ||
583 1.1 uwe !uvm_useracc(p->green, count, B_READ) ||
584 1.1 uwe !uvm_useracc(p->blue, count, B_READ))
585 1.1 uwe return (EFAULT);
586 1.1 uwe
587 1.1 uwe copyin(p->red, &sc->sc_cmap.r[index], count);
588 1.1 uwe copyin(p->green, &sc->sc_cmap.g[index], count);
589 1.1 uwe copyin(p->blue, &sc->sc_cmap.b[index], count);
590 1.1 uwe
591 1.1 uwe igsfb_update_cmap(sc, p->index, p->count);
592 1.1 uwe
593 1.1 uwe return (0);
594 1.1 uwe }
595 1.1 uwe
596 1.1 uwe
597 1.1 uwe /*
598 1.1 uwe * Propagate specified part of the software cmap copy to device.
599 1.1 uwe */
600 1.1 uwe static void
601 1.1 uwe igsfb_update_cmap(sc, index, count)
602 1.1 uwe struct igsfb_softc *sc;
603 1.1 uwe u_int index, count;
604 1.1 uwe {
605 1.1 uwe bus_space_tag_t t;
606 1.1 uwe bus_space_handle_t h;
607 1.1 uwe u_int last, i;
608 1.1 uwe
609 1.1 uwe if (index >= IGS_CMAP_SIZE)
610 1.1 uwe return;
611 1.1 uwe
612 1.1 uwe last = index + count;
613 1.1 uwe if (last > IGS_CMAP_SIZE)
614 1.1 uwe last = IGS_CMAP_SIZE;
615 1.1 uwe
616 1.1 uwe t = sc->sc_iot;
617 1.1 uwe h = sc->sc_ioh;
618 1.1 uwe
619 1.1 uwe /* start palette writing, index is autoincremented by hardware */
620 1.1 uwe bus_space_write_1(t, h, IGS_DAC_PEL_WRITE_IDX, index);
621 1.1 uwe
622 1.1 uwe for (i = index; i < last; ++i) {
623 1.1 uwe bus_space_write_1(t, h, IGS_DAC_PEL_DATA, sc->sc_cmap.r[i]);
624 1.1 uwe bus_space_write_1(t, h, IGS_DAC_PEL_DATA, sc->sc_cmap.g[i]);
625 1.1 uwe bus_space_write_1(t, h, IGS_DAC_PEL_DATA, sc->sc_cmap.b[i]);
626 1.1 uwe }
627 1.1 uwe }
628 1.1 uwe
629 1.1 uwe
630 1.1 uwe /*
631 1.1 uwe * wsdisplay_accessops: ioctl(WSDISPLAYIO_SCURPOS)
632 1.1 uwe */
633 1.1 uwe static void
634 1.1 uwe igsfb_set_curpos(sc, curpos)
635 1.1 uwe struct igsfb_softc *sc;
636 1.1 uwe struct wsdisplay_curpos *curpos;
637 1.1 uwe {
638 1.1 uwe struct rasops_info *ri = sc->sc_ri;
639 1.1 uwe int x = curpos->x, y = curpos->y;
640 1.1 uwe
641 1.1 uwe if (y < 0)
642 1.1 uwe y = 0;
643 1.1 uwe else if (y > ri->ri_height)
644 1.1 uwe y = ri->ri_height;
645 1.1 uwe if (x < 0)
646 1.1 uwe x = 0;
647 1.1 uwe else if (x > ri->ri_width)
648 1.1 uwe x = ri->ri_width;
649 1.1 uwe sc->sc_cursor.cc_pos.x = x;
650 1.1 uwe sc->sc_cursor.cc_pos.y = y;
651 1.1 uwe
652 1.1 uwe igsfb_update_curpos(sc);
653 1.1 uwe }
654 1.1 uwe
655 1.1 uwe
656 1.1 uwe static void
657 1.1 uwe igsfb_update_curpos(sc)
658 1.1 uwe struct igsfb_softc *sc;
659 1.1 uwe {
660 1.1 uwe bus_space_tag_t t;
661 1.1 uwe bus_space_handle_t h;
662 1.1 uwe int x, xoff, y, yoff;
663 1.1 uwe
664 1.1 uwe xoff = 0;
665 1.1 uwe x = sc->sc_cursor.cc_pos.x - sc->sc_cursor.cc_hot.x;
666 1.1 uwe if (x < 0) {
667 1.1 uwe x = 0;
668 1.1 uwe xoff = -x;
669 1.1 uwe }
670 1.1 uwe
671 1.1 uwe yoff = 0;
672 1.1 uwe y = sc->sc_cursor.cc_pos.y - sc->sc_cursor.cc_hot.y;
673 1.1 uwe if (y < 0) {
674 1.1 uwe y = 0;
675 1.1 uwe yoff = -y;
676 1.1 uwe }
677 1.1 uwe
678 1.1 uwe t = sc->sc_iot;
679 1.1 uwe h = sc->sc_ioh;
680 1.1 uwe
681 1.1 uwe igs_ext_write(t, h, IGS_EXT_SPRITE_HSTART_LO, x & 0xff);
682 1.1 uwe igs_ext_write(t, h, IGS_EXT_SPRITE_HSTART_HI, (x >> 8) & 0x07);
683 1.1 uwe igs_ext_write(t, h, IGS_EXT_SPRITE_HPRESET, xoff & 0x3f);
684 1.1 uwe
685 1.1 uwe igs_ext_write(t, h, IGS_EXT_SPRITE_VSTART_LO, y & 0xff);
686 1.1 uwe igs_ext_write(t, h, IGS_EXT_SPRITE_VSTART_HI, (y >> 8) & 0x07);
687 1.1 uwe igs_ext_write(t, h, IGS_EXT_SPRITE_VPRESET, yoff & 0x3f);
688 1.1 uwe }
689 1.1 uwe
690 1.1 uwe
691 1.1 uwe /*
692 1.1 uwe * wsdisplay_accessops: ioctl(WSDISPLAYIO_GCURSOR)
693 1.1 uwe */
694 1.1 uwe static int
695 1.1 uwe igsfb_get_cursor(sc, p)
696 1.1 uwe struct igsfb_softc *sc;
697 1.1 uwe struct wsdisplay_cursor *p;
698 1.1 uwe {
699 1.1 uwe
700 1.1 uwe /* XXX: TODO */
701 1.1 uwe return (0);
702 1.1 uwe }
703 1.1 uwe
704 1.1 uwe
705 1.1 uwe /*
706 1.1 uwe * wsdisplay_accessops: ioctl(WSDISPLAYIO_SCURSOR)
707 1.1 uwe */
708 1.1 uwe static int
709 1.1 uwe igsfb_set_cursor(sc, p)
710 1.1 uwe struct igsfb_softc *sc;
711 1.1 uwe struct wsdisplay_cursor *p;
712 1.1 uwe {
713 1.1 uwe struct igs_hwcursor *cc;
714 1.1 uwe u_int v, index, count, icount, iwidth;
715 1.1 uwe
716 1.1 uwe cc = &sc->sc_cursor;
717 1.1 uwe v = p->which;
718 1.1 uwe
719 1.1 uwe if (v & WSDISPLAY_CURSOR_DOCMAP) {
720 1.1 uwe index = p->cmap.index;
721 1.1 uwe count = p->cmap.count;
722 1.1 uwe if (index >= 2 || (index + count) > 2)
723 1.1 uwe return (EINVAL);
724 1.1 uwe if (!uvm_useracc(p->cmap.red, count, B_READ)
725 1.1 uwe || !uvm_useracc(p->cmap.green, count, B_READ)
726 1.1 uwe || !uvm_useracc(p->cmap.blue, count, B_READ))
727 1.1 uwe return (EFAULT);
728 1.1 uwe }
729 1.1 uwe
730 1.1 uwe if (v & WSDISPLAY_CURSOR_DOSHAPE) {
731 1.1 uwe if (p->size.x > IGS_CURSOR_MAX_SIZE
732 1.1 uwe || p->size.y > IGS_CURSOR_MAX_SIZE)
733 1.1 uwe return (EINVAL);
734 1.1 uwe
735 1.1 uwe iwidth = (p->size.x + 7) >> 3; /* bytes per scan line */
736 1.1 uwe icount = iwidth * p->size.y;
737 1.1 uwe if (!uvm_useracc(p->image, icount, B_READ)
738 1.1 uwe || !uvm_useracc(p->mask, icount, B_READ))
739 1.1 uwe return (EFAULT);
740 1.1 uwe }
741 1.1 uwe
742 1.1 uwe /* XXX: verify that hot is within size, pos within screen? */
743 1.1 uwe
744 1.1 uwe /* arguments verified, do the processing */
745 1.1 uwe
746 1.1 uwe if (v & WSDISPLAY_CURSOR_DOCUR)
747 1.1 uwe sc->sc_curenb = p->enable;
748 1.1 uwe
749 1.1 uwe if (v & WSDISPLAY_CURSOR_DOPOS)
750 1.1 uwe cc->cc_pos = p->pos;
751 1.1 uwe
752 1.1 uwe if (v & WSDISPLAY_CURSOR_DOHOT)
753 1.1 uwe cc->cc_hot = p->hot;
754 1.1 uwe
755 1.1 uwe if (v & WSDISPLAY_CURSOR_DOCMAP) {
756 1.1 uwe copyin(p->cmap.red, &cc->cc_color[index], count);
757 1.1 uwe copyin(p->cmap.green, &cc->cc_color[index + 2], count);
758 1.1 uwe copyin(p->cmap.blue, &cc->cc_color[index + 4], count);
759 1.1 uwe }
760 1.1 uwe
761 1.1 uwe if (v & WSDISPLAY_CURSOR_DOSHAPE) {
762 1.1 uwe u_int trailing_bits;
763 1.1 uwe
764 1.1 uwe copyin(p->image, cc->cc_image, icount);
765 1.1 uwe copyin(p->mask, cc->cc_mask, icount);
766 1.1 uwe cc->cc_size = p->size;
767 1.1 uwe
768 1.1 uwe /* clear trailing bits in the "partial" mask bytes */
769 1.1 uwe trailing_bits = p->size.x & 0x07;
770 1.1 uwe if (trailing_bits != 0) {
771 1.1 uwe const u_int cutmask = ~((~0) << trailing_bits);
772 1.1 uwe u_char *mp;
773 1.1 uwe u_int i;
774 1.1 uwe
775 1.1 uwe mp = cc->cc_mask + iwidth - 1;
776 1.1 uwe for (i = 0; i < p->size.y; ++i) {
777 1.1 uwe *mp &= cutmask;
778 1.1 uwe mp += iwidth;
779 1.1 uwe }
780 1.1 uwe }
781 1.1 uwe igsfb_convert_cursor_data(sc, iwidth, p->size.y);
782 1.1 uwe }
783 1.1 uwe
784 1.1 uwe igsfb_update_cursor(sc, v);
785 1.1 uwe return (0);
786 1.1 uwe }
787 1.1 uwe
788 1.4 uwe
789 1.1 uwe /*
790 1.1 uwe * Convert incoming 1bpp cursor image/mask into native 2bpp format.
791 1.1 uwe */
792 1.1 uwe static void
793 1.1 uwe igsfb_convert_cursor_data(sc, w, h)
794 1.1 uwe struct igsfb_softc *sc;
795 1.1 uwe u_int w, h;
796 1.1 uwe {
797 1.1 uwe struct igs_hwcursor *cc = &sc->sc_cursor;
798 1.1 uwe struct igs_bittab *btab = sc->sc_bittab;
799 1.1 uwe u_int8_t *ip, *mp;
800 1.1 uwe u_int16_t *dp;
801 1.1 uwe u_int line, i;
802 1.1 uwe
803 1.1 uwe /* init sprite to be all transparent */
804 1.1 uwe memset(cc->cc_sprite, 0xaa, IGS_CURSOR_DATA_SIZE);
805 1.1 uwe
806 1.1 uwe /* first scanline */
807 1.1 uwe ip = cc->cc_image;
808 1.1 uwe mp = cc->cc_mask;
809 1.1 uwe dp = cc->cc_sprite;
810 1.1 uwe
811 1.1 uwe for (line = 0; line < h; ++line) {
812 1.1 uwe for (i = 0; i < w; ++i) {
813 1.1 uwe u_int16_t is = btab->iexpand[ip[i]];
814 1.1 uwe u_int16_t ms = btab->mexpand[mp[i]];
815 1.1 uwe
816 1.1 uwe /* NB: tables are pre-bswapped if needed */
817 1.1 uwe dp[i] = (0xaaaa & ~ms) | (is & ms);
818 1.1 uwe }
819 1.1 uwe
820 1.1 uwe /* next scanline */
821 1.1 uwe ip += w;
822 1.1 uwe mp += w;
823 1.1 uwe dp += 8; /* 2bpp, 8 pixels per short = 8 shorts */
824 1.1 uwe }
825 1.1 uwe }
826 1.1 uwe
827 1.1 uwe
828 1.1 uwe /*
829 1.1 uwe * Propagate cursor changes to device.
830 1.1 uwe * "which" is composed from WSDISPLAY_CURSOR_DO* bits.
831 1.1 uwe */
832 1.1 uwe static void
833 1.1 uwe igsfb_update_cursor(sc, which)
834 1.1 uwe struct igsfb_softc *sc;
835 1.1 uwe u_int which;
836 1.1 uwe {
837 1.1 uwe bus_space_tag_t iot = sc->sc_iot;
838 1.1 uwe bus_space_handle_t ioh = sc->sc_ioh;
839 1.1 uwe u_int8_t curctl;
840 1.1 uwe
841 1.1 uwe /*
842 1.1 uwe * We will need to tweak sprite control register for cursor
843 1.1 uwe * visibility and cursor color map manipualtion.
844 1.1 uwe */
845 1.1 uwe if (which & (WSDISPLAY_CURSOR_DOCUR | WSDISPLAY_CURSOR_DOCMAP)) {
846 1.1 uwe curctl = igs_ext_read(iot, ioh, IGS_EXT_SPRITE_CTL);
847 1.1 uwe }
848 1.1 uwe
849 1.1 uwe if (which & WSDISPLAY_CURSOR_DOSHAPE) {
850 1.1 uwe u_int8_t *dst = bus_space_vaddr(sc->sc_memt, sc->sc_crh);
851 1.1 uwe
852 1.1 uwe /*
853 1.1 uwe * memcpy between spaces of different endianness would
854 1.1 uwe * be ... special. We cannot be sure if memset gonna
855 1.1 uwe * push data in 4-byte chunks, we can't pre-bswap it,
856 1.1 uwe * so do it byte-by-byte to preserve byte ordering.
857 1.1 uwe */
858 1.1 uwe if (sc->sc_hwflags & IGSFB_HW_BSWAP) {
859 1.1 uwe u_int8_t *src = (u_int8_t *)sc->sc_cursor.cc_sprite;
860 1.1 uwe int i;
861 1.1 uwe
862 1.1 uwe for (i = 0; i < 1024; ++i)
863 1.1 uwe *dst++ = *src++;
864 1.1 uwe } else {
865 1.1 uwe memcpy(dst, sc->sc_cursor.cc_sprite, 1024);
866 1.1 uwe }
867 1.1 uwe }
868 1.1 uwe
869 1.1 uwe if (which & (WSDISPLAY_CURSOR_DOPOS | WSDISPLAY_CURSOR_DOHOT)) {
870 1.1 uwe /* code shared with WSDISPLAYIO_SCURPOS */
871 1.1 uwe igsfb_update_curpos(sc);
872 1.1 uwe }
873 1.1 uwe
874 1.1 uwe if (which & WSDISPLAY_CURSOR_DOCMAP) {
875 1.1 uwe u_int8_t *p;
876 1.1 uwe
877 1.1 uwe /* tell DAC we want access to the cursor palette */
878 1.1 uwe igs_ext_write(iot, ioh, IGS_EXT_SPRITE_CTL,
879 1.4 uwe curctl | IGS_EXT_SPRITE_DAC_PEL);
880 1.1 uwe
881 1.1 uwe p = sc->sc_cursor.cc_color;
882 1.1 uwe
883 1.1 uwe bus_space_write_1(iot, ioh, IGS_DAC_PEL_WRITE_IDX, 0);
884 1.1 uwe bus_space_write_1(iot, ioh, IGS_DAC_PEL_DATA, p[0]);
885 1.1 uwe bus_space_write_1(iot, ioh, IGS_DAC_PEL_DATA, p[2]);
886 1.1 uwe bus_space_write_1(iot, ioh, IGS_DAC_PEL_DATA, p[4]);
887 1.1 uwe
888 1.1 uwe bus_space_write_1(iot, ioh, IGS_DAC_PEL_WRITE_IDX, 1);
889 1.1 uwe bus_space_write_1(iot, ioh, IGS_DAC_PEL_DATA, p[1]);
890 1.1 uwe bus_space_write_1(iot, ioh, IGS_DAC_PEL_DATA, p[3]);
891 1.1 uwe bus_space_write_1(iot, ioh, IGS_DAC_PEL_DATA, p[5]);
892 1.1 uwe
893 1.1 uwe /* restore access to normal palette */
894 1.1 uwe igs_ext_write(iot, ioh, IGS_EXT_SPRITE_CTL, curctl);
895 1.1 uwe }
896 1.1 uwe
897 1.1 uwe if (which & WSDISPLAY_CURSOR_DOCUR) {
898 1.1 uwe if ((curctl & IGS_EXT_SPRITE_VISIBLE) == 0
899 1.1 uwe && sc->sc_curenb)
900 1.1 uwe igs_ext_write(iot, ioh, IGS_EXT_SPRITE_CTL,
901 1.1 uwe curctl | IGS_EXT_SPRITE_VISIBLE);
902 1.1 uwe else if ((curctl & IGS_EXT_SPRITE_VISIBLE) != 0
903 1.1 uwe && !sc->sc_curenb)
904 1.1 uwe igs_ext_write(iot, ioh, IGS_EXT_SPRITE_CTL,
905 1.1 uwe curctl & ~IGS_EXT_SPRITE_VISIBLE);
906 1.1 uwe }
907 1.1 uwe }
908 1.1 uwe
909 1.1 uwe
910 1.1 uwe /*
911 1.1 uwe * wsdisplay_accessops: alloc_screen()
912 1.1 uwe */
913 1.1 uwe static int
914 1.1 uwe igsfb_alloc_screen(v, type, cookiep, curxp, curyp, attrp)
915 1.1 uwe void *v;
916 1.1 uwe const struct wsscreen_descr *type;
917 1.1 uwe void **cookiep;
918 1.1 uwe int *curxp, *curyp;
919 1.1 uwe long *attrp;
920 1.1 uwe {
921 1.7 uwe struct igsfb_softc *sc = v;
922 1.7 uwe
923 1.7 uwe if (sc->sc_nscreens > 0) /* only do single screen for now */
924 1.7 uwe return (ENOMEM);
925 1.1 uwe
926 1.7 uwe sc->sc_nscreens = 1;
927 1.7 uwe
928 1.7 uwe *cookiep = sc->sc_ri; /* emulcookie */
929 1.7 uwe *curxp = *curyp = 0;
930 1.7 uwe (*sc->sc_ri->ri_ops.allocattr)(sc->sc_ri, 0, 0, 0, attrp);
931 1.7 uwe
932 1.7 uwe return (0);
933 1.1 uwe }
934 1.1 uwe
935 1.1 uwe
936 1.1 uwe /*
937 1.1 uwe * wsdisplay_accessops: free_screen()
938 1.1 uwe */
939 1.1 uwe static void
940 1.1 uwe igsfb_free_screen(v, cookie)
941 1.1 uwe void *v;
942 1.1 uwe void *cookie;
943 1.1 uwe {
944 1.1 uwe
945 1.1 uwe /* TODO */
946 1.1 uwe return;
947 1.1 uwe }
948 1.1 uwe
949 1.1 uwe
950 1.1 uwe /*
951 1.1 uwe * wsdisplay_accessops: show_screen()
952 1.1 uwe */
953 1.1 uwe static int
954 1.1 uwe igsfb_show_screen(v, cookie, waitok, cb, cbarg)
955 1.1 uwe void *v;
956 1.1 uwe void *cookie;
957 1.1 uwe int waitok;
958 1.1 uwe void (*cb)(void *, int, int);
959 1.1 uwe void *cbarg;
960 1.1 uwe {
961 1.1 uwe
962 1.1 uwe return (0);
963 1.1 uwe }
964