]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - sound/isa/es1688/es1688.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6
[linux-2.6-omap-h63xx.git] / sound / isa / es1688 / es1688.c
index f7d0c5fab5d956493a957d27c311a130ba7e0700..b46377139cf81d4ffc73d1e10572f6996c5ad4c3 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Driver for generic ESS AudioDrive ESx688 soundcards
- *  Copyright (c) by Jaroslav Kysela <perex@suse.cz>
+ *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
  *
  *
  *   This program is free software; you can redistribute it and/or modify
@@ -19,7 +19,6 @@
  *
  */
 
-#include <sound/driver.h>
 #include <linux/init.h>
 #include <linux/err.h>
 #include <linux/isa.h>
@@ -39,7 +38,7 @@
 #define DEV_NAME "es1688"
 
 MODULE_DESCRIPTION(CRD_NAME);
-MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
+MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
 MODULE_LICENSE("GPL");
 MODULE_SUPPORTED_DEVICE("{{ESS,ES688 PnP AudioDrive,pnp:ESS0100},"
                "{ESS,ES1688 PnP AudioDrive,pnp:ESS0102},"
@@ -77,13 +76,46 @@ static int __devinit snd_es1688_match(struct device *dev, unsigned int n)
        return enable[n];
 }
 
-static int __devinit snd_es1688_probe(struct device *dev, unsigned int n)
+static int __devinit snd_es1688_legacy_create(struct snd_card *card, 
+               struct device *dev, unsigned int n, struct snd_es1688 **rchip)
 {
-       static unsigned long possible_ports[] = {0x220, 0x240, 0x260};
+       static long possible_ports[] = {0x220, 0x240, 0x260};
        static int possible_irqs[] = {5, 9, 10, 7, -1};
        static int possible_dmas[] = {1, 3, 0, -1};
-       int i, xirq, xdma;
 
+       int i, error;
+
+       if (irq[n] == SNDRV_AUTO_IRQ) {
+               irq[n] = snd_legacy_find_free_irq(possible_irqs);
+               if (irq[n] < 0) {
+                       dev_err(dev, "unable to find a free IRQ\n");
+                       return -EBUSY;
+               }
+       }
+       if (dma8[n] == SNDRV_AUTO_DMA) {
+               dma8[n] = snd_legacy_find_free_dma(possible_dmas);
+               if (dma8[n] < 0) {
+                       dev_err(dev, "unable to find a free DMA\n");
+                       return -EBUSY;
+               }
+       }
+
+       if (port[n] != SNDRV_AUTO_PORT)
+               return snd_es1688_create(card, port[n], mpu_port[n], irq[n],
+                               mpu_irq[n], dma8[n], ES1688_HW_AUTO, rchip);
+
+       i = 0;
+       do {
+               port[n] = possible_ports[i];
+               error = snd_es1688_create(card, port[n], mpu_port[n], irq[n],
+                               mpu_irq[n], dma8[n], ES1688_HW_AUTO, rchip);
+       } while (error < 0 && ++i < ARRAY_SIZE(possible_ports));
+
+       return error;
+}
+
+static int __devinit snd_es1688_probe(struct device *dev, unsigned int n)
+{
        struct snd_card *card;
        struct snd_es1688 *chip;
        struct snd_opl3 *opl3;
@@ -94,33 +126,7 @@ static int __devinit snd_es1688_probe(struct device *dev, unsigned int n)
        if (!card)
                return -EINVAL;
 
-       error = -EBUSY;
-
-       xirq = irq[n];
-       if (xirq == SNDRV_AUTO_IRQ) {
-               xirq = snd_legacy_find_free_irq(possible_irqs);
-               if (xirq < 0) {
-                       snd_printk(KERN_ERR "%s: unable to find a free IRQ\n", dev->bus_id);
-                       goto out;
-               }
-       }
-
-       xdma = dma8[n];
-       if (xdma == SNDRV_AUTO_DMA) {
-               xdma = snd_legacy_find_free_dma(possible_dmas);
-               if (xdma < 0) {
-                       snd_printk(KERN_ERR "%s: unable to find a free DMA\n", dev->bus_id);
-                       goto out;
-               }
-       }
-
-       if (port[n] == SNDRV_AUTO_PORT)
-               for (i = 0; i < ARRAY_SIZE(possible_ports) && error < 0; i++)
-                       error = snd_es1688_create(card, possible_ports[i], mpu_port[n],
-                                       xirq, mpu_irq[n], xdma, ES1688_HW_AUTO, &chip);
-       else
-               error = snd_es1688_create(card, port[n], mpu_port[n],
-                               xirq, mpu_irq[n], xdma, ES1688_HW_AUTO, &chip);
+       error = snd_es1688_legacy_create(card, dev, n, &chip);
        if (error < 0)
                goto out;
 
@@ -134,19 +140,23 @@ static int __devinit snd_es1688_probe(struct device *dev, unsigned int n)
 
        strcpy(card->driver, "ES1688");
        strcpy(card->shortname, pcm->name);
-       sprintf(card->longname, "%s at 0x%lx, irq %i, dma %i", pcm->name, chip->port, xirq, xdma);
+       sprintf(card->longname, "%s at 0x%lx, irq %i, dma %i", pcm->name,
+               chip->port, chip->irq, chip->dma8);
 
-       if (snd_opl3_create(card, chip->port, chip->port + 2, OPL3_HW_OPL3, 0, &opl3) < 0)
-               printk(KERN_WARNING "%s: opl3 not detected at 0x%lx\n", dev->bus_id, chip->port);
+       if (snd_opl3_create(card, chip->port, chip->port + 2,
+                       OPL3_HW_OPL3, 0, &opl3) < 0)
+               dev_warn(dev, "opl3 not detected at 0x%lx\n", chip->port);
        else {
                error = snd_opl3_hwdep_new(opl3, 0, 1, NULL);
                if (error < 0)
                        goto out;
        }
 
-       if (mpu_irq[n] >= 0 && mpu_irq[n] != SNDRV_AUTO_IRQ && chip->mpu_port > 0) {
-               error = snd_mpu401_uart_new(card, 0, MPU401_HW_ES1688, chip->mpu_port,
-                               0, mpu_irq[n], IRQF_DISABLED, NULL);
+       if (mpu_irq[n] >= 0 && mpu_irq[n] != SNDRV_AUTO_IRQ &&
+                       chip->mpu_port > 0) {
+               error = snd_mpu401_uart_new(card, 0, MPU401_HW_ES1688,
+                               chip->mpu_port, 0,
+                               mpu_irq[n], IRQF_DISABLED, NULL);
                if (error < 0)
                        goto out;
        }