Split device_t and softc, aprintify

This commit is contained in:
jmcneill 2008-03-27 11:58:18 +00:00
parent 010b86ace4
commit d7e505a90f

View File

@ -1,7 +1,7 @@
/* $NetBSD: unichromefb.c,v 1.11 2008/03/12 18:11:38 phx Exp $ */
/* $NetBSD: unichromefb.c,v 1.12 2008/03/27 11:58:18 jmcneill Exp $ */
/*-
* Copyright (c) 2006 Jared D. McNeill <jmcneill@invisible.ca>
* Copyright (c) 2006, 2008 Jared D. McNeill <jmcneill@invisible.ca>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -57,7 +57,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: unichromefb.c,v 1.11 2008/03/12 18:11:38 phx Exp $");
__KERNEL_RCSID(0, "$NetBSD: unichromefb.c,v 1.12 2008/03/27 11:58:18 jmcneill Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -99,7 +99,7 @@ __KERNEL_RCSID(0, "$NetBSD: unichromefb.c,v 1.11 2008/03/12 18:11:38 phx Exp $")
#define UNICHROMEFB_HEIGHT 1024
struct unichromefb_softc {
struct device sc_dev;
device_t sc_dev;
struct vcons_data sc_vd;
void * sc_fbbase;
unsigned int sc_fbaddr;
@ -230,7 +230,7 @@ struct wsscreen_list unichromefb_screenlist = {
_unichromefb_scrlist
};
CFATTACH_DECL(unichromefb, sizeof(struct unichromefb_softc),
CFATTACH_DECL_NEW(unichromefb, sizeof(struct unichromefb_softc),
unichromefb_match, unichromefb_attach, NULL, NULL);
static int
@ -258,16 +258,16 @@ unichromefb_match(struct device *parent, struct cfdata *match, void *opaque)
static void
unichromefb_attach(struct device *parent, struct device *self, void *opaque)
{
struct unichromefb_softc *sc;
struct unichromefb_softc *sc = device_private(self);
struct pci_attach_args *pa;
struct rasops_info *ri;
struct wsemuldisplaydev_attach_args aa;
uint8_t val;
long defattr;
sc = (struct unichromefb_softc *)self;
pa = (struct pci_attach_args *)opaque;
sc->sc_dev = self;
sc->sc_width = UNICHROMEFB_WIDTH;
sc->sc_height = UNICHROMEFB_HEIGHT;
sc->sc_depth = UNICHROMEFB_DEPTH;
@ -318,8 +318,7 @@ unichromefb_attach(struct device *parent, struct device *self, void *opaque)
aprint_normal(": VIA UniChrome frame buffer\n");
if (sc->sc_accel)
aprint_normal("%s: MMIO @0x%08x/0x%x\n",
sc->sc_dev.dv_xname,
aprint_normal_dev(self, "MMIO @0x%08x/0x%x\n",
(uint32_t)sc->sc_mmiobase,
(uint32_t)sc->sc_mmiosize);
@ -338,7 +337,7 @@ unichromefb_attach(struct device *parent, struct device *self, void *opaque)
uni_fillrect(sc, 0, 0, sc->sc_width, sc->sc_height, 0);
}
aprint_normal("%s: FB @0x%08x (%dx%dx%d)\n", sc->sc_dev.dv_xname,
aprint_normal_dev(self, "FB @0x%08x (%dx%dx%d)\n",
sc->sc_fbaddr, sc->sc_width, sc->sc_height, sc->sc_depth);
unichromefb_console_screen.scr_flags |= VCONS_SCREEN_IS_STATIC;
@ -376,7 +375,7 @@ unichromefb_drm_print(void *opaque, const char *pnp)
static int
unichromefb_drm_unmap(struct unichromefb_softc *sc)
{
printf("%s: releasing bus resources\n", sc->sc_dev.dv_xname);
aprint_debug_dev(sc->sc_dev, "releasing bus resources\n");
bus_space_unmap(sc->sc_apmemt, sc->sc_apmemh, sc->sc_fbsize);
bus_space_unmap(sc->sc_memt, sc->sc_memh, sc->sc_mmiosize);
@ -393,15 +392,15 @@ unichromefb_drm_map(struct unichromefb_softc *sc)
rv = bus_space_map(sc->sc_iot, VIA_REGBASE, 0x20, 0,
&sc->sc_ioh);
if (rv) {
printf("%s: failed to map I/O registers\n",
sc->sc_dev.dv_xname);
aprint_error_dev(sc->sc_dev, "failed to map I/O registers\n");
return rv;
}
rv = bus_space_map(sc->sc_apmemt, sc->sc_fbaddr, sc->sc_fbsize,
BUS_SPACE_MAP_LINEAR, &sc->sc_apmemh);
if (rv) {
printf("%s: failed to map aperture at 0x%08x/0x%x\n",
sc->sc_dev.dv_xname, sc->sc_fbaddr, sc->sc_fbsize);
aprint_error_dev(sc->sc_dev,
"failed to map aperture at 0x%08x/0x%x\n",
sc->sc_fbaddr, sc->sc_fbsize);
return rv;
}
sc->sc_fbbase = (void *)bus_space_vaddr(sc->sc_apmemt, sc->sc_apmemh);
@ -409,18 +408,16 @@ unichromefb_drm_map(struct unichromefb_softc *sc)
&sc->sc_memt, &sc->sc_memh, &sc->sc_mmiobase,
&sc->sc_mmiosize);
if (rv) {
printf("%s: failed to map MMIO registers\n",
sc->sc_dev.dv_xname);
aprint_error_dev(sc->sc_dev, "failed to map MMIO registers\n");
sc->sc_accel = 0;
}
uni_setmode(sc, UNICHROMEFB_MODE, sc->sc_depth);
uni_init_dac(sc, IGA1);
if (sc->sc_accel) {
if (sc->sc_accel)
uni_init_accel(sc);
}
printf("%s: re-acquired bus resources\n", sc->sc_dev.dv_xname);
aprint_debug_dev(sc->sc_dev, "re-acquired bus resources\n");
return 0;
}
@ -633,7 +630,8 @@ uni_setmode(struct unichromefb_softc *sc, int idx, int bpp)
/* XXX */
vtbl = uni_getmode(idx);
if (vtbl == NULL)
panic("%s: unsupported mode: %d\n", sc->sc_dev.dv_xname, idx);
panic("%s: unsupported mode: %d\n",
device_xname(sc->sc_dev), idx);
crt = vtbl->crtc;
@ -900,14 +898,15 @@ uni_load_crtc(struct unichromefb_softc *sc,
reg = iga1_crtc_reg.ver_sync_end.reg;
break;
default:
printf("%s: unknown index %d while setting up CRTC\n",
sc->sc_dev.dv_xname, i);
aprint_error_dev(sc->sc_dev,
"unknown index %d while setting up CRTC\n",
i);
break;
}
break;
case IGA2:
printf("%s: %s: IGA2 not supported\n",
sc->sc_dev.dv_xname, __func__);
aprint_error_dev(sc->sc_dev, "%s: IGA2 not supported\n",
__func__);
break;
}
@ -982,7 +981,7 @@ uni_load_offset(struct unichromefb_softc *sc, int haddr, int bpp, int iga)
VIACR);
break;
default:
printf("%s: %s: only IGA1 is supported\n", sc->sc_dev.dv_xname,
aprint_error_dev(sc->sc_dev, "%s: only IGA1 is supported\n",
__func__);
break;
}
@ -1003,7 +1002,7 @@ uni_load_fetchcnt(struct unichromefb_softc *sc, int haddr, int bpp, int iga)
VIASR);
break;
default:
printf("%s: %s: only IGA1 is supported\n", sc->sc_dev.dv_xname,
aprint_error_dev(sc->sc_dev, "%s: only IGA1 is supported\n",
__func__);
break;
}
@ -1063,7 +1062,7 @@ uni_load_fifo(struct unichromefb_softc *sc, int iga, int horact, int veract)
break;
default:
printf("%s: %s: only IGA1 is supported\n", sc->sc_dev.dv_xname,
aprint_error_dev(sc->sc_dev, "%s: only IGA1 is supported\n",
__func__);
break;
}
@ -1087,12 +1086,12 @@ uni_set_depth(struct unichromefb_softc *sc, int bpp, int iga)
uni_wr_mask(sc, VIASR, SR15, 0x22, 0xfe);
break;
default:
printf("%s: %s: mode (%d) unsupported\n",
sc->sc_dev.dv_xname, __func__, bpp);
aprint_error_dev(sc->sc_dev,
"%s: mode (%d) unsupported\n", __func__, bpp);
}
break;
default:
printf("%s: %s: only IGA1 is supported\n", sc->sc_dev.dv_xname,
aprint_error_dev(sc->sc_dev, "%s: only IGA1 is supported\n",
__func__);
break;
}
@ -1110,8 +1109,7 @@ uni_get_clkval(struct unichromefb_softc *sc, int clk)
}
}
aprint_error("%s: can't find matching PLL value\n",
sc->sc_dev.dv_xname);
aprint_error_dev(sc->sc_dev, "can't find matching PLL value\n");
return 0;
}
@ -1132,7 +1130,7 @@ uni_set_vclk(struct unichromefb_softc *sc, uint32_t clk, int iga)
uni_wr(sc, VIASR, SR46, clk % 0x100);
break;
default:
printf("%s: %s: only IGA1 is supported\n", sc->sc_dev.dv_xname,
aprint_error_dev(sc->sc_dev, "%s: only IGA1 is supported\n",
__func__);
break;
}
@ -1268,7 +1266,7 @@ uni_wait_idle(struct unichromefb_softc *sc)
;
if (loop >= MAXLOOP)
aprint_error("%s: engine stall\n", sc->sc_dev.dv_xname);
aprint_error_dev(sc->sc_dev, "engine stall\n");
return;
}