mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-28 07:13:34 +00:00
[ALSA] es968 - Add PM support
Modules: ES968 driver Add PM support to es968 driver. Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
67be445871
commit
7a8fef1f95
1 changed files with 40 additions and 9 deletions
|
@ -58,6 +58,7 @@ MODULE_PARM_DESC(dma8, "8-bit DMA # for es968 driver.");
|
||||||
|
|
||||||
struct snd_card_es968 {
|
struct snd_card_es968 {
|
||||||
struct pnp_dev *dev;
|
struct pnp_dev *dev;
|
||||||
|
struct snd_sb *chip;
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct pnp_card_device_id snd_es968_pnpids[] = {
|
static struct pnp_card_device_id snd_es968_pnpids[] = {
|
||||||
|
@ -135,7 +136,7 @@ static int __init snd_card_es968_probe(int dev,
|
||||||
if ((card = snd_card_new(index[dev], id[dev], THIS_MODULE,
|
if ((card = snd_card_new(index[dev], id[dev], THIS_MODULE,
|
||||||
sizeof(struct snd_card_es968))) == NULL)
|
sizeof(struct snd_card_es968))) == NULL)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
acard = (struct snd_card_es968 *)card->private_data;
|
acard = card->private_data;
|
||||||
if ((error = snd_card_es968_pnp(dev, acard, pcard, pid))) {
|
if ((error = snd_card_es968_pnp(dev, acard, pcard, pid))) {
|
||||||
snd_card_free(card);
|
snd_card_free(card);
|
||||||
return error;
|
return error;
|
||||||
|
@ -151,6 +152,7 @@ static int __init snd_card_es968_probe(int dev,
|
||||||
snd_card_free(card);
|
snd_card_free(card);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
acard->chip = chip;
|
||||||
|
|
||||||
if ((error = snd_sb8dsp_pcm(chip, 0, NULL)) < 0) {
|
if ((error = snd_sb8dsp_pcm(chip, 0, NULL)) < 0) {
|
||||||
snd_card_free(card);
|
snd_card_free(card);
|
||||||
|
@ -200,30 +202,59 @@ static int __devinit snd_es968_pnp_detect(struct pnp_card_link *card,
|
||||||
|
|
||||||
static void __devexit snd_es968_pnp_remove(struct pnp_card_link * pcard)
|
static void __devexit snd_es968_pnp_remove(struct pnp_card_link * pcard)
|
||||||
{
|
{
|
||||||
struct snd_card *card = (struct snd_card *) pnp_get_card_drvdata(pcard);
|
snd_card_free(pnp_get_card_drvdata(pcard));
|
||||||
|
pnp_set_card_drvdata(pcard, NULL);
|
||||||
snd_card_disconnect(card);
|
|
||||||
snd_card_free_in_thread(card);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_PM
|
||||||
|
static int snd_es968_pnp_suspend(struct pnp_card_link *pcard, pm_message_t state)
|
||||||
|
{
|
||||||
|
struct snd_card *card = pnp_get_card_drvdata(pcard);
|
||||||
|
struct snd_card_es968 *acard = card->private_data;
|
||||||
|
struct snd_sb *chip = acard->chip;
|
||||||
|
|
||||||
|
snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
|
||||||
|
snd_pcm_suspend_all(chip->pcm);
|
||||||
|
snd_sbmixer_suspend(chip);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int snd_es968_pnp_resume(struct pnp_card_link *pcard)
|
||||||
|
{
|
||||||
|
struct snd_card *card = pnp_get_card_drvdata(pcard);
|
||||||
|
struct snd_card_es968 *acard = card->private_data;
|
||||||
|
struct snd_sb *chip = acard->chip;
|
||||||
|
|
||||||
|
snd_sbdsp_reset(chip);
|
||||||
|
snd_sbmixer_resume(chip);
|
||||||
|
snd_power_change_state(card, SNDRV_CTL_POWER_D0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static struct pnp_card_driver es968_pnpc_driver = {
|
static struct pnp_card_driver es968_pnpc_driver = {
|
||||||
.flags = PNP_DRIVER_RES_DISABLE,
|
.flags = PNP_DRIVER_RES_DISABLE,
|
||||||
.name = "es968",
|
.name = "es968",
|
||||||
.id_table = snd_es968_pnpids,
|
.id_table = snd_es968_pnpids,
|
||||||
.probe = snd_es968_pnp_detect,
|
.probe = snd_es968_pnp_detect,
|
||||||
.remove = __devexit_p(snd_es968_pnp_remove),
|
.remove = __devexit_p(snd_es968_pnp_remove),
|
||||||
|
#ifdef CONFIG_PM
|
||||||
|
.suspend = snd_es968_pnp_suspend,
|
||||||
|
.resume = snd_es968_pnp_resume,
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
static int __init alsa_card_es968_init(void)
|
static int __init alsa_card_es968_init(void)
|
||||||
{
|
{
|
||||||
int cards = pnp_register_card_driver(&es968_pnpc_driver);
|
int cards = pnp_register_card_driver(&es968_pnpc_driver);
|
||||||
#ifdef MODULE
|
if (cards <= 0) {
|
||||||
if (cards == 0) {
|
|
||||||
pnp_unregister_card_driver(&es968_pnpc_driver);
|
pnp_unregister_card_driver(&es968_pnpc_driver);
|
||||||
|
#ifdef MODULE
|
||||||
snd_printk(KERN_ERR "no ES968 based soundcards found\n");
|
snd_printk(KERN_ERR "no ES968 based soundcards found\n");
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
return cards ? 0 : -ENODEV;
|
return -ENODEV;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __exit alsa_card_es968_exit(void)
|
static void __exit alsa_card_es968_exit(void)
|
||||||
|
|
Loading…
Reference in a new issue