ALSA: vx_core: Use standard print API

Use the standard print API with dev_*() instead of the old house-baked
one.  It gives better information and allows dynamically control of
debug prints.

The commented old debug prints are dropped, too.

Reviewed-by: Jaroslav Kysela <perex@perex.cz>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://patch.msgid.link/20240807133452.9424-12-tiwai@suse.de
This commit is contained in:
Takashi Iwai 2024-08-07 15:34:01 +02:00
parent b426b3ba9f
commit 41abc8056d
4 changed files with 44 additions and 48 deletions

View File

@ -52,7 +52,9 @@ int snd_vx_check_reg_bit(struct vx_core *chip, int reg, int mask, int bit, int t
return 0; return 0;
//msleep(10); //msleep(10);
} while (time_after_eq(end_time, jiffies)); } 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)); dev_dbg(chip->card->dev,
"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; return -EIO;
} }
@ -129,13 +131,14 @@ static int vx_transfer_end(struct vx_core *chip, int cmd)
if (err & ISR_ERR) { if (err & ISR_ERR) {
err = vx_wait_for_rx_full(chip); err = vx_wait_for_rx_full(chip);
if (err < 0) { if (err < 0) {
snd_printd(KERN_DEBUG "transfer_end: error in rx_full\n"); dev_dbg(chip->card->dev,
"transfer_end: error in rx_full\n");
return err; return err;
} }
err = vx_inb(chip, RXH) << 16; err = vx_inb(chip, RXH) << 16;
err |= vx_inb(chip, RXM) << 8; err |= vx_inb(chip, RXM) << 8;
err |= vx_inb(chip, RXL); err |= vx_inb(chip, RXL);
snd_printd(KERN_DEBUG "transfer_end: error = 0x%x\n", err); dev_dbg(chip->card->dev, "transfer_end: error = 0x%x\n", err);
return -(VX_ERR_MASK | err); return -(VX_ERR_MASK | err);
} }
return 0; return 0;
@ -239,20 +242,10 @@ int vx_send_msg_nolock(struct vx_core *chip, struct vx_rmh *rmh)
err = vx_reset_chk(chip); err = vx_reset_chk(chip);
if (err < 0) { if (err < 0) {
snd_printd(KERN_DEBUG "vx_send_msg: vx_reset_chk error\n"); dev_dbg(chip->card->dev, "vx_send_msg: vx_reset_chk error\n");
return err; return err;
} }
#if 0
printk(KERN_DEBUG "rmh: cmd = 0x%06x, length = %d, stype = %d\n",
rmh->Cmd[0], rmh->LgCmd, rmh->DspStat);
if (rmh->LgCmd > 1) {
printk(KERN_DEBUG " ");
for (i = 1; i < rmh->LgCmd; i++)
printk(KERN_CONT "0x%06x ", rmh->Cmd[i]);
printk(KERN_CONT "\n");
}
#endif
/* Check bit M is set according to length of the command */ /* Check bit M is set according to length of the command */
if (rmh->LgCmd > 1) if (rmh->LgCmd > 1)
rmh->Cmd[0] |= MASK_MORE_THAN_1_WORD_COMMAND; rmh->Cmd[0] |= MASK_MORE_THAN_1_WORD_COMMAND;
@ -262,7 +255,7 @@ int vx_send_msg_nolock(struct vx_core *chip, struct vx_rmh *rmh)
/* Wait for TX empty */ /* Wait for TX empty */
err = vx_wait_isr_bit(chip, ISR_TX_EMPTY); err = vx_wait_isr_bit(chip, ISR_TX_EMPTY);
if (err < 0) { if (err < 0) {
snd_printd(KERN_DEBUG "vx_send_msg: wait tx empty error\n"); dev_dbg(chip->card->dev, "vx_send_msg: wait tx empty error\n");
return err; return err;
} }
@ -274,7 +267,8 @@ int vx_send_msg_nolock(struct vx_core *chip, struct vx_rmh *rmh)
/* Trigger irq MESSAGE */ /* Trigger irq MESSAGE */
err = vx_send_irq_dsp(chip, IRQ_MESSAGE); err = vx_send_irq_dsp(chip, IRQ_MESSAGE);
if (err < 0) { if (err < 0) {
snd_printd(KERN_DEBUG "vx_send_msg: send IRQ_MESSAGE error\n"); dev_dbg(chip->card->dev,
"vx_send_msg: send IRQ_MESSAGE error\n");
return err; return err;
} }
@ -287,13 +281,15 @@ int vx_send_msg_nolock(struct vx_core *chip, struct vx_rmh *rmh)
if (vx_inb(chip, ISR) & ISR_ERR) { if (vx_inb(chip, ISR) & ISR_ERR) {
err = vx_wait_for_rx_full(chip); err = vx_wait_for_rx_full(chip);
if (err < 0) { if (err < 0) {
snd_printd(KERN_DEBUG "vx_send_msg: rx_full read error\n"); dev_dbg(chip->card->dev,
"vx_send_msg: rx_full read error\n");
return err; return err;
} }
err = vx_inb(chip, RXH) << 16; err = vx_inb(chip, RXH) << 16;
err |= vx_inb(chip, RXM) << 8; err |= vx_inb(chip, RXM) << 8;
err |= vx_inb(chip, RXL); err |= vx_inb(chip, RXL);
snd_printd(KERN_DEBUG "msg got error = 0x%x at cmd[0]\n", err); dev_dbg(chip->card->dev,
"msg got error = 0x%x at cmd[0]\n", err);
err = -(VX_ERR_MASK | err); err = -(VX_ERR_MASK | err);
return err; return err;
} }
@ -304,7 +300,8 @@ int vx_send_msg_nolock(struct vx_core *chip, struct vx_rmh *rmh)
/* Wait for TX ready */ /* Wait for TX ready */
err = vx_wait_isr_bit(chip, ISR_TX_READY); err = vx_wait_isr_bit(chip, ISR_TX_READY);
if (err < 0) { if (err < 0) {
snd_printd(KERN_DEBUG "vx_send_msg: tx_ready error\n"); dev_dbg(chip->card->dev,
"vx_send_msg: tx_ready error\n");
return err; return err;
} }
@ -316,14 +313,16 @@ int vx_send_msg_nolock(struct vx_core *chip, struct vx_rmh *rmh)
/* Trigger irq MESS_READ_NEXT */ /* Trigger irq MESS_READ_NEXT */
err = vx_send_irq_dsp(chip, IRQ_MESS_READ_NEXT); err = vx_send_irq_dsp(chip, IRQ_MESS_READ_NEXT);
if (err < 0) { if (err < 0) {
snd_printd(KERN_DEBUG "vx_send_msg: IRQ_READ_NEXT error\n"); dev_dbg(chip->card->dev,
"vx_send_msg: IRQ_READ_NEXT error\n");
return err; return err;
} }
} }
/* Wait for TX empty */ /* Wait for TX empty */
err = vx_wait_isr_bit(chip, ISR_TX_READY); err = vx_wait_isr_bit(chip, ISR_TX_READY);
if (err < 0) { if (err < 0) {
snd_printd(KERN_DEBUG "vx_send_msg: TX_READY error\n"); dev_dbg(chip->card->dev,
"vx_send_msg: TX_READY error\n");
return err; return err;
} }
/* End of transfer */ /* End of transfer */
@ -372,9 +371,6 @@ int vx_send_rih_nolock(struct vx_core *chip, int cmd)
if (chip->chip_status & VX_STAT_IS_STALE) if (chip->chip_status & VX_STAT_IS_STALE)
return -EBUSY; return -EBUSY;
#if 0
printk(KERN_DEBUG "send_rih: cmd = 0x%x\n", cmd);
#endif
err = vx_reset_chk(chip); err = vx_reset_chk(chip);
if (err < 0) if (err < 0)
return err; return err;
@ -453,7 +449,7 @@ int snd_vx_load_boot_image(struct vx_core *chip, const struct firmware *boot)
if (no_fillup) if (no_fillup)
break; break;
if (vx_wait_isr_bit(chip, ISR_TX_EMPTY) < 0) { if (vx_wait_isr_bit(chip, ISR_TX_EMPTY) < 0) {
snd_printk(KERN_ERR "dsp boot failed at %d\n", i); dev_err(chip->card->dev, "dsp boot failed at %d\n", i);
return -EIO; return -EIO;
} }
vx_outb(chip, TXH, 0); vx_outb(chip, TXH, 0);
@ -462,7 +458,7 @@ int snd_vx_load_boot_image(struct vx_core *chip, const struct firmware *boot)
} else { } else {
const unsigned char *image = boot->data + i; const unsigned char *image = boot->data + i;
if (vx_wait_isr_bit(chip, ISR_TX_EMPTY) < 0) { if (vx_wait_isr_bit(chip, ISR_TX_EMPTY) < 0) {
snd_printk(KERN_ERR "dsp boot failed at %d\n", i); dev_err(chip->card->dev, "dsp boot failed at %d\n", i);
return -EIO; return -EIO;
} }
vx_outb(chip, TXH, image[0]); vx_outb(chip, TXH, image[0]);
@ -510,18 +506,12 @@ irqreturn_t snd_vx_threaded_irq_handler(int irq, void *dev)
if (vx_test_irq_src(chip, &events) < 0) if (vx_test_irq_src(chip, &events) < 0)
return IRQ_HANDLED; return IRQ_HANDLED;
#if 0
if (events & 0x000800)
printk(KERN_ERR "DSP Stream underrun ! IRQ events = 0x%x\n", events);
#endif
// printk(KERN_DEBUG "IRQ events = 0x%x\n", events);
/* We must prevent any application using this DSP /* We must prevent any application using this DSP
* and block any further request until the application * and block any further request until the application
* either unregisters or reloads the DSP * either unregisters or reloads the DSP
*/ */
if (events & FATAL_DSP_ERROR) { if (events & FATAL_DSP_ERROR) {
snd_printk(KERN_ERR "vx_core: fatal DSP error!!\n"); dev_err(chip->card->dev, "vx_core: fatal DSP error!!\n");
return IRQ_HANDLED; return IRQ_HANDLED;
} }
@ -698,8 +688,8 @@ int snd_vx_dsp_load(struct vx_core *chip, const struct firmware *dsp)
/* Wait DSP ready for a new read */ /* Wait DSP ready for a new read */
err = vx_wait_isr_bit(chip, ISR_TX_EMPTY); err = vx_wait_isr_bit(chip, ISR_TX_EMPTY);
if (err < 0) { if (err < 0) {
printk(KERN_ERR dev_err(chip->card->dev,
"dsp loading error at position %d\n", i); "dsp loading error at position %d\n", i);
return err; return err;
} }
cptr = image; cptr = image;
@ -713,7 +703,6 @@ int snd_vx_dsp_load(struct vx_core *chip, const struct firmware *dsp)
csum = (csum >> 24) | (csum << 8); csum = (csum >> 24) | (csum << 8);
vx_outb(chip, TXL, *cptr++); vx_outb(chip, TXL, *cptr++);
} }
snd_printdd(KERN_DEBUG "checksum = 0x%08x\n", csum);
msleep(200); msleep(200);
@ -759,7 +748,8 @@ int snd_vx_resume(struct vx_core *chip)
continue; continue;
err = chip->ops->load_dsp(chip, i, chip->firmware[i]); err = chip->ops->load_dsp(chip, i, chip->firmware[i]);
if (err < 0) { if (err < 0) {
snd_printk(KERN_ERR "vx: firmware resume error at DSP %d\n", i); dev_err(chip->card->dev,
"vx: firmware resume error at DSP %d\n", i);
return -EIO; return -EIO;
} }
} }

View File

@ -59,7 +59,7 @@ int snd_vx_setup_firmware(struct vx_core *chip)
continue; continue;
sprintf(path, "vx/%s", fw_files[chip->type][i]); sprintf(path, "vx/%s", fw_files[chip->type][i]);
if (request_firmware(&fw, path, chip->card->dev)) { if (request_firmware(&fw, path, chip->card->dev)) {
snd_printk(KERN_ERR "vx: can't load firmware %s\n", path); dev_err(chip->card->dev, "vx: can't load firmware %s\n", path);
return -ENOENT; return -ENOENT;
} }
err = chip->ops->load_dsp(chip, i, fw); err = chip->ops->load_dsp(chip, i, fw);

View File

@ -190,8 +190,10 @@ static int vx_set_ibl(struct vx_core *chip, struct vx_ibl_info *info)
info->max_size = rmh.Stat[1]; info->max_size = rmh.Stat[1];
info->min_size = rmh.Stat[2]; info->min_size = rmh.Stat[2];
info->granularity = rmh.Stat[3]; info->granularity = rmh.Stat[3];
snd_printdd(KERN_DEBUG "vx_set_ibl: size = %d, max = %d, min = %d, gran = %d\n", dev_dbg(chip->card->dev,
info->size, info->max_size, info->min_size, info->granularity); "%s: size = %d, max = %d, min = %d, gran = %d\n",
__func__, info->size, info->max_size, info->min_size,
info->granularity);
return 0; return 0;
} }
@ -616,12 +618,12 @@ static int vx_pcm_playback_transfer_chunk(struct vx_core *chip,
if (space < 0) { if (space < 0) {
/* disconnect the host, SIZE_HBUF command always switches to the stream mode */ /* disconnect the host, SIZE_HBUF command always switches to the stream mode */
vx_send_rih(chip, IRQ_CONNECT_STREAM_NEXT); vx_send_rih(chip, IRQ_CONNECT_STREAM_NEXT);
snd_printd("error hbuffer\n"); dev_dbg(chip->card->dev, "error hbuffer\n");
return space; return space;
} }
if (space < size) { if (space < size) {
vx_send_rih(chip, IRQ_CONNECT_STREAM_NEXT); vx_send_rih(chip, IRQ_CONNECT_STREAM_NEXT);
snd_printd("no enough hbuffer space %d\n", space); dev_dbg(chip->card->dev, "no enough hbuffer space %d\n", space);
return -EIO; /* XRUN */ return -EIO; /* XRUN */
} }
@ -795,7 +797,8 @@ static int vx_pcm_prepare(struct snd_pcm_substream *subs)
/* IEC958 status (raw-mode) was changed */ /* IEC958 status (raw-mode) was changed */
/* we reopen the pipe */ /* we reopen the pipe */
struct vx_rmh rmh; struct vx_rmh rmh;
snd_printdd(KERN_DEBUG "reopen the pipe with data_mode = %d\n", data_mode); dev_dbg(chip->card->dev,
"reopen the pipe with data_mode = %d\n", data_mode);
vx_init_rmh(&rmh, CMD_FREE_PIPE); vx_init_rmh(&rmh, CMD_FREE_PIPE);
vx_set_pipe_cmd_params(&rmh, 0, pipe->number, 0); vx_set_pipe_cmd_params(&rmh, 0, pipe->number, 0);
err = vx_send_msg(chip, &rmh); err = vx_send_msg(chip, &rmh);
@ -812,8 +815,9 @@ static int vx_pcm_prepare(struct snd_pcm_substream *subs)
} }
if (chip->pcm_running && chip->freq != runtime->rate) { if (chip->pcm_running && chip->freq != runtime->rate) {
snd_printk(KERN_ERR "vx: cannot set different clock %d " dev_err(chip->card->dev,
"from the current %d\n", runtime->rate, chip->freq); "vx: cannot set different clock %d from the current %d\n",
runtime->rate, chip->freq);
return -EINVAL; return -EINVAL;
} }
vx_set_clock(chip, runtime->rate); vx_set_clock(chip, runtime->rate);
@ -1091,7 +1095,7 @@ void vx_pcm_update_intr(struct vx_core *chip, unsigned int events)
chip->irq_rmh.Cmd[0] |= 0x00000002; /* SEL_END_OF_BUF_EVENTS */ chip->irq_rmh.Cmd[0] |= 0x00000002; /* SEL_END_OF_BUF_EVENTS */
if (vx_send_msg(chip, &chip->irq_rmh) < 0) { if (vx_send_msg(chip, &chip->irq_rmh) < 0) {
snd_printdd(KERN_ERR "msg send error!!\n"); dev_dbg(chip->card->dev, "msg send error!!\n");
return; return;
} }
@ -1141,7 +1145,8 @@ static int vx_init_audio_io(struct vx_core *chip)
vx_init_rmh(&rmh, CMD_SUPPORTED); vx_init_rmh(&rmh, CMD_SUPPORTED);
if (vx_send_msg(chip, &rmh) < 0) { if (vx_send_msg(chip, &rmh) < 0) {
snd_printk(KERN_ERR "vx: cannot get the supported audio data\n"); dev_err(chip->card->dev,
"vx: cannot get the supported audio data\n");
return -ENXIO; return -ENXIO;
} }

View File

@ -196,7 +196,8 @@ void vx_set_internal_clock(struct vx_core *chip, unsigned int freq)
/* Get real clock value */ /* Get real clock value */
clock = vx_calc_clock_from_freq(chip, freq); clock = vx_calc_clock_from_freq(chip, freq);
snd_printdd(KERN_DEBUG "set internal clock to 0x%x from freq %d\n", clock, freq); dev_dbg(chip->card->dev,
"set internal clock to 0x%x from freq %d\n", clock, freq);
mutex_lock(&chip->lock); mutex_lock(&chip->lock);
if (vx_is_pcmcia(chip)) { if (vx_is_pcmcia(chip)) {
vx_outb(chip, HIFREQ, (clock >> 8) & 0x0f); vx_outb(chip, HIFREQ, (clock >> 8) & 0x0f);