Subject: kern/26432: auvia has no powerhook (fix included) (for inclusion in 2.0)
To: None <gnats-bugs@gnats.NetBSD.org>
From: Rhialto <rhialto@azenomei.knuffel.net>
List: netbsd-bugs
Date: 07/26/2004 15:34:52
>Number: 26432
>Category: kern
>Synopsis: auvia has no powerhook (fix included) (for inclusion in 2.0)
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: kern-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Jul 26 13:36:00 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator: Rhialto
>Release: NetBSD 2.0_BETA
>Organization:
>Environment:
System: NetBSD loelappie.falu.nl 2.0_BETA NetBSD 2.0_BETA (LOELAPPIE) #6: Mon Jul 26 14:58:37 CEST 2004 root@loelappie.falu.nl:/usr/src/sys/arch/i386/compile/LOELAPPIE i386
Architecture: i386
Machine: i386
auvia0 at pci0 dev 17 function 5: VIA VT82C686A AC'97 Audio (rev 0x40)
auvia0: interrupting at irq 9
auvia0: ac97: VIA Technologies VT1612A codec; headphone, 18 bit DAC, 18 bit ADC, KS Waves 3D
auvia0: ac97: ext id 201<AMAP,VRA>
audio0 at auvia0: full duplex, mmap, independent
>Description:
The audio on my laptop is muted after a suspend/resume cycle.
Furthermore the sample frequency is locked to 48 kHz.
This is because there are no powerhooks to set the audio chip.
The other little thing is the master volume. Since 2.0 BETA, it
is lower than it used to be after boot (the audio is barely
audible on my machine), and after a resume the master volume is
restored to that level.
>How-To-Repeat:
audioplay some.wav
(suspend)
(resume)
audioplay some.wav
>Fix:
I just transplanted the auich code into auvia, with a suitable
s/ich/via/. Perhaps this could be made some generic AC'97 code
somehow.
It would be nice if this could still be included in 2.0.
--- auviavar.h.orig 2002-10-16 17:27:28.000000000 +0200
+++ auviavar.h 2004-07-26 14:36:47.000000000 +0200
@@ -73,6 +73,11 @@
struct auvia_dma *sc_dmas;
struct auvia_softc_chan sc_play, sc_record;
+
+ /* Power Management */
+ void *sc_powerhook;
+ int sc_suspend;
+ u_int16_t ext_status;
};
#define IS_FIXED_RATE(codec) !((codec)->vtbl->get_extcaps(codec) \
--- auvia.c.orig 2004-04-01 07:23:14.000000000 +0200
+++ auvia.c 2004-07-26 14:53:52.000000000 +0200
@@ -113,9 +113,20 @@
void *, struct audio_params *);
int auvia_trigger_input(void *, void *, void *, int, void (*)(void *),
void *, struct audio_params *);
+void auvia_powerhook(int, void *);
int auvia_intr __P((void *));
+/* Debug */
+#ifdef AUDIO_DEBUG
+#define DPRINTF(l,x) do { if (auvia_debug & (l)) printf x; } while(0)
+int auvia_debug = 0xffff;
+#define VIA_DEBUG_CODECIO 0x0001
+#define VIA_DEBUG_DMA 0x0002
+#define VIA_DEBUG_PARAM 0x0004
+#else
+#define DPRINTF(x,y) /* nothing */
+#endif
CFATTACH_DECL(auvia, sizeof (struct auvia_softc),
auvia_match, auvia_attach, NULL, NULL);
@@ -367,6 +378,10 @@
return;
}
+ /* Watch for power change */
+ sc->sc_suspend = PWR_RESUME;
+ sc->sc_powerhook = powerhook_establish(auvia_powerhook, sc);
+
audio_attach_mi(&auvia_hw_if, sc, &sc->sc_dev);
}
@@ -1141,3 +1156,40 @@
return rval;
}
+
+void
+auvia_powerhook(int why, void *addr)
+{
+ struct auvia_softc *sc = (struct auvia_softc *)addr;
+
+ switch (why) {
+ case PWR_SUSPEND:
+ case PWR_STANDBY:
+ /* Power down */
+ DPRINTF(1, ("%s: power down\n", sc->sc_dev.dv_xname));
+ sc->sc_suspend = why;
+ auvia_read_codec(sc, AC97_REG_EXT_AUDIO_CTRL, &sc->ext_status);
+ break;
+
+ case PWR_RESUME:
+ /* Wake up */
+ DPRINTF(1, ("%s: power resume\n", sc->sc_dev.dv_xname));
+ if (sc->sc_suspend == PWR_RESUME) {
+ printf("%s: resume without suspend.\n",
+ sc->sc_dev.dv_xname);
+ sc->sc_suspend = why;
+ return;
+ }
+ sc->sc_suspend = why;
+ auvia_reset_codec(sc);
+ DELAY(1000);
+ (sc->codec_if->vtbl->restore_ports)(sc->codec_if);
+ auvia_write_codec(sc, AC97_REG_EXT_AUDIO_CTRL, sc->ext_status);
+ break;
+
+ case PWR_SOFTSUSPEND:
+ case PWR_SOFTSTANDBY:
+ case PWR_SOFTRESUME:
+ break;
+ }
+}
-Olaf.
--
___ Olaf 'Rhialto' Seibert
\X/ rhialto/at/xs4all.nl -- Cetero censeo "authored" delendum esse.
>Release-Note:
>Audit-Trail:
>Unformatted: