Merge branch 'master'
[pandora-kernel.git] / sound / pci / atiixp.c
index 5ead666..12e6188 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/pci.h>
 #include <linux/slab.h>
 #include <linux/moduleparam.h>
+#include <linux/mutex.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
@@ -277,7 +278,7 @@ struct atiixp {
        unsigned int codec_not_ready_bits;      /* for codec detection */
 
        int spdif_over_aclink;          /* passed from the module option */
-       struct semaphore open_mutex;    /* playback open mutex */
+       struct mutex open_mutex;        /* playback open mutex */
 };
 
 
@@ -1051,9 +1052,9 @@ static int snd_atiixp_playback_open(struct snd_pcm_substream *substream)
        struct atiixp *chip = snd_pcm_substream_chip(substream);
        int err;
 
-       down(&chip->open_mutex);
+       mutex_lock(&chip->open_mutex);
        err = snd_atiixp_pcm_open(substream, &chip->dmas[ATI_DMA_PLAYBACK], 0);
-       up(&chip->open_mutex);
+       mutex_unlock(&chip->open_mutex);
        if (err < 0)
                return err;
        substream->runtime->hw.channels_max = chip->max_channels;
@@ -1068,9 +1069,9 @@ static int snd_atiixp_playback_close(struct snd_pcm_substream *substream)
 {
        struct atiixp *chip = snd_pcm_substream_chip(substream);
        int err;
-       down(&chip->open_mutex);
+       mutex_lock(&chip->open_mutex);
        err = snd_atiixp_pcm_close(substream, &chip->dmas[ATI_DMA_PLAYBACK]);
-       up(&chip->open_mutex);
+       mutex_unlock(&chip->open_mutex);
        return err;
 }
 
@@ -1090,12 +1091,12 @@ static int snd_atiixp_spdif_open(struct snd_pcm_substream *substream)
 {
        struct atiixp *chip = snd_pcm_substream_chip(substream);
        int err;
-       down(&chip->open_mutex);
+       mutex_lock(&chip->open_mutex);
        if (chip->spdif_over_aclink) /* share DMA_PLAYBACK */
                err = snd_atiixp_pcm_open(substream, &chip->dmas[ATI_DMA_PLAYBACK], 2);
        else
                err = snd_atiixp_pcm_open(substream, &chip->dmas[ATI_DMA_SPDIF], -1);
-       up(&chip->open_mutex);
+       mutex_unlock(&chip->open_mutex);
        return err;
 }
 
@@ -1103,12 +1104,12 @@ static int snd_atiixp_spdif_close(struct snd_pcm_substream *substream)
 {
        struct atiixp *chip = snd_pcm_substream_chip(substream);
        int err;
-       down(&chip->open_mutex);
+       mutex_lock(&chip->open_mutex);
        if (chip->spdif_over_aclink)
                err = snd_atiixp_pcm_close(substream, &chip->dmas[ATI_DMA_PLAYBACK]);
        else
                err = snd_atiixp_pcm_close(substream, &chip->dmas[ATI_DMA_SPDIF]);
-       up(&chip->open_mutex);
+       mutex_unlock(&chip->open_mutex);
        return err;
 }
 
@@ -1353,6 +1354,12 @@ static struct ac97_quirk ac97_quirks[] __devinitdata = {
                .name = "HP Pavilion ZV5030US",
                .type = AC97_TUNE_MUTE_LED
        },
+       {
+               .subvendor = 0x103c,
+               .subdevice = 0x308b,
+               .name = "HP nx6125",
+               .type = AC97_TUNE_MUTE_LED
+       },
        { } /* terminator */
 };
 
