vidcvideo.c revision 1.33 1 1.33 chris /* $NetBSD: vidcvideo.c,v 1.33 2008/02/05 14:40:10 chris Exp $ */
2 1.1 reinoud
3 1.1 reinoud /*
4 1.1 reinoud * Copyright (c) 2001 Reinoud Zandijk
5 1.1 reinoud * Copyright (c) 1998, 1999 Tohru Nishimura. All rights reserved.
6 1.1 reinoud *
7 1.1 reinoud * Redistribution and use in source and binary forms, with or without
8 1.1 reinoud * modification, are permitted provided that the following conditions
9 1.1 reinoud * are met:
10 1.1 reinoud * 1. Redistributions of source code must retain the above copyright
11 1.1 reinoud * notice, this list of conditions and the following disclaimer.
12 1.1 reinoud * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 reinoud * notice, this list of conditions and the following disclaimer in the
14 1.1 reinoud * documentation and/or other materials provided with the distribution.
15 1.1 reinoud * 3. All advertising materials mentioning features or use of this software
16 1.1 reinoud * must display the following acknowledgement:
17 1.1 reinoud * This product includes software developed by Tohru Nishimura
18 1.1 reinoud * and Reinoud Zandijk for the NetBSD Project.
19 1.1 reinoud * 4. The name of the author may not be used to endorse or promote products
20 1.1 reinoud * derived from this software without specific prior written permission
21 1.1 reinoud *
22 1.1 reinoud * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 1.1 reinoud * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 1.1 reinoud * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 1.1 reinoud * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 1.1 reinoud * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 1.1 reinoud * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 1.1 reinoud * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 1.1 reinoud * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 1.1 reinoud * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 1.1 reinoud * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 1.1 reinoud *
33 1.1 reinoud * Created vidcvideo.c from /dev/tc/cfb.c to fit the Acorn/ARM VIDC1 and VIDC20 chips
34 1.1 reinoud *
35 1.1 reinoud */
36 1.1 reinoud
37 1.1 reinoud #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
38 1.1 reinoud
39 1.33 chris __KERNEL_RCSID(0, "$NetBSD: vidcvideo.c,v 1.33 2008/02/05 14:40:10 chris Exp $");
40 1.1 reinoud
41 1.1 reinoud #include <sys/param.h>
42 1.1 reinoud #include <sys/systm.h>
43 1.1 reinoud #include <sys/kernel.h>
44 1.1 reinoud #include <sys/device.h>
45 1.1 reinoud #include <sys/malloc.h>
46 1.1 reinoud #include <sys/buf.h>
47 1.1 reinoud #include <sys/ioctl.h>
48 1.1 reinoud
49 1.1 reinoud #include <arm/mainbus/mainbus.h>
50 1.1 reinoud #include <machine/bus.h>
51 1.1 reinoud #include <machine/intr.h>
52 1.1 reinoud
53 1.1 reinoud #include <dev/wscons/wsconsio.h>
54 1.1 reinoud #include <dev/wscons/wsdisplayvar.h>
55 1.1 reinoud
56 1.1 reinoud #include <dev/rasops/rasops.h>
57 1.1 reinoud #include <dev/wsfont/wsfont.h>
58 1.1 reinoud
59 1.1 reinoud #include <uvm/uvm_extern.h>
60 1.1 reinoud #include <arm/arm32/pmap.h>
61 1.9 reinoud #include <arm/cpufunc.h>
62 1.1 reinoud
63 1.1 reinoud /* for vidc_mode ... needs to be MI indepenent one day */
64 1.1 reinoud #include <arm/iomd/vidc.h>
65 1.1 reinoud #include <arm/iomd/vidc20config.h>
66 1.9 reinoud #include <arm/iomd/vidcvideo.h>
67 1.1 reinoud #include <machine/bootconfig.h>
68 1.9 reinoud
69 1.1 reinoud /* FOR DEBUG */
70 1.1 reinoud extern videomemory_t videomemory;
71 1.1 reinoud
72 1.1 reinoud struct hwcmap256 {
73 1.1 reinoud #define CMAP_SIZE 256 /* 256 R/G/B entries */
74 1.1 reinoud u_int8_t r[CMAP_SIZE];
75 1.1 reinoud u_int8_t g[CMAP_SIZE];
76 1.1 reinoud u_int8_t b[CMAP_SIZE];
77 1.1 reinoud };
78 1.1 reinoud
79 1.1 reinoud
80 1.1 reinoud /* XXX for CURSOR_MAX_WIDTH = 32 */
81 1.1 reinoud struct hwcursor32 {
82 1.1 reinoud struct wsdisplay_curpos cc_pos;
83 1.1 reinoud struct wsdisplay_curpos cc_hot;
84 1.1 reinoud struct wsdisplay_curpos cc_size;
85 1.1 reinoud u_int8_t cc_color[6]; /* how many? */
86 1.1 reinoud u_int32_t cc_image[(CURSOR_MAX_WIDTH/4) * CURSOR_MAX_HEIGHT];
87 1.1 reinoud u_int32_t cc_mask[(CURSOR_MAX_WIDTH/4) * CURSOR_MAX_HEIGHT];
88 1.1 reinoud };
89 1.1 reinoud
90 1.1 reinoud
91 1.9 reinoud struct fb_devconfig {
92 1.11 reinoud vaddr_t dc_vaddr; /* memory space virtual base address */
93 1.11 reinoud paddr_t dc_paddr; /* memory space physical base address */
94 1.11 reinoud vsize_t dc_size; /* size of slot memory */
95 1.11 reinoud int dc_wid; /* width of frame buffer */
96 1.11 reinoud int dc_ht; /* height of frame buffer */
97 1.11 reinoud int dc_log2_depth; /* log2 of bits per pixel */
98 1.11 reinoud int dc_depth; /* depth, bits per pixel */
99 1.11 reinoud int dc_rowbytes; /* bytes in a FB scan line */
100 1.11 reinoud vaddr_t dc_videobase; /* base of flat frame buffer */
101 1.11 reinoud int dc_blanked; /* currently has video disabled */
102 1.11 reinoud void *dc_hwscroll_cookie; /* cookie for hardware scroll */
103 1.33 chris void *dc_ih; /* interrupt handler for dc */
104 1.11 reinoud
105 1.11 reinoud int dc_curenb; /* is cursor sprite enabled ? */
106 1.33 chris int _internal_dc_changed; /* need update of hardware */
107 1.11 reinoud int dc_writeback_delay; /* Screenarea write back vsync counter */
108 1.9 reinoud #define WSDISPLAY_CMAP_DOLUT 0x20
109 1.9 reinoud #define WSDISPLAY_VIDEO_ONOFF 0x40
110 1.9 reinoud #define WSDISPLAY_WB_COUNTER 0x80
111 1.9 reinoud
112 1.11 reinoud struct hwcmap256 dc_cmap;/* software copy of colormap */
113 1.11 reinoud struct hwcursor32 dc_cursor;/* software copy of cursor */
114 1.9 reinoud
115 1.9 reinoud struct vidc_mode mode_info;
116 1.9 reinoud struct rasops_info rinfo;
117 1.9 reinoud
118 1.9 reinoud struct wsdisplay_emulops orig_ri_ops; /* Rasops functions for deligation */
119 1.9 reinoud };
120 1.9 reinoud
121 1.9 reinoud
122 1.1 reinoud struct vidcvideo_softc {
123 1.1 reinoud struct device sc_dev;
124 1.9 reinoud struct fb_devconfig *sc_dc; /* device configuration */
125 1.9 reinoud int nscreens; /* number of screens configured */
126 1.1 reinoud };
127 1.1 reinoud
128 1.1 reinoud
129 1.1 reinoud /* Function prototypes for glue */
130 1.25 bjh21 static int vidcvideo_match(struct device *, struct cfdata *, void *);
131 1.25 bjh21 static void vidcvideo_attach(struct device *, struct device *, void *);
132 1.1 reinoud
133 1.1 reinoud
134 1.1 reinoud /* config glue */
135 1.15 thorpej CFATTACH_DECL(vidcvideo, sizeof(struct vidcvideo_softc),
136 1.16 thorpej vidcvideo_match, vidcvideo_attach, NULL, NULL);
137 1.1 reinoud
138 1.1 reinoud static struct fb_devconfig vidcvideo_console_dc;
139 1.1 reinoud static int vidcvideo_is_console;
140 1.1 reinoud
141 1.1 reinoud
142 1.1 reinoud static struct wsscreen_descr vidcvideo_stdscreen = {
143 1.1 reinoud "std", 0, 0,
144 1.1 reinoud 0, /* textops */
145 1.1 reinoud 0, 0,
146 1.1 reinoud WSSCREEN_REVERSE
147 1.1 reinoud };
148 1.1 reinoud
149 1.1 reinoud static const struct wsscreen_descr *_vidcvideo_scrlist[] = {
150 1.1 reinoud &vidcvideo_stdscreen,
151 1.1 reinoud };
152 1.1 reinoud
153 1.1 reinoud static const struct wsscreen_list vidcvideo_screenlist = {
154 1.25 bjh21 sizeof(_vidcvideo_scrlist) / sizeof(struct wsscreen_descr *),
155 1.25 bjh21 _vidcvideo_scrlist
156 1.1 reinoud };
157 1.1 reinoud
158 1.31 christos static int vidcvideoioctl(void *, void *, u_long, void *, int,
159 1.25 bjh21 struct lwp *);
160 1.25 bjh21 static paddr_t vidcvideommap(void *, void *, off_t, int);
161 1.25 bjh21
162 1.25 bjh21 static int vidcvideo_alloc_screen(void *, const struct wsscreen_descr *,
163 1.25 bjh21 void **, int *, int *, long *);
164 1.25 bjh21 static void vidcvideo_free_screen(void *, void *);
165 1.25 bjh21 static int vidcvideo_show_screen(void *, void *, int,
166 1.25 bjh21 void (*) (void *, int, int), void *);
167 1.1 reinoud
168 1.33 chris static void vidcvideo_queue_dc_change(struct fb_devconfig*, int);
169 1.33 chris static int flush_dc_changes_to_screen(struct fb_devconfig*);
170 1.33 chris
171 1.1 reinoud static const struct wsdisplay_accessops vidcvideo_accessops = {
172 1.1 reinoud vidcvideoioctl,
173 1.1 reinoud vidcvideommap,
174 1.1 reinoud vidcvideo_alloc_screen,
175 1.1 reinoud vidcvideo_free_screen,
176 1.1 reinoud vidcvideo_show_screen,
177 1.17 reinoud NULL, /* load_font */
178 1.23 jmmv NULL /* pollc */
179 1.1 reinoud };
180 1.1 reinoud
181 1.6 reinoud
182 1.1 reinoud /* Function prototypes */
183 1.25 bjh21 int vidcvideo_cnattach(vaddr_t);
184 1.25 bjh21 static void vidcvideo_colourmap_and_cursor_init(struct fb_devconfig *);
185 1.1 reinoud
186 1.25 bjh21 static int get_cmap(struct vidcvideo_softc *, struct wsdisplay_cmap *);
187 1.25 bjh21 static int set_cmap(struct vidcvideo_softc *, struct wsdisplay_cmap *);
188 1.25 bjh21 static int set_cursor(struct vidcvideo_softc *, struct wsdisplay_cursor *);
189 1.25 bjh21 static int get_cursor(struct vidcvideo_softc *, struct wsdisplay_cursor *);
190 1.25 bjh21 static void set_curpos(struct vidcvideo_softc *, struct wsdisplay_curpos *);
191 1.25 bjh21 static void vidcvideo_getdevconfig(vaddr_t, struct fb_devconfig *);
192 1.1 reinoud
193 1.25 bjh21 static int vidcvideointr(void *);
194 1.25 bjh21 static void vidcvideo_config_wscons(struct fb_devconfig *);
195 1.1 reinoud
196 1.6 reinoud
197 1.1 reinoud /* Acceleration function prototypes */
198 1.25 bjh21 static void vv_copyrows(void *, int, int, int);
199 1.25 bjh21 static void vv_eraserows(void *, int, int, long);
200 1.25 bjh21 static void vv_putchar(void *c, int row, int col, u_int uc, long attr);
201 1.1 reinoud
202 1.1 reinoud
203 1.1 reinoud static int
204 1.1 reinoud vidcvideo_match(parent, match, aux)
205 1.1 reinoud struct device *parent;
206 1.1 reinoud struct cfdata *match;
207 1.1 reinoud void *aux;
208 1.1 reinoud {
209 1.25 bjh21
210 1.1 reinoud /* Can't probe AFAIK ; how ? */
211 1.25 bjh21 return 1;
212 1.1 reinoud }
213 1.1 reinoud
214 1.1 reinoud
215 1.1 reinoud static void
216 1.25 bjh21 vidcvideo_getdevconfig(vaddr_t dense_addr, struct fb_devconfig *dc)
217 1.1 reinoud {
218 1.25 bjh21
219 1.1 reinoud dc->dc_vaddr = dense_addr;
220 1.11 reinoud (void) pmap_extract(pmap_kernel(), dc->dc_vaddr, &(dc->dc_paddr));
221 1.1 reinoud
222 1.1 reinoud vidcvideo_getmode(&dc->mode_info);
223 1.1 reinoud
224 1.27 bjh21 dc->dc_wid = dc->mode_info.timings.hdisplay;
225 1.27 bjh21 dc->dc_ht = dc->mode_info.timings.vdisplay;
226 1.1 reinoud dc->dc_log2_depth = dc->mode_info.log2_bpp;
227 1.1 reinoud dc->dc_depth = 1 << dc->dc_log2_depth;
228 1.1 reinoud dc->dc_videobase = dc->dc_vaddr;
229 1.1 reinoud dc->dc_blanked = 0;
230 1.1 reinoud
231 1.1 reinoud /* this should/could be done somewhat more elegant! */
232 1.1 reinoud switch (dc->dc_depth) {
233 1.1 reinoud case 1:
234 1.1 reinoud dc->dc_rowbytes = dc->dc_wid / 8;
235 1.1 reinoud break;
236 1.1 reinoud case 2:
237 1.1 reinoud dc->dc_rowbytes = dc->dc_wid / 4;
238 1.1 reinoud break;
239 1.1 reinoud case 4:
240 1.1 reinoud dc->dc_rowbytes = dc->dc_wid / 2;
241 1.1 reinoud break;
242 1.1 reinoud case 8:
243 1.1 reinoud dc->dc_rowbytes = dc->dc_wid;
244 1.1 reinoud break;
245 1.1 reinoud case 16:
246 1.1 reinoud dc->dc_rowbytes = dc->dc_wid * 2;
247 1.1 reinoud break;
248 1.1 reinoud case 32:
249 1.1 reinoud dc->dc_rowbytes = dc->dc_wid * 4;
250 1.1 reinoud break;
251 1.1 reinoud default:
252 1.1 reinoud printf("Unknown colour depth %d ... what to do ?", dc->dc_depth);
253 1.1 reinoud break;
254 1.25 bjh21 }
255 1.1 reinoud
256 1.1 reinoud /* euhm... correct ? i.e. not complete VIDC memory */
257 1.27 bjh21 dc->dc_size = dc->mode_info.timings.vdisplay * dc->dc_rowbytes;
258 1.1 reinoud
259 1.1 reinoud /* initialize colormap and cursor resource */
260 1.1 reinoud vidcvideo_colourmap_and_cursor_init(dc);
261 1.1 reinoud
262 1.1 reinoud dc->rinfo.ri_flg = 0; /* RI_CENTER; */
263 1.1 reinoud dc->rinfo.ri_depth = dc->dc_depth;
264 1.1 reinoud dc->rinfo.ri_bits = (void *) dc->dc_videobase;
265 1.1 reinoud dc->rinfo.ri_width = dc->dc_wid;
266 1.1 reinoud dc->rinfo.ri_height = dc->dc_ht;
267 1.1 reinoud dc->rinfo.ri_stride = dc->dc_rowbytes;
268 1.9 reinoud dc->rinfo.ri_hw = dc; /* link back */
269 1.9 reinoud
270 1.9 reinoud /* intitialise miscelanious */
271 1.9 reinoud dc->dc_writeback_delay = 0;
272 1.1 reinoud }
273 1.1 reinoud
274 1.1 reinoud
275 1.1 reinoud static void
276 1.25 bjh21 vidcvideo_config_wscons(struct fb_devconfig *dc)
277 1.1 reinoud {
278 1.4 ad int i, cookie, font_not_locked;
279 1.1 reinoud
280 1.25 bjh21 /*
281 1.25 bjh21 * clear the screen ; why not a memset ? - it was this way so
282 1.25 bjh21 * keep it for now
283 1.25 bjh21 */
284 1.1 reinoud for (i = 0; i < dc->dc_ht * dc->dc_rowbytes; i += sizeof(u_int32_t))
285 1.1 reinoud *(u_int32_t *)(dc->dc_videobase + i) = 0x0;
286 1.1 reinoud
287 1.1 reinoud wsfont_init();
288 1.1 reinoud
289 1.1 reinoud /* prefer 8 pixel wide font */
290 1.4 ad cookie = wsfont_find(NULL, 8, 0, 0, WSDISPLAY_FONTORDER_L2R,
291 1.4 ad WSDISPLAY_FONTORDER_L2R);
292 1.4 ad if (cookie <= 0)
293 1.4 ad cookie = wsfont_find(NULL, 0, 0, 0, WSDISPLAY_FONTORDER_L2R,
294 1.4 ad WSDISPLAY_FONTORDER_L2R);
295 1.1 reinoud
296 1.1 reinoud if (cookie < 0) {
297 1.1 reinoud /* Can I even print here ? */
298 1.1 reinoud printf("Font table empty! exiting\n");
299 1.1 reinoud return;
300 1.25 bjh21 }
301 1.1 reinoud
302 1.4 ad font_not_locked = wsfont_lock(cookie, &dc->rinfo.ri_font);
303 1.1 reinoud
304 1.1 reinoud dc->rinfo.ri_wsfcookie = cookie;
305 1.1 reinoud
306 1.1 reinoud rasops_init(&dc->rinfo,
307 1.25 bjh21 dc->rinfo.ri_height / dc->rinfo.ri_font->fontheight,
308 1.25 bjh21 dc->rinfo.ri_width / dc->rinfo.ri_font->fontwidth);
309 1.1 reinoud
310 1.6 reinoud /*
311 1.6 reinoud * Provide a hook for the acceleration functions and make a copy of the
312 1.6 reinoud * original rasops functions for passing on calls
313 1.6 reinoud */
314 1.6 reinoud dc->rinfo.ri_hw = dc;
315 1.25 bjh21 memcpy(&(dc->orig_ri_ops), &(dc->rinfo.ri_ops),
316 1.25 bjh21 sizeof(struct wsdisplay_emulops));
317 1.6 reinoud
318 1.6 reinoud /* add our accelerated functions */
319 1.1 reinoud dc->rinfo.ri_ops.eraserows = vv_eraserows;
320 1.1 reinoud dc->rinfo.ri_ops.copyrows = vv_copyrows;
321 1.1 reinoud
322 1.6 reinoud /* add the extra activity measuring functions; they just delegate on */
323 1.6 reinoud dc->rinfo.ri_ops.putchar = vv_putchar;
324 1.6 reinoud
325 1.1 reinoud /* XXX shouldn't be global */
326 1.1 reinoud vidcvideo_stdscreen.nrows = dc->rinfo.ri_rows;
327 1.1 reinoud vidcvideo_stdscreen.ncols = dc->rinfo.ri_cols;
328 1.1 reinoud vidcvideo_stdscreen.textops = &dc->rinfo.ri_ops;
329 1.1 reinoud vidcvideo_stdscreen.capabilities = dc->rinfo.ri_caps;
330 1.1 reinoud
331 1.25 bjh21 if (font_not_locked)
332 1.1 reinoud printf(" warning ... couldn't lock font! ");
333 1.1 reinoud }
334 1.1 reinoud
335 1.1 reinoud
336 1.1 reinoud static void
337 1.25 bjh21 vidcvideo_attach(struct device *parent, struct device *self, void *aux)
338 1.1 reinoud {
339 1.1 reinoud struct vidcvideo_softc *sc = (struct vidcvideo_softc *)self;
340 1.9 reinoud struct fb_devconfig *dc;
341 1.1 reinoud struct wsemuldisplaydev_attach_args waa;
342 1.1 reinoud struct hwcmap256 *cm;
343 1.1 reinoud const u_int8_t *p;
344 1.6 reinoud long defattr;
345 1.1 reinoud int index;
346 1.1 reinoud
347 1.1 reinoud vidcvideo_init();
348 1.1 reinoud if (sc->nscreens == 0) {
349 1.6 reinoud sc->sc_dc = &vidcvideo_console_dc;
350 1.6 reinoud if (!vidcvideo_is_console) {
351 1.6 reinoud printf(" : non console (no kbd yet) ");
352 1.6 reinoud vidcvideo_getdevconfig(videomemory.vidm_vbase, sc->sc_dc);
353 1.6 reinoud vidcvideo_config_wscons(sc->sc_dc);
354 1.13 junyoung (*sc->sc_dc->rinfo.ri_ops.allocattr)(&sc->sc_dc->rinfo, 0, 0, 0, &defattr);
355 1.25 bjh21 }
356 1.1 reinoud sc->nscreens = 1;
357 1.1 reinoud } else {
358 1.24 snj printf(": already attached ... can't cope with this\n");
359 1.1 reinoud return;
360 1.25 bjh21 }
361 1.1 reinoud
362 1.9 reinoud dc = sc->sc_dc;
363 1.9 reinoud
364 1.1 reinoud vidcvideo_printdetails();
365 1.28 bjh21 printf(": mode %s, %dbpp\n", dc->mode_info.timings.name,
366 1.9 reinoud dc->dc_depth);
367 1.1 reinoud
368 1.1 reinoud /* initialise rasops */
369 1.9 reinoud cm = &dc->dc_cmap;
370 1.1 reinoud p = rasops_cmap;
371 1.1 reinoud for (index = 0; index < CMAP_SIZE; index++, p += 3) {
372 1.1 reinoud cm->r[index] = p[0];
373 1.1 reinoud cm->g[index] = p[1];
374 1.1 reinoud cm->b[index] = p[2];
375 1.1 reinoud }
376 1.1 reinoud
377 1.1 reinoud /* set up interrupt flags */
378 1.33 chris vidcvideo_queue_dc_change(dc, WSDISPLAY_CMAP_DOLUT);
379 1.1 reinoud
380 1.6 reinoud /*
381 1.6 reinoud * Set up a link in the rasops structure to our device config
382 1.6 reinoud * for acceleration stuff
383 1.6 reinoud */
384 1.9 reinoud dc->rinfo.ri_hw = sc->sc_dc;
385 1.1 reinoud
386 1.1 reinoud /* Establish an interrupt handler, and clear any pending interrupts */
387 1.33 chris dc->dc_ih = intr_claim(IRQ_FLYBACK, IPL_TTY, "vblank", vidcvideointr, dc);
388 1.1 reinoud
389 1.1 reinoud waa.console = (vidcvideo_is_console ? 1 : 0);
390 1.1 reinoud waa.scrdata = &vidcvideo_screenlist;
391 1.1 reinoud waa.accessops = &vidcvideo_accessops;
392 1.1 reinoud waa.accesscookie = sc;
393 1.1 reinoud
394 1.1 reinoud config_found(self, &waa, wsemuldisplaydevprint);
395 1.1 reinoud }
396 1.1 reinoud
397 1.1 reinoud
398 1.1 reinoud static int
399 1.31 christos vidcvideoioctl(void *v, void *vs, u_long cmd, void *data, int flag,
400 1.25 bjh21 struct lwp *l)
401 1.1 reinoud {
402 1.1 reinoud struct vidcvideo_softc *sc = v;
403 1.1 reinoud struct fb_devconfig *dc = sc->sc_dc;
404 1.1 reinoud int state;
405 1.1 reinoud
406 1.1 reinoud switch (cmd) {
407 1.1 reinoud case WSDISPLAYIO_GTYPE:
408 1.1 reinoud *(u_int *)data = WSDISPLAY_TYPE_VIDC;
409 1.25 bjh21 return 0;
410 1.1 reinoud
411 1.1 reinoud case WSDISPLAYIO_GINFO:
412 1.1 reinoud #define wsd_fbip ((struct wsdisplay_fbinfo *)data)
413 1.9 reinoud wsd_fbip->height = dc->dc_ht;
414 1.9 reinoud wsd_fbip->width = dc->dc_wid;
415 1.9 reinoud wsd_fbip->depth = dc->dc_depth;
416 1.1 reinoud wsd_fbip->cmsize = CMAP_SIZE;
417 1.1 reinoud #undef fbt
418 1.25 bjh21 return 0;
419 1.1 reinoud
420 1.1 reinoud case WSDISPLAYIO_GETCMAP:
421 1.1 reinoud return get_cmap(sc, (struct wsdisplay_cmap *)data);
422 1.1 reinoud
423 1.1 reinoud case WSDISPLAYIO_PUTCMAP:
424 1.1 reinoud return set_cmap(sc, (struct wsdisplay_cmap *)data);
425 1.1 reinoud
426 1.1 reinoud case WSDISPLAYIO_SVIDEO:
427 1.1 reinoud state = *(int *)data;
428 1.1 reinoud dc->dc_blanked = (state == WSDISPLAYIO_VIDEO_OFF);
429 1.33 chris vidcvideo_queue_dc_change(dc, WSDISPLAY_VIDEO_ONOFF);
430 1.1 reinoud /* done on video blank */
431 1.25 bjh21 return 0;
432 1.1 reinoud
433 1.1 reinoud case WSDISPLAYIO_GVIDEO:
434 1.1 reinoud *(u_int *)data = dc->dc_blanked ?
435 1.1 reinoud WSDISPLAYIO_VIDEO_OFF : WSDISPLAYIO_VIDEO_ON;
436 1.25 bjh21 return 0;
437 1.1 reinoud
438 1.1 reinoud case WSDISPLAYIO_GCURPOS:
439 1.9 reinoud *(struct wsdisplay_curpos *)data = dc->dc_cursor.cc_pos;
440 1.25 bjh21 return 0;
441 1.1 reinoud
442 1.1 reinoud case WSDISPLAYIO_SCURPOS:
443 1.1 reinoud set_curpos(sc, (struct wsdisplay_curpos *)data);
444 1.33 chris vidcvideo_queue_dc_change(dc, WSDISPLAY_CURSOR_DOPOS);
445 1.25 bjh21 return 0;
446 1.1 reinoud
447 1.1 reinoud case WSDISPLAYIO_GCURMAX:
448 1.1 reinoud ((struct wsdisplay_curpos *)data)->x = CURSOR_MAX_WIDTH;
449 1.1 reinoud ((struct wsdisplay_curpos *)data)->y = CURSOR_MAX_HEIGHT;
450 1.25 bjh21 return 0;
451 1.1 reinoud
452 1.1 reinoud case WSDISPLAYIO_GCURSOR:
453 1.1 reinoud return get_cursor(sc, (struct wsdisplay_cursor *)data);
454 1.1 reinoud
455 1.1 reinoud case WSDISPLAYIO_SCURSOR:
456 1.1 reinoud return set_cursor(sc, (struct wsdisplay_cursor *)data);
457 1.1 reinoud
458 1.1 reinoud case WSDISPLAYIO_SMODE:
459 1.1 reinoud state = *(int *)data;
460 1.25 bjh21 if (state == WSDISPLAYIO_MODE_MAPPED)
461 1.1 reinoud dc->dc_hwscroll_cookie = vidcvideo_hwscroll_reset();
462 1.25 bjh21 if (state == WSDISPLAYIO_MODE_EMUL)
463 1.1 reinoud vidcvideo_hwscroll_back(dc->dc_hwscroll_cookie);
464 1.1 reinoud vidcvideo_progr_scroll();
465 1.11 reinoud
466 1.25 bjh21 return 0;
467 1.1 reinoud }
468 1.5 atatat return EPASSTHROUGH;
469 1.1 reinoud }
470 1.1 reinoud
471 1.1 reinoud
472 1.1 reinoud paddr_t
473 1.25 bjh21 vidcvideommap(void *v, void *vs, off_t offset, int prot)
474 1.1 reinoud {
475 1.1 reinoud struct vidcvideo_softc *sc = v;
476 1.1 reinoud
477 1.1 reinoud if (offset >= sc->sc_dc->dc_size || offset < 0)
478 1.25 bjh21 return -1;
479 1.11 reinoud
480 1.11 reinoud return arm_btop(sc->sc_dc->dc_paddr + offset);
481 1.1 reinoud }
482 1.1 reinoud
483 1.1 reinoud
484 1.1 reinoud static int
485 1.25 bjh21 vidcvideo_alloc_screen(void *v, const struct wsscreen_descr *type,
486 1.25 bjh21 void **cookiep, int *curxp, int *curyp, long *attrp)
487 1.1 reinoud {
488 1.1 reinoud struct vidcvideo_softc *sc = v;
489 1.9 reinoud struct fb_devconfig *dc = sc->sc_dc;
490 1.1 reinoud long defattr;
491 1.1 reinoud
492 1.6 reinoud /*
493 1.6 reinoud * One and just only one for now :( ... if the vidcconsole is not the
494 1.6 reinoud * console then this makes one wsconsole screen free for use !
495 1.6 reinoud */
496 1.6 reinoud if ((sc->nscreens > 1) || vidcvideo_is_console)
497 1.25 bjh21 return ENOMEM;
498 1.1 reinoud
499 1.6 reinoud /* Add the screen to wscons to control */
500 1.9 reinoud *cookiep = &dc->rinfo;
501 1.1 reinoud *curxp = 0;
502 1.1 reinoud *curyp = 0;
503 1.9 reinoud vidcvideo_getdevconfig(videomemory.vidm_vbase, dc);
504 1.9 reinoud vidcvideo_config_wscons(dc);
505 1.13 junyoung (*dc->rinfo.ri_ops.allocattr)(&dc->rinfo, 0, 0, 0, &defattr);
506 1.1 reinoud *attrp = defattr;
507 1.1 reinoud sc->nscreens++;
508 1.6 reinoud
509 1.25 bjh21 return 0;
510 1.1 reinoud }
511 1.1 reinoud
512 1.1 reinoud
513 1.1 reinoud static void
514 1.25 bjh21 vidcvideo_free_screen(void *v, void *cookie)
515 1.1 reinoud {
516 1.1 reinoud struct vidcvideo_softc *sc = v;
517 1.1 reinoud
518 1.1 reinoud if (sc->sc_dc == &vidcvideo_console_dc)
519 1.1 reinoud panic("vidcvideo_free_screen: console");
520 1.1 reinoud
521 1.1 reinoud sc->nscreens--;
522 1.1 reinoud }
523 1.1 reinoud
524 1.1 reinoud
525 1.1 reinoud static int
526 1.25 bjh21 vidcvideo_show_screen(void *v, void *cookie, int waitok,
527 1.25 bjh21 void (*cb)(void *, int, int), void *cbarg)
528 1.1 reinoud {
529 1.1 reinoud
530 1.25 bjh21 return 0;
531 1.1 reinoud }
532 1.1 reinoud
533 1.1 reinoud
534 1.1 reinoud /* EXPORT */ int
535 1.25 bjh21 vidcvideo_cnattach(vaddr_t addr)
536 1.1 reinoud {
537 1.1 reinoud struct fb_devconfig *dcp = &vidcvideo_console_dc;
538 1.1 reinoud long defattr;
539 1.1 reinoud
540 1.1 reinoud vidcvideo_init();
541 1.1 reinoud vidcvideo_getdevconfig(addr, dcp);
542 1.1 reinoud vidcvideo_config_wscons(dcp);
543 1.13 junyoung (*dcp->rinfo.ri_ops.allocattr)(&dcp->rinfo, 0, 0, 0, &defattr);
544 1.1 reinoud wsdisplay_cnattach(&vidcvideo_stdscreen, &dcp->rinfo, 0, 0, defattr);
545 1.1 reinoud
546 1.1 reinoud vidcvideo_is_console = 1;
547 1.25 bjh21 return 0;
548 1.1 reinoud }
549 1.1 reinoud
550 1.1 reinoud
551 1.1 reinoud static int
552 1.25 bjh21 vidcvideointr(void *arg)
553 1.1 reinoud {
554 1.9 reinoud struct fb_devconfig *dc = arg;
555 1.33 chris
556 1.33 chris return flush_dc_changes_to_screen(dc);
557 1.33 chris }
558 1.33 chris
559 1.33 chris static int
560 1.33 chris flush_dc_changes_to_screen(struct fb_devconfig *dc)
561 1.33 chris {
562 1.9 reinoud int v, cleared = 0;
563 1.1 reinoud
564 1.33 chris v = dc->_internal_dc_changed;
565 1.33 chris
566 1.33 chris if (v == 0) {
567 1.33 chris disable_irq(IRQ_FLYBACK);
568 1.25 bjh21 return 1;
569 1.33 chris }
570 1.1 reinoud
571 1.9 reinoud if (v & WSDISPLAY_WB_COUNTER) {
572 1.9 reinoud dc->dc_writeback_delay--;
573 1.9 reinoud if (dc->dc_writeback_delay == 0) {
574 1.9 reinoud cpu_dcache_wb_range(dc->dc_vaddr, dc->dc_size);
575 1.9 reinoud cleared |= WSDISPLAY_WB_COUNTER;
576 1.25 bjh21 }
577 1.9 reinoud }
578 1.9 reinoud
579 1.1 reinoud if (v & WSDISPLAY_CMAP_DOLUT) {
580 1.9 reinoud struct hwcmap256 *cm = &dc->dc_cmap;
581 1.1 reinoud int index;
582 1.1 reinoud
583 1.9 reinoud if (dc->dc_depth == 4) {
584 1.1 reinoud /* palette for 4 bpp is different from 8bpp */
585 1.1 reinoud vidcvideo_write(VIDC_PALREG, 0x00000000);
586 1.9 reinoud for (index=0; index < (1 << dc->dc_depth); index++)
587 1.1 reinoud vidcvideo_write(VIDC_PALETTE,
588 1.1 reinoud VIDC_COL(cm->r[index],
589 1.1 reinoud cm->g[index],
590 1.1 reinoud cm->b[index]));
591 1.25 bjh21 }
592 1.1 reinoud
593 1.9 reinoud if (dc->dc_depth == 8) {
594 1.25 bjh21 /*
595 1.25 bjh21 * dunno what to do in more than 8bpp
596 1.25 bjh21 * palettes only make sense in 8bpp and less modes
597 1.25 bjh21 * on VIDC
598 1.25 bjh21 */
599 1.1 reinoud vidcvideo_write(VIDC_PALREG, 0x00000000);
600 1.1 reinoud for (index = 0; index < CMAP_SIZE; index++) {
601 1.1 reinoud vidcvideo_write(VIDC_PALETTE,
602 1.25 bjh21 VIDC_COL(cm->r[index], cm->g[index],
603 1.25 bjh21 cm->b[index]));
604 1.25 bjh21 }
605 1.25 bjh21 }
606 1.9 reinoud cleared |= WSDISPLAY_CMAP_DOLUT;
607 1.1 reinoud }
608 1.1 reinoud
609 1.1 reinoud if (v & WSDISPLAY_VIDEO_ONOFF) {
610 1.9 reinoud vidcvideo_blank(dc->dc_blanked);
611 1.9 reinoud cleared |= WSDISPLAY_VIDEO_ONOFF;
612 1.25 bjh21 }
613 1.1 reinoud
614 1.1 reinoud if (v & (WSDISPLAY_CURSOR_DOPOS | WSDISPLAY_CURSOR_DOHOT)) {
615 1.1 reinoud int x, y;
616 1.9 reinoud x = dc->dc_cursor.cc_pos.x - dc->dc_cursor.cc_hot.x;
617 1.9 reinoud y = dc->dc_cursor.cc_pos.y - dc->dc_cursor.cc_hot.y;
618 1.1 reinoud
619 1.1 reinoud vidcvideo_updatecursor(x, y);
620 1.9 reinoud cleared |= WSDISPLAY_CURSOR_DOPOS | WSDISPLAY_CURSOR_DOHOT;
621 1.25 bjh21 }
622 1.1 reinoud
623 1.1 reinoud if (v & WSDISPLAY_CURSOR_DOCUR) {
624 1.9 reinoud vidcvideo_enablecursor(dc->dc_curenb);
625 1.9 reinoud cleared |= WSDISPLAY_CURSOR_DOCUR;
626 1.25 bjh21 }
627 1.1 reinoud
628 1.33 chris dc->_internal_dc_changed ^= cleared;
629 1.33 chris
630 1.33 chris if (dc->_internal_dc_changed == 0) {
631 1.33 chris disable_irq(IRQ_FLYBACK);
632 1.33 chris }
633 1.9 reinoud
634 1.25 bjh21 return 1;
635 1.1 reinoud }
636 1.1 reinoud
637 1.1 reinoud
638 1.33 chris static void vidcvideo_queue_dc_change(struct fb_devconfig *dc, int dc_change)
639 1.33 chris {
640 1.33 chris dc->_internal_dc_changed |= dc_change;
641 1.33 chris
642 1.33 chris if (current_spl_level == _SPL_HIGH) {
643 1.33 chris /* running in ddb or without interrupts */
644 1.33 chris dc->dc_writeback_delay = 1;
645 1.33 chris flush_dc_changes_to_screen(dc);
646 1.33 chris } else {
647 1.33 chris /*
648 1.33 chris * running with interrupts so handle this in the next
649 1.33 chris * vsync
650 1.33 chris */
651 1.33 chris if (dc->dc_ih) {
652 1.33 chris enable_irq(IRQ_FLYBACK);
653 1.33 chris }
654 1.33 chris }
655 1.33 chris }
656 1.33 chris
657 1.33 chris
658 1.1 reinoud static u_char ri_col_data[6][6] = {
659 1.1 reinoud { 0, 0, 0, 0, 0, 0}, /* 1 bpp */
660 1.1 reinoud { 0, 0, 0, 0, 0, 0}, /* 2 bpp */
661 1.1 reinoud { 0, 0, 0, 0, 0, 0}, /* 4 bpp */
662 1.1 reinoud { 0, 0, 0, 0, 0, 0}, /* 8 bpp */
663 1.12 bjh21 { 6, 5, 5, 0, 6, 11}, /* 16 bpp */
664 1.1 reinoud { 8, 8, 8, 0, 8, 16}, /* 32 bpp */
665 1.1 reinoud };
666 1.1 reinoud
667 1.1 reinoud static void
668 1.25 bjh21 vidcvideo_colourmap_and_cursor_init(struct fb_devconfig *dc)
669 1.1 reinoud {
670 1.1 reinoud struct rasops_info *ri = &dc->rinfo;
671 1.1 reinoud u_char *rgbdat;
672 1.1 reinoud
673 1.1 reinoud /* Whatever we do later... just make sure we have a
674 1.1 reinoud * sane palette to start with
675 1.1 reinoud */
676 1.1 reinoud vidcvideo_stdpalette();
677 1.1 reinoud
678 1.1 reinoud /* set up rgb bit pattern values for rasops_init */
679 1.1 reinoud rgbdat = ri_col_data[dc->dc_log2_depth];
680 1.1 reinoud ri->ri_rnum = rgbdat[0];
681 1.1 reinoud ri->ri_gnum = rgbdat[1];
682 1.1 reinoud ri->ri_bnum = rgbdat[2];
683 1.1 reinoud ri->ri_rpos = rgbdat[3];
684 1.1 reinoud ri->ri_gpos = rgbdat[4];
685 1.1 reinoud ri->ri_bpos = rgbdat[5];
686 1.1 reinoud }
687 1.1 reinoud
688 1.1 reinoud
689 1.1 reinoud static int
690 1.25 bjh21 get_cmap(struct vidcvideo_softc *sc, struct wsdisplay_cmap *p)
691 1.1 reinoud {
692 1.1 reinoud u_int index = p->index, count = p->count;
693 1.20 chs int error;
694 1.1 reinoud
695 1.14 itojun if (index >= CMAP_SIZE || count > CMAP_SIZE - index)
696 1.25 bjh21 return EINVAL;
697 1.1 reinoud
698 1.20 chs error = copyout(&sc->sc_dc->dc_cmap.r[index], p->red, count);
699 1.20 chs if (error)
700 1.20 chs return error;
701 1.20 chs error = copyout(&sc->sc_dc->dc_cmap.g[index], p->green, count);
702 1.20 chs if (error)
703 1.20 chs return error;
704 1.20 chs error = copyout(&sc->sc_dc->dc_cmap.b[index], p->blue, count);
705 1.20 chs return error;
706 1.1 reinoud }
707 1.1 reinoud
708 1.1 reinoud
709 1.1 reinoud static int
710 1.25 bjh21 set_cmap(struct vidcvideo_softc *sc, struct wsdisplay_cmap *p)
711 1.1 reinoud {
712 1.9 reinoud struct fb_devconfig *dc = sc->sc_dc;
713 1.20 chs struct hwcmap256 cmap;
714 1.1 reinoud u_int index = p->index, count = p->count;
715 1.20 chs int error;
716 1.1 reinoud
717 1.1 reinoud if (index >= CMAP_SIZE || (index + count) > CMAP_SIZE)
718 1.25 bjh21 return EINVAL;
719 1.1 reinoud
720 1.20 chs error = copyin(p->red, &cmap.r[index], count);
721 1.20 chs if (error)
722 1.20 chs return error;
723 1.20 chs error = copyin(p->green, &cmap.g[index], count);
724 1.20 chs if (error)
725 1.20 chs return error;
726 1.20 chs error = copyin(p->blue, &cmap.b[index], count);
727 1.20 chs if (error)
728 1.20 chs return error;
729 1.20 chs memcpy(&dc->dc_cmap.r[index], &cmap.r[index], count);
730 1.20 chs memcpy(&dc->dc_cmap.g[index], &cmap.g[index], count);
731 1.20 chs memcpy(&dc->dc_cmap.b[index], &cmap.b[index], count);
732 1.33 chris vidcvideo_queue_dc_change(dc, WSDISPLAY_CMAP_DOLUT);
733 1.25 bjh21 return 0;
734 1.1 reinoud }
735 1.1 reinoud
736 1.1 reinoud
737 1.1 reinoud static int
738 1.25 bjh21 set_cursor(struct vidcvideo_softc *sc, struct wsdisplay_cursor *p)
739 1.1 reinoud {
740 1.9 reinoud #define cc (&dc->dc_cursor)
741 1.9 reinoud struct fb_devconfig *dc = sc->sc_dc;
742 1.20 chs u_int v, index = 0, count = 0, icount = 0;
743 1.20 chs uint8_t r[2], g[2], b[2], image[512], mask[512];
744 1.20 chs int error;
745 1.19 he
746 1.19 he /* XXX gcc does not detect identical conditions */
747 1.19 he index = count = icount = 0;
748 1.1 reinoud
749 1.1 reinoud v = p->which;
750 1.1 reinoud if (v & WSDISPLAY_CURSOR_DOCMAP) {
751 1.1 reinoud index = p->cmap.index;
752 1.1 reinoud count = p->cmap.count;
753 1.20 chs if (index >= CURSOR_MAX_COLOURS ||
754 1.20 chs (index + count) > CURSOR_MAX_COLOURS)
755 1.25 bjh21 return EINVAL;
756 1.20 chs error = copyin(p->cmap.red, &r[index], count);
757 1.20 chs if (error)
758 1.20 chs return error;
759 1.20 chs error = copyin(p->cmap.green, &g[index], count);
760 1.20 chs if (error)
761 1.20 chs return error;
762 1.20 chs error = copyin(p->cmap.blue, &b[index], count);
763 1.20 chs if (error)
764 1.20 chs return error;
765 1.1 reinoud }
766 1.1 reinoud if (v & WSDISPLAY_CURSOR_DOSHAPE) {
767 1.20 chs if (p->size.x > CURSOR_MAX_WIDTH ||
768 1.20 chs p->size.y > CURSOR_MAX_HEIGHT)
769 1.25 bjh21 return EINVAL;
770 1.1 reinoud icount = sizeof(u_int32_t) * p->size.y;
771 1.20 chs error = copyin(p->image, &image, icount);
772 1.20 chs if (error)
773 1.20 chs return error;
774 1.20 chs error = copyin(p->mask, &mask, icount);
775 1.20 chs if (error)
776 1.20 chs return error;
777 1.1 reinoud }
778 1.1 reinoud
779 1.1 reinoud if (v & WSDISPLAY_CURSOR_DOCUR)
780 1.9 reinoud dc->dc_curenb = p->enable;
781 1.1 reinoud if (v & WSDISPLAY_CURSOR_DOPOS)
782 1.1 reinoud set_curpos(sc, &p->pos);
783 1.1 reinoud if (v & WSDISPLAY_CURSOR_DOHOT)
784 1.1 reinoud cc->cc_hot = p->hot;
785 1.1 reinoud if (v & WSDISPLAY_CURSOR_DOCMAP) {
786 1.20 chs memcpy(&cc->cc_color[index], &r[index], count);
787 1.20 chs memcpy(&cc->cc_color[index + 2], &g[index], count);
788 1.20 chs memcpy(&cc->cc_color[index + 4], &b[index], count);
789 1.1 reinoud }
790 1.1 reinoud if (v & WSDISPLAY_CURSOR_DOSHAPE) {
791 1.1 reinoud cc->cc_size = p->size;
792 1.1 reinoud memset(cc->cc_image, 0, sizeof cc->cc_image);
793 1.20 chs memcpy(cc->cc_image, image, icount);
794 1.1 reinoud memset(cc->cc_mask, 0, sizeof cc->cc_mask);
795 1.20 chs memcpy(cc->cc_mask, mask, icount);
796 1.1 reinoud }
797 1.33 chris vidcvideo_queue_dc_change(dc, v);
798 1.1 reinoud
799 1.25 bjh21 return 0;
800 1.1 reinoud #undef cc
801 1.1 reinoud }
802 1.1 reinoud
803 1.1 reinoud
804 1.1 reinoud static int
805 1.25 bjh21 get_cursor(struct vidcvideo_softc *sc, struct wsdisplay_cursor *p)
806 1.1 reinoud {
807 1.25 bjh21
808 1.25 bjh21 return EPASSTHROUGH; /* XXX */
809 1.1 reinoud }
810 1.1 reinoud
811 1.1 reinoud
812 1.1 reinoud static void
813 1.25 bjh21 set_curpos(struct vidcvideo_softc *sc, struct wsdisplay_curpos *curpos)
814 1.1 reinoud {
815 1.1 reinoud struct fb_devconfig *dc = sc->sc_dc;
816 1.1 reinoud int x = curpos->x, y = curpos->y;
817 1.1 reinoud
818 1.1 reinoud if (y < 0)
819 1.1 reinoud y = 0;
820 1.1 reinoud else if (y > dc->dc_ht)
821 1.1 reinoud y = dc->dc_ht;
822 1.1 reinoud if (x < 0)
823 1.1 reinoud x = 0;
824 1.1 reinoud else if (x > dc->dc_wid)
825 1.1 reinoud x = dc->dc_wid;
826 1.9 reinoud dc->dc_cursor.cc_pos.x = x;
827 1.9 reinoud dc->dc_cursor.cc_pos.y = y;
828 1.1 reinoud }
829 1.1 reinoud
830 1.1 reinoud
831 1.25 bjh21 static void vv_copyrows(void *id, int srcrow, int dstrow, int nrows)
832 1.1 reinoud {
833 1.1 reinoud struct rasops_info *ri = id;
834 1.1 reinoud int height, offset, size;
835 1.1 reinoud int scrollup, scrolldown;
836 1.1 reinoud unsigned char *src, *dst;
837 1.33 chris struct fb_devconfig *dc = (struct fb_devconfig *) (ri->ri_hw);
838 1.1 reinoud
839 1.1 reinoud /* All movements are done in multiples of character heigths */
840 1.1 reinoud height = ri->ri_font->fontheight * nrows;
841 1.1 reinoud offset = (srcrow - dstrow) * ri->ri_yscale;
842 1.1 reinoud size = height * ri->ri_stride;
843 1.1 reinoud
844 1.1 reinoud /* check if we are full screen scrolling */
845 1.1 reinoud scrollup = (srcrow + nrows >= ri->ri_rows);
846 1.1 reinoud scrolldown = (dstrow + nrows >= ri->ri_rows);
847 1.1 reinoud
848 1.25 bjh21 if ((scrollup || scrolldown) &&
849 1.25 bjh21 (videomemory.vidm_type == VIDEOMEM_TYPE_VRAM)) {
850 1.1 reinoud ri->ri_bits = vidcvideo_hwscroll(offset);
851 1.1 reinoud vidcvideo_progr_scroll(); /* sadistic ; shouldnt this be on vsync? */
852 1.1 reinoud
853 1.1 reinoud /* wipe out remains of the screen if nessisary */
854 1.25 bjh21 if (ri->ri_emuheight != ri->ri_height)
855 1.25 bjh21 vv_eraserows(id, ri->ri_rows, 1, 0);
856 1.1 reinoud return;
857 1.25 bjh21 }
858 1.1 reinoud
859 1.25 bjh21 /*
860 1.25 bjh21 * Else we just copy the area : we're braindead for now
861 1.25 bjh21 * Note: we can't use hardware scrolling when the softc isnt
862 1.25 bjh21 * known yet... if its not known we dont have interrupts and
863 1.25 bjh21 * we can't change the display address reliable other than in
864 1.25 bjh21 * a Vsync
865 1.1 reinoud */
866 1.1 reinoud
867 1.1 reinoud src = ri->ri_bits + srcrow * ri->ri_font->fontheight * ri->ri_stride;
868 1.1 reinoud dst = ri->ri_bits + dstrow * ri->ri_font->fontheight * ri->ri_stride;
869 1.1 reinoud
870 1.32 chris memmove(dst, src, size);
871 1.33 chris
872 1.33 chris /* delay the write back operation of the screen area */
873 1.33 chris dc->dc_writeback_delay = SCREEN_WRITE_BACK_DELAY;
874 1.33 chris vidcvideo_queue_dc_change(dc, WSDISPLAY_WB_COUNTER);
875 1.1 reinoud }
876 1.1 reinoud
877 1.1 reinoud
878 1.25 bjh21 static void vv_eraserows(void *id, int startrow, int nrows, long attr)
879 1.1 reinoud {
880 1.1 reinoud struct rasops_info *ri = id;
881 1.1 reinoud int height;
882 1.1 reinoud unsigned char *src;
883 1.33 chris struct fb_devconfig *dc = (struct fb_devconfig *) (ri->ri_hw);
884 1.1 reinoud
885 1.1 reinoud /* we're braindead for now */
886 1.1 reinoud height = ri->ri_font->fontheight * nrows * ri->ri_stride;
887 1.1 reinoud
888 1.1 reinoud src = ri->ri_bits + startrow * ri->ri_font->fontheight * ri->ri_stride;
889 1.1 reinoud
890 1.26 bjh21 memset(src, 0, height);
891 1.33 chris
892 1.33 chris /* delay the write back operation of the screen area */
893 1.33 chris dc->dc_writeback_delay = SCREEN_WRITE_BACK_DELAY;
894 1.33 chris vidcvideo_queue_dc_change(dc, WSDISPLAY_WB_COUNTER);
895 1.6 reinoud }
896 1.6 reinoud
897 1.6 reinoud
898 1.25 bjh21 static void vv_putchar(void *id, int row, int col, u_int uc, long attr)
899 1.6 reinoud {
900 1.6 reinoud struct rasops_info *ri = id;
901 1.6 reinoud struct fb_devconfig *dc = (struct fb_devconfig *) (ri->ri_hw);
902 1.9 reinoud
903 1.33 chris /* just delegate */
904 1.33 chris dc->orig_ri_ops.putchar(id, row, col, uc, attr);
905 1.33 chris
906 1.9 reinoud /* delay the write back operation of the screen area */
907 1.9 reinoud dc->dc_writeback_delay = SCREEN_WRITE_BACK_DELAY;
908 1.33 chris vidcvideo_queue_dc_change(dc, WSDISPLAY_WB_COUNTER);
909 1.1 reinoud }
910