diff options
author | Takashi Iwai <tiwai@suse.de> | 2005-11-17 10:10:35 -0500 |
---|---|---|
committer | Jaroslav Kysela <perex@suse.cz> | 2006-01-03 06:27:48 -0500 |
commit | 57feb83507d598de04e986cfa463acda9f2a67a8 (patch) | |
tree | 3a9b9fef2fed7b8306674724685270c012d096b9 /sound/pci/via82xx.c | |
parent | 0e2364a7013688c06d1a9454a2c20567027f6a6e (diff) |
[ALSA] via82xx - Fix PM support
Modules: VIA82xx driver,VIA82xx-modem driver
Fix PM support on VIA82xx and modem drivers.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/via82xx.c')
-rw-r--r-- | sound/pci/via82xx.c | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c index c87000130dd2..ce4985f8078e 100644 --- a/sound/pci/via82xx.c +++ b/sound/pci/via82xx.c | |||
@@ -2126,14 +2126,15 @@ static int snd_via82xx_chip_init(struct via82xx *chip) | |||
2126 | /* | 2126 | /* |
2127 | * power management | 2127 | * power management |
2128 | */ | 2128 | */ |
2129 | static int snd_via82xx_suspend(struct snd_card *card, pm_message_t state) | 2129 | static int snd_via82xx_suspend(struct pci_dev *pci, pm_message_t state) |
2130 | { | 2130 | { |
2131 | struct via82xx *chip = card->pm_private_data; | 2131 | struct snd_card *card = pci_get_drvdata(pci); |
2132 | struct via82xx *chip = card->private_data; | ||
2132 | int i; | 2133 | int i; |
2133 | 2134 | ||
2135 | snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); | ||
2134 | for (i = 0; i < 2; i++) | 2136 | for (i = 0; i < 2; i++) |
2135 | if (chip->pcms[i]) | 2137 | snd_pcm_suspend_all(chip->pcms[i]); |
2136 | snd_pcm_suspend_all(chip->pcms[i]); | ||
2137 | for (i = 0; i < chip->num_devs; i++) | 2138 | for (i = 0; i < chip->num_devs; i++) |
2138 | snd_via82xx_channel_reset(chip, &chip->devs[i]); | 2139 | snd_via82xx_channel_reset(chip, &chip->devs[i]); |
2139 | synchronize_irq(chip->irq); | 2140 | synchronize_irq(chip->irq); |
@@ -2146,18 +2147,21 @@ static int snd_via82xx_suspend(struct snd_card *card, pm_message_t state) | |||
2146 | chip->capture_src_saved[1] = inb(chip->port + VIA_REG_CAPTURE_CHANNEL + 0x10); | 2147 | chip->capture_src_saved[1] = inb(chip->port + VIA_REG_CAPTURE_CHANNEL + 0x10); |
2147 | } | 2148 | } |
2148 | 2149 | ||
2149 | pci_set_power_state(chip->pci, 3); | 2150 | pci_set_power_state(pci, PCI_D3hot); |
2150 | pci_disable_device(chip->pci); | 2151 | pci_disable_device(pci); |
2152 | pci_save_state(pci); | ||
2151 | return 0; | 2153 | return 0; |
2152 | } | 2154 | } |
2153 | 2155 | ||
2154 | static int snd_via82xx_resume(struct snd_card *card) | 2156 | static int snd_via82xx_resume(struct pci_dev *pci) |
2155 | { | 2157 | { |
2156 | struct via82xx *chip = card->pm_private_data; | 2158 | struct snd_card *card = pci_get_drvdata(pci); |
2159 | struct via82xx *chip = card->private_data; | ||
2157 | int i; | 2160 | int i; |
2158 | 2161 | ||
2159 | pci_enable_device(chip->pci); | 2162 | pci_restore_state(pci); |
2160 | pci_set_power_state(chip->pci, 0); | 2163 | pci_enable_device(pci); |
2164 | pci_set_power_state(pci, PCI_D0); | ||
2161 | 2165 | ||
2162 | snd_via82xx_chip_init(chip); | 2166 | snd_via82xx_chip_init(chip); |
2163 | 2167 | ||
@@ -2177,6 +2181,7 @@ static int snd_via82xx_resume(struct snd_card *card) | |||
2177 | for (i = 0; i < chip->num_devs; i++) | 2181 | for (i = 0; i < chip->num_devs; i++) |
2178 | snd_via82xx_channel_reset(chip, &chip->devs[i]); | 2182 | snd_via82xx_channel_reset(chip, &chip->devs[i]); |
2179 | 2183 | ||
2184 | snd_power_change_state(card, SNDRV_CTL_POWER_D0); | ||
2180 | return 0; | 2185 | return 0; |
2181 | } | 2186 | } |
2182 | #endif /* CONFIG_PM */ | 2187 | #endif /* CONFIG_PM */ |
@@ -2453,6 +2458,7 @@ static int __devinit snd_via82xx_probe(struct pci_dev *pci, | |||
2453 | if ((err = snd_via82xx_create(card, pci, chip_type, revision, | 2458 | if ((err = snd_via82xx_create(card, pci, chip_type, revision, |
2454 | ac97_clock, &chip)) < 0) | 2459 | ac97_clock, &chip)) < 0) |
2455 | goto __error; | 2460 | goto __error; |
2461 | card->private_data = chip; | ||
2456 | if ((err = snd_via82xx_mixer_new(chip, ac97_quirk)) < 0) | 2462 | if ((err = snd_via82xx_mixer_new(chip, ac97_quirk)) < 0) |
2457 | goto __error; | 2463 | goto __error; |
2458 | 2464 | ||
@@ -2481,8 +2487,6 @@ static int __devinit snd_via82xx_probe(struct pci_dev *pci, | |||
2481 | goto __error; | 2487 | goto __error; |
2482 | } | 2488 | } |
2483 | 2489 | ||
2484 | snd_card_set_pm_callback(card, snd_via82xx_suspend, snd_via82xx_resume, chip); | ||
2485 | |||
2486 | /* disable interrupts */ | 2490 | /* disable interrupts */ |
2487 | for (i = 0; i < chip->num_devs; i++) | 2491 | for (i = 0; i < chip->num_devs; i++) |
2488 | snd_via82xx_channel_reset(chip, &chip->devs[i]); | 2492 | snd_via82xx_channel_reset(chip, &chip->devs[i]); |
@@ -2516,7 +2520,10 @@ static struct pci_driver driver = { | |||
2516 | .id_table = snd_via82xx_ids, | 2520 | .id_table = snd_via82xx_ids, |
2517 | .probe = snd_via82xx_probe, | 2521 | .probe = snd_via82xx_probe, |
2518 | .remove = __devexit_p(snd_via82xx_remove), | 2522 | .remove = __devexit_p(snd_via82xx_remove), |
2519 | SND_PCI_PM_CALLBACKS | 2523 | #ifdef CONFIG_PM |
2524 | .suspend = snd_via82xx_suspend, | ||
2525 | .resume = snd_via82xx_resume, | ||
2526 | #endif | ||
2520 | }; | 2527 | }; |
2521 | 2528 | ||
2522 | static int __init alsa_card_via82xx_init(void) | 2529 | static int __init alsa_card_via82xx_init(void) |