@@ -1415,11 +1422,13 @@ static int __devinit snd_atiixp_mixer_new(struct atiixp *chip, int clock,
 /*
  * power management
  */
-static int snd_atiixp_suspend(struct snd_card *card, pm_message_t state)
+static int snd_atiixp_suspend(struct pci_dev *pci, pm_message_t state)
 {
-       struct atiixp *chip = card->pm_private_data;
+       struct snd_card *card = pci_get_drvdata(pci);
+       struct atiixp *chip = card->private_data;
        int i;
 
+       snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
        for (i = 0; i < NUM_ATI_PCMDEVS; i++)
                if (chip->pcmdevs[i]) {
                        struct atiixp_dma *dma = &chip->dmas[i];
@@ -1429,31 +1438,32 @@ static int snd_atiixp_suspend(struct snd_card *card, pm_message_t state)
                        snd_pcm_suspend_all(chip->pcmdevs[i]);
                }
        for (i = 0; i < NUM_ATI_CODECS; i++)
-               if (chip->ac97[i])
-                       snd_ac97_suspend(chip->ac97[i]);
+               snd_ac97_suspend(chip->ac97[i]);
        snd_atiixp_aclink_down(chip);
        snd_atiixp_chip_stop(chip);
 
-       pci_set_power_state(chip->pci, PCI_D3hot);
-       pci_disable_device(chip->pci);
+       pci_set_power_state(pci, PCI_D3hot);
+       pci_disable_device(pci);
+       pci_save_state(pci);
        return 0;
 }
 
-static int snd_atiixp_resume(struct snd_card *card)
+static int snd_atiixp_resume(struct pci_dev *pci)
 {
-       struct atiixp *chip = card->pm_private_data;
+       struct snd_card *card = pci_get_drvdata(pci);
+       struct atiixp *chip = card->private_data;
        int i;
 
-       pci_enable_device(chip->pci);
-       pci_set_power_state(chip->pci, PCI_D0);
-       pci_set_master(chip->pci);
+       pci_restore_state(pci);
+       pci_enable_device(pci);
+       pci_set_power_state(pci, PCI_D0);
+       pci_set_master(pci);
 
        snd_atiixp_aclink_reset(chip);
        snd_atiixp_chip_start(chip);
 
        for (i = 0; i < NUM_ATI_CODECS; i++)
-               if (chip->ac97[i])
-                       snd_ac97_resume(chip->ac97[i]);
+               snd_ac97_resume(chip->ac97[i]);
 
        for (i = 0; i < NUM_ATI_PCMDEVS; i++)
                if (chip->pcmdevs[i]) {
@@ -1468,11 +1478,13 @@ static int snd_atiixp_resume(struct snd_card *card)
                        }
                }
 
+       snd_power_change_state(card, SNDRV_CTL_POWER_D0);
        return 0;
 }
 #endif /* CONFIG_PM */
 
 
+#ifdef CONFIG_PROC_FS
 /*
  * proc interface for register dump
  */
@@ -1494,7 +1506,9 @@ static void __devinit snd_atiixp_proc_init(struct atiixp *chip)
        if (! snd_card_proc_new(chip->card, "atiixp", &entry))
                snd_info_set_text_ops(entry, chip, 1024, snd_atiixp_proc_read);
 }
-
+#else /* !CONFIG_PROC_FS */
+#define snd_atiixp_proc_init(chip)
+#endif
 
 
 /*
@@ -1547,7 +1561,7 @@ static int __devinit snd_atiixp_create(struct snd_card *card,
        }
 
        spin_lock_init(&chip->reg_lock);
-       init_MUTEX(&chip->open_mutex);
+       mutex_init(&chip->open_mutex);
        chip->card = card;
        chip->pci = pci;
        chip->irq = -1;
@@ -1604,6 +1618,7 @@ static int __devinit snd_atiixp_probe(struct pci_dev *pci,
        strcpy(card->shortname, "ATI IXP");
        if ((err = snd_atiixp_create(card, pci, &chip)) < 0)
                goto __error;
+       card->private_data = chip;
 
        if ((err = snd_atiixp_aclink_reset(chip)) < 0)
                goto __error;
@@ -1625,8 +1640,6 @@ static int __devinit snd_atiixp_probe(struct pci_dev *pci,
                 chip->ac97[0] ? snd_ac97_get_short_name(chip->ac97[0]) : "?",
                 chip->addr, chip->irq);
 
-       snd_card_set_pm_callback(card, snd_atiixp_suspend, snd_atiixp_resume, chip);
-
        if ((err = snd_card_register(card)) < 0)
                goto __error;
 
@@ -1649,7 +1662,10 @@ static struct pci_driver driver = {
        .id_table = snd_atiixp_ids,
        .probe = snd_atiixp_probe,
        .remove = __devexit_p(snd_atiixp_remove),
-       SND_PCI_PM_CALLBACKS
+#ifdef CONFIG_PM
+       .suspend = snd_atiixp_suspend,
+       .resume = snd_atiixp_resume,
+#endif
 };