[PATCH 044/113] ASoC: sh: 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/sh/dma-sh7760.c | 12 ++++++------
 sound/soc/sh/fsi.c        |  7 +------
 sound/soc/sh/hac.c        |  2 +-
 sound/soc/sh/rcar/core.c  |  4 ++--
 sound/soc/sh/rz-ssi.c     | 14 ++++----------
 sound/soc/sh/siu_dai.c    |  4 ++--
 sound/soc/sh/siu_pcm.c    | 14 +++++++-------
 sound/soc/sh/ssi.c        |  2 +-
 8 files changed, 24 insertions(+), 35 deletions(-)

diff --git a/sound/soc/sh/dma-sh7760.c b/sound/soc/sh/dma-sh7760.c
index c53539482c208..32b30bbfaa88f 100644
--- a/sound/soc/sh/dma-sh7760.c
+++ b/sound/soc/sh/dma-sh7760.c
@@ -120,7 +120,7 @@ static int camelot_pcm_open(struct snd_soc_component *component,
 {
 	struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
 	struct camelot_pcm *cam = &cam_pcm_data[snd_soc_rtd_to_cpu(rtd, 0)->id];
-	int recv = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? 0:1;
+	int recv = snd_pcm_is_capture(substream);
 	int ret, dmairq;
 
 	snd_soc_set_runtime_hwparams(substream, &camelot_pcm_hardware);
@@ -154,7 +154,7 @@ static int camelot_pcm_close(struct snd_soc_component *component,
 {
 	struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
 	struct camelot_pcm *cam = &cam_pcm_data[snd_soc_rtd_to_cpu(rtd, 0)->id];
-	int recv = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? 0:1;
+	int recv = snd_pcm_is_capture(substream);
 	int dmairq;
 
 	dmairq = (recv) ? cam->txid + 2 : cam->txid;
@@ -176,7 +176,7 @@ static int camelot_hw_params(struct snd_soc_component *component,
 {
 	struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
 	struct camelot_pcm *cam = &cam_pcm_data[snd_soc_rtd_to_cpu(rtd, 0)->id];
-	int recv = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? 0:1;
+	int recv = snd_pcm_is_capture(substream);
 
 	if (recv) {
 		cam->rx_period_size = params_period_bytes(hw_params);
@@ -198,7 +198,7 @@ static int camelot_prepare(struct snd_soc_component *component,
 	pr_debug("PCM data: addr %pad len %zu\n", &runtime->dma_addr,
 		 runtime->dma_bytes);
 
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+	if (snd_pcm_is_playback(substream)) {
 		BRGREG(BRGATXSAR) = (unsigned long)runtime->dma_area;
 		BRGREG(BRGATXTCR) = runtime->dma_bytes;
 	} else {
@@ -242,7 +242,7 @@ static int camelot_trigger(struct snd_soc_component *component,
 {
 	struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
 	struct camelot_pcm *cam = &cam_pcm_data[snd_soc_rtd_to_cpu(rtd, 0)->id];
-	int recv = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? 0:1;
+	int recv = snd_pcm_is_capture(substream);
 
 	switch (cmd) {
 	case SNDRV_PCM_TRIGGER_START:
@@ -270,7 +270,7 @@ static snd_pcm_uframes_t camelot_pos(struct snd_soc_component *component,
 	struct snd_pcm_runtime *runtime = substream->runtime;
 	struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
 	struct camelot_pcm *cam = &cam_pcm_data[snd_soc_rtd_to_cpu(rtd, 0)->id];
-	int recv = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? 0:1;
+	int recv = snd_pcm_is_capture(substream);
 	unsigned long pos;
 
 	/* cannot use the DMABRG pointer register: under load, by the
diff --git a/sound/soc/sh/fsi.c b/sound/soc/sh/fsi.c
index 087e379aa3bc4..59198f615ed6a 100644
--- a/sound/soc/sh/fsi.c
+++ b/sound/soc/sh/fsi.c
@@ -398,11 +398,6 @@ static int fsi_is_enable_stream(struct fsi_priv *fsi)
 	return fsi->enable_stream;
 }
 
-static int fsi_is_play(struct snd_pcm_substream *substream)
-{
-	return substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
-}
-
 static struct snd_soc_dai *fsi_get_dai(struct snd_pcm_substream *substream)
 {
 	struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
@@ -492,7 +487,7 @@ static void fsi_count_fifo_err(struct fsi_priv *fsi)
 static inline struct fsi_stream *fsi_stream_get(struct fsi_priv *fsi,
 					struct snd_pcm_substream *substream)
 {
-	return fsi_is_play(substream) ? &fsi->playback : &fsi->capture;
+	return snd_pcm_is_playback(substream) ? &fsi->playback : &fsi->capture;
 }
 
 static int fsi_stream_is_working(struct fsi_priv *fsi,
diff --git a/sound/soc/sh/hac.c b/sound/soc/sh/hac.c
index cc200f45826c3..dc724042d336e 100644
--- a/sound/soc/sh/hac.c
+++ b/sound/soc/sh/hac.c
@@ -237,7 +237,7 @@ static int hac_hw_params(struct snd_pcm_substream *substream,
 			 struct snd_soc_dai *dai)
 {
 	struct hac_priv *hac = &hac_cpu_data[dai->id];
-	int d = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? 0 : 1;
+	int d = snd_pcm_is_capture(substream);
 
 	switch (params->msbits) {
 	case 16:
diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c
index 15cb5e7008f9f..9e719a01769ba 100644
--- a/sound/soc/sh/rcar/core.c
+++ b/sound/soc/sh/rcar/core.c
@@ -683,7 +683,7 @@ static
 struct rsnd_dai_stream *rsnd_rdai_to_io(struct rsnd_dai *rdai,
 					struct snd_pcm_substream *substream)
 {
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+	if (snd_pcm_is_playback(substream))
 		return &rdai->playback;
 	else
 		return &rdai->capture;
@@ -1004,7 +1004,7 @@ static int rsnd_soc_dai_startup(struct snd_pcm_substream *substream,
 	 * It depends on Clock Master Mode
 	 */
 	if (rsnd_rdai_is_clk_master(rdai)) {
-		int is_play = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
+		int is_play = snd_pcm_is_playback(substream);
 
 		snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
 				    rsnd_soc_hw_rule_rate,
diff --git a/sound/soc/sh/rz-ssi.c b/sound/soc/sh/rz-ssi.c
index d0bf0487bf1bd..d0afc9ced950b 100644
--- a/sound/soc/sh/rz-ssi.c
+++ b/sound/soc/sh/rz-ssi.c
@@ -171,18 +171,12 @@ rz_ssi_get_dai(struct snd_pcm_substream *substream)
 	return snd_soc_rtd_to_cpu(rtd, 0);
 }
 
-static inline bool rz_ssi_stream_is_play(struct rz_ssi_priv *ssi,
-					 struct snd_pcm_substream *substream)
-{
-	return substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
-}
-
 static inline struct rz_ssi_stream *
 rz_ssi_stream_get(struct rz_ssi_priv *ssi, struct snd_pcm_substream *substream)
 {
 	struct rz_ssi_stream *stream = &ssi->playback;
 
-	if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK)
+	if (!snd_pcm_is_playback(substream))
 		stream = &ssi->capture;
 
 	return stream;
@@ -349,7 +343,7 @@ static void rz_ssi_set_idle(struct rz_ssi_priv *ssi)
 
 static int rz_ssi_start(struct rz_ssi_priv *ssi, struct rz_ssi_stream *strm)
 {
-	bool is_play = rz_ssi_stream_is_play(ssi, strm->substream);
+	bool is_play = snd_pcm_is_playback(strm->substream);
 	bool is_full_duplex;
 	u32 ssicr, ssifcr;
 
@@ -682,7 +676,7 @@ static int rz_ssi_dma_transfer(struct rz_ssi_priv *ssi,
 		 */
 		return 0;
 
-	dir = rz_ssi_stream_is_play(ssi, substream) ? DMA_MEM_TO_DEV : DMA_DEV_TO_MEM;
+	dir = snd_pcm_is_playback(substream) ? DMA_MEM_TO_DEV : DMA_DEV_TO_MEM;
 
 	/* Always transfer 1 period */
 	amount = runtime->period_size;
@@ -808,7 +802,7 @@ static int rz_ssi_dai_trigger(struct snd_pcm_substream *substream, int cmd,
 		if (ssi->dma_rt) {
 			bool is_playback;
 
-			is_playback = rz_ssi_stream_is_play(ssi, substream);
+			is_playback = snd_pcm_is_playback(substream);
 			ret = rz_ssi_dma_slave_config(ssi, ssi->playback.dma_ch,
 						      is_playback);
 			/* Fallback to pio */
diff --git a/sound/soc/sh/siu_dai.c b/sound/soc/sh/siu_dai.c
index d0b5c543fd2f8..e747d34b51580 100644
--- a/sound/soc/sh/siu_dai.c
+++ b/sound/soc/sh/siu_dai.c
@@ -521,7 +521,7 @@ static void siu_dai_shutdown(struct snd_pcm_substream *substream,
 	dev_dbg(substream->pcm->card->dev, "%s: port=%d@%p\n", __func__,
 		info->port_id, port_info);
 
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+	if (snd_pcm_is_playback(substream))
 		port_info->play_cap &= ~PLAYBACK_ENABLED;
 	else
 		port_info->play_cap &= ~CAPTURE_ENABLED;
@@ -550,7 +550,7 @@ static int siu_dai_prepare(struct snd_pcm_substream *substream,
 		"%s: port %d, active streams %lx, %d channels\n",
 		__func__, info->port_id, port_info->play_cap, rt->channels);
 
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+	if (snd_pcm_is_playback(substream)) {
 		self = PLAYBACK_ENABLED;
 		siu_stream = &port_info->playback;
 	} else {
diff --git a/sound/soc/sh/siu_pcm.c b/sound/soc/sh/siu_pcm.c
index f15ff36e79345..27ee6fd6d35c2 100644
--- a/sound/soc/sh/siu_pcm.c
+++ b/sound/soc/sh/siu_pcm.c
@@ -214,7 +214,7 @@ static void siu_io_work(struct work_struct *work)
 		return;
 	}
 
-	if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
+	if (snd_pcm_is_capture(substream)) {
 		dma_addr_t buff;
 		size_t count;
 
@@ -306,7 +306,7 @@ static int siu_pcm_open(struct snd_soc_component *component,
 
 	dev_dbg(dev, "%s, port=%d@%p\n", __func__, port, port_info);
 
-	if (ss->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+	if (snd_pcm_is_playback(ss)) {
 		siu_stream = &port_info->playback;
 		param = &siu_stream->param;
 		param->shdma_slave.slave_id = port ? pdata->dma_slave_tx_b :
@@ -340,7 +340,7 @@ static int siu_pcm_close(struct snd_soc_component *component,
 
 	dev_dbg(dev, "%s: port=%d\n", __func__, info->port_id);
 
-	if (ss->stream == SNDRV_PCM_STREAM_PLAYBACK)
+	if (snd_pcm_is_playback(ss))
 		siu_stream = &port_info->playback;
 	else
 		siu_stream = &port_info->capture;
@@ -363,7 +363,7 @@ static int siu_pcm_prepare(struct snd_soc_component *component,
 	struct siu_stream *siu_stream;
 	snd_pcm_sframes_t xfer_cnt;
 
-	if (ss->stream == SNDRV_PCM_STREAM_PLAYBACK)
+	if (snd_pcm_is_playback(ss))
 		siu_stream = &port_info->playback;
 	else
 		siu_stream = &port_info->capture;
@@ -413,7 +413,7 @@ static int siu_pcm_trigger(struct snd_soc_component *component,
 
 	switch (cmd) {
 	case SNDRV_PCM_TRIGGER_START:
-		if (ss->stream == SNDRV_PCM_STREAM_PLAYBACK)
+		if (snd_pcm_is_playback(ss))
 			ret = siu_pcm_stmwrite_start(port_info);
 		else
 			ret = siu_pcm_stmread_start(port_info);
@@ -424,7 +424,7 @@ static int siu_pcm_trigger(struct snd_soc_component *component,
 
 		break;
 	case SNDRV_PCM_TRIGGER_STOP:
-		if (ss->stream == SNDRV_PCM_STREAM_PLAYBACK)
+		if (snd_pcm_is_playback(ss))
 			siu_pcm_stmwrite_stop(port_info);
 		else
 			siu_pcm_stmread_stop(port_info);
@@ -455,7 +455,7 @@ siu_pcm_pointer_dma(struct snd_soc_component *component,
 	size_t ptr;
 	struct siu_stream *siu_stream;
 
-	if (ss->stream == SNDRV_PCM_STREAM_PLAYBACK)
+	if (snd_pcm_is_playback(ss))
 		siu_stream = &port_info->playback;
 	else
 		siu_stream = &port_info->capture;
diff --git a/sound/soc/sh/ssi.c b/sound/soc/sh/ssi.c
index 96cf523c22734..f77b4d9a4a205 100644
--- a/sound/soc/sh/ssi.c
+++ b/sound/soc/sh/ssi.c
@@ -135,7 +135,7 @@ static int ssi_hw_params(struct snd_pcm_substream *substream,
 
 	channels = params_channels(params);
 	bits = params->msbits;
-	recv = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ? 0 : 1;
+	recv = snd_pcm_is_capture(substream);
 
 	pr_debug("ssi_hw_params() enter\nssicr was    %08lx\n", ssicr);
 	pr_debug("bits: %u channels: %u\n", bits, channels);
-- 
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