Commit e2fa2135 authored by Takashi Iwai's avatar Takashi Iwai Committed by Jaroslav Kysela

[ALSA] dt019x - Add PM support

Modules: DT019x driver

Add PM support to dt019x driver.
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent b6cc25ca
...@@ -74,6 +74,7 @@ struct snd_card_dt019x { ...@@ -74,6 +74,7 @@ struct snd_card_dt019x {
struct pnp_dev *dev; struct pnp_dev *dev;
struct pnp_dev *devmpu; struct pnp_dev *devmpu;
struct pnp_dev *devopl; struct pnp_dev *devopl;
struct snd_sb *chip;
}; };
static struct pnp_card_device_id snd_dt019x_pnpids[] = { static struct pnp_card_device_id snd_dt019x_pnpids[] = {
...@@ -196,7 +197,7 @@ static int __devinit snd_card_dt019x_probe(int dev, struct pnp_card_link *pcard, ...@@ -196,7 +197,7 @@ static int __devinit snd_card_dt019x_probe(int dev, struct pnp_card_link *pcard,
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_dt019x))) == NULL) sizeof(struct snd_card_dt019x))) == NULL)
return -ENOMEM; return -ENOMEM;
acard = (struct snd_card_dt019x *)card->private_data; acard = card->private_data;
snd_card_set_dev(card, &pcard->card->dev); snd_card_set_dev(card, &pcard->card->dev);
if ((error = snd_card_dt019x_pnp(dev, acard, pcard, pid))) { if ((error = snd_card_dt019x_pnp(dev, acard, pcard, pid))) {
...@@ -214,6 +215,7 @@ static int __devinit snd_card_dt019x_probe(int dev, struct pnp_card_link *pcard, ...@@ -214,6 +215,7 @@ static int __devinit snd_card_dt019x_probe(int dev, struct pnp_card_link *pcard,
snd_card_free(card); snd_card_free(card);
return error; return error;
} }
acard->chip = chip;
strcpy(card->driver, "DT-019X"); strcpy(card->driver, "DT-019X");
strcpy(card->shortname, "Diamond Tech. DT-019X"); strcpy(card->shortname, "Diamond Tech. DT-019X");
...@@ -290,10 +292,35 @@ static int __devinit snd_dt019x_pnp_probe(struct pnp_card_link *card, ...@@ -290,10 +292,35 @@ static int __devinit snd_dt019x_pnp_probe(struct pnp_card_link *card,
static void __devexit snd_dt019x_pnp_remove(struct pnp_card_link * pcard) static void __devexit snd_dt019x_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));
snd_card_disconnect(card); pnp_set_card_drvdata(pcard, NULL);
snd_card_free_in_thread(card); }
#ifdef CONFIG_PM
static int snd_dt019x_pnp_suspend(struct pnp_card_link *pcard, pm_message_t state)
{
struct snd_card *card = pnp_get_card_drvdata(pcard);
struct snd_card_dt019x *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_dt019x_pnp_resume(struct pnp_card_link *pcard)
{
struct snd_card *card = pnp_get_card_drvdata(pcard);
struct snd_card_dt019x *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 dt019x_pnpc_driver = { static struct pnp_card_driver dt019x_pnpc_driver = {
.flags = PNP_DRIVER_RES_DISABLE, .flags = PNP_DRIVER_RES_DISABLE,
...@@ -301,21 +328,25 @@ static struct pnp_card_driver dt019x_pnpc_driver = { ...@@ -301,21 +328,25 @@ static struct pnp_card_driver dt019x_pnpc_driver = {
.id_table = snd_dt019x_pnpids, .id_table = snd_dt019x_pnpids,
.probe = snd_dt019x_pnp_probe, .probe = snd_dt019x_pnp_probe,
.remove = __devexit_p(snd_dt019x_pnp_remove), .remove = __devexit_p(snd_dt019x_pnp_remove),
#ifdef CONFIG_PM
.suspend = snd_dt019x_pnp_suspend,
.resume = snd_dt019x_pnp_resume,
#endif
}; };
static int __init alsa_card_dt019x_init(void) static int __init alsa_card_dt019x_init(void)
{ {
int cards = 0; int cards = 0;
cards += pnp_register_card_driver(&dt019x_pnpc_driver); cards = pnp_register_card_driver(&dt019x_pnpc_driver);
if (cards <= 0) {
#ifdef MODULE
if (!cards) {
pnp_unregister_card_driver(&dt019x_pnpc_driver); pnp_unregister_card_driver(&dt019x_pnpc_driver);
#ifdef MODULE
snd_printk(KERN_ERR "no DT-019X / ALS-007 based soundcards found\n"); snd_printk(KERN_ERR "no DT-019X / ALS-007 based soundcards found\n");
}
#endif #endif
return cards ? 0 : -ENODEV; return -ENODEV;
}
return 0;
} }
static void __exit alsa_card_dt019x_exit(void) static void __exit alsa_card_dt019x_exit(void)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment