x86: cpa: move flush to cpa
[safe/jmp/linux-2.6] / sound / pci / intel8x0.c
index da024ff..4bb9764 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *   ALSA driver for Intel ICH (i8x0) chipsets
  *
- *     Copyright (c) 2000 Jaroslav Kysela <perex@suse.cz>
+ *     Copyright (c) 2000 Jaroslav Kysela <perex@perex.cz>
  *
  *
  *   This code also contains alpha support for SiS 735 chipsets provided
@@ -43,7 +43,7 @@
 #include <asm/pgtable.h>
 #include <asm/cacheflush.h>
 
-MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
+MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
 MODULE_DESCRIPTION("Intel 82801AA,82901AB,i810,i820,i830,i840,i845,MX440; SiS 7012; Ali 5455");
 MODULE_LICENSE("GPL");
 MODULE_SUPPORTED_DEVICE("{{Intel,82801AA-ICH},"
@@ -66,11 +66,12 @@ MODULE_SUPPORTED_DEVICE("{{Intel,82801AA-ICH},"
 
 static int index = SNDRV_DEFAULT_IDX1; /* Index 0-MAX */
 static char *id = SNDRV_DEFAULT_STR1;  /* ID for this card */
-static int ac97_clock = 0;
+static int ac97_clock;
 static char *ac97_quirk;
 static int buggy_semaphore;
 static int buggy_irq = -1; /* auto-check */
 static int xbox;
+static int spdif_aclink = -1;
 
 module_param(index, int, 0444);
 MODULE_PARM_DESC(index, "Index value for Intel i8x0 soundcard.");
@@ -86,6 +87,8 @@ module_param(buggy_irq, bool, 0444);
 MODULE_PARM_DESC(buggy_irq, "Enable workaround for buggy interrupts on some motherboards.");
 module_param(xbox, bool, 0444);
 MODULE_PARM_DESC(xbox, "Set to 1 for Xbox, if you have problems with the AC'97 codec detection.");
+module_param(spdif_aclink, int, 0444);
+MODULE_PARM_DESC(spdif_aclink, "S/PDIF over AC-link.");
 
 /* just for backward compatibility */
 static int enable;
@@ -368,12 +371,8 @@ struct intel8x0 {
 
        int irq;
 
-       unsigned int mmio;
-       unsigned long addr;
-       void __iomem *remap_addr;
-       unsigned int bm_mmio;
-       unsigned long bmaddr;
-       void __iomem *remap_bmaddr;
+       void __iomem *addr;
+       void __iomem *bmaddr;
 
        struct pci_dev *pci;
        struct snd_card *card;
@@ -446,72 +445,48 @@ MODULE_DEVICE_TABLE(pci, snd_intel8x0_ids);
  *  Lowlevel I/O - busmaster
  */
 
-static u8 igetbyte(struct intel8x0 *chip, u32 offset)
+static inline u8 igetbyte(struct intel8x0 *chip, u32 offset)
 {
-       if (chip->bm_mmio)
-               return readb(chip->remap_bmaddr + offset);
-       else
-               return inb(chip->bmaddr + offset);
+       return ioread8(chip->bmaddr + offset);
 }
 
-static u16 igetword(struct intel8x0 *chip, u32 offset)
+static inline u16 igetword(struct intel8x0 *chip, u32 offset)
 {
-       if (chip->bm_mmio)
-               return readw(chip->remap_bmaddr + offset);
-       else
-               return inw(chip->bmaddr + offset);
+       return ioread16(chip->bmaddr + offset);
 }
 
-static u32 igetdword(struct intel8x0 *chip, u32 offset)
+static inline u32 igetdword(struct intel8x0 *chip, u32 offset)
 {
-       if (chip->bm_mmio)
-               return readl(chip->remap_bmaddr + offset);
-       else
-               return inl(chip->bmaddr + offset);
+       return ioread32(chip->bmaddr + offset);
 }
 
-static void iputbyte(struct intel8x0 *chip, u32 offset, u8 val)
+static inline void iputbyte(struct intel8x0 *chip, u32 offset, u8 val)
 {
-       if (chip->bm_mmio)
-               writeb(val, chip->remap_bmaddr + offset);
-       else
-               outb(val, chip->bmaddr + offset);
+       iowrite8(val, chip->bmaddr + offset);
 }
 
-static void iputword(struct intel8x0 *chip, u32 offset, u16 val)
+static inline void iputword(struct intel8x0 *chip, u32 offset, u16 val)
 {
-       if (chip->bm_mmio)
-               writew(val, chip->remap_bmaddr + offset);
-       else
-               outw(val, chip->bmaddr + offset);
+       iowrite16(val, chip->bmaddr + offset);
 }
 
-static void iputdword(struct intel8x0 *chip, u32 offset, u32 val)
+static inline void iputdword(struct intel8x0 *chip, u32 offset, u32 val)
 {
-       if (chip->bm_mmio)
-               writel(val, chip->remap_bmaddr + offset);
-       else
-               outl(val, chip->bmaddr + offset);
+       iowrite32(val, chip->bmaddr + offset);
 }
 
 /*
  *  Lowlevel I/O - AC'97 registers
  */
 
-static u16 iagetword(struct intel8x0 *chip, u32 offset)
+static inline u16 iagetword(struct intel8x0 *chip, u32 offset)
 {
-       if (chip->mmio)
-               return readw(chip->remap_addr + offset);
-       else
-               return inw(chip->addr + offset);
+       return ioread16(chip->addr + offset);
 }
 
-static void iaputword(struct intel8x0 *chip, u32 offset, u16 val)
+static inline void iaputword(struct intel8x0 *chip, u32 offset, u16 val)
 {
-       if (chip->mmio)
-               writew(val, chip->remap_addr + offset);
-       else
-               outw(val, chip->addr + offset);
+       iowrite16(val, chip->addr + offset);
 }
 
 /*
@@ -736,11 +711,13 @@ static void snd_intel8x0_setup_periods(struct intel8x0 *chip, struct ichdev *ich
 static void fill_nocache(void *buf, int size, int nocache)
 {
        size = (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
-       change_page_attr(virt_to_page(buf), size, nocache ? PAGE_KERNEL_NOCACHE : PAGE_KERNEL);
-       global_flush_tlb();
+       if (nocache)
+               set_pages_uc(virt_to_page(buf), size);
+       else
+               set_pages_wb(virt_to_page(buf), size);
 }
 #else
-#define fill_nocache(buf,size,nocache)
+#define fill_nocache(buf, size, nocache) do { ; } while (0)
 #endif
 
 /*
@@ -750,10 +727,11 @@ static void fill_nocache(void *buf, int size, int nocache)
 static inline void snd_intel8x0_update(struct intel8x0 *chip, struct ichdev *ichdev)
 {
        unsigned long port = ichdev->reg_offset;
+       unsigned long flags;
        int status, civ, i, step;
        int ack = 0;
 
-       spin_lock(&chip->reg_lock);
+       spin_lock_irqsave(&chip->reg_lock, flags);
        status = igetbyte(chip, port + ichdev->roff_sr);
        civ = igetbyte(chip, port + ICH_REG_OFF_CIV);
        if (!(status & ICH_BCIS)) {
@@ -793,7 +771,7 @@ static inline void snd_intel8x0_update(struct intel8x0 *chip, struct ichdev *ich
                        ack = 1;
                }
        }
-       spin_unlock(&chip->reg_lock);
+       spin_unlock_irqrestore(&chip->reg_lock, flags);
        if (ack && ichdev->substream) {
                snd_pcm_period_elapsed(ichdev->substream);
        }
@@ -801,7 +779,7 @@ static inline void snd_intel8x0_update(struct intel8x0 *chip, struct ichdev *ich
                 status & (ICH_FIFOE | ICH_BCIS | ICH_LVBCI));
 }
 
-static irqreturn_t snd_intel8x0_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t snd_intel8x0_interrupt(int irq, void *dev_id)
 {
        struct intel8x0 *chip = dev_id;
        struct ichdev *ichdev;
@@ -1293,6 +1271,7 @@ static int snd_intel8x0_ali_ac97spdifout_close(struct snd_pcm_substream *substre
        return 0;
 }
 
+#if 0 // NYI
 static int snd_intel8x0_ali_spdifin_open(struct snd_pcm_substream *substream)
 {
        struct intel8x0 *chip = snd_pcm_substream_chip(substream);
@@ -1308,7 +1287,6 @@ static int snd_intel8x0_ali_spdifin_close(struct snd_pcm_substream *substream)
        return 0;
 }
 
-#if 0 // NYI
 static int snd_intel8x0_ali_spdifout_open(struct snd_pcm_substream *substream)
 {
        struct intel8x0 *chip = snd_pcm_substream_chip(substream);
@@ -1435,6 +1413,7 @@ static struct snd_pcm_ops snd_intel8x0_ali_ac97spdifout_ops = {
        .pointer =      snd_intel8x0_pcm_pointer,
 };
 
+#if 0 // NYI
 static struct snd_pcm_ops snd_intel8x0_ali_spdifin_ops = {
        .open =         snd_intel8x0_ali_spdifin_open,
        .close =        snd_intel8x0_ali_spdifin_close,
@@ -1446,7 +1425,6 @@ static struct snd_pcm_ops snd_intel8x0_ali_spdifin_ops = {
        .pointer =      snd_intel8x0_pcm_pointer,
 };
 
-#if 0 // NYI
 static struct snd_pcm_ops snd_intel8x0_ali_spdifout_ops = {
        .open =         snd_intel8x0_ali_spdifout_open,
        .close =        snd_intel8x0_ali_spdifout_close,
@@ -1582,7 +1560,7 @@ static struct ich_pcm_table ali_pcms[] __devinitdata = {
        {
                .suffix = "IEC958",
                .playback_ops = &snd_intel8x0_ali_ac97spdifout_ops,
-               .capture_ops = &snd_intel8x0_ali_spdifin_ops,
+               /* .capture_ops = &snd_intel8x0_ali_spdifin_ops, */
                .prealloc_size = 64 * 1024,
                .prealloc_max_size = 128 * 1024,
                .ac97_idx = ALID_AC97SPDIFOUT,
@@ -1606,10 +1584,14 @@ static int __devinit snd_intel8x0_pcm(struct intel8x0 *chip)
        case DEVICE_INTEL_ICH4:
                tbl = intel_pcms;
                tblsize = ARRAY_SIZE(intel_pcms);
+               if (spdif_aclink)
+                       tblsize--;
                break;
        case DEVICE_NFORCE:
                tbl = nforce_pcms;
                tblsize = ARRAY_SIZE(nforce_pcms);
+               if (spdif_aclink)
+                       tblsize--;
                break;
        case DEVICE_ALI:
                tbl = ali_pcms;
@@ -1807,12 +1789,30 @@ static struct ac97_quirk ac97_quirks[] __devinitdata = {
        },
        {
                .subvendor = 0x1028,
+               .subdevice = 0x014e,
+               .name = "Dell D800", /* STAC9750/51 */
+               .type = AC97_TUNE_HP_ONLY
+       },
+       {
+               .subvendor = 0x1028,
                .subdevice = 0x0163,
                .name = "Dell Unknown", /* STAC9750/51 */
                .type = AC97_TUNE_HP_ONLY
        },
        {
                .subvendor = 0x1028,
+               .subdevice = 0x0186,
+               .name = "Dell Latitude D810", /* cf. Malone #41015 */
+               .type = AC97_TUNE_HP_MUTE_LED
+       },
+       {
+               .subvendor = 0x1028,
+               .subdevice = 0x0188,
+               .name = "Dell Inspiron 6000",
+               .type = AC97_TUNE_HP_MUTE_LED /* cf. Malone #41015 */
+       },
+       {
+               .subvendor = 0x1028,
                .subdevice = 0x0191,
                .name = "Dell Inspiron 8600",
                .type = AC97_TUNE_HP_ONLY
@@ -1833,7 +1833,7 @@ static struct ac97_quirk ac97_quirks[] __devinitdata = {
                .subvendor = 0x103c,
                .subdevice = 0x088c,
                .name = "HP nc8000",
-               .type = AC97_TUNE_MUTE_LED
+               .type = AC97_TUNE_HP_MUTE_LED
        },
        {
                .subvendor = 0x103c,
@@ -1927,6 +1927,12 @@ static struct ac97_quirk ac97_quirks[] __devinitdata = {
        },
        {
                .subvendor = 0x10cf,
+               .subdevice = 0x127e,
+               .name = "Fujitsu Lifebook C1211D",
+               .type = AC97_TUNE_HP_ONLY
+       },
+       {
+               .subvendor = 0x10cf,
                .subdevice = 0x12ec,
                .name = "Fujitsu-Siemens 4010",
                .type = AC97_TUNE_HP_ONLY
@@ -1950,6 +1956,18 @@ static struct ac97_quirk ac97_quirks[] __devinitdata = {
                .type = AC97_TUNE_HP_ONLY
        },
        {
+               .subvendor = 0x10f1,
+               .subdevice = 0x2895,
+               .name = "Tyan Thunder K8WE",
+               .type = AC97_TUNE_HP_ONLY
+       },
+       {
+               .subvendor = 0x10f7,
+               .subdevice = 0x834c,
+               .name = "Panasonic CF-R4",
+               .type = AC97_TUNE_HP_ONLY,
+       },
+       {
                .subvendor = 0x110a,
                .subdevice = 0x0056,
                .name = "Fujitsu-Siemens Scenic",       /* AD1981? */
@@ -2050,24 +2068,26 @@ static int __devinit snd_intel8x0_mixer(struct intel8x0 *chip, int ac97_clock,
        };
 
        chip->spdif_idx = -1; /* use PCMOUT (or disabled) */
-       switch (chip->device_type) {
-       case DEVICE_NFORCE:
-               chip->spdif_idx = NVD_SPBAR;
-               break;
-       case DEVICE_ALI:
-               chip->spdif_idx = ALID_AC97SPDIFOUT;
-               break;
-       case DEVICE_INTEL_ICH4:
-               chip->spdif_idx = ICHD_SPBAR;
-               break;
-       };
+       if (!spdif_aclink) {
+               switch (chip->device_type) {
+               case DEVICE_NFORCE:
+                       chip->spdif_idx = NVD_SPBAR;
+                       break;
+               case DEVICE_ALI:
+                       chip->spdif_idx = ALID_AC97SPDIFOUT;
+                       break;
+               case DEVICE_INTEL_ICH4:
+                       chip->spdif_idx = ICHD_SPBAR;
+                       break;
+               };
+       }
 
        chip->in_ac97_init = 1;
        
        memset(&ac97, 0, sizeof(ac97));
        ac97.private_data = chip;
        ac97.private_free = snd_intel8x0_mixer_free_ac97;
-       ac97.scaps = AC97_SCAP_SKIP_MODEM;
+       ac97.scaps = AC97_SCAP_SKIP_MODEM | AC97_SCAP_POWER_SAVE;
        if (chip->xbox)
                ac97.scaps |= AC97_SCAP_DETECT_BY_VENDOR;
        if (chip->device_type != DEVICE_ALI) {
@@ -2183,11 +2203,11 @@ static int __devinit snd_intel8x0_mixer(struct intel8x0 *chip, int ac97_clock,
                if ((igetdword(chip, ICHREG(GLOB_STA)) & ICH_SAMPLE_CAP) == ICH_SAMPLE_16_20)
                        chip->smp20bit = 1;
        }
-       if (chip->device_type == DEVICE_NFORCE) {
+       if (chip->device_type == DEVICE_NFORCE && !spdif_aclink) {
                /* 48kHz only */
                chip->ichd[chip->spdif_idx].pcm->rates = SNDRV_PCM_RATE_48000;
        }
-       if (chip->device_type == DEVICE_INTEL_ICH4) {
+       if (chip->device_type == DEVICE_INTEL_ICH4 && !spdif_aclink) {
                /* use slot 10/11 for SPDIF */
                u32 val;
                val = igetdword(chip, ICHREG(GLOB_CNT)) & ~ICH_PCM_SPDIF_MASK;
@@ -2239,6 +2259,16 @@ static int snd_intel8x0_ich_chip_init(struct intel8x0 *chip, int probing)
        /* ACLink on, 2 channels */
        cnt = igetdword(chip, ICHREG(GLOB_CNT));
        cnt &= ~(ICH_ACLINK | ICH_PCM_246_MASK);
+#ifdef CONFIG_SND_AC97_POWER_SAVE
+       /* do cold reset - the full ac97 powerdown may leave the controller
+        * in a warm state but actually it cannot communicate with the codec.
+        */
+       iputdword(chip, ICHREG(GLOB_CNT), cnt & ~ICH_AC97COLD);
+       cnt = igetdword(chip, ICHREG(GLOB_CNT));
+       udelay(10);
+       iputdword(chip, ICHREG(GLOB_CNT), cnt | ICH_AC97COLD);
+       msleep(1);
+#else
        /* finish cold or do warm reset */
        cnt |= (cnt & ICH_AC97COLD) == 0 ? ICH_AC97COLD : ICH_AC97WARM;
        iputdword(chip, ICHREG(GLOB_CNT), cnt);
@@ -2253,6 +2283,7 @@ static int snd_intel8x0_ich_chip_init(struct intel8x0 *chip, int probing)
        return -EIO;
 
       __ok:
+#endif
        if (probing) {
                /* wait for any codec ready status.
                 * Once it becomes ready it should remain ready
@@ -2304,7 +2335,7 @@ static int snd_intel8x0_ich_chip_init(struct intel8x0 *chip, int probing)
                /* unmute the output on SIS7012 */
                iputword(chip, 0x4c, igetword(chip, 0x4c) | 1);
        }
-       if (chip->device_type == DEVICE_NFORCE) {
+       if (chip->device_type == DEVICE_NFORCE && !spdif_aclink) {
                /* enable SPDIF interrupt */
                unsigned int val;
                pci_read_config_dword(chip->pci, 0x4c, &val);
@@ -2351,7 +2382,7 @@ static int snd_intel8x0_ali_chip_init(struct intel8x0 *chip, int probing)
 
 static int snd_intel8x0_chip_init(struct intel8x0 *chip, int probing)
 {
-       unsigned int i;
+       unsigned int i, timeout;
        int err;
        
        if (chip->device_type != DEVICE_ALI) {
@@ -2369,6 +2400,15 @@ static int snd_intel8x0_chip_init(struct intel8x0 *chip, int probing)
        /* reset channels */
        for (i = 0; i < chip->bdbars_count; i++)
                iputbyte(chip, ICH_REG_OFF_CR + chip->ichd[i].reg_offset, ICH_RESETREGS);
+       for (i = 0; i < chip->bdbars_count; i++) {
+               timeout = 100000;
+               while (--timeout != 0) {
+                       if ((igetbyte(chip, ICH_REG_OFF_CR + chip->ichd[i].reg_offset) & ICH_RESETREGS) == 0)
+                               break;
+                }
+                if (timeout == 0)
+                        printk(KERN_ERR "intel8x0: reset of registers failed?\n");
+        }
        /* initialize Buffer Descriptor Lists */
        for (i = 0; i < chip->bdbars_count; i++)
                iputdword(chip, ICH_REG_OFF_BDBAR + chip->ichd[i].reg_offset,
@@ -2388,7 +2428,7 @@ static int snd_intel8x0_free(struct intel8x0 *chip)
        /* reset channels */
        for (i = 0; i < chip->bdbars_count; i++)
                iputbyte(chip, ICH_REG_OFF_CR + chip->ichd[i].reg_offset, ICH_RESETREGS);
-       if (chip->device_type == DEVICE_NFORCE) {
+       if (chip->device_type == DEVICE_NFORCE && !spdif_aclink) {
                /* stop the spdif interrupt */
                unsigned int val;
                pci_read_config_dword(chip->pci, 0x4c, &val);
@@ -2405,10 +2445,10 @@ static int snd_intel8x0_free(struct intel8x0 *chip)
                        fill_nocache(chip->bdbars.area, chip->bdbars.bytes, 0);
                snd_dma_free_pages(&chip->bdbars);
        }
-       if (chip->remap_addr)
-               iounmap(chip->remap_addr);
-       if (chip->remap_bmaddr)
-               iounmap(chip->remap_bmaddr);
+       if (chip->addr)
+               pci_iounmap(chip->pci, chip->addr);
+       if (chip->bmaddr)
+               pci_iounmap(chip->pci, chip->bmaddr);
        pci_release_regions(chip->pci);
        pci_disable_device(chip->pci);
        kfree(chip);
@@ -2444,10 +2484,17 @@ static int intel8x0_suspend(struct pci_dev *pci, pm_message_t state)
        if (chip->device_type == DEVICE_INTEL_ICH4)
                chip->sdm_saved = igetbyte(chip, ICHREG(SDM));
 
-       if (chip->irq >= 0)
+       if (chip->irq >= 0) {
+               synchronize_irq(chip->irq);
                free_irq(chip->irq, chip);
+               chip->irq = -1;
+       }
        pci_disable_device(pci);
        pci_save_state(pci);
+       /* The call below may disable built-in speaker on some laptops
+        * after S2RAM.  So, don't touch it.
+        */
+       /* pci_set_power_state(pci, pci_choose_state(pci, state)); */
        return 0;
 }
 
@@ -2457,17 +2504,28 @@ static int intel8x0_resume(struct pci_dev *pci)
        struct intel8x0 *chip = card->private_data;
        int i;
 
+       pci_set_power_state(pci, PCI_D0);
        pci_restore_state(pci);
-       pci_enable_device(pci);
+       if (pci_enable_device(pci) < 0) {
+               printk(KERN_ERR "intel8x0: pci_enable_device failed, "
+                      "disabling device\n");
+               snd_card_disconnect(card);
+               return -EIO;
+       }
        pci_set_master(pci);
-       request_irq(pci->irq, snd_intel8x0_interrupt, SA_INTERRUPT|SA_SHIRQ,
-                   card->shortname, chip);
+       snd_intel8x0_chip_init(chip, 0);
+       if (request_irq(pci->irq, snd_intel8x0_interrupt,
+                       IRQF_SHARED, card->shortname, chip)) {
+               printk(KERN_ERR "intel8x0: unable to grab IRQ %d, "
+                      "disabling device\n", pci->irq);
+               snd_card_disconnect(card);
+               return -EIO;
+       }
        chip->irq = pci->irq;
        synchronize_irq(chip->irq);
-       snd_intel8x0_chip_init(chip, 1);
 
        /* re-initialize mixer stuff */
-       if (chip->device_type == DEVICE_INTEL_ICH4) {
+       if (chip->device_type == DEVICE_INTEL_ICH4 && !spdif_aclink) {
                /* enable separate SDINs for ICH4 */
                iputbyte(chip, ICHREG(SDM), chip->sdm_saved);
                /* use slot 10/11 for SPDIF */
@@ -2594,6 +2652,7 @@ static void __devinit intel8x0_measure_ac97_clock(struct intel8x0 *chip)
                /* not 48000Hz, tuning the clock.. */
                chip->ac97_bus->clock = (chip->ac97_bus->clock * 48000) / pos;
        printk(KERN_INFO "intel8x0: clocking to %d\n", chip->ac97_bus->clock);
+       snd_ac97_update_power(chip->ac97[0], AC97_PCM_FRONT_DAC_RATE, 0);
 }
 
 #ifdef CONFIG_PROC_FS
@@ -2636,7 +2695,7 @@ static void __devinit snd_intel8x0_proc_init(struct intel8x0 * chip)
        struct snd_info_entry *entry;
 
        if (! snd_card_proc_new(chip->card, "intel8x0", &entry))
-               snd_info_set_text_ops(entry, chip, 1024, snd_intel8x0_proc_read);
+               snd_info_set_text_ops(entry, chip, snd_intel8x0_proc_read);
 }
 #else
 #define snd_intel8x0_proc_init(x)
@@ -2739,35 +2798,27 @@ static int __devinit snd_intel8x0_create(struct snd_card *card,
 
        if (device_type == DEVICE_ALI) {
                /* ALI5455 has no ac97 region */
-               chip->bmaddr = pci_resource_start(pci, 0);
+               chip->bmaddr = pci_iomap(pci, 0, 0);
                goto port_inited;
        }
 
-       if (pci_resource_flags(pci, 2) & IORESOURCE_MEM) {      /* ICH4 and Nforce */
-               chip->mmio = 1;
-               chip->addr = pci_resource_start(pci, 2);
-               chip->remap_addr = ioremap_nocache(chip->addr,
-                                                  pci_resource_len(pci, 2));
-               if (chip->remap_addr == NULL) {
-                       snd_printk(KERN_ERR "AC'97 space ioremap problem\n");
-                       snd_intel8x0_free(chip);
-                       return -EIO;
-               }
-       } else {
-               chip->addr = pci_resource_start(pci, 0);
-       }
-       if (pci_resource_flags(pci, 3) & IORESOURCE_MEM) {      /* ICH4 */
-               chip->bm_mmio = 1;
-               chip->bmaddr = pci_resource_start(pci, 3);
-               chip->remap_bmaddr = ioremap_nocache(chip->bmaddr,
-                                                    pci_resource_len(pci, 3));
-               if (chip->remap_bmaddr == NULL) {
-                       snd_printk(KERN_ERR "Controller space ioremap problem\n");
-                       snd_intel8x0_free(chip);
-                       return -EIO;
-               }
-       } else {
-               chip->bmaddr = pci_resource_start(pci, 1);
+       if (pci_resource_flags(pci, 2) & IORESOURCE_MEM) /* ICH4 and Nforce */
+               chip->addr = pci_iomap(pci, 2, 0);
+       else
+               chip->addr = pci_iomap(pci, 0, 0);
+       if (!chip->addr) {
+               snd_printk(KERN_ERR "AC'97 space ioremap problem\n");
+               snd_intel8x0_free(chip);
+               return -EIO;
+       }
+       if (pci_resource_flags(pci, 3) & IORESOURCE_MEM) /* ICH4 */
+               chip->bmaddr = pci_iomap(pci, 3, 0);
+       else
+               chip->bmaddr = pci_iomap(pci, 1, 0);
+       if (!chip->bmaddr) {
+               snd_printk(KERN_ERR "Controller space ioremap problem\n");
+               snd_intel8x0_free(chip);
+               return -EIO;
        }
 
  port_inited:
@@ -2831,16 +2882,7 @@ static int __devinit snd_intel8x0_create(struct snd_card *card,
                ICH_REG_ALI_INTERRUPTSR : ICH_REG_GLOB_STA;
        chip->int_sta_mask = int_sta_masks;
 
-       /* request irq after initializaing int_sta_mask, etc */
-       if (request_irq(pci->irq, snd_intel8x0_interrupt,
-                       SA_INTERRUPT|SA_SHIRQ, card->shortname, chip)) {
-               snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
-               snd_intel8x0_free(chip);
-               return -EBUSY;
-       }
-       chip->irq = pci->irq;
        pci_set_master(pci);
-       synchronize_irq(chip->irq);
 
        switch(chip->device_type) {
        case DEVICE_INTEL_ICH4:
@@ -2870,6 +2912,15 @@ static int __devinit snd_intel8x0_create(struct snd_card *card,
                return err;
        }
 
+       /* request irq after initializaing int_sta_mask, etc */
+       if (request_irq(pci->irq, snd_intel8x0_interrupt,
+                       IRQF_SHARED, card->shortname, chip)) {
+               snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
+               snd_intel8x0_free(chip);
+               return -EBUSY;
+       }
+       chip->irq = pci->irq;
+
        if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
                snd_intel8x0_free(chip);
                return err;
@@ -2910,6 +2961,29 @@ static struct shortname_table {
        { 0, NULL },
 };
 
+static struct snd_pci_quirk spdif_aclink_defaults[] __devinitdata = {
+       SND_PCI_QUIRK(0x147b, 0x1c1a, "ASUS KN8", 1),
+       { } /* end */
+};
+
+/* look up white/black list for SPDIF over ac-link */
+static int __devinit check_default_spdif_aclink(struct pci_dev *pci)
+{
+       const struct snd_pci_quirk *w;
+
+       w = snd_pci_quirk_lookup(pci, spdif_aclink_defaults);
+       if (w) {
+               if (w->value)
+                       snd_printdd(KERN_INFO "intel8x0: Using SPDIF over "
+                                   "AC-Link for %s\n", w->name);
+               else
+                       snd_printdd(KERN_INFO "intel8x0: Using integrated "
+                                   "SPDIF DMA for %s\n", w->name);
+               return w->value;
+       }
+       return 0;
+}
+
 static int __devinit snd_intel8x0_probe(struct pci_dev *pci,
                                        const struct pci_device_id *pci_id)
 {
@@ -2922,16 +2996,18 @@ static int __devinit snd_intel8x0_probe(struct pci_dev *pci,
        if (card == NULL)
                return -ENOMEM;
 
-       switch (pci_id->driver_data) {
-       case DEVICE_NFORCE:
-               strcpy(card->driver, "NFORCE");
-               break;
-       case DEVICE_INTEL_ICH4:
-               strcpy(card->driver, "ICH4");
-               break;
-       default:
-               strcpy(card->driver, "ICH");
-               break;
+       if (spdif_aclink < 0)
+               spdif_aclink = check_default_spdif_aclink(pci);
+
+       strcpy(card->driver, "ICH");
+       if (!spdif_aclink) {
+               switch (pci_id->driver_data) {
+               case DEVICE_NFORCE:
+                       strcpy(card->driver, "NFORCE");
+                       break;
+               case DEVICE_INTEL_ICH4:
+                       strcpy(card->driver, "ICH4");
+               }
        }
 
        strcpy(card->shortname, "Intel ICH");
@@ -2971,8 +3047,8 @@ static int __devinit snd_intel8x0_probe(struct pci_dev *pci,
        snd_intel8x0_proc_init(chip);
 
        snprintf(card->longname, sizeof(card->longname),
-                "%s with %s at %#lx, irq %i", card->shortname,
-                snd_ac97_get_short_name(chip->ac97[0]), chip->addr, chip->irq);
+                "%s with %s at irq %i", card->shortname,
+                snd_ac97_get_short_name(chip->ac97[0]), chip->irq);
 
        if (! ac97_clock)
                intel8x0_measure_ac97_clock(chip);