diff options
author | Takashi Iwai <tiwai@suse.de> | 2005-11-17 11:03:53 -0500 |
---|---|---|
committer | Jaroslav Kysela <perex@suse.cz> | 2006-01-03 06:28:17 -0500 |
commit | 480615f33fa48e1a4db33e40b21d4009250f5b23 (patch) | |
tree | bd87766d2d32ae02722a65ab99ec0f36c884efb6 /sound/isa | |
parent | 6bba41ac974ad77aa21d112a368ee565b55f303b (diff) |
[ALSA] als100 - Add PM support
Modules: ALS100 driver
Add PM support to als100 driver.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/isa')
-rw-r--r-- | sound/isa/als100.c | 51 |
1 files changed, 41 insertions, 10 deletions
diff --git a/sound/isa/als100.c b/sound/isa/als100.c index 0d709bc50c16..9b77c17b3f66 100644 --- a/sound/isa/als100.c +++ b/sound/isa/als100.c | |||
@@ -83,6 +83,7 @@ struct snd_card_als100 { | |||
83 | struct pnp_dev *dev; | 83 | struct pnp_dev *dev; |
84 | struct pnp_dev *devmpu; | 84 | struct pnp_dev *devmpu; |
85 | struct pnp_dev *devopl; | 85 | struct pnp_dev *devopl; |
86 | struct snd_sb *chip; | ||
86 | }; | 87 | }; |
87 | 88 | ||
88 | static struct pnp_card_device_id snd_als100_pnpids[] = { | 89 | static struct pnp_card_device_id snd_als100_pnpids[] = { |
@@ -211,7 +212,7 @@ static int __init snd_card_als100_probe(int dev, | |||
211 | if ((card = snd_card_new(index[dev], id[dev], THIS_MODULE, | 212 | if ((card = snd_card_new(index[dev], id[dev], THIS_MODULE, |
212 | sizeof(struct snd_card_als100))) == NULL) | 213 | sizeof(struct snd_card_als100))) == NULL) |
213 | return -ENOMEM; | 214 | return -ENOMEM; |
214 | acard = (struct snd_card_als100 *)card->private_data; | 215 | acard = card->private_data; |
215 | 216 | ||
216 | if ((error = snd_card_als100_pnp(dev, acard, pcard, pid))) { | 217 | if ((error = snd_card_als100_pnp(dev, acard, pcard, pid))) { |
217 | snd_card_free(card); | 218 | snd_card_free(card); |
@@ -228,6 +229,7 @@ static int __init snd_card_als100_probe(int dev, | |||
228 | snd_card_free(card); | 229 | snd_card_free(card); |
229 | return error; | 230 | return error; |
230 | } | 231 | } |
232 | acard->chip = chip; | ||
231 | 233 | ||
232 | strcpy(card->driver, "ALS100"); | 234 | strcpy(card->driver, "ALS100"); |
233 | strcpy(card->shortname, "Avance Logic ALS100"); | 235 | strcpy(card->shortname, "Avance Logic ALS100"); |
@@ -299,11 +301,35 @@ static int __devinit snd_als100_pnp_detect(struct pnp_card_link *card, | |||
299 | 301 | ||
300 | static void __devexit snd_als100_pnp_remove(struct pnp_card_link * pcard) | 302 | static void __devexit snd_als100_pnp_remove(struct pnp_card_link * pcard) |
301 | { | 303 | { |
302 | struct snd_card *card = (struct snd_card *) pnp_get_card_drvdata(pcard); | 304 | snd_card_free(pnp_get_card_drvdata(pcard)); |
305 | pnp_set_card_drvdata(pcard, NULL); | ||
306 | } | ||
307 | |||
308 | #ifdef CONFIG_PM | ||
309 | static int snd_als100_pnp_suspend(struct pnp_card_link *pcard, pm_message_t state) | ||
310 | { | ||
311 | struct snd_card *card = pnp_get_card_drvdata(pcard); | ||
312 | struct snd_card_als100 *acard = card->private_data; | ||
313 | struct snd_sb *chip = acard->chip; | ||
314 | |||
315 | snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); | ||
316 | snd_pcm_suspend_all(chip->pcm); | ||
317 | snd_sbmixer_suspend(chip); | ||
318 | return 0; | ||
319 | } | ||
320 | |||
321 | static int snd_als100_pnp_resume(struct pnp_card_link *pcard) | ||
322 | { | ||
323 | struct snd_card *card = pnp_get_card_drvdata(pcard); | ||
324 | struct snd_card_als100 *acard = card->private_data; | ||
325 | struct snd_sb *chip = acard->chip; | ||
303 | 326 | ||
304 | snd_card_disconnect(card); | 327 | snd_sbdsp_reset(chip); |
305 | snd_card_free_in_thread(card); | 328 | snd_sbmixer_resume(chip); |
329 | snd_power_change_state(card, SNDRV_CTL_POWER_D0); | ||
330 | return 0; | ||
306 | } | 331 | } |
332 | #endif | ||
307 | 333 | ||
308 | static struct pnp_card_driver als100_pnpc_driver = { | 334 | static struct pnp_card_driver als100_pnpc_driver = { |
309 | .flags = PNP_DRIVER_RES_DISABLE, | 335 | .flags = PNP_DRIVER_RES_DISABLE, |
@@ -311,20 +337,25 @@ static struct pnp_card_driver als100_pnpc_driver = { | |||
311 | .id_table = snd_als100_pnpids, | 337 | .id_table = snd_als100_pnpids, |
312 | .probe = snd_als100_pnp_detect, | 338 | .probe = snd_als100_pnp_detect, |
313 | .remove = __devexit_p(snd_als100_pnp_remove), | 339 | .remove = __devexit_p(snd_als100_pnp_remove), |
340 | #ifdef CONFIG_PM | ||
341 | .suspend = snd_als100_pnp_suspend, | ||
342 | .resume = snd_als100_pnp_resume, | ||
343 | #endif | ||
314 | }; | 344 | }; |
315 | 345 | ||
316 | static int __init alsa_card_als100_init(void) | 346 | static int __init alsa_card_als100_init(void) |
317 | { | 347 | { |
318 | int cards = 0; | 348 | int cards; |
319 | 349 | ||
320 | cards += pnp_register_card_driver(&als100_pnpc_driver); | 350 | cards = pnp_register_card_driver(&als100_pnpc_driver); |
321 | #ifdef MODULE | 351 | if (cards <= 0) { |
322 | if (!cards) { | ||
323 | pnp_unregister_card_driver(&als100_pnpc_driver); | 352 | pnp_unregister_card_driver(&als100_pnpc_driver); |
353 | #ifdef MODULE | ||
324 | snd_printk(KERN_ERR "no ALS100 based soundcards found\n"); | 354 | snd_printk(KERN_ERR "no ALS100 based soundcards found\n"); |
325 | } | ||
326 | #endif | 355 | #endif |
327 | return cards ? 0 : -ENODEV; | 356 | return -ENODEV; |
357 | } | ||
358 | return 0; | ||
328 | } | 359 | } |
329 | 360 | ||
330 | static void __exit alsa_card_als100_exit(void) | 361 | static void __exit alsa_card_als100_exit(void) |