Commit 480615f33fa48e1a4db33e40b21d4009250f5b23

Authored by Takashi Iwai
Committed by Jaroslav Kysela
1 parent 6bba41ac97

[ALSA] als100 - Add PM support

Modules: ALS100 driver

Add PM support to als100 driver.

Signed-off-by: Takashi Iwai <tiwai@suse.de>

Showing 1 changed file with 41 additions and 10 deletions Side-by-side Diff

... ... @@ -83,6 +83,7 @@
83 83 struct pnp_dev *dev;
84 84 struct pnp_dev *devmpu;
85 85 struct pnp_dev *devopl;
  86 + struct snd_sb *chip;
86 87 };
87 88  
88 89 static struct pnp_card_device_id snd_als100_pnpids[] = {
... ... @@ -211,7 +212,7 @@
211 212 if ((card = snd_card_new(index[dev], id[dev], THIS_MODULE,
212 213 sizeof(struct snd_card_als100))) == NULL)
213 214 return -ENOMEM;
214   - acard = (struct snd_card_als100 *)card->private_data;
  215 + acard = card->private_data;
215 216  
216 217 if ((error = snd_card_als100_pnp(dev, acard, pcard, pid))) {
217 218 snd_card_free(card);
... ... @@ -228,6 +229,7 @@
228 229 snd_card_free(card);
229 230 return error;
230 231 }
  232 + acard->chip = chip;
231 233  
232 234 strcpy(card->driver, "ALS100");
233 235 strcpy(card->shortname, "Avance Logic ALS100");
234 236  
235 237  
236 238  
237 239  
238 240  
239 241  
240 242  
241 243  
... ... @@ -299,32 +301,61 @@
299 301  
300 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 +}
303 307  
304   - snd_card_disconnect(card);
305   - snd_card_free_in_thread(card);
  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;
306 319 }
307 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;
  326 +
  327 + snd_sbdsp_reset(chip);
  328 + snd_sbmixer_resume(chip);
  329 + snd_power_change_state(card, SNDRV_CTL_POWER_D0);
  330 + return 0;
  331 +}
  332 +#endif
  333 +
308 334 static struct pnp_card_driver als100_pnpc_driver = {
309 335 .flags = PNP_DRIVER_RES_DISABLE,
310 336 .name = "als100",
311 337 .id_table = snd_als100_pnpids,
312 338 .probe = snd_als100_pnp_detect,
313 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 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);
321   -#ifdef MODULE
322   - if (!cards) {
  350 + cards = pnp_register_card_driver(&als100_pnpc_driver);
  351 + if (cards <= 0) {
323 352 pnp_unregister_card_driver(&als100_pnpc_driver);
  353 +#ifdef MODULE
324 354 snd_printk(KERN_ERR "no ALS100 based soundcards found\n");
325   - }
326 355 #endif
327   - return cards ? 0 : -ENODEV;
  356 + return -ENODEV;
  357 + }
  358 + return 0;
328 359 }
329 360  
330 361 static void __exit alsa_card_als100_exit(void)