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