diff mbox series

[043/113] ASoC: ti: use snd_pcm_is_playback/capture()

Message ID 87ed73ztv3.wl-kuninori.morimoto.gx@renesas.com
State New
Headers show
Series [001/113] ALSA: add snd_pcm_is_playback/capture() macro | expand

Commit Message

Kuninori Morimoto Aug. 5, 2024, 12:38 a.m. UTC
We can use snd_pcm_is_playback/capture(). Let's use it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/ti/davinci-i2s.c   | 12 ++++++------
 sound/soc/ti/davinci-mcasp.c | 18 +++++++++---------
 sound/soc/ti/omap-mcbsp.c    | 18 +++++++++---------
 sound/soc/ti/omap-mcpdm.c    | 10 +++++-----
 4 files changed, 29 insertions(+), 29 deletions(-)
diff mbox series

Patch

diff --git a/sound/soc/ti/davinci-i2s.c b/sound/soc/ti/davinci-i2s.c
index 0f15a743c7982..f509aaafa411f 100644
--- a/sound/soc/ti/davinci-i2s.c
+++ b/sound/soc/ti/davinci-i2s.c
@@ -190,7 +190,7 @@  static void toggle_clock(struct davinci_mcbsp_dev *dev, int playback)
 static void davinci_mcbsp_start(struct davinci_mcbsp_dev *dev,
 		struct snd_pcm_substream *substream)
 {
-	int playback = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK);
+	int playback = snd_pcm_is_playback(substream);
 	u32 spcr;
 	u32 mask = playback ? DAVINCI_MCBSP_SPCR_XRST : DAVINCI_MCBSP_SPCR_RRST;
 
@@ -485,7 +485,7 @@  static int davinci_i2s_hw_params(struct snd_pcm_substream *substream,
 	}
 
 	/* general line settings */
