device_t/softc split and other related cosmetic changes.
This commit is contained in:
parent
6dc246f785
commit
e9025ab64a
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: auich.c,v 1.126 2008/04/28 20:23:54 martin Exp $ */
|
||||
/* $NetBSD: auich.c,v 1.127 2008/05/04 15:58:51 xtraeme Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2000, 2004, 2005 The NetBSD Foundation, Inc.
|
||||
|
@ -111,7 +111,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: auich.c,v 1.126 2008/04/28 20:23:54 martin Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: auich.c,v 1.127 2008/05/04 15:58:51 xtraeme Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -162,10 +162,10 @@ struct auich_cdata {
|
|||
#define ICH_MICI_OFF(x) ICH_CDOFF(ic_dmalist_mici[(x)])
|
||||
|
||||
struct auich_softc {
|
||||
struct device sc_dev;
|
||||
device_t sc_dev;
|
||||
void *sc_ih;
|
||||
|
||||
struct device *sc_audiodev;
|
||||
device_t sc_audiodev;
|
||||
audio_device_t sc_audev;
|
||||
|
||||
pci_chipset_tag_t sc_pc;
|
||||
|
@ -238,13 +238,13 @@ int auich_debug = 0xfffe;
|
|||
#define DPRINTF(x,y) /* nothing */
|
||||
#endif
|
||||
|
||||
static int auich_match(struct device *, struct cfdata *, void *);
|
||||
static void auich_attach(struct device *, struct device *, void *);
|
||||
static int auich_detach(struct device *, int);
|
||||
static int auich_activate(struct device *, enum devact);
|
||||
static int auich_match(device_t, cfdata_t, void *);
|
||||
static void auich_attach(device_t, device_t, void *);
|
||||
static int auich_detach(device_t, int);
|
||||
static int auich_activate(device_t, enum devact);
|
||||
static int auich_intr(void *);
|
||||
|
||||
CFATTACH_DECL(auich, sizeof(struct auich_softc),
|
||||
CFATTACH_DECL_NEW(auich, sizeof(struct auich_softc),
|
||||
auich_match, auich_attach, auich_detach, auich_activate);
|
||||
|
||||
static int auich_open(void *, int);
|
||||
|
@ -283,7 +283,7 @@ static int auich_freemem(struct auich_softc *, struct auich_dma *);
|
|||
static bool auich_resume(device_t PMF_FN_PROTO);
|
||||
static int auich_set_rate(struct auich_softc *, int, u_long);
|
||||
static int auich_sysctl_verify(SYSCTLFN_ARGS);
|
||||
static void auich_finish_attach(struct device *);
|
||||
static void auich_finish_attach(device_t);
|
||||
static void auich_calibrate(struct auich_softc *);
|
||||
static void auich_clear_cas(struct auich_softc *);
|
||||
|
||||
|
@ -427,8 +427,7 @@ auich_lookup(struct pci_attach_args *pa, const struct auich_devtype *auich_devic
|
|||
}
|
||||
|
||||
static int
|
||||
auich_match(struct device *parent, struct cfdata *match,
|
||||
void *aux)
|
||||
auich_match(device_t parent, cfdata_t match, void *aux)
|
||||
{
|
||||
struct pci_attach_args *pa;
|
||||
|
||||
|
@ -442,9 +441,9 @@ auich_match(struct device *parent, struct cfdata *match,
|
|||
}
|
||||
|
||||
static void
|
||||
auich_attach(struct device *parent, struct device *self, void *aux)
|
||||
auich_attach(device_t parent, device_t self, void *aux)
|
||||
{
|
||||
struct auich_softc *sc;
|
||||
struct auich_softc *sc = device_private(self);
|
||||
struct pci_attach_args *pa;
|
||||
pcireg_t v, subdev;
|
||||
const char *intrstr;
|
||||
|
@ -452,7 +451,7 @@ auich_attach(struct device *parent, struct device *self, void *aux)
|
|||
const struct sysctlnode *node, *node_ac97clock;
|
||||
int err, node_mib, i;
|
||||
|
||||
sc = (struct auich_softc *)self;
|
||||
sc->sc_dev = self;
|
||||
pa = aux;
|
||||
|
||||
if ((d = auich_lookup(pa, auich_modem_devices)) != NULL) {
|
||||
|
@ -489,7 +488,7 @@ auich_attach(struct device *parent, struct device *self, void *aux)
|
|||
if (pci_mapreg_map(pa, ICH_NAMBAR, PCI_MAPREG_TYPE_IO,
|
||||
0, &sc->iot, &sc->mix_ioh, NULL,
|
||||
&sc->mix_size)) {
|
||||
aprint_error_dev(&sc->sc_dev, "can't map codec i/o space\n");
|
||||
aprint_error_dev(self, "can't map codec i/o space\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -501,19 +500,19 @@ auich_attach(struct device *parent, struct device *self, void *aux)
|
|||
if (pci_mapreg_map(pa, ICH_NABMBAR, PCI_MAPREG_TYPE_IO,
|
||||
0, &sc->iot, &sc->aud_ioh, NULL,
|
||||
&sc->aud_size)) {
|
||||
aprint_error_dev(&sc->sc_dev, "can't map device i/o space\n");
|
||||
aprint_error_dev(self, "can't map device i/o space\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (pci_mapreg_map(pa, ICH_NAMBAR, PCI_MAPREG_TYPE_IO, 0,
|
||||
&sc->iot, &sc->mix_ioh, NULL, &sc->mix_size)) {
|
||||
aprint_error_dev(&sc->sc_dev, "can't map codec i/o space\n");
|
||||
aprint_error_dev(self, "can't map codec i/o space\n");
|
||||
return;
|
||||
}
|
||||
if (pci_mapreg_map(pa, ICH_NABMBAR, PCI_MAPREG_TYPE_IO, 0,
|
||||
&sc->iot, &sc->aud_ioh, NULL, &sc->aud_size)) {
|
||||
aprint_error_dev(&sc->sc_dev, "can't map device i/o space\n");
|
||||
aprint_error_dev(self, "can't map device i/o space\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -526,25 +525,25 @@ auich_attach(struct device *parent, struct device *self, void *aux)
|
|||
|
||||
/* Map and establish the interrupt. */
|
||||
if (pci_intr_map(pa, &sc->intrh)) {
|
||||
aprint_error_dev(&sc->sc_dev, "can't map interrupt\n");
|
||||
aprint_error_dev(self, "can't map interrupt\n");
|
||||
return;
|
||||
}
|
||||
intrstr = pci_intr_string(pa->pa_pc, sc->intrh);
|
||||
sc->sc_ih = pci_intr_establish(pa->pa_pc, sc->intrh, IPL_AUDIO,
|
||||
auich_intr, sc);
|
||||
if (sc->sc_ih == NULL) {
|
||||
aprint_error_dev(&sc->sc_dev, "can't establish interrupt");
|
||||
aprint_error_dev(self, "can't establish interrupt");
|
||||
if (intrstr != NULL)
|
||||
aprint_normal(" at %s", intrstr);
|
||||
aprint_normal("\n");
|
||||
return;
|
||||
}
|
||||
aprint_normal_dev(&sc->sc_dev, "interrupting at %s\n", intrstr);
|
||||
aprint_normal_dev(self, "interrupting at %s\n", intrstr);
|
||||
|
||||
snprintf(sc->sc_audev.name, MAX_AUDIO_DEV_LEN, "%s AC97", d->shortname);
|
||||
snprintf(sc->sc_audev.version, MAX_AUDIO_DEV_LEN,
|
||||
"0x%02x", PCI_REVISION(pa->pa_class));
|
||||
strlcpy(sc->sc_audev.config, device_xname(&sc->sc_dev), MAX_AUDIO_DEV_LEN);
|
||||
strlcpy(sc->sc_audev.config, device_xname(self), MAX_AUDIO_DEV_LEN);
|
||||
|
||||
/* SiS 7012 needs special handling */
|
||||
if (d->id == PCIID_SIS7012) {
|
||||
|
@ -563,7 +562,7 @@ auich_attach(struct device *parent, struct device *self, void *aux)
|
|||
sc->sc_dmamap_flags = BUS_DMA_COHERENT;
|
||||
if (d->id == PCIID_440MX) {
|
||||
sc->sc_dmamap_flags |= BUS_DMA_NOCACHE;
|
||||
printf("%s: DMA bug workaround enabled\n", device_xname(&sc->sc_dev));
|
||||
aprint_normal_dev(self, "DMA bug workaround enabled\n");
|
||||
}
|
||||
|
||||
/* Set up DMA lists. */
|
||||
|
@ -647,7 +646,7 @@ auich_attach(struct device *parent, struct device *self, void *aux)
|
|||
if (err != 0)
|
||||
goto sysctl_err;
|
||||
err = sysctl_createv(&sc->sc_log, 0, NULL, &node, 0,
|
||||
CTLTYPE_NODE, device_xname(&sc->sc_dev), NULL, NULL, 0,
|
||||
CTLTYPE_NODE, device_xname(self), NULL, NULL, 0,
|
||||
NULL, 0, CTL_HW, CTL_CREATE, CTL_EOL);
|
||||
if (err != 0)
|
||||
goto sysctl_err;
|
||||
|
@ -670,7 +669,7 @@ auich_attach(struct device *parent, struct device *self, void *aux)
|
|||
|
||||
sysctl_err:
|
||||
printf("%s: failed to add sysctl nodes. (%d)\n",
|
||||
device_xname(&sc->sc_dev), err);
|
||||
device_xname(self), err);
|
||||
return; /* failure of sysctl is not fatal. */
|
||||
}
|
||||
|
||||
|
@ -750,15 +749,14 @@ auich_sysctl_verify(SYSCTLFN_ARGS)
|
|||
}
|
||||
|
||||
static void
|
||||
auich_finish_attach(struct device *self)
|
||||
auich_finish_attach(device_t self)
|
||||
{
|
||||
struct auich_softc *sc;
|
||||
struct auich_softc *sc = device_private(self);
|
||||
|
||||
sc = (void *)self;
|
||||
if (!AC97_IS_FIXED_RATE(sc->codec_if))
|
||||
auich_calibrate(sc);
|
||||
|
||||
sc->sc_audiodev = audio_attach_mi(&auich_hw_if, sc, &sc->sc_dev);
|
||||
sc->sc_audiodev = audio_attach_mi(&auich_hw_if, sc, sc->sc_dev);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -791,7 +789,7 @@ auich_read_codec(void *v, uint8_t reg, uint16_t *val)
|
|||
status & ~(ICH_SRI|ICH_PRI|ICH_GSCI));
|
||||
*val = 0xffff;
|
||||
DPRINTF(ICH_DEBUG_CODECIO,
|
||||
("%s: read_codec error\n", device_xname(&sc->sc_dev)));
|
||||
("%s: read_codec error\n", device_xname(sc->sc_dev)));
|
||||
if (reg == AC97_REG_GPIO_STATUS)
|
||||
auich_clear_cas(sc);
|
||||
return -1;
|
||||
|
@ -800,7 +798,7 @@ auich_read_codec(void *v, uint8_t reg, uint16_t *val)
|
|||
auich_clear_cas(sc);
|
||||
return 0;
|
||||
} else {
|
||||
aprint_normal_dev(&sc->sc_dev, "read_codec timeout\n");
|
||||
aprint_normal_dev(sc->sc_dev, "read_codec timeout\n");
|
||||
if (reg == AC97_REG_GPIO_STATUS)
|
||||
auich_clear_cas(sc);
|
||||
return -1;
|
||||
|
@ -826,7 +824,7 @@ auich_write_codec(void *v, uint8_t reg, uint16_t val)
|
|||
reg + (sc->sc_codecnum * ICH_CODEC_OFFSET), val);
|
||||
return 0;
|
||||
} else {
|
||||
aprint_normal_dev(&sc->sc_dev, "write_codec timeout\n");
|
||||
aprint_normal_dev(sc->sc_dev, "write_codec timeout\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -870,16 +868,16 @@ auich_reset_codec(void *v)
|
|||
DELAY(1);
|
||||
}
|
||||
if (i <= 0) {
|
||||
aprint_error_dev(&sc->sc_dev, "auich_reset_codec: time out\n");
|
||||
aprint_error_dev(sc->sc_dev, "auich_reset_codec: time out\n");
|
||||
return ETIMEDOUT;
|
||||
}
|
||||
#ifdef AUICH_DEBUG
|
||||
if (status & ICH_SCR)
|
||||
printf("%s: The 2nd codec is ready.\n",
|
||||
device_xname(&sc->sc_dev));
|
||||
device_xname(sc->sc_dev));
|
||||
if (status & ICH_S2CR)
|
||||
printf("%s: The 3rd codec is ready.\n",
|
||||
device_xname(&sc->sc_dev));
|
||||
device_xname(sc->sc_dev));
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
@ -1064,7 +1062,7 @@ auich_halt_output(void *v)
|
|||
struct auich_softc *sc;
|
||||
|
||||
sc = v;
|
||||
DPRINTF(ICH_DEBUG_DMA, ("%s: halt_output\n", device_xname(&sc->sc_dev)));
|
||||
DPRINTF(ICH_DEBUG_DMA, ("%s: halt_output\n", device_xname(sc->sc_dev)));
|
||||
|
||||
auich_halt_pipe(sc, ICH_PCMO);
|
||||
sc->pcmo.intr = NULL;
|
||||
|
@ -1078,7 +1076,7 @@ auich_halt_input(void *v)
|
|||
struct auich_softc *sc;
|
||||
|
||||
sc = v;
|
||||
DPRINTF(ICH_DEBUG_DMA, ("%s: halt_input\n", device_xname(&sc->sc_dev)));
|
||||
DPRINTF(ICH_DEBUG_DMA, ("%s: halt_input\n", device_xname(sc->sc_dev)));
|
||||
|
||||
auich_halt_pipe(sc, ICH_PCMI);
|
||||
sc->pcmi.intr = NULL;
|
||||
|
@ -1225,7 +1223,7 @@ auich_intr(void *v)
|
|||
|
||||
sc = v;
|
||||
|
||||
if (!device_has_power(&sc->sc_dev))
|
||||
if (!device_has_power(sc->sc_dev))
|
||||
return (0);
|
||||
|
||||
ret = 0;
|
||||
|
@ -1250,7 +1248,7 @@ auich_intr(void *v)
|
|||
("auich_intr: osts=0x%x\n", sts));
|
||||
|
||||
if (sts & ICH_FIFOE)
|
||||
printf("%s: fifo underrun\n", device_xname(&sc->sc_dev));
|
||||
printf("%s: fifo underrun\n", device_xname(sc->sc_dev));
|
||||
|
||||
if (sts & ICH_BCIS)
|
||||
auich_intr_pipe(sc, ICH_PCMO, &sc->pcmo);
|
||||
|
@ -1277,7 +1275,7 @@ auich_intr(void *v)
|
|||
("auich_intr: ists=0x%x\n", sts));
|
||||
|
||||
if (sts & ICH_FIFOE)
|
||||
printf("%s: fifo overrun\n", device_xname(&sc->sc_dev));
|
||||
printf("%s: fifo overrun\n", device_xname(sc->sc_dev));
|
||||
|
||||
if (sts & ICH_BCIS)
|
||||
auich_intr_pipe(sc, ICH_PCMI, &sc->pcmi);
|
||||
|
@ -1303,7 +1301,7 @@ auich_intr(void *v)
|
|||
("auich_intr: ists=0x%x\n", sts));
|
||||
|
||||
if (sts & ICH_FIFOE)
|
||||
printf("%s: fifo overrun\n", device_xname(&sc->sc_dev));
|
||||
printf("%s: fifo overrun\n", device_xname(sc->sc_dev));
|
||||
|
||||
if (sts & ICH_BCIS)
|
||||
auich_intr_pipe(sc, ICH_MICI, &sc->mici);
|
||||
|
@ -1318,7 +1316,7 @@ auich_intr(void *v)
|
|||
|
||||
#ifdef AUICH_MODEM_DEBUG
|
||||
if (sc->sc_codectype == AC97_CODEC_TYPE_MODEM && gsts & ICH_GSCI) {
|
||||
printf("%s: gsts=0x%x\n", device_xname(&sc->sc_dev), gsts);
|
||||
printf("%s: gsts=0x%x\n", device_xname(sc->sc_dev), gsts);
|
||||
/* int ack */
|
||||
bus_space_write_4(sc->iot, sc->aud_ioh,
|
||||
ICH_GSTS + sc->sc_modem_offset, ICH_GSCI);
|
||||
|
@ -1527,7 +1525,7 @@ auich_alloc_cdata(struct auich_softc *sc)
|
|||
if ((error = bus_dmamem_alloc(sc->dmat,
|
||||
sizeof(struct auich_cdata),
|
||||
PAGE_SIZE, 0, &seg, 1, &rseg, 0)) != 0) {
|
||||
aprint_error_dev(&sc->sc_dev, "unable to allocate control data, error = %d\n", error);
|
||||
aprint_error_dev(sc->sc_dev, "unable to allocate control data, error = %d\n", error);
|
||||
goto fail_0;
|
||||
}
|
||||
|
||||
|
@ -1535,14 +1533,14 @@ auich_alloc_cdata(struct auich_softc *sc)
|
|||
sizeof(struct auich_cdata),
|
||||
(void **) &sc->sc_cdata,
|
||||
sc->sc_dmamap_flags)) != 0) {
|
||||
aprint_error_dev(&sc->sc_dev, "unable to map control data, error = %d\n", error);
|
||||
aprint_error_dev(sc->sc_dev, "unable to map control data, error = %d\n", error);
|
||||
goto fail_1;
|
||||
}
|
||||
|
||||
if ((error = bus_dmamap_create(sc->dmat, sizeof(struct auich_cdata), 1,
|
||||
sizeof(struct auich_cdata), 0, 0,
|
||||
&sc->sc_cddmamap)) != 0) {
|
||||
aprint_error_dev(&sc->sc_dev, "unable to create control data DMA map, "
|
||||
aprint_error_dev(sc->sc_dev, "unable to create control data DMA map, "
|
||||
"error = %d\n", error);
|
||||
goto fail_2;
|
||||
}
|
||||
|
@ -1550,7 +1548,7 @@ auich_alloc_cdata(struct auich_softc *sc)
|
|||
if ((error = bus_dmamap_load(sc->dmat, sc->sc_cddmamap,
|
||||
sc->sc_cdata, sizeof(struct auich_cdata),
|
||||
NULL, 0)) != 0) {
|
||||
aprint_error_dev(&sc->sc_dev, "unable tp load control data DMA map, "
|
||||
aprint_error_dev(sc->sc_dev, "unable tp load control data DMA map, "
|
||||
"error = %d\n", error);
|
||||
goto fail_3;
|
||||
}
|
||||
|
@ -1679,7 +1677,7 @@ auich_calibrate(struct auich_softc *sc)
|
|||
|
||||
if (nciv == ociv) {
|
||||
printf("%s: ac97 link rate calibration timed out after %"
|
||||
PRIu64 " us\n", device_xname(&sc->sc_dev), wait_us);
|
||||
PRIu64 " us\n", device_xname(sc->sc_dev), wait_us);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1691,7 +1689,7 @@ auich_calibrate(struct auich_softc *sc)
|
|||
ac97rate = ((actual_48k_rate + 500) / 1000) * 1000;
|
||||
|
||||
printf("%s: measured ac97 link rate at %d Hz",
|
||||
device_xname(&sc->sc_dev), actual_48k_rate);
|
||||
device_xname(sc->sc_dev), actual_48k_rate);
|
||||
if (ac97rate != actual_48k_rate)
|
||||
printf(", will use %d Hz", ac97rate);
|
||||
printf("\n");
|
||||
|
|
Loading…
Reference in New Issue