Thu Apr 19 08:59:42 2012 UTC ()
glyphcache_init() works much better with its parameters in the right order


(macallan)
diff -r1.33 -r1.34 src/sys/dev/pci/r128fb.c

cvs diff -r1.33 -r1.34 src/sys/dev/pci/r128fb.c (expand / switch to unified diff)

--- src/sys/dev/pci/r128fb.c 2012/04/19 06:58:55 1.33
+++ src/sys/dev/pci/r128fb.c 2012/04/19 08:59:42 1.34
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: r128fb.c,v 1.33 2012/04/19 06:58:55 macallan Exp $ */ 1/* $NetBSD: r128fb.c,v 1.34 2012/04/19 08:59:42 macallan Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2007 Michael Lorenz 4 * Copyright (c) 2007 Michael Lorenz
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -21,27 +21,27 @@ @@ -21,27 +21,27 @@
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28/* 28/*
29 * A console driver for ATI Rage 128 graphics controllers 29 * A console driver for ATI Rage 128 graphics controllers
30 * tested on macppc only so far 30 * tested on macppc only so far
31 */ 31 */
32 32
33#include <sys/cdefs.h> 33#include <sys/cdefs.h>
34__KERNEL_RCSID(0, "$NetBSD: r128fb.c,v 1.33 2012/04/19 06:58:55 macallan Exp $"); 34__KERNEL_RCSID(0, "$NetBSD: r128fb.c,v 1.34 2012/04/19 08:59:42 macallan Exp $");
35 35
36#include <sys/param.h> 36#include <sys/param.h>
37#include <sys/systm.h> 37#include <sys/systm.h>
38#include <sys/kernel.h> 38#include <sys/kernel.h>
39#include <sys/device.h> 39#include <sys/device.h>
40#include <sys/malloc.h> 40#include <sys/malloc.h>
41#include <sys/lwp.h> 41#include <sys/lwp.h>
42#include <sys/kauth.h> 42#include <sys/kauth.h>
43 43
44#include <dev/videomode/videomode.h> 44#include <dev/videomode/videomode.h>
45 45
46#include <dev/pci/pcivar.h> 46#include <dev/pci/pcivar.h>
47#include <dev/pci/pcireg.h> 47#include <dev/pci/pcireg.h>
@@ -214,26 +214,32 @@ r128fb_attach(device_t parent, device_t  @@ -214,26 +214,32 @@ r128fb_attach(device_t parent, device_t
214 214
215 pci_aprint_devinfo(pa, NULL); 215 pci_aprint_devinfo(pa, NULL);
216 216
217 /* fill in parameters from properties */ 217 /* fill in parameters from properties */
218 dict = device_properties(self); 218 dict = device_properties(self);
219 if (!prop_dictionary_get_uint32(dict, "width", &sc->sc_width)) { 219 if (!prop_dictionary_get_uint32(dict, "width", &sc->sc_width)) {
220 aprint_error("%s: no width property\n", device_xname(self)); 220 aprint_error("%s: no width property\n", device_xname(self));
221 return; 221 return;
222 } 222 }
223 if (!prop_dictionary_get_uint32(dict, "height", &sc->sc_height)) { 223 if (!prop_dictionary_get_uint32(dict, "height", &sc->sc_height)) {
224 aprint_error("%s: no height property\n", device_xname(self)); 224 aprint_error("%s: no height property\n", device_xname(self));
225 return; 225 return;
226 } 226 }
 227
 228#ifdef GLYPHCACHE_DEBUG
 229 /* leave some visible VRAM unused so we can see the glyph cache */
 230 sc->sc_height -= 100;
 231#endif
 232
227 if (!prop_dictionary_get_uint32(dict, "depth", &sc->sc_depth)) { 233 if (!prop_dictionary_get_uint32(dict, "depth", &sc->sc_depth)) {
228 aprint_error("%s: no depth property\n", device_xname(self)); 234 aprint_error("%s: no depth property\n", device_xname(self));
229 return; 235 return;
230 } 236 }
231 if (!prop_dictionary_get_uint32(dict, "linebytes", &sc->sc_stride)) { 237 if (!prop_dictionary_get_uint32(dict, "linebytes", &sc->sc_stride)) {
232 aprint_error("%s: no linebytes property\n", 238 aprint_error("%s: no linebytes property\n",
233 device_xname(self)); 239 device_xname(self));
234 return; 240 return;
235 } 241 }
236 242
237 prop_dictionary_get_bool(dict, "is_console", &is_console); 243 prop_dictionary_get_bool(dict, "is_console", &is_console);
238 244
239 if (pci_mapreg_info(pa->pa_pc, pa->pa_tag, 0x10, PCI_MAPREG_TYPE_MEM, 245 if (pci_mapreg_info(pa->pa_pc, pa->pa_tag, 0x10, PCI_MAPREG_TYPE_MEM,
@@ -278,43 +284,43 @@ r128fb_attach(device_t parent, device_t  @@ -278,43 +284,43 @@ r128fb_attach(device_t parent, device_t
278 sc->sc_gc.gc_rop = R128_ROP3_S; 284 sc->sc_gc.gc_rop = R128_ROP3_S;
279 if (is_console) { 285 if (is_console) {
280 vcons_init_screen(&sc->vd, &sc->sc_console_screen, 1, 286 vcons_init_screen(&sc->vd, &sc->sc_console_screen, 1,
281 &defattr); 287 &defattr);
282 sc->sc_console_screen.scr_flags |= VCONS_SCREEN_IS_STATIC; 288 sc->sc_console_screen.scr_flags |= VCONS_SCREEN_IS_STATIC;
283 289
284 r128fb_rectfill(sc, 0, 0, sc->sc_width, sc->sc_height, 290 r128fb_rectfill(sc, 0, 0, sc->sc_width, sc->sc_height,
285 ri->ri_devcmap[(defattr >> 16) & 0xff]); 291 ri->ri_devcmap[(defattr >> 16) & 0xff]);
286 sc->sc_defaultscreen_descr.textops = &ri->ri_ops; 292 sc->sc_defaultscreen_descr.textops = &ri->ri_ops;
287 sc->sc_defaultscreen_descr.capabilities = ri->ri_caps; 293 sc->sc_defaultscreen_descr.capabilities = ri->ri_caps;
288 sc->sc_defaultscreen_descr.nrows = ri->ri_rows; 294 sc->sc_defaultscreen_descr.nrows = ri->ri_rows;
289 sc->sc_defaultscreen_descr.ncols = ri->ri_cols; 295 sc->sc_defaultscreen_descr.ncols = ri->ri_cols;
290 glyphcache_init(&sc->sc_gc, sc->sc_height + 5, 296 glyphcache_init(&sc->sc_gc, sc->sc_height + 5,
291 sc->sc_width, 
292 (0x800000 / sc->sc_stride) - sc->sc_height - 5, 297 (0x800000 / sc->sc_stride) - sc->sc_height - 5,
 298 sc->sc_width,
293 ri->ri_font->fontwidth, 299 ri->ri_font->fontwidth,
294 ri->ri_font->fontheight, 300 ri->ri_font->fontheight,
295 defattr); 301 defattr);
296 wsdisplay_cnattach(&sc->sc_defaultscreen_descr, ri, 0, 0, 302 wsdisplay_cnattach(&sc->sc_defaultscreen_descr, ri, 0, 0,
297 defattr); 303 defattr);
298 vcons_replay_msgbuf(&sc->sc_console_screen); 304 vcons_replay_msgbuf(&sc->sc_console_screen);
299 } else { 305 } else {
300 /* 306 /*
301 * since we're not the console we can postpone the rest 307 * since we're not the console we can postpone the rest
302 * until someone actually allocates a screen for us 308 * until someone actually allocates a screen for us
303 */ 309 */
304 (*ri->ri_ops.allocattr)(ri, 0, 0, 0, &defattr); 310 (*ri->ri_ops.allocattr)(ri, 0, 0, 0, &defattr);
305 glyphcache_init(&sc->sc_gc, sc->sc_height, 311 glyphcache_init(&sc->sc_gc, sc->sc_height + 5,
 312 (0x800000 / sc->sc_stride) - sc->sc_height - 5,
306 sc->sc_width, 313 sc->sc_width,
307 (0x800000 / sc->sc_stride) - sc->sc_height, 
308 ri->ri_font->fontwidth, 314 ri->ri_font->fontwidth,
309 ri->ri_font->fontheight, 315 ri->ri_font->fontheight,
310 defattr); 316 defattr);
311 } 317 }
312 318
313 j = 0; 319 j = 0;
314 rasops_get_cmap(ri, cmap, sizeof(cmap)); 320 rasops_get_cmap(ri, cmap, sizeof(cmap));
315 for (i = 0; i < 256; i++) { 321 for (i = 0; i < 256; i++) {
316 sc->sc_cmap_red[i] = cmap[j]; 322 sc->sc_cmap_red[i] = cmap[j];
317 sc->sc_cmap_green[i] = cmap[j + 1]; 323 sc->sc_cmap_green[i] = cmap[j + 1];
318 sc->sc_cmap_blue[i] = cmap[j + 2]; 324 sc->sc_cmap_blue[i] = cmap[j + 2];
319 r128fb_putpalreg(sc, i, cmap[j], cmap[j + 1], cmap[j + 2]); 325 r128fb_putpalreg(sc, i, cmap[j], cmap[j + 1], cmap[j + 2]);
320 j += 3; 326 j += 3;