igsfb.c revision 1.29 1 1.29 uwe /* $NetBSD: igsfb.c,v 1.29 2006/04/03 20:44:35 uwe Exp $ */
2 1.1 uwe
3 1.1 uwe /*
4 1.8 uwe * Copyright (c) 2002, 2003 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.1 uwe */
33 1.1 uwe #include <sys/cdefs.h>
34 1.29 uwe __KERNEL_RCSID(0, "$NetBSD: igsfb.c,v 1.29 2006/04/03 20:44:35 uwe 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.8 uwe #include <dev/wscons/wsconsio.h>
49 1.8 uwe #include <dev/wsfont/wsfont.h>
50 1.1 uwe #include <dev/rasops/rasops.h>
51 1.1 uwe
52 1.27 macallan #include <dev/wscons/wsdisplay_vconsvar.h>
53 1.27 macallan
54 1.1 uwe #include <dev/ic/igsfbreg.h>
55 1.1 uwe #include <dev/ic/igsfbvar.h>
56 1.1 uwe
57 1.27 macallan #include "opt_wsemul.h"
58 1.1 uwe
59 1.8 uwe struct igsfb_devconfig igsfb_console_dc;
60 1.8 uwe
61 1.1 uwe /*
62 1.1 uwe * wsscreen
63 1.1 uwe */
64 1.1 uwe
65 1.1 uwe /* filled from rasops_info in igsfb_common_init */
66 1.1 uwe static struct wsscreen_descr igsfb_stdscreen = {
67 1.1 uwe "std", /* name */
68 1.1 uwe 0, 0, /* ncols, nrows */
69 1.1 uwe NULL, /* textops */
70 1.1 uwe 0, 0, /* fontwidth, fontheight */
71 1.1 uwe 0 /* capabilities */
72 1.1 uwe };
73 1.1 uwe
74 1.1 uwe static const struct wsscreen_descr *_igsfb_scrlist[] = {
75 1.1 uwe &igsfb_stdscreen,
76 1.1 uwe };
77 1.1 uwe
78 1.1 uwe static const struct wsscreen_list igsfb_screenlist = {
79 1.1 uwe sizeof(_igsfb_scrlist) / sizeof(struct wsscreen_descr *),
80 1.1 uwe _igsfb_scrlist
81 1.1 uwe };
82 1.1 uwe
83 1.1 uwe
84 1.1 uwe /*
85 1.1 uwe * wsdisplay_accessops
86 1.1 uwe */
87 1.1 uwe
88 1.26 christos static int igsfb_ioctl(void *, u_long, caddr_t, int, struct lwp *);
89 1.1 uwe static paddr_t igsfb_mmap(void *, off_t, int);
90 1.1 uwe
91 1.27 macallan static struct wsdisplay_accessops igsfb_accessops = {
92 1.1 uwe igsfb_ioctl,
93 1.1 uwe igsfb_mmap,
94 1.27 macallan NULL,
95 1.27 macallan NULL,
96 1.27 macallan NULL,
97 1.11 uwe NULL, /* load_font */
98 1.11 uwe NULL, /* pollc */
99 1.11 uwe NULL, /* getwschar */
100 1.11 uwe NULL /* putwschar */
101 1.1 uwe };
102 1.1 uwe
103 1.1 uwe
104 1.1 uwe /*
105 1.11 uwe * acceleration
106 1.11 uwe */
107 1.27 macallan static int igsfb_make_text_cursor(struct igsfb_devconfig *,
108 1.27 macallan struct vcons_screen *);
109 1.11 uwe static void igsfb_accel_cursor(void *, int, int, int);
110 1.11 uwe
111 1.12 uwe static int igsfb_accel_wait(struct igsfb_devconfig *);
112 1.12 uwe static void igsfb_accel_fill(struct igsfb_devconfig *,
113 1.19 uwe uint32_t, uint32_t, uint16_t, uint16_t);
114 1.12 uwe static void igsfb_accel_copy(struct igsfb_devconfig *,
115 1.19 uwe uint32_t, uint32_t, uint16_t, uint16_t);
116 1.12 uwe
117 1.12 uwe static void igsfb_accel_copycols(void *, int, int, int, int);
118 1.12 uwe static void igsfb_accel_erasecols(void *, int, int, int, long);
119 1.12 uwe static void igsfb_accel_copyrows(void *, int, int, int);
120 1.12 uwe static void igsfb_accel_eraserows(void *, int, int, long);
121 1.12 uwe static void igsfb_accel_putchar(void *, int, int, u_int, long);
122 1.12 uwe
123 1.11 uwe
124 1.11 uwe /*
125 1.1 uwe * internal functions
126 1.1 uwe */
127 1.8 uwe static int igsfb_init_video(struct igsfb_devconfig *);
128 1.8 uwe static void igsfb_init_cmap(struct igsfb_devconfig *);
129 1.19 uwe static uint16_t igsfb_spread_bits_8(uint8_t);
130 1.10 uwe static void igsfb_init_bit_table(struct igsfb_devconfig *);
131 1.27 macallan static void igsfb_init_wsdisplay(void *, struct vcons_screen *, int,
132 1.27 macallan long *);
133 1.27 macallan
134 1.8 uwe
135 1.8 uwe static void igsfb_blank_screen(struct igsfb_devconfig *, int);
136 1.8 uwe static int igsfb_get_cmap(struct igsfb_devconfig *,
137 1.8 uwe struct wsdisplay_cmap *);
138 1.8 uwe static int igsfb_set_cmap(struct igsfb_devconfig *,
139 1.9 uwe const struct wsdisplay_cmap *);
140 1.8 uwe static void igsfb_update_cmap(struct igsfb_devconfig *, u_int, u_int);
141 1.8 uwe static void igsfb_set_curpos(struct igsfb_devconfig *,
142 1.9 uwe const struct wsdisplay_curpos *);
143 1.8 uwe static void igsfb_update_curpos(struct igsfb_devconfig *);
144 1.8 uwe static int igsfb_get_cursor(struct igsfb_devconfig *,
145 1.1 uwe struct wsdisplay_cursor *);
146 1.8 uwe static int igsfb_set_cursor(struct igsfb_devconfig *,
147 1.9 uwe const struct wsdisplay_cursor *);
148 1.8 uwe static void igsfb_update_cursor(struct igsfb_devconfig *, u_int);
149 1.8 uwe static void igsfb_convert_cursor_data(struct igsfb_devconfig *,
150 1.8 uwe u_int, u_int);
151 1.8 uwe
152 1.8 uwe
153 1.8 uwe int
154 1.8 uwe igsfb_cnattach_subr(dc)
155 1.8 uwe struct igsfb_devconfig *dc;
156 1.8 uwe {
157 1.8 uwe struct rasops_info *ri;
158 1.8 uwe long defattr;
159 1.1 uwe
160 1.8 uwe KASSERT(dc == &igsfb_console_dc);
161 1.8 uwe
162 1.8 uwe igsfb_init_video(dc);
163 1.27 macallan dc->dc_vd.active = NULL;
164 1.27 macallan igsfb_init_wsdisplay(dc, &dc->dc_console, 1, &defattr);
165 1.1 uwe
166 1.27 macallan ri = &dc->dc_console.scr_ri;
167 1.27 macallan ri->ri_hw = &dc->dc_console;
168 1.27 macallan dc->dc_console.scr_cookie = dc;
169 1.27 macallan
170 1.8 uwe (*ri->ri_ops.allocattr)(ri,
171 1.27 macallan WS_DEFAULT_FG, /* fg */
172 1.27 macallan WS_DEFAULT_BG, /* bg */
173 1.8 uwe 0, /* wsattrs */
174 1.8 uwe &defattr);
175 1.8 uwe
176 1.8 uwe wsdisplay_cnattach(&igsfb_stdscreen,
177 1.8 uwe ri, /* emulcookie */
178 1.8 uwe 0, 0, /* cursor position */
179 1.8 uwe defattr);
180 1.8 uwe return (0);
181 1.8 uwe }
182 1.1 uwe
183 1.1 uwe
184 1.1 uwe /*
185 1.1 uwe * Finish off the attach. Bus specific attach method should have
186 1.8 uwe * enabled io and memory accesses and mapped io (and cop?) registers.
187 1.1 uwe */
188 1.1 uwe void
189 1.8 uwe igsfb_attach_subr(sc, isconsole)
190 1.1 uwe struct igsfb_softc *sc;
191 1.1 uwe int isconsole;
192 1.1 uwe {
193 1.8 uwe struct igsfb_devconfig *dc = sc->sc_dc;
194 1.8 uwe struct wsemuldisplaydev_attach_args waa;
195 1.27 macallan struct rasops_info *ri;
196 1.27 macallan long defattr;
197 1.8 uwe
198 1.8 uwe KASSERT(dc != NULL);
199 1.8 uwe
200 1.8 uwe if (!isconsole) {
201 1.8 uwe igsfb_init_video(dc);
202 1.8 uwe }
203 1.8 uwe
204 1.27 macallan vcons_init(&dc->dc_vd, dc, &igsfb_stdscreen, &igsfb_accessops);
205 1.27 macallan dc->dc_vd.init_screen = igsfb_init_wsdisplay;
206 1.27 macallan
207 1.27 macallan vcons_init_screen(&dc->dc_vd, &dc->dc_console, 1, &defattr);
208 1.27 macallan dc->dc_console.scr_flags |= VCONS_SCREEN_IS_STATIC;
209 1.27 macallan
210 1.8 uwe printf("%s: %dMB, %s%dx%d, %dbpp\n",
211 1.8 uwe sc->sc_dev.dv_xname,
212 1.19 uwe (uint32_t)(dc->dc_vmemsz >> 20),
213 1.8 uwe (dc->dc_hwflags & IGSFB_HW_BSWAP)
214 1.8 uwe ? (dc->dc_hwflags & IGSFB_HW_BE_SELECT)
215 1.8 uwe ? "hardware bswap, " : "software bswap, "
216 1.8 uwe : "",
217 1.8 uwe dc->dc_width, dc->dc_height, dc->dc_depth);
218 1.8 uwe
219 1.27 macallan ri = &dc->dc_console.scr_ri;
220 1.27 macallan ri->ri_ops.eraserows(ri, 0, ri->ri_rows, defattr);
221 1.27 macallan
222 1.8 uwe /* attach wsdisplay */
223 1.8 uwe waa.console = isconsole;
224 1.8 uwe waa.scrdata = &igsfb_screenlist;
225 1.8 uwe waa.accessops = &igsfb_accessops;
226 1.27 macallan waa.accesscookie = &dc->dc_vd;
227 1.8 uwe
228 1.8 uwe config_found(&sc->sc_dev, &waa, wsemuldisplaydevprint);
229 1.8 uwe }
230 1.8 uwe
231 1.8 uwe
232 1.8 uwe static int
233 1.8 uwe igsfb_init_video(dc)
234 1.8 uwe struct igsfb_devconfig *dc;
235 1.8 uwe {
236 1.4 uwe bus_space_handle_t tmph;
237 1.19 uwe uint8_t *p;
238 1.4 uwe int need_bswap;
239 1.8 uwe bus_addr_t fbaddr, craddr;
240 1.1 uwe off_t croffset;
241 1.19 uwe uint8_t busctl, curctl;
242 1.1 uwe
243 1.8 uwe /* Total amount of video memory. */
244 1.8 uwe busctl = igs_ext_read(dc->dc_iot, dc->dc_ioh, IGS_EXT_BUS_CTL);
245 1.1 uwe if (busctl & 0x2)
246 1.8 uwe dc->dc_vmemsz = 4;
247 1.1 uwe else if (busctl & 0x1)
248 1.8 uwe dc->dc_vmemsz = 2;
249 1.1 uwe else
250 1.8 uwe dc->dc_vmemsz = 1;
251 1.8 uwe dc->dc_vmemsz <<= 20; /* megabytes -> bytes */
252 1.4 uwe
253 1.4 uwe /*
254 1.8 uwe * Check for endianness mismatch by writing a word at the end of
255 1.8 uwe * the video memory (off-screen) and reading it back byte-by-byte.
256 1.4 uwe */
257 1.8 uwe if (bus_space_map(dc->dc_memt,
258 1.19 uwe dc->dc_memaddr + dc->dc_vmemsz - sizeof(uint32_t),
259 1.19 uwe sizeof(uint32_t),
260 1.8 uwe dc->dc_memflags | BUS_SPACE_MAP_LINEAR,
261 1.4 uwe &tmph) != 0)
262 1.4 uwe {
263 1.4 uwe printf("unable to map video memory for endianness test\n");
264 1.8 uwe return (1);
265 1.4 uwe }
266 1.4 uwe
267 1.8 uwe p = bus_space_vaddr(dc->dc_memt, tmph);
268 1.4 uwe #if BYTE_ORDER == BIG_ENDIAN
269 1.19 uwe *((uint32_t *)p) = 0x12345678;
270 1.4 uwe #else
271 1.19 uwe *((uint32_t *)p) = 0x78563412;
272 1.4 uwe #endif
273 1.4 uwe if (p[0] == 0x12 && p[1] == 0x34 && p[2] == 0x56 && p[3] == 0x78)
274 1.4 uwe need_bswap = 0;
275 1.4 uwe else
276 1.4 uwe need_bswap = 1;
277 1.4 uwe
278 1.19 uwe bus_space_unmap(dc->dc_memt, tmph, sizeof(uint32_t));
279 1.4 uwe
280 1.4 uwe /*
281 1.4 uwe * On CyberPro we can use magic bswap bit in linear address.
282 1.4 uwe */
283 1.8 uwe fbaddr = dc->dc_memaddr;
284 1.8 uwe if (need_bswap) {
285 1.8 uwe dc->dc_hwflags |= IGSFB_HW_BSWAP;
286 1.8 uwe if (dc->dc_id >= 0x2000) {
287 1.8 uwe dc->dc_hwflags |= IGSFB_HW_BE_SELECT;
288 1.4 uwe fbaddr |= IGS_MEM_BE_SELECT;
289 1.4 uwe }
290 1.8 uwe }
291 1.8 uwe
292 1.8 uwe /*
293 1.8 uwe * XXX: TODO: make it possible to select the desired video mode.
294 1.8 uwe * For now - hardcode to 1024x768/8bpp. This is what Krups OFW uses.
295 1.8 uwe */
296 1.8 uwe igsfb_hw_setup(dc);
297 1.14 uwe delay(10000); /* XXX: uwe */
298 1.8 uwe
299 1.8 uwe dc->dc_width = 1024;
300 1.8 uwe dc->dc_height = 768;
301 1.8 uwe dc->dc_depth = 8;
302 1.1 uwe
303 1.1 uwe /*
304 1.8 uwe * Don't map in all N megs, just the amount we need for the wsscreen.
305 1.1 uwe */
306 1.8 uwe dc->dc_fbsz = dc->dc_width * dc->dc_height; /* XXX: 8bpp specific */
307 1.8 uwe if (bus_space_map(dc->dc_memt, fbaddr, dc->dc_fbsz,
308 1.8 uwe dc->dc_memflags | BUS_SPACE_MAP_LINEAR,
309 1.8 uwe &dc->dc_fbh) != 0)
310 1.1 uwe {
311 1.8 uwe bus_space_unmap(dc->dc_iot, dc->dc_ioh, IGS_REG_SIZE);
312 1.1 uwe printf("unable to map framebuffer\n");
313 1.8 uwe return (1);
314 1.1 uwe }
315 1.1 uwe
316 1.8 uwe igsfb_init_cmap(dc);
317 1.8 uwe
318 1.1 uwe /*
319 1.8 uwe * 1KB for cursor sprite data at the very end of the video memory.
320 1.1 uwe */
321 1.8 uwe croffset = dc->dc_vmemsz - IGS_CURSOR_DATA_SIZE;
322 1.4 uwe craddr = fbaddr + croffset;
323 1.8 uwe if (bus_space_map(dc->dc_memt, craddr, IGS_CURSOR_DATA_SIZE,
324 1.8 uwe dc->dc_memflags | BUS_SPACE_MAP_LINEAR,
325 1.8 uwe &dc->dc_crh) != 0)
326 1.1 uwe {
327 1.8 uwe bus_space_unmap(dc->dc_iot, dc->dc_ioh, IGS_REG_SIZE);
328 1.8 uwe bus_space_unmap(dc->dc_memt, dc->dc_fbh, dc->dc_fbsz);
329 1.1 uwe printf("unable to map cursor sprite region\n");
330 1.8 uwe return (1);
331 1.1 uwe }
332 1.1 uwe
333 1.1 uwe /*
334 1.8 uwe * Tell the device where cursor sprite data are located in the
335 1.8 uwe * linear space (it takes data offset in 1KB units).
336 1.1 uwe */
337 1.8 uwe croffset >>= 10; /* bytes -> kilobytes */
338 1.8 uwe igs_ext_write(dc->dc_iot, dc->dc_ioh,
339 1.1 uwe IGS_EXT_SPRITE_DATA_LO, croffset & 0xff);
340 1.8 uwe igs_ext_write(dc->dc_iot, dc->dc_ioh,
341 1.1 uwe IGS_EXT_SPRITE_DATA_HI, (croffset >> 8) & 0xf);
342 1.1 uwe
343 1.10 uwe /* init the bit expansion table for cursor sprite data conversion */
344 1.10 uwe igsfb_init_bit_table(dc);
345 1.8 uwe
346 1.8 uwe /* XXX: fill dc_cursor and use igsfb_update_cursor() instead? */
347 1.8 uwe memset(&dc->dc_cursor, 0, sizeof(struct igs_hwcursor));
348 1.8 uwe memset(bus_space_vaddr(dc->dc_memt, dc->dc_crh),
349 1.8 uwe /* transparent */ 0xaa, IGS_CURSOR_DATA_SIZE);
350 1.1 uwe
351 1.8 uwe curctl = igs_ext_read(dc->dc_iot, dc->dc_ioh, IGS_EXT_SPRITE_CTL);
352 1.1 uwe curctl |= IGS_EXT_SPRITE_64x64;
353 1.1 uwe curctl &= ~IGS_EXT_SPRITE_VISIBLE;
354 1.8 uwe igs_ext_write(dc->dc_iot, dc->dc_ioh, IGS_EXT_SPRITE_CTL, curctl);
355 1.8 uwe dc->dc_curenb = 0;
356 1.1 uwe
357 1.12 uwe /*
358 1.18 uwe * Map and init graphic coprocessor for accelerated rasops.
359 1.12 uwe */
360 1.12 uwe if (dc->dc_id >= 0x2000) { /* XXX */
361 1.12 uwe if (bus_space_map(dc->dc_iot,
362 1.12 uwe dc->dc_iobase + IGS_COP_BASE_B, IGS_COP_SIZE,
363 1.12 uwe dc->dc_ioflags,
364 1.12 uwe &dc->dc_coph) != 0)
365 1.12 uwe {
366 1.12 uwe printf("unable to map COP registers\n");
367 1.12 uwe return (1);
368 1.12 uwe }
369 1.12 uwe
370 1.12 uwe /* XXX: hardcoded 8bpp */
371 1.12 uwe bus_space_write_2(dc->dc_iot, dc->dc_coph,
372 1.12 uwe IGS_COP_SRC_MAP_WIDTH_REG,
373 1.12 uwe dc->dc_width - 1);
374 1.12 uwe bus_space_write_2(dc->dc_iot, dc->dc_coph,
375 1.12 uwe IGS_COP_DST_MAP_WIDTH_REG,
376 1.12 uwe dc->dc_width - 1);
377 1.12 uwe
378 1.12 uwe bus_space_write_1(dc->dc_iot, dc->dc_coph,
379 1.12 uwe IGS_COP_MAP_FMT_REG,
380 1.12 uwe IGS_COP_MAP_8BPP);
381 1.12 uwe }
382 1.12 uwe
383 1.8 uwe /* make sure screen is not blanked */
384 1.8 uwe dc->dc_blanked = 0;
385 1.8 uwe igsfb_blank_screen(dc, dc->dc_blanked);
386 1.1 uwe
387 1.8 uwe return (0);
388 1.1 uwe }
389 1.1 uwe
390 1.1 uwe
391 1.8 uwe static void
392 1.8 uwe igsfb_init_cmap(dc)
393 1.8 uwe struct igsfb_devconfig *dc;
394 1.4 uwe {
395 1.8 uwe bus_space_tag_t iot = dc->dc_iot;
396 1.8 uwe bus_space_handle_t ioh = dc->dc_ioh;
397 1.19 uwe const uint8_t *p;
398 1.8 uwe int i;
399 1.4 uwe
400 1.8 uwe p = rasops_cmap; /* "ANSI" color map */
401 1.4 uwe
402 1.8 uwe /* init software copy */
403 1.8 uwe for (i = 0; i < IGS_CMAP_SIZE; ++i, p += 3) {
404 1.8 uwe dc->dc_cmap.r[i] = p[0];
405 1.8 uwe dc->dc_cmap.g[i] = p[1];
406 1.8 uwe dc->dc_cmap.b[i] = p[2];
407 1.8 uwe }
408 1.4 uwe
409 1.8 uwe /* propagate to the device */
410 1.8 uwe igsfb_update_cmap(dc, 0, IGS_CMAP_SIZE);
411 1.1 uwe
412 1.11 uwe /* set overscan color (XXX: use defattr's background?) */
413 1.8 uwe igs_ext_write(iot, ioh, IGS_EXT_OVERSCAN_RED, 0);
414 1.8 uwe igs_ext_write(iot, ioh, IGS_EXT_OVERSCAN_GREEN, 0);
415 1.8 uwe igs_ext_write(iot, ioh, IGS_EXT_OVERSCAN_BLUE, 0);
416 1.1 uwe }
417 1.1 uwe
418 1.8 uwe
419 1.1 uwe static void
420 1.27 macallan igsfb_init_wsdisplay(void *cookie, struct vcons_screen *scr, int existing,
421 1.27 macallan long *defattr)
422 1.1 uwe {
423 1.27 macallan struct igsfb_devconfig *dc = cookie;
424 1.27 macallan struct rasops_info *ri = &scr->scr_ri;
425 1.1 uwe int wsfcookie;
426 1.1 uwe
427 1.27 macallan if ((scr == &dc->dc_console) && (dc->dc_vd.active != NULL))
428 1.27 macallan return;
429 1.27 macallan
430 1.1 uwe
431 1.28 macallan ri->ri_flg = RI_CENTER | RI_FULLCLEAR;
432 1.8 uwe if (IGSFB_HW_SOFT_BSWAP(dc))
433 1.1 uwe ri->ri_flg |= RI_BSWAP;
434 1.1 uwe
435 1.8 uwe ri->ri_depth = dc->dc_depth;
436 1.8 uwe ri->ri_width = dc->dc_width;
437 1.8 uwe ri->ri_height = dc->dc_height;
438 1.6 uwe
439 1.8 uwe ri->ri_stride = dc->dc_width; /* XXX: 8bpp specific */
440 1.8 uwe ri->ri_bits = (u_char *)dc->dc_fbh;
441 1.1 uwe
442 1.1 uwe /*
443 1.1 uwe * Initialize wsfont related stuff.
444 1.1 uwe */
445 1.1 uwe wsfont_init();
446 1.1 uwe
447 1.1 uwe /* prefer gallant that is identical to the one the prom uses */
448 1.1 uwe wsfcookie = wsfont_find("Gallant", 12, 22, 0,
449 1.1 uwe WSDISPLAY_FONTORDER_L2R,
450 1.1 uwe WSDISPLAY_FONTORDER_L2R);
451 1.1 uwe if (wsfcookie <= 0) {
452 1.1 uwe #ifdef DIAGNOSTIC
453 1.8 uwe printf("unable to find font Gallant 12x22\n");
454 1.1 uwe #endif
455 1.8 uwe wsfcookie = wsfont_find(NULL, 0, 0, 0, /* any font at all? */
456 1.1 uwe WSDISPLAY_FONTORDER_L2R,
457 1.1 uwe WSDISPLAY_FONTORDER_L2R);
458 1.1 uwe }
459 1.1 uwe
460 1.1 uwe if (wsfcookie <= 0) {
461 1.8 uwe printf("unable to find any fonts\n");
462 1.1 uwe return;
463 1.1 uwe }
464 1.1 uwe
465 1.1 uwe if (wsfont_lock(wsfcookie, &ri->ri_font) != 0) {
466 1.8 uwe printf("unable to lock font\n");
467 1.1 uwe return;
468 1.1 uwe }
469 1.1 uwe ri->ri_wsfcookie = wsfcookie;
470 1.1 uwe
471 1.1 uwe
472 1.11 uwe /* XXX: TODO: compute term size based on font dimensions? */
473 1.1 uwe rasops_init(ri, 34, 80);
474 1.22 macallan rasops_reconfig(ri, ri->ri_height / ri->ri_font->fontheight,
475 1.22 macallan ri->ri_width / ri->ri_font->fontwidth);
476 1.1 uwe
477 1.12 uwe
478 1.11 uwe /* use the sprite for the text mode cursor */
479 1.27 macallan igsfb_make_text_cursor(dc, scr);
480 1.11 uwe
481 1.11 uwe /* the cursor is "busy" while we are in the text mode */
482 1.11 uwe dc->dc_hwflags |= IGSFB_HW_TEXT_CURSOR;
483 1.11 uwe
484 1.11 uwe /* propagate sprite data to the device */
485 1.11 uwe igsfb_update_cursor(dc, WSDISPLAY_CURSOR_DOSHAPE);
486 1.11 uwe
487 1.12 uwe /* accelerated text cursor */
488 1.11 uwe ri->ri_ops.cursor = igsfb_accel_cursor;
489 1.11 uwe
490 1.14 uwe if (dc->dc_id >= 0x2000) { /* XXX */
491 1.14 uwe /* accelerated erase/copy */
492 1.14 uwe ri->ri_ops.copycols = igsfb_accel_copycols;
493 1.14 uwe ri->ri_ops.erasecols = igsfb_accel_erasecols;
494 1.14 uwe ri->ri_ops.copyrows = igsfb_accel_copyrows;
495 1.14 uwe ri->ri_ops.eraserows = igsfb_accel_eraserows;
496 1.14 uwe
497 1.14 uwe /* putchar hook to sync with the cop */
498 1.14 uwe dc->dc_ri_putchar = ri->ri_ops.putchar;
499 1.14 uwe ri->ri_ops.putchar = igsfb_accel_putchar;
500 1.14 uwe }
501 1.12 uwe
502 1.1 uwe igsfb_stdscreen.nrows = ri->ri_rows;
503 1.1 uwe igsfb_stdscreen.ncols = ri->ri_cols;
504 1.1 uwe igsfb_stdscreen.textops = &ri->ri_ops;
505 1.1 uwe igsfb_stdscreen.capabilities = ri->ri_caps;
506 1.1 uwe }
507 1.1 uwe
508 1.1 uwe
509 1.1 uwe /*
510 1.11 uwe * Init cursor data in dc_cursor for the accelerated text cursor.
511 1.11 uwe */
512 1.11 uwe static int
513 1.27 macallan igsfb_make_text_cursor(dc, scr)
514 1.11 uwe struct igsfb_devconfig *dc;
515 1.27 macallan struct vcons_screen *scr;
516 1.11 uwe {
517 1.27 macallan struct rasops_info *ri = &scr->scr_ri;
518 1.27 macallan struct wsdisplay_font *f = ri->ri_font;
519 1.19 uwe uint16_t cc_scan[8]; /* one sprite scanline */
520 1.19 uwe uint16_t s;
521 1.11 uwe int w, i;
522 1.11 uwe
523 1.11 uwe KASSERT(f->fontwidth <= IGS_CURSOR_MAX_SIZE);
524 1.11 uwe KASSERT(f->fontheight <= IGS_CURSOR_MAX_SIZE);
525 1.11 uwe
526 1.11 uwe w = f->fontwidth;
527 1.11 uwe for (i = 0; i < f->stride; ++i) {
528 1.11 uwe if (w >= 8) {
529 1.11 uwe s = 0xffff; /* all inverted */
530 1.11 uwe w -= 8;
531 1.11 uwe } else {
532 1.11 uwe /* first w pixels inverted, the rest is transparent */
533 1.11 uwe s = ~(0x5555 << (w * 2));
534 1.29 uwe s = htole16(s);
535 1.11 uwe w = 0;
536 1.11 uwe }
537 1.11 uwe cc_scan[i] = s;
538 1.11 uwe }
539 1.11 uwe
540 1.11 uwe dc->dc_cursor.cc_size.x = f->fontwidth;
541 1.11 uwe dc->dc_cursor.cc_size.y = f->fontheight;
542 1.11 uwe
543 1.11 uwe dc->dc_cursor.cc_hot.x = 0;
544 1.11 uwe dc->dc_cursor.cc_hot.y = 0;
545 1.11 uwe
546 1.11 uwe /* init sprite array to be all transparent */
547 1.11 uwe memset(dc->dc_cursor.cc_sprite, 0xaa, IGS_CURSOR_DATA_SIZE);
548 1.11 uwe
549 1.11 uwe for (i = 0; i < f->fontheight; ++i)
550 1.11 uwe memcpy(&dc->dc_cursor.cc_sprite[i * 8],
551 1.19 uwe cc_scan, f->stride * sizeof(uint16_t));
552 1.11 uwe
553 1.11 uwe return (0);
554 1.11 uwe }
555 1.11 uwe
556 1.11 uwe
557 1.11 uwe /*
558 1.8 uwe * Spread a byte (abcd.efgh) into two (0a0b.0c0d 0e0f.0g0h).
559 1.10 uwe * Helper function for igsfb_init_bit_table().
560 1.8 uwe */
561 1.19 uwe static uint16_t
562 1.8 uwe igsfb_spread_bits_8(b)
563 1.19 uwe uint8_t b;
564 1.8 uwe {
565 1.19 uwe uint16_t s = b;
566 1.8 uwe
567 1.8 uwe s = ((s & 0x00f0) << 4) | (s & 0x000f);
568 1.8 uwe s = ((s & 0x0c0c) << 2) | (s & 0x0303);
569 1.8 uwe s = ((s & 0x2222) << 1) | (s & 0x1111);
570 1.8 uwe return (s);
571 1.8 uwe }
572 1.8 uwe
573 1.8 uwe
574 1.8 uwe /*
575 1.8 uwe * Cursor sprite data are in 2bpp. Incoming image/mask are in 1bpp.
576 1.18 uwe * Prebuild the table to expand 1bpp->2bpp, with bswapping if necessary.
577 1.8 uwe */
578 1.8 uwe static void
579 1.10 uwe igsfb_init_bit_table(dc)
580 1.8 uwe struct igsfb_devconfig *dc;
581 1.8 uwe {
582 1.19 uwe uint16_t *expand = dc->dc_bexpand;
583 1.19 uwe uint16_t s;
584 1.8 uwe u_int i;
585 1.8 uwe
586 1.8 uwe for (i = 0; i < 256; ++i) {
587 1.10 uwe s = igsfb_spread_bits_8(i);
588 1.29 uwe expand[i] = htole16(s);
589 1.8 uwe }
590 1.8 uwe }
591 1.8 uwe
592 1.8 uwe
593 1.8 uwe /*
594 1.1 uwe * wsdisplay_accessops: mmap()
595 1.4 uwe * XXX: allow mmapping i/o mapped i/o regs if INSECURE???
596 1.1 uwe */
597 1.1 uwe static paddr_t
598 1.1 uwe igsfb_mmap(v, offset, prot)
599 1.1 uwe void *v;
600 1.1 uwe off_t offset;
601 1.1 uwe int prot;
602 1.1 uwe {
603 1.27 macallan struct vcons_data *vd = v;
604 1.27 macallan struct igsfb_devconfig *dc = vd->cookie;
605 1.1 uwe
606 1.8 uwe if (offset >= dc->dc_memsz || offset < 0)
607 1.1 uwe return (-1);
608 1.1 uwe
609 1.8 uwe return (bus_space_mmap(dc->dc_memt, dc->dc_memaddr, offset, prot,
610 1.8 uwe dc->dc_memflags | BUS_SPACE_MAP_LINEAR));
611 1.1 uwe }
612 1.1 uwe
613 1.1 uwe
614 1.1 uwe /*
615 1.1 uwe * wsdisplay_accessops: ioctl()
616 1.1 uwe */
617 1.1 uwe static int
618 1.26 christos igsfb_ioctl(v, cmd, data, flag, l)
619 1.1 uwe void *v;
620 1.1 uwe u_long cmd;
621 1.1 uwe caddr_t data;
622 1.1 uwe int flag;
623 1.26 christos struct lwp *l;
624 1.1 uwe {
625 1.27 macallan struct vcons_data *vd = v;
626 1.27 macallan struct igsfb_devconfig *dc = vd->cookie;
627 1.8 uwe struct rasops_info *ri;
628 1.11 uwe int cursor_busy;
629 1.1 uwe int turnoff;
630 1.1 uwe
631 1.11 uwe /* don't permit cursor ioctls if we use sprite for text cursor */
632 1.11 uwe cursor_busy = !dc->dc_mapped
633 1.11 uwe && (dc->dc_hwflags & IGSFB_HW_TEXT_CURSOR);
634 1.11 uwe
635 1.1 uwe switch (cmd) {
636 1.1 uwe
637 1.1 uwe case WSDISPLAYIO_GTYPE:
638 1.1 uwe *(u_int *)data = WSDISPLAY_TYPE_PCIMISC;
639 1.1 uwe return (0);
640 1.1 uwe
641 1.1 uwe case WSDISPLAYIO_GINFO:
642 1.27 macallan ri = &dc->dc_vd.active->scr_ri;
643 1.1 uwe #define wsd_fbip ((struct wsdisplay_fbinfo *)data)
644 1.1 uwe wsd_fbip->height = ri->ri_height;
645 1.1 uwe wsd_fbip->width = ri->ri_width;
646 1.1 uwe wsd_fbip->depth = ri->ri_depth;
647 1.1 uwe wsd_fbip->cmsize = IGS_CMAP_SIZE;
648 1.1 uwe #undef wsd_fbip
649 1.1 uwe return (0);
650 1.22 macallan
651 1.21 macallan case WSDISPLAYIO_LINEBYTES:
652 1.27 macallan ri = &dc->dc_vd.active->scr_ri;
653 1.21 macallan *(int *)data = ri->ri_stride;
654 1.21 macallan return (0);
655 1.1 uwe
656 1.11 uwe case WSDISPLAYIO_SMODE:
657 1.11 uwe #define d (*(int *)data)
658 1.25 macallan if (d != WSDISPLAYIO_MODE_EMUL) {
659 1.11 uwe dc->dc_mapped = 1;
660 1.23 macallan /* turn off hardware cursor */
661 1.23 macallan if (dc->dc_hwflags & IGSFB_HW_TEXT_CURSOR) {
662 1.23 macallan dc->dc_curenb = 0;
663 1.23 macallan igsfb_update_cursor(dc,
664 1.23 macallan WSDISPLAY_CURSOR_DOCUR);
665 1.23 macallan }
666 1.25 macallan } else {
667 1.11 uwe dc->dc_mapped = 0;
668 1.11 uwe /* reinit sprite for text cursor */
669 1.11 uwe if (dc->dc_hwflags & IGSFB_HW_TEXT_CURSOR) {
670 1.27 macallan igsfb_make_text_cursor(dc, dc->dc_vd.active);
671 1.11 uwe dc->dc_curenb = 0;
672 1.11 uwe igsfb_update_cursor(dc,
673 1.11 uwe WSDISPLAY_CURSOR_DOSHAPE
674 1.11 uwe | WSDISPLAY_CURSOR_DOCUR);
675 1.11 uwe }
676 1.27 macallan vcons_redraw_screen(vd->active);
677 1.11 uwe }
678 1.11 uwe return (0);
679 1.11 uwe
680 1.1 uwe case WSDISPLAYIO_GVIDEO:
681 1.8 uwe *(u_int *)data = dc->dc_blanked ?
682 1.1 uwe WSDISPLAYIO_VIDEO_OFF : WSDISPLAYIO_VIDEO_ON;
683 1.1 uwe return (0);
684 1.1 uwe
685 1.1 uwe case WSDISPLAYIO_SVIDEO:
686 1.1 uwe turnoff = (*(u_int *)data == WSDISPLAYIO_VIDEO_OFF);
687 1.8 uwe if (dc->dc_blanked != turnoff) {
688 1.8 uwe dc->dc_blanked = turnoff;
689 1.8 uwe igsfb_blank_screen(dc, dc->dc_blanked);
690 1.1 uwe }
691 1.1 uwe return (0);
692 1.1 uwe
693 1.1 uwe case WSDISPLAYIO_GETCMAP:
694 1.8 uwe return (igsfb_get_cmap(dc, (struct wsdisplay_cmap *)data));
695 1.1 uwe
696 1.1 uwe case WSDISPLAYIO_PUTCMAP:
697 1.8 uwe return (igsfb_set_cmap(dc, (struct wsdisplay_cmap *)data));
698 1.1 uwe
699 1.1 uwe case WSDISPLAYIO_GCURMAX:
700 1.1 uwe ((struct wsdisplay_curpos *)data)->x = IGS_CURSOR_MAX_SIZE;
701 1.1 uwe ((struct wsdisplay_curpos *)data)->y = IGS_CURSOR_MAX_SIZE;
702 1.1 uwe return (0);
703 1.1 uwe
704 1.1 uwe case WSDISPLAYIO_GCURPOS:
705 1.11 uwe if (cursor_busy)
706 1.11 uwe return (EBUSY);
707 1.8 uwe *(struct wsdisplay_curpos *)data = dc->dc_cursor.cc_pos;
708 1.1 uwe return (0);
709 1.1 uwe
710 1.1 uwe case WSDISPLAYIO_SCURPOS:
711 1.11 uwe if (cursor_busy)
712 1.11 uwe return (EBUSY);
713 1.8 uwe igsfb_set_curpos(dc, (struct wsdisplay_curpos *)data);
714 1.1 uwe return (0);
715 1.1 uwe
716 1.1 uwe case WSDISPLAYIO_GCURSOR:
717 1.11 uwe if (cursor_busy)
718 1.11 uwe return (EBUSY);
719 1.8 uwe return (igsfb_get_cursor(dc, (struct wsdisplay_cursor *)data));
720 1.1 uwe
721 1.1 uwe case WSDISPLAYIO_SCURSOR:
722 1.24 uwe if (cursor_busy)
723 1.11 uwe return (EBUSY);
724 1.8 uwe return (igsfb_set_cursor(dc, (struct wsdisplay_cursor *)data));
725 1.1 uwe }
726 1.1 uwe
727 1.1 uwe return (EPASSTHROUGH);
728 1.1 uwe }
729 1.1 uwe
730 1.1 uwe
731 1.1 uwe /*
732 1.1 uwe * wsdisplay_accessops: ioctl(WSDISPLAYIO_SVIDEO)
733 1.1 uwe */
734 1.1 uwe static void
735 1.8 uwe igsfb_blank_screen(dc, blank)
736 1.8 uwe struct igsfb_devconfig *dc;
737 1.1 uwe int blank;
738 1.1 uwe {
739 1.1 uwe
740 1.8 uwe igs_ext_write(dc->dc_iot, dc->dc_ioh,
741 1.1 uwe IGS_EXT_SYNC_CTL,
742 1.1 uwe blank ? IGS_EXT_SYNC_H0 | IGS_EXT_SYNC_V0
743 1.1 uwe : 0);
744 1.1 uwe }
745 1.1 uwe
746 1.1 uwe
747 1.1 uwe /*
748 1.1 uwe * wsdisplay_accessops: ioctl(WSDISPLAYIO_GETCMAP)
749 1.8 uwe * Served from the software cmap copy.
750 1.1 uwe */
751 1.1 uwe static int
752 1.8 uwe igsfb_get_cmap(dc, p)
753 1.8 uwe struct igsfb_devconfig *dc;
754 1.1 uwe struct wsdisplay_cmap *p;
755 1.1 uwe {
756 1.11 uwe u_int index, count;
757 1.11 uwe int err;
758 1.11 uwe
759 1.11 uwe index = p->index;
760 1.11 uwe count = p->count;
761 1.1 uwe
762 1.5 itojun if (index >= IGS_CMAP_SIZE || count > IGS_CMAP_SIZE - index)
763 1.1 uwe return (EINVAL);
764 1.1 uwe
765 1.11 uwe err = copyout(&dc->dc_cmap.r[index], p->red, count);
766 1.11 uwe if (err)
767 1.11 uwe return (err);
768 1.11 uwe err = copyout(&dc->dc_cmap.g[index], p->green, count);
769 1.11 uwe if (err)
770 1.11 uwe return (err);
771 1.11 uwe err = copyout(&dc->dc_cmap.b[index], p->blue, count);
772 1.11 uwe if (err)
773 1.11 uwe return (err);
774 1.1 uwe
775 1.1 uwe return (0);
776 1.1 uwe }
777 1.1 uwe
778 1.1 uwe
779 1.1 uwe /*
780 1.15 uwe * wsdisplay_accessops: ioctl(WSDISPLAYIO_PUTCMAP)
781 1.8 uwe * Set the software cmap copy and propagate changed range to the device.
782 1.1 uwe */
783 1.1 uwe static int
784 1.8 uwe igsfb_set_cmap(dc, p)
785 1.8 uwe struct igsfb_devconfig *dc;
786 1.9 uwe const struct wsdisplay_cmap *p;
787 1.1 uwe {
788 1.11 uwe u_int index, count;
789 1.17 chs uint8_t r[IGS_CMAP_SIZE];
790 1.17 chs uint8_t g[IGS_CMAP_SIZE];
791 1.17 chs uint8_t b[IGS_CMAP_SIZE];
792 1.17 chs int error;
793 1.11 uwe
794 1.11 uwe index = p->index;
795 1.11 uwe count = p->count;
796 1.5 itojun if (index >= IGS_CMAP_SIZE || count > IGS_CMAP_SIZE - index)
797 1.1 uwe return (EINVAL);
798 1.17 chs error = copyin(p->red, &r[index], count);
799 1.17 chs if (error)
800 1.17 chs return error;
801 1.17 chs error = copyin(p->green, &g[index], count);
802 1.17 chs if (error)
803 1.17 chs return error;
804 1.17 chs error = copyin(p->blue, &b[index], count);
805 1.17 chs if (error)
806 1.17 chs return error;
807 1.17 chs
808 1.17 chs memcpy(&dc->dc_cmap.r[index], &r[index], count);
809 1.17 chs memcpy(&dc->dc_cmap.g[index], &g[index], count);
810 1.17 chs memcpy(&dc->dc_cmap.b[index], &b[index], count);
811 1.1 uwe
812 1.11 uwe /* propagate changes to the device */
813 1.11 uwe igsfb_update_cmap(dc, index, count);
814 1.1 uwe return (0);
815 1.1 uwe }
816 1.1 uwe
817 1.1 uwe
818 1.1 uwe /*
819 1.8 uwe * Propagate specified part of the software cmap copy to the device.
820 1.1 uwe */
821 1.1 uwe static void
822 1.8 uwe igsfb_update_cmap(dc, index, count)
823 1.8 uwe struct igsfb_devconfig *dc;
824 1.1 uwe u_int index, count;
825 1.1 uwe {
826 1.1 uwe bus_space_tag_t t;
827 1.1 uwe bus_space_handle_t h;
828 1.1 uwe u_int last, i;
829 1.1 uwe
830 1.1 uwe if (index >= IGS_CMAP_SIZE)
831 1.1 uwe return;
832 1.1 uwe
833 1.1 uwe last = index + count;
834 1.1 uwe if (last > IGS_CMAP_SIZE)
835 1.1 uwe last = IGS_CMAP_SIZE;
836 1.1 uwe
837 1.8 uwe t = dc->dc_iot;
838 1.8 uwe h = dc->dc_ioh;
839 1.1 uwe
840 1.1 uwe /* start palette writing, index is autoincremented by hardware */
841 1.1 uwe bus_space_write_1(t, h, IGS_DAC_PEL_WRITE_IDX, index);
842 1.1 uwe
843 1.1 uwe for (i = index; i < last; ++i) {
844 1.8 uwe bus_space_write_1(t, h, IGS_DAC_PEL_DATA, dc->dc_cmap.r[i]);
845 1.8 uwe bus_space_write_1(t, h, IGS_DAC_PEL_DATA, dc->dc_cmap.g[i]);
846 1.8 uwe bus_space_write_1(t, h, IGS_DAC_PEL_DATA, dc->dc_cmap.b[i]);
847 1.1 uwe }
848 1.1 uwe }
849 1.1 uwe
850 1.1 uwe
851 1.1 uwe /*
852 1.1 uwe * wsdisplay_accessops: ioctl(WSDISPLAYIO_SCURPOS)
853 1.1 uwe */
854 1.1 uwe static void
855 1.8 uwe igsfb_set_curpos(dc, curpos)
856 1.8 uwe struct igsfb_devconfig *dc;
857 1.9 uwe const struct wsdisplay_curpos *curpos;
858 1.1 uwe {
859 1.27 macallan struct rasops_info *ri = &dc->dc_vd.active->scr_ri;
860 1.9 uwe u_int x = curpos->x, y = curpos->y;
861 1.9 uwe
862 1.9 uwe if (x >= ri->ri_width)
863 1.9 uwe x = ri->ri_width - 1;
864 1.9 uwe if (y >= ri->ri_height)
865 1.9 uwe y = ri->ri_height - 1;
866 1.1 uwe
867 1.8 uwe dc->dc_cursor.cc_pos.x = x;
868 1.8 uwe dc->dc_cursor.cc_pos.y = y;
869 1.1 uwe
870 1.11 uwe /* propagate changes to the device */
871 1.8 uwe igsfb_update_curpos(dc);
872 1.1 uwe }
873 1.1 uwe
874 1.1 uwe
875 1.1 uwe static void
876 1.8 uwe igsfb_update_curpos(dc)
877 1.8 uwe struct igsfb_devconfig *dc;
878 1.1 uwe {
879 1.1 uwe bus_space_tag_t t;
880 1.1 uwe bus_space_handle_t h;
881 1.1 uwe int x, xoff, y, yoff;
882 1.1 uwe
883 1.1 uwe xoff = 0;
884 1.8 uwe x = dc->dc_cursor.cc_pos.x - dc->dc_cursor.cc_hot.x;
885 1.1 uwe if (x < 0) {
886 1.8 uwe xoff = -x;
887 1.1 uwe x = 0;
888 1.1 uwe }
889 1.1 uwe
890 1.1 uwe yoff = 0;
891 1.8 uwe y = dc->dc_cursor.cc_pos.y - dc->dc_cursor.cc_hot.y;
892 1.1 uwe if (y < 0) {
893 1.8 uwe yoff = -y;
894 1.1 uwe y = 0;
895 1.1 uwe }
896 1.1 uwe
897 1.8 uwe t = dc->dc_iot;
898 1.8 uwe h = dc->dc_ioh;
899 1.1 uwe
900 1.1 uwe igs_ext_write(t, h, IGS_EXT_SPRITE_HSTART_LO, x & 0xff);
901 1.1 uwe igs_ext_write(t, h, IGS_EXT_SPRITE_HSTART_HI, (x >> 8) & 0x07);
902 1.1 uwe igs_ext_write(t, h, IGS_EXT_SPRITE_HPRESET, xoff & 0x3f);
903 1.1 uwe
904 1.1 uwe igs_ext_write(t, h, IGS_EXT_SPRITE_VSTART_LO, y & 0xff);
905 1.1 uwe igs_ext_write(t, h, IGS_EXT_SPRITE_VSTART_HI, (y >> 8) & 0x07);
906 1.1 uwe igs_ext_write(t, h, IGS_EXT_SPRITE_VPRESET, yoff & 0x3f);
907 1.1 uwe }
908 1.1 uwe
909 1.1 uwe
910 1.1 uwe /*
911 1.1 uwe * wsdisplay_accessops: ioctl(WSDISPLAYIO_GCURSOR)
912 1.1 uwe */
913 1.1 uwe static int
914 1.8 uwe igsfb_get_cursor(dc, p)
915 1.8 uwe struct igsfb_devconfig *dc;
916 1.1 uwe struct wsdisplay_cursor *p;
917 1.1 uwe {
918 1.1 uwe
919 1.1 uwe /* XXX: TODO */
920 1.1 uwe return (0);
921 1.1 uwe }
922 1.1 uwe
923 1.1 uwe
924 1.1 uwe /*
925 1.1 uwe * wsdisplay_accessops: ioctl(WSDISPLAYIO_SCURSOR)
926 1.1 uwe */
927 1.1 uwe static int
928 1.8 uwe igsfb_set_cursor(dc, p)
929 1.8 uwe struct igsfb_devconfig *dc;
930 1.9 uwe const struct wsdisplay_cursor *p;
931 1.1 uwe {
932 1.1 uwe struct igs_hwcursor *cc;
933 1.9 uwe struct wsdisplay_curpos pos, hot;
934 1.1 uwe u_int v, index, count, icount, iwidth;
935 1.17 chs uint8_t r[2], g[2], b[2], image[512], mask[512];
936 1.17 chs int error;
937 1.1 uwe
938 1.8 uwe cc = &dc->dc_cursor;
939 1.1 uwe v = p->which;
940 1.17 chs index = count = icount = iwidth = 0; /* XXX: gcc */
941 1.24 uwe
942 1.17 chs /* copy in the new cursor colormap */
943 1.1 uwe if (v & WSDISPLAY_CURSOR_DOCMAP) {
944 1.1 uwe index = p->cmap.index;
945 1.1 uwe count = p->cmap.count;
946 1.1 uwe if (index >= 2 || (index + count) > 2)
947 1.1 uwe return (EINVAL);
948 1.17 chs error = copyin(p->cmap.red, &r[index], count);
949 1.17 chs if (error)
950 1.17 chs return error;
951 1.17 chs error = copyin(p->cmap.green, &g[index], count);
952 1.17 chs if (error)
953 1.17 chs return error;
954 1.17 chs error = copyin(p->cmap.blue, &b[index], count);
955 1.17 chs if (error)
956 1.17 chs return error;
957 1.1 uwe }
958 1.1 uwe
959 1.9 uwe /* verify that the new cursor data are valid */
960 1.1 uwe if (v & WSDISPLAY_CURSOR_DOSHAPE) {
961 1.1 uwe if (p->size.x > IGS_CURSOR_MAX_SIZE
962 1.1 uwe || p->size.y > IGS_CURSOR_MAX_SIZE)
963 1.1 uwe return (EINVAL);
964 1.1 uwe
965 1.1 uwe iwidth = (p->size.x + 7) >> 3; /* bytes per scan line */
966 1.1 uwe icount = iwidth * p->size.y;
967 1.17 chs error = copyin(p->image, image, icount);
968 1.17 chs if (error)
969 1.17 chs return error;
970 1.17 chs error = copyin(p->mask, mask, icount);
971 1.17 chs if (error)
972 1.17 chs return error;
973 1.1 uwe }
974 1.1 uwe
975 1.9 uwe /* enforce that the position is within screen bounds */
976 1.9 uwe if (v & WSDISPLAY_CURSOR_DOPOS) {
977 1.27 macallan struct rasops_info *ri = &dc->dc_vd.active->scr_ri;
978 1.9 uwe
979 1.9 uwe pos = p->pos; /* local copy we can write to */
980 1.25 macallan if (pos.x >= ri->ri_width)
981 1.25 macallan pos.x = ri->ri_width - 1;
982 1.25 macallan if (pos.y >= ri->ri_height)
983 1.25 macallan pos.y = ri->ri_height - 1;
984 1.9 uwe }
985 1.9 uwe
986 1.9 uwe /* enforce that the hot spot is within sprite bounds */
987 1.9 uwe if (v & WSDISPLAY_CURSOR_DOHOT)
988 1.9 uwe hot = p->hot; /* local copy we can write to */
989 1.9 uwe
990 1.9 uwe if (v & (WSDISPLAY_CURSOR_DOHOT | WSDISPLAY_CURSOR_DOSHAPE)) {
991 1.9 uwe const struct wsdisplay_curpos *nsize;
992 1.9 uwe struct wsdisplay_curpos *nhot;
993 1.1 uwe
994 1.9 uwe nsize = (v & WSDISPLAY_CURSOR_DOSHAPE) ?
995 1.9 uwe &p->size : &cc->cc_size;
996 1.9 uwe nhot = (v & WSDISPLAY_CURSOR_DOHOT) ? &hot : &cc->cc_hot;
997 1.1 uwe
998 1.9 uwe if (nhot->x >= nsize->x)
999 1.9 uwe nhot->x = nsize->x - 1;
1000 1.9 uwe if (nhot->y >= nsize->y)
1001 1.9 uwe nhot->y = nsize->y - 1;
1002 1.9 uwe }
1003 1.9 uwe
1004 1.17 chs /* copy data to the driver's cursor info */
1005 1.1 uwe if (v & WSDISPLAY_CURSOR_DOCUR)
1006 1.8 uwe dc->dc_curenb = p->enable;
1007 1.1 uwe if (v & WSDISPLAY_CURSOR_DOPOS)
1008 1.9 uwe cc->cc_pos = pos; /* local copy, possibly corrected */
1009 1.1 uwe if (v & WSDISPLAY_CURSOR_DOHOT)
1010 1.9 uwe cc->cc_hot = hot; /* local copy, possibly corrected */
1011 1.1 uwe if (v & WSDISPLAY_CURSOR_DOCMAP) {
1012 1.17 chs memcpy(&cc->cc_color[index], &r[index], count);
1013 1.17 chs memcpy(&cc->cc_color[index + 2], &g[index], count);
1014 1.17 chs memcpy(&cc->cc_color[index + 4], &b[index], count);
1015 1.1 uwe }
1016 1.1 uwe if (v & WSDISPLAY_CURSOR_DOSHAPE) {
1017 1.1 uwe u_int trailing_bits;
1018 1.1 uwe
1019 1.17 chs memcpy(cc->cc_image, image, icount);
1020 1.17 chs memcpy(cc->cc_mask, mask, icount);
1021 1.1 uwe cc->cc_size = p->size;
1022 1.1 uwe
1023 1.1 uwe /* clear trailing bits in the "partial" mask bytes */
1024 1.1 uwe trailing_bits = p->size.x & 0x07;
1025 1.1 uwe if (trailing_bits != 0) {
1026 1.1 uwe const u_int cutmask = ~((~0) << trailing_bits);
1027 1.1 uwe u_char *mp;
1028 1.1 uwe u_int i;
1029 1.1 uwe
1030 1.1 uwe mp = cc->cc_mask + iwidth - 1;
1031 1.1 uwe for (i = 0; i < p->size.y; ++i) {
1032 1.1 uwe *mp &= cutmask;
1033 1.1 uwe mp += iwidth;
1034 1.1 uwe }
1035 1.1 uwe }
1036 1.8 uwe igsfb_convert_cursor_data(dc, iwidth, p->size.y);
1037 1.1 uwe }
1038 1.1 uwe
1039 1.9 uwe /* propagate changes to the device */
1040 1.8 uwe igsfb_update_cursor(dc, v);
1041 1.9 uwe
1042 1.1 uwe return (0);
1043 1.1 uwe }
1044 1.1 uwe
1045 1.4 uwe
1046 1.1 uwe /*
1047 1.1 uwe * Convert incoming 1bpp cursor image/mask into native 2bpp format.
1048 1.1 uwe */
1049 1.1 uwe static void
1050 1.10 uwe igsfb_convert_cursor_data(dc, width, height)
1051 1.8 uwe struct igsfb_devconfig *dc;
1052 1.10 uwe u_int width, height;
1053 1.1 uwe {
1054 1.8 uwe struct igs_hwcursor *cc = &dc->dc_cursor;
1055 1.19 uwe uint16_t *expand = dc->dc_bexpand;
1056 1.19 uwe uint8_t *ip, *mp;
1057 1.19 uwe uint16_t is, ms, *dp;
1058 1.1 uwe u_int line, i;
1059 1.1 uwe
1060 1.1 uwe /* init sprite to be all transparent */
1061 1.1 uwe memset(cc->cc_sprite, 0xaa, IGS_CURSOR_DATA_SIZE);
1062 1.1 uwe
1063 1.1 uwe /* first scanline */
1064 1.1 uwe ip = cc->cc_image;
1065 1.1 uwe mp = cc->cc_mask;
1066 1.1 uwe dp = cc->cc_sprite;
1067 1.1 uwe
1068 1.10 uwe for (line = 0; line < height; ++line) {
1069 1.10 uwe for (i = 0; i < width; ++i) {
1070 1.10 uwe is = expand[ip[i]]; /* image: 0 -> 00, 1 -> 01 */
1071 1.10 uwe ms = expand[mp[i]]; /* mask: 0 -> 00, 1 -> 11 */
1072 1.8 uwe ms |= (ms << 1);
1073 1.1 uwe dp[i] = (0xaaaa & ~ms) | (is & ms);
1074 1.1 uwe }
1075 1.1 uwe
1076 1.1 uwe /* next scanline */
1077 1.10 uwe ip += width;
1078 1.10 uwe mp += width;
1079 1.10 uwe dp += 8; /* 64 pixels, 2bpp, 8 pixels per short = 8 shorts */
1080 1.1 uwe }
1081 1.1 uwe }
1082 1.1 uwe
1083 1.1 uwe
1084 1.1 uwe /*
1085 1.8 uwe * Propagate cursor changes to the device.
1086 1.8 uwe * "which" is composed of WSDISPLAY_CURSOR_DO* bits.
1087 1.1 uwe */
1088 1.1 uwe static void
1089 1.8 uwe igsfb_update_cursor(dc, which)
1090 1.8 uwe struct igsfb_devconfig *dc;
1091 1.1 uwe u_int which;
1092 1.1 uwe {
1093 1.8 uwe bus_space_tag_t iot = dc->dc_iot;
1094 1.8 uwe bus_space_handle_t ioh = dc->dc_ioh;
1095 1.19 uwe uint8_t curctl;
1096 1.16 uwe
1097 1.16 uwe curctl = 0; /* XXX: gcc */
1098 1.1 uwe
1099 1.1 uwe /*
1100 1.1 uwe * We will need to tweak sprite control register for cursor
1101 1.18 uwe * visibility and cursor color map manipulation.
1102 1.1 uwe */
1103 1.1 uwe if (which & (WSDISPLAY_CURSOR_DOCUR | WSDISPLAY_CURSOR_DOCMAP)) {
1104 1.1 uwe curctl = igs_ext_read(iot, ioh, IGS_EXT_SPRITE_CTL);
1105 1.1 uwe }
1106 1.1 uwe
1107 1.1 uwe if (which & WSDISPLAY_CURSOR_DOSHAPE) {
1108 1.19 uwe uint8_t *dst = bus_space_vaddr(dc->dc_memt, dc->dc_crh);
1109 1.1 uwe
1110 1.1 uwe /*
1111 1.1 uwe * memcpy between spaces of different endianness would
1112 1.8 uwe * be ... special. We cannot be sure if memcpy gonna
1113 1.1 uwe * push data in 4-byte chunks, we can't pre-bswap it,
1114 1.1 uwe * so do it byte-by-byte to preserve byte ordering.
1115 1.1 uwe */
1116 1.8 uwe if (IGSFB_HW_SOFT_BSWAP(dc)) {
1117 1.19 uwe uint8_t *src = (uint8_t *)dc->dc_cursor.cc_sprite;
1118 1.1 uwe int i;
1119 1.1 uwe
1120 1.8 uwe for (i = 0; i < IGS_CURSOR_DATA_SIZE; ++i)
1121 1.1 uwe *dst++ = *src++;
1122 1.1 uwe } else {
1123 1.8 uwe memcpy(dst, dc->dc_cursor.cc_sprite,
1124 1.8 uwe IGS_CURSOR_DATA_SIZE);
1125 1.1 uwe }
1126 1.1 uwe }
1127 1.1 uwe
1128 1.1 uwe if (which & (WSDISPLAY_CURSOR_DOPOS | WSDISPLAY_CURSOR_DOHOT)) {
1129 1.1 uwe /* code shared with WSDISPLAYIO_SCURPOS */
1130 1.8 uwe igsfb_update_curpos(dc);
1131 1.1 uwe }
1132 1.1 uwe
1133 1.1 uwe if (which & WSDISPLAY_CURSOR_DOCMAP) {
1134 1.19 uwe uint8_t *p;
1135 1.1 uwe
1136 1.1 uwe /* tell DAC we want access to the cursor palette */
1137 1.1 uwe igs_ext_write(iot, ioh, IGS_EXT_SPRITE_CTL,
1138 1.4 uwe curctl | IGS_EXT_SPRITE_DAC_PEL);
1139 1.1 uwe
1140 1.8 uwe p = dc->dc_cursor.cc_color;
1141 1.1 uwe
1142 1.1 uwe bus_space_write_1(iot, ioh, IGS_DAC_PEL_WRITE_IDX, 0);
1143 1.1 uwe bus_space_write_1(iot, ioh, IGS_DAC_PEL_DATA, p[0]);
1144 1.1 uwe bus_space_write_1(iot, ioh, IGS_DAC_PEL_DATA, p[2]);
1145 1.1 uwe bus_space_write_1(iot, ioh, IGS_DAC_PEL_DATA, p[4]);
1146 1.1 uwe
1147 1.1 uwe bus_space_write_1(iot, ioh, IGS_DAC_PEL_WRITE_IDX, 1);
1148 1.1 uwe bus_space_write_1(iot, ioh, IGS_DAC_PEL_DATA, p[1]);
1149 1.1 uwe bus_space_write_1(iot, ioh, IGS_DAC_PEL_DATA, p[3]);
1150 1.1 uwe bus_space_write_1(iot, ioh, IGS_DAC_PEL_DATA, p[5]);
1151 1.1 uwe
1152 1.8 uwe /* restore access to the normal palette */
1153 1.1 uwe igs_ext_write(iot, ioh, IGS_EXT_SPRITE_CTL, curctl);
1154 1.1 uwe }
1155 1.1 uwe
1156 1.1 uwe if (which & WSDISPLAY_CURSOR_DOCUR) {
1157 1.1 uwe if ((curctl & IGS_EXT_SPRITE_VISIBLE) == 0
1158 1.8 uwe && dc->dc_curenb)
1159 1.1 uwe igs_ext_write(iot, ioh, IGS_EXT_SPRITE_CTL,
1160 1.1 uwe curctl | IGS_EXT_SPRITE_VISIBLE);
1161 1.1 uwe else if ((curctl & IGS_EXT_SPRITE_VISIBLE) != 0
1162 1.8 uwe && !dc->dc_curenb)
1163 1.1 uwe igs_ext_write(iot, ioh, IGS_EXT_SPRITE_CTL,
1164 1.1 uwe curctl & ~IGS_EXT_SPRITE_VISIBLE);
1165 1.1 uwe }
1166 1.1 uwe }
1167 1.1 uwe
1168 1.1 uwe
1169 1.1 uwe /*
1170 1.11 uwe * Accelerated text mode cursor that uses hardware sprite.
1171 1.11 uwe */
1172 1.11 uwe static void
1173 1.11 uwe igsfb_accel_cursor(cookie, on, row, col)
1174 1.11 uwe void *cookie;
1175 1.11 uwe int on, row, col;
1176 1.11 uwe {
1177 1.11 uwe struct rasops_info *ri = (struct rasops_info *)cookie;
1178 1.27 macallan struct vcons_screen *scr = ri->ri_hw;
1179 1.27 macallan struct igsfb_devconfig *dc = scr->scr_cookie;
1180 1.11 uwe struct igs_hwcursor *cc = &dc->dc_cursor;
1181 1.11 uwe u_int which;
1182 1.11 uwe
1183 1.11 uwe ri->ri_crow = row;
1184 1.11 uwe ri->ri_ccol = col;
1185 1.11 uwe
1186 1.11 uwe which = 0;
1187 1.11 uwe if (on) {
1188 1.11 uwe ri->ri_flg |= RI_CURSOR;
1189 1.11 uwe
1190 1.18 uwe /* only bother to move the cursor if it's visible */
1191 1.11 uwe cc->cc_pos.x = ri->ri_xorigin
1192 1.11 uwe + ri->ri_ccol * ri->ri_font->fontwidth;
1193 1.11 uwe cc->cc_pos.y = ri->ri_yorigin
1194 1.11 uwe + ri->ri_crow * ri->ri_font->fontheight;
1195 1.11 uwe which |= WSDISPLAY_CURSOR_DOPOS;
1196 1.11 uwe } else
1197 1.11 uwe ri->ri_flg &= ~RI_CURSOR;
1198 1.11 uwe
1199 1.11 uwe if (dc->dc_curenb != on) {
1200 1.11 uwe dc->dc_curenb = on;
1201 1.11 uwe which |= WSDISPLAY_CURSOR_DOCUR;
1202 1.11 uwe }
1203 1.11 uwe
1204 1.11 uwe /* propagate changes to the device */
1205 1.11 uwe igsfb_update_cursor(dc, which);
1206 1.12 uwe }
1207 1.12 uwe
1208 1.12 uwe
1209 1.12 uwe
1210 1.12 uwe /*
1211 1.12 uwe * Accelerated raster ops that use graphic coprocessor.
1212 1.12 uwe */
1213 1.12 uwe
1214 1.12 uwe static int
1215 1.12 uwe igsfb_accel_wait(dc)
1216 1.12 uwe struct igsfb_devconfig *dc;
1217 1.12 uwe {
1218 1.12 uwe bus_space_tag_t t = dc->dc_iot;
1219 1.12 uwe bus_space_handle_t h = dc->dc_coph;
1220 1.12 uwe int timo = 100000;
1221 1.19 uwe uint8_t reg;
1222 1.12 uwe
1223 1.12 uwe while (timo--) {
1224 1.12 uwe reg = bus_space_read_1(t, h, IGS_COP_CTL_REG);
1225 1.12 uwe if ((reg & IGS_COP_CTL_BUSY) == 0)
1226 1.12 uwe return (0);
1227 1.12 uwe }
1228 1.12 uwe
1229 1.12 uwe return (1);
1230 1.12 uwe }
1231 1.12 uwe
1232 1.12 uwe
1233 1.12 uwe static void
1234 1.12 uwe igsfb_accel_copy(dc, src, dst, width, height)
1235 1.12 uwe struct igsfb_devconfig *dc;
1236 1.19 uwe uint32_t src, dst;
1237 1.19 uwe uint16_t width, height;
1238 1.12 uwe {
1239 1.12 uwe bus_space_tag_t t = dc->dc_iot;
1240 1.12 uwe bus_space_handle_t h = dc->dc_coph;
1241 1.19 uwe uint32_t toend;
1242 1.19 uwe uint8_t drawcmd;
1243 1.12 uwe
1244 1.12 uwe drawcmd = IGS_COP_DRAW_ALL;
1245 1.12 uwe if (dst > src) {
1246 1.27 macallan toend = dc->dc_vd.active->scr_ri.ri_width * (height - 1) + (width - 1);
1247 1.12 uwe src += toend;
1248 1.12 uwe dst += toend;
1249 1.12 uwe drawcmd |= IGS_COP_OCTANT_X_NEG | IGS_COP_OCTANT_Y_NEG;
1250 1.12 uwe }
1251 1.12 uwe
1252 1.12 uwe igsfb_accel_wait(dc);
1253 1.12 uwe bus_space_write_1(t, h, IGS_COP_CTL_REG, 0);
1254 1.12 uwe
1255 1.12 uwe bus_space_write_1(t, h, IGS_COP_FG_MIX_REG, IGS_COP_MIX_S);
1256 1.12 uwe
1257 1.12 uwe bus_space_write_2(t, h, IGS_COP_WIDTH_REG, width - 1);
1258 1.12 uwe bus_space_write_2(t, h, IGS_COP_HEIGHT_REG, height - 1);
1259 1.12 uwe
1260 1.12 uwe bus_space_write_4(t, h, IGS_COP_SRC_START_REG, src);
1261 1.12 uwe bus_space_write_4(t, h, IGS_COP_DST_START_REG, dst);
1262 1.12 uwe
1263 1.12 uwe bus_space_write_1(t, h, IGS_COP_PIXEL_OP_0_REG, drawcmd);
1264 1.12 uwe bus_space_write_1(t, h, IGS_COP_PIXEL_OP_1_REG, IGS_COP_PPM_FIXED_FG);
1265 1.12 uwe bus_space_write_1(t, h, IGS_COP_PIXEL_OP_2_REG, 0);
1266 1.12 uwe bus_space_write_1(t, h, IGS_COP_PIXEL_OP_3_REG,
1267 1.12 uwe IGS_COP_OP_PXBLT | IGS_COP_OP_FG_FROM_SRC);
1268 1.12 uwe }
1269 1.12 uwe
1270 1.12 uwe static void
1271 1.12 uwe igsfb_accel_fill(dc, color, dst, width, height)
1272 1.12 uwe struct igsfb_devconfig *dc;
1273 1.19 uwe uint32_t color;
1274 1.19 uwe uint32_t dst;
1275 1.19 uwe uint16_t width, height;
1276 1.12 uwe {
1277 1.12 uwe bus_space_tag_t t = dc->dc_iot;
1278 1.12 uwe bus_space_handle_t h = dc->dc_coph;
1279 1.12 uwe
1280 1.12 uwe igsfb_accel_wait(dc);
1281 1.12 uwe bus_space_write_1(t, h, IGS_COP_CTL_REG, 0);
1282 1.12 uwe
1283 1.12 uwe bus_space_write_1(t, h, IGS_COP_FG_MIX_REG, IGS_COP_MIX_S);
1284 1.12 uwe
1285 1.12 uwe bus_space_write_2(t, h, IGS_COP_WIDTH_REG, width - 1);
1286 1.12 uwe bus_space_write_2(t, h, IGS_COP_HEIGHT_REG, height - 1);
1287 1.12 uwe
1288 1.12 uwe bus_space_write_4(t, h, IGS_COP_DST_START_REG, dst);
1289 1.12 uwe bus_space_write_4(t, h, IGS_COP_FG_REG, color);
1290 1.12 uwe
1291 1.12 uwe bus_space_write_1(t, h, IGS_COP_PIXEL_OP_0_REG, IGS_COP_DRAW_ALL);
1292 1.12 uwe bus_space_write_1(t, h, IGS_COP_PIXEL_OP_1_REG, IGS_COP_PPM_FIXED_FG);
1293 1.12 uwe bus_space_write_1(t, h, IGS_COP_PIXEL_OP_2_REG, 0);
1294 1.12 uwe bus_space_write_1(t, h, IGS_COP_PIXEL_OP_3_REG, IGS_COP_OP_PXBLT);
1295 1.12 uwe }
1296 1.12 uwe
1297 1.12 uwe
1298 1.12 uwe static void
1299 1.12 uwe igsfb_accel_copyrows(cookie, src, dst, num)
1300 1.12 uwe void *cookie;
1301 1.12 uwe int src, dst, num;
1302 1.12 uwe {
1303 1.12 uwe struct rasops_info *ri = (struct rasops_info *)cookie;
1304 1.27 macallan struct vcons_screen *scr = ri->ri_hw;
1305 1.27 macallan struct igsfb_devconfig *dc = (struct igsfb_devconfig *)scr->scr_cookie;
1306 1.19 uwe uint32_t srp, dsp;
1307 1.19 uwe uint16_t width, height;
1308 1.12 uwe
1309 1.12 uwe width = ri->ri_emuwidth;
1310 1.12 uwe height = num * ri->ri_font->fontheight;
1311 1.12 uwe
1312 1.12 uwe srp = ri->ri_xorigin
1313 1.12 uwe + ri->ri_width * (ri->ri_yorigin
1314 1.12 uwe + src * ri->ri_font->fontheight);
1315 1.12 uwe dsp = ri->ri_xorigin
1316 1.12 uwe + ri->ri_width * (ri->ri_yorigin
1317 1.12 uwe + dst * ri->ri_font->fontheight);
1318 1.12 uwe
1319 1.12 uwe igsfb_accel_copy(dc, srp, dsp, width, height);
1320 1.12 uwe }
1321 1.12 uwe
1322 1.12 uwe
1323 1.12 uwe void
1324 1.12 uwe igsfb_accel_copycols(cookie, row, src, dst, num)
1325 1.12 uwe void *cookie;
1326 1.12 uwe int row, src, dst, num;
1327 1.12 uwe {
1328 1.12 uwe struct rasops_info *ri = (struct rasops_info *)cookie;
1329 1.27 macallan struct vcons_screen *scr = ri->ri_hw;
1330 1.27 macallan struct igsfb_devconfig *dc = (struct igsfb_devconfig *)scr->scr_cookie;
1331 1.19 uwe uint32_t rowp, srp, dsp;
1332 1.19 uwe uint16_t width, height;
1333 1.20 perry
1334 1.12 uwe width = num * ri->ri_font->fontwidth;
1335 1.12 uwe height = ri->ri_font->fontheight;
1336 1.12 uwe
1337 1.12 uwe rowp = ri->ri_xorigin
1338 1.12 uwe + ri->ri_width * (ri->ri_yorigin
1339 1.12 uwe + row * ri->ri_font->fontheight);
1340 1.12 uwe
1341 1.12 uwe srp = rowp + src * ri->ri_font->fontwidth;
1342 1.12 uwe dsp = rowp + dst * ri->ri_font->fontwidth;
1343 1.12 uwe
1344 1.20 perry igsfb_accel_copy(dc, srp, dsp, width, height);
1345 1.12 uwe }
1346 1.12 uwe
1347 1.12 uwe
1348 1.12 uwe static void
1349 1.12 uwe igsfb_accel_eraserows(cookie, row, num, attr)
1350 1.12 uwe void *cookie;
1351 1.12 uwe int row, num;
1352 1.12 uwe long attr;
1353 1.12 uwe {
1354 1.12 uwe struct rasops_info *ri = (struct rasops_info *)cookie;
1355 1.27 macallan struct vcons_screen *scr = ri->ri_hw;
1356 1.27 macallan struct igsfb_devconfig *dc = (struct igsfb_devconfig *)scr->scr_cookie;
1357 1.19 uwe uint32_t color;
1358 1.19 uwe uint32_t dsp;
1359 1.19 uwe uint16_t width, height;
1360 1.12 uwe
1361 1.12 uwe width = ri->ri_emuwidth;
1362 1.12 uwe height = num * ri->ri_font->fontheight;
1363 1.12 uwe
1364 1.12 uwe dsp = ri->ri_xorigin
1365 1.12 uwe + ri->ri_width * (ri->ri_yorigin
1366 1.12 uwe + row * ri->ri_font->fontheight);
1367 1.12 uwe
1368 1.12 uwe /* XXX: we "know" the encoding that rasops' allocattr uses */
1369 1.12 uwe color = (attr >> 16) & 0xff;
1370 1.12 uwe
1371 1.12 uwe igsfb_accel_fill(dc, color, dsp, width, height);
1372 1.12 uwe }
1373 1.12 uwe
1374 1.12 uwe
1375 1.12 uwe void
1376 1.12 uwe igsfb_accel_erasecols(cookie, row, col, num, attr)
1377 1.12 uwe void *cookie;
1378 1.12 uwe int row, col, num;
1379 1.12 uwe long attr;
1380 1.12 uwe {
1381 1.12 uwe struct rasops_info *ri = (struct rasops_info *)cookie;
1382 1.27 macallan struct vcons_screen *scr = ri->ri_hw;
1383 1.27 macallan struct igsfb_devconfig *dc = (struct igsfb_devconfig *)scr->scr_cookie;
1384 1.19 uwe uint32_t color;
1385 1.19 uwe uint32_t rowp, dsp;
1386 1.19 uwe uint16_t width, height;
1387 1.12 uwe
1388 1.12 uwe width = num * ri->ri_font->fontwidth;
1389 1.12 uwe height = ri->ri_font->fontheight;
1390 1.12 uwe
1391 1.12 uwe rowp = ri->ri_xorigin
1392 1.12 uwe + ri->ri_width * (ri->ri_yorigin
1393 1.12 uwe + row * ri->ri_font->fontheight);
1394 1.12 uwe
1395 1.12 uwe dsp = rowp + col * ri->ri_font->fontwidth;
1396 1.12 uwe
1397 1.12 uwe /* XXX: we "know" the encoding that rasops' allocattr uses */
1398 1.12 uwe color = (attr >> 16) & 0xff;
1399 1.12 uwe
1400 1.12 uwe igsfb_accel_fill(dc, color, dsp, width, height);
1401 1.12 uwe }
1402 1.12 uwe
1403 1.12 uwe
1404 1.12 uwe /*
1405 1.12 uwe * Not really implemented here, but we need to hook into the one
1406 1.12 uwe * supplied by rasops so that we can synchronize with the COP.
1407 1.12 uwe */
1408 1.12 uwe static void
1409 1.12 uwe igsfb_accel_putchar(cookie, row, col, uc, attr)
1410 1.12 uwe void *cookie;
1411 1.12 uwe int row, col;
1412 1.12 uwe u_int uc;
1413 1.12 uwe long attr;
1414 1.12 uwe {
1415 1.12 uwe struct rasops_info *ri = (struct rasops_info *)cookie;
1416 1.27 macallan struct vcons_screen *scr = ri->ri_hw;
1417 1.27 macallan struct igsfb_devconfig *dc = (struct igsfb_devconfig *)scr->scr_cookie;
1418 1.12 uwe
1419 1.12 uwe igsfb_accel_wait(dc);
1420 1.12 uwe (*dc->dc_ri_putchar)(cookie, row, col, uc, attr);
1421 1.1 uwe }
1422