-	if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
+	if (snd_pcm_is_capture(substream)) {
 		spcr |= DAVINCI_MCBSP_SPCR_RINTM(3);
 		davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_SPCR_REG, spcr);
 	} else {
@@ -641,7 +641,7 @@  static int davinci_i2s_hw_params(struct snd_pcm_substream *substream,
 	xcr |= DAVINCI_MCBSP_XCR_XWDLEN1(mcbsp_word_length) |
 		DAVINCI_MCBSP_XCR_XWDLEN2(mcbsp_word_length);
 
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+	if (snd_pcm_is_playback(substream))
 		davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_XCR_REG, xcr);
 	else
 		davinci_mcbsp_write_reg(dev, DAVINCI_MCBSP_RCR_REG, rcr);
@@ -656,7 +656,7 @@  static int davinci_i2s_prepare(struct snd_pcm_substream *substream,
 		struct snd_soc_dai *dai)
 {
 	struct davinci_mcbsp_dev *dev = snd_soc_dai_get_drvdata(dai);
-	int playback = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK);
+	int playback = snd_pcm_is_playback(substream);
 	u32 spcr;
 	u32 mask = playback ? DAVINCI_MCBSP_SPCR_XRST : DAVINCI_MCBSP_SPCR_RRST;
 
@@ -700,7 +700,7 @@  static int davinci_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
 {
 	struct davinci_mcbsp_dev *dev = snd_soc_dai_get_drvdata(dai);
 	int ret = 0;
-	int playback = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK);
+	int playback = snd_pcm_is_playback(substream);
 
 	switch (cmd) {
 	case SNDRV_PCM_TRIGGER_START:
@@ -723,7 +723,7 @@  static void davinci_i2s_shutdown(struct snd_pcm_substream *substream,
 		struct snd_soc_dai *dai)
 {
 	struct davinci_mcbsp_dev *dev = snd_soc_dai_get_drvdata(dai);
-	int playback = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK);
+	int playback = snd_pcm_is_playback(substream);
 	davinci_mcbsp_stop(dev, playback);
 }
 
diff --git a/sound/soc/ti/davinci-mcasp.c b/sound/soc/ti/davinci-mcasp.c
index 2b1ed91a736c9..e7eabbd972e79 100644
--- a/sound/soc/ti/davinci-mcasp.c
+++ b/sound/soc/ti/davinci-mcasp.c
@@ -289,7 +289,7 @@  static void davinci_mcasp_start(struct davinci_mcasp *mcasp, int stream)
 {
 	mcasp->streams++;
 
-	if (stream == SNDRV_PCM_STREAM_PLAYBACK)
+	if (snd_pcm_is_playback(stream))
 		mcasp_start_tx(mcasp);
 	else
 		mcasp_start_rx(mcasp);
@@ -354,7 +354,7 @@  static void davinci_mcasp_stop(struct davinci_mcasp *mcasp, int stream)
 {
 	mcasp->streams--;
 
-	if (stream == SNDRV_PCM_STREAM_PLAYBACK)
+	if (snd_pcm_is_playback(stream))
 		mcasp_stop_tx(mcasp);
 	else
 		mcasp_stop_rx(mcasp);
@@ -873,7 +873,7 @@  static int mcasp_common_hw_param(struct davinci_mcasp *mcasp, int stream,
 	if (mcasp->version < MCASP_VERSION_3)
 		mcasp_set_bits(mcasp, DAVINCI_MCASP_PWREMUMGT_REG, MCASP_SOFT);
 
-	if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
+	if (snd_pcm_is_playback(stream)) {
 		mcasp_set_reg(mcasp, DAVINCI_MCASP_TXSTAT_REG, 0xFFFFFFFF);
 		mcasp_clr_bits(mcasp, DAVINCI_MCASP_XEVTCTL_REG, TXDATADMADIS);
 		max_tx_serializers = max_active_serializers;
@@ -913,7 +913,7 @@  static int mcasp_common_hw_param(struct davinci_mcasp *mcasp, int stream,
 		}
 	}
 
-	if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
+	if (snd_pcm_is_playback(stream)) {
 		active_serializers = tx_ser;
 		numevt = mcasp->txnumevt;
 		reg = mcasp->fifo_base + MCASP_WFIFOCTL_OFFSET;
@@ -1026,12 +1026,12 @@  static int mcasp_i2s_hw_param(struct davinci_mcasp *mcasp, int stream,
 	if (!mcasp->dat_port)
 		busel = TXSEL;
 
-	if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
+	if (snd_pcm_is_playback(stream)) {
 		mcasp_set_reg(mcasp, DAVINCI_MCASP_TXTDM_REG, mask);
 		mcasp_set_bits(mcasp, DAVINCI_MCASP_TXFMT_REG, busel | TXORD);
 		mcasp_mod_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG,
 			       FSXMOD(total_slots), FSXMOD(0x1FF));
-	} else if (stream == SNDRV_PCM_STREAM_CAPTURE) {
+	} else if (snd_pcm_is_capture(stream)) {
 		mcasp_set_reg(mcasp, DAVINCI_MCASP_RXTDM_REG, mask);
 		mcasp_set_bits(mcasp, DAVINCI_MCASP_RXFMT_REG, busel | RXORD);
 		mcasp_mod_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG,
@@ -1190,7 +1190,7 @@  static snd_pcm_sframes_t davinci_mcasp_delay(
 	struct davinci_mcasp *mcasp = snd_soc_dai_get_drvdata(cpu_dai);
 	u32 fifo_use;
 
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+	if (snd_pcm_is_playback(substream))
 		fifo_use = davinci_mcasp_tx_delay(mcasp);
 	else
 		fifo_use = davinci_mcasp_rx_delay(mcasp);
@@ -1509,7 +1509,7 @@  static int davinci_mcasp_startup(struct snd_pcm_substream *substream,
 	 * Limit the maximum allowed channels for the first stream:
 	 * number of serializers for the direction * tdm slots per serializer
 	 */
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+	if (snd_pcm_is_playback(substream))
 		dir = TX_MODE;
 	else
 		dir = RX_MODE;
@@ -1591,7 +1591,7 @@  static int davinci_mcasp_startup(struct snd_pcm_substream *substream,
 			return ret;
 	}
 
-	numevt = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ?
+	numevt = snd_pcm_is_playback(substream) ?
 			 &mcasp->txnumevt :
 			 &mcasp->rxnumevt;
 	snd_pcm_hw_rule_add(substream->runtime, 0,
diff --git a/sound/soc/ti/omap-mcbsp.c b/sound/soc/ti/omap-mcbsp.c
index 2110ffe5281ce..bb6a01b41ac86 100644
--- a/sound/soc/ti/omap-mcbsp.c
+++ b/sound/soc/ti/omap-mcbsp.c
@@ -217,7 +217,7 @@  static int omap_mcbsp_dma_reg_params(struct omap_mcbsp *mcbsp,
 {
 	int data_reg;
 
-	if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
+	if (snd_pcm_is_playback(stream)) {
 		if (mcbsp->pdata->reg_size == 2)
 			data_reg = OMAP_MCBSP_REG_DXR1;
 		else
@@ -413,7 +413,7 @@  static void omap_mcbsp_free(struct omap_mcbsp *mcbsp)
  */
 static void omap_mcbsp_start(struct omap_mcbsp *mcbsp, int stream)
 {
-	int tx = (stream == SNDRV_PCM_STREAM_PLAYBACK);
+	int tx = snd_pcm_is_playback(stream);
 	int rx = !tx;
 	int enable_srg = 0;
 	u16 w;
@@ -472,7 +472,7 @@  static void omap_mcbsp_start(struct omap_mcbsp *mcbsp, int stream)
 
 static void omap_mcbsp_stop(struct omap_mcbsp *mcbsp, int stream)
 {
-	int tx = (stream == SNDRV_PCM_STREAM_PLAYBACK);
+	int tx = snd_pcm_is_playback(stream);
 	int rx = !tx;
 	int idle;
 	u16 w;
@@ -742,7 +742,7 @@  static void omap_mcbsp_set_threshold(struct snd_pcm_substream *substream,
 		words = 1;
 
 	/* Configure McBSP internal buffer usage */
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+	if (snd_pcm_is_playback(substream))
 		omap_mcbsp_set_tx_threshold(mcbsp, words);
 	else
 		omap_mcbsp_set_rx_threshold(mcbsp, words);
@@ -797,7 +797,7 @@  static int omap_mcbsp_dai_startup(struct snd_pcm_substream *substream,
 		* smaller buffer than the FIFO size to avoid underruns.
 		* This applies only for the playback stream.
 		*/
-		if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+		if (snd_pcm_is_playback(substream))
 			snd_pcm_hw_rule_add(substream->runtime, 0,
 					    SNDRV_PCM_HW_PARAM_BUFFER_SIZE,
 					    omap_mcbsp_hwrule_min_buffersize,
@@ -816,7 +816,7 @@  static void omap_mcbsp_dai_shutdown(struct snd_pcm_substream *substream,
 				    struct snd_soc_dai *cpu_dai)
 {
 	struct omap_mcbsp *mcbsp = snd_soc_dai_get_drvdata(cpu_dai);
-	int tx = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK);
+	int tx = snd_pcm_is_playback(substream);
 	int stream1 = tx ? SNDRV_PCM_STREAM_PLAYBACK : SNDRV_PCM_STREAM_CAPTURE;
 	int stream2 = tx ? SNDRV_PCM_STREAM_CAPTURE : SNDRV_PCM_STREAM_PLAYBACK;
 
@@ -839,7 +839,7 @@  static int omap_mcbsp_dai_prepare(struct snd_pcm_substream *substream,
 {
 	struct omap_mcbsp *mcbsp = snd_soc_dai_get_drvdata(cpu_dai);
 	struct pm_qos_request *pm_qos_req = &mcbsp->pm_qos_req;
-	int tx = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK);
+	int tx = snd_pcm_is_playback(substream);
 	int stream1 = tx ? SNDRV_PCM_STREAM_PLAYBACK : SNDRV_PCM_STREAM_CAPTURE;
 	int stream2 = tx ? SNDRV_PCM_STREAM_CAPTURE : SNDRV_PCM_STREAM_PLAYBACK;
 	int latency = mcbsp->latency[stream2];
@@ -896,7 +896,7 @@  static snd_pcm_sframes_t omap_mcbsp_dai_delay(
 	if (mcbsp->pdata->buffer_size == 0)
 		return 0;
 
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+	if (snd_pcm_is_playback(substream))
 		fifo_use = omap_mcbsp_get_tx_delay(mcbsp);
 	else
 		fifo_use = omap_mcbsp_get_rx_delay(mcbsp);
@@ -944,7 +944,7 @@  static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream,
 			int divider = 0;
 
 			period_words = params_period_bytes(params) / (wlen / 8);
-			if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+			if (snd_pcm_is_playback(substream))
 				max_thrsh = mcbsp->max_tx_thres;
 			else
 				max_thrsh = mcbsp->max_rx_thres;
diff --git a/sound/soc/ti/omap-mcpdm.c b/sound/soc/ti/omap-mcpdm.c
index 1a5d19937c642..43637ce12b665 100644
--- a/sound/soc/ti/omap-mcpdm.c
+++ b/sound/soc/ti/omap-mcpdm.c
@@ -265,7 +265,7 @@  static void omap_mcpdm_dai_shutdown(struct snd_pcm_substream *substream,
 				  struct snd_soc_dai *dai)
 {
 	struct omap_mcpdm *mcpdm = snd_soc_dai_get_drvdata(dai);
-	int tx = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK);
+	int tx = snd_pcm_is_playback(substream);
 	int stream1 = tx ? SNDRV_PCM_STREAM_PLAYBACK : SNDRV_PCM_STREAM_CAPTURE;
 	int stream2 = tx ? SNDRV_PCM_STREAM_CAPTURE : SNDRV_PCM_STREAM_PLAYBACK;
 
@@ -305,13 +305,13 @@  static int omap_mcpdm_dai_hw_params(struct snd_pcm_substream *substream,
 	channels = params_channels(params);
 	switch (channels) {
 	case 5:
-		if (stream == SNDRV_PCM_STREAM_CAPTURE)
+		if (snd_pcm_is_capture(stream))
 			/* up to 3 channels for capture */
 			return -EINVAL;
 		link_mask |= 1 << 4;
 		fallthrough;
 	case 4:
-		if (stream == SNDRV_PCM_STREAM_CAPTURE)
+		if (snd_pcm_is_capture(stream))
 			/* up to 3 channels for capture */
 			return -EINVAL;
 		link_mask |= 1 << 3;
@@ -334,7 +334,7 @@  static int omap_mcpdm_dai_hw_params(struct snd_pcm_substream *substream,
 
 	threshold = mcpdm->config[stream].threshold;
 	/* Configure McPDM channels, and DMA packet size */
-	if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
+	if (snd_pcm_is_playback(stream)) {
 		link_mask <<= 3;
 
 		/* If capture is not running assume a stereo stream to come */
@@ -377,7 +377,7 @@  static int omap_mcpdm_prepare(struct snd_pcm_substream *substream,
 {
 	struct omap_mcpdm *mcpdm = snd_soc_dai_get_drvdata(dai);
 	struct pm_qos_request *pm_qos_req = &mcpdm->pm_qos_req;
-	int tx = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK);
+	int tx = snd_pcm_is_playback(substream);
 	int stream1 = tx ? SNDRV_PCM_STREAM_PLAYBACK : SNDRV_PCM_STREAM_CAPTURE;
 	int stream2 = tx ? SNDRV_PCM_STREAM_CAPTURE : SNDRV_PCM_STREAM_PLAYBACK;
 	int latency = mcpdm->latency[stream2];