Thu Oct 4 10:22:45 2012 UTC ()
don't call allocattr() for the default attribute


(macallan)
diff -r1.35 -r1.36 src/sys/dev/pci/r128fb.c

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

--- src/sys/dev/pci/r128fb.c 2012/05/23 18:39:30 1.35
+++ src/sys/dev/pci/r128fb.c 2012/10/04 10:22:45 1.36
@@ -1,17 +1,17 @@ @@ -1,17 +1,17 @@
1/* $NetBSD: r128fb.c,v 1.35 2012/05/23 18:39:30 macallan Exp $ */ 1/* $NetBSD: r128fb.c,v 1.36 2012/10/04 10:22:45 macallan Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2007 Michael Lorenz 4 * Copyright (c) 2007, 2012 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.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
@@ -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.35 2012/05/23 18:39:30 macallan Exp $"); 34__KERNEL_RCSID(0, "$NetBSD: r128fb.c,v 1.36 2012/10/04 10:22:45 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>
@@ -217,27 +217,27 @@ r128fb_attach(device_t parent, device_t  @@ -217,27 +217,27 @@ r128fb_attach(device_t parent, device_t
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 227
228#ifdef GLYPHCACHE_DEBUG 228#ifdef GLYPHCACHE_DEBUG
229 /* leave some visible VRAM unused so we can see the glyph cache */ 229 /* leave some visible VRAM unused so we can see the glyph cache */
230 sc->sc_height -= 100; 230 sc->sc_height -= 200;
231#endif 231#endif
232 232
233 if (!prop_dictionary_get_uint32(dict, "depth", &sc->sc_depth)) { 233 if (!prop_dictionary_get_uint32(dict, "depth", &sc->sc_depth)) {
234 aprint_error("%s: no depth property\n", device_xname(self)); 234 aprint_error("%s: no depth property\n", device_xname(self));
235 return; 235 return;
236 } 236 }
237 if (!prop_dictionary_get_uint32(dict, "linebytes", &sc->sc_stride)) { 237 if (!prop_dictionary_get_uint32(dict, "linebytes", &sc->sc_stride)) {
238 aprint_error("%s: no linebytes property\n", 238 aprint_error("%s: no linebytes property\n",
239 device_xname(self)); 239 device_xname(self));
240 return; 240 return;
241 } 241 }
242 242
243 prop_dictionary_get_bool(dict, "is_console", &is_console); 243 prop_dictionary_get_bool(dict, "is_console", &is_console);
@@ -369,27 +369,28 @@ r128fb_ioctl(void *v, void *vs, u_long c @@ -369,27 +369,28 @@ r128fb_ioctl(void *v, void *vs, u_long c
369 369
370 switch (cmd) { 370 switch (cmd) {
371 case WSDISPLAYIO_GTYPE: 371 case WSDISPLAYIO_GTYPE:
372 *(u_int *)data = WSDISPLAY_TYPE_PCIMISC; 372 *(u_int *)data = WSDISPLAY_TYPE_PCIMISC;
373 return 0; 373 return 0;
374 374
375 /* PCI config read/write passthrough. */ 375 /* PCI config read/write passthrough. */
376 case PCI_IOC_CFGREAD: 376 case PCI_IOC_CFGREAD:
377 case PCI_IOC_CFGWRITE: 377 case PCI_IOC_CFGWRITE:
378 return pci_devioctl(sc->sc_pc, sc->sc_pcitag, 378 return pci_devioctl(sc->sc_pc, sc->sc_pcitag,
379 cmd, data, flag, l); 379 cmd, data, flag, l);
380 380
381 case WSDISPLAYIO_GET_BUSID: 381 case WSDISPLAYIO_GET_BUSID:
382 return wsdisplayio_busid_pci(sc->sc_dev, sc->sc_pc, sc->sc_pcitag, data); 382 return wsdisplayio_busid_pci(sc->sc_dev, sc->sc_pc,
 383 sc->sc_pcitag, data);
383 384
384 case WSDISPLAYIO_GINFO: 385 case WSDISPLAYIO_GINFO:
385 if (ms == NULL) 386 if (ms == NULL)
386 return ENODEV; 387 return ENODEV;
387 wdf = (void *)data; 388 wdf = (void *)data;
388 wdf->height = ms->scr_ri.ri_height; 389 wdf->height = ms->scr_ri.ri_height;
389 wdf->width = ms->scr_ri.ri_width; 390 wdf->width = ms->scr_ri.ri_width;
390 wdf->depth = ms->scr_ri.ri_depth; 391 wdf->depth = ms->scr_ri.ri_depth;
391 wdf->cmsize = 256; 392 wdf->cmsize = 256;
392 return 0; 393 return 0;
393 394
394 case WSDISPLAYIO_GETCMAP: 395 case WSDISPLAYIO_GETCMAP:
395 return r128fb_getcmap(sc, 396 return r128fb_getcmap(sc,
@@ -539,28 +540,26 @@ r128fb_init_screen(void *cookie, struct  @@ -539,28 +540,26 @@ r128fb_init_screen(void *cookie, struct
539#endif 540#endif
540 541
541 rasops_reconfig(ri, sc->sc_height / ri->ri_font->fontheight, 542 rasops_reconfig(ri, sc->sc_height / ri->ri_font->fontheight,
542 sc->sc_width / ri->ri_font->fontwidth); 543 sc->sc_width / ri->ri_font->fontwidth);
543 544
544 ri->ri_hw = scr; 545 ri->ri_hw = scr;
545 ri->ri_ops.copyrows = r128fb_copyrows; 546 ri->ri_ops.copyrows = r128fb_copyrows;
546 ri->ri_ops.copycols = r128fb_copycols; 547 ri->ri_ops.copycols = r128fb_copycols;
547 ri->ri_ops.eraserows = r128fb_eraserows; 548 ri->ri_ops.eraserows = r128fb_eraserows;
548 ri->ri_ops.erasecols = r128fb_erasecols; 549 ri->ri_ops.erasecols = r128fb_erasecols;
549 ri->ri_ops.cursor = r128fb_cursor; 550 ri->ri_ops.cursor = r128fb_cursor;
550 if (FONT_IS_ALPHA(ri->ri_font)) { 551 if (FONT_IS_ALPHA(ri->ri_font)) {
551 ri->ri_ops.putchar = r128fb_putchar_aa; 552 ri->ri_ops.putchar = r128fb_putchar_aa;
552 ri->ri_ops.allocattr(ri, WS_DEFAULT_FG, WS_DEFAULT_BG, 
553 0, &sc->sc_gc.gc_attr); 
554 } else 553 } else
555 ri->ri_ops.putchar = r128fb_putchar; 554 ri->ri_ops.putchar = r128fb_putchar;
556} 555}
557 556
558static int 557static int
559r128fb_putcmap(struct r128fb_softc *sc, struct wsdisplay_cmap *cm) 558r128fb_putcmap(struct r128fb_softc *sc, struct wsdisplay_cmap *cm)
560{ 559{
561 u_char *r, *g, *b; 560 u_char *r, *g, *b;
562 u_int index = cm->index; 561 u_int index = cm->index;
563 u_int count = cm->count; 562 u_int count = cm->count;
564 int i, error; 563 int i, error;
565 u_char rbuf[256], gbuf[256], bbuf[256]; 564 u_char rbuf[256], gbuf[256], bbuf[256];
566 565