X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sound%2Fdrivers%2Fvx%2Fvx_core.c;h=ed19bc17400ba8cf2112a29f7b8ff21f577b97c9;hb=97bf2856c6014879bd04983a3e9dfcdac1e7fe85;hp=c6fa5afa3e9ae3414ce5e08e0e36df38feee458a;hpb=f7f1b0f1e2fbadeab12d24236000e778aa9b1ead;p=linux-2.6.git diff --git a/sound/drivers/vx/vx_core.c b/sound/drivers/vx/vx_core.c index c6fa5afa3..ed19bc174 100644 --- a/sound/drivers/vx/vx_core.c +++ b/sound/drivers/vx/vx_core.c @@ -40,18 +40,6 @@ MODULE_DESCRIPTION("Common routines for Digigram VX drivers"); MODULE_LICENSE("GPL"); -/* - * snd_vx_delay - delay for the specified time - * @xmsec: the time to delay in msec - */ -void snd_vx_delay(vx_core_t *chip, int xmsec) -{ - if (! in_interrupt() && xmsec >= 1000 / HZ) - msleep(xmsec); - else - mdelay(xmsec); -} - /* * vx_check_reg_bit - wait for the specified bit is set/reset on a register * @reg: register to check @@ -61,7 +49,7 @@ void snd_vx_delay(vx_core_t *chip, int xmsec) * * returns zero if a bit matches, or a negative error code. */ -int snd_vx_check_reg_bit(vx_core_t *chip, int reg, int mask, int bit, int time) +int snd_vx_check_reg_bit(struct vx_core *chip, int reg, int mask, int bit, int time) { unsigned long end_time = jiffies + (time * HZ + 999) / 1000; #ifdef CONFIG_SND_DEBUG @@ -76,12 +64,14 @@ int snd_vx_check_reg_bit(vx_core_t *chip, int reg, int mask, int bit, int time) do { if ((snd_vx_inb(chip, reg) & mask) == bit) return 0; - //snd_vx_delay(chip, 10); + //msleep(10); } while (time_after_eq(end_time, jiffies)); snd_printd(KERN_DEBUG "vx_check_reg_bit: timeout, reg=%s, mask=0x%x, val=0x%x\n", reg_names[reg], mask, snd_vx_inb(chip, reg)); return -EIO; } +EXPORT_SYMBOL(snd_vx_check_reg_bit); + /* * vx_send_irq_dsp - set command irq bit * @num: the requested IRQ type, IRQ_XXX @@ -90,7 +80,7 @@ int snd_vx_check_reg_bit(vx_core_t *chip, int reg, int mask, int bit, int time) * returns 0 if successful, or a negative error code. * */ -static int vx_send_irq_dsp(vx_core_t *chip, int num) +static int vx_send_irq_dsp(struct vx_core *chip, int num) { int nirq; @@ -111,7 +101,7 @@ static int vx_send_irq_dsp(vx_core_t *chip, int num) * * returns 0 if successful, or a negative error code. */ -static int vx_reset_chk(vx_core_t *chip) +static int vx_reset_chk(struct vx_core *chip) { /* Reset irq CHK */ if (vx_send_irq_dsp(chip, IRQ_RESET_CHK) < 0) @@ -130,7 +120,7 @@ static int vx_reset_chk(vx_core_t *chip) * the error code can be VX-specific, retrieved via vx_get_error(). * NB: call with spinlock held! */ -static int vx_transfer_end(vx_core_t *chip, int cmd) +static int vx_transfer_end(struct vx_core *chip, int cmd) { int err; @@ -168,7 +158,7 @@ static int vx_transfer_end(vx_core_t *chip, int cmd) * the error code can be VX-specific, retrieved via vx_get_error(). * NB: call with spinlock held! */ -static int vx_read_status(vx_core_t *chip, struct vx_rmh *rmh) +static int vx_read_status(struct vx_core *chip, struct vx_rmh *rmh) { int i, err, val, size; @@ -248,7 +238,7 @@ static int vx_read_status(vx_core_t *chip, struct vx_rmh *rmh) * * this function doesn't call spinlock at all. */ -int vx_send_msg_nolock(vx_core_t *chip, struct vx_rmh *rmh) +int vx_send_msg_nolock(struct vx_core *chip, struct vx_rmh *rmh) { int i, err; @@ -353,7 +343,7 @@ int vx_send_msg_nolock(vx_core_t *chip, struct vx_rmh *rmh) * returns 0 if successful, or a negative error code. * see vx_send_msg_nolock(). */ -int vx_send_msg(vx_core_t *chip, struct vx_rmh *rmh) +int vx_send_msg(struct vx_core *chip, struct vx_rmh *rmh) { unsigned long flags; int err; @@ -376,7 +366,7 @@ int vx_send_msg(vx_core_t *chip, struct vx_rmh *rmh) * * unlike RMH, no command is sent to DSP. */ -int vx_send_rih_nolock(vx_core_t *chip, int cmd) +int vx_send_rih_nolock(struct vx_core *chip, int cmd) { int err; @@ -413,7 +403,7 @@ int vx_send_rih_nolock(vx_core_t *chip, int cmd) * * see vx_send_rih_nolock(). */ -int vx_send_rih(vx_core_t *chip, int cmd) +int vx_send_rih(struct vx_core *chip, int cmd) { unsigned long flags; int err; @@ -430,7 +420,7 @@ int vx_send_rih(vx_core_t *chip, int cmd) * snd_vx_boot_xilinx - boot up the xilinx interface * @boot: the boot record to load */ -int snd_vx_load_boot_image(vx_core_t *chip, const struct firmware *boot) +int snd_vx_load_boot_image(struct vx_core *chip, const struct firmware *boot) { unsigned int i; int no_fillup = vx_has_new_dsp(chip); @@ -477,12 +467,14 @@ int snd_vx_load_boot_image(vx_core_t *chip, const struct firmware *boot) return 0; } +EXPORT_SYMBOL(snd_vx_load_boot_image); + /* * vx_test_irq_src - query the source of interrupts * * called from irq handler only */ -static int vx_test_irq_src(vx_core_t *chip, unsigned int *ret) +static int vx_test_irq_src(struct vx_core *chip, unsigned int *ret) { int err; @@ -503,7 +495,7 @@ static int vx_test_irq_src(vx_core_t *chip, unsigned int *ret) */ static void vx_interrupt(unsigned long private_data) { - vx_core_t *chip = (vx_core_t *) private_data; + struct vx_core *chip = (struct vx_core *) private_data; unsigned int events; if (chip->chip_status & VX_STAT_IS_STALE) @@ -545,9 +537,9 @@ static void vx_interrupt(unsigned long private_data) /** * snd_vx_irq_handler - interrupt handler */ -irqreturn_t snd_vx_irq_handler(int irq, void *dev, struct pt_regs *regs) +irqreturn_t snd_vx_irq_handler(int irq, void *dev) { - vx_core_t *chip = dev; + struct vx_core *chip = dev; if (! (chip->chip_status & VX_STAT_CHIP_INIT) || (chip->chip_status & VX_STAT_IS_STALE)) @@ -557,10 +549,11 @@ irqreturn_t snd_vx_irq_handler(int irq, void *dev, struct pt_regs *regs) return IRQ_HANDLED; } +EXPORT_SYMBOL(snd_vx_irq_handler); /* */ -static void vx_reset_board(vx_core_t *chip, int cold_reset) +static void vx_reset_board(struct vx_core *chip, int cold_reset) { snd_assert(chip->ops->reset_board, return); @@ -599,9 +592,9 @@ static void vx_reset_board(vx_core_t *chip, int cold_reset) * proc interface */ -static void vx_proc_read(snd_info_entry_t *entry, snd_info_buffer_t *buffer) +static void vx_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) { - vx_core_t *chip = entry->private_data; + struct vx_core *chip = entry->private_data; static char *audio_src_vxp[] = { "Line", "Mic", "Digital" }; static char *audio_src_vx2[] = { "Analog", "Analog", "Digital" }; static char *clock_mode[] = { "Auto", "Internal", "External" }; @@ -642,19 +635,19 @@ static void vx_proc_read(snd_info_entry_t *entry, snd_info_buffer_t *buffer) chip->ibl.granularity); } -static void vx_proc_init(vx_core_t *chip) +static void vx_proc_init(struct vx_core *chip) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; if (! snd_card_proc_new(chip->card, "vx-status", &entry)) - snd_info_set_text_ops(entry, chip, 1024, vx_proc_read); + snd_info_set_text_ops(entry, chip, vx_proc_read); } /** * snd_vx_dsp_boot - load the DSP boot */ -int snd_vx_dsp_boot(vx_core_t *chip, const struct firmware *boot) +int snd_vx_dsp_boot(struct vx_core *chip, const struct firmware *boot) { int err; int cold_reset = !(chip->chip_status & VX_STAT_DEVICE_INIT); @@ -664,15 +657,17 @@ int snd_vx_dsp_boot(vx_core_t *chip, const struct firmware *boot) if ((err = snd_vx_load_boot_image(chip, boot)) < 0) return err; - snd_vx_delay(chip, 10); + msleep(10); return 0; } +EXPORT_SYMBOL(snd_vx_dsp_boot); + /** * snd_vx_dsp_load - load the DSP image */ -int snd_vx_dsp_load(vx_core_t *chip, const struct firmware *dsp) +int snd_vx_dsp_load(struct vx_core *chip, const struct firmware *dsp) { unsigned int i; int err; @@ -704,7 +699,7 @@ int snd_vx_dsp_load(vx_core_t *chip, const struct firmware *dsp) } snd_printdd(KERN_DEBUG "checksum = 0x%08x\n", csum); - snd_vx_delay(chip, 200); + msleep(200); if ((err = vx_wait_isr_bit(chip, ISR_CHK)) < 0) return err; @@ -717,17 +712,17 @@ int snd_vx_dsp_load(vx_core_t *chip, const struct firmware *dsp) return 0; } +EXPORT_SYMBOL(snd_vx_dsp_load); + #ifdef CONFIG_PM /* * suspend */ -static int snd_vx_suspend(snd_card_t *card, pm_message_t state) +int snd_vx_suspend(struct vx_core *chip, pm_message_t state) { - vx_core_t *chip = card->pm_private_data; unsigned int i; - snd_assert(chip, return -EINVAL); - + snd_power_change_state(chip->card, SNDRV_CTL_POWER_D3hot); chip->chip_status |= VX_STAT_IN_SUSPEND; for (i = 0; i < chip->hw->num_codecs; i++) snd_pcm_suspend_all(chip->pcm[i]); @@ -735,16 +730,15 @@ static int snd_vx_suspend(snd_card_t *card, pm_message_t state) return 0; } +EXPORT_SYMBOL(snd_vx_suspend); + /* * resume */ -static int snd_vx_resume(snd_card_t *card) +int snd_vx_resume(struct vx_core *chip) { - vx_core_t *chip = card->pm_private_data; int i, err; - snd_assert(chip, return -EINVAL); - chip->chip_status &= ~VX_STAT_CHIP_INIT; for (i = 0; i < 4; i++) { @@ -760,13 +754,15 @@ static int snd_vx_resume(snd_card_t *card) chip->chip_status |= VX_STAT_CHIP_INIT; chip->chip_status &= ~VX_STAT_IN_SUSPEND; + snd_power_change_state(chip->card, SNDRV_CTL_POWER_D0); return 0; } +EXPORT_SYMBOL(snd_vx_resume); #endif /** - * snd_vx_create - constructor for vx_core_t + * snd_vx_create - constructor for struct vx_core * @hw: hardware specific record * * this function allocates the instance and prepare for the hardware @@ -774,15 +770,15 @@ static int snd_vx_resume(snd_card_t *card) * * return the instance pointer if successful, NULL in error. */ -vx_core_t *snd_vx_create(snd_card_t *card, struct snd_vx_hardware *hw, - struct snd_vx_ops *ops, - int extra_size) +struct vx_core *snd_vx_create(struct snd_card *card, struct snd_vx_hardware *hw, + struct snd_vx_ops *ops, + int extra_size) { - vx_core_t *chip; + struct vx_core *chip; snd_assert(card && hw && ops, return NULL); - chip = kcalloc(1, sizeof(*chip) + extra_size, GFP_KERNEL); + chip = kzalloc(sizeof(*chip) + extra_size, GFP_KERNEL); if (! chip) { snd_printk(KERN_ERR "vx_core: no memory\n"); return NULL; @@ -794,20 +790,20 @@ vx_core_t *snd_vx_create(snd_card_t *card, struct snd_vx_hardware *hw, chip->type = hw->type; chip->ops = ops; tasklet_init(&chip->tq, vx_interrupt, (unsigned long)chip); - init_MUTEX(&chip->mixer_mutex); + mutex_init(&chip->mixer_mutex); chip->card = card; card->private_data = chip; strcpy(card->driver, hw->name); sprintf(card->shortname, "Digigram %s", hw->name); - snd_card_set_pm_callback(card, snd_vx_suspend, snd_vx_resume, chip); - vx_proc_init(chip); return chip; } +EXPORT_SYMBOL(snd_vx_create); + /* * module entries */ @@ -822,16 +818,3 @@ static void __exit alsa_vx_core_exit(void) module_init(alsa_vx_core_init) module_exit(alsa_vx_core_exit) - -/* - * exports - */ -EXPORT_SYMBOL(snd_vx_check_reg_bit); -EXPORT_SYMBOL(snd_vx_create); -EXPORT_SYMBOL(snd_vx_setup_firmware); -EXPORT_SYMBOL(snd_vx_free_firmware); -EXPORT_SYMBOL(snd_vx_irq_handler); -EXPORT_SYMBOL(snd_vx_delay); -EXPORT_SYMBOL(snd_vx_dsp_boot); -EXPORT_SYMBOL(snd_vx_dsp_load); -EXPORT_SYMBOL(snd_vx_load_boot_image);