Commit b6cc25cae365bada36c9f006e314b998eb2c5e7c

Authored by Takashi Iwai
Committed by Jaroslav Kysela
1 parent 480615f33f

[ALSA] azt2320 - Add PM support

Modules: AZT2320 driver

Add PM support to azt2320 driver.

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

Showing 1 changed file with 37 additions and 9 deletions Side-by-side Diff

... ... @@ -93,6 +93,7 @@
93 93 int dev_no;
94 94 struct pnp_dev *dev;
95 95 struct pnp_dev *devmpu;
  96 + struct snd_cs4231 *chip;
96 97 };
97 98  
98 99 static struct pnp_card_device_id snd_azt2320_pnpids[] = {
99 100  
100 101  
101 102  
102 103  
103 104  
104 105  
105 106  
106 107  
... ... @@ -329,32 +330,59 @@
329 330  
330 331 static void __devexit snd_azt2320_pnp_remove(struct pnp_card_link * pcard)
331 332 {
332   - struct snd_card *card = (struct snd_card *) pnp_get_card_drvdata(pcard);
  333 + snd_card_free(pnp_get_card_drvdata(pcard));
  334 + pnp_set_card_drvdata(pcard, NULL);
  335 +}
333 336  
334   - snd_card_disconnect(card);
335   - snd_card_free_in_thread(card);
  337 +#ifdef CONFIG_PM
  338 +static int snd_azt2320_pnp_suspend(struct pnp_card_link *pcard, pm_message_t state)
  339 +{
  340 + struct snd_card *card = pnp_get_card_drvdata(pcard);
  341 + struct snd_card_azt2320 *acard = card->private_data;
  342 + struct snd_cs4231 *chip = acard->chip;
  343 +
  344 + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
  345 + chip->suspend(chip);
  346 + return 0;
336 347 }
337 348  
  349 +static int snd_azt2320_pnp_resume(struct pnp_card_link *pcard)
  350 +{
  351 + struct snd_card *card = pnp_get_card_drvdata(pcard);
  352 + struct snd_card_azt2320 *acard = card->private_data;
  353 + struct snd_cs4231 *chip = acard->chip;
  354 +
  355 + chip->resume(chip);
  356 + snd_power_change_state(card, SNDRV_CTL_POWER_D0);
  357 + return 0;
  358 +}
  359 +#endif
  360 +
338 361 static struct pnp_card_driver azt2320_pnpc_driver = {
339 362 .flags = PNP_DRIVER_RES_DISABLE,
340 363 .name = "azt2320",
341 364 .id_table = snd_azt2320_pnpids,
342 365 .probe = snd_azt2320_pnp_detect,
343 366 .remove = __devexit_p(snd_azt2320_pnp_remove),
  367 +#ifdef CONFIG_PM
  368 + .suspend = snd_azt2320_pnp_suspend,
  369 + .resume = snd_azt2320_pnp_resume,
  370 +#endif
344 371 };
345 372  
346 373 static int __init alsa_card_azt2320_init(void)
347 374 {
348   - int cards = 0;
  375 + int cards;
349 376  
350   - cards += pnp_register_card_driver(&azt2320_pnpc_driver);
351   -#ifdef MODULE
352   - if (!cards) {
  377 + cards = pnp_register_card_driver(&azt2320_pnpc_driver);
  378 + if (cards <= 0) {
353 379 pnp_unregister_card_driver(&azt2320_pnpc_driver);
  380 +#ifdef MODULE
354 381 snd_printk(KERN_ERR "no AZT2320 based soundcards found\n");
355   - }
356 382 #endif
357   - return cards ? 0 : -ENODEV;
  383 + return -ENODEV;
  384 + }
  385 + return 0;
358 386 }
359 387  
360 388 static void __exit alsa_card_azt2320_exit(void)