Commit 41abc805 authored by Takashi Iwai's avatar Takashi Iwai
Browse files

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: default avatarJaroslav Kysela <perex@perex.cz>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
Link: https://patch.msgid.link/20240807133452.9424-12-tiwai@suse.de
parent b426b3ba
Loading
Loading
Loading
Loading
+27 −37
Original line number Diff line number Diff line
@@ -52,7 +52,9 @@ int snd_vx_check_reg_bit(struct vx_core *chip, int reg, int mask, int bit, int t
			return 0;
		//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));
	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;
}

@@ -129,13 +131,14 @@ static int vx_transfer_end(struct vx_core *chip, int cmd)
	if (err & ISR_ERR) {
		err = vx_wait_for_rx_full(chip);
		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;
		}
		err = vx_inb(chip, RXH) << 16;
		err |= vx_inb(chip, RXM) << 8;
		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 0;
@@ -239,20 +242,10 @@ int vx_send_msg_nolock(struct vx_core *chip, struct vx_rmh *rmh)

	err = vx_reset_chk(chip);
	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;
	}

#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 */
	if (rmh->LgCmd > 1)
		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 */
	err = vx_wait_isr_bit(chip, ISR_TX_EMPTY);
	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;
	}

@@ -274,7 +267,8 @@ int vx_send_msg_nolock(struct vx_core *chip, struct vx_rmh *rmh)
	/* Trigger irq MESSAGE */
	err = vx_send_irq_dsp(chip, IRQ_MESSAGE);
	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;
	}

@@ -287,13 +281,15 @@ int vx_send_msg_nolock(struct vx_core *chip, struct vx_rmh *rmh)
	if (vx_inb(chip, ISR) & ISR_ERR) {
		err = vx_wait_for_rx_full(chip);
		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;
		}
		err = vx_inb(chip, RXH) << 16;
		err |= vx_inb(chip, RXM) << 8;
		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);
		return err;
	}
@@ -304,7 +300,8 @@ int vx_send_msg_nolock(struct vx_core *chip, struct vx_rmh *rmh)
			/* Wait for TX ready */
			err = vx_wait_isr_bit(chip, ISR_TX_READY);
			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;
			}

@@ -316,14 +313,16 @@ int vx_send_msg_nolock(struct vx_core *chip, struct vx_rmh *rmh)
			/* Trigger irq MESS_READ_NEXT */
			err = vx_send_irq_dsp(chip, IRQ_MESS_READ_NEXT);
			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;
			}
		}
		/* Wait for TX empty */
		err = vx_wait_isr_bit(chip, ISR_TX_READY);
		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;
		}
		/* 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)
		return -EBUSY;

#if 0
	printk(KERN_DEBUG "send_rih: cmd = 0x%x\n", cmd);
#endif
	err = vx_reset_chk(chip);
	if (err < 0)
		return err;
@@ -453,7 +449,7 @@ int snd_vx_load_boot_image(struct vx_core *chip, const struct firmware *boot)
			if (no_fillup)
				break;
			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;
			}
			vx_outb(chip, TXH, 0);
@@ -462,7 +458,7 @@ int snd_vx_load_boot_image(struct vx_core *chip, const struct firmware *boot)
		} else {
			const unsigned char *image = boot->data + i;
			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;
			}
			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)
		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
	 * and block any further request until the application
	 * either unregisters or reloads the DSP
	 */
	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;
	}

@@ -698,7 +688,7 @@ int snd_vx_dsp_load(struct vx_core *chip, const struct firmware *dsp)
		/* Wait DSP ready for a new read */
		err = vx_wait_isr_bit(chip, ISR_TX_EMPTY);
		if (err < 0) {
			printk(KERN_ERR
			dev_err(chip->card->dev,
				"dsp loading error at position %d\n", i);
			return err;
		}
@@ -713,7 +703,6 @@ int snd_vx_dsp_load(struct vx_core *chip, const struct firmware *dsp)
		csum = (csum >> 24) | (csum << 8);
		vx_outb(chip, TXL, *cptr++);
	}
	snd_printdd(KERN_DEBUG "checksum = 0x%08x\n", csum);

	msleep(200);

@@ -759,7 +748,8 @@ int snd_vx_resume(struct vx_core *chip)
			continue;
		err = chip->ops->load_dsp(chip, i, chip->firmware[i]);
		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;
		}
	}
+1 −1
Original line number Diff line number Diff line
@@ -59,7 +59,7 @@ int snd_vx_setup_firmware(struct vx_core *chip)
			continue;
		sprintf(path, "vx/%s", fw_files[chip->type][i]);
		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;
		}
		err = chip->ops->load_dsp(chip, i, fw);
+14 −9
Original line number Diff line number Diff line
@@ -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->min_size = rmh.Stat[2];
	info->granularity = rmh.Stat[3];
	snd_printdd(KERN_DEBUG "vx_set_ibl: size = %d, max = %d, min = %d, gran = %d\n",
		   info->size, info->max_size, info->min_size, info->granularity);
	dev_dbg(chip->card->dev,
		"%s: size = %d, max = %d, min = %d, gran = %d\n",
		__func__, info->size, info->max_size, info->min_size,
		info->granularity);
	return 0;
}

@@ -616,12 +618,12 @@ static int vx_pcm_playback_transfer_chunk(struct vx_core *chip,
	if (space < 0) {
		/* disconnect the host, SIZE_HBUF command always switches to the stream mode */
		vx_send_rih(chip, IRQ_CONNECT_STREAM_NEXT);
		snd_printd("error hbuffer\n");
		dev_dbg(chip->card->dev, "error hbuffer\n");
		return space;
	}
	if (space < size) {
		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 */
	}
		
@@ -795,7 +797,8 @@ static int vx_pcm_prepare(struct snd_pcm_substream *subs)
		/* IEC958 status (raw-mode) was changed */
		/* we reopen the pipe */
		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_set_pipe_cmd_params(&rmh, 0, pipe->number, 0);
		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) {
		snd_printk(KERN_ERR "vx: cannot set different clock %d "
			   "from the current %d\n", runtime->rate, chip->freq);
		dev_err(chip->card->dev,
			"vx: cannot set different clock %d from the current %d\n",
			runtime->rate, chip->freq);
		return -EINVAL;
	}
	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 */

		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;
		}

@@ -1141,7 +1145,8 @@ static int vx_init_audio_io(struct vx_core *chip)

	vx_init_rmh(&rmh, CMD_SUPPORTED);
	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;
	}

+2 −1
Original line number Diff line number Diff line
@@ -196,7 +196,8 @@ void vx_set_internal_clock(struct vx_core *chip, unsigned int freq)

	/* Get real clock value */
	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);
	if (vx_is_pcmcia(chip)) {
		vx_outb(chip, HIFREQ, (clock >> 8) & 0x0f);