]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - sound/pci/cs5535audio/cs5535audio.c
x86: c_p_a() make it more robust against use of PAT bits
[linux-2.6-omap-h63xx.git] / sound / pci / cs5535audio / cs5535audio.c
index 9fc7f3827461eda749261d62bdd669201d57a8e8..2b35889787be6533f88cf484820c481c747d70b0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Driver for audio on multifunction CS5535 companion device
+ * Driver for audio on multifunction CS5535/6 companion device
  * Copyright (C) Jaya Kumar
  *
  * Based on Jaroslav Kysela and Takashi Iwai's examples.
 
 #define DRIVER_NAME "cs5535audio"
 
+static char *ac97_quirk;
+module_param(ac97_quirk, charp, 0444);
+MODULE_PARM_DESC(ac97_quirk, "AC'97 board specific workarounds.");
+
+static struct ac97_quirk ac97_quirks[] __devinitdata = {
+#if 0 /* Not yet confirmed if all 5536 boards are HP only */
+       {
+               .subvendor = PCI_VENDOR_ID_AMD, 
+               .subdevice = PCI_DEVICE_ID_AMD_CS5536_AUDIO, 
+               .name = "AMD RDK",     
+               .type = AC97_TUNE_HP_ONLY
+       },
+#endif
+       {}
+};
 
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
 
+module_param_array(index, int, NULL, 0444);
+MODULE_PARM_DESC(index, "Index value for " DRIVER_NAME);
+module_param_array(id, charp, NULL, 0444);
+MODULE_PARM_DESC(id, "ID string for " DRIVER_NAME);
+module_param_array(enable, bool, NULL, 0444);
+MODULE_PARM_DESC(enable, "Enable " DRIVER_NAME);
+
 static struct pci_device_id snd_cs5535audio_ids[] = {
-       { PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_CS5535_AUDIO,
-         PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, },
-       { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_AUDIO,
-         PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, },
+       { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_CS5535_AUDIO) },
+       { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_AUDIO) },
        {}
 };
 
@@ -90,7 +110,8 @@ static unsigned short snd_cs5535audio_codec_read(struct cs5535audio *cs5535au,
                udelay(1);
        } while (--timeout);
        if (!timeout)
-               snd_printk(KERN_ERR "Failure reading cs5535 codec\n");
+               snd_printk(KERN_ERR "Failure reading codec reg 0x%x,"
+                                       "Last value=0x%x\n", reg, val);
 
        return (unsigned short) val;
 }
@@ -148,6 +169,8 @@ static int snd_cs5535audio_mixer(struct cs5535audio *cs5535au)
                return err;
        }
 
+       snd_ac97_tune_hardware(cs5535au->ac97, ac97_quirks, ac97_quirk);
+
        return 0;
 }
 
@@ -180,11 +203,9 @@ static void process_bm1_irq(struct cs5535audio *cs5535au)
        }
 }
 
-static irqreturn_t snd_cs5535audio_interrupt(int irq, void *dev_id,
-                                            struct pt_regs *regs)
+static irqreturn_t snd_cs5535audio_interrupt(int irq, void *dev_id)
 {
        u16 acc_irq_stat;
-       u8 bm_stat;
        unsigned char count;
        struct cs5535audio *cs5535au = dev_id;
 
@@ -195,7 +216,7 @@ static irqreturn_t snd_cs5535audio_interrupt(int irq, void *dev_id,
 
        if (!acc_irq_stat)
                return IRQ_NONE;
-       for (count = 0; count < 10; count++) {
+       for (count = 0; count < 4; count++) {
                if (acc_irq_stat & (1 << count)) {
                        switch (count) {
                        case IRQ_STS:
@@ -210,26 +231,9 @@ static irqreturn_t snd_cs5535audio_interrupt(int irq, void *dev_id,
                        case BM1_IRQ_STS:
                                process_bm1_irq(cs5535au);
                                break;
-                       case BM2_IRQ_STS:
-                               bm_stat = cs_readb(cs5535au, ACC_BM2_STATUS);
-                               break;
-                       case BM3_IRQ_STS:
-                               bm_stat = cs_readb(cs5535au, ACC_BM3_STATUS);
-                               break;
-                       case BM4_IRQ_STS:
-                               bm_stat = cs_readb(cs5535au, ACC_BM4_STATUS);
-                               break;
-                       case BM5_IRQ_STS:
-                               bm_stat = cs_readb(cs5535au, ACC_BM5_STATUS);
-                               break;
-                       case BM6_IRQ_STS:
-                               bm_stat = cs_readb(cs5535au, ACC_BM6_STATUS);
-                               break;
-                       case BM7_IRQ_STS:
-                               bm_stat = cs_readb(cs5535au, ACC_BM7_STATUS);
-                               break;
                        default:
-                               snd_printk(KERN_ERR "Unexpected irq src\n");
+                               snd_printk(KERN_ERR "Unexpected irq src: "
+                                               "0x%x\n", acc_irq_stat);
                                break;
                        }
                }
@@ -298,7 +302,7 @@ static int __devinit snd_cs5535audio_create(struct snd_card *card,
        cs5535au->port = pci_resource_start(pci, 0);
 
        if (request_irq(pci->irq, snd_cs5535audio_interrupt,
-                       SA_INTERRUPT|SA_SHIRQ, "CS5535 Audio", cs5535au)) {
+                       IRQF_SHARED, "CS5535 Audio", cs5535au)) {
                snd_printk("unable to grab IRQ %d\n", pci->irq);
                err = -EBUSY;
                goto sndfail;
@@ -347,6 +351,8 @@ static int __devinit snd_cs5535audio_probe(struct pci_dev *pci,
        if ((err = snd_cs5535audio_create(card, pci, &cs5535au)) < 0)
                goto probefail_out;
 
+       card->private_data = cs5535au;
+
        if ((err = snd_cs5535audio_mixer(cs5535au)) < 0)
                goto probefail_out;
 
@@ -383,6 +389,10 @@ static struct pci_driver driver = {
        .id_table = snd_cs5535audio_ids,
        .probe = snd_cs5535audio_probe,
        .remove = __devexit_p(snd_cs5535audio_remove),
+#ifdef CONFIG_PM
+       .suspend = snd_cs5535audio_suspend,
+       .resume = snd_cs5535audio_resume,
+#endif
 };
 
 static int __init alsa_card_cs5535audio_init(void)