X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sound%2Fsparc%2Fcs4231.c;h=36f9fe4d7beac9c76a3091311bd346fc827feb63;hb=6a77f38946aaee1cd85eeec6cf4229b204c15071;hp=00a845e28b8569053f1335205a42adc1d18995c5;hpb=9213980e6a70d8473e0ffd4b39ab5b6caaba9ff5;p=linux-2.6.git diff --git a/sound/sparc/cs4231.c b/sound/sparc/cs4231.c index 00a845e28..36f9fe4d7 100644 --- a/sound/sparc/cs4231.c +++ b/sound/sparc/cs4231.c @@ -49,26 +49,21 @@ 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 boot_devs; -module_param_array(index, int, boot_devs, 0444); +module_param_array(index, int, NULL, 0444); MODULE_PARM_DESC(index, "Index value for Sun CS4231 soundcard."); -MODULE_PARM_SYNTAX(index, SNDRV_INDEX_DESC); -module_param_array(id, charp, boot_devs, 0444); +module_param_array(id, charp, NULL, 0444); MODULE_PARM_DESC(id, "ID string for Sun CS4231 soundcard."); -MODULE_PARM_SYNTAX(id, SNDRV_ID_DESC); -module_param_array(enable, bool, boot_devs, 0444); +module_param_array(enable, bool, NULL, 0444); MODULE_PARM_DESC(enable, "Enable Sun CS4231 soundcard."); -MODULE_PARM_SYNTAX(enable, SNDRV_ENABLE_DESC); MODULE_AUTHOR("Jaroslav Kysela, Derrick J. Brashear and David S. Miller"); MODULE_DESCRIPTION("Sun CS4231"); MODULE_LICENSE("GPL"); -MODULE_CLASSES("{sound}"); -MODULE_DEVICES("{{Sun,CS4231}}"); +MODULE_SUPPORTED_DEVICE("{{Sun,CS4231}}"); typedef struct snd_cs4231 { spinlock_t lock; - unsigned long port; + void __iomem *port; #ifdef EBUS_SUPPORT struct ebus_dma_info eb2c; struct ebus_dma_info eb2p; @@ -112,7 +107,6 @@ typedef struct snd_cs4231 { unsigned int regs_size; struct snd_cs4231 *next; } cs4231_t; -#define chip_t cs4231_t static cs4231_t *cs4231_list; @@ -362,7 +356,7 @@ static unsigned char snd_cs4231_original_image[32] = 0x00, /* 1f/31 - cbrl */ }; -static u8 __cs4231_readb(cs4231_t *cp, unsigned long reg_addr) +static u8 __cs4231_readb(cs4231_t *cp, void __iomem *reg_addr) { #ifdef EBUS_SUPPORT if (cp->flags & CS4231_FLAG_EBUS) { @@ -377,7 +371,7 @@ static u8 __cs4231_readb(cs4231_t *cp, unsigned long reg_addr) #endif } -static void __cs4231_writeb(cs4231_t *cp, u8 val, unsigned long reg_addr) +static void __cs4231_writeb(cs4231_t *cp, u8 val, void __iomem *reg_addr) { #ifdef EBUS_SUPPORT if (cp->flags & CS4231_FLAG_EBUS) { @@ -396,7 +390,7 @@ static void __cs4231_writeb(cs4231_t *cp, u8 val, unsigned long reg_addr) * Basic I/O functions */ -void snd_cs4231_outm(cs4231_t *chip, unsigned char reg, +static void snd_cs4231_outm(cs4231_t *chip, unsigned char reg, unsigned char mask, unsigned char value) { int timeout; @@ -479,9 +473,9 @@ static unsigned char snd_cs4231_in(cs4231_t *chip, unsigned char reg) return ret; } -#ifdef CONFIG_SND_DEBUG +#if 0 -void snd_cs4231_debug(cs4231_t *chip) +static void snd_cs4231_debug(cs4231_t *chip) { printk("CS4231 REGS: INDEX = 0x%02x ", __cs4231_readb(chip, CS4231P(chip, REGSEL))); @@ -556,7 +550,7 @@ static void snd_cs4231_mce_up(cs4231_t *chip) chip->mce_bit |= CS4231_MCE; timeout = __cs4231_readb(chip, CS4231P(chip, REGSEL)); if (timeout == 0x80) - snd_printk("mce_up [0x%lx]: serious init problem - codec still busy\n", chip->port); + snd_printk("mce_up [%p]: serious init problem - codec still busy\n", chip->port); if (!(timeout & CS4231_MCE)) __cs4231_writeb(chip, chip->mce_bit | (timeout & 0x1f), CS4231P(chip, REGSEL)); spin_unlock_irqrestore(&chip->lock, flags); @@ -566,7 +560,6 @@ static void snd_cs4231_mce_down(cs4231_t *chip) { unsigned long flags; int timeout; - signed long time; spin_lock_irqsave(&chip->lock, flags); snd_cs4231_busy_wait(chip); @@ -575,13 +568,13 @@ static void snd_cs4231_mce_down(cs4231_t *chip) #endif #ifdef CONFIG_SND_DEBUG if (__cs4231_readb(chip, CS4231P(chip, REGSEL)) & CS4231_INIT) - snd_printk("mce_down [0x%lx] - auto calibration time out (0)\n", CS4231P(chip, REGSEL)); + snd_printk("mce_down [%p] - auto calibration time out (0)\n", CS4231P(chip, REGSEL)); #endif chip->mce_bit &= ~CS4231_MCE; timeout = __cs4231_readb(chip, CS4231P(chip, REGSEL)); __cs4231_writeb(chip, chip->mce_bit | (timeout & 0x1f), CS4231P(chip, REGSEL)); if (timeout == 0x80) - snd_printk("mce_down [0x%lx]: serious init problem - codec still busy\n", chip->port); + snd_printk("mce_down [%p]: serious init problem - codec still busy\n", chip->port); if ((timeout & CS4231_MCE) == 0) { spin_unlock_irqrestore(&chip->lock, flags); return; @@ -600,29 +593,29 @@ static void snd_cs4231_mce_down(cs4231_t *chip) #if 0 printk("(2) timeout = %i, jiffies = %li\n", timeout, jiffies); #endif - time = HZ / 4; + /* in 10ms increments, check condition, up to 250ms */ + timeout = 25; while (snd_cs4231_in(chip, CS4231_TEST_INIT) & CS4231_CALIB_IN_PROGRESS) { spin_unlock_irqrestore(&chip->lock, flags); - if (time <= 0) { + if (--timeout < 0) { snd_printk("mce_down - auto calibration time out (2)\n"); return; } - set_current_state(TASK_INTERRUPTIBLE); - time = schedule_timeout(time); + msleep(10); spin_lock_irqsave(&chip->lock, flags); } #if 0 printk("(3) jiffies = %li\n", jiffies); #endif - time = HZ / 10; + /* in 10ms increments, check condition, up to 100ms */ + timeout = 10; while (__cs4231_readb(chip, CS4231P(chip, REGSEL)) & CS4231_INIT) { spin_unlock_irqrestore(&chip->lock, flags); - if (time <= 0) { + if (--timeout < 0) { snd_printk("mce_down - auto calibration time out (3)\n"); return; } - set_current_state(TASK_INTERRUPTIBLE); - time = schedule_timeout(time); + msleep(10); spin_lock_irqsave(&chip->lock, flags); } spin_unlock_irqrestore(&chip->lock, flags); @@ -1232,7 +1225,7 @@ static void snd_cs4231_generic_interrupt(cs4231_t *chip) #ifdef SBUS_SUPPORT static irqreturn_t snd_cs4231_sbus_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - cs4231_t *chip = snd_magic_cast(cs4231_t, dev_id, return); + cs4231_t *chip = dev_id; u32 csr; csr = sbus_readl(chip->port + APCCSR); @@ -1256,7 +1249,7 @@ static irqreturn_t snd_cs4231_sbus_interrupt(int irq, void *dev_id, struct pt_re #ifdef EBUS_SUPPORT static void snd_cs4231_ebus_play_callback(struct ebus_dma_info *p, int event, void *cookie) { - cs4231_t *chip = snd_magic_cast(cs4231_t, cookie, return); + cs4231_t *chip = cookie; if (chip->image[CS4231_IFACE_CTRL] & CS4231_PLAYBACK_ENABLE) { snd_pcm_period_elapsed(chip->playback_substream); @@ -1267,7 +1260,7 @@ static void snd_cs4231_ebus_play_callback(struct ebus_dma_info *p, int event, vo static void snd_cs4231_ebus_capture_callback(struct ebus_dma_info *p, int event, void *cookie) { - cs4231_t *chip = snd_magic_cast(cs4231_t, cookie, return); + cs4231_t *chip = cookie; if (chip->image[CS4231_IFACE_CTRL] & CS4231_RECORD_ENABLE) { snd_pcm_period_elapsed(chip->capture_substream); @@ -1353,7 +1346,7 @@ static int snd_cs4231_probe(cs4231_t *chip) break; /* this is valid value */ } } - snd_printdd("cs4231: port = 0x%lx, id = 0x%x\n", chip->port, id); + snd_printdd("cs4231: port = %p, id = 0x%x\n", chip->port, id); if (id != 0x0a) return -ENODEV; /* no valid device found */ @@ -1547,7 +1540,7 @@ static snd_pcm_ops_t snd_cs4231_capture_ops = { static void snd_cs4231_pcm_free(snd_pcm_t *pcm) { - cs4231_t *chip = snd_magic_cast(cs4231_t, pcm->private_data, return); + cs4231_t *chip = pcm->private_data; chip->pcm = NULL; snd_pcm_lib_preallocate_free_for_all(pcm); } @@ -1592,7 +1585,7 @@ int snd_cs4231_pcm(cs4231_t *chip) static void snd_cs4231_timer_free(snd_timer_t *timer) { - cs4231_t *chip = snd_magic_cast(cs4231_t, timer->private_data, return); + cs4231_t *chip = timer->private_data; chip->timer = NULL; } @@ -1821,8 +1814,6 @@ int snd_cs4231_put_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontr return change; } -#define CS4231_CONTROLS (sizeof(snd_cs4231_controls)/sizeof(snd_kcontrol_new_t)) - #define CS4231_SINGLE(xname, xindex, reg, shift, mask, invert) \ { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \ .info = snd_cs4231_info_single, \ @@ -1875,7 +1866,7 @@ int snd_cs4231_mixer(cs4231_t *chip) strcpy(card->mixername, chip->pcm->name); - for (idx = 0; idx < CS4231_CONTROLS; idx++) { + for (idx = 0; idx < ARRAY_SIZE(snd_cs4231_controls); idx++) { if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_cs4231_controls[idx], chip))) < 0) @@ -1950,14 +1941,14 @@ static int snd_cs4231_sbus_free(cs4231_t *chip) if (chip->timer) snd_device_free(chip->card, chip->timer); - snd_magic_kfree(chip); + kfree(chip); return 0; } static int snd_cs4231_sbus_dev_free(snd_device_t *device) { - cs4231_t *cp = snd_magic_cast(cs4231_t, device->device_data, return -ENXIO); + cs4231_t *cp = device->device_data; return snd_cs4231_sbus_free(cp); } @@ -1975,7 +1966,7 @@ static int __init snd_cs4231_sbus_create(snd_card_t *card, int err; *rchip = NULL; - chip = snd_magic_kcalloc(cs4231_t, 0, GFP_KERNEL); + chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); if (chip == NULL) return -ENOMEM; @@ -2064,14 +2055,14 @@ static int snd_cs4231_ebus_free(cs4231_t *chip) if (chip->timer) snd_device_free(chip->card, chip->timer); - snd_magic_kfree(chip); + kfree(chip); return 0; } static int snd_cs4231_ebus_dev_free(snd_device_t *device) { - cs4231_t *cp = snd_magic_cast(cs4231_t, device->device_data, return -ENXIO); + cs4231_t *cp = device->device_data; return snd_cs4231_ebus_free(cp); } @@ -2089,7 +2080,7 @@ static int __init snd_cs4231_ebus_create(snd_card_t *card, int err; *rchip = NULL; - chip = snd_magic_kcalloc(cs4231_t, 0, GFP_KERNEL); + chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); if (chip == NULL) return -ENOMEM; @@ -2114,9 +2105,9 @@ static int __init snd_cs4231_ebus_create(snd_card_t *card, chip->eb2p.client_cookie = chip; chip->eb2p.irq = edev->irqs[1]; - chip->port = (unsigned long) ioremap(edev->resource[0].start, 0x10); - chip->eb2p.regs = (unsigned long) ioremap(edev->resource[1].start, 0x10); - chip->eb2c.regs = (unsigned long) ioremap(edev->resource[2].start, 0x10); + chip->port = ioremap(edev->resource[0].start, 0x10); + chip->eb2p.regs = ioremap(edev->resource[1].start, 0x10); + chip->eb2c.regs = ioremap(edev->resource[2].start, 0x10); if (!chip->port || !chip->eb2p.regs || !chip->eb2c.regs) { snd_cs4231_ebus_free(chip); snd_printk("cs4231-%d: Unable to map chip registers.\n", dev);