Merge branch 'fix/hda' into for-linus
[safe/jmp/linux-2.6] / sound / pci / atiixp.c
index 92df811..d6752df 100644 (file)
@@ -19,7 +19,6 @@
  *
  */
 
-#include <sound/driver.h>
 #include <asm/io.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
@@ -38,7 +37,7 @@
 MODULE_AUTHOR("Takashi Iwai <tiwai@suse.de>");
 MODULE_DESCRIPTION("ATI IXP AC97 controller");
 MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("{{ATI,IXP150/200/250/300/400}}");
+MODULE_SUPPORTED_DEVICE("{{ATI,IXP150/200/250/300/400/600}}");
 
 static int index = SNDRV_DEFAULT_IDX1; /* Index 0-MAX */
 static char *id = SNDRV_DEFAULT_STR1;  /* ID for this card */
@@ -288,29 +287,18 @@ struct atiixp {
 /*
  */
 static struct pci_device_id snd_atiixp_ids[] = {
-       { 0x1002, 0x4341, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* SB200 */
-       { 0x1002, 0x4361, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* SB300 */
-       { 0x1002, 0x4370, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* SB400 */
+       { PCI_VDEVICE(ATI, 0x4341), 0 }, /* SB200 */
+       { PCI_VDEVICE(ATI, 0x4361), 0 }, /* SB300 */
+       { PCI_VDEVICE(ATI, 0x4370), 0 }, /* SB400 */
+       { PCI_VDEVICE(ATI, 0x4382), 0 }, /* SB600 */
        { 0, }
 };
 
 MODULE_DEVICE_TABLE(pci, snd_atiixp_ids);
 
-struct atiixp_quirk {
-       unsigned short  subvendor;
-       unsigned short  subdevice;
-       const char *name;
-       int ac97_codec;
-};
-
-static struct atiixp_quirk atiixp_quirks[] __devinitdata = {
-       {
-               .subvendor = 0x15bd,
-               .subdevice = 0x3100,
-               .name = "DFI RS482",
-               .ac97_codec = 0,
-       },
-       { .subvendor = 0 } /* terminator */
+static struct snd_pci_quirk atiixp_quirks[] __devinitdata = {
+       SND_PCI_QUIRK(0x15bd, 0x3100, "DFI RS482", 0),
+       { } /* terminator */
 };
 
 /*
@@ -572,25 +560,21 @@ static int snd_atiixp_aclink_down(struct atiixp *chip)
             ATI_REG_ISR_CODEC2_NOT_READY)
 #define CODEC_CHECK_BITS (ALL_CODEC_NOT_READY|ATI_REG_ISR_NEW_FRAME)
 
-static int ac97_probing_bugs(struct pci_dev *pci)
+static int __devinit ac97_probing_bugs(struct pci_dev *pci)
 {
-       int i = 0;
-
-       while (atiixp_quirks[i].subvendor) {
-               if (pci->subsystem_vendor == atiixp_quirks[i].subvendor  &&
-                   pci->subsystem_device == atiixp_quirks[i].subdevice) {
-                       printk(KERN_INFO "Atiixp quirk for %s.  "
-                              "Forcing codec %d\n", atiixp_quirks[i].name, 
-                              atiixp_quirks[i].ac97_codec);
-                       return atiixp_quirks[i].ac97_codec;
-               }
-               i++;
+       const struct snd_pci_quirk *q;
+
+       q = snd_pci_quirk_lookup(pci, atiixp_quirks);
+       if (q) {
+               snd_printdd(KERN_INFO "Atiixp quirk for %s.  "
+                           "Forcing codec %d\n", q->name, q->value);
+               return q->value;
        }
        /* this hardware doesn't need workarounds.  Probe for codec */
        return -1;
 }
 
-static int snd_atiixp_codec_detect(struct atiixp *chip)
+static int __devinit snd_atiixp_codec_detect(struct atiixp *chip)
 {
        int timeout;
 
@@ -739,7 +723,9 @@ static int snd_atiixp_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
        struct atiixp_dma *dma = substream->runtime->private_data;
        int err = 0;
 
-       snd_assert(dma->ops->enable_transfer && dma->ops->flush_dma, return -EINVAL);
+       if (snd_BUG_ON(!dma->ops->enable_transfer ||
+                      !dma->ops->flush_dma))
+               return -EINVAL;
 
        spin_lock(&chip->reg_lock);
        switch (cmd) {
@@ -1049,7 +1035,8 @@ static int snd_atiixp_pcm_open(struct snd_pcm_substream *substream,
        struct snd_pcm_runtime *runtime = substream->runtime;
        int err;
 
-       snd_assert(dma->ops && dma->ops->enable_dma, return -EINVAL);
+       if (snd_BUG_ON(!dma->ops || !dma->ops->enable_dma))
+               return -EINVAL;
 
        if (dma->opened)
                return -EBUSY;
@@ -1081,7 +1068,8 @@ static int snd_atiixp_pcm_close(struct snd_pcm_substream *substream,
 {
        struct atiixp *chip = snd_pcm_substream_chip(substream);
        /* disable DMA bits */
-       snd_assert(dma->ops && dma->ops->enable_dma, return -EINVAL);
+       if (snd_BUG_ON(!dma->ops || !dma->ops->enable_dma))
+               return -EINVAL;
        spin_lock_irq(&chip->reg_lock);
        dma->ops->enable_dma(chip, 0);
        spin_unlock_irq(&chip->reg_lock);
@@ -1405,6 +1393,12 @@ static struct ac97_quirk ac97_quirks[] __devinitdata = {
                .name = "HP nx6125",
                .type = AC97_TUNE_MUTE_LED
        },
+       {
+               .subvendor = 0x103c,
+               .subdevice = 0x3091,
+               .name = "unknown HP",
+               .type = AC97_TUNE_MUTE_LED
+       },
        { } /* terminator */
 };
 
@@ -1570,7 +1564,7 @@ static int snd_atiixp_free(struct atiixp *chip)
        if (chip->irq < 0)
                goto __hw_end;
        snd_atiixp_chip_stop(chip);
-       synchronize_irq(chip->irq);
+
       __hw_end:
        if (chip->irq >= 0)
                free_irq(chip->irq, chip);
@@ -1621,7 +1615,7 @@ static int __devinit snd_atiixp_create(struct snd_card *card,
                return err;
        }
        chip->addr = pci_resource_start(pci, 0);
-       chip->remap_addr = ioremap_nocache(chip->addr, pci_resource_len(pci, 0));
+       chip->remap_addr = pci_ioremap_bar(pci, 0);
        if (chip->remap_addr == NULL) {
                snd_printk(KERN_ERR "AC'97 space ioremap problem\n");
                snd_atiixp_free(chip);
@@ -1655,14 +1649,11 @@ static int __devinit snd_atiixp_probe(struct pci_dev *pci,
 {
        struct snd_card *card;
        struct atiixp *chip;
-       unsigned char revision;
        int err;
 
-       card = snd_card_new(index, id, THIS_MODULE, 0);
-       if (card == NULL)
-               return -ENOMEM;
-
-       pci_read_config_byte(pci, PCI_REVISION_ID, &revision);
+       err = snd_card_create(index, id, THIS_MODULE, 0, &card);
+       if (err < 0)
+               return err;
 
        strcpy(card->driver, spdif_aclink ? "ATIIXP" : "ATIIXP-SPDMA");
        strcpy(card->shortname, "ATI IXP");
@@ -1686,7 +1677,8 @@ static int __devinit snd_atiixp_probe(struct pci_dev *pci,
        snd_atiixp_chip_start(chip);
 
        snprintf(card->longname, sizeof(card->longname),
-                "%s rev %x with %s at %#lx, irq %i", card->shortname, revision,
+                "%s rev %x with %s at %#lx, irq %i", card->shortname,
+                pci->revision,
                 chip->ac97[0] ? snd_ac97_get_short_name(chip->ac97[0]) : "?",
                 chip->addr, chip->irq);