summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorratchov <ratchov@openbsd.org>2018-03-17 13:35:12 +0000
committerratchov <ratchov@openbsd.org>2018-03-17 13:35:12 +0000
commit2af838c1216cab41f29a3d08d862eef80b2f8697 (patch)
tree621ce5c09005c7eb91e3f01e80a90ec501e6afe3
parentSet base DMA pointers when DMA starts. (diff)
downloadwireguard-openbsd-2af838c1216cab41f29a3d08d862eef80b2f8697.tar.xz
wireguard-openbsd-2af838c1216cab41f29a3d08d862eef80b2f8697.zip
Add proper suspend/resume support.
Most of the resume work is already done in the audio(4) layer, so, to fix suspend/resume we just need to reinitize the device. ok kettenis@
-rw-r--r--sys/dev/pci/envy.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/sys/dev/pci/envy.c b/sys/dev/pci/envy.c
index a12d15e4bd6..94daaacabb1 100644
--- a/sys/dev/pci/envy.c
+++ b/sys/dev/pci/envy.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: envy.c,v 1.71 2018/03/17 13:33:08 ratchov Exp $ */
+/* $OpenBSD: envy.c,v 1.72 2018/03/17 13:35:12 ratchov Exp $ */
/*
* Copyright (c) 2007 Alexandre Ratchov <alex@caoua.org>
*
@@ -56,6 +56,7 @@ int envydebug = 1;
int envymatch(struct device *, void *, void *);
void envyattach(struct device *, struct device *, void *);
int envydetach(struct device *, int);
+int envyactivate(struct device *, int);
int envy_ccs_read(struct envy_softc *, int);
void envy_ccs_write(struct envy_softc *, int, int);
@@ -168,7 +169,8 @@ void ak5365_adc_get(struct envy_softc *, struct mixer_ctrl *, int);
int ak5365_adc_set(struct envy_softc *, struct mixer_ctrl *, int);
struct cfattach envy_ca = {
- sizeof(struct envy_softc), envymatch, envyattach, envydetach
+ sizeof(struct envy_softc), envymatch, envyattach, envydetach,
+ envyactivate
};
struct cfdriver envy_cd = {
@@ -1728,6 +1730,22 @@ envydetach(struct device *self, int flags)
}
int
+envyactivate(struct device *self, int act)
+{
+ struct envy_softc *sc = (struct envy_softc *)self;
+
+ if (act == DVACT_RESUME) {
+ /*
+ * The audio(4) layer will restore parameters and, if
+ * needed, start DMA. So we only need to reach the
+ * same device state as after the audio_attach() call.
+ */
+ envy_reset(sc);
+ }
+ return config_activate_children(self, act);
+}
+
+int
envy_open(void *self, int flags)
{
return 0;