[PATCH 108/113] ASoC: mediatek: use snd_pcm_is_playback/capture()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We can use snd_pcm_is_playback/capture(). Let's use it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@xxxxxxxxxxx>
---
 sound/soc/mediatek/common/mtk-afe-fe-dai.c     |  4 ++--
 sound/soc/mediatek/common/mtk-btcvsd.c         | 18 +++++++++---------
 sound/soc/mediatek/common/mtk-dsp-sof-common.c |  4 ++--
 sound/soc/mediatek/mt2701/mt2701-afe-pcm.c     | 10 +++++-----
 sound/soc/mediatek/mt6797/mt6797-dai-adda.c    |  2 +-
 sound/soc/mediatek/mt8183/mt8183-dai-adda.c    |  2 +-
 sound/soc/mediatek/mt8186/mt8186-afe-pcm.c     |  4 ++--
 sound/soc/mediatek/mt8186/mt8186-dai-adda.c    |  2 +-
 sound/soc/mediatek/mt8186/mt8186-dai-src.c     |  4 ++--
 sound/soc/mediatek/mt8188/mt8188-afe-pcm.c     |  2 +-
 sound/soc/mediatek/mt8188/mt8188-dai-adda.c    |  2 +-
 sound/soc/mediatek/mt8192/mt8192-dai-adda.c    |  2 +-
 sound/soc/mediatek/mt8195/mt8195-dai-adda.c    |  2 +-
 13 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/sound/soc/mediatek/common/mtk-afe-fe-dai.c b/sound/soc/mediatek/common/mtk-afe-fe-dai.c
index 3044d9ab3d4d9..71223feefa1af 100644
--- a/sound/soc/mediatek/common/mtk-afe-fe-dai.c
+++ b/sound/soc/mediatek/common/mtk-afe-fe-dai.c
@@ -61,7 +61,7 @@ int mtk_afe_fe_startup(struct snd_pcm_substream *substream,
 	 * This easily leads to overrun when avail_min is period_size.
 	 * One more period can hold the possible unread buffer.
 	 */
-	if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
+	if (snd_pcm_is_capture(substream)) {
 		int periods_max = mtk_afe_hardware->periods_max;
 
 		ret = snd_pcm_hw_constraint_minmax(runtime,
@@ -268,7 +268,7 @@ int mtk_afe_fe_prepare(struct snd_pcm_substream *substream,
 	int id = snd_soc_rtd_to_cpu(rtd, 0)->id;
 	int pbuf_size;
 
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+	if (snd_pcm_is_playback(substream)) {
 		if (afe->get_memif_pbuf_size) {
 			pbuf_size = afe->get_memif_pbuf_size(substream);
 			mtk_memif_set_pbuf_size(afe, id, pbuf_size);
diff --git a/sound/soc/mediatek/common/mtk-btcvsd.c b/sound/soc/mediatek/common/mtk-btcvsd.c
index c12d170fa1de6..a896f0c01e600 100644
--- a/sound/soc/mediatek/common/mtk-btcvsd.c
+++ b/sound/soc/mediatek/common/mtk-btcvsd.c
@@ -647,7 +647,7 @@ static int wait_for_bt_irq(struct mtk_btcvsd_snd *bt,
 
 	while (max_timeout_trial && !bt_stream->wait_flag) {
 		t1 = sched_clock();
-		if (bt_stream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+		if (snd_pcm_is_playback(bt_stream->stream)) {
 			ret = wait_event_interruptible_timeout(bt->tx_wait,
 				bt_stream->wait_flag,
 				nsecs_to_jiffies(timeout_limit));
@@ -850,7 +850,7 @@ static ssize_t mtk_btcvsd_snd_write(struct mtk_btcvsd_snd *bt,
 static struct mtk_btcvsd_snd_stream *get_bt_stream
 	(struct mtk_btcvsd_snd *bt, struct snd_pcm_substream *substream)
 {
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+	if (snd_pcm_is_playback(substream))
 		return bt->tx;
 	else
 		return bt->rx;
@@ -879,7 +879,7 @@ static int mtk_pcm_btcvsd_open(struct snd_soc_component *component,
 
 	snd_soc_set_runtime_hwparams(substream, &mtk_btcvsd_hardware);
 
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+	if (snd_pcm_is_playback(substream)) {
 		ret = mtk_btcvsd_snd_tx_init(bt);
 		bt->tx->substream = substream;
 	} else {
@@ -909,7 +909,7 @@ static int mtk_pcm_btcvsd_hw_params(struct snd_soc_component *component,
 {
 	struct mtk_btcvsd_snd *bt = snd_soc_component_get_drvdata(component);
 
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK &&
+	if (snd_pcm_is_playback(substream) &&
 	    params_buffer_bytes(hw_params) % bt->tx->packet_size != 0) {
 		dev_warn(bt->dev, "%s(), error, buffer size %d not valid\n",
 			 __func__,
@@ -926,7 +926,7 @@ static int mtk_pcm_btcvsd_hw_free(struct snd_soc_component *component,
 {
 	struct mtk_btcvsd_snd *bt = snd_soc_component_get_drvdata(component);
 
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+	if (snd_pcm_is_playback(substream))
 		btcvsd_tx_clean_buffer(bt);
 
 	return 0;
@@ -958,7 +958,7 @@ static int mtk_pcm_btcvsd_trigger(struct snd_soc_component *component,
 	switch (cmd) {
 	case SNDRV_PCM_TRIGGER_START:
 	case SNDRV_PCM_TRIGGER_RESUME:
-		hw_packet_ptr = stream == SNDRV_PCM_STREAM_PLAYBACK ?
+		hw_packet_ptr = snd_pcm_is_playback(stream) ?
 				bt_stream->packet_r : bt_stream->packet_w;
 		bt_stream->prev_packet_idx = hw_packet_ptr;
 		bt_stream->prev_frame = 0;
@@ -987,7 +987,7 @@ static snd_pcm_uframes_t mtk_pcm_btcvsd_pointer(
 	spinlock_t *lock;	/* spinlock for bt stream control */
 	unsigned long flags;
 
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+	if (snd_pcm_is_playback(substream)) {
 		lock = &bt->tx_lock;
 		bt_stream = bt->tx;
 	} else {
@@ -996,7 +996,7 @@ static snd_pcm_uframes_t mtk_pcm_btcvsd_pointer(
 	}
 
 	spin_lock_irqsave(lock, flags);
-	hw_packet_ptr = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
+	hw_packet_ptr = snd_pcm_is_playback(substream) ?
 			bt->tx->packet_r : bt->rx->packet_w;
 
 	/* get packet diff from last time */
@@ -1030,7 +1030,7 @@ static int mtk_pcm_btcvsd_copy(struct snd_soc_component *component,
 {
 	struct mtk_btcvsd_snd *bt = snd_soc_component_get_drvdata(component);
 
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+	if (snd_pcm_is_playback(substream))
 		return mtk_btcvsd_snd_write(bt, buf, count);
 	else
 		return mtk_btcvsd_snd_read(bt, buf, count);
diff --git a/sound/soc/mediatek/common/mtk-dsp-sof-common.c b/sound/soc/mediatek/common/mtk-dsp-sof-common.c
index bca758dca2c9a..050a72b5fc21e 100644
--- a/sound/soc/mediatek/common/mtk-dsp-sof-common.c
+++ b/sound/soc/mediatek/common/mtk-dsp-sof-common.c
@@ -200,13 +200,13 @@ int mtk_sof_card_late_probe(struct snd_soc_card *card)
 				struct snd_soc_dapm_widget *widget = snd_soc_dai_get_widget(cpu_dai, conn->stream_dir);
 
 				memset(&route, 0, sizeof(route));
-				if (conn->stream_dir == SNDRV_PCM_STREAM_CAPTURE && widget) {
+				if (snd_pcm_is_capture(conn->stream_dir) && widget) {
 					snd_soc_dapm_widget_for_each_sink_path(widget, p) {
 						route.source = conn->sof_dma;
 						route.sink = p->sink->name;
 						snd_soc_dapm_add_routes(&card->dapm, &route, 1);
 					}
-				} else if (conn->stream_dir == SNDRV_PCM_STREAM_PLAYBACK && widget) {
+				} else if (snd_pcm_is_playback(conn->stream_dir) && widget) {
 					snd_soc_dapm_widget_for_each_source_path(widget, p) {
 						route.source = p->source->name;
 						route.sink = conn->sof_dma;
diff --git a/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c b/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c
index 6a17deb874df7..6bad411dcf243 100644
--- a/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c
+++ b/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c
@@ -160,7 +160,7 @@ static void mt2701_afe_i2s_shutdown(struct snd_pcm_substream *substream,
 	mt2701_afe_i2s_path_disable(afe, i2s_path, substream->stream);
 
 	/* need to disable i2s-out path when disable i2s-in */
-	if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
+	if (snd_pcm_is_capture(substream))
 		mt2701_afe_i2s_path_disable(afe, i2s_path, !substream->stream);
 
 exit:
@@ -192,7 +192,7 @@ static int mt2701_i2s_path_enable(struct mtk_base_afe *afe,
 	      ASYS_I2S_CON_I2S_MODE |
 	      ASYS_I2S_CON_WIDE_MODE_SET(w_len);
 
-	if (stream_dir == SNDRV_PCM_STREAM_CAPTURE) {
+	if (snd_pcm_is_capture(stream_dir)) {
 		mask |= ASYS_I2S_IN_PHASE_FIX;
 		val |= ASYS_I2S_IN_PHASE_FIX;
 		reg = ASMI_TIMING_CON1;
@@ -250,7 +250,7 @@ static int mt2701_afe_i2s_prepare(struct snd_pcm_substream *substream,
 	i2s_path->occupied[substream->stream] = 1;
 
 	/* need to enable i2s-out path when enable i2s-in */
-	if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
+	if (snd_pcm_is_capture(substream))
 		mt2701_i2s_path_enable(afe, i2s_path, !substream->stream,
 				       substream->runtime->rate);
 
@@ -368,7 +368,7 @@ static int mt2701_simple_fe_startup(struct snd_pcm_substream *substream,
 	int stream_dir = substream->stream;
 
 	/* can't run single DL & DLM at the same time */
-	if (stream_dir == SNDRV_PCM_STREAM_PLAYBACK) {
+	if (snd_pcm_is_playback(stream_dir)) {
 		memif_tmp = &afe->memif[MT2701_MEMIF_DLM];
 		if (memif_tmp->substream) {
 			dev_warn(afe->dev, "memif is not available");
@@ -387,7 +387,7 @@ static int mt2701_simple_fe_hw_params(struct snd_pcm_substream *substream,
 	int stream_dir = substream->stream;
 
 	/* single DL use PAIR_INTERLEAVE */
-	if (stream_dir == SNDRV_PCM_STREAM_PLAYBACK)
+	if (snd_pcm_is_playback(stream_dir))
 		regmap_update_bits(afe->regmap,
 				   AFE_MEMIF_PBUF_SIZE,
 				   AFE_MEMIF_PBUF_SIZE_DLM_MASK,
diff --git a/sound/soc/mediatek/mt6797/mt6797-dai-adda.c b/sound/soc/mediatek/mt6797/mt6797-dai-adda.c
index 78f3ad758c120..baf5a46781071 100644
--- a/sound/soc/mediatek/mt6797/mt6797-dai-adda.c
+++ b/sound/soc/mediatek/mt6797/mt6797-dai-adda.c
@@ -158,7 +158,7 @@ static int mtk_dai_adda_hw_params(struct snd_pcm_substream *substream,
 	dev_dbg(afe->dev, "%s(), id %d, stream %d, rate %d\n",
 		__func__, dai->id, substream->stream, rate);
 
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+	if (snd_pcm_is_playback(substream)) {
 		unsigned int dl_src2_con0 = 0;
 		unsigned int dl_src2_con1 = 0;
 
diff --git a/sound/soc/mediatek/mt8183/mt8183-dai-adda.c b/sound/soc/mediatek/mt8183/mt8183-dai-adda.c
index be69bcea2a786..8317fc1cc5e25 100644
--- a/sound/soc/mediatek/mt8183/mt8183-dai-adda.c
+++ b/sound/soc/mediatek/mt8183/mt8183-dai-adda.c
@@ -276,7 +276,7 @@ static int mtk_dai_adda_hw_params(struct snd_pcm_substream *substream,
 	dev_dbg(afe->dev, "%s(), id %d, stream %d, rate %d\n",
 		__func__, dai->id, substream->stream, rate);
 
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+	if (snd_pcm_is_playback(substream)) {
 		unsigned int dl_src2_con0 = 0;
 		unsigned int dl_src2_con1 = 0;
 
diff --git a/sound/soc/mediatek/mt8186/mt8186-afe-pcm.c b/sound/soc/mediatek/mt8186/mt8186-afe-pcm.c
index bafbef96a42da..08776982e44ff 100644
--- a/sound/soc/mediatek/mt8186/mt8186-afe-pcm.c
+++ b/sound/soc/mediatek/mt8186/mt8186-afe-pcm.c
@@ -184,7 +184,7 @@ static int mt8186_fe_trigger(struct snd_pcm_substream *substream, int cmd,
 		 * for small latency record
 		 * ul memif need read some data before irq enable
 		 */
-		if (substream->stream == SNDRV_PCM_STREAM_CAPTURE &&
+		if (snd_pcm_is_capture(substream) &&
 		    ((runtime->period_size * 1000) / rate <= 10))
 			udelay(300);
 
@@ -219,7 +219,7 @@ static int mt8186_fe_trigger(struct snd_pcm_substream *substream, int cmd,
 	case SNDRV_PCM_TRIGGER_STOP:
 	case SNDRV_PCM_TRIGGER_SUSPEND:
 		if (afe_priv->xrun_assert[id] > 0) {
-			if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
+			if (snd_pcm_is_capture(substream)) {
 				int avail = snd_pcm_capture_avail(runtime);
 				/* alsa can trigger stop/start when occur xrun */
 				if (avail >= runtime->buffer_size)
diff --git a/sound/soc/mediatek/mt8186/mt8186-dai-adda.c b/sound/soc/mediatek/mt8186/mt8186-dai-adda.c
index dbd157d1a1ea2..5243e263c105d 100644
--- a/sound/soc/mediatek/mt8186/mt8186-dai-adda.c
+++ b/sound/soc/mediatek/mt8186/mt8186-dai-adda.c
@@ -565,7 +565,7 @@ static int mtk_dai_adda_hw_params(struct snd_pcm_substream *substream,
 	dev_dbg(afe->dev, "%s(), id %d, stream %d, rate %d\n",
 		__func__, id, substream->stream, rate);
 
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+	if (snd_pcm_is_playback(substream)) {
 		unsigned int dl_src2_con0;
 		unsigned int dl_src2_con1;
 
diff --git a/sound/soc/mediatek/mt8186/mt8186-dai-src.c b/sound/soc/mediatek/mt8186/mt8186-dai-src.c
index e475f4591aef5..5071fd69281c7 100644
--- a/sound/soc/mediatek/mt8186/mt8186-dai-src.c
+++ b/sound/soc/mediatek/mt8186/mt8186-dai-src.c
@@ -560,7 +560,7 @@ static int mtk_dai_src_hw_params(struct snd_pcm_substream *substream,
 		__func__, id, substream->stream, rate);
 
 	/* rate */
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+	if (snd_pcm_is_playback(substream)) {
 		src_priv->dl_rate = rate;
 		if (id == MT8186_DAI_SRC_1) {
 			sft = GENERAL1_ASRCIN_MODE_SFT;
@@ -596,7 +596,7 @@ static int mtk_dai_src_hw_free(struct snd_pcm_substream *substream,
 	dev_dbg(afe->dev, "%s(), id %d, stream %d\n",
 		__func__, id, substream->stream);
 
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+	if (snd_pcm_is_playback(substream))
 		src_priv->dl_rate = 0;
 	else
 		src_priv->ul_rate = 0;
diff --git a/sound/soc/mediatek/mt8188/mt8188-afe-pcm.c b/sound/soc/mediatek/mt8188/mt8188-afe-pcm.c
index ccb6c1f3adc7d..2058e0aa63993 100644
--- a/sound/soc/mediatek/mt8188/mt8188-afe-pcm.c
+++ b/sound/soc/mediatek/mt8188/mt8188-afe-pcm.c
@@ -397,7 +397,7 @@ static int mt8188_afe_fe_trigger(struct snd_pcm_substream *substream, int cmd,
 					   fs << irq_data->irq_fs_shift);
 
 		/* delay for uplink */
-		if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
+		if (snd_pcm_is_capture(substream)) {
 			u32 sample_delay;
 
 			sample_delay = ((MEMIF_AXI_MINLEN + 1) * 64 +
diff --git a/sound/soc/mediatek/mt8188/mt8188-dai-adda.c b/sound/soc/mediatek/mt8188/mt8188-dai-adda.c
index 8a17d1935c48f..58e1795bfad92 100644
--- a/sound/soc/mediatek/mt8188/mt8188-dai-adda.c
+++ b/sound/soc/mediatek/mt8188/mt8188-dai-adda.c
@@ -414,7 +414,7 @@ static int mtk_dai_adda_hw_params(struct snd_pcm_substream *substream,
 
 	adda_priv->hires_required = (rate > ADDA_HIRES_THRES);
 
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+	if (snd_pcm_is_playback(substream))
 		ret = mtk_dai_da_configure(afe, rate, id);
 	else
 		ret = mtk_dai_ad_configure(afe, rate, id);
diff --git a/sound/soc/mediatek/mt8192/mt8192-dai-adda.c b/sound/soc/mediatek/mt8192/mt8192-dai-adda.c
index 99de85b876435..5fae5e877d449 100644
--- a/sound/soc/mediatek/mt8192/mt8192-dai-adda.c
+++ b/sound/soc/mediatek/mt8192/mt8192-dai-adda.c
@@ -1067,7 +1067,7 @@ static int mtk_dai_adda_hw_params(struct snd_pcm_substream *substream,
 	unsigned int rate = params_rate(params);
 	int id = dai->id;
 
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+	if (snd_pcm_is_playback(substream)) {
 		unsigned int dl_src2_con0 = 0;
 		unsigned int dl_src2_con1 = 0;
 
diff --git a/sound/soc/mediatek/mt8195/mt8195-dai-adda.c b/sound/soc/mediatek/mt8195/mt8195-dai-adda.c
index 8da1587128ccf..18c63f7fc5407 100644
--- a/sound/soc/mediatek/mt8195/mt8195-dai-adda.c
+++ b/sound/soc/mediatek/mt8195/mt8195-dai-adda.c
@@ -638,7 +638,7 @@ static int mtk_dai_adda_hw_params(struct snd_pcm_substream *substream,
 	else
 		adda_priv->hires_required = 0;
 
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+	if (snd_pcm_is_playback(substream))
 		ret = mtk_dai_da_configure(afe, rate, dai->id);
 	else
 		ret = mtk_dai_ad_configure(afe, rate, dai->id);
-- 
2.43.0




[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Pulse Audio]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux