igsfb.c revision 1.6 1 1.6 uwe /* $NetBSD: igsfb.c,v 1.6 2002/09/24 18:17:24 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.6 uwe __KERNEL_RCSID(0, "$NetBSD: igsfb.c,v 1.6 2002/09/24 18:17:24 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.1 uwe if (isconsole) {
264 1.1 uwe long defattr;
265 1.3 junyoung (*ri->ri_ops.allocattr)(ri, 0, 0, 0, &defattr);
266 1.1 uwe wsdisplay_cnattach(&igsfb_stdscreen, ri, 0, 0, defattr);
267 1.1 uwe }
268 1.1 uwe
269 1.1 uwe
270 1.6 uwe printf("%s: %dMB%s, %dx%d, %dbpp\n",
271 1.4 uwe sc->sc_dev.dv_xname,
272 1.4 uwe (u_int32_t)(sc->sc_vmemsz >> 20),
273 1.4 uwe bswap_msg,
274 1.4 uwe ri->ri_width, ri->ri_height, ri->ri_depth);
275 1.1 uwe
276 1.1 uwe /* attach wsdisplay */
277 1.1 uwe waa.console = isconsole;
278 1.1 uwe waa.scrdata = &igsfb_screenlist;
279 1.1 uwe waa.accessops = &igsfb_accessops;
280 1.1 uwe waa.accesscookie = sc;
281 1.1 uwe
282 1.1 uwe config_found(&sc->sc_dev, &waa, wsemuldisplaydevprint);
283 1.1 uwe }
284 1.1 uwe
285 1.1 uwe
286 1.1 uwe /*
287 1.4 uwe * Helper function for igsfb_init_bit_tables().
288 1.4 uwe */
289 1.4 uwe static u_int16_t
290 1.4 uwe igsfb_spread_bits_8(b)
291 1.4 uwe u_int8_t b;
292 1.4 uwe {
293 1.4 uwe u_int16_t s = b;
294 1.4 uwe
295 1.4 uwe s = ((s & 0x00f0) << 4) | (s & 0x000f);
296 1.4 uwe s = ((s & 0x0c0c) << 2) | (s & 0x0303);
297 1.4 uwe s = ((s & 0x2222) << 1) | (s & 0x1111);
298 1.4 uwe return (s);
299 1.4 uwe }
300 1.4 uwe
301 1.4 uwe
302 1.4 uwe /*
303 1.1 uwe * Cursor sprite data are in 2bpp. Incoming image/mask are in 1bpp.
304 1.1 uwe * Prebuild tables to expand 1bpp->2bpp with bswapping if neccessary.
305 1.1 uwe */
306 1.1 uwe static void
307 1.1 uwe igsfb_init_bit_tables(sc)
308 1.1 uwe struct igsfb_softc *sc;
309 1.1 uwe {
310 1.1 uwe struct igs_bittab *tab;
311 1.1 uwe u_int i;
312 1.1 uwe
313 1.1 uwe if (sc->sc_hwflags & IGSFB_HW_BSWAP) {
314 1.1 uwe if (igsfb_bittab_bswap == NULL) {
315 1.1 uwe tab = malloc(sizeof(struct igs_bittab),
316 1.1 uwe M_DEVBUF, M_NOWAIT);
317 1.1 uwe for (i = 0; i < 256; ++i) {
318 1.1 uwe u_int16_t s = igsfb_spread_bits_8(i);
319 1.1 uwe tab->iexpand[i] = bswap16(s);
320 1.1 uwe tab->mexpand[i] = bswap16((s << 1) | s);
321 1.1 uwe }
322 1.1 uwe igsfb_bittab_bswap = tab;
323 1.1 uwe }
324 1.1 uwe sc->sc_bittab = igsfb_bittab_bswap;
325 1.1 uwe } else {
326 1.1 uwe if (igsfb_bittab == NULL) {
327 1.1 uwe tab = malloc(sizeof(struct igs_bittab),
328 1.1 uwe M_DEVBUF, M_NOWAIT);
329 1.1 uwe for (i = 0; i < 256; ++i) {
330 1.1 uwe u_int16_t s = igsfb_spread_bits_8(i);
331 1.1 uwe tab->iexpand[i] = s;
332 1.1 uwe tab->mexpand[i] = (s << 1) | s;
333 1.1 uwe }
334 1.1 uwe igsfb_bittab = tab;
335 1.1 uwe }
336 1.1 uwe sc->sc_bittab = igsfb_bittab;
337 1.1 uwe }
338 1.1 uwe }
339 1.1 uwe
340 1.1 uwe /*
341 1.1 uwe * I/O and memory are mapped, video enabled, structures allocated.
342 1.1 uwe */
343 1.1 uwe static void
344 1.1 uwe igsfb_common_init(sc)
345 1.1 uwe struct igsfb_softc *sc;
346 1.1 uwe {
347 1.1 uwe bus_space_tag_t iot = sc->sc_iot;
348 1.1 uwe bus_space_handle_t ioh = sc->sc_ioh;
349 1.1 uwe struct rasops_info *ri = sc->sc_ri;
350 1.1 uwe int wsfcookie;
351 1.1 uwe const u_int8_t *p;
352 1.1 uwe int i;
353 1.1 uwe
354 1.1 uwe sc->sc_blanked = 0;
355 1.1 uwe
356 1.1 uwe ri->ri_flg = RI_CENTER | RI_CLEAR;
357 1.1 uwe if (sc->sc_hwflags & IGSFB_HW_BSWAP)
358 1.1 uwe ri->ri_flg |= RI_BSWAP;
359 1.1 uwe
360 1.6 uwe /* XXX: deduce these from chip registers */
361 1.1 uwe ri->ri_depth = 8;
362 1.1 uwe ri->ri_width = 1024;
363 1.1 uwe ri->ri_height = 768;
364 1.6 uwe
365 1.1 uwe ri->ri_stride = 1024;
366 1.1 uwe ri->ri_bits = (u_char *)sc->sc_fbh;
367 1.1 uwe
368 1.1 uwe /*
369 1.1 uwe * Initialize wsfont related stuff.
370 1.1 uwe */
371 1.1 uwe wsfont_init();
372 1.1 uwe
373 1.1 uwe /* prefer gallant that is identical to the one the prom uses */
374 1.1 uwe wsfcookie = wsfont_find("Gallant", 12, 22, 0,
375 1.1 uwe WSDISPLAY_FONTORDER_L2R,
376 1.1 uwe WSDISPLAY_FONTORDER_L2R);
377 1.1 uwe if (wsfcookie <= 0) {
378 1.1 uwe #ifdef DIAGNOSTIC
379 1.1 uwe printf("%s: unable to find font Gallant 12x22\n",
380 1.1 uwe sc->sc_dev.dv_xname);
381 1.1 uwe #endif
382 1.1 uwe /* any font at all? */
383 1.1 uwe wsfcookie = wsfont_find(NULL, 0, 0, 0,
384 1.1 uwe WSDISPLAY_FONTORDER_L2R,
385 1.1 uwe WSDISPLAY_FONTORDER_L2R);
386 1.1 uwe }
387 1.1 uwe
388 1.1 uwe if (wsfcookie <= 0) {
389 1.1 uwe printf("%s: unable to find any fonts\n", sc->sc_dev.dv_xname);
390 1.1 uwe return;
391 1.1 uwe }
392 1.1 uwe
393 1.1 uwe if (wsfont_lock(wsfcookie, &ri->ri_font) != 0) {
394 1.1 uwe printf("%s: unable to lock font\n", sc->sc_dev.dv_xname);
395 1.1 uwe return;
396 1.1 uwe }
397 1.1 uwe ri->ri_wsfcookie = wsfcookie;
398 1.1 uwe
399 1.1 uwe
400 1.1 uwe /*
401 1.1 uwe * Initialize colormap related stuff.
402 1.1 uwe */
403 1.1 uwe
404 1.1 uwe /* ANSI color map */
405 1.1 uwe p = rasops_cmap;
406 1.1 uwe for (i = 0; i < IGS_CMAP_SIZE; ++i, p += 3) { /* software copy */
407 1.1 uwe sc->sc_cmap.r[i] = p[0];
408 1.1 uwe sc->sc_cmap.g[i] = p[1];
409 1.1 uwe sc->sc_cmap.b[i] = p[2];
410 1.1 uwe }
411 1.1 uwe igsfb_update_cmap(sc, 0, IGS_CMAP_SIZE);
412 1.1 uwe
413 1.1 uwe /* set overscan color r/g/b (XXX: use defattr's rgb?) */
414 1.1 uwe igs_ext_write(iot, ioh, IGS_EXT_OVERSCAN_RED, 0);
415 1.1 uwe igs_ext_write(iot, ioh, IGS_EXT_OVERSCAN_GREEN, 0);
416 1.1 uwe igs_ext_write(iot, ioh, IGS_EXT_OVERSCAN_BLUE, 0);
417 1.1 uwe
418 1.1 uwe
419 1.1 uwe /* TODO: compute term size based on font dimensions? */
420 1.1 uwe rasops_init(ri, 34, 80);
421 1.1 uwe
422 1.1 uwe igsfb_stdscreen.nrows = ri->ri_rows;
423 1.1 uwe igsfb_stdscreen.ncols = ri->ri_cols;
424 1.1 uwe igsfb_stdscreen.textops = &ri->ri_ops;
425 1.1 uwe igsfb_stdscreen.capabilities = ri->ri_caps;
426 1.1 uwe }
427 1.1 uwe
428 1.1 uwe
429 1.1 uwe /*
430 1.1 uwe * wsdisplay_accessops: mmap()
431 1.4 uwe * XXX: allow mmapping i/o mapped i/o regs if INSECURE???
432 1.1 uwe */
433 1.1 uwe static paddr_t
434 1.1 uwe igsfb_mmap(v, offset, prot)
435 1.1 uwe void *v;
436 1.1 uwe off_t offset;
437 1.1 uwe int prot;
438 1.1 uwe {
439 1.1 uwe struct igsfb_softc *sc = v;
440 1.1 uwe
441 1.1 uwe if (offset >= sc->sc_memsz || offset < 0)
442 1.1 uwe return (-1);
443 1.1 uwe
444 1.1 uwe return (bus_space_mmap(sc->sc_memt, sc->sc_memaddr, offset, prot,
445 1.1 uwe sc->sc_memflags | BUS_SPACE_MAP_LINEAR));
446 1.1 uwe }
447 1.1 uwe
448 1.1 uwe
449 1.1 uwe /*
450 1.1 uwe * wsdisplay_accessops: ioctl()
451 1.1 uwe */
452 1.1 uwe static int
453 1.1 uwe igsfb_ioctl(v, cmd, data, flag, p)
454 1.1 uwe void *v;
455 1.1 uwe u_long cmd;
456 1.1 uwe caddr_t data;
457 1.1 uwe int flag;
458 1.1 uwe struct proc *p;
459 1.1 uwe {
460 1.1 uwe struct igsfb_softc *sc = v;
461 1.1 uwe struct rasops_info *ri = sc->sc_ri;
462 1.1 uwe int turnoff;
463 1.1 uwe
464 1.1 uwe switch (cmd) {
465 1.1 uwe
466 1.1 uwe case WSDISPLAYIO_GTYPE:
467 1.1 uwe *(u_int *)data = WSDISPLAY_TYPE_PCIMISC;
468 1.1 uwe return (0);
469 1.1 uwe
470 1.1 uwe case WSDISPLAYIO_GINFO:
471 1.1 uwe #define wsd_fbip ((struct wsdisplay_fbinfo *)data)
472 1.1 uwe wsd_fbip->height = ri->ri_height;
473 1.1 uwe wsd_fbip->width = ri->ri_width;
474 1.1 uwe wsd_fbip->depth = ri->ri_depth;
475 1.1 uwe wsd_fbip->cmsize = IGS_CMAP_SIZE;
476 1.1 uwe #undef wsd_fbip
477 1.1 uwe return (0);
478 1.1 uwe
479 1.1 uwe case WSDISPLAYIO_GVIDEO:
480 1.1 uwe *(u_int *)data = sc->sc_blanked ?
481 1.1 uwe WSDISPLAYIO_VIDEO_OFF : WSDISPLAYIO_VIDEO_ON;
482 1.1 uwe return (0);
483 1.1 uwe
484 1.1 uwe case WSDISPLAYIO_SVIDEO:
485 1.1 uwe turnoff = (*(u_int *)data == WSDISPLAYIO_VIDEO_OFF);
486 1.1 uwe if (sc->sc_blanked != turnoff) {
487 1.1 uwe sc->sc_blanked = turnoff;
488 1.1 uwe igsfb_blank_screen(sc, sc->sc_blanked);
489 1.1 uwe }
490 1.1 uwe return (0);
491 1.1 uwe
492 1.1 uwe case WSDISPLAYIO_GETCMAP:
493 1.1 uwe return (igsfb_get_cmap(sc, (struct wsdisplay_cmap *)data));
494 1.1 uwe
495 1.1 uwe case WSDISPLAYIO_PUTCMAP:
496 1.1 uwe return (igsfb_set_cmap(sc, (struct wsdisplay_cmap *)data));
497 1.1 uwe
498 1.1 uwe case WSDISPLAYIO_GCURMAX:
499 1.1 uwe ((struct wsdisplay_curpos *)data)->x = IGS_CURSOR_MAX_SIZE;
500 1.1 uwe ((struct wsdisplay_curpos *)data)->y = IGS_CURSOR_MAX_SIZE;
501 1.1 uwe return (0);
502 1.1 uwe
503 1.1 uwe case WSDISPLAYIO_GCURPOS:
504 1.1 uwe *(struct wsdisplay_curpos *)data = sc->sc_cursor.cc_pos;
505 1.1 uwe return (0);
506 1.1 uwe
507 1.1 uwe case WSDISPLAYIO_SCURPOS:
508 1.1 uwe igsfb_set_curpos(sc, (struct wsdisplay_curpos *)data);
509 1.1 uwe return (0);
510 1.1 uwe
511 1.1 uwe case WSDISPLAYIO_GCURSOR:
512 1.1 uwe return (igsfb_get_cursor(sc, (struct wsdisplay_cursor *)data));
513 1.1 uwe
514 1.1 uwe case WSDISPLAYIO_SCURSOR:
515 1.1 uwe return (igsfb_set_cursor(sc, (struct wsdisplay_cursor *)data));
516 1.1 uwe }
517 1.1 uwe
518 1.1 uwe return (EPASSTHROUGH);
519 1.1 uwe }
520 1.1 uwe
521 1.1 uwe
522 1.1 uwe /*
523 1.1 uwe * wsdisplay_accessops: ioctl(WSDISPLAYIO_SVIDEO)
524 1.1 uwe */
525 1.1 uwe static void
526 1.1 uwe igsfb_blank_screen(sc, blank)
527 1.1 uwe struct igsfb_softc *sc;
528 1.1 uwe int blank;
529 1.1 uwe {
530 1.1 uwe
531 1.1 uwe igs_ext_write(sc->sc_iot, sc->sc_ioh,
532 1.1 uwe IGS_EXT_SYNC_CTL,
533 1.1 uwe blank ? IGS_EXT_SYNC_H0 | IGS_EXT_SYNC_V0
534 1.1 uwe : 0);
535 1.1 uwe }
536 1.1 uwe
537 1.1 uwe
538 1.1 uwe /*
539 1.1 uwe * wsdisplay_accessops: ioctl(WSDISPLAYIO_GETCMAP)
540 1.1 uwe * Served from software cmap copy.
541 1.1 uwe */
542 1.1 uwe static int
543 1.1 uwe igsfb_get_cmap(sc, p)
544 1.1 uwe struct igsfb_softc *sc;
545 1.1 uwe struct wsdisplay_cmap *p;
546 1.1 uwe {
547 1.1 uwe u_int index = p->index, count = p->count;
548 1.1 uwe
549 1.5 itojun if (index >= IGS_CMAP_SIZE || count > IGS_CMAP_SIZE - index)
550 1.1 uwe return (EINVAL);
551 1.1 uwe
552 1.1 uwe if (!uvm_useracc(p->red, count, B_WRITE) ||
553 1.1 uwe !uvm_useracc(p->green, count, B_WRITE) ||
554 1.1 uwe !uvm_useracc(p->blue, count, B_WRITE))
555 1.1 uwe return (EFAULT);
556 1.1 uwe
557 1.1 uwe copyout(&sc->sc_cmap.r[index], p->red, count);
558 1.1 uwe copyout(&sc->sc_cmap.g[index], p->green, count);
559 1.1 uwe copyout(&sc->sc_cmap.b[index], p->blue, count);
560 1.1 uwe
561 1.1 uwe return (0);
562 1.1 uwe }
563 1.1 uwe
564 1.1 uwe
565 1.1 uwe /*
566 1.1 uwe * wsdisplay_accessops: ioctl(WSDISPLAYIO_SETCMAP)
567 1.1 uwe * Set software cmap copy and propagate changed range to device.
568 1.1 uwe */
569 1.1 uwe static int
570 1.1 uwe igsfb_set_cmap(sc, p)
571 1.1 uwe struct igsfb_softc *sc;
572 1.1 uwe struct wsdisplay_cmap *p;
573 1.1 uwe {
574 1.1 uwe u_int index = p->index, count = p->count;
575 1.1 uwe
576 1.5 itojun if (index >= IGS_CMAP_SIZE || count > IGS_CMAP_SIZE - index)
577 1.1 uwe return (EINVAL);
578 1.1 uwe
579 1.1 uwe if (!uvm_useracc(p->red, count, B_READ) ||
580 1.1 uwe !uvm_useracc(p->green, count, B_READ) ||
581 1.1 uwe !uvm_useracc(p->blue, count, B_READ))
582 1.1 uwe return (EFAULT);
583 1.1 uwe
584 1.1 uwe copyin(p->red, &sc->sc_cmap.r[index], count);
585 1.1 uwe copyin(p->green, &sc->sc_cmap.g[index], count);
586 1.1 uwe copyin(p->blue, &sc->sc_cmap.b[index], count);
587 1.1 uwe
588 1.1 uwe igsfb_update_cmap(sc, p->index, p->count);
589 1.1 uwe
590 1.1 uwe return (0);
591 1.1 uwe }
592 1.1 uwe
593 1.1 uwe
594 1.1 uwe /*
595 1.1 uwe * Propagate specified part of the software cmap copy to device.
596 1.1 uwe */
597 1.1 uwe static void
598 1.1 uwe igsfb_update_cmap(sc, index, count)
599 1.1 uwe struct igsfb_softc *sc;
600 1.1 uwe u_int index, count;
601 1.1 uwe {
602 1.1 uwe bus_space_tag_t t;
603 1.1 uwe bus_space_handle_t h;
604 1.1 uwe u_int last, i;
605 1.1 uwe
606 1.1 uwe if (index >= IGS_CMAP_SIZE)
607 1.1 uwe return;
608 1.1 uwe
609 1.1 uwe last = index + count;
610 1.1 uwe if (last > IGS_CMAP_SIZE)
611 1.1 uwe last = IGS_CMAP_SIZE;
612 1.1 uwe
613 1.1 uwe t = sc->sc_iot;
614 1.1 uwe h = sc->sc_ioh;
615 1.1 uwe
616 1.1 uwe /* start palette writing, index is autoincremented by hardware */
617 1.1 uwe bus_space_write_1(t, h, IGS_DAC_PEL_WRITE_IDX, index);
618 1.1 uwe
619 1.1 uwe for (i = index; i < last; ++i) {
620 1.1 uwe bus_space_write_1(t, h, IGS_DAC_PEL_DATA, sc->sc_cmap.r[i]);
621 1.1 uwe bus_space_write_1(t, h, IGS_DAC_PEL_DATA, sc->sc_cmap.g[i]);
622 1.1 uwe bus_space_write_1(t, h, IGS_DAC_PEL_DATA, sc->sc_cmap.b[i]);
623 1.1 uwe }
624 1.1 uwe }
625 1.1 uwe
626 1.1 uwe
627 1.1 uwe /*
628 1.1 uwe * wsdisplay_accessops: ioctl(WSDISPLAYIO_SCURPOS)
629 1.1 uwe */
630 1.1 uwe static void
631 1.1 uwe igsfb_set_curpos(sc, curpos)
632 1.1 uwe struct igsfb_softc *sc;
633 1.1 uwe struct wsdisplay_curpos *curpos;
634 1.1 uwe {
635 1.1 uwe struct rasops_info *ri = sc->sc_ri;
636 1.1 uwe int x = curpos->x, y = curpos->y;
637 1.1 uwe
638 1.1 uwe if (y < 0)
639 1.1 uwe y = 0;
640 1.1 uwe else if (y > ri->ri_height)
641 1.1 uwe y = ri->ri_height;
642 1.1 uwe if (x < 0)
643 1.1 uwe x = 0;
644 1.1 uwe else if (x > ri->ri_width)
645 1.1 uwe x = ri->ri_width;
646 1.1 uwe sc->sc_cursor.cc_pos.x = x;
647 1.1 uwe sc->sc_cursor.cc_pos.y = y;
648 1.1 uwe
649 1.1 uwe igsfb_update_curpos(sc);
650 1.1 uwe }
651 1.1 uwe
652 1.1 uwe
653 1.1 uwe static void
654 1.1 uwe igsfb_update_curpos(sc)
655 1.1 uwe struct igsfb_softc *sc;
656 1.1 uwe {
657 1.1 uwe bus_space_tag_t t;
658 1.1 uwe bus_space_handle_t h;
659 1.1 uwe int x, xoff, y, yoff;
660 1.1 uwe
661 1.1 uwe xoff = 0;
662 1.1 uwe x = sc->sc_cursor.cc_pos.x - sc->sc_cursor.cc_hot.x;
663 1.1 uwe if (x < 0) {
664 1.1 uwe x = 0;
665 1.1 uwe xoff = -x;
666 1.1 uwe }
667 1.1 uwe
668 1.1 uwe yoff = 0;
669 1.1 uwe y = sc->sc_cursor.cc_pos.y - sc->sc_cursor.cc_hot.y;
670 1.1 uwe if (y < 0) {
671 1.1 uwe y = 0;
672 1.1 uwe yoff = -y;
673 1.1 uwe }
674 1.1 uwe
675 1.1 uwe t = sc->sc_iot;
676 1.1 uwe h = sc->sc_ioh;
677 1.1 uwe
678 1.1 uwe igs_ext_write(t, h, IGS_EXT_SPRITE_HSTART_LO, x & 0xff);
679 1.1 uwe igs_ext_write(t, h, IGS_EXT_SPRITE_HSTART_HI, (x >> 8) & 0x07);
680 1.1 uwe igs_ext_write(t, h, IGS_EXT_SPRITE_HPRESET, xoff & 0x3f);
681 1.1 uwe
682 1.1 uwe igs_ext_write(t, h, IGS_EXT_SPRITE_VSTART_LO, y & 0xff);
683 1.1 uwe igs_ext_write(t, h, IGS_EXT_SPRITE_VSTART_HI, (y >> 8) & 0x07);
684 1.1 uwe igs_ext_write(t, h, IGS_EXT_SPRITE_VPRESET, yoff & 0x3f);
685 1.1 uwe }
686 1.1 uwe
687 1.1 uwe
688 1.1 uwe /*
689 1.1 uwe * wsdisplay_accessops: ioctl(WSDISPLAYIO_GCURSOR)
690 1.1 uwe */
691 1.1 uwe static int
692 1.1 uwe igsfb_get_cursor(sc, p)
693 1.1 uwe struct igsfb_softc *sc;
694 1.1 uwe struct wsdisplay_cursor *p;
695 1.1 uwe {
696 1.1 uwe
697 1.1 uwe /* XXX: TODO */
698 1.1 uwe return (0);
699 1.1 uwe }
700 1.1 uwe
701 1.1 uwe
702 1.1 uwe /*
703 1.1 uwe * wsdisplay_accessops: ioctl(WSDISPLAYIO_SCURSOR)
704 1.1 uwe */
705 1.1 uwe static int
706 1.1 uwe igsfb_set_cursor(sc, p)
707 1.1 uwe struct igsfb_softc *sc;
708 1.1 uwe struct wsdisplay_cursor *p;
709 1.1 uwe {
710 1.1 uwe struct igs_hwcursor *cc;
711 1.1 uwe u_int v, index, count, icount, iwidth;
712 1.1 uwe
713 1.1 uwe cc = &sc->sc_cursor;
714 1.1 uwe v = p->which;
715 1.1 uwe
716 1.1 uwe if (v & WSDISPLAY_CURSOR_DOCMAP) {
717 1.1 uwe index = p->cmap.index;
718 1.1 uwe count = p->cmap.count;
719 1.1 uwe if (index >= 2 || (index + count) > 2)
720 1.1 uwe return (EINVAL);
721 1.1 uwe if (!uvm_useracc(p->cmap.red, count, B_READ)
722 1.1 uwe || !uvm_useracc(p->cmap.green, count, B_READ)
723 1.1 uwe || !uvm_useracc(p->cmap.blue, count, B_READ))
724 1.1 uwe return (EFAULT);
725 1.1 uwe }
726 1.1 uwe
727 1.1 uwe if (v & WSDISPLAY_CURSOR_DOSHAPE) {
728 1.1 uwe if (p->size.x > IGS_CURSOR_MAX_SIZE
729 1.1 uwe || p->size.y > IGS_CURSOR_MAX_SIZE)
730 1.1 uwe return (EINVAL);
731 1.1 uwe
732 1.1 uwe iwidth = (p->size.x + 7) >> 3; /* bytes per scan line */
733 1.1 uwe icount = iwidth * p->size.y;
734 1.1 uwe if (!uvm_useracc(p->image, icount, B_READ)
735 1.1 uwe || !uvm_useracc(p->mask, icount, B_READ))
736 1.1 uwe return (EFAULT);
737 1.1 uwe }
738 1.1 uwe
739 1.1 uwe /* XXX: verify that hot is within size, pos within screen? */
740 1.1 uwe
741 1.1 uwe /* arguments verified, do the processing */
742 1.1 uwe
743 1.1 uwe if (v & WSDISPLAY_CURSOR_DOCUR)
744 1.1 uwe sc->sc_curenb = p->enable;
745 1.1 uwe
746 1.1 uwe if (v & WSDISPLAY_CURSOR_DOPOS)
747 1.1 uwe cc->cc_pos = p->pos;
748 1.1 uwe
749 1.1 uwe if (v & WSDISPLAY_CURSOR_DOHOT)
750 1.1 uwe cc->cc_hot = p->hot;
751 1.1 uwe
752 1.1 uwe if (v & WSDISPLAY_CURSOR_DOCMAP) {
753 1.1 uwe copyin(p->cmap.red, &cc->cc_color[index], count);
754 1.1 uwe copyin(p->cmap.green, &cc->cc_color[index + 2], count);
755 1.1 uwe copyin(p->cmap.blue, &cc->cc_color[index + 4], count);
756 1.1 uwe }
757 1.1 uwe
758 1.1 uwe if (v & WSDISPLAY_CURSOR_DOSHAPE) {
759 1.1 uwe u_int trailing_bits;
760 1.1 uwe
761 1.1 uwe copyin(p->image, cc->cc_image, icount);
762 1.1 uwe copyin(p->mask, cc->cc_mask, icount);
763 1.1 uwe cc->cc_size = p->size;
764 1.1 uwe
765 1.1 uwe /* clear trailing bits in the "partial" mask bytes */
766 1.1 uwe trailing_bits = p->size.x & 0x07;
767 1.1 uwe if (trailing_bits != 0) {
768 1.1 uwe const u_int cutmask = ~((~0) << trailing_bits);
769 1.1 uwe u_char *mp;
770 1.1 uwe u_int i;
771 1.1 uwe
772 1.1 uwe mp = cc->cc_mask + iwidth - 1;
773 1.1 uwe for (i = 0; i < p->size.y; ++i) {
774 1.1 uwe *mp &= cutmask;
775 1.1 uwe mp += iwidth;
776 1.1 uwe }
777 1.1 uwe }
778 1.1 uwe igsfb_convert_cursor_data(sc, iwidth, p->size.y);
779 1.1 uwe }
780 1.1 uwe
781 1.1 uwe igsfb_update_cursor(sc, v);
782 1.1 uwe return (0);
783 1.1 uwe }
784 1.1 uwe
785 1.4 uwe
786 1.1 uwe /*
787 1.1 uwe * Convert incoming 1bpp cursor image/mask into native 2bpp format.
788 1.1 uwe */
789 1.1 uwe static void
790 1.1 uwe igsfb_convert_cursor_data(sc, w, h)
791 1.1 uwe struct igsfb_softc *sc;
792 1.1 uwe u_int w, h;
793 1.1 uwe {
794 1.1 uwe struct igs_hwcursor *cc = &sc->sc_cursor;
795 1.1 uwe struct igs_bittab *btab = sc->sc_bittab;
796 1.1 uwe u_int8_t *ip, *mp;
797 1.1 uwe u_int16_t *dp;
798 1.1 uwe u_int line, i;
799 1.1 uwe
800 1.1 uwe /* init sprite to be all transparent */
801 1.1 uwe memset(cc->cc_sprite, 0xaa, IGS_CURSOR_DATA_SIZE);
802 1.1 uwe
803 1.1 uwe /* first scanline */
804 1.1 uwe ip = cc->cc_image;
805 1.1 uwe mp = cc->cc_mask;
806 1.1 uwe dp = cc->cc_sprite;
807 1.1 uwe
808 1.1 uwe for (line = 0; line < h; ++line) {
809 1.1 uwe for (i = 0; i < w; ++i) {
810 1.1 uwe u_int16_t is = btab->iexpand[ip[i]];
811 1.1 uwe u_int16_t ms = btab->mexpand[mp[i]];
812 1.1 uwe
813 1.1 uwe /* NB: tables are pre-bswapped if needed */
814 1.1 uwe dp[i] = (0xaaaa & ~ms) | (is & ms);
815 1.1 uwe }
816 1.1 uwe
817 1.1 uwe /* next scanline */
818 1.1 uwe ip += w;
819 1.1 uwe mp += w;
820 1.1 uwe dp += 8; /* 2bpp, 8 pixels per short = 8 shorts */
821 1.1 uwe }
822 1.1 uwe }
823 1.1 uwe
824 1.1 uwe
825 1.1 uwe /*
826 1.1 uwe * Propagate cursor changes to device.
827 1.1 uwe * "which" is composed from WSDISPLAY_CURSOR_DO* bits.
828 1.1 uwe */
829 1.1 uwe static void
830 1.1 uwe igsfb_update_cursor(sc, which)
831 1.1 uwe struct igsfb_softc *sc;
832 1.1 uwe u_int which;
833 1.1 uwe {
834 1.1 uwe bus_space_tag_t iot = sc->sc_iot;
835 1.1 uwe bus_space_handle_t ioh = sc->sc_ioh;
836 1.1 uwe u_int8_t curctl;
837 1.1 uwe
838 1.1 uwe /*
839 1.1 uwe * We will need to tweak sprite control register for cursor
840 1.1 uwe * visibility and cursor color map manipualtion.
841 1.1 uwe */
842 1.1 uwe if (which & (WSDISPLAY_CURSOR_DOCUR | WSDISPLAY_CURSOR_DOCMAP)) {
843 1.1 uwe curctl = igs_ext_read(iot, ioh, IGS_EXT_SPRITE_CTL);
844 1.1 uwe }
845 1.1 uwe
846 1.1 uwe if (which & WSDISPLAY_CURSOR_DOSHAPE) {
847 1.1 uwe u_int8_t *dst = bus_space_vaddr(sc->sc_memt, sc->sc_crh);
848 1.1 uwe
849 1.1 uwe /*
850 1.1 uwe * memcpy between spaces of different endianness would
851 1.1 uwe * be ... special. We cannot be sure if memset gonna
852 1.1 uwe * push data in 4-byte chunks, we can't pre-bswap it,
853 1.1 uwe * so do it byte-by-byte to preserve byte ordering.
854 1.1 uwe */
855 1.1 uwe if (sc->sc_hwflags & IGSFB_HW_BSWAP) {
856 1.1 uwe u_int8_t *src = (u_int8_t *)sc->sc_cursor.cc_sprite;
857 1.1 uwe int i;
858 1.1 uwe
859 1.1 uwe for (i = 0; i < 1024; ++i)
860 1.1 uwe *dst++ = *src++;
861 1.1 uwe } else {
862 1.1 uwe memcpy(dst, sc->sc_cursor.cc_sprite, 1024);
863 1.1 uwe }
864 1.1 uwe }
865 1.1 uwe
866 1.1 uwe if (which & (WSDISPLAY_CURSOR_DOPOS | WSDISPLAY_CURSOR_DOHOT)) {
867 1.1 uwe /* code shared with WSDISPLAYIO_SCURPOS */
868 1.1 uwe igsfb_update_curpos(sc);
869 1.1 uwe }
870 1.1 uwe
871 1.1 uwe if (which & WSDISPLAY_CURSOR_DOCMAP) {
872 1.1 uwe u_int8_t *p;
873 1.1 uwe
874 1.1 uwe /* tell DAC we want access to the cursor palette */
875 1.1 uwe igs_ext_write(iot, ioh, IGS_EXT_SPRITE_CTL,
876 1.4 uwe curctl | IGS_EXT_SPRITE_DAC_PEL);
877 1.1 uwe
878 1.1 uwe p = sc->sc_cursor.cc_color;
879 1.1 uwe
880 1.1 uwe bus_space_write_1(iot, ioh, IGS_DAC_PEL_WRITE_IDX, 0);
881 1.1 uwe bus_space_write_1(iot, ioh, IGS_DAC_PEL_DATA, p[0]);
882 1.1 uwe bus_space_write_1(iot, ioh, IGS_DAC_PEL_DATA, p[2]);
883 1.1 uwe bus_space_write_1(iot, ioh, IGS_DAC_PEL_DATA, p[4]);
884 1.1 uwe
885 1.1 uwe bus_space_write_1(iot, ioh, IGS_DAC_PEL_WRITE_IDX, 1);
886 1.1 uwe bus_space_write_1(iot, ioh, IGS_DAC_PEL_DATA, p[1]);
887 1.1 uwe bus_space_write_1(iot, ioh, IGS_DAC_PEL_DATA, p[3]);
888 1.1 uwe bus_space_write_1(iot, ioh, IGS_DAC_PEL_DATA, p[5]);
889 1.1 uwe
890 1.1 uwe /* restore access to normal palette */
891 1.1 uwe igs_ext_write(iot, ioh, IGS_EXT_SPRITE_CTL, curctl);
892 1.1 uwe }
893 1.1 uwe
894 1.1 uwe if (which & WSDISPLAY_CURSOR_DOCUR) {
895 1.1 uwe if ((curctl & IGS_EXT_SPRITE_VISIBLE) == 0
896 1.1 uwe && sc->sc_curenb)
897 1.1 uwe igs_ext_write(iot, ioh, IGS_EXT_SPRITE_CTL,
898 1.1 uwe curctl | IGS_EXT_SPRITE_VISIBLE);
899 1.1 uwe else if ((curctl & IGS_EXT_SPRITE_VISIBLE) != 0
900 1.1 uwe && !sc->sc_curenb)
901 1.1 uwe igs_ext_write(iot, ioh, IGS_EXT_SPRITE_CTL,
902 1.1 uwe curctl & ~IGS_EXT_SPRITE_VISIBLE);
903 1.1 uwe }
904 1.1 uwe }
905 1.1 uwe
906 1.1 uwe
907 1.1 uwe /*
908 1.1 uwe * wsdisplay_accessops: alloc_screen()
909 1.1 uwe */
910 1.1 uwe static int
911 1.1 uwe igsfb_alloc_screen(v, type, cookiep, curxp, curyp, attrp)
912 1.1 uwe void *v;
913 1.1 uwe const struct wsscreen_descr *type;
914 1.1 uwe void **cookiep;
915 1.1 uwe int *curxp, *curyp;
916 1.1 uwe long *attrp;
917 1.1 uwe {
918 1.1 uwe
919 1.1 uwe /* TODO */
920 1.1 uwe return (ENOMEM);
921 1.1 uwe }
922 1.1 uwe
923 1.1 uwe
924 1.1 uwe /*
925 1.1 uwe * wsdisplay_accessops: free_screen()
926 1.1 uwe */
927 1.1 uwe static void
928 1.1 uwe igsfb_free_screen(v, cookie)
929 1.1 uwe void *v;
930 1.1 uwe void *cookie;
931 1.1 uwe {
932 1.1 uwe
933 1.1 uwe /* TODO */
934 1.1 uwe return;
935 1.1 uwe }
936 1.1 uwe
937 1.1 uwe
938 1.1 uwe /*
939 1.1 uwe * wsdisplay_accessops: show_screen()
940 1.1 uwe */
941 1.1 uwe static int
942 1.1 uwe igsfb_show_screen(v, cookie, waitok, cb, cbarg)
943 1.1 uwe void *v;
944 1.1 uwe void *cookie;
945 1.1 uwe int waitok;
946 1.1 uwe void (*cb)(void *, int, int);
947 1.1 uwe void *cbarg;
948 1.1 uwe {
949 1.1 uwe
950 1.1 uwe return (0);
951 1.1 uwe }
952