diff options
author | Takashi Iwai <tiwai@suse.de> | 2005-11-17 10:10:51 -0500 |
---|---|---|
committer | Jaroslav Kysela <perex@suse.cz> | 2006-01-03 06:27:50 -0500 |
commit | bf53c3b3f368cdc2aa9a59f220337ede854f507d (patch) | |
tree | 420cfb1ef9012e49c8c0b0cfc5a6b3565731c945 /sound/pci/ali5451/ali5451.c | |
parent | 57feb83507d598de04e986cfa463acda9f2a67a8 (diff) |
[ALSA] ali5451 - Fix PM support
Modules: ALI5451 driver
Fix PM support on ALI5451 driver.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/ali5451/ali5451.c')
-rw-r--r-- | sound/pci/ali5451/ali5451.c | 46 |
1 files changed, 24 insertions, 22 deletions
diff --git a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c index 2538cda2521d..bc4d1ef08efa 100644 --- a/sound/pci/ali5451/ali5451.c +++ b/sound/pci/ali5451/ali5451.c | |||
@@ -1991,9 +1991,10 @@ static int __devinit snd_ali_mixer(struct snd_ali * codec) | |||
1991 | } | 1991 | } |
1992 | 1992 | ||
1993 | #ifdef CONFIG_PM | 1993 | #ifdef CONFIG_PM |
1994 | static int ali_suspend(struct snd_card *card, pm_message_t state) | 1994 | static int ali_suspend(struct pci_dev *pci, pm_message_t state) |
1995 | { | 1995 | { |
1996 | struct snd_ali *chip = card->pm_private_data; | 1996 | struct snd_card *card = pci_get_drvdata(pci); |
1997 | struct snd_ali *chip = card->private_data; | ||
1997 | struct snd_ali_image *im; | 1998 | struct snd_ali_image *im; |
1998 | int i, j; | 1999 | int i, j; |
1999 | 2000 | ||
@@ -2001,11 +2002,10 @@ static int ali_suspend(struct snd_card *card, pm_message_t state) | |||
2001 | if (! im) | 2002 | if (! im) |
2002 | return 0; | 2003 | return 0; |
2003 | 2004 | ||
2005 | snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); | ||
2004 | for(i = 0 ; i < chip->num_of_codecs ; i++) { | 2006 | for(i = 0 ; i < chip->num_of_codecs ; i++) { |
2005 | if (chip->pcm[i]) | 2007 | snd_pcm_suspend_all(chip->pcm[i]); |
2006 | snd_pcm_suspend_all(chip->pcm[i]); | 2008 | snd_ac97_suspend(chip->ac97[i]); |
2007 | if(chip->ac97[i]) | ||
2008 | snd_ac97_suspend(chip->ac97[i]); | ||
2009 | } | 2009 | } |
2010 | 2010 | ||
2011 | spin_lock_irq(&chip->reg_lock); | 2011 | spin_lock_irq(&chip->reg_lock); |
@@ -2033,13 +2033,15 @@ static int ali_suspend(struct snd_card *card, pm_message_t state) | |||
2033 | outl(0xffffffff, ALI_REG(chip, ALI_STOP)); | 2033 | outl(0xffffffff, ALI_REG(chip, ALI_STOP)); |
2034 | 2034 | ||
2035 | spin_unlock_irq(&chip->reg_lock); | 2035 | spin_unlock_irq(&chip->reg_lock); |
2036 | pci_disable_device(chip->pci); | 2036 | pci_disable_device(pci); |
2037 | pci_save_state(pci); | ||
2037 | return 0; | 2038 | return 0; |
2038 | } | 2039 | } |
2039 | 2040 | ||
2040 | static int ali_resume(struct snd_card *card) | 2041 | static int ali_resume(struct pci_dev *pci) |
2041 | { | 2042 | { |
2042 | struct snd_ali *chip = card->pm_private_data; | 2043 | struct snd_card *card = pci_get_drvdata(pci); |
2044 | struct snd_ali *chip = card->private_data; | ||
2043 | struct snd_ali_image *im; | 2045 | struct snd_ali_image *im; |
2044 | int i, j; | 2046 | int i, j; |
2045 | 2047 | ||
@@ -2047,7 +2049,8 @@ static int ali_resume(struct snd_card *card) | |||
2047 | if (! im) | 2049 | if (! im) |
2048 | return 0; | 2050 | return 0; |
2049 | 2051 | ||
2050 | pci_enable_device(chip->pci); | 2052 | pci_restore_state(pci); |
2053 | pci_enable_device(pci); | ||
2051 | 2054 | ||
2052 | spin_lock_irq(&chip->reg_lock); | 2055 | spin_lock_irq(&chip->reg_lock); |
2053 | 2056 | ||
@@ -2071,9 +2074,9 @@ static int ali_resume(struct snd_card *card) | |||
2071 | spin_unlock_irq(&chip->reg_lock); | 2074 | spin_unlock_irq(&chip->reg_lock); |
2072 | 2075 | ||
2073 | for(i = 0 ; i < chip->num_of_codecs ; i++) | 2076 | for(i = 0 ; i < chip->num_of_codecs ; i++) |
2074 | if(chip->ac97[i]) | 2077 | snd_ac97_resume(chip->ac97[i]); |
2075 | snd_ac97_resume(chip->ac97[i]); | ||
2076 | 2078 | ||
2079 | snd_power_change_state(card, SNDRV_CTL_POWER_D0); | ||
2077 | return 0; | 2080 | return 0; |
2078 | } | 2081 | } |
2079 | #endif /* CONFIG_PM */ | 2082 | #endif /* CONFIG_PM */ |
@@ -2204,9 +2207,8 @@ static int __devinit snd_ali_create(struct snd_card *card, | |||
2204 | { | 2207 | { |
2205 | struct snd_ali *codec; | 2208 | struct snd_ali *codec; |
2206 | int i, err; | 2209 | int i, err; |
2207 | unsigned short cmdw = 0; | 2210 | unsigned short cmdw; |
2208 | struct pci_dev *pci_dev = NULL; | 2211 | static struct snd_device_ops ops = { |
2209 | static struct snd_device_ops ops = { | ||
2210 | .dev_free = snd_ali_dev_free, | 2212 | .dev_free = snd_ali_dev_free, |
2211 | }; | 2213 | }; |
2212 | 2214 | ||
@@ -2281,16 +2283,14 @@ static int __devinit snd_ali_create(struct snd_card *card, | |||
2281 | codec->chregs.data.ainten = 0x00; | 2283 | codec->chregs.data.ainten = 0x00; |
2282 | 2284 | ||
2283 | /* M1533: southbridge */ | 2285 | /* M1533: southbridge */ |
2284 | pci_dev = pci_get_device(0x10b9, 0x1533, NULL); | 2286 | codec->pci_m1533 = pci_get_device(0x10b9, 0x1533, NULL); |
2285 | codec->pci_m1533 = pci_dev; | ||
2286 | if (! codec->pci_m1533) { | 2287 | if (! codec->pci_m1533) { |
2287 | snd_printk(KERN_ERR "ali5451: cannot find ALi 1533 chip.\n"); | 2288 | snd_printk(KERN_ERR "ali5451: cannot find ALi 1533 chip.\n"); |
2288 | snd_ali_free(codec); | 2289 | snd_ali_free(codec); |
2289 | return -ENODEV; | 2290 | return -ENODEV; |
2290 | } | 2291 | } |
2291 | /* M7101: power management */ | 2292 | /* M7101: power management */ |
2292 | pci_dev = pci_get_device(0x10b9, 0x7101, NULL); | 2293 | codec->pci_m7101 = pci_get_device(0x10b9, 0x7101, NULL); |
2293 | codec->pci_m7101 = pci_dev; | ||
2294 | if (! codec->pci_m7101 && codec->revision == ALI_5451_V02) { | 2294 | if (! codec->pci_m7101 && codec->revision == ALI_5451_V02) { |
2295 | snd_printk(KERN_ERR "ali5451: cannot find ALi 7101 chip.\n"); | 2295 | snd_printk(KERN_ERR "ali5451: cannot find ALi 7101 chip.\n"); |
2296 | snd_ali_free(codec); | 2296 | snd_ali_free(codec); |
@@ -2317,8 +2317,6 @@ static int __devinit snd_ali_create(struct snd_card *card, | |||
2317 | codec->image = kmalloc(sizeof(*codec->image), GFP_KERNEL); | 2317 | codec->image = kmalloc(sizeof(*codec->image), GFP_KERNEL); |
2318 | if (! codec->image) | 2318 | if (! codec->image) |
2319 | snd_printk(KERN_WARNING "can't allocate apm buffer\n"); | 2319 | snd_printk(KERN_WARNING "can't allocate apm buffer\n"); |
2320 | else | ||
2321 | snd_card_set_pm_callback(card, ali_suspend, ali_resume, codec); | ||
2322 | #endif | 2320 | #endif |
2323 | 2321 | ||
2324 | snd_ali_enable_address_interrupt(codec); | 2322 | snd_ali_enable_address_interrupt(codec); |
@@ -2346,6 +2344,7 @@ static int __devinit snd_ali_probe(struct pci_dev *pci, | |||
2346 | snd_card_free(card); | 2344 | snd_card_free(card); |
2347 | return err; | 2345 | return err; |
2348 | } | 2346 | } |
2347 | card->private_data = codec; | ||
2349 | 2348 | ||
2350 | snd_ali_printk("mixer building ...\n"); | 2349 | snd_ali_printk("mixer building ...\n"); |
2351 | if ((err = snd_ali_mixer(codec)) < 0) { | 2350 | if ((err = snd_ali_mixer(codec)) < 0) { |
@@ -2387,7 +2386,10 @@ static struct pci_driver driver = { | |||
2387 | .id_table = snd_ali_ids, | 2386 | .id_table = snd_ali_ids, |
2388 | .probe = snd_ali_probe, | 2387 | .probe = snd_ali_probe, |
2389 | .remove = __devexit_p(snd_ali_remove), | 2388 | .remove = __devexit_p(snd_ali_remove), |
2390 | SND_PCI_PM_CALLBACKS | 2389 | #ifdef CONFIG_PM |
2390 | .suspend = ali_suspend, | ||
2391 | .resume = ali_resume, | ||
2392 | #endif | ||
2391 | }; | 2393 | }; |
2392 | 2394 | ||
2393 | static int __init alsa_card_ali_init(void) | 2395 | static int __init alsa_card_ali_init(void) |