Commit cb28e45b authored by Takashi Iwai's avatar Takashi Iwai Committed by Jaroslav Kysela

[ALSA] cs46xx - Fix PM support

Modules: CS46xx driver

Fix PM support on CS46xx driver.
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 1d4b822b
...@@ -1728,6 +1728,8 @@ int snd_cs46xx_create(struct snd_card *card, ...@@ -1728,6 +1728,8 @@ int snd_cs46xx_create(struct snd_card *card,
struct pci_dev *pci, struct pci_dev *pci,
int external_amp, int thinkpad, int external_amp, int thinkpad,
struct snd_cs46xx **rcodec); struct snd_cs46xx **rcodec);
int snd_cs46xx_suspend(struct pci_dev *pci, pm_message_t state);
int snd_cs46xx_resume(struct pci_dev *pci);
int snd_cs46xx_pcm(struct snd_cs46xx *chip, int device, struct snd_pcm **rpcm); int snd_cs46xx_pcm(struct snd_cs46xx *chip, int device, struct snd_pcm **rpcm);
int snd_cs46xx_pcm_rear(struct snd_cs46xx *chip, int device, struct snd_pcm **rpcm); int snd_cs46xx_pcm_rear(struct snd_cs46xx *chip, int device, struct snd_pcm **rpcm);
......
...@@ -98,6 +98,7 @@ static int __devinit snd_card_cs46xx_probe(struct pci_dev *pci, ...@@ -98,6 +98,7 @@ static int __devinit snd_card_cs46xx_probe(struct pci_dev *pci,
snd_card_free(card); snd_card_free(card);
return err; return err;
} }
card->private_data = chip;
chip->accept_valid = mmap_valid[dev]; chip->accept_valid = mmap_valid[dev];
if ((err = snd_cs46xx_pcm(chip, 0, NULL)) < 0) { if ((err = snd_cs46xx_pcm(chip, 0, NULL)) < 0) {
snd_card_free(card); snd_card_free(card);
...@@ -166,7 +167,10 @@ static struct pci_driver driver = { ...@@ -166,7 +167,10 @@ static struct pci_driver driver = {
.id_table = snd_cs46xx_ids, .id_table = snd_cs46xx_ids,
.probe = snd_card_cs46xx_probe, .probe = snd_card_cs46xx_probe,
.remove = __devexit_p(snd_card_cs46xx_remove), .remove = __devexit_p(snd_card_cs46xx_remove),
SND_PCI_PM_CALLBACKS #ifdef CONFIG_PM
.suspend = snd_cs46xx_suspend,
.resume = snd_cs46xx_resume,
#endif
}; };
static int __init alsa_card_cs46xx_init(void) static int __init alsa_card_cs46xx_init(void)
......
...@@ -3654,18 +3654,19 @@ static struct cs_card_type __devinitdata cards[] = { ...@@ -3654,18 +3654,19 @@ static struct cs_card_type __devinitdata cards[] = {
* APM support * APM support
*/ */
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int snd_cs46xx_suspend(struct snd_card *card, pm_message_t state) int snd_cs46xx_suspend(struct pci_dev *pci, pm_message_t state)
{ {
struct snd_cs46xx *chip = card->pm_private_data; struct snd_card *card = pci_get_drvdata(pci);
struct snd_cs46xx *chip = card->private_data;
int amp_saved; int amp_saved;
snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
snd_pcm_suspend_all(chip->pcm); snd_pcm_suspend_all(chip->pcm);
// chip->ac97_powerdown = snd_cs46xx_codec_read(chip, AC97_POWER_CONTROL); // chip->ac97_powerdown = snd_cs46xx_codec_read(chip, AC97_POWER_CONTROL);
// chip->ac97_general_purpose = snd_cs46xx_codec_read(chip, BA0_AC97_GENERAL_PURPOSE); // chip->ac97_general_purpose = snd_cs46xx_codec_read(chip, BA0_AC97_GENERAL_PURPOSE);
snd_ac97_suspend(chip->ac97[CS46XX_PRIMARY_CODEC_INDEX]); snd_ac97_suspend(chip->ac97[CS46XX_PRIMARY_CODEC_INDEX]);
if (chip->ac97[CS46XX_SECONDARY_CODEC_INDEX]) snd_ac97_suspend(chip->ac97[CS46XX_SECONDARY_CODEC_INDEX]);
snd_ac97_suspend(chip->ac97[CS46XX_SECONDARY_CODEC_INDEX]);
amp_saved = chip->amplifier; amp_saved = chip->amplifier;
/* turn off amp */ /* turn off amp */
...@@ -3674,17 +3675,20 @@ static int snd_cs46xx_suspend(struct snd_card *card, pm_message_t state) ...@@ -3674,17 +3675,20 @@ static int snd_cs46xx_suspend(struct snd_card *card, pm_message_t state)
/* disable CLKRUN */ /* disable CLKRUN */
chip->active_ctrl(chip, -chip->amplifier); chip->active_ctrl(chip, -chip->amplifier);
chip->amplifier = amp_saved; /* restore the status */ chip->amplifier = amp_saved; /* restore the status */
pci_disable_device(chip->pci); pci_disable_device(pci);
pci_save_state(pci);
return 0; return 0;
} }
static int snd_cs46xx_resume(struct snd_card *card) int snd_cs46xx_resume(struct pci_dev *pci)
{ {
struct snd_cs46xx *chip = card->pm_private_data; struct snd_card *card = pci_get_drvdata(pci);
struct snd_cs46xx *chip = card->private_data;
int amp_saved; int amp_saved;
pci_enable_device(chip->pci); pci_restore_state(pci);
pci_set_master(chip->pci); pci_enable_device(pci);
pci_set_master(pci);
amp_saved = chip->amplifier; amp_saved = chip->amplifier;
chip->amplifier = 0; chip->amplifier = 0;
chip->active_ctrl(chip, 1); /* force to on */ chip->active_ctrl(chip, 1); /* force to on */
...@@ -3703,14 +3707,14 @@ static int snd_cs46xx_resume(struct snd_card *card) ...@@ -3703,14 +3707,14 @@ static int snd_cs46xx_resume(struct snd_card *card)
#endif #endif
snd_ac97_resume(chip->ac97[CS46XX_PRIMARY_CODEC_INDEX]); snd_ac97_resume(chip->ac97[CS46XX_PRIMARY_CODEC_INDEX]);
if (chip->ac97[CS46XX_SECONDARY_CODEC_INDEX]) snd_ac97_resume(chip->ac97[CS46XX_SECONDARY_CODEC_INDEX]);
snd_ac97_resume(chip->ac97[CS46XX_SECONDARY_CODEC_INDEX]);
if (amp_saved) if (amp_saved)
chip->amplifier_ctrl(chip, 1); /* turn amp on */ chip->amplifier_ctrl(chip, 1); /* turn amp on */
else else
chip->active_ctrl(chip, -1); /* disable CLKRUN */ chip->active_ctrl(chip, -1); /* disable CLKRUN */
chip->amplifier = amp_saved; chip->amplifier = amp_saved;
snd_power_change_state(card, SNDRV_CTL_POWER_D0);
return 0; return 0;
} }
#endif /* CONFIG_PM */ #endif /* CONFIG_PM */
...@@ -3870,8 +3874,6 @@ int __devinit snd_cs46xx_create(struct snd_card *card, ...@@ -3870,8 +3874,6 @@ int __devinit snd_cs46xx_create(struct snd_card *card,
snd_cs46xx_proc_init(card, chip); snd_cs46xx_proc_init(card, chip);
snd_card_set_pm_callback(card, snd_cs46xx_suspend, snd_cs46xx_resume, chip);
chip->active_ctrl(chip, -1); /* disable CLKRUN */ chip->active_ctrl(chip, -1); /* disable CLKRUN */
snd_card_set_dev(card, &pci->dev); snd_card_set_dev(card, &pci->dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment