diff options
author | Jacob Meuser <jakemsr@cvs.openbsd.org> | 2010-09-17 07:55:53 +0000 |
---|---|---|
committer | Jacob Meuser <jakemsr@cvs.openbsd.org> | 2010-09-17 07:55:53 +0000 |
commit | f1d0d8c28eb63eb535135015e3ef03ccc0d6b676 (patch) | |
tree | 5d8d0322ea7fff60ab69984089edfe6b15365abd /sys/dev | |
parent | 543587431c1ac4d68005f3cb5c94c1479e838f17 (diff) |
use audio(4) DVACT_{QUIESCE,RESUME}
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/pci/yds.c | 59 | ||||
-rw-r--r-- | sys/dev/pci/ydsreg.h | 3 |
2 files changed, 39 insertions, 23 deletions
diff --git a/sys/dev/pci/yds.c b/sys/dev/pci/yds.c index c19cbe467a6..31f0e6d2e0f 100644 --- a/sys/dev/pci/yds.c +++ b/sys/dev/pci/yds.c @@ -1,4 +1,4 @@ -/* $OpenBSD: yds.c,v 1.37 2010/09/07 16:21:46 deraadt Exp $ */ +/* $OpenBSD: yds.c,v 1.38 2010/09/17 07:55:52 jakemsr Exp $ */ /* $NetBSD: yds.c,v 1.5 2001/05/21 23:55:04 minoura Exp $ */ /* @@ -186,7 +186,7 @@ int yds_get_portnum_by_name(struct yds_softc *, char *, char *, static u_int yds_get_dstype(int); static int yds_download_mcode(struct yds_softc *); -static int yds_allocate_slots(struct yds_softc *); +static int yds_allocate_slots(struct yds_softc *, int); static void yds_configure_legacy(struct yds_softc *arg); static void yds_enable_dsp(struct yds_softc *); static int yds_disable_dsp(struct yds_softc *); @@ -196,7 +196,7 @@ static u_int32_t yds_get_lpfq(u_int); static u_int32_t yds_get_lpfk(u_int); static struct yds_dma *yds_find_dma(struct yds_softc *, void *); -int yds_init(void *sc); +int yds_init(struct yds_softc *, int); void yds_attachhook(void *); #ifdef AUDIO_DEBUG @@ -418,8 +418,7 @@ yds_download_mcode(sc) } static int -yds_allocate_slots(sc) - struct yds_softc *sc; +yds_allocate_slots(struct yds_softc *sc, int resuming) { size_t pcs, rcs, ecs, ws, memsize; void *mp; @@ -458,12 +457,14 @@ yds_allocate_slots(sc) memsize += (N_PLAY_SLOTS+1)*sizeof(u_int32_t); p = &sc->sc_ctrldata; - i = yds_allocmem(sc, memsize, 16, p); - if (i) { - printf("%s: couldn't alloc/map DSP DMA buffer, reason %d\n", - sc->sc_dev.dv_xname, i); - free(p, M_DEVBUF); - return 1; + if (!resuming) { + i = yds_allocmem(sc, memsize, 16, p); + if (i) { + printf("%s: couldn't alloc/map DSP DMA buffer, reason %d\n", + sc->sc_dev.dv_xname, i); + free(p, M_DEVBUF); + return 1; + } } mp = KERNADDR(p); da = DMAADDR(p); @@ -749,7 +750,7 @@ yds_attachhook(void *xsc) int r, i; /* Initialize the device */ - if (yds_init(sc) == -1) + if (yds_init(sc, 0) == -1) return; /* @@ -1805,23 +1806,35 @@ int yds_activate(struct device *self, int act) { struct yds_softc *sc = (struct yds_softc *)self; + int rv = 0; switch (act) { + case DVACT_QUIESCE: + if (sc->sc_play.intr || sc->sc_rec.intr) + sc->sc_resume_active = 1; + else + sc->sc_resume_active = 0; + rv = config_activate_children(self, act); + if (sc->sc_resume_active) + yds_close(sc); + break; case DVACT_SUSPEND: break; case DVACT_RESUME: - yds_init(sc); - (sc->sc_codec[0].codec_if->vtbl->restore_ports)(sc->sc_codec[0].codec_if); + yds_halt(sc); + yds_init(sc, 1); + ac97_resume(&sc->sc_codec[0].host_if, sc->sc_codec[0].codec_if); + if (sc->sc_resume_active) + yds_open(sc, 0); + rv = config_activate_children(self, act); break; } - return 0; + return (rv); } int -yds_init(sc_) - void *sc_; +yds_init(struct yds_softc *sc, int resuming) { - struct yds_softc *sc = sc_; u_int32_t reg; pci_chipset_tag_t pc = sc->sc_pc; @@ -1831,12 +1844,14 @@ yds_init(sc_) DPRINTF(("in yds_init()\n")); /* Download microcode */ - if (yds_download_mcode(sc)) { - printf("%s: download microcode failed\n", sc->sc_dev.dv_xname); - return -1; + if (!resuming) { + if (yds_download_mcode(sc)) { + printf("%s: download microcode failed\n", sc->sc_dev.dv_xname); + return -1; + } } /* Allocate DMA buffers */ - if (yds_allocate_slots(sc)) { + if (yds_allocate_slots(sc, resuming)) { printf("%s: could not allocate slots\n", sc->sc_dev.dv_xname); return -1; } diff --git a/sys/dev/pci/ydsreg.h b/sys/dev/pci/ydsreg.h index 1fb6f05cadf..2e39695627f 100644 --- a/sys/dev/pci/ydsreg.h +++ b/sys/dev/pci/ydsreg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ydsreg.h,v 1.6 2010/09/07 16:21:46 deraadt Exp $ */ +/* $OpenBSD: ydsreg.h,v 1.7 2010/09/17 07:55:52 jakemsr Exp $ */ /* $NetBSD$ */ /* @@ -399,6 +399,7 @@ struct yds_softc { * Suspend/resume support */ int suspend; + int sc_resume_active; }; #define sc_opl_iot sc_legacy_iot #define sc_mpu_iot sc_legacy_iot |