]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - sound/pci/intel8x0m.c
[ALSA] Remove xxx_t typedefs: PCI AD1889
[linux-2.6-omap-h63xx.git] / sound / pci / intel8x0m.c
index bb758c77d211067ab49979f0fb962f7db654ae2c..3244df9c1e92bd4e0ba0690314b0094d9fd8c7b8 100644 (file)
@@ -3,7 +3,7 @@
  *
  *     Copyright (c) 2000 Jaroslav Kysela <perex@suse.cz>
  *
- *   This is modified (by Sasha Khapyorsky <sashak@smlink.com>) version
+ *   This is modified (by Sasha Khapyorsky <sashak@alsa-project.org>) version
  *   of ALSA ICH sound driver intel8x0.c .
  *
  *
@@ -56,68 +56,24 @@ MODULE_SUPPORTED_DEVICE("{{Intel,82801AA-ICH},"
                "{NVidia,NForce3 Modem},"
                "{AMD,AMD768}}");
 
-static int index[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = -2}; /* Exclude the first card */
-static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;      /* ID for this card */
-static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;     /* Enable this card */
-static int ac97_clock[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0};
+static int index = -2; /* Exclude the first card */
+static char *id = SNDRV_DEFAULT_STR1;  /* ID for this card */
+static int ac97_clock = 0;
 
-module_param_array(index, int, NULL, 0444);
+module_param(index, int, 0444);
 MODULE_PARM_DESC(index, "Index value for Intel i8x0 modemcard.");
-module_param_array(id, charp, NULL, 0444);
+module_param(id, charp, 0444);
 MODULE_PARM_DESC(id, "ID string for Intel i8x0 modemcard.");
-module_param_array(enable, bool, NULL, 0444);
-MODULE_PARM_DESC(enable, "Enable Intel i8x0 modemcard.");
-module_param_array(ac97_clock, int, NULL, 0444);
+module_param(ac97_clock, int, 0444);
 MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (0 = auto-detect).");
 
+/* just for backward compatibility */
+static int enable;
+module_param(enable, bool, 0444);
+
 /*
  *  Direct registers
  */
-
-#ifndef PCI_DEVICE_ID_INTEL_82801_6
-#define PCI_DEVICE_ID_INTEL_82801_6     0x2416
-#endif
-#ifndef PCI_DEVICE_ID_INTEL_82901_6
-#define PCI_DEVICE_ID_INTEL_82901_6     0x2426
-#endif
-#ifndef PCI_DEVICE_ID_INTEL_82801BA_6
-#define PCI_DEVICE_ID_INTEL_82801BA_6   0x2446
-#endif
-#ifndef PCI_DEVICE_ID_INTEL_440MX_6
-#define PCI_DEVICE_ID_INTEL_440MX_6     0x7196
-#endif
-#ifndef PCI_DEVICE_ID_INTEL_ICH3_6
-#define PCI_DEVICE_ID_INTEL_ICH3_6     0x2486
-#endif
-#ifndef PCI_DEVICE_ID_INTEL_ICH4_6
-#define PCI_DEVICE_ID_INTEL_ICH4_6     0x24c6
-#endif
-#ifndef PCI_DEVICE_ID_INTEL_ICH5_6
-#define PCI_DEVICE_ID_INTEL_ICH5_6     0x24d6
-#endif
-#ifndef PCI_DEVICE_ID_INTEL_ICH6_6
-#define PCI_DEVICE_ID_INTEL_ICH6_6     0x266d
-#endif
-#ifndef PCI_DEVICE_ID_INTEL_ICH7_6
-#define PCI_DEVICE_ID_INTEL_ICH7_6     0x27dd
-#endif
-#ifndef PCI_DEVICE_ID_SI_7013
-#define PCI_DEVICE_ID_SI_7013          0x7013
-#endif
-#ifndef PCI_DEVICE_ID_NVIDIA_MCP_MODEM
-#define PCI_DEVICE_ID_NVIDIA_MCP_MODEM 0x01c1
-#endif
-#ifndef PCI_DEVICE_ID_NVIDIA_MCP2_MODEM
-#define PCI_DEVICE_ID_NVIDIA_MCP2_MODEM        0x0069
-#endif
-#ifndef PCI_DEVICE_ID_NVIDIA_MCP2S_MODEM
-#define PCI_DEVICE_ID_NVIDIA_MCP2S_MODEM 0x0089
-#endif
-#ifndef PCI_DEVICE_ID_NVIDIA_MCP3_MODEM
-#define PCI_DEVICE_ID_NVIDIA_MCP3_MODEM        0x00d9
-#endif
-
-
 enum { DEVICE_INTEL, DEVICE_SIS, DEVICE_ALI, DEVICE_NFORCE };
 
 #define ICHREG(x) ICH_REG_##x
@@ -407,7 +363,7 @@ static int snd_intel8x0m_codec_semaphore(intel8x0_t *chip, unsigned int codec)
        /* access to some forbidden (non existant) ac97 registers will not
         * reset the semaphore. So even if you don't get the semaphore, still
         * continue the access. We don't need the semaphore anyway. */
-       snd_printk("codec_semaphore: semaphore is not ready [0x%x][0x%x]\n",
+       snd_printk(KERN_ERR "codec_semaphore: semaphore is not ready [0x%x][0x%x]\n",
                        igetbyte(chip, ICHREG(ACC_SEMA)), igetdword(chip, ICHREG(GLOB_STA)));
        iagetword(chip, 0);     /* clear semaphore flag */
        /* I don't care about the semaphore */
@@ -422,7 +378,7 @@ static void snd_intel8x0_codec_write(ac97_t *ac97,
        
        if (snd_intel8x0m_codec_semaphore(chip, ac97->num) < 0) {
                if (! chip->in_ac97_init)
-                       snd_printk("codec_write %d: semaphore is not ready for register 0x%x\n", ac97->num, reg);
+                       snd_printk(KERN_ERR "codec_write %d: semaphore is not ready for register 0x%x\n", ac97->num, reg);
        }
        iaputword(chip, reg + ac97->num * 0x80, val);
 }
@@ -436,7 +392,7 @@ static unsigned short snd_intel8x0_codec_read(ac97_t *ac97,
 
        if (snd_intel8x0m_codec_semaphore(chip, ac97->num) < 0) {
                if (! chip->in_ac97_init)
-                       snd_printk("codec_read %d: semaphore is not ready for register 0x%x\n", ac97->num, reg);
+                       snd_printk(KERN_ERR "codec_read %d: semaphore is not ready for register 0x%x\n", ac97->num, reg);
                res = 0xffff;
        } else {
                res = iagetword(chip, reg + ac97->num * 0x80);
@@ -444,7 +400,7 @@ static unsigned short snd_intel8x0_codec_read(ac97_t *ac97,
                        /* reset RCS and preserve other R/WC bits */
                        iputdword(chip, ICHREG(GLOB_STA), tmp & ~(ICH_SRI|ICH_PRI|ICH_TRI|ICH_GSCI));
                        if (! chip->in_ac97_init)
-                               snd_printk("codec_read %d: read timeout for register 0x%x\n", ac97->num, reg);
+                               snd_printk(KERN_ERR "codec_read %d: read timeout for register 0x%x\n", ac97->num, reg);
                        res = 0xffff;
                }
        }
@@ -791,6 +747,7 @@ static int __devinit snd_intel8x0_pcm1(intel8x0_t *chip, int device, struct ich_
 
        pcm->private_data = chip;
        pcm->info_flags = 0;
+       pcm->dev_class = SNDRV_PCM_CLASS_MODEM;
        if (rec->suffix)
                sprintf(pcm->name, "%s - %s", chip->card->shortname, rec->suffix);
        else
@@ -899,7 +856,6 @@ static int __devinit snd_intel8x0_mixer(intel8x0_t *chip, int ac97_clock)
        if ((err = snd_ac97_bus(chip->card, 0, &ops, chip, &pbus)) < 0)
                goto __err;
        pbus->private_free = snd_intel8x0_mixer_free_ac97_bus;
-       pbus->shared_type = AC97_SHARED_TYPE_ICH;       /* shared with audio driver */
        if (ac97_clock >= 8000 && ac97_clock <= 48000)
                pbus->clock = ac97_clock;
        chip->ac97_bus = pbus;
@@ -933,11 +889,6 @@ static int __devinit snd_intel8x0_mixer(intel8x0_t *chip, int ac97_clock)
  *
  */
 
-#define do_delay(chip) do {\
-       set_current_state(TASK_UNINTERRUPTIBLE);\
-       schedule_timeout(1);\
-} while (0)
-
 static int snd_intel8x0m_ich_chip_init(intel8x0_t *chip, int probing)
 {
        unsigned long end_time;
@@ -959,9 +910,9 @@ static int snd_intel8x0m_ich_chip_init(intel8x0_t *chip, int probing)
        do {
                if ((igetdword(chip, ICHREG(GLOB_CNT)) & ICH_AC97WARM) == 0)
                        goto __ok;
-               do_delay(chip);
+               schedule_timeout_uninterruptible(1);
        } while (time_after_eq(end_time, jiffies));
-       snd_printk("AC'97 warm reset still in progress? [0x%x]\n", igetdword(chip, ICHREG(GLOB_CNT)));
+       snd_printk(KERN_ERR "AC'97 warm reset still in progress? [0x%x]\n", igetdword(chip, ICHREG(GLOB_CNT)));
        return -EIO;
 
       __ok:
@@ -975,7 +926,7 @@ static int snd_intel8x0m_ich_chip_init(intel8x0_t *chip, int probing)
                        status = igetdword(chip, ICHREG(GLOB_STA)) & (ICH_PCR | ICH_SCR | ICH_TCR);
                        if (status)
                                break;
-                       do_delay(chip);
+                       schedule_timeout_uninterruptible(1);
                } while (time_after_eq(end_time, jiffies));
                if (! status) {
                        /* no codec is found */
@@ -989,7 +940,7 @@ static int snd_intel8x0m_ich_chip_init(intel8x0_t *chip, int probing)
                /* wait for other codecs ready status. */
                end_time = jiffies + HZ / 4;
                while (status != nstatus && time_after_eq(end_time, jiffies)) {
-                       do_delay(chip);
+                       schedule_timeout_uninterruptible(1);
                        status |= igetdword(chip, ICHREG(GLOB_STA)) & nstatus;
                }
 
@@ -1004,7 +955,7 @@ static int snd_intel8x0m_ich_chip_init(intel8x0_t *chip, int probing)
                        nstatus = igetdword(chip, ICHREG(GLOB_STA)) & (ICH_PCR | ICH_SCR | ICH_TCR);
                        if (status == nstatus)
                                break;
-                       do_delay(chip);
+                       schedule_timeout_uninterruptible(1);
                } while (time_after_eq(end_time, jiffies));
        }
 
@@ -1158,7 +1109,7 @@ static int __devinit snd_intel8x0m_create(snd_card_t * card,
        if ((err = pci_enable_device(pci)) < 0)
                return err;
 
-       chip = kcalloc(1, sizeof(*chip), GFP_KERNEL);
+       chip = kzalloc(sizeof(*chip), GFP_KERNEL);
        if (chip == NULL) {
                pci_disable_device(pci);
                return -ENOMEM;
@@ -1187,7 +1138,7 @@ static int __devinit snd_intel8x0m_create(snd_card_t * card,
                chip->remap_addr = ioremap_nocache(chip->addr,
                                                   pci_resource_len(pci, 2));
                if (chip->remap_addr == NULL) {
-                       snd_printk("AC'97 space ioremap problem\n");
+                       snd_printk(KERN_ERR "AC'97 space ioremap problem\n");
                        snd_intel8x0_free(chip);
                        return -EIO;
                }
@@ -1200,7 +1151,7 @@ static int __devinit snd_intel8x0m_create(snd_card_t * card,
                chip->remap_bmaddr = ioremap_nocache(chip->bmaddr,
                                                     pci_resource_len(pci, 3));
                if (chip->remap_bmaddr == NULL) {
-                       snd_printk("Controller space ioremap problem\n");
+                       snd_printk(KERN_ERR "Controller space ioremap problem\n");
                        snd_intel8x0_free(chip);
                        return -EIO;
                }
@@ -1210,7 +1161,7 @@ static int __devinit snd_intel8x0m_create(snd_card_t * card,
 
  port_inited:
        if (request_irq(pci->irq, snd_intel8x0_interrupt, SA_INTERRUPT|SA_SHIRQ, card->shortname, (void *)chip)) {
-               snd_printk("unable to grab IRQ %d\n", pci->irq);
+               snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
                snd_intel8x0_free(chip);
                return -EBUSY;
        }
@@ -1283,18 +1234,18 @@ static struct shortname_table {
        unsigned int id;
        const char *s;
 } shortnames[] __devinitdata = {
-       { PCI_DEVICE_ID_INTEL_82801_6, "Intel 82801AA-ICH" },
-       { PCI_DEVICE_ID_INTEL_82901_6, "Intel 82901AB-ICH0" },
+       { PCI_DEVICE_ID_INTEL_82801AA_6, "Intel 82801AA-ICH" },
+       { PCI_DEVICE_ID_INTEL_82801AB_6, "Intel 82901AB-ICH0" },
        { PCI_DEVICE_ID_INTEL_82801BA_6, "Intel 82801BA-ICH2" },
        { PCI_DEVICE_ID_INTEL_440MX_6, "Intel 440MX" },
-       { PCI_DEVICE_ID_INTEL_ICH3_6, "Intel 82801CA-ICH3" },
-       { PCI_DEVICE_ID_INTEL_ICH4_6, "Intel 82801DB-ICH4" },
-       { PCI_DEVICE_ID_INTEL_ICH5_6, "Intel ICH5" },
-       { PCI_DEVICE_ID_INTEL_ICH6_6, "Intel ICH6" },
-       { PCI_DEVICE_ID_INTEL_ICH7_6, "Intel ICH7" },
+       { PCI_DEVICE_ID_INTEL_82801CA_6, "Intel 82801CA-ICH3" },
+       { PCI_DEVICE_ID_INTEL_82801DB_6, "Intel 82801DB-ICH4" },
+       { PCI_DEVICE_ID_INTEL_82801EB_6, "Intel ICH5" },
+       { PCI_DEVICE_ID_INTEL_ICH6_17, "Intel ICH6" },
+       { PCI_DEVICE_ID_INTEL_ICH7_19, "Intel ICH7" },
        { 0x7446, "AMD AMD768" },
        { PCI_DEVICE_ID_SI_7013, "SiS SI7013" },
-       { PCI_DEVICE_ID_NVIDIA_MCP_MODEM, "NVidia nForce" },
+       { PCI_DEVICE_ID_NVIDIA_MCP1_MODEM, "NVidia nForce" },
        { PCI_DEVICE_ID_NVIDIA_MCP2_MODEM, "NVidia nForce2" },
        { PCI_DEVICE_ID_NVIDIA_MCP2S_MODEM, "NVidia nForce2s" },
        { PCI_DEVICE_ID_NVIDIA_MCP3_MODEM, "NVidia nForce3" },
@@ -1308,20 +1259,12 @@ static struct shortname_table {
 static int __devinit snd_intel8x0m_probe(struct pci_dev *pci,
                                        const struct pci_device_id *pci_id)
 {
-       static int dev;
        snd_card_t *card;
        intel8x0_t *chip;
        int err;
        struct shortname_table *name;
 
-       if (dev >= SNDRV_CARDS)
-               return -ENODEV;
-       if (!enable[dev]) {
-               dev++;
-               return -ENOENT;
-       }
-
-       card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0);
+       card = snd_card_new(index, id, THIS_MODULE, 0);
        if (card == NULL)
                return -ENOMEM;
 
@@ -1340,7 +1283,7 @@ static int __devinit snd_intel8x0m_probe(struct pci_dev *pci,
                return err;
        }
 
-       if ((err = snd_intel8x0_mixer(chip, ac97_clock[dev])) < 0) {
+       if ((err = snd_intel8x0_mixer(chip, ac97_clock)) < 0) {
                snd_card_free(card);
                return err;
        }
@@ -1359,7 +1302,6 @@ static int __devinit snd_intel8x0m_probe(struct pci_dev *pci,
                return err;
        }
        pci_set_drvdata(pci, card);
-       dev++;
        return 0;
 }