summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/pci/auacer.c43
-rw-r--r--sys/dev/pci/auglx.c38
-rw-r--r--sys/dev/pci/auich.c30
-rw-r--r--sys/dev/pci/autri.c28
-rw-r--r--sys/dev/pci/autrivar.h4
-rw-r--r--sys/dev/pci/cs4280.c44
-rw-r--r--sys/dev/pci/cs4281.c43
-rw-r--r--sys/dev/pci/esa.c24
-rw-r--r--sys/dev/pci/eso.c28
-rw-r--r--sys/dev/pci/maestro.c35
-rw-r--r--sys/dev/pci/yds.c39
11 files changed, 177 insertions, 179 deletions
diff --git a/sys/dev/pci/auacer.c b/sys/dev/pci/auacer.c
index f36d9a3957d..ceaebca7cbc 100644
--- a/sys/dev/pci/auacer.c
+++ b/sys/dev/pci/auacer.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: auacer.c,v 1.7 2010/07/15 03:43:11 jakemsr Exp $ */
+/* $OpenBSD: auacer.c,v 1.8 2010/08/27 18:50:56 deraadt Exp $ */
/* $NetBSD: auacer.c,v 1.3 2004/11/10 04:20:26 kent Exp $ */
/*-
@@ -121,7 +121,6 @@ struct auacer_softc {
/* Power Management */
void *sc_powerhook;
- int sc_suspend;
};
#define READ1(sc, a) bus_space_read_1(sc->iot, sc->aud_ioh, a)
@@ -150,10 +149,12 @@ struct cfdriver auacer_cd = {
int auacer_match(struct device *, void *, void *);
void auacer_attach(struct device *, struct device *, void *);
+int auacer_activate(struct device *, int);
int auacer_intr(void *);
struct cfattach auacer_ca = {
- sizeof(struct auacer_softc), auacer_match, auacer_attach
+ sizeof(struct auacer_softc), auacer_match, auacer_attach, NULL,
+ auacer_activate
};
int auacer_open(void *, int);
@@ -296,8 +297,6 @@ auacer_attach(struct device *parent, struct device *self, void *aux)
if (ac97_attach(&sc->host_if) != 0)
return;
- /* Watch for power change */
- sc->sc_suspend = PWR_RESUME;
sc->sc_powerhook = powerhook_establish(auacer_powerhook, sc);
audio_attach_mi(&auacer_hw_if, sc, &sc->sc_dev);
@@ -1082,27 +1081,25 @@ auacer_alloc_cdata(struct auacer_softc *sc)
return (error);
}
-void
-auacer_powerhook(int why, void *addr)
+int
+auacer_activate(struct device *self, int act)
{
- struct auacer_softc *sc = (struct auacer_softc *)addr;
-
- if (why != PWR_RESUME) {
- /* Power down */
- DPRINTF(1, ("%s: power down\n", sc->sc_dev.dv_xname));
- sc->sc_suspend = why;
- } else {
- /* 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;
+ struct auacer_softc *sc = (struct auacer_softc *)self;
+
+ switch (act) {
+ case DVACT_SUSPEND:
+ break;
+ case DVACT_RESUME:
auacer_reset_codec(sc);
delay(1000);
(sc->codec_if->vtbl->restore_ports)(sc->codec_if);
+ break;
}
+ return 0;
+}
+
+void
+auacer_powerhook(int why, void *addr)
+{
+ auacer_activate(addr, why);
}
diff --git a/sys/dev/pci/auglx.c b/sys/dev/pci/auglx.c
index 6e22cb94258..9b524b61147 100644
--- a/sys/dev/pci/auglx.c
+++ b/sys/dev/pci/auglx.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: auglx.c,v 1.4 2010/07/15 03:43:11 jakemsr Exp $ */
+/* $OpenBSD: auglx.c,v 1.5 2010/08/27 18:50:56 deraadt Exp $ */
/*
* Copyright (c) 2008 Marc Balmer <mbalmer@openbsd.org>
@@ -199,7 +199,6 @@ struct auglx_softc {
/* power mgmt */
void *sc_powerhook;
- int sc_suspend;
u_int16_t sc_ext_ctrl;
int sc_dmamap_flags;
@@ -280,6 +279,7 @@ struct audio_hw_if auglx_hw_if = {
int auglx_match(struct device *, void *, void *);
void auglx_attach(struct device *, struct device *, void *);
+int auglx_activate(struct device *, int);
int auglx_intr(void *);
int auglx_attach_codec(void *, struct ac97_codec_if *);
@@ -289,7 +289,8 @@ void auglx_reset_codec(void *);
enum ac97_host_flags auglx_flags_codec(void *);
struct cfattach auglx_ca = {
- sizeof(struct auglx_softc), auglx_match, auglx_attach
+ sizeof(struct auglx_softc), auglx_match, auglx_attach, NULL,
+ auglx_activate
};
const struct pci_matchid auglx_devices[] = {
@@ -360,7 +361,6 @@ auglx_attach(struct device *parent, struct device *self, void *aux)
audio_attach_mi(&auglx_hw_if, sc, &sc->sc_dev);
/* Watch for power changes */
- sc->sc_suspend = PWR_RESUME;
sc->sc_powerhook = powerhook_establish(auglx_powerhook, sc);
}
@@ -1345,27 +1345,27 @@ auglx_free_prd(struct auglx_softc *sc, struct auglx_ring *bm)
bus_dmamem_free(sc->sc_dmat, &bm->seg, bm->nsegs);
}
-void
-auglx_powerhook(int why, void *self)
+int
+auglx_activate(struct device *self, int act)
{
- struct auglx_softc *sc = self;
+ struct auglx_softc *sc = (struct auglx_softc *)self;
- if (why != PWR_RESUME) {
- /* Power down */
- sc->sc_suspend = why;
+ switch (act) {
+ case DVACT_SUSPEND:
auglx_read_codec(sc, AC97_REG_EXT_AUDIO_CTRL, &sc->sc_ext_ctrl);
- } else {
- /* Wake up */
- 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;
+ break;
+ case DVACT_RESUME:
auglx_reset_codec(sc);
delay(1000);
(sc->codec_if->vtbl->restore_ports)(sc->codec_if);
auglx_write_codec(sc, AC97_REG_EXT_AUDIO_CTRL, sc->sc_ext_ctrl);
+ break;
}
+ return 0;
+}
+
+void
+auglx_powerhook(int why, void *self)
+{
+ auglx_activate(self, why);
}
diff --git a/sys/dev/pci/auich.c b/sys/dev/pci/auich.c
index 8bddd26552c..2537fc028d4 100644
--- a/sys/dev/pci/auich.c
+++ b/sys/dev/pci/auich.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: auich.c,v 1.86 2010/08/09 05:43:48 jakemsr Exp $ */
+/* $OpenBSD: auich.c,v 1.87 2010/08/27 18:50:56 deraadt Exp $ */
/*
* Copyright (c) 2000,2001 Michael Shalayeff
@@ -1952,33 +1952,9 @@ auich_resume(struct auich_softc *sc)
}
void
-auich_powerhook(why, self)
- int why;
- void *self;
+auich_powerhook(int why, void *self)
{
- struct auich_softc *sc = (struct auich_softc *)self;
-
- if (why != PWR_RESUME) {
- /* Power down */
- DPRINTF(1, ("auich: power down\n"));
- sc->suspend = why;
- auich_read_codec(sc, AC97_REG_EXT_AUDIO_CTRL, &sc->ext_ctrl);
-
- } else {
- /* Wake up */
- DPRINTF(1, ("auich: power resume\n"));
- if (sc->suspend == PWR_RESUME) {
- printf("%s: resume without suspend?\n",
- sc->sc_dev.dv_xname);
- sc->suspend = why;
- return;
- }
- sc->suspend = why;
- auich_reset_codec(sc);
- DELAY(1000);
- (sc->codec_if->vtbl->restore_ports)(sc->codec_if);
- auich_write_codec(sc, AC97_REG_EXT_AUDIO_CTRL, sc->ext_ctrl);
- }
+ auich_activate(self, why);
}
diff --git a/sys/dev/pci/autri.c b/sys/dev/pci/autri.c
index 5389362351a..f87cd11077e 100644
--- a/sys/dev/pci/autri.c
+++ b/sys/dev/pci/autri.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: autri.c,v 1.25 2010/07/15 03:43:11 jakemsr Exp $ */
+/* $OpenBSD: autri.c,v 1.26 2010/08/27 18:50:56 deraadt Exp $ */
/*
* Copyright (c) 2001 SOMEYA Yoshihiko and KUROSAWA Takahiro.
@@ -72,6 +72,7 @@ int autridebug = 0;
int autri_match(struct device *, void *, void *);
void autri_attach(struct device *, struct device *, void *);
+int autri_activate(struct device *, int);
int autri_intr(void *);
#define DMAADDR(p) ((p)->map->dm_segs[0].ds_addr)
@@ -117,7 +118,8 @@ struct cfdriver autri_cd = {
};
struct cfattach autri_ca = {
- sizeof(struct autri_softc), autri_match, autri_attach
+ sizeof(struct autri_softc), autri_match, autri_attach, NULL,
+ autri_activate
};
int autri_open(void *, int);
@@ -616,22 +618,30 @@ autri_attach(parent, self, aux)
midi_attach_mi(&autri_midi_hw_if, sc, &sc->sc_dev);
#endif
- sc->sc_old_power = PWR_RESUME;
powerhook_establish(autri_powerhook, sc);
}
-void
-autri_powerhook(int why,void *addr)
+int
+autri_activate(struct device *self, int act)
{
- struct autri_softc *sc = addr;
+ struct autri_softc *sc = (struct autri_softc *)self;
- if (why == PWR_RESUME && sc->sc_old_power == PWR_SUSPEND) {
- DPRINTF(("PWR_RESUME\n"));
+ switch (act) {
+ case DVACT_SUSPEND:
+ break;
+ case DVACT_RESUME:
autri_init(sc);
/*autri_reset_codec(&sc->sc_codec);*/
(sc->sc_codec.codec_if->vtbl->restore_ports)(sc->sc_codec.codec_if);
+ break;
}
- sc->sc_old_power = why;
+ return 0;
+}
+
+void
+autri_powerhook(int why,void *addr)
+{
+ autri_activate(addr, why);
}
int
diff --git a/sys/dev/pci/autrivar.h b/sys/dev/pci/autrivar.h
index d1e64507b7f..4eef614398b 100644
--- a/sys/dev/pci/autrivar.h
+++ b/sys/dev/pci/autrivar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: autrivar.h,v 1.3 2003/03/09 01:52:14 tedu Exp $ */
+/* $OpenBSD: autrivar.h,v 1.4 2010/08/27 18:50:56 deraadt Exp $ */
/*
* Copyright (c) 2001 SOMEYA Yoshihiko and KUROSAWA Takahiro.
@@ -87,8 +87,6 @@ struct autri_softc {
u_int32_t sc_class;
int sc_revision;
- int sc_old_power;
-
/*
* Play/record status
*/
diff --git a/sys/dev/pci/cs4280.c b/sys/dev/pci/cs4280.c
index 8d278d9e9b8..92d4572f12c 100644
--- a/sys/dev/pci/cs4280.c
+++ b/sys/dev/pci/cs4280.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cs4280.c,v 1.34 2010/07/15 03:43:11 jakemsr Exp $ */
+/* $OpenBSD: cs4280.c,v 1.35 2010/08/27 18:50:57 deraadt Exp $ */
/* $NetBSD: cs4280.c,v 1.5 2000/06/26 04:56:23 simonb Exp $ */
/*
@@ -157,7 +157,6 @@ struct cs4280_softc {
struct ac97_codec_if *codec_if;
struct ac97_host_if host_if;
- char sc_suspend;
void *sc_powerhook; /* Power Hook */
u_int16_t ac97_reg[CS4280_SAVE_REG_MAX + 1]; /* Save ac97 registers */
};
@@ -169,6 +168,7 @@ struct cs4280_softc {
int cs4280_match(struct device *, void *, void *);
void cs4280_attach(struct device *, struct device *, void *);
+int cs4280_activate(struct device *, int);
void cs4280_attachhook(void *xsc);
int cs4280_intr(void *);
void cs4280_reset(void *);
@@ -190,7 +190,8 @@ struct cfdriver clcs_cd = {
};
struct cfattach clcs_ca = {
- sizeof(struct cs4280_softc), cs4280_match, cs4280_attach
+ sizeof(struct cs4280_softc), cs4280_match, cs4280_attach, NULL,
+ cs4280_activate
};
int cs4280_init(struct cs4280_softc *, int);
@@ -232,7 +233,7 @@ int cs4280_read_codec(void *sc, u_int8_t a, u_int16_t *d);
int cs4280_write_codec(void *sc, u_int8_t a, u_int16_t d);
void cs4280_reset_codec(void *sc);
-void cs4280_power(int, void *);
+void cs4280_powerhook(int, void *);
void cs4280_clear_fifos(struct cs4280_softc *);
@@ -590,8 +591,7 @@ cs4280_attachhook(void *xsc)
#if NMIDI > 0
midi_attach_mi(&cs4280_midi_hw_if, sc, &sc->sc_dev);
#endif
- sc->sc_suspend = PWR_RESUME;
- sc->sc_powerhook = powerhook_establish(cs4280_power, sc);
+ sc->sc_powerhook = powerhook_establish(cs4280_powerhook, sc);
}
void
@@ -1829,19 +1829,14 @@ cs4280_init2(sc, init)
return(0);
}
-void
-cs4280_power(why, v)
- int why;
- void *v;
+int
+cs4280_activate(struct device *self, int act)
{
- struct cs4280_softc *sc = (struct cs4280_softc *)v;
+ struct cs4280_softc *sc = (struct cs4280_softc *)self;
int i;
- DPRINTF(("%s: cs4280_power why=%d\n",
- sc->sc_dev.dv_xname, why));
- if (why != PWR_RESUME) {
- sc->sc_suspend = why;
-
+ switch (act) {
+ case DVACT_SUSPEND:
cs4280_halt_output(sc);
cs4280_halt_input(sc);
/* Save AC97 registers */
@@ -1852,13 +1847,8 @@ cs4280_power(why, v)
}
/* should I powerdown here ? */
cs4280_write_codec(sc, AC97_REG_POWER, CS4280_POWER_DOWN_ALL);
- } else {
- if (sc->sc_suspend == PWR_RESUME) {
- printf("cs4280_power: odd, resume without suspend.\n");
- sc->sc_suspend = why;
- return;
- }
- sc->sc_suspend = why;
+ break;
+ case DVACT_RESUME:
cs4280_init(sc, 0);
cs4280_init2(sc, 0);
cs4280_reset_codec(sc);
@@ -1869,7 +1859,15 @@ cs4280_power(why, v)
continue;
cs4280_write_codec(sc, 2*i, sc->ac97_reg[i]);
}
+ break;
}
+ return 0;
+}
+
+void
+cs4280_powerhook(int why, void *v)
+{
+ cs4280_activate(v, why);
}
void
diff --git a/sys/dev/pci/cs4281.c b/sys/dev/pci/cs4281.c
index 43e3147e948..dad225ed926 100644
--- a/sys/dev/pci/cs4281.c
+++ b/sys/dev/pci/cs4281.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cs4281.c,v 1.23 2010/07/15 03:43:11 jakemsr Exp $ */
+/* $OpenBSD: cs4281.c,v 1.24 2010/08/27 18:50:57 deraadt Exp $ */
/* $Tera: cs4281.c,v 1.18 2000/12/27 14:24:45 tacha Exp $ */
/*
@@ -140,7 +140,6 @@ struct cs4281_softc {
struct ac97_host_if host_if;
/* Power Management */
- char sc_suspend;
void *sc_powerhook; /* Power hook */
u_int16_t ac97_reg[CS4281_SAVE_REG_MAX + 1]; /* Save ac97 registers */
};
@@ -158,6 +157,7 @@ struct cs4281_softc {
int cs4281_match(struct device *, void *, void *);
void cs4281_attach(struct device *, struct device *, void *);
+int cs4281_activate(struct device *, int);
int cs4281_intr(void *);
int cs4281_query_encoding(void *, struct audio_encoding *);
int cs4281_set_params(void *, int, int, struct audio_params *,
@@ -183,7 +183,7 @@ int cs4281_read_codec(void *, u_int8_t , u_int16_t *);
int cs4281_write_codec(void *, u_int8_t, u_int16_t);
void cs4281_reset_codec(void *);
-void cs4281_power(int, void *);
+void cs4281_powerhook(int, void *);
int cs4281_mixer_set_port(void *, mixer_ctrl_t *);
int cs4281_mixer_get_port(void *, mixer_ctrl_t *);
@@ -256,7 +256,8 @@ struct midi_hw_if cs4281_midi_hw_if = {
#endif
struct cfattach clct_ca = {
- sizeof(struct cs4281_softc), cs4281_match, cs4281_attach
+ sizeof(struct cs4281_softc), cs4281_match, cs4281_attach, NULL,
+ cs4281_activate
};
struct cfdriver clct_cd = {
@@ -368,8 +369,7 @@ cs4281_attach(parent, self, aux)
midi_attach_mi(&cs4281_midi_hw_if, sc, &sc->sc_dev);
#endif
- sc->sc_suspend = PWR_RESUME;
- sc->sc_powerhook = powerhook_establish(cs4281_power, sc);
+ sc->sc_powerhook = powerhook_establish(cs4281_powerhook, sc);
}
@@ -1131,18 +1131,14 @@ cs4281_init(sc)
return (0);
}
-void
-cs4281_power(why, v)
- int why;
- void *v;
+int
+cs4281_activate(struct device *self, int act)
{
- struct cs4281_softc *sc = (struct cs4281_softc *)v;
+ struct cs4281_softc *sc = (struct cs4281_softc *)self;
int i;
- DPRINTF(("%s: cs4281_power why=%d\n", sc->sc_dev.dv_xname, why));
- if (why != PWR_RESUME) {
- sc->sc_suspend = why;
-
+ switch (act) {
+ case DVACT_SUSPEND:
cs4281_halt_output(sc);
cs4281_halt_input(sc);
/* Save AC97 registers */
@@ -1153,13 +1149,8 @@ cs4281_power(why, v)
}
/* should I powerdown here ? */
cs4281_write_codec(sc, AC97_REG_POWER, CS4281_POWER_DOWN_ALL);
- } else {
- if (sc->sc_suspend == PWR_RESUME) {
- printf("cs4281_power: odd, resume without suspend.\n");
- sc->sc_suspend = why;
- return;
- }
- sc->sc_suspend = why;
+ break;
+ case DVACT_RESUME:
cs4281_init(sc);
cs4281_reset_codec(sc);
@@ -1169,7 +1160,15 @@ cs4281_power(why, v)
continue;
cs4281_write_codec(sc, 2*i, sc->ac97_reg[i>>1]);
}
+ break;
}
+ return 0;
+}
+
+void
+cs4281_powerhook(int why, void *v)
+{
+ cs4281_activate(v, why);
}
void
diff --git a/sys/dev/pci/esa.c b/sys/dev/pci/esa.c
index 95ea0753502..eb33bda86fb 100644
--- a/sys/dev/pci/esa.c
+++ b/sys/dev/pci/esa.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: esa.c,v 1.20 2010/08/27 04:09:19 deraadt Exp $ */
+/* $OpenBSD: esa.c,v 1.21 2010/08/27 18:50:57 deraadt Exp $ */
/* $NetBSD: esa.c,v 1.12 2002/03/24 14:17:35 jmcneill Exp $ */
/*
@@ -102,6 +102,7 @@ struct audio_device esa_device = {
int esa_match(struct device *, void *, void *);
void esa_attach(struct device *, struct device *, void *);
int esa_detach(struct device *, int);
+int esa_activate(struct device *, int);
/* audio(9) functions */
int esa_open(void *, int);
@@ -219,7 +220,7 @@ struct cfdriver esa_cd = {
struct cfattach esa_ca = {
sizeof(struct esa_softc), esa_match, esa_attach,
- esa_detach, /*esa_activate*/ NULL
+ esa_detach, esa_activate
};
/*
@@ -1604,20 +1605,27 @@ esa_remove_list(struct esa_voice *vc, struct esa_list *el, int index)
return;
}
-void
-esa_powerhook(int why, void *hdl)
+int
+esa_activate(struct device *self, int act)
{
- struct esa_softc *sc = (struct esa_softc *)hdl;
+ struct esa_softc *sc = (struct esa_softc *)self;
- switch (why) {
- case PWR_SUSPEND:
+ switch (act) {
+ case DVACT_SUSPEND:
esa_suspend(sc);
break;
- case PWR_RESUME:
+ case DVACT_RESUME:
esa_resume(sc);
(sc->codec_if->vtbl->restore_ports)(sc->codec_if);
break;
}
+ return 0;
+}
+
+void
+esa_powerhook(int why, void *hdl)
+{
+ esa_activate(hdl, why);
}
int
diff --git a/sys/dev/pci/eso.c b/sys/dev/pci/eso.c
index 7edba2c8865..2094778e71a 100644
--- a/sys/dev/pci/eso.c
+++ b/sys/dev/pci/eso.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: eso.c,v 1.32 2010/07/15 03:43:11 jakemsr Exp $ */
+/* $OpenBSD: eso.c,v 1.33 2010/08/27 18:50:57 deraadt Exp $ */
/* $NetBSD: eso.c,v 1.48 2006/12/18 23:13:39 kleink Exp $ */
/*
@@ -90,10 +90,12 @@ struct eso_dma {
int eso_match(struct device *, void *, void *);
void eso_attach(struct device *, struct device *, void *);
+int eso_activate(struct device *, int);
void eso_defer(struct device *);
struct cfattach eso_ca = {
- sizeof (struct eso_softc), eso_match, eso_attach
+ sizeof (struct eso_softc), eso_match, eso_attach, NULL,
+ eso_activate
};
struct cfdriver eso_cd = {
@@ -2057,12 +2059,13 @@ eso_set_gain(struct eso_softc *sc, uint port)
sc->sc_gain[port][ESO_LEFT], sc->sc_gain[port][ESO_RIGHT]));
}
-void
-eso_powerhook(int why, void *self)
+int
+eso_activate(struct device *self, int act)
{
struct eso_softc *sc = (struct eso_softc *)self;
- if (why != PWR_RESUME) {
+ switch (act) {
+ case DVACT_SUSPEND:
eso_halt_output(sc);
eso_halt_input(sc);
@@ -2074,7 +2077,18 @@ eso_powerhook(int why, void *self)
/* shut down dma */
pci_conf_write(sc->sc_pa.pa_pc,
- sc->sc_pa.pa_tag, ESO_PCI_DDMAC, 0);
- } else
+ sc->sc_pa.pa_tag, ESO_PCI_DDMAC, 0);
+ break;
+ case DVACT_RESUME:
eso_setup(sc, 0);
+ break;
+ }
+ return 0;
+}
+
+void
+eso_powerhook(int why, void *self)
+{
+ eso_activate(self, why);
+
}
diff --git a/sys/dev/pci/maestro.c b/sys/dev/pci/maestro.c
index dea2b251000..34d63e2a87c 100644
--- a/sys/dev/pci/maestro.c
+++ b/sys/dev/pci/maestro.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: maestro.c,v 1.29 2010/07/15 03:43:11 jakemsr Exp $ */
+/* $OpenBSD: maestro.c,v 1.30 2010/08/27 18:50:57 deraadt Exp $ */
/* $FreeBSD: /c/ncvs/src/sys/dev/sound/pci/maestro.c,v 1.3 2000/11/21 12:22:11 julian Exp $ */
/*
* FreeBSD's ESS Agogo/Maestro driver
@@ -475,6 +475,7 @@ void salloc_insert(salloc_t, struct salloc_head *,
int maestro_match(struct device *, void *, void *);
void maestro_attach(struct device *, struct device *, void *);
+int maestro_activate(struct device *, int);
int maestro_intr(void *);
int maestro_open(void *, int);
@@ -542,7 +543,8 @@ struct cfdriver maestro_cd = {
};
struct cfattach maestro_ca = {
- sizeof (struct maestro_softc), maestro_match, maestro_attach
+ sizeof (struct maestro_softc), maestro_match, maestro_attach,
+ NULL, maestro_activate
};
struct audio_hw_if maestro_hw_if = {
@@ -767,7 +769,6 @@ maestro_attach(parent, self, aux)
audio_attach_mi(&maestro_hw_if, sc, &sc->dev);
/* Hook power changes */
- sc->suspend = PWR_RESUME;
sc->powerhook = powerhook_establish(maestro_powerhook, sc);
return;
@@ -1504,17 +1505,15 @@ maestro_initcodec(self)
* Power management interface
*/
-void
-maestro_powerhook(why, self)
- int why;
- void *self;
+int
+maestro_activate(struct device *self, int act)
{
struct maestro_softc *sc = (struct maestro_softc *)self;
- if (why != PWR_RESUME) {
+ switch (act) {
+ case DVACT_SUSPEND:
/* Power down device on shutdown. */
DPRINTF(("maestro: power down\n"));
- sc->suspend = why;
if (sc->record.mode & MAESTRO_RUNNING) {
sc->record.current = wp_apu_read(sc, sc->record.num, APUREG_CURPTR);
maestro_channel_stop(&sc->record);
@@ -1533,16 +1532,10 @@ maestro_powerhook(why, self)
bus_space_write_4(sc->iot, sc->ioh, PORT_RINGBUS_CTRL, 0);
DELAY(1);
maestro_power(sc, PPMI_D3);
- } else {
+ break;
+ case DVACT_RESUME:
/* Power up device on resume. */
DPRINTF(("maestro: power resume\n"));
- if (sc->suspend == PWR_RESUME) {
- printf("%s: resume without suspend?\n",
- sc->dev.dv_xname);
- sc->suspend = why;
- return;
- }
- sc->suspend = why;
maestro_power(sc, PPMI_D0);
DELAY(100000);
maestro_init(sc);
@@ -1554,7 +1547,15 @@ maestro_powerhook(why, self)
if (sc->record.mode & MAESTRO_RUNNING)
maestro_channel_start(&sc->record);
maestro_update_timer(sc);
+ break;
}
+ return 0;
+}
+
+void
+maestro_powerhook(int why, void *v)
+{
+ maestro_activate(v, why);
}
void
diff --git a/sys/dev/pci/yds.c b/sys/dev/pci/yds.c
index fd5addc3d6c..ad2a339d462 100644
--- a/sys/dev/pci/yds.c
+++ b/sys/dev/pci/yds.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: yds.c,v 1.34 2010/07/15 03:43:11 jakemsr Exp $ */
+/* $OpenBSD: yds.c,v 1.35 2010/08/27 18:50:57 deraadt Exp $ */
/* $NetBSD: yds.c,v 1.5 2001/05/21 23:55:04 minoura Exp $ */
/*
@@ -88,6 +88,7 @@ static int ac97_id2;
int yds_match(struct device *, void *, void *);
void yds_attach(struct device *, struct device *, void *);
+int yds_activate(struct device *, int);
int yds_intr(void *);
static void nswaph(u_int32_t *p, int wcount);
@@ -145,7 +146,8 @@ void YWRITE4(struct yds_softc *sc,bus_size_t r,u_int32_t x)
bus_space_write_region_4((sc)->memt, (sc)->memh, (r), (x), (c) / 4)
struct cfattach yds_ca = {
- sizeof(struct yds_softc), yds_match, yds_attach
+ sizeof(struct yds_softc), yds_match, yds_attach, NULL,
+ yds_activate
};
struct cfdriver yds_cd = {
@@ -1802,31 +1804,26 @@ yds_get_props(addr)
AUDIO_PROP_FULLDUPLEX);
}
-void
-yds_powerhook(why, self)
- int why;
- void *self;
+int
+yds_activate(struct device *self, int act)
{
struct yds_softc *sc = (struct yds_softc *)self;
- if (why != PWR_RESUME) {
- /* Power down */
- DPRINTF(("yds: power down\n"));
- sc->suspend = why;
-
- } else {
- /* Wake up */
- DPRINTF(("yds: power resume\n"));
- if (sc->suspend == PWR_RESUME) {
- printf("%s: resume without suspend?\n",
- sc->sc_dev.dv_xname);
- sc->suspend = why;
- return;
- }
- sc->suspend = why;
+ switch (act) {
+ 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);
+ break;
}
+ return 0;
+}
+
+void
+yds_powerhook(int why, void *self)
+{
+ yds_activate(self, why);
}
int