X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sound%2Fpci%2Fintel8x0m.c;h=09dcf923b5471fdda5015daf25f8b6a4f7a239a2;hb=97bf2856c6014879bd04983a3e9dfcdac1e7fe85;hp=feac6c64b1713ec2b27d435a49182ead6c74c75f;hpb=5273a3df6485dc2ad6aa7ddd441b9a21970f003b;p=linux-2.6.git diff --git a/sound/pci/intel8x0m.c b/sound/pci/intel8x0m.c index feac6c64b..09dcf923b 100644 --- a/sound/pci/intel8x0m.c +++ b/sound/pci/intel8x0m.c @@ -3,7 +3,7 @@ * * Copyright (c) 2000 Jaroslav Kysela * - * This is modified (by Sasha Khapyorsky ) version + * This is modified (by Sasha Khapyorsky ) version * of ALSA ICH sound driver intel8x0.c . * * @@ -30,86 +30,51 @@ #include #include #include -#include +#include #include #include #include #include -#include -#define SNDRV_GET_ID #include MODULE_AUTHOR("Jaroslav Kysela "); -MODULE_DESCRIPTION("Intel 82801AA,82901AB,i810,i820,i830,i840,i845,MX440 modem"); +MODULE_DESCRIPTION("Intel 82801AA,82901AB,i810,i820,i830,i840,i845,MX440; " + "SiS 7013; NVidia MCP/2/2S/3 modems"); MODULE_LICENSE("GPL"); -MODULE_CLASSES("{sound}"); -MODULE_DEVICES("{{Intel,82801AA-ICH}," +MODULE_SUPPORTED_DEVICE("{{Intel,82801AA-ICH}," "{Intel,82901AB-ICH0}," "{Intel,82801BA-ICH2}," "{Intel,82801CA-ICH3}," "{Intel,82801DB-ICH4}," "{Intel,ICH5}," - "{Intel,MX440}}"); - - -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}; - -MODULE_PARM(index, "1-" __MODULE_STRING(SNDRV_CARDS) "i"); + "{Intel,ICH6}," + "{Intel,ICH7}," + "{Intel,MX440}," + "{SiS,7013}," + "{NVidia,NForce Modem}," + "{NVidia,NForce2 Modem}," + "{NVidia,NForce2s Modem}," + "{NVidia,NForce3 Modem}," + "{AMD,AMD768}}"); + +static int index = -2; /* Exclude the first card */ +static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */ +static int ac97_clock; + +module_param(index, int, 0444); MODULE_PARM_DESC(index, "Index value for Intel i8x0 modemcard."); -MODULE_PARM_SYNTAX(index, SNDRV_INDEX_DESC); -MODULE_PARM(id, "1-" __MODULE_STRING(SNDRV_CARDS) "s"); +module_param(id, charp, 0444); MODULE_PARM_DESC(id, "ID string for Intel i8x0 modemcard."); -MODULE_PARM_SYNTAX(id, SNDRV_ID_DESC); -MODULE_PARM(enable, "1-" __MODULE_STRING(SNDRV_CARDS) "i"); -MODULE_PARM_DESC(enable, "Enable Intel i8x0 modemcard."); -MODULE_PARM_SYNTAX(enable, SNDRV_ENABLE_DESC); -MODULE_PARM(ac97_clock, "1-" __MODULE_STRING(SNDRV_CARDS) "i"); +module_param(ac97_clock, int, 0444); MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (0 = auto-detect)."); -MODULE_PARM_SYNTAX(ac97_clock, SNDRV_ENABLED ",default:0"); + +/* 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_SI_7013 -#define PCI_DEVICE_ID_SI_7013 0x7013 -#endif -#if 0 -#ifndef PCI_DEVICE_ID_NVIDIA_MCP_AUDIO -#define PCI_DEVICE_ID_NVIDIA_MCP_AUDIO 0x01b1 -#endif -#ifndef PCI_DEVICE_ID_NVIDIA_MCP2_AUDIO -#define PCI_DEVICE_ID_NVIDIA_MCP2_AUDIO 0x006a -#endif -#ifndef PCI_DEVICE_ID_NVIDIA_MCP3_AUDIO -#define PCI_DEVICE_ID_NVIDIA_MCP3_AUDIO 0x00da -#endif -#endif - enum { DEVICE_INTEL, DEVICE_SIS, DEVICE_ALI, DEVICE_NFORCE }; #define ICHREG(x) ICH_REG_##x @@ -199,14 +164,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; @@ -223,53 +188,40 @@ 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; -#define chip_t intel8x0_t + struct snd_ac97 *ac97; +}; -struct _snd_intel8x0m { +struct intel8x0m { unsigned int device_type; - char ac97_name[64]; - char ctrl_name[64]; int irq; unsigned int mmio; unsigned long addr; - unsigned long remap_addr; - struct resource *res; + void __iomem *remap_addr; unsigned int bm_mmio; unsigned long bmaddr; - unsigned long remap_bmaddr; - struct resource *res_bm; + void __iomem *remap_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]; - int in_ac97_init: 1; + 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; - spinlock_t ac97_lock; - struct snd_dma_device dma_dev; struct snd_dma_buffer bdbars; u32 bdbars_count; u32 int_sta_reg; /* interrupt status register */ u32 int_sta_mask; /* interrupt status mask */ unsigned int pcm_pos_shift; - -#ifdef CONFIG_PM - int in_suspend; -#endif }; static struct pci_device_id snd_intel8x0m_ids[] = { @@ -279,14 +231,16 @@ static struct pci_device_id snd_intel8x0m_ids[] = { { 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 */ -#if 0 - /* TODO: support needed */ { 0x1039, 0x7013, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_SIS }, /* SI7013 */ - { 0x10de, 0x01b1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_NFORCE }, /* NFORCE */ - { 0x10de, 0x006a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_NFORCE }, /* NFORCE2 */ - { 0x10de, 0x00da, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_NFORCE }, /* NFORCE3 */ + { 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 */ +#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 */ #endif @@ -299,7 +253,7 @@ MODULE_DEVICE_TABLE(pci, snd_intel8x0m_ids); * Lowlevel I/O - busmaster */ -static u8 igetbyte(intel8x0_t *chip, u32 offset) +static u8 igetbyte(struct intel8x0m *chip, u32 offset) { if (chip->bm_mmio) return readb(chip->remap_bmaddr + offset); @@ -307,7 +261,7 @@ static u8 igetbyte(intel8x0_t *chip, u32 offset) return inb(chip->bmaddr + offset); } -static u16 igetword(intel8x0_t *chip, u32 offset) +static u16 igetword(struct intel8x0m *chip, u32 offset) { if (chip->bm_mmio) return readw(chip->remap_bmaddr + offset); @@ -315,7 +269,7 @@ static u16 igetword(intel8x0_t *chip, u32 offset) return inw(chip->bmaddr + offset); } -static u32 igetdword(intel8x0_t *chip, u32 offset) +static u32 igetdword(struct intel8x0m *chip, u32 offset) { if (chip->bm_mmio) return readl(chip->remap_bmaddr + offset); @@ -323,7 +277,7 @@ static u32 igetdword(intel8x0_t *chip, u32 offset) return inl(chip->bmaddr + offset); } -static void iputbyte(intel8x0_t *chip, u32 offset, u8 val) +static void iputbyte(struct intel8x0m *chip, u32 offset, u8 val) { if (chip->bm_mmio) writeb(val, chip->remap_bmaddr + offset); @@ -331,7 +285,15 @@ static void iputbyte(intel8x0_t *chip, u32 offset, u8 val) outb(val, chip->bmaddr + offset); } -static void iputdword(intel8x0_t *chip, u32 offset, u32 val) +static 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); +} + +static void iputdword(struct intel8x0m *chip, u32 offset, u32 val) { if (chip->bm_mmio) writel(val, chip->remap_bmaddr + offset); @@ -343,7 +305,7 @@ static void iputdword(intel8x0_t *chip, u32 offset, u32 val) * Lowlevel I/O - AC'97 registers */ -static u16 iagetword(intel8x0_t *chip, u32 offset) +static u16 iagetword(struct intel8x0m *chip, u32 offset) { if (chip->mmio) return readw(chip->remap_addr + offset); @@ -351,7 +313,7 @@ static u16 iagetword(intel8x0_t *chip, u32 offset) return inw(chip->addr + offset); } -static void iaputword(intel8x0_t *chip, u32 offset, u16 val) +static void iaputword(struct intel8x0m *chip, u32 offset, u16 val) { if (chip->mmio) writew(val, chip->remap_addr + offset); @@ -368,7 +330,7 @@ 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 @@ -377,7 +339,7 @@ static unsigned int get_ich_codec_bit(intel8x0_t *chip, unsigned int codec) 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; @@ -400,51 +362,50 @@ 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 = snd_magic_cast(intel8x0_t, ac97->private_data, return); + struct intel8x0m *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); + 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); - spin_unlock(&chip->ac97_lock); } -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 = snd_magic_cast(intel8x0_t, ac97->private_data, return ~0); + struct intel8x0m *chip = ac97->private_data; 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); + 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; } } - spin_unlock(&chip->ac97_lock); + if (reg == AC97_GPIO_STATUS) + iagetword(chip, 0); /* clear semaphore */ return res; } @@ -452,7 +413,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; @@ -499,7 +460,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; @@ -528,8 +489,15 @@ 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("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; @@ -543,15 +511,19 @@ 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 = snd_magic_cast(intel8x0_t, dev_id, return IRQ_NONE); - ichdev_t *ichdev; + struct intel8x0m *chip = dev_id; + struct ichdev *ichdev; unsigned int status; unsigned int i; spin_lock(&chip->reg_lock); status = igetdword(chip, chip->int_sta_reg); + if (status == 0xffffffff) { /* we are not yet resumed */ + spin_unlock(&chip->reg_lock); + return IRQ_NONE; + } if ((status & chip->int_sta_mask) == 0) { if (status) iputdword(chip, chip->int_sta_reg, status); @@ -576,10 +548,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; @@ -611,21 +583,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; @@ -639,31 +611,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_trigger(snd_pcm_substream_t *substream, int cmd) +static int snd_intel8x0m_pcm_prepare(struct snd_pcm_substream *substream) { - ichdev_t *ichdev = get_ichdev(substream); - /* hook off/on on start/stop */ - /* TODO: move it to ac97 controls */ - switch (cmd) { - case SNDRV_PCM_TRIGGER_START: - snd_ac97_update_bits(ichdev->ac97, AC97_GPIO_STATUS, - AC97_GPIO_LINE1_OH, AC97_GPIO_LINE1_OH); - break; - case SNDRV_PCM_TRIGGER_STOP: - snd_ac97_update_bits(ichdev->ac97, AC97_GPIO_STATUS, - AC97_GPIO_LINE1_OH, ~AC97_GPIO_LINE1_OH); - break; - default: - return -EINVAL; - } - return snd_intel8x0_pcm_trigger(substream,cmd); -} - -static int snd_intel8x0m_pcm_prepare(snd_pcm_substream_t * 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); @@ -674,7 +626,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 | @@ -687,101 +639,103 @@ static snd_pcm_hardware_t snd_intel8x0m_stream = .rate_max = 16000, .channels_min = 1, .channels_max = 1, - .buffer_bytes_max = 32 * 1024, + .buffer_bytes_max = 64 * 1024, .period_bytes_min = 32, - .period_bytes_max = 32 * 1024, + .period_bytes_max = 64 * 1024, .periods_min = 1, .periods_max = 1024, .fifo_size = 0, }; -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, .hw_params = snd_intel8x0_hw_params, .hw_free = snd_intel8x0_hw_free, .prepare = snd_intel8x0m_pcm_prepare, - .trigger = snd_intel8x0m_pcm_trigger, + .trigger = snd_intel8x0_pcm_trigger, .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, .hw_params = snd_intel8x0_hw_params, .hw_free = snd_intel8x0_hw_free, .prepare = snd_intel8x0m_pcm_prepare, - .trigger = snd_intel8x0m_pcm_trigger, + .trigger = snd_intel8x0_pcm_trigger, .pointer = snd_intel8x0_pcm_pointer, }; 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]; @@ -802,6 +756,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 @@ -821,12 +776,12 @@ static struct ich_pcm_table intel_pcms[] __devinitdata = { .suffix = "Modem", .playback_ops = &snd_intel8x0m_playback_ops, .capture_ops = &snd_intel8x0m_capture_ops, - .prealloc_size = 4 * 1024, - .prealloc_max_size = 16 * 1024, + .prealloc_size = 32 * 1024, + .prealloc_max_size = 64 * 1024, }, }; -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; @@ -873,47 +828,47 @@ 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 = snd_magic_cast(intel8x0_t, bus->private_data, return); + 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 = snd_magic_cast(intel8x0_t, ac97->private_data, return); + 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 bus, *pbus; - ac97_t ac97, *x97; + struct snd_ac97_bus *pbus; + struct snd_ac97_template ac97; + struct snd_ac97 *x97; int err; unsigned int glob_sta = 0; + static struct snd_ac97_bus_ops ops = { + .write = snd_intel8x0_codec_write, + .read = snd_intel8x0_codec_read, + }; chip->in_ac97_init = 1; - memset(&bus, 0, sizeof(bus)); - bus.private_data = chip; - bus.private_free = snd_intel8x0_mixer_free_ac97_bus; - if (ac97_clock >= 8000 && ac97_clock <= 48000) - bus.clock = ac97_clock; - else - bus.clock = 48000; memset(&ac97, 0, sizeof(ac97)); ac97.private_data = chip; ac97.private_free = snd_intel8x0_mixer_free_ac97; + ac97.scaps = AC97_SCAP_SKIP_AUDIO; glob_sta = igetdword(chip, ICHREG(GLOB_STA)); - bus.write = snd_intel8x0_codec_write; - bus.read = snd_intel8x0_codec_read; - bus.vra = 1; - if ((err = snd_ac97_bus(chip->card, &bus, &pbus)) < 0) + if ((err = snd_ac97_bus(chip->card, 0, &ops, chip, &pbus)) < 0) goto __err; + pbus->private_free = snd_intel8x0_mixer_free_ac97_bus; + if (ac97_clock >= 8000 && ac97_clock <= 48000) + pbus->clock = ac97_clock; chip->ac97_bus = pbus; + ac97.pci = chip->pci; ac97.num = glob_sta & ICH_SCR ? 1 : 0; if ((err = snd_ac97_mixer(pbus, &ac97, &x97)) < 0) { @@ -923,7 +878,7 @@ static int __devinit snd_intel8x0_mixer(intel8x0_t *chip, int ac97_clock) return err; } chip->ac97 = x97; - if(ac97_is_modem(x97) && !chip->ichd[ICHD_MDMIN].ac97 ) { + if(ac97_is_modem(x97) && !chip->ichd[ICHD_MDMIN].ac97) { chip->ichd[ICHD_MDMIN].ac97 = x97; chip->ichd[ICHD_MDMOUT].ac97 = x97; } @@ -934,7 +889,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; } @@ -943,12 +899,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; @@ -969,9 +920,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: @@ -982,14 +934,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; } @@ -999,7 +953,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; } @@ -1011,17 +965,23 @@ 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)); } + if (chip->device_type == DEVICE_SIS) { + /* unmute the output on SIS7012 */ + iputword(chip, 0x4c, igetword(chip, 0x4c) | 1); + } + 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; @@ -1042,7 +1002,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; @@ -1058,22 +1018,16 @@ static int snd_intel8x0_free(intel8x0_t *chip) synchronize_irq(chip->irq); __hw_end: if (chip->bdbars.area) - snd_dma_free_pages(&chip->dma_dev, &chip->bdbars); + 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); - if (chip->res) { - release_resource(chip->res); - kfree_nocheck(chip->res); - } - if (chip->res_bm) { - release_resource(chip->res_bm); - kfree_nocheck(chip->res_bm); - } + iounmap(chip->remap_bmaddr); if (chip->irq >= 0) - free_irq(chip->irq, (void *)chip); - snd_magic_kfree(chip); + free_irq(chip->irq, chip); + pci_release_regions(chip->pci); + pci_disable_device(chip->pci); + kfree(chip); return 0; } @@ -1081,85 +1035,70 @@ static int snd_intel8x0_free(intel8x0_t *chip) /* * power management */ -static void intel8x0_suspend(intel8x0_t *chip) +static int intel8x0m_suspend(struct pci_dev *pci, pm_message_t state) { - snd_card_t *card = chip->card; + struct snd_card *card = pci_get_drvdata(pci); + struct intel8x0m *chip = card->private_data; int i; - if (chip->in_suspend || - card->power_state == SNDRV_CTL_POWER_D3hot) - return; - - chip->in_suspend = 1; + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); for (i = 0; i < chip->pcm_devs; i++) snd_pcm_suspend_all(chip->pcm[i]); - snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); + snd_ac97_suspend(chip->ac97); + if (chip->irq >= 0) { + synchronize_irq(chip->irq); + 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 void intel8x0_resume(intel8x0_t *chip) +static int intel8x0m_resume(struct pci_dev *pci) { - snd_card_t *card = chip->card; - - if (! chip->in_suspend || - card->power_state == SNDRV_CTL_POWER_D0) - return; - - 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); - chip->in_suspend = 0; snd_power_change_state(card, SNDRV_CTL_POWER_D0); -} - -static int snd_intel8x0m_suspend(struct pci_dev *dev, u32 state) -{ - intel8x0_t *chip = snd_magic_cast(intel8x0_t, pci_get_drvdata(dev), return -ENXIO); - intel8x0_suspend(chip); return 0; } -static int snd_intel8x0m_resume(struct pci_dev *dev) -{ - intel8x0_t *chip = snd_magic_cast(intel8x0_t, pci_get_drvdata(dev), return -ENXIO); - intel8x0_resume(chip); - return 0; -} - -/* callback */ -static int snd_intel8x0_set_power_state(snd_card_t *card, unsigned int power_state) -{ - intel8x0_t *chip = snd_magic_cast(intel8x0_t, card->power_state_private_data, return -ENXIO); - switch (power_state) { - case SNDRV_CTL_POWER_D0: - case SNDRV_CTL_POWER_D1: - case SNDRV_CTL_POWER_D2: - intel8x0_resume(chip); - break; - case SNDRV_CTL_POWER_D3hot: - case SNDRV_CTL_POWER_D3cold: - intel8x0_suspend(chip); - break; - default: - return -EINVAL; - } - 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 = snd_magic_cast(intel8x0_t, entry->private_data, return); + 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" : "", @@ -1168,17 +1107,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 = snd_magic_cast(intel8x0_t, device->device_data, return -ENXIO); + struct intel8x0m *chip = device->device_data; return snd_intel8x0_free(chip); } @@ -1187,17 +1130,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] = { @@ -1211,77 +1154,60 @@ static int __devinit snd_intel8x0m_create(snd_card_t * card, if ((err = pci_enable_device(pci)) < 0) return err; - chip = snd_magic_kcalloc(intel8x0_t, 0, GFP_KERNEL); - if (chip == NULL) + chip = kzalloc(sizeof(*chip), GFP_KERNEL); + 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; chip->irq = -1; - snd_intel8x0m_proc_init(chip); - sprintf(chip->ac97_name, "%s - AC'97", card->shortname); - sprintf(chip->ctrl_name, "%s - Controller", card->shortname); + + if ((err = pci_request_regions(pci, card->shortname)) < 0) { + kfree(chip); + pci_disable_device(pci); + return err; + } + if (device_type == DEVICE_ALI) { /* ALI5455 has no ac97 region */ chip->bmaddr = pci_resource_start(pci, 0); - if ((chip->res_bm = request_region(chip->bmaddr, 256, chip->ctrl_name)) == NULL) { - snd_printk("unable to grab ports 0x%lx-0x%lx\n", chip->bmaddr, chip->bmaddr + 256 - 1); - snd_intel8x0_free(chip); - return -EBUSY; - } goto port_inited; } if (pci_resource_flags(pci, 2) & IORESOURCE_MEM) { /* ICH4 and Nforce */ chip->mmio = 1; chip->addr = pci_resource_start(pci, 2); - if ((chip->res = request_mem_region(chip->addr, 512, chip->ac97_name)) == NULL) { - snd_printk("unable to grab I/O memory 0x%lx-0x%lx\n", chip->addr, chip->addr + 512 - 1); - snd_intel8x0_free(chip); - return -EBUSY; - } - chip->remap_addr = (unsigned long) ioremap_nocache(chip->addr, 512); - if (chip->remap_addr == 0) { - snd_printk("AC'97 space ioremap problem\n"); + 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 ((chip->res = request_region(chip->addr, 256, chip->ac97_name)) == NULL) { - snd_printk("unable to grab ports 0x%lx-0x%lx\n", chip->addr, chip->addr + 256 - 1); - snd_intel8x0_free(chip); - return -EBUSY; - } } if (pci_resource_flags(pci, 3) & IORESOURCE_MEM) { /* ICH4 */ chip->bm_mmio = 1; chip->bmaddr = pci_resource_start(pci, 3); - if ((chip->res_bm = request_mem_region(chip->bmaddr, 256, chip->ctrl_name)) == NULL) { - snd_printk("unable to grab I/O memory 0x%lx-0x%lx\n", chip->bmaddr, chip->bmaddr + 512 - 1); - snd_intel8x0_free(chip); - return -EBUSY; - } - chip->remap_bmaddr = (unsigned long) ioremap_nocache(chip->bmaddr, 256); - if (chip->remap_bmaddr == 0) { - snd_printk("Controller space ioremap problem\n"); + 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 ((chip->res_bm = request_region(chip->bmaddr, 128, chip->ctrl_name)) == NULL) { - snd_printk("unable to grab ports 0x%lx-0x%lx\n", chip->bmaddr, chip->bmaddr + 128 - 1); - snd_intel8x0_free(chip); - return -EBUSY; - } } 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; } @@ -1314,10 +1240,9 @@ static int __devinit snd_intel8x0m_create(snd_card_t * card, /* allocate buffer descriptor lists */ /* the start of each lists must be aligned to 8 bytes */ - memset(&chip->dma_dev, 0, sizeof(chip->dma_dev)); - chip->dma_dev.type = SNDRV_DMA_TYPE_DEV; - chip->dma_dev.dev = snd_dma_pci_data(pci); - if (snd_dma_alloc_pages(&chip->dma_dev, chip->bdbars_count * sizeof(u32) * ICH_MAX_FRAGS * 2, &chip->bdbars) < 0) { + if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), + chip->bdbars_count * sizeof(u32) * ICH_MAX_FRAGS * 2, + &chip->bdbars) < 0) { snd_intel8x0_free(chip); return -ENOMEM; } @@ -1338,11 +1263,6 @@ static int __devinit snd_intel8x0m_create(snd_card_t * card, return err; } -#ifdef CONFIG_PM - card->set_power_state = snd_intel8x0_set_power_state; - card->power_state_private_data = chip; -#endif - if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { snd_intel8x0_free(chip); return err; @@ -1358,54 +1278,41 @@ 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_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" }, -#if 0 { PCI_DEVICE_ID_SI_7013, "SiS SI7013" }, - { PCI_DEVICE_ID_NVIDIA_MCP_AUDIO, "NVidia nForce" }, - { PCI_DEVICE_ID_NVIDIA_MCP2_AUDIO, "NVidia nForce2" }, - { PCI_DEVICE_ID_NVIDIA_MCP3_AUDIO, "NVidia nForce3" }, + { 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" }, +#if 0 { 0x5455, "ALi M5455" }, { 0x746d, "AMD AMD8111" }, #endif - { 0, 0 }, + { 0 }, }; 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; + struct snd_card *card; + struct intel8x0m *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; - switch (pci_id->driver_data) { - case DEVICE_NFORCE: - strcpy(card->driver, "NFORCE"); - break; - default: - strcpy(card->driver, "ICH"); - break; - } - + strcpy(card->driver, "ICH-MODEM"); strcpy(card->shortname, "Intel ICH"); for (name = shortnames; name->id; name++) { if (pci->device == name->id) { @@ -1419,8 +1326,9 @@ 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[dev])) < 0) { + if ((err = snd_intel8x0_mixer(chip, ac97_clock)) < 0) { snd_card_free(card); return err; } @@ -1429,6 +1337,8 @@ static int __devinit snd_intel8x0m_probe(struct pci_dev *pci, return err; } + snd_intel8x0m_proc_init(chip); + sprintf(card->longname, "%s at 0x%lx, irq %i", card->shortname, chip->addr, chip->irq); @@ -1436,16 +1346,13 @@ static int __devinit snd_intel8x0m_probe(struct pci_dev *pci, snd_card_free(card); return err; } - pci_set_drvdata(pci, chip); - dev++; + pci_set_drvdata(pci, card); return 0; } static void __devexit snd_intel8x0m_remove(struct pci_dev *pci) { - intel8x0_t *chip = snd_magic_cast(intel8x0_t, pci_get_drvdata(pci), return); - if (chip) - snd_card_free(chip->card); + snd_card_free(pci_get_drvdata(pci)); pci_set_drvdata(pci, NULL); } @@ -1455,24 +1362,15 @@ static struct pci_driver driver = { .probe = snd_intel8x0m_probe, .remove = __devexit_p(snd_intel8x0m_remove), #ifdef CONFIG_PM - .suspend = snd_intel8x0m_suspend, - .resume = snd_intel8x0m_resume, + .suspend = intel8x0m_suspend, + .resume = intel8x0m_resume, #endif }; static int __init alsa_card_intel8x0m_init(void) { - int err; - - if ((err = pci_module_init(&driver)) < 0) { -#ifdef MODULE - printk(KERN_ERR "Intel ICH modemcard not found or device busy\n"); -#endif - return err; - } - - return 0; + return pci_register_driver(&driver); } static void __exit alsa_card_intel8x0m_exit(void) @@ -1482,26 +1380,3 @@ static void __exit alsa_card_intel8x0m_exit(void) module_init(alsa_card_intel8x0m_init) module_exit(alsa_card_intel8x0m_exit) - -#ifndef MODULE - -/* format is: snd-intel8x0=enable,index,id,ac97_clock,mpu_port,joystick */ - -static int __init alsa_card_intel8x0m_setup(char *str) -{ - static unsigned __initdata nr_dev = 0; - - if (nr_dev >= SNDRV_CARDS) - return 0; - (void)(get_option(&str,&enable[nr_dev]) == 2 && - get_option(&str,&index[nr_dev]) == 2 && - get_id(&str,&id[nr_dev]) == 2 && - get_option(&str,&ac97_clock[nr_dev]) == 2 - ); - nr_dev++; - return 1; -} - -__setup("snd-intel8x0m=", alsa_card_intel8x0m_setup); - -#endif /* ifndef MODULE */