Module Name: src Committed By: snj Date: Mon Sep 28 00:40:21 UTC 2009
Modified Files: src/sys/dev/pci/hdaudio [netbsd-5]: hdaudio_afg.c Log Message: Pull up following revision(s) (requested by jmcneill in ticket #1024): sys/dev/pci/hdaudio/hdaudio_afg.c: revision 1.15 ensure that hp sensing is stopped on suspend, and restarted on resume if required. To generate a diff of this commit: cvs rdiff -u -r1.14.2.2 -r1.14.2.3 src/sys/dev/pci/hdaudio/hdaudio_afg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/pci/hdaudio/hdaudio_afg.c diff -u src/sys/dev/pci/hdaudio/hdaudio_afg.c:1.14.2.2 src/sys/dev/pci/hdaudio/hdaudio_afg.c:1.14.2.3 --- src/sys/dev/pci/hdaudio/hdaudio_afg.c:1.14.2.2 Sat Sep 26 19:52:10 2009 +++ src/sys/dev/pci/hdaudio/hdaudio_afg.c Mon Sep 28 00:40:21 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: hdaudio_afg.c,v 1.14.2.2 2009/09/26 19:52:10 snj Exp $ */ +/* $NetBSD: hdaudio_afg.c,v 1.14.2.3 2009/09/28 00:40:21 snj Exp $ */ /* * Copyright (c) 2009 Precedence Technologies Ltd <supp...@precedence.co.uk> @@ -60,7 +60,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: hdaudio_afg.c,v 1.14.2.2 2009/09/26 19:52:10 snj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hdaudio_afg.c,v 1.14.2.3 2009/09/28 00:40:21 snj Exp $"); #include <sys/types.h> #include <sys/param.h> @@ -106,7 +106,7 @@ #define HDAUDIO_UNSOLTAG_EVENT_HP 0x00 -#define HDAUDIO_HP_SENSE_PERIOD (hz / 2) +#define HDAUDIO_HP_SENSE_PERIOD hz static const char *hdaudio_afg_mixer_names[] = HDAUDIO_DEVICE_NAMES; @@ -290,6 +290,7 @@ audio_params_t sc_pparam, sc_rparam; struct callout sc_jack_callout; + bool sc_jack_polling; struct { uint32_t afg_cap; @@ -308,6 +309,7 @@ static void hdaudio_afg_attach(device_t, device_t, void *); static int hdaudio_afg_detach(device_t, int); static void hdaudio_afg_childdet(device_t, device_t); +static bool hdaudio_afg_suspend(device_t PMF_FN_PROTO); static bool hdaudio_afg_resume(device_t PMF_FN_PROTO); CFATTACH_DECL2_NEW( @@ -2984,6 +2986,9 @@ uint32_t res = 0; int i, j; + if (!device_is_active(sc->sc_dev)) + goto resched; + for (i = 0; i < sc->sc_nassocs; i++) for (j = 0; j < HDAUDIO_MAXPINS; j++) { w = hdaudio_afg_widget_lookup(sc, as[i].as_pins[j]); @@ -3030,6 +3035,7 @@ } } +resched: callout_schedule(&sc->sc_jack_callout, HDAUDIO_HP_SENSE_PERIOD); } @@ -3070,8 +3076,8 @@ "unsol" : "poll"); } if (enable) { + sc->sc_jack_polling = true; hdaudio_afg_hp_switch_handler(sc); - callout_schedule(&sc->sc_jack_callout, HDAUDIO_HP_SENSE_PERIOD); } else hda_trace(sc, "jack detect not enabled\n"); } @@ -3093,7 +3099,7 @@ callout_setfunc(&sc->sc_jack_callout, hdaudio_afg_hp_switch_handler, sc); - if (!pmf_device_register(self, NULL, hdaudio_afg_resume)) + if (!pmf_device_register(self, hdaudio_afg_suspend, hdaudio_afg_resume)) aprint_error_dev(self, "couldn't establish power handler\n"); sc->sc_config = prop_dictionary_get(args, "pin-config"); @@ -3241,6 +3247,16 @@ } static bool +hdaudio_afg_suspend(device_t self PMF_FN_ARGS) +{ + struct hdaudio_afg_softc *sc = device_private(self); + + callout_halt(&sc->sc_jack_callout, NULL); + + return true; +} + +static bool hdaudio_afg_resume(device_t self PMF_FN_ARGS) { struct hdaudio_afg_softc *sc = device_private(self); @@ -3258,6 +3274,9 @@ hdaudio_afg_stream_connect(sc, AUMODE_PLAY); hdaudio_afg_stream_connect(sc, AUMODE_RECORD); + if (sc->sc_jack_polling) + hdaudio_afg_hp_switch_handler(sc); + return true; }