diff options
-rw-r--r-- | include/sound/cs46xx.h | 2 | ||||
-rw-r--r-- | sound/pci/cs46xx/cs46xx.c | 6 | ||||
-rw-r--r-- | sound/pci/cs46xx/cs46xx_lib.c | 28 |
3 files changed, 22 insertions, 14 deletions
diff --git a/include/sound/cs46xx.h b/include/sound/cs46xx.h index b33ca2a36300..199b5098ff7e 100644 --- a/include/sound/cs46xx.h +++ b/include/sound/cs46xx.h | |||
@@ -1728,6 +1728,8 @@ int snd_cs46xx_create(struct snd_card *card, | |||
1728 | struct pci_dev *pci, | 1728 | struct pci_dev *pci, |
1729 | int external_amp, int thinkpad, | 1729 | int external_amp, int thinkpad, |
1730 | struct snd_cs46xx **rcodec); | 1730 | struct snd_cs46xx **rcodec); |
1731 | int snd_cs46xx_suspend(struct pci_dev *pci, pm_message_t state); | ||
1732 | int snd_cs46xx_resume(struct pci_dev *pci); | ||
1731 | 1733 | ||
1732 | int snd_cs46xx_pcm(struct snd_cs46xx *chip, int device, struct snd_pcm **rpcm); | 1734 | int snd_cs46xx_pcm(struct snd_cs46xx *chip, int device, struct snd_pcm **rpcm); |
1733 | int snd_cs46xx_pcm_rear(struct snd_cs46xx *chip, int device, struct snd_pcm **rpcm); | 1735 | int snd_cs46xx_pcm_rear(struct snd_cs46xx *chip, int device, struct snd_pcm **rpcm); |
diff --git a/sound/pci/cs46xx/cs46xx.c b/sound/pci/cs46xx/cs46xx.c index 7d6b29e5433a..c590602e20cd 100644 --- a/sound/pci/cs46xx/cs46xx.c +++ b/sound/pci/cs46xx/cs46xx.c | |||
@@ -98,6 +98,7 @@ static int __devinit snd_card_cs46xx_probe(struct pci_dev *pci, | |||
98 | snd_card_free(card); | 98 | snd_card_free(card); |
99 | return err; | 99 | return err; |
100 | } | 100 | } |
101 | card->private_data = chip; | ||
101 | chip->accept_valid = mmap_valid[dev]; | 102 | chip->accept_valid = mmap_valid[dev]; |
102 | if ((err = snd_cs46xx_pcm(chip, 0, NULL)) < 0) { | 103 | if ((err = snd_cs46xx_pcm(chip, 0, NULL)) < 0) { |
103 | snd_card_free(card); | 104 | snd_card_free(card); |
@@ -166,7 +167,10 @@ static struct pci_driver driver = { | |||
166 | .id_table = snd_cs46xx_ids, | 167 | .id_table = snd_cs46xx_ids, |
167 | .probe = snd_card_cs46xx_probe, | 168 | .probe = snd_card_cs46xx_probe, |
168 | .remove = __devexit_p(snd_card_cs46xx_remove), | 169 | .remove = __devexit_p(snd_card_cs46xx_remove), |
169 | SND_PCI_PM_CALLBACKS | 170 | #ifdef CONFIG_PM |
171 | .suspend = snd_cs46xx_suspend, | ||
172 | .resume = snd_cs46xx_resume, | ||
173 | #endif | ||
170 | }; | 174 | }; |
171 | 175 | ||
172 | static int __init alsa_card_cs46xx_init(void) | 176 | static int __init alsa_card_cs46xx_init(void) |
diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c index 11d91d08a14c..0ec0592a6e6f 100644 --- a/sound/pci/cs46xx/cs46xx_lib.c +++ b/sound/pci/cs46xx/cs46xx_lib.c | |||
@@ -3654,18 +3654,19 @@ static struct cs_card_type __devinitdata cards[] = { | |||
3654 | * APM support | 3654 | * APM support |
3655 | */ | 3655 | */ |
3656 | #ifdef CONFIG_PM | 3656 | #ifdef CONFIG_PM |
3657 | static int snd_cs46xx_suspend(struct snd_card *card, pm_message_t state) | 3657 | int snd_cs46xx_suspend(struct pci_dev *pci, pm_message_t state) |
3658 | { | 3658 | { |
3659 | struct snd_cs46xx *chip = card->pm_private_data; | 3659 | struct snd_card *card = pci_get_drvdata(pci); |
3660 | struct snd_cs46xx *chip = card->private_data; | ||
3660 | int amp_saved; | 3661 | int amp_saved; |
3661 | 3662 | ||
3663 | snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); | ||
3662 | snd_pcm_suspend_all(chip->pcm); | 3664 | snd_pcm_suspend_all(chip->pcm); |
3663 | // chip->ac97_powerdown = snd_cs46xx_codec_read(chip, AC97_POWER_CONTROL); | 3665 | // chip->ac97_powerdown = snd_cs46xx_codec_read(chip, AC97_POWER_CONTROL); |
3664 | // chip->ac97_general_purpose = snd_cs46xx_codec_read(chip, BA0_AC97_GENERAL_PURPOSE); | 3666 | // chip->ac97_general_purpose = snd_cs46xx_codec_read(chip, BA0_AC97_GENERAL_PURPOSE); |
3665 | 3667 | ||
3666 | snd_ac97_suspend(chip->ac97[CS46XX_PRIMARY_CODEC_INDEX]); | 3668 | snd_ac97_suspend(chip->ac97[CS46XX_PRIMARY_CODEC_INDEX]); |
3667 | if (chip->ac97[CS46XX_SECONDARY_CODEC_INDEX]) | 3669 | snd_ac97_suspend(chip->ac97[CS46XX_SECONDARY_CODEC_INDEX]); |
3668 | snd_ac97_suspend(chip->ac97[CS46XX_SECONDARY_CODEC_INDEX]); | ||
3669 | 3670 | ||
3670 | amp_saved = chip->amplifier; | 3671 | amp_saved = chip->amplifier; |
3671 | /* turn off amp */ | 3672 | /* turn off amp */ |
@@ -3674,17 +3675,20 @@ static int snd_cs46xx_suspend(struct snd_card *card, pm_message_t state) | |||
3674 | /* disable CLKRUN */ | 3675 | /* disable CLKRUN */ |
3675 | chip->active_ctrl(chip, -chip->amplifier); | 3676 | chip->active_ctrl(chip, -chip->amplifier); |
3676 | chip->amplifier = amp_saved; /* restore the status */ | 3677 | chip->amplifier = amp_saved; /* restore the status */ |
3677 | pci_disable_device(chip->pci); | 3678 | pci_disable_device(pci); |
3679 | pci_save_state(pci); | ||
3678 | return 0; | 3680 | return 0; |
3679 | } | 3681 | } |
3680 | 3682 | ||
3681 | static int snd_cs46xx_resume(struct snd_card *card) | 3683 | int snd_cs46xx_resume(struct pci_dev *pci) |
3682 | { | 3684 | { |
3683 | struct snd_cs46xx *chip = card->pm_private_data; | 3685 | struct snd_card *card = pci_get_drvdata(pci); |
3686 | struct snd_cs46xx *chip = card->private_data; | ||
3684 | int amp_saved; | 3687 | int amp_saved; |
3685 | 3688 | ||
3686 | pci_enable_device(chip->pci); | 3689 | pci_restore_state(pci); |
3687 | pci_set_master(chip->pci); | 3690 | pci_enable_device(pci); |
3691 | pci_set_master(pci); | ||
3688 | amp_saved = chip->amplifier; | 3692 | amp_saved = chip->amplifier; |
3689 | chip->amplifier = 0; | 3693 | chip->amplifier = 0; |
3690 | chip->active_ctrl(chip, 1); /* force to on */ | 3694 | chip->active_ctrl(chip, 1); /* force to on */ |
@@ -3703,14 +3707,14 @@ static int snd_cs46xx_resume(struct snd_card *card) | |||
3703 | #endif | 3707 | #endif |
3704 | 3708 | ||
3705 | snd_ac97_resume(chip->ac97[CS46XX_PRIMARY_CODEC_INDEX]); | 3709 | snd_ac97_resume(chip->ac97[CS46XX_PRIMARY_CODEC_INDEX]); |
3706 | if (chip->ac97[CS46XX_SECONDARY_CODEC_INDEX]) | 3710 | snd_ac97_resume(chip->ac97[CS46XX_SECONDARY_CODEC_INDEX]); |
3707 | snd_ac97_resume(chip->ac97[CS46XX_SECONDARY_CODEC_INDEX]); | ||
3708 | 3711 | ||
3709 | if (amp_saved) | 3712 | if (amp_saved) |
3710 | chip->amplifier_ctrl(chip, 1); /* turn amp on */ | 3713 | chip->amplifier_ctrl(chip, 1); /* turn amp on */ |
3711 | else | 3714 | else |
3712 | chip->active_ctrl(chip, -1); /* disable CLKRUN */ | 3715 | chip->active_ctrl(chip, -1); /* disable CLKRUN */ |
3713 | chip->amplifier = amp_saved; | 3716 | chip->amplifier = amp_saved; |
3717 | snd_power_change_state(card, SNDRV_CTL_POWER_D0); | ||
3714 | return 0; | 3718 | return 0; |
3715 | } | 3719 | } |
3716 | #endif /* CONFIG_PM */ | 3720 | #endif /* CONFIG_PM */ |
@@ -3870,8 +3874,6 @@ int __devinit snd_cs46xx_create(struct snd_card *card, | |||
3870 | 3874 | ||
3871 | snd_cs46xx_proc_init(card, chip); | 3875 | snd_cs46xx_proc_init(card, chip); |
3872 | 3876 | ||
3873 | snd_card_set_pm_callback(card, snd_cs46xx_suspend, snd_cs46xx_resume, chip); | ||
3874 | |||
3875 | chip->active_ctrl(chip, -1); /* disable CLKRUN */ | 3877 | chip->active_ctrl(chip, -1); /* disable CLKRUN */ |
3876 | 3878 | ||
3877 | snd_card_set_dev(card, &pci->dev); | 3879 | snd_card_set_dev(card, &pci->dev); |