vserver 1.9.5.x5
[linux-2.6.git] / sound / pci / intel8x0m.c
index a9b3175..91df930 100644 (file)
 #include <linux/init.h>
 #include <linux/pci.h>
 #include <linux/slab.h>
-#include <linux/gameport.h>
 #include <linux/moduleparam.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/ac97_codec.h>
 #include <sound/info.h>
-#include <sound/mpu401.h>
 #include <sound/initval.h>
 
 MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
@@ -48,22 +46,26 @@ MODULE_SUPPORTED_DEVICE("{{Intel,82801AA-ICH},"
                "{Intel,82801CA-ICH3},"
                "{Intel,82801DB-ICH4},"
                "{Intel,ICH5},"
-               "{Intel,MX440}}");
-
+               "{Intel,MX440},"
+               "{SiS,7013},"
+               "{NVidia,NForce Modem},"
+               "{NVidia,NForce2 Modem},"
+               "{NVidia,NForce2s Modem},"
+               "{NVidia,NForce3 Modem},"
+               "{AMD,AMD768}}");
 
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;     /* Index 0-MAX */
 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 boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for Intel i8x0 modemcard.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for Intel i8x0 modemcard.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable Intel i8x0 modemcard.");
-module_param_array(ac97_clock, int, boot_devs, 0444);
+module_param_array(ac97_clock, int, NULL, 0444);
 MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (0 = auto-detect).");
 
 /*
@@ -233,10 +235,10 @@ struct _snd_intel8x0m {
 
        unsigned int mmio;
        unsigned long addr;
-       unsigned long remap_addr;
+       void __iomem *remap_addr;
        unsigned int bm_mmio;
        unsigned long bmaddr;
-       unsigned long remap_bmaddr;
+       void __iomem *remap_bmaddr;
 
        struct pci_dev *pci;
        snd_card_t *card;
@@ -251,7 +253,6 @@ struct _snd_intel8x0m {
        ac97_t *ac97;
 
        spinlock_t reg_lock;
-       spinlock_t ac97_lock;
        
        struct snd_dma_buffer bdbars;
        u32 bdbars_count;
@@ -409,13 +410,11 @@ static void snd_intel8x0_codec_write(ac97_t *ac97,
 {
        intel8x0_t *chip = ac97->private_data;
        
-       spin_lock(&chip->ac97_lock);
        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);
        }
        iaputword(chip, reg + ac97->num * 0x80, val);
-       spin_unlock(&chip->ac97_lock);
 }
 
 static unsigned short snd_intel8x0_codec_read(ac97_t *ac97,
@@ -425,7 +424,6 @@ static unsigned short snd_intel8x0_codec_read(ac97_t *ac97,
        unsigned short res;
        unsigned int tmp;
 
-       spin_lock(&chip->ac97_lock);
        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);
@@ -440,7 +438,6 @@ static unsigned short snd_intel8x0_codec_read(ac97_t *ac97,
                        res = 0xffff;
                }
        }
-       spin_unlock(&chip->ac97_lock);
        return res;
 }
 
@@ -1066,12 +1063,13 @@ static int snd_intel8x0_free(intel8x0_t *chip)
        if (chip->bdbars.area)
                snd_dma_free_pages(&chip->bdbars);
        if (chip->remap_addr)
-               iounmap((void *) chip->remap_addr);
+               iounmap(chip->remap_addr);
        if (chip->remap_bmaddr)
-               iounmap((void *) chip->remap_bmaddr);
+               iounmap(chip->remap_bmaddr);
        if (chip->irq >= 0)
                free_irq(chip->irq, (void *)chip);
        pci_release_regions(chip->pci);
+       pci_disable_device(chip->pci);
        kfree(chip);
        return 0;
 }
@@ -1089,7 +1087,7 @@ static int intel8x0m_suspend(snd_card_t *card, unsigned int state)
                snd_pcm_suspend_all(chip->pcm[i]);
        if (chip->ac97)
                snd_ac97_suspend(chip->ac97);
-       snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
+       pci_disable_device(chip->pci);
        return 0;
 }
 
@@ -1102,7 +1100,6 @@ static int intel8x0m_resume(snd_card_t *card, unsigned int state)
        if (chip->ac97)
                snd_ac97_resume(chip->ac97);
 
-       snd_power_change_state(card, SNDRV_CTL_POWER_D0);
        return 0;
 }
 #endif /* CONFIG_PM */
@@ -1170,10 +1167,11 @@ static int __devinit snd_intel8x0m_create(snd_card_t * card,
                return err;
 
        chip = kcalloc(1, sizeof(*chip), GFP_KERNEL);
-       if (chip == NULL)
+       if (chip == NULL) {
+               pci_disable_device(pci);
                return -ENOMEM;
+       }
        spin_lock_init(&chip->reg_lock);
-       spin_lock_init(&chip->ac97_lock);
        chip->device_type = device_type;
        chip->card = card;
        chip->pci = pci;
@@ -1181,6 +1179,7 @@ static int __devinit snd_intel8x0m_create(snd_card_t * card,
 
        if ((err = pci_request_regions(pci, card->shortname)) < 0) {
                kfree(chip);
+               pci_disable_device(pci);
                return err;
        }
 
@@ -1193,9 +1192,9 @@ static int __devinit snd_intel8x0m_create(snd_card_t * card,
        if (pci_resource_flags(pci, 2) & IORESOURCE_MEM) {      /* ICH4 and Nforce */
                chip->mmio = 1;
                chip->addr = pci_resource_start(pci, 2);
-               chip->remap_addr = (unsigned long) ioremap_nocache(chip->addr,
-                                                                  pci_resource_len(pci, 2));
-               if (chip->remap_addr == 0) {
+               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_intel8x0_free(chip);
                        return -EIO;
@@ -1206,9 +1205,9 @@ static int __devinit snd_intel8x0m_create(snd_card_t * card,
        if (pci_resource_flags(pci, 3) & IORESOURCE_MEM) {      /* ICH4 */
                chip->bm_mmio = 1;
                chip->bmaddr = pci_resource_start(pci, 3);
-               chip->remap_bmaddr = (unsigned long) ioremap_nocache(chip->bmaddr,
-                                                                    pci_resource_len(pci, 3));
-               if (chip->remap_bmaddr == 0) {
+               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_intel8x0_free(chip);
                        return -EIO;
@@ -1332,15 +1331,7 @@ static int __devinit snd_intel8x0m_probe(struct pci_dev *pci,
        if (card == NULL)
                return -ENOMEM;
 
-       switch (pci_id->driver_data) {
-       case DEVICE_NFORCE:
-               strcpy(card->driver, "NFORCE-MODEM");
-               break;
-       default:
-               strcpy(card->driver, "ICH-MODEM");
-               break;
-       }
-
+       strcpy(card->driver, "ICH-MODEM");
        strcpy(card->shortname, "Intel ICH");
        for (name = shortnames; name->id; name++) {
                if (pci->device == name->id) {