sound: use DEFINE_PCI_DEVICE_TABLE
[safe/jmp/linux-2.6] / sound / pci / intel8x0m.c
index 314f3d8..13cec1e 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *   ALSA modem driver for Intel ICH (i8x0) chipsets
  *
- *     Copyright (c) 2000 Jaroslav Kysela <perex@suse.cz>
+ *     Copyright (c) 2000 Jaroslav Kysela <perex@perex.cz>
  *
  *   This is modified (by Sasha Khapyorsky <sashak@alsa-project.org>) version
  *   of ALSA ICH sound driver intel8x0.c .
@@ -23,7 +23,6 @@
  *
  */      
 
-#include <sound/driver.h>
 #include <asm/io.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
@@ -37,8 +36,9 @@
 #include <sound/info.h>
 #include <sound/initval.h>
 
-MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
-MODULE_DESCRIPTION("Intel 82801AA,82901AB,i810,i820,i830,i840,i845,MX440; SiS 7013; NVidia MCP/2/2S/3 modems");
+MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
+MODULE_DESCRIPTION("Intel 82801AA,82901AB,i810,i820,i830,i840,i845,MX440; "
+                  "SiS 7013; NVidia MCP/2/2S/3 modems");
 MODULE_LICENSE("GPL");
 MODULE_SUPPORTED_DEVICE("{{Intel,82801AA-ICH},"
                "{Intel,82901AB-ICH0},"
@@ -58,7 +58,7 @@ MODULE_SUPPORTED_DEVICE("{{Intel,82801AA-ICH},"
 
 static int index = -2; /* Exclude the first card */
 static char *id = SNDRV_DEFAULT_STR1;  /* ID for this card */
-static int ac97_clock = 0;
+static int ac97_clock;
 
 module_param(index, int, 0444);
 MODULE_PARM_DESC(index, "Index value for Intel i8x0 modemcard.");
@@ -69,7 +69,7 @@ MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (0 = auto-detect).");
 
 /* just for backward compatibility */
 static int enable;
-module_param(enable, int, 0444);
+module_param(enable, bool, 0444);
 
 /*
  *  Direct registers
@@ -163,14 +163,14 @@ DEFINE_REGSET(OFF, 0);            /* offset */
 enum { ICHD_MDMIN, ICHD_MDMOUT, ICHD_MDMLAST = ICHD_MDMOUT };
 enum { ALID_MDMIN, ALID_MDMOUT, ALID_MDMLAST = ALID_MDMOUT };
 
-#define get_ichdev(substream) (ichdev_t *)(substream->runtime->private_data)
+#define get_ichdev(substream) (substream->runtime->private_data)
 
-typedef struct {
+struct ichdev {
        unsigned int ichd;                      /* ich device number */
        unsigned long reg_offset;               /* offset to bmaddr */
        u32 *bdbar;                             /* CPU address (32bit) */
        unsigned int bdbar_addr;                /* PCI bus address (32bit) */
-       snd_pcm_substream_t *substream;
+       struct snd_pcm_substream *substream;
        unsigned int physbuf;                   /* physical address (32bit) */
         unsigned int size;
         unsigned int fragsize;
@@ -187,34 +187,28 @@ typedef struct {
        unsigned int roff_picb;
        unsigned int int_sta_mask;              /* interrupt status mask */
        unsigned int ali_slot;                  /* ALI DMA slot */
-       ac97_t *ac97;
-} ichdev_t;
-
-typedef struct _snd_intel8x0m intel8x0_t;
+       struct snd_ac97 *ac97;
+};
 
-struct _snd_intel8x0m {
+struct intel8x0m {
        unsigned int device_type;
 
        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;
-       snd_card_t *card;
+       struct snd_card *card;
 
        int pcm_devs;
-       snd_pcm_t *pcm[2];
-       ichdev_t ichd[2];
+       struct snd_pcm *pcm[2];
+       struct ichdev ichd[2];
 
        unsigned int in_ac97_init: 1;
 
-       ac97_bus_t *ac97_bus;
-       ac97_t *ac97;
+       struct snd_ac97_bus *ac97_bus;
+       struct snd_ac97 *ac97;
 
        spinlock_t reg_lock;
        
@@ -225,25 +219,25 @@ struct _snd_intel8x0m {
        unsigned int pcm_pos_shift;
 };
 
-static struct pci_device_id snd_intel8x0m_ids[] = {
-       { 0x8086, 0x2416, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL }, /* 82801AA */
-       { 0x8086, 0x2426, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL }, /* 82901AB */
-       { 0x8086, 0x2446, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL }, /* 82801BA */
-       { 0x8086, 0x2486, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL }, /* ICH3 */
-       { 0x8086, 0x24c6, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL }, /* ICH4 */
-       { 0x8086, 0x24d6, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL }, /* ICH5 */
-       { 0x8086, 0x266d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL }, /* ICH6 */
-       { 0x8086, 0x27dd, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL }, /* ICH7 */
-       { 0x8086, 0x7196, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL }, /* 440MX */
-       { 0x1022, 0x7446, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL }, /* AMD768 */
-       { 0x1039, 0x7013, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_SIS },   /* SI7013 */
-       { 0x10de, 0x01c1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_NFORCE }, /* NFORCE */
-       { 0x10de, 0x0069, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_NFORCE }, /* NFORCE2 */
-       { 0x10de, 0x0089, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_NFORCE }, /* NFORCE2s */
-       { 0x10de, 0x00d9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_NFORCE }, /* NFORCE3 */
+static DEFINE_PCI_DEVICE_TABLE(snd_intel8x0m_ids) = {
+       { PCI_VDEVICE(INTEL, 0x2416), DEVICE_INTEL },   /* 82801AA */
+       { PCI_VDEVICE(INTEL, 0x2426), DEVICE_INTEL },   /* 82901AB */
+       { PCI_VDEVICE(INTEL, 0x2446), DEVICE_INTEL },   /* 82801BA */
+       { PCI_VDEVICE(INTEL, 0x2486), DEVICE_INTEL },   /* ICH3 */
+       { PCI_VDEVICE(INTEL, 0x24c6), DEVICE_INTEL }, /* ICH4 */
+       { PCI_VDEVICE(INTEL, 0x24d6), DEVICE_INTEL }, /* ICH5 */
+       { PCI_VDEVICE(INTEL, 0x266d), DEVICE_INTEL },   /* ICH6 */
+       { PCI_VDEVICE(INTEL, 0x27dd), DEVICE_INTEL },   /* ICH7 */
+       { PCI_VDEVICE(INTEL, 0x7196), DEVICE_INTEL },   /* 440MX */
+       { PCI_VDEVICE(AMD, 0x7446), DEVICE_INTEL },     /* AMD768 */
+       { PCI_VDEVICE(SI, 0x7013), DEVICE_SIS },        /* SI7013 */
+       { PCI_VDEVICE(NVIDIA, 0x01c1), DEVICE_NFORCE }, /* NFORCE */
+       { PCI_VDEVICE(NVIDIA, 0x0069), DEVICE_NFORCE }, /* NFORCE2 */
+       { PCI_VDEVICE(NVIDIA, 0x0089), DEVICE_NFORCE }, /* NFORCE2s */
+       { PCI_VDEVICE(NVIDIA, 0x00d9), DEVICE_NFORCE }, /* NFORCE3 */
 #if 0
-       { 0x1022, 0x746d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL }, /* AMD8111 */
-       { 0x10b9, 0x5455, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_ALI },   /* Ali5455 */
+       { PCI_VDEVICE(AMD, 0x746d), DEVICE_INTEL },     /* AMD8111 */
+       { PCI_VDEVICE(AL, 0x5455), DEVICE_ALI },   /* Ali5455 */
 #endif
        { 0, }
 };
@@ -254,72 +248,48 @@ MODULE_DEVICE_TABLE(pci, snd_intel8x0m_ids);
  *  Lowlevel I/O - busmaster
  */
 
-static u8 igetbyte(intel8x0_t *chip, u32 offset)
+static inline u8 igetbyte(struct intel8x0m *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(intel8x0_t *chip, u32 offset)
+static inline u16 igetword(struct intel8x0m *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(intel8x0_t *chip, u32 offset)
+static inline u32 igetdword(struct intel8x0m *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(intel8x0_t *chip, u32 offset, u8 val)
+static inline void iputbyte(struct intel8x0m *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(intel8x0_t *chip, u32 offset, u16 val)
+static inline void iputword(struct intel8x0m *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(intel8x0_t *chip, u32 offset, u32 val)
+static inline void iputdword(struct intel8x0m *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(intel8x0_t *chip, u32 offset)
+static inline u16 iagetword(struct intel8x0m *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(intel8x0_t *chip, u32 offset, u16 val)
+static inline void iaputword(struct intel8x0m *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);
 }
 
 /*
@@ -331,16 +301,17 @@ static void iaputword(intel8x0_t *chip, u32 offset, u16 val)
  */
 
 /* return the GLOB_STA bit for the corresponding codec */
-static unsigned int get_ich_codec_bit(intel8x0_t *chip, unsigned int codec)
+static unsigned int get_ich_codec_bit(struct intel8x0m *chip, unsigned int codec)
 {
        static unsigned int codec_bit[3] = {
                ICH_PCR, ICH_SCR, ICH_TCR
        };
-       snd_assert(codec < 3, return ICH_PCR);
+       if (snd_BUG_ON(codec >= 3))
+               return ICH_PCR;
        return codec_bit[codec];
 }
 
-static int snd_intel8x0m_codec_semaphore(intel8x0_t *chip, unsigned int codec)
+static int snd_intel8x0m_codec_semaphore(struct intel8x0m *chip, unsigned int codec)
 {
        int time;
        
@@ -363,44 +334,45 @@ 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 */
        return -EBUSY;
 }
  
-static void snd_intel8x0_codec_write(ac97_t *ac97,
+static void snd_intel8x0_codec_write(struct snd_ac97 *ac97,
                                     unsigned short reg,
                                     unsigned short val)
 {
-       intel8x0_t *chip = ac97->private_data;
+       struct intel8x0m *chip = ac97->private_data;
        
        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);
 }
 
-static unsigned short snd_intel8x0_codec_read(ac97_t *ac97,
+static unsigned short snd_intel8x0_codec_read(struct snd_ac97 *ac97,
                                              unsigned short reg)
 {
-       intel8x0_t *chip = ac97->private_data;
+       struct intel8x0m *chip = ac97->private_data;
        unsigned short res;
        unsigned int tmp;
 
        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);
                if ((tmp = igetdword(chip, ICHREG(GLOB_STA))) & ICH_RCS) {
                        /* reset RCS and preserve other R/WC bits */
-                       iputdword(chip, ICHREG(GLOB_STA), tmp & ~(ICH_SRI|ICH_PRI|ICH_TRI|ICH_GSCI));
+                       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;
                }
        }
@@ -413,7 +385,7 @@ static unsigned short snd_intel8x0_codec_read(ac97_t *ac97,
 /*
  * DMA I/O
  */
-static void snd_intel8x0_setup_periods(intel8x0_t *chip, ichdev_t *ichdev) 
+static void snd_intel8x0_setup_periods(struct intel8x0m *chip, struct ichdev *ichdev) 
 {
        int idx;
        u32 *bdbar = ichdev->bdbar;
@@ -439,7 +411,10 @@ static void snd_intel8x0_setup_periods(intel8x0_t *chip, ichdev_t *ichdev)
                        bdbar[idx + 0] = cpu_to_le32(ichdev->physbuf + (((idx >> 1) * ichdev->fragsize) % ichdev->size));
                        bdbar[idx + 1] = cpu_to_le32(0x80000000 | /* interrupt on completion */
                                                     ichdev->fragsize >> chip->pcm_pos_shift);
-                       // printk("bdbar[%i] = 0x%x [0x%x]\n", idx + 0, bdbar[idx + 0], bdbar[idx + 1]);
+                       /*
+                       printk(KERN_DEBUG "bdbar[%i] = 0x%x [0x%x]\n",
+                              idx + 0, bdbar[idx + 0], bdbar[idx + 1]);
+                       */
                }
                ichdev->frags = ichdev->size / ichdev->fragsize;
        }
@@ -449,8 +424,10 @@ static void snd_intel8x0_setup_periods(intel8x0_t *chip, ichdev_t *ichdev)
        ichdev->lvi_frag = ICH_REG_LVI_MASK % ichdev->frags;
        ichdev->position = 0;
 #if 0
-       printk("lvi_frag = %i, frags = %i, period_size = 0x%x, period_size1 = 0x%x\n",
-                       ichdev->lvi_frag, ichdev->frags, ichdev->fragsize, ichdev->fragsize1);
+       printk(KERN_DEBUG "lvi_frag = %i, frags = %i, period_size = 0x%x, "
+              "period_size1 = 0x%x\n",
+              ichdev->lvi_frag, ichdev->frags, ichdev->fragsize,
+              ichdev->fragsize1);
 #endif
        /* clear interrupts */
        iputbyte(chip, port + ichdev->roff_sr, ICH_FIFOE | ICH_BCIS | ICH_LVBCI);
@@ -460,7 +437,7 @@ static void snd_intel8x0_setup_periods(intel8x0_t *chip, ichdev_t *ichdev)
  *  Interrupt handler
  */
 
-static inline void snd_intel8x0_update(intel8x0_t *chip, ichdev_t *ichdev)
+static inline void snd_intel8x0_update(struct intel8x0m *chip, struct ichdev *ichdev)
 {
        unsigned long port = ichdev->reg_offset;
        int civ, i, step;
@@ -489,8 +466,16 @@ static inline void snd_intel8x0_update(intel8x0_t *chip, ichdev_t *ichdev)
        for (i = 0; i < step; i++) {
                ichdev->lvi_frag++;
                ichdev->lvi_frag %= ichdev->frags;
-               ichdev->bdbar[ichdev->lvi * 2] = cpu_to_le32(ichdev->physbuf + ichdev->lvi_frag * ichdev->fragsize1);
-       // printk("new: bdbar[%i] = 0x%x [0x%x], prefetch = %i, all = 0x%x, 0x%x\n", ichdev->lvi * 2, ichdev->bdbar[ichdev->lvi * 2], ichdev->bdbar[ichdev->lvi * 2 + 1], inb(ICH_REG_OFF_PIV + port), inl(port + 4), inb(port + ICH_REG_OFF_CR));
+               ichdev->bdbar[ichdev->lvi * 2] = cpu_to_le32(ichdev->physbuf +
+                                                            ichdev->lvi_frag *
+                                                            ichdev->fragsize1);
+#if 0
+               printk(KERN_DEBUG "new: bdbar[%i] = 0x%x [0x%x], "
+                      "prefetch = %i, all = 0x%x, 0x%x\n",
+                      ichdev->lvi * 2, ichdev->bdbar[ichdev->lvi * 2],
+                      ichdev->bdbar[ichdev->lvi * 2 + 1], inb(ICH_REG_OFF_PIV + port),
+                      inl(port + 4), inb(port + ICH_REG_OFF_CR));
+#endif
                if (--ichdev->ack == 0) {
                        ichdev->ack = ichdev->ack_reload;
                        ack = 1;
@@ -504,10 +489,10 @@ static inline void snd_intel8x0_update(intel8x0_t *chip, ichdev_t *ichdev)
        iputbyte(chip, port + ichdev->roff_sr, 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)
 {
-       intel8x0_t *chip = dev_id;
-       ichdev_t *ichdev;
+       struct intel8x0m *chip = dev_id;
+       struct ichdev *ichdev;
        unsigned int status;
        unsigned int i;
 
@@ -541,10 +526,10 @@ static irqreturn_t snd_intel8x0_interrupt(int irq, void *dev_id, struct pt_regs
  *  PCM part
  */
 
-static int snd_intel8x0_pcm_trigger(snd_pcm_substream_t *substream, int cmd)
+static int snd_intel8x0_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
 {
-       intel8x0_t *chip = snd_pcm_substream_chip(substream);
-       ichdev_t *ichdev = get_ichdev(substream);
+       struct intel8x0m *chip = snd_pcm_substream_chip(substream);
+       struct ichdev *ichdev = get_ichdev(substream);
        unsigned char val = 0;
        unsigned long port = ichdev->reg_offset;
 
@@ -576,21 +561,21 @@ static int snd_intel8x0_pcm_trigger(snd_pcm_substream_t *substream, int cmd)
        return 0;
 }
 
-static int snd_intel8x0_hw_params(snd_pcm_substream_t * substream,
-                                 snd_pcm_hw_params_t * hw_params)
+static int snd_intel8x0_hw_params(struct snd_pcm_substream *substream,
+                                 struct snd_pcm_hw_params *hw_params)
 {
        return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
 }
 
-static int snd_intel8x0_hw_free(snd_pcm_substream_t * substream)
+static int snd_intel8x0_hw_free(struct snd_pcm_substream *substream)
 {
        return snd_pcm_lib_free_pages(substream);
 }
 
-static snd_pcm_uframes_t snd_intel8x0_pcm_pointer(snd_pcm_substream_t * substream)
+static snd_pcm_uframes_t snd_intel8x0_pcm_pointer(struct snd_pcm_substream *substream)
 {
-       intel8x0_t *chip = snd_pcm_substream_chip(substream);
-       ichdev_t *ichdev = get_ichdev(substream);
+       struct intel8x0m *chip = snd_pcm_substream_chip(substream);
+       struct ichdev *ichdev = get_ichdev(substream);
        size_t ptr1, ptr;
 
        ptr1 = igetword(chip, ichdev->reg_offset + ichdev->roff_picb) << chip->pcm_pos_shift;
@@ -604,11 +589,11 @@ static snd_pcm_uframes_t snd_intel8x0_pcm_pointer(snd_pcm_substream_t * substrea
        return bytes_to_frames(substream->runtime, ptr);
 }
 
-static int snd_intel8x0m_pcm_prepare(snd_pcm_substream_t * substream)
+static int snd_intel8x0m_pcm_prepare(struct snd_pcm_substream *substream)
 {
-       intel8x0_t *chip = snd_pcm_substream_chip(substream);
-       snd_pcm_runtime_t *runtime = substream->runtime;
-       ichdev_t *ichdev = get_ichdev(substream);
+       struct intel8x0m *chip = snd_pcm_substream_chip(substream);
+       struct snd_pcm_runtime *runtime = substream->runtime;
+       struct ichdev *ichdev = get_ichdev(substream);
 
        ichdev->physbuf = runtime->dma_addr;
        ichdev->size = snd_pcm_lib_buffer_bytes(substream);
@@ -619,7 +604,7 @@ static int snd_intel8x0m_pcm_prepare(snd_pcm_substream_t * substream)
        return 0;
 }
 
-static snd_pcm_hardware_t snd_intel8x0m_stream =
+static struct snd_pcm_hardware snd_intel8x0m_stream =
 {
        .info =                 (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
                                 SNDRV_PCM_INFO_BLOCK_TRANSFER |
@@ -641,58 +626,59 @@ static snd_pcm_hardware_t snd_intel8x0m_stream =
 };
 
 
-static int snd_intel8x0m_pcm_open(snd_pcm_substream_t * substream, ichdev_t *ichdev)
+static int snd_intel8x0m_pcm_open(struct snd_pcm_substream *substream, struct ichdev *ichdev)
 {
        static unsigned int rates[] = { 8000,  9600, 12000, 16000 };
-       static snd_pcm_hw_constraint_list_t hw_constraints_rates = {
+       static struct snd_pcm_hw_constraint_list hw_constraints_rates = {
                .count = ARRAY_SIZE(rates),
                .list = rates,
                .mask = 0,
        };
-       snd_pcm_runtime_t *runtime = substream->runtime;
+       struct snd_pcm_runtime *runtime = substream->runtime;
        int err;
 
        ichdev->substream = substream;
        runtime->hw = snd_intel8x0m_stream;
-       err = snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &hw_constraints_rates);
+       err = snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
+                                        &hw_constraints_rates);
        if ( err < 0 )
                return err;
        runtime->private_data = ichdev;
        return 0;
 }
 
-static int snd_intel8x0m_playback_open(snd_pcm_substream_t * substream)
+static int snd_intel8x0m_playback_open(struct snd_pcm_substream *substream)
 {
-       intel8x0_t *chip = snd_pcm_substream_chip(substream);
+       struct intel8x0m *chip = snd_pcm_substream_chip(substream);
 
        return snd_intel8x0m_pcm_open(substream, &chip->ichd[ICHD_MDMOUT]);
 }
 
-static int snd_intel8x0m_playback_close(snd_pcm_substream_t * substream)
+static int snd_intel8x0m_playback_close(struct snd_pcm_substream *substream)
 {
-       intel8x0_t *chip = snd_pcm_substream_chip(substream);
+       struct intel8x0m *chip = snd_pcm_substream_chip(substream);
 
        chip->ichd[ICHD_MDMOUT].substream = NULL;
        return 0;
 }
 
-static int snd_intel8x0m_capture_open(snd_pcm_substream_t * substream)
+static int snd_intel8x0m_capture_open(struct snd_pcm_substream *substream)
 {
-       intel8x0_t *chip = snd_pcm_substream_chip(substream);
+       struct intel8x0m *chip = snd_pcm_substream_chip(substream);
 
        return snd_intel8x0m_pcm_open(substream, &chip->ichd[ICHD_MDMIN]);
 }
 
-static int snd_intel8x0m_capture_close(snd_pcm_substream_t * substream)
+static int snd_intel8x0m_capture_close(struct snd_pcm_substream *substream)
 {
-       intel8x0_t *chip = snd_pcm_substream_chip(substream);
+       struct intel8x0m *chip = snd_pcm_substream_chip(substream);
 
        chip->ichd[ICHD_MDMIN].substream = NULL;
        return 0;
 }
 
 
-static snd_pcm_ops_t snd_intel8x0m_playback_ops = {
+static struct snd_pcm_ops snd_intel8x0m_playback_ops = {
        .open =         snd_intel8x0m_playback_open,
        .close =        snd_intel8x0m_playback_close,
        .ioctl =        snd_pcm_lib_ioctl,
@@ -703,7 +689,7 @@ static snd_pcm_ops_t snd_intel8x0m_playback_ops = {
        .pointer =      snd_intel8x0_pcm_pointer,
 };
 
-static snd_pcm_ops_t snd_intel8x0m_capture_ops = {
+static struct snd_pcm_ops snd_intel8x0m_capture_ops = {
        .open =         snd_intel8x0m_capture_open,
        .close =        snd_intel8x0m_capture_close,
        .ioctl =        snd_pcm_lib_ioctl,
@@ -717,16 +703,17 @@ static snd_pcm_ops_t snd_intel8x0m_capture_ops = {
 
 struct ich_pcm_table {
        char *suffix;
-       snd_pcm_ops_t *playback_ops;
-       snd_pcm_ops_t *capture_ops;
+       struct snd_pcm_ops *playback_ops;
+       struct snd_pcm_ops *capture_ops;
        size_t prealloc_size;
        size_t prealloc_max_size;
        int ac97_idx;
 };
 
-static int __devinit snd_intel8x0_pcm1(intel8x0_t *chip, int device, struct ich_pcm_table *rec)
+static int __devinit snd_intel8x0_pcm1(struct intel8x0m *chip, int device,
+                                      struct ich_pcm_table *rec)
 {
-       snd_pcm_t *pcm;
+       struct snd_pcm *pcm;
        int err;
        char name[32];
 
@@ -772,7 +759,7 @@ static struct ich_pcm_table intel_pcms[] __devinitdata = {
        },
 };
 
-static int __devinit snd_intel8x0_pcm(intel8x0_t *chip)
+static int __devinit snd_intel8x0_pcm(struct intel8x0m *chip)
 {
        int i, tblsize, device, err;
        struct ich_pcm_table *tbl, *rec;
@@ -819,27 +806,27 @@ static int __devinit snd_intel8x0_pcm(intel8x0_t *chip)
  *  Mixer part
  */
 
-static void snd_intel8x0_mixer_free_ac97_bus(ac97_bus_t *bus)
+static void snd_intel8x0_mixer_free_ac97_bus(struct snd_ac97_bus *bus)
 {
-       intel8x0_t *chip = bus->private_data;
+       struct intel8x0m *chip = bus->private_data;
        chip->ac97_bus = NULL;
 }
 
-static void snd_intel8x0_mixer_free_ac97(ac97_t *ac97)
+static void snd_intel8x0_mixer_free_ac97(struct snd_ac97 *ac97)
 {
-       intel8x0_t *chip = ac97->private_data;
+       struct intel8x0m *chip = ac97->private_data;
        chip->ac97 = NULL;
 }
 
 
-static int __devinit snd_intel8x0_mixer(intel8x0_t *chip, int ac97_clock)
+static int __devinit snd_intel8x0_mixer(struct intel8x0m *chip, int ac97_clock)
 {
-       ac97_bus_t *pbus;
-       ac97_template_t ac97;
-       ac97_t *x97;
+       struct snd_ac97_bus *pbus;
+       struct snd_ac97_template ac97;
+       struct snd_ac97 *x97;
        int err;
        unsigned int glob_sta = 0;
-       static ac97_bus_ops_t ops = {
+       static struct snd_ac97_bus_ops ops = {
                .write = snd_intel8x0_codec_write,
                .read = snd_intel8x0_codec_read,
        };
@@ -849,7 +836,7 @@ static int __devinit snd_intel8x0_mixer(intel8x0_t *chip, int ac97_clock)
        memset(&ac97, 0, sizeof(ac97));
        ac97.private_data = chip;
        ac97.private_free = snd_intel8x0_mixer_free_ac97;
-       ac97.scaps = AC97_SCAP_SKIP_AUDIO;
+       ac97.scaps = AC97_SCAP_SKIP_AUDIO | AC97_SCAP_POWER_SAVE;
 
        glob_sta = igetdword(chip, ICHREG(GLOB_STA));
 
@@ -880,7 +867,8 @@ static int __devinit snd_intel8x0_mixer(intel8x0_t *chip, int ac97_clock)
  __err:
        /* clear the cold-reset bit for the next chance */
        if (chip->device_type != DEVICE_ALI)
-               iputdword(chip, ICHREG(GLOB_CNT), igetdword(chip, ICHREG(GLOB_CNT)) & ~ICH_AC97COLD);
+               iputdword(chip, ICHREG(GLOB_CNT),
+                         igetdword(chip, ICHREG(GLOB_CNT)) & ~ICH_AC97COLD);
        return err;
 }
 
@@ -889,12 +877,7 @@ 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)
+static int snd_intel8x0m_ich_chip_init(struct intel8x0m *chip, int probing)
 {
        unsigned long end_time;
        unsigned int cnt, status, nstatus;
@@ -915,9 +898,10 @@ 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:
@@ -928,14 +912,16 @@ static int snd_intel8x0m_ich_chip_init(intel8x0_t *chip, int probing)
                 */
                end_time = jiffies + HZ;
                do {
-                       status = igetdword(chip, ICHREG(GLOB_STA)) & (ICH_PCR | ICH_SCR | ICH_TCR);
+                       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 */
-                       snd_printk(KERN_ERR "codec_ready: codec is not ready [0x%x]\n", igetdword(chip, ICHREG(GLOB_STA)));
+                       snd_printk(KERN_ERR "codec_ready: codec is not ready [0x%x]\n",
+                                  igetdword(chip, ICHREG(GLOB_STA)));
                        return -EIO;
                }
 
@@ -945,7 +931,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;
                }
 
@@ -957,10 +943,11 @@ static int snd_intel8x0m_ich_chip_init(intel8x0_t *chip, int probing)
                /* wait until all the probed codecs are ready */
                end_time = jiffies + HZ;
                do {
-                       nstatus = igetdword(chip, ICHREG(GLOB_STA)) & (ICH_PCR | ICH_SCR | ICH_TCR);
+                       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));
        }
 
@@ -972,7 +959,7 @@ static int snd_intel8x0m_ich_chip_init(intel8x0_t *chip, int probing)
        return 0;
 }
 
-static int snd_intel8x0_chip_init(intel8x0_t *chip, int probing)
+static int snd_intel8x0_chip_init(struct intel8x0m *chip, int probing)
 {
        unsigned int i;
        int err;
@@ -993,7 +980,7 @@ static int snd_intel8x0_chip_init(intel8x0_t *chip, int probing)
        return 0;
 }
 
-static int snd_intel8x0_free(intel8x0_t *chip)
+static int snd_intel8x0_free(struct intel8x0m *chip)
 {
        unsigned int i;
 
@@ -1005,17 +992,15 @@ static int snd_intel8x0_free(intel8x0_t *chip)
        /* reset channels */
        for (i = 0; i < chip->bdbars_count; i++)
                iputbyte(chip, ICH_REG_OFF_CR + chip->ichd[i].reg_offset, ICH_RESETREGS);
-       /* --- */
-       synchronize_irq(chip->irq);
-      __hw_end:
+ __hw_end:
+       if (chip->irq >= 0)
+               free_irq(chip->irq, chip);
        if (chip->bdbars.area)
                snd_dma_free_pages(&chip->bdbars);
-       if (chip->remap_addr)
-               iounmap(chip->remap_addr);
-       if (chip->remap_bmaddr)
-               iounmap(chip->remap_bmaddr);
-       if (chip->irq >= 0)
-               free_irq(chip->irq, (void *)chip);
+       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);
@@ -1026,43 +1011,69 @@ static int snd_intel8x0_free(intel8x0_t *chip)
 /*
  * power management
  */
-static int intel8x0m_suspend(snd_card_t *card, pm_message_t state)
+static int intel8x0m_suspend(struct pci_dev *pci, pm_message_t state)
 {
-       intel8x0_t *chip = card->pm_private_data;
+       struct snd_card *card = pci_get_drvdata(pci);
+       struct intel8x0m *chip = card->private_data;
        int i;
 
+       snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
        for (i = 0; i < chip->pcm_devs; i++)
                snd_pcm_suspend_all(chip->pcm[i]);
-       if (chip->ac97)
-               snd_ac97_suspend(chip->ac97);
-       pci_disable_device(chip->pci);
+       snd_ac97_suspend(chip->ac97);
+       if (chip->irq >= 0) {
+               free_irq(chip->irq, chip);
+               chip->irq = -1;
+       }
+       pci_disable_device(pci);
+       pci_save_state(pci);
+       pci_set_power_state(pci, pci_choose_state(pci, state));
        return 0;
 }
 
-static int intel8x0m_resume(snd_card_t *card)
+static int intel8x0m_resume(struct pci_dev *pci)
 {
-       intel8x0_t *chip = card->pm_private_data;
-       pci_enable_device(chip->pci);
-       pci_set_master(chip->pci);
+       struct snd_card *card = pci_get_drvdata(pci);
+       struct intel8x0m *chip = card->private_data;
+
+       pci_set_power_state(pci, PCI_D0);
+       pci_restore_state(pci);
+       if (pci_enable_device(pci) < 0) {
+               printk(KERN_ERR "intel8x0m: pci_enable_device failed, "
+                      "disabling device\n");
+               snd_card_disconnect(card);
+               return -EIO;
+       }
+       pci_set_master(pci);
+       if (request_irq(pci->irq, snd_intel8x0_interrupt,
+                       IRQF_SHARED, card->shortname, chip)) {
+               printk(KERN_ERR "intel8x0m: unable to grab IRQ %d, "
+                      "disabling device\n", pci->irq);
+               snd_card_disconnect(card);
+               return -EIO;
+       }
+       chip->irq = pci->irq;
        snd_intel8x0_chip_init(chip, 0);
-       if (chip->ac97)
-               snd_ac97_resume(chip->ac97);
+       snd_ac97_resume(chip->ac97);
 
+       snd_power_change_state(card, SNDRV_CTL_POWER_D0);
        return 0;
 }
 #endif /* CONFIG_PM */
 
-static void snd_intel8x0m_proc_read(snd_info_entry_t * entry,
-                                  snd_info_buffer_t * buffer)
+#ifdef CONFIG_PROC_FS
+static void snd_intel8x0m_proc_read(struct snd_info_entry * entry,
+                                  struct snd_info_buffer *buffer)
 {
-       intel8x0_t *chip = entry->private_data;
+       struct intel8x0m *chip = entry->private_data;
        unsigned int tmp;
 
        snd_iprintf(buffer, "Intel8x0m\n\n");
        if (chip->device_type == DEVICE_ALI)
                return;
        tmp = igetdword(chip, ICHREG(GLOB_STA));
-       snd_iprintf(buffer, "Global control        : 0x%08x\n", igetdword(chip, ICHREG(GLOB_CNT)));
+       snd_iprintf(buffer, "Global control        : 0x%08x\n",
+                   igetdword(chip, ICHREG(GLOB_CNT)));
        snd_iprintf(buffer, "Global status         : 0x%08x\n", tmp);
        snd_iprintf(buffer, "AC'97 codecs ready    :%s%s%s%s\n",
                        tmp & ICH_PCR ? " primary" : "",
@@ -1071,17 +1082,21 @@ static void snd_intel8x0m_proc_read(snd_info_entry_t * entry,
                        (tmp & (ICH_PCR | ICH_SCR | ICH_TCR)) == 0 ? " none" : "");
 }
 
-static void __devinit snd_intel8x0m_proc_init(intel8x0_t * chip)
+static void __devinit snd_intel8x0m_proc_init(struct intel8x0m * chip)
 {
-       snd_info_entry_t *entry;
+       struct snd_info_entry *entry;
 
        if (! snd_card_proc_new(chip->card, "intel8x0m", &entry))
-               snd_info_set_text_ops(entry, chip, 1024, snd_intel8x0m_proc_read);
+               snd_info_set_text_ops(entry, chip, snd_intel8x0m_proc_read);
 }
+#else /* !CONFIG_PROC_FS */
+#define snd_intel8x0m_proc_init(chip)
+#endif /* CONFIG_PROC_FS */
+
 
-static int snd_intel8x0_dev_free(snd_device_t *device)
+static int snd_intel8x0_dev_free(struct snd_device *device)
 {
-       intel8x0_t *chip = device->device_data;
+       struct intel8x0m *chip = device->device_data;
        return snd_intel8x0_free(chip);
 }
 
@@ -1090,17 +1105,17 @@ struct ich_reg_info {
        unsigned int offset;
 };
 
-static int __devinit snd_intel8x0m_create(snd_card_t * card,
+static int __devinit snd_intel8x0m_create(struct snd_card *card,
                                         struct pci_dev *pci,
                                         unsigned long device_type,
-                                        intel8x0_t ** r_intel8x0)
+                                        struct intel8x0m ** r_intel8x0)
 {
-       intel8x0_t *chip;
+       struct intel8x0m *chip;
        int err;
        unsigned int i;
        unsigned int int_sta_masks;
-       ichdev_t *ichdev;
-       static snd_device_ops_t ops = {
+       struct ichdev *ichdev;
+       static struct snd_device_ops ops = {
                .dev_free =     snd_intel8x0_dev_free,
        };
        static struct ich_reg_info intel_regs[2] = {
@@ -1133,40 +1148,33 @@ static int __devinit snd_intel8x0m_create(snd_card_t * 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("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, 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->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("Controller space ioremap problem\n");
-                       snd_intel8x0_free(chip);
-                       return -EIO;
-               }
-       } else {
-               chip->bmaddr = pci_resource_start(pci, 1);
+       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:
-       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);
+       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;
        }
@@ -1222,8 +1230,6 @@ static int __devinit snd_intel8x0m_create(snd_card_t * card,
                return err;
        }
 
-       snd_card_set_pm_callback(card, intel8x0m_suspend, intel8x0m_resume, chip);
-
        if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
                snd_intel8x0_free(chip);
                return err;
@@ -1264,14 +1270,14 @@ static struct shortname_table {
 static int __devinit snd_intel8x0m_probe(struct pci_dev *pci,
                                        const struct pci_device_id *pci_id)
 {
-       snd_card_t *card;
-       intel8x0_t *chip;
+       struct snd_card *card;
+       struct intel8x0m *chip;
        int err;
        struct shortname_table *name;
 
-       card = snd_card_new(index, id, THIS_MODULE, 0);
-       if (card == NULL)
-               return -ENOMEM;
+       err = snd_card_create(index, id, THIS_MODULE, 0, &card);
+       if (err < 0)
+               return err;
 
        strcpy(card->driver, "ICH-MODEM");
        strcpy(card->shortname, "Intel ICH");
@@ -1287,6 +1293,7 @@ static int __devinit snd_intel8x0m_probe(struct pci_dev *pci,
                snd_card_free(card);
                return err;
        }
+       card->private_data = chip;
 
        if ((err = snd_intel8x0_mixer(chip, ac97_clock)) < 0) {
                snd_card_free(card);
@@ -1299,8 +1306,8 @@ static int __devinit snd_intel8x0m_probe(struct pci_dev *pci,
        
        snd_intel8x0m_proc_init(chip);
 
-       sprintf(card->longname, "%s at 0x%lx, irq %i",
-               card->shortname, chip->addr, chip->irq);
+       sprintf(card->longname, "%s at irq %i",
+               card->shortname, chip->irq);
 
        if ((err = snd_card_register(card)) < 0) {
                snd_card_free(card);
@@ -1318,11 +1325,13 @@ static void __devexit snd_intel8x0m_remove(struct pci_dev *pci)
 
 static struct pci_driver driver = {
        .name = "Intel ICH Modem",
-       .owner = THIS_MODULE,
        .id_table = snd_intel8x0m_ids,
        .probe = snd_intel8x0m_probe,
        .remove = __devexit_p(snd_intel8x0m_remove),
-       SND_PCI_PM_CALLBACKS
+#ifdef CONFIG_PM
+       .suspend = intel8x0m_suspend,
+       .resume = intel8x0m_resume,
+#endif
 };