Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pci add support for suspending/resuming.



details:   https://anonhg.NetBSD.org/src/rev/c9de9cb77e74
branches:  trunk
changeset: 570544:c9de9cb77e74
user:      kent <kent%NetBSD.org@localhost>
date:      Sun Oct 17 08:46:39 2004 +0000

description:
add support for suspending/resuming.
patch provided by Rhialto in PR#26432

diffstat:

 sys/dev/pci/auvia.c    |  45 +++++++++++++++++++++++++++++++++++++++++----
 sys/dev/pci/auviavar.h |   6 +++++-
 2 files changed, 46 insertions(+), 5 deletions(-)

diffs (97 lines):

diff -r 5385e276efef -r c9de9cb77e74 sys/dev/pci/auvia.c
--- a/sys/dev/pci/auvia.c       Sun Oct 17 08:20:15 2004 +0000
+++ b/sys/dev/pci/auvia.c       Sun Oct 17 08:46:39 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: auvia.c,v 1.42 2004/09/22 12:20:25 kent Exp $  */
+/*     $NetBSD: auvia.c,v 1.43 2004/10/17 08:46:39 kent Exp $  */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -47,7 +47,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: auvia.c,v 1.42 2004/09/22 12:20:25 kent Exp $");
+__KERNEL_RCSID(0, "$NetBSD: auvia.c,v 1.43 2004/10/17 08:46:39 kent Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -113,8 +113,8 @@
        void *, struct audio_params *);
 int    auvia_trigger_input(void *, void *, void *, int, void (*)(void *),
        void *, struct audio_params *);
-
-int    auvia_intr __P((void *));
+void   auvia_powerhook(int, void *);
+int    auvia_intr(void *);
 
 CFATTACH_DECL(auvia, sizeof (struct auvia_softc),
     auvia_match, auvia_attach, NULL, NULL);
@@ -368,6 +368,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);
 }
 
@@ -1140,3 +1144,36 @@
 
        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 */
+               sc->sc_suspend = why;
+               break;
+
+       case PWR_RESUME:
+               /* 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;
+               auvia_reset_codec(sc);
+               DELAY(1000);
+               (sc->codec_if->vtbl->restore_ports)(sc->codec_if);
+               break;
+
+       case PWR_SOFTSUSPEND:
+       case PWR_SOFTSTANDBY:
+       case PWR_SOFTRESUME:
+               break;
+       }
+}
diff -r 5385e276efef -r c9de9cb77e74 sys/dev/pci/auviavar.h
--- a/sys/dev/pci/auviavar.h    Sun Oct 17 08:20:15 2004 +0000
+++ b/sys/dev/pci/auviavar.h    Sun Oct 17 08:46:39 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: auviavar.h,v 1.5 2002/10/16 15:27:28 kent Exp $        */
+/*     $NetBSD: auviavar.h,v 1.6 2004/10/17 08:46:39 kent Exp $        */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -73,6 +73,10 @@
        struct auvia_dma *sc_dmas;
 
        struct auvia_softc_chan sc_play, sc_record;
+
+       /* Power Management */
+       void *sc_powerhook;
+       int sc_suspend;
 };
 
 #define IS_FIXED_RATE(codec)   !((codec)->vtbl->get_extcaps(codec) \



Home | Main Index | Thread Index | Old Index