diff options
author | Jacob Meuser <jakemsr@cvs.openbsd.org> | 2009-09-09 07:16:51 +0000 |
---|---|---|
committer | Jacob Meuser <jakemsr@cvs.openbsd.org> | 2009-09-09 07:16:51 +0000 |
commit | 6389a0f6f9c5477c9d6993d3529e449ac1193e8c (patch) | |
tree | 6298d20ba7af091262f5badf07d9887b919f4bca /sys/dev | |
parent | a47ae3fd41b55eb872f242d006f24f22b1118178 (diff) |
move code to reset the controller from the attach function to it's
own function
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/pci/azalia.c | 48 |
1 files changed, 31 insertions, 17 deletions
diff --git a/sys/dev/pci/azalia.c b/sys/dev/pci/azalia.c index 76ad06b2250..63065cbd9fa 100644 --- a/sys/dev/pci/azalia.c +++ b/sys/dev/pci/azalia.c @@ -1,4 +1,4 @@ -/* $OpenBSD: azalia.c,v 1.147 2009/09/09 03:15:04 jakemsr Exp $ */ +/* $OpenBSD: azalia.c,v 1.148 2009/09/09 07:16:50 jakemsr Exp $ */ /* $NetBSD: azalia.c,v 1.20 2006/05/07 08:31:44 kent Exp $ */ /*- @@ -187,6 +187,7 @@ int azalia_pci_activate(struct device *, enum devact); int azalia_pci_detach(struct device *, int); int azalia_intr(void *); void azalia_print_codec(codec_t *); +int azalia_reset(azalia_t *); int azalia_attach(azalia_t *); void azalia_attach_intr(struct device *); void azalia_shutdown(void *); @@ -597,22 +598,10 @@ azalia_print_codec(codec_t *codec) } int -azalia_attach(azalia_t *az) +azalia_reset(azalia_t *az) { - int i, n; uint32_t gctl; - uint16_t gcap; - uint16_t statests; - - DPRINTF(("%s: host: High Definition Audio rev. %d.%d\n", - XNAME(az), AZ_READ_1(az, VMAJ), AZ_READ_1(az, VMIN))); - gcap = AZ_READ_2(az, GCAP); - az->nistreams = HDA_GCAP_ISS(gcap); - az->nostreams = HDA_GCAP_OSS(gcap); - az->nbstreams = HDA_GCAP_BSS(gcap); - az->ok64 = (gcap & HDA_GCAP_64OK) != 0; - DPRINTF(("%s: host: %d output, %d input, and %d bidi streams\n", - XNAME(az), az->nostreams, az->nistreams, az->nbstreams)); + int i; /* 4.2.2 Starting the High Definition Audio Controller */ DPRINTF(("%s: resetting\n", __func__)); @@ -626,7 +615,7 @@ azalia_attach(azalia_t *az) DPRINTF(("%s: reset counter = %d\n", __func__, i)); if (i <= 0) { printf("%s: reset failure\n", XNAME(az)); - return ETIMEDOUT; + return(ETIMEDOUT); } DELAY(1000); gctl = AZ_READ_4(az, GCTL); @@ -639,9 +628,34 @@ azalia_attach(azalia_t *az) DPRINTF(("%s: reset counter = %d\n", __func__, i)); if (i <= 0) { printf("%s: reset-exit failure\n", XNAME(az)); - return ETIMEDOUT; + return(ETIMEDOUT); } + return(0); +} + +int +azalia_attach(azalia_t *az) +{ + int i, n, err; + uint32_t gctl; + uint16_t gcap; + uint16_t statests; + + DPRINTF(("%s: host: High Definition Audio rev. %d.%d\n", + XNAME(az), AZ_READ_1(az, VMAJ), AZ_READ_1(az, VMIN))); + gcap = AZ_READ_2(az, GCAP); + az->nistreams = HDA_GCAP_ISS(gcap); + az->nostreams = HDA_GCAP_OSS(gcap); + az->nbstreams = HDA_GCAP_BSS(gcap); + az->ok64 = (gcap & HDA_GCAP_64OK) != 0; + DPRINTF(("%s: host: %d output, %d input, and %d bidi streams\n", + XNAME(az), az->nostreams, az->nistreams, az->nbstreams)); + + err = azalia_reset(az); + if (err) + return(err); + /* enable unsolicited response */ gctl = AZ_READ_4(az, GCTL); AZ_WRITE_4(az, GCTL, gctl | HDA_GCTL_UNSOL); |