Commit 0e2364a7013688c06d1a9454a2c20567027f6a6e

Authored by Takashi Iwai
Committed by Jaroslav Kysela
1 parent 5809c6c41a

[ALSA] maestro3 - Fix PM support

Modules: Maestro3 driver

Fix PM support on maestro3 driver.

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

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

sound/pci/maestro3.c
... ... @@ -2546,14 +2546,16 @@
2546 2546 * APM support
2547 2547 */
2548 2548 #ifdef CONFIG_PM
2549   -static int m3_suspend(struct snd_card *card, pm_message_t state)
  2549 +static int m3_suspend(struct pci_dev *pci, pm_message_t state)
2550 2550 {
2551   - struct snd_m3 *chip = card->pm_private_data;
  2551 + struct snd_card *card = pci_get_drvdata(pci);
  2552 + struct snd_m3 *chip = card->private_data;
2552 2553 int i, index;
2553 2554  
2554 2555 if (chip->suspend_mem == NULL)
2555 2556 return 0;
2556 2557  
  2558 + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
2557 2559 snd_pcm_suspend_all(chip->pcm);
2558 2560 snd_ac97_suspend(chip->ac97);
2559 2561  
2560 2562  
2561 2563  
2562 2564  
... ... @@ -2574,20 +2576,23 @@
2574 2576 snd_m3_outw(chip, 0xffff, 0x54);
2575 2577 snd_m3_outw(chip, 0xffff, 0x56);
2576 2578  
2577   - pci_disable_device(chip->pci);
  2579 + pci_disable_device(pci);
  2580 + pci_save_state(pci);
2578 2581 return 0;
2579 2582 }
2580 2583  
2581   -static int m3_resume(struct snd_card *card)
  2584 +static int m3_resume(struct pci_dev *pci)
2582 2585 {
2583   - struct snd_m3 *chip = card->pm_private_data;
  2586 + struct snd_card *card = pci_get_drvdata(pci);
  2587 + struct snd_m3 *chip = card->private_data;
2584 2588 int i, index;
2585 2589  
2586 2590 if (chip->suspend_mem == NULL)
2587 2591 return 0;
2588 2592  
2589   - pci_enable_device(chip->pci);
2590   - pci_set_master(chip->pci);
  2593 + pci_restore_state(pci);
  2594 + pci_enable_device(pci);
  2595 + pci_set_master(pci);
2591 2596  
2592 2597 /* first lets just bring everything back. .*/
2593 2598 snd_m3_outw(chip, 0, 0x54);
... ... @@ -2617,6 +2622,7 @@
2617 2622 snd_m3_enable_ints(chip);
2618 2623 snd_m3_amp_enable(chip, 1);
2619 2624  
  2625 + snd_power_change_state(card, SNDRV_CTL_POWER_D0);
2620 2626 return 0;
2621 2627 }
2622 2628 #endif /* CONFIG_PM */
... ... @@ -2748,8 +2754,6 @@
2748 2754 chip->suspend_mem = vmalloc(sizeof(u16) * (REV_B_CODE_MEMORY_LENGTH + REV_B_DATA_MEMORY_LENGTH));
2749 2755 if (chip->suspend_mem == NULL)
2750 2756 snd_printk(KERN_WARNING "can't allocate apm buffer\n");
2751   - else
2752   - snd_card_set_pm_callback(card, m3_suspend, m3_resume, chip);
2753 2757 #endif
2754 2758  
2755 2759 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
... ... @@ -2825,6 +2829,7 @@
2825 2829 snd_card_free(card);
2826 2830 return err;
2827 2831 }
  2832 + card->private_data = chip;
2828 2833  
2829 2834 sprintf(card->shortname, "ESS %s PCI", card->driver);
2830 2835 sprintf(card->longname, "%s at 0x%lx, irq %d",
... ... @@ -2860,7 +2865,10 @@
2860 2865 .id_table = snd_m3_ids,
2861 2866 .probe = snd_m3_probe,
2862 2867 .remove = __devexit_p(snd_m3_remove),
2863   - SND_PCI_PM_CALLBACKS
  2868 +#ifdef CONFIG_PM
  2869 + .suspend = m3_suspend,
  2870 + .resume = m3_resume,
  2871 +#endif
2864 2872 };
2865 2873  
2866 2874 static int __init alsa_card_m3_init(void)