[ALSA] azt2320 - Add PM support
authorTakashi Iwai <tiwai@suse.de>
Thu, 17 Nov 2005 16:04:12 +0000 (17:04 +0100)
committerJaroslav Kysela <perex@suse.cz>
Tue, 3 Jan 2006 11:28:21 +0000 (12:28 +0100)
Modules: AZT2320 driver

Add PM support to azt2320 driver.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/isa/azt2320.c

index db4e7334a67dced5cdf47647466cf5bd4ad40369..a530691bf4f7232acb9e5fb6c0a2e12953591ab3 100644 (file)
@@ -93,6 +93,7 @@ struct snd_card_azt2320 {
        int dev_no;
        struct pnp_dev *dev;
        struct pnp_dev *devmpu;
+       struct snd_cs4231 *chip;
 };
 
 static struct pnp_card_device_id snd_azt2320_pnpids[] = {
@@ -329,11 +330,33 @@ static int __devinit snd_azt2320_pnp_detect(struct pnp_card_link *card,
 
 static void __devexit snd_azt2320_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);
+}
+
+#ifdef CONFIG_PM
+static int snd_azt2320_pnp_suspend(struct pnp_card_link *pcard, pm_message_t state)
+{
+       struct snd_card *card = pnp_get_card_drvdata(pcard);
+       struct snd_card_azt2320 *acard = card->private_data;
+       struct snd_cs4231 *chip = acard->chip;
+
+       snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
+       chip->suspend(chip);
+       return 0;
+}
+
+static int snd_azt2320_pnp_resume(struct pnp_card_link *pcard)
+{
+       struct snd_card *card = pnp_get_card_drvdata(pcard);
+       struct snd_card_azt2320 *acard = card->private_data;
+       struct snd_cs4231 *chip = acard->chip;
 
-       snd_card_disconnect(card);
-       snd_card_free_in_thread(card);
+       chip->resume(chip);
+       snd_power_change_state(card, SNDRV_CTL_POWER_D0);
+       return 0;
 }
+#endif
 
 static struct pnp_card_driver azt2320_pnpc_driver = {
        .flags          = PNP_DRIVER_RES_DISABLE,
@@ -341,20 +364,25 @@ static struct pnp_card_driver azt2320_pnpc_driver = {
        .id_table       = snd_azt2320_pnpids,
        .probe          = snd_azt2320_pnp_detect,
        .remove         = __devexit_p(snd_azt2320_pnp_remove),
+#ifdef CONFIG_PM
+       .suspend        = snd_azt2320_pnp_suspend,
+       .resume         = snd_azt2320_pnp_resume,
+#endif
 };
 
 static int __init alsa_card_azt2320_init(void)
 {
-       int cards = 0;
+       int cards;
 
-       cards += pnp_register_card_driver(&azt2320_pnpc_driver);
-#ifdef MODULE
-       if (!cards) {
+       cards = pnp_register_card_driver(&azt2320_pnpc_driver);
+       if (cards <= 0) {
                pnp_unregister_card_driver(&azt2320_pnpc_driver);
+#ifdef MODULE
                snd_printk(KERN_ERR "no AZT2320 based soundcards found\n");
-       }
 #endif
-       return cards ? 0 : -ENODEV;
+               return -ENODEV;
+       }
+       return 0;
 }
 
 static void __exit alsa_card_azt2320_exit(void)