aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/cs4281.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2005-11-17 10:08:11 -0500
committerJaroslav Kysela <perex@suse.cz>2006-01-03 06:27:27 -0500
commit38c0a158ee23027e6a4fe47311e05d9c34c94da4 (patch)
tree541dfe21e27fed32932b117aa00dd3d5971ac344 /sound/pci/cs4281.c
parent92304cc7ecfc87d8336696ab5fe6a1c0eec2ff00 (diff)
[ALSA] cs4281 - Fix PM support
Modules: CS4281 driver Fix PM support on CS4281 driver. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/cs4281.c')
-rw-r--r--sound/pci/cs4281.c44
1 files changed, 22 insertions, 22 deletions
diff --git a/sound/pci/cs4281.c b/sound/pci/cs4281.c
index 116cdc1c5528..4f65ec56bf35 100644
--- a/sound/pci/cs4281.c
+++ b/sound/pci/cs4281.c
@@ -1339,10 +1339,6 @@ static int snd_cs4281_dev_free(struct snd_device *device)
1339} 1339}
1340 1340
1341static int snd_cs4281_chip_init(struct cs4281 *chip); /* defined below */ 1341static int snd_cs4281_chip_init(struct cs4281 *chip); /* defined below */
1342#ifdef CONFIG_PM
1343static int cs4281_suspend(struct snd_card *card, pm_message_t state);
1344static int cs4281_resume(struct snd_card *card);
1345#endif
1346 1342
1347static int __devinit snd_cs4281_create(struct snd_card *card, 1343static int __devinit snd_cs4281_create(struct snd_card *card,
1348 struct pci_dev *pci, 1344 struct pci_dev *pci,
@@ -1411,8 +1407,6 @@ static int __devinit snd_cs4281_create(struct snd_card *card,
1411 1407
1412 snd_cs4281_proc_init(chip); 1408 snd_cs4281_proc_init(chip);
1413 1409
1414 snd_card_set_pm_callback(card, cs4281_suspend, cs4281_resume, chip);
1415
1416 snd_card_set_dev(card, &pci->dev); 1410 snd_card_set_dev(card, &pci->dev);
1417 1411
1418 *rchip = chip; 1412 *rchip = chip;
@@ -1936,6 +1930,7 @@ static int __devinit snd_cs4281_probe(struct pci_dev *pci,
1936 snd_card_free(card); 1930 snd_card_free(card);
1937 return err; 1931 return err;
1938 } 1932 }
1933 card->private_data = chip;
1939 1934
1940 if ((err = snd_cs4281_mixer(chip)) < 0) { 1935 if ((err = snd_cs4281_mixer(chip)) < 0) {
1941 snd_card_free(card); 1936 snd_card_free(card);
@@ -2007,18 +2002,18 @@ static int saved_regs[SUSPEND_REGISTERS] = {
2007 2002
2008#define CLKCR1_CKRA 0x00010000L 2003#define CLKCR1_CKRA 0x00010000L
2009 2004
2010static int cs4281_suspend(struct snd_card *card, pm_message_t state) 2005static int cs4281_suspend(struct pci_dev *pci, pm_message_t state)
2011{ 2006{
2012 struct cs4281 *chip = card->pm_private_data; 2007 struct snd_card *card = pci_get_drvdata(pci);
2008 struct cs4281 *chip = card->private_data;
2013 u32 ulCLK; 2009 u32 ulCLK;
2014 unsigned int i; 2010 unsigned int i;
2015 2011
2012 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
2016 snd_pcm_suspend_all(chip->pcm); 2013 snd_pcm_suspend_all(chip->pcm);
2017 2014
2018 if (chip->ac97) 2015 snd_ac97_suspend(chip->ac97);
2019 snd_ac97_suspend(chip->ac97); 2016 snd_ac97_suspend(chip->ac97_secondary);
2020 if (chip->ac97_secondary)
2021 snd_ac97_suspend(chip->ac97_secondary);
2022 2017
2023 ulCLK = snd_cs4281_peekBA0(chip, BA0_CLKCR1); 2018 ulCLK = snd_cs4281_peekBA0(chip, BA0_CLKCR1);
2024 ulCLK |= CLKCR1_CKRA; 2019 ulCLK |= CLKCR1_CKRA;
@@ -2048,18 +2043,21 @@ static int cs4281_suspend(struct snd_card *card, pm_message_t state)
2048 ulCLK &= ~CLKCR1_CKRA; 2043 ulCLK &= ~CLKCR1_CKRA;
2049 snd_cs4281_pokeBA0(chip, BA0_CLKCR1, ulCLK); 2044 snd_cs4281_pokeBA0(chip, BA0_CLKCR1, ulCLK);
2050 2045
2051 pci_disable_device(chip->pci); 2046 pci_disable_device(pci);
2047 pci_save_state(pci);
2052 return 0; 2048 return 0;
2053} 2049}
2054 2050
2055static int cs4281_resume(struct snd_card *card) 2051static int cs4281_resume(struct pci_dev *pci)
2056{ 2052{
2057 struct cs4281 *chip = card->pm_private_data; 2053 struct snd_card *card = pci_get_drvdata(pci);
2054 struct cs4281 *chip = card->private_data;
2058 unsigned int i; 2055 unsigned int i;
2059 u32 ulCLK; 2056 u32 ulCLK;
2060 2057
2061 pci_enable_device(chip->pci); 2058 pci_restore_state(pci);
2062 pci_set_master(chip->pci); 2059 pci_enable_device(pci);
2060 pci_set_master(pci);
2063 2061
2064 ulCLK = snd_cs4281_peekBA0(chip, BA0_CLKCR1); 2062 ulCLK = snd_cs4281_peekBA0(chip, BA0_CLKCR1);
2065 ulCLK |= CLKCR1_CKRA; 2063 ulCLK |= CLKCR1_CKRA;
@@ -2072,15 +2070,14 @@ static int cs4281_resume(struct snd_card *card)
2072 if (saved_regs[i]) 2070 if (saved_regs[i])
2073 snd_cs4281_pokeBA0(chip, saved_regs[i], chip->suspend_regs[i]); 2071 snd_cs4281_pokeBA0(chip, saved_regs[i], chip->suspend_regs[i]);
2074 2072
2075 if (chip->ac97) 2073 snd_ac97_resume(chip->ac97);
2076 snd_ac97_resume(chip->ac97); 2074 snd_ac97_resume(chip->ac97_secondary);
2077 if (chip->ac97_secondary)
2078 snd_ac97_resume(chip->ac97_secondary);
2079 2075
2080 ulCLK = snd_cs4281_peekBA0(chip, BA0_CLKCR1); 2076 ulCLK = snd_cs4281_peekBA0(chip, BA0_CLKCR1);
2081 ulCLK &= ~CLKCR1_CKRA; 2077 ulCLK &= ~CLKCR1_CKRA;
2082 snd_cs4281_pokeBA0(chip, BA0_CLKCR1, ulCLK); 2078 snd_cs4281_pokeBA0(chip, BA0_CLKCR1, ulCLK);
2083 2079
2080 snd_power_change_state(card, SNDRV_CTL_POWER_D0);
2084 return 0; 2081 return 0;
2085} 2082}
2086#endif /* CONFIG_PM */ 2083#endif /* CONFIG_PM */
@@ -2090,7 +2087,10 @@ static struct pci_driver driver = {
2090 .id_table = snd_cs4281_ids, 2087 .id_table = snd_cs4281_ids,
2091 .probe = snd_cs4281_probe, 2088 .probe = snd_cs4281_probe,
2092 .remove = __devexit_p(snd_cs4281_remove), 2089 .remove = __devexit_p(snd_cs4281_remove),
2093 SND_PCI_PM_CALLBACKS 2090#ifdef CONFIG_PM
2091 .suspend = cs4281_suspend,
2092 .resume = cs4281_resume,
2093#endif
2094}; 2094};
2095 2095
2096static int __init alsa_card_cs4281_init(void) 2096static int __init alsa_card_cs4281_init(void)