Skip to content

Commit

Permalink
[ALSA] ali5451 - Fix PM support
Browse files Browse the repository at this point in the history
Modules: ALI5451 driver

Fix PM support on ALI5451 driver.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
  • Loading branch information
Takashi Iwai authored and Jaroslav Kysela committed Jan 3, 2006
1 parent 57feb83 commit bf53c3b
Showing 1 changed file with 24 additions and 22 deletions.
46 changes: 24 additions & 22 deletions sound/pci/ali5451/ali5451.c
Original file line number Diff line number Diff line change
Expand Up @@ -1991,21 +1991,21 @@ static int __devinit snd_ali_mixer(struct snd_ali * codec)
}

#ifdef CONFIG_PM
static int ali_suspend(struct snd_card *card, pm_message_t state)
static int ali_suspend(struct pci_dev *pci, pm_message_t state)
{
struct snd_ali *chip = card->pm_private_data;
struct snd_card *card = pci_get_drvdata(pci);
struct snd_ali *chip = card->private_data;
struct snd_ali_image *im;
int i, j;

im = chip->image;
if (! im)
return 0;

snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
for(i = 0 ; i < chip->num_of_codecs ; i++) {
if (chip->pcm[i])
snd_pcm_suspend_all(chip->pcm[i]);
if(chip->ac97[i])
snd_ac97_suspend(chip->ac97[i]);
snd_pcm_suspend_all(chip->pcm[i]);
snd_ac97_suspend(chip->ac97[i]);
}

spin_lock_irq(&chip->reg_lock);
Expand Down Expand Up @@ -2033,21 +2033,24 @@ static int ali_suspend(struct snd_card *card, pm_message_t state)
outl(0xffffffff, ALI_REG(chip, ALI_STOP));

spin_unlock_irq(&chip->reg_lock);
pci_disable_device(chip->pci);
pci_disable_device(pci);
pci_save_state(pci);
return 0;
}

static int ali_resume(struct snd_card *card)
static int ali_resume(struct pci_dev *pci)
{
struct snd_ali *chip = card->pm_private_data;
struct snd_card *card = pci_get_drvdata(pci);
struct snd_ali *chip = card->private_data;
struct snd_ali_image *im;
int i, j;

im = chip->image;
if (! im)
return 0;

pci_enable_device(chip->pci);
pci_restore_state(pci);
pci_enable_device(pci);

spin_lock_irq(&chip->reg_lock);

Expand All @@ -2071,9 +2074,9 @@ static int ali_resume(struct snd_card *card)
spin_unlock_irq(&chip->reg_lock);

for(i = 0 ; i < chip->num_of_codecs ; i++)
if(chip->ac97[i])
snd_ac97_resume(chip->ac97[i]);
snd_ac97_resume(chip->ac97[i]);

snd_power_change_state(card, SNDRV_CTL_POWER_D0);
return 0;
}
#endif /* CONFIG_PM */
Expand Down Expand Up @@ -2204,9 +2207,8 @@ static int __devinit snd_ali_create(struct snd_card *card,
{
struct snd_ali *codec;
int i, err;
unsigned short cmdw = 0;
struct pci_dev *pci_dev = NULL;
static struct snd_device_ops ops = {
unsigned short cmdw;
static struct snd_device_ops ops = {
.dev_free = snd_ali_dev_free,
};

Expand Down Expand Up @@ -2281,16 +2283,14 @@ static int __devinit snd_ali_create(struct snd_card *card,
codec->chregs.data.ainten = 0x00;

/* M1533: southbridge */
pci_dev = pci_get_device(0x10b9, 0x1533, NULL);
codec->pci_m1533 = pci_dev;
codec->pci_m1533 = pci_get_device(0x10b9, 0x1533, NULL);
if (! codec->pci_m1533) {
snd_printk(KERN_ERR "ali5451: cannot find ALi 1533 chip.\n");
snd_ali_free(codec);
return -ENODEV;
}
/* M7101: power management */
pci_dev = pci_get_device(0x10b9, 0x7101, NULL);
codec->pci_m7101 = pci_dev;
codec->pci_m7101 = pci_get_device(0x10b9, 0x7101, NULL);
if (! codec->pci_m7101 && codec->revision == ALI_5451_V02) {
snd_printk(KERN_ERR "ali5451: cannot find ALi 7101 chip.\n");
snd_ali_free(codec);
Expand All @@ -2317,8 +2317,6 @@ static int __devinit snd_ali_create(struct snd_card *card,
codec->image = kmalloc(sizeof(*codec->image), GFP_KERNEL);
if (! codec->image)
snd_printk(KERN_WARNING "can't allocate apm buffer\n");
else
snd_card_set_pm_callback(card, ali_suspend, ali_resume, codec);
#endif

snd_ali_enable_address_interrupt(codec);
Expand Down Expand Up @@ -2346,6 +2344,7 @@ static int __devinit snd_ali_probe(struct pci_dev *pci,
snd_card_free(card);
return err;
}
card->private_data = codec;

snd_ali_printk("mixer building ...\n");
if ((err = snd_ali_mixer(codec)) < 0) {
Expand Down Expand Up @@ -2387,7 +2386,10 @@ static struct pci_driver driver = {
.id_table = snd_ali_ids,
.probe = snd_ali_probe,
.remove = __devexit_p(snd_ali_remove),
SND_PCI_PM_CALLBACKS
#ifdef CONFIG_PM
.suspend = ali_suspend,
.resume = ali_resume,
#endif
};

static int __init alsa_card_ali_init(void)
Expand Down

0 comments on commit bf53c3b

Please sign in to comment.