Commit 57feb83507d598de04e986cfa463acda9f2a67a8
Committed by
Jaroslav Kysela
1 parent
0e2364a701
Exists in
master
and in
7 other branches
[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>
Showing 2 changed files with 41 additions and 27 deletions Side-by-side Diff
sound/pci/via82xx.c
... | ... | @@ -2126,14 +2126,15 @@ |
2126 | 2126 | /* |
2127 | 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 | 2133 | int i; |
2133 | 2134 | |
2135 | + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); | |
2134 | 2136 | for (i = 0; i < 2; i++) |
2135 | - if (chip->pcms[i]) | |
2136 | - snd_pcm_suspend_all(chip->pcms[i]); | |
2137 | + snd_pcm_suspend_all(chip->pcms[i]); | |
2137 | 2138 | for (i = 0; i < chip->num_devs; i++) |
2138 | 2139 | snd_via82xx_channel_reset(chip, &chip->devs[i]); |
2139 | 2140 | synchronize_irq(chip->irq); |
2140 | 2141 | |
2141 | 2142 | |
2142 | 2143 | |
... | ... | @@ -2146,18 +2147,21 @@ |
2146 | 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_disable_device(chip->pci); | |
2150 | + pci_set_power_state(pci, PCI_D3hot); | |
2151 | + pci_disable_device(pci); | |
2152 | + pci_save_state(pci); | |
2151 | 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 | 2160 | int i; |
2158 | 2161 | |
2159 | - pci_enable_device(chip->pci); | |
2160 | - pci_set_power_state(chip->pci, 0); | |
2162 | + pci_restore_state(pci); | |
2163 | + pci_enable_device(pci); | |
2164 | + pci_set_power_state(pci, PCI_D0); | |
2161 | 2165 | |
2162 | 2166 | snd_via82xx_chip_init(chip); |
2163 | 2167 | |
... | ... | @@ -2177,6 +2181,7 @@ |
2177 | 2181 | for (i = 0; i < chip->num_devs; i++) |
2178 | 2182 | snd_via82xx_channel_reset(chip, &chip->devs[i]); |
2179 | 2183 | |
2184 | + snd_power_change_state(card, SNDRV_CTL_POWER_D0); | |
2180 | 2185 | return 0; |
2181 | 2186 | } |
2182 | 2187 | #endif /* CONFIG_PM */ |
... | ... | @@ -2453,6 +2458,7 @@ |
2453 | 2458 | if ((err = snd_via82xx_create(card, pci, chip_type, revision, |
2454 | 2459 | ac97_clock, &chip)) < 0) |
2455 | 2460 | goto __error; |
2461 | + card->private_data = chip; | |
2456 | 2462 | if ((err = snd_via82xx_mixer_new(chip, ac97_quirk)) < 0) |
2457 | 2463 | goto __error; |
2458 | 2464 | |
... | ... | @@ -2481,8 +2487,6 @@ |
2481 | 2487 | goto __error; |
2482 | 2488 | } |
2483 | 2489 | |
2484 | - snd_card_set_pm_callback(card, snd_via82xx_suspend, snd_via82xx_resume, chip); | |
2485 | - | |
2486 | 2490 | /* disable interrupts */ |
2487 | 2491 | for (i = 0; i < chip->num_devs; i++) |
2488 | 2492 | snd_via82xx_channel_reset(chip, &chip->devs[i]); |
... | ... | @@ -2516,7 +2520,10 @@ |
2516 | 2520 | .id_table = snd_via82xx_ids, |
2517 | 2521 | .probe = snd_via82xx_probe, |
2518 | 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 | 2529 | static int __init alsa_card_via82xx_init(void) |
sound/pci/via82xx_modem.c
... | ... | @@ -1019,31 +1019,35 @@ |
1019 | 1019 | /* |
1020 | 1020 | * power management |
1021 | 1021 | */ |
1022 | -static int snd_via82xx_suspend(struct snd_card *card, pm_message_t state) | |
1022 | +static int snd_via82xx_suspend(struct pci_dev *pci, pm_message_t state) | |
1023 | 1023 | { |
1024 | - struct via82xx_modem *chip = card->pm_private_data; | |
1024 | + struct snd_card *card = pci_get_drvdata(pci); | |
1025 | + struct via82xx_modem *chip = card->private_data; | |
1025 | 1026 | int i; |
1026 | 1027 | |
1028 | + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); | |
1027 | 1029 | for (i = 0; i < 2; i++) |
1028 | - if (chip->pcms[i]) | |
1029 | - snd_pcm_suspend_all(chip->pcms[i]); | |
1030 | + snd_pcm_suspend_all(chip->pcms[i]); | |
1030 | 1031 | for (i = 0; i < chip->num_devs; i++) |
1031 | 1032 | snd_via82xx_channel_reset(chip, &chip->devs[i]); |
1032 | 1033 | synchronize_irq(chip->irq); |
1033 | 1034 | snd_ac97_suspend(chip->ac97); |
1034 | - pci_set_power_state(chip->pci, 3); | |
1035 | - pci_disable_device(chip->pci); | |
1035 | + pci_set_power_state(pci, PCI_D3hot); | |
1036 | + pci_disable_device(pci); | |
1037 | + pci_save_state(pci); | |
1036 | 1038 | return 0; |
1037 | 1039 | } |
1038 | 1040 | |
1039 | -static int snd_via82xx_resume(struct snd_card *card) | |
1041 | +static int snd_via82xx_resume(struct pci_dev *pci) | |
1040 | 1042 | { |
1041 | - struct via82xx_modem *chip = card->pm_private_data; | |
1043 | + struct snd_card *card = pci_get_drvdata(pci); | |
1044 | + struct via82xx_modem *chip = card->private_data; | |
1042 | 1045 | int i; |
1043 | 1046 | |
1044 | - pci_enable_device(chip->pci); | |
1045 | - pci_set_power_state(chip->pci, 0); | |
1046 | - pci_set_master(chip->pci); | |
1047 | + pci_restore_state(pci); | |
1048 | + pci_enable_device(pci); | |
1049 | + pci_set_power_state(pci, PCI_D0); | |
1050 | + pci_set_master(pci); | |
1047 | 1051 | |
1048 | 1052 | snd_via82xx_chip_init(chip); |
1049 | 1053 | |
... | ... | @@ -1052,6 +1056,7 @@ |
1052 | 1056 | for (i = 0; i < chip->num_devs; i++) |
1053 | 1057 | snd_via82xx_channel_reset(chip, &chip->devs[i]); |
1054 | 1058 | |
1059 | + snd_power_change_state(card, SNDRV_CTL_POWER_D0); | |
1055 | 1060 | return 0; |
1056 | 1061 | } |
1057 | 1062 | #endif /* CONFIG_PM */ |
1058 | 1063 | |
... | ... | @@ -1176,14 +1181,13 @@ |
1176 | 1181 | if ((err = snd_via82xx_create(card, pci, chip_type, revision, |
1177 | 1182 | ac97_clock, &chip)) < 0) |
1178 | 1183 | goto __error; |
1184 | + card->private_data = chip; | |
1179 | 1185 | if ((err = snd_via82xx_mixer_new(chip)) < 0) |
1180 | 1186 | goto __error; |
1181 | 1187 | |
1182 | 1188 | if ((err = snd_via686_pcm_new(chip)) < 0 ) |
1183 | 1189 | goto __error; |
1184 | 1190 | |
1185 | - snd_card_set_pm_callback(card, snd_via82xx_suspend, snd_via82xx_resume, chip); | |
1186 | - | |
1187 | 1191 | /* disable interrupts */ |
1188 | 1192 | for (i = 0; i < chip->num_devs; i++) |
1189 | 1193 | snd_via82xx_channel_reset(chip, &chip->devs[i]); |
... | ... | @@ -1216,7 +1220,10 @@ |
1216 | 1220 | .id_table = snd_via82xx_modem_ids, |
1217 | 1221 | .probe = snd_via82xx_probe, |
1218 | 1222 | .remove = __devexit_p(snd_via82xx_remove), |
1219 | - SND_PCI_PM_CALLBACKS | |
1223 | +#ifdef CONFIG_PM | |
1224 | + .suspend = snd_via82xx_suspend, | |
1225 | + .resume = snd_via82xx_resume, | |
1226 | +#endif | |
1220 | 1227 | }; |
1221 | 1228 | |
1222 | 1229 | static int __init alsa_card_via82xx_init(void) |