[ALSA] ens137x - Fix and ADD PM support
authorTakashi Iwai <tiwai@suse.de>
Thu, 17 Nov 2005 15:13:41 +0000 (16:13 +0100)
committerJaroslav Kysela <perex@suse.cz>
Tue, 3 Jan 2006 11:27:56 +0000 (12:27 +0100)
Modules: ENS1370/1+ driver

Fix PM support on ens1371 driver.
Add PM support on ens1370 (together with AK4531), too.

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

index 2cc0f83a0fde36ba1b6460fc783947ded3889cbd..ff86fabc98c31be7c1317c41522e780ca20aa79c 100644 (file)
@@ -2034,40 +2034,45 @@ static void snd_ensoniq_chip_init(struct ensoniq *ensoniq)
 }
 
 #ifdef CONFIG_PM
-static int snd_ensoniq_suspend(struct snd_card *card, pm_message_t state)
+static int snd_ensoniq_suspend(struct pci_dev *pci, pm_message_t state)
 {
-       struct ensoniq *ensoniq = card->pm_private_data;
+       struct snd_card *card = pci_get_drvdata(pci);
+       struct ensoniq *ensoniq = card->private_data;
        
+       snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
+
        snd_pcm_suspend_all(ensoniq->pcm1);
        snd_pcm_suspend_all(ensoniq->pcm2);
        
 #ifdef CHIP1371        
-       if (ensoniq->u.es1371.ac97)
-               snd_ac97_suspend(ensoniq->u.es1371.ac97);
+       snd_ac97_suspend(ensoniq->u.es1371.ac97);
 #else
-       /* FIXME */
+       snd_ak4531_suspend(ensoniq->u.es1370.ak4531);
 #endif 
-       pci_set_power_state(ensoniq->pci, 3);
-       pci_disable_device(ensoniq->pci);
+       pci_set_power_state(pci, PCI_D3hot);
+       pci_disable_device(pci);
+       pci_save_state(pci);
        return 0;
 }
 
-static int snd_ensoniq_resume(struct snd_card *card)
+static int snd_ensoniq_resume(struct pci_dev *pci)
 {
-       struct ensoniq *ensoniq = card->pm_private_data;
+       struct snd_card *card = pci_get_drvdata(pci);
+       struct ensoniq *ensoniq = card->private_data;
 
-       pci_enable_device(ensoniq->pci);
-       pci_set_power_state(ensoniq->pci, 0);   
-       pci_set_master(ensoniq->pci);
+       pci_restore_state(pci);
+       pci_enable_device(pci);
+       pci_set_power_state(pci, PCI_D0);
+       pci_set_master(pci);
 
        snd_ensoniq_chip_init(ensoniq);
 
 #ifdef CHIP1371        
-       if (ensoniq->u.es1371.ac97)
-               snd_ac97_resume(ensoniq->u.es1371.ac97);
+       snd_ac97_resume(ensoniq->u.es1371.ac97);
 #else
-       /* FIXME */
+       snd_ak4531_resume(ensoniq->u.es1370.ak4531);
 #endif 
+       snd_power_change_state(card, SNDRV_CTL_POWER_D0);
        return 0;
 }
 #endif /* CONFIG_PM */
@@ -2165,8 +2170,6 @@ static int __devinit snd_ensoniq_create(struct snd_card *card,
 
        snd_ensoniq_proc_init(ensoniq);
 
-       snd_card_set_pm_callback(card, snd_ensoniq_suspend, snd_ensoniq_resume, ensoniq);
-
        snd_card_set_dev(card, &pci->dev);
 
        *rensoniq = ensoniq;
@@ -2436,6 +2439,7 @@ static int __devinit snd_audiopci_probe(struct pci_dev *pci,
                snd_card_free(card);
                return err;
        }
+       card->private_data = ensoniq;
 
        pcm_devs[0] = 0; pcm_devs[1] = 1;
 #ifdef CHIP1370
@@ -2495,7 +2499,10 @@ static struct pci_driver driver = {
        .id_table = snd_audiopci_ids,
        .probe = snd_audiopci_probe,
        .remove = __devexit_p(snd_audiopci_remove),
-       SND_PCI_PM_CALLBACKS
+#ifdef CONFIG_PM
+       .suspend = snd_ensoniq_suspend,
+       .resume = snd_ensoniq_resume,
+#endif
 };
        
 static int __init alsa_card_ens137x_init(void)