aboutsummaryrefslogtreecommitdiffstats
path: root/sound/isa/sb/es968.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2005-11-17 10:56:11 -0500
committerJaroslav Kysela <perex@suse.cz>2006-01-03 06:28:08 -0500
commit7a8fef1f95e563a93c7d70048b63c1ca20685a1b (patch)
tree34fa516e4d6775d50fefbab9bfe1bda8d6deb57b /sound/isa/sb/es968.c
parent67be445871bb35c450100753b72392ad6ddc0245 (diff)
[ALSA] es968 - Add PM support
Modules: ES968 driver Add PM support to es968 driver. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/isa/sb/es968.c')
-rw-r--r--sound/isa/sb/es968.c47
1 files changed, 39 insertions, 8 deletions
diff --git a/sound/isa/sb/es968.c b/sound/isa/sb/es968.c
index f7d1afe83dfe..9da80bfa3027 100644
--- a/sound/isa/sb/es968.c
+++ b/sound/isa/sb/es968.c
@@ -58,6 +58,7 @@ MODULE_PARM_DESC(dma8, "8-bit DMA # for es968 driver.");
58 58
59struct snd_card_es968 { 59struct snd_card_es968 {
60 struct pnp_dev *dev; 60 struct pnp_dev *dev;
61 struct snd_sb *chip;
61}; 62};
62 63
63static struct pnp_card_device_id snd_es968_pnpids[] = { 64static struct pnp_card_device_id snd_es968_pnpids[] = {
@@ -135,7 +136,7 @@ static int __init snd_card_es968_probe(int dev,
135 if ((card = snd_card_new(index[dev], id[dev], THIS_MODULE, 136 if ((card = snd_card_new(index[dev], id[dev], THIS_MODULE,
136 sizeof(struct snd_card_es968))) == NULL) 137 sizeof(struct snd_card_es968))) == NULL)
137 return -ENOMEM; 138 return -ENOMEM;
138 acard = (struct snd_card_es968 *)card->private_data; 139 acard = card->private_data;
139 if ((error = snd_card_es968_pnp(dev, acard, pcard, pid))) { 140 if ((error = snd_card_es968_pnp(dev, acard, pcard, pid))) {
140 snd_card_free(card); 141 snd_card_free(card);
141 return error; 142 return error;
@@ -151,6 +152,7 @@ static int __init snd_card_es968_probe(int dev,
151 snd_card_free(card); 152 snd_card_free(card);
152 return error; 153 return error;
153 } 154 }
155 acard->chip = chip;
154 156
155 if ((error = snd_sb8dsp_pcm(chip, 0, NULL)) < 0) { 157 if ((error = snd_sb8dsp_pcm(chip, 0, NULL)) < 0) {
156 snd_card_free(card); 158 snd_card_free(card);
@@ -200,11 +202,35 @@ static int __devinit snd_es968_pnp_detect(struct pnp_card_link *card,
200 202
201static void __devexit snd_es968_pnp_remove(struct pnp_card_link * pcard) 203static void __devexit snd_es968_pnp_remove(struct pnp_card_link * pcard)
202{ 204{
203 struct snd_card *card = (struct snd_card *) pnp_get_card_drvdata(pcard); 205 snd_card_free(pnp_get_card_drvdata(pcard));
206 pnp_set_card_drvdata(pcard, NULL);
207}
208
209#ifdef CONFIG_PM
210static int snd_es968_pnp_suspend(struct pnp_card_link *pcard, pm_message_t state)
211{
212 struct snd_card *card = pnp_get_card_drvdata(pcard);
213 struct snd_card_es968 *acard = card->private_data;
214 struct snd_sb *chip = acard->chip;
215
216 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
217 snd_pcm_suspend_all(chip->pcm);
218 snd_sbmixer_suspend(chip);
219 return 0;
220}
221
222static int snd_es968_pnp_resume(struct pnp_card_link *pcard)
223{
224 struct snd_card *card = pnp_get_card_drvdata(pcard);
225 struct snd_card_es968 *acard = card->private_data;
226 struct snd_sb *chip = acard->chip;
204 227
205 snd_card_disconnect(card); 228 snd_sbdsp_reset(chip);
206 snd_card_free_in_thread(card); 229 snd_sbmixer_resume(chip);
230 snd_power_change_state(card, SNDRV_CTL_POWER_D0);
231 return 0;
207} 232}
233#endif
208 234
209static struct pnp_card_driver es968_pnpc_driver = { 235static struct pnp_card_driver es968_pnpc_driver = {
210 .flags = PNP_DRIVER_RES_DISABLE, 236 .flags = PNP_DRIVER_RES_DISABLE,
@@ -212,18 +238,23 @@ static struct pnp_card_driver es968_pnpc_driver = {
212 .id_table = snd_es968_pnpids, 238 .id_table = snd_es968_pnpids,
213 .probe = snd_es968_pnp_detect, 239 .probe = snd_es968_pnp_detect,
214 .remove = __devexit_p(snd_es968_pnp_remove), 240 .remove = __devexit_p(snd_es968_pnp_remove),
241#ifdef CONFIG_PM
242 .suspend = snd_es968_pnp_suspend,
243 .resume = snd_es968_pnp_resume,
244#endif
215}; 245};
216 246
217static int __init alsa_card_es968_init(void) 247static int __init alsa_card_es968_init(void)
218{ 248{
219 int cards = pnp_register_card_driver(&es968_pnpc_driver); 249 int cards = pnp_register_card_driver(&es968_pnpc_driver);
220#ifdef MODULE 250 if (cards <= 0) {
221 if (cards == 0) {
222 pnp_unregister_card_driver(&es968_pnpc_driver); 251 pnp_unregister_card_driver(&es968_pnpc_driver);
252#ifdef MODULE
223 snd_printk(KERN_ERR "no ES968 based soundcards found\n"); 253 snd_printk(KERN_ERR "no ES968 based soundcards found\n");
224 }
225#endif 254#endif
226 return cards ? 0 : -ENODEV; 255 return -ENODEV;
256 }
257 return 0;
227} 258}
228 259
229static void __exit alsa_card_es968_exit(void) 260static void __exit alsa_card_es968_exit(void)