add support for suspending/resuming.

patch provided by Rhialto in PR#26432
This commit is contained in:
kent 2004-10-17 08:46:39 +00:00
parent 8e74ad23a5
commit bac58e9eff
2 changed files with 46 additions and 5 deletions

View File

@ -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 @@ int auvia_trigger_output(void *, void *, void *, int, void (*)(void *),
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 @@ auvia_attach(struct device *parent, struct device *self, void *aux)
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 @@ auvia_intr(void *arg)
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;
}
}

View File

@ -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_softc {
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) \