[PATCH 062/113] ASoC: intel: 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/intel/atom/sst-atom-controls.c     |  2 +-
 sound/soc/intel/atom/sst/sst_drv_interface.c |  2 +-
 sound/soc/intel/boards/bdw-rt5650.c          |  2 +-
 sound/soc/intel/boards/sof_maxim_common.c    |  2 +-
 sound/soc/intel/boards/sof_sdw.c             |  4 +--
 sound/soc/intel/catpt/pcm.c                  |  4 +--
 sound/soc/intel/keembay/kmb_platform.c       | 28 ++++++++++----------
 sound/soc/intel/skylake/skl-pcm.c            | 14 +++++-----
 sound/soc/intel/skylake/skl-topology.c       | 18 ++++++-------
 9 files changed, 38 insertions(+), 38 deletions(-)

diff --git a/sound/soc/intel/atom/sst-atom-controls.c b/sound/soc/intel/atom/sst-atom-controls.c
index 38116c7587174..0c6ce403148f8 100644
--- a/sound/soc/intel/atom/sst-atom-controls.c
+++ b/sound/soc/intel/atom/sst-atom-controls.c
@@ -1333,7 +1333,7 @@ int sst_send_pipe_gains(struct snd_soc_dai *dai, int stream, int mute)
 	dev_dbg(dai->dev, "enter, dai-name=%s dir=%d\n", dai->name, stream);
 	dev_dbg(dai->dev, "Stream name=%s\n", w->name);
 
-	if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
+	if (snd_pcm_is_playback(stream)) {
 		snd_soc_dapm_widget_for_each_sink_path(w, p) {
 			if (p->connected && !p->connected(w, p->sink))
 				continue;
diff --git a/sound/soc/intel/atom/sst/sst_drv_interface.c b/sound/soc/intel/atom/sst/sst_drv_interface.c
index dc31c2c8f54c8..f02ee7f48a2a4 100644
--- a/sound/soc/intel/atom/sst/sst_drv_interface.c
+++ b/sound/soc/intel/atom/sst/sst_drv_interface.c
@@ -487,7 +487,7 @@ static inline int sst_calc_tstamp(struct intel_sst_drv *ctx,
 			fw_tstamp->ring_buffer_counter);
 	dev_dbg(ctx->dev, "mrfld hardware_counter %llu in bytes\n",
 			 fw_tstamp->hardware_counter);
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+	if (snd_pcm_is_playback(substream))
 		delay_bytes = (size_t) (fw_tstamp->ring_buffer_counter -
 					fw_tstamp->hardware_counter);
 	else
diff --git a/sound/soc/intel/boards/bdw-rt5650.c b/sound/soc/intel/boards/bdw-rt5650.c
index 3c7cee03a02e6..a5df4d3067d71 100644
--- a/sound/soc/intel/boards/bdw-rt5650.c
+++ b/sound/soc/intel/boards/bdw-rt5650.c
@@ -150,7 +150,7 @@ static int bdw_rt5650_fe_startup(struct snd_pcm_substream *substream)
 	struct snd_pcm_runtime *runtime = substream->runtime;
 
 	/* Board supports stereo and quad configurations for capture */
-	if (substream->stream != SNDRV_PCM_STREAM_CAPTURE)
+	if (!snd_pcm_is_capture(substream))
 		return 0;
 
 	runtime->hw.channels_max = 4;
diff --git a/sound/soc/intel/boards/sof_maxim_common.c b/sound/soc/intel/boards/sof_maxim_common.c
index fcc3b95e57a4f..f520442bbb096 100644
--- a/sound/soc/intel/boards/sof_maxim_common.c
+++ b/sound/soc/intel/boards/sof_maxim_common.c
@@ -196,7 +196,7 @@ static int max_98373_trigger(struct snd_pcm_substream *substream, int cmd)
 	int ret = 0;
 
 	/* set spk pin by playback only */
-	if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
+	if (snd_pcm_is_capture(substream))
 		return 0;
 
 	cpu_dai = snd_soc_rtd_to_cpu(rtd, 0);
diff --git a/sound/soc/intel/boards/sof_sdw.c b/sound/soc/intel/boards/sof_sdw.c
index d258728d64cf5..5818c21173032 100644
--- a/sound/soc/intel/boards/sof_sdw.c
+++ b/sound/soc/intel/boards/sof_sdw.c
@@ -846,8 +846,8 @@ static int create_sdw_dailink(struct snd_soc_card *card,
 
 		WARN_ON(i != num_cpus || j != num_codecs);
 
-		playback = (stream == SNDRV_PCM_STREAM_PLAYBACK);
-		capture = (stream == SNDRV_PCM_STREAM_CAPTURE);
+		playback = snd_pcm_is_playback(stream);
+		capture  = snd_pcm_is_capture(stream);
 
 		asoc_sdw_init_dai_link(dev, *dai_links, be_id, name, playback, capture,
 				       cpus, num_cpus, platform_component,
diff --git a/sound/soc/intel/catpt/pcm.c b/sound/soc/intel/catpt/pcm.c
index 81a2f0339e055..c32c101e65b9c 100644
--- a/sound/soc/intel/catpt/pcm.c
+++ b/sound/soc/intel/catpt/pcm.c
@@ -83,11 +83,11 @@ catpt_get_stream_template(struct snd_pcm_substream *substream)
 	/* account for capture in bidirectional dais */
 	switch (type) {
 	case CATPT_STRM_TYPE_SYSTEM:
-		if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
+		if (snd_pcm_is_capture(substream))
 			type = CATPT_STRM_TYPE_CAPTURE;
 		break;
 	case CATPT_STRM_TYPE_BLUETOOTH_RENDER:
-		if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
+		if (snd_pcm_is_capture(substream))
 			type = CATPT_STRM_TYPE_BLUETOOTH_CAPTURE;
 		break;
 	default:
diff --git a/sound/soc/intel/keembay/kmb_platform.c b/sound/soc/intel/keembay/kmb_platform.c
index 37ea2e1d2e922..eab7b8223b51b 100644
--- a/sound/soc/intel/keembay/kmb_platform.c
+++ b/sound/soc/intel/keembay/kmb_platform.c
@@ -170,7 +170,7 @@ static inline void kmb_i2s_disable_channels(struct kmb_i2s_info *kmb_i2s,
 	u32 i;
 
 	/* Disable all channels regardless of configuration*/
-	if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
+	if (snd_pcm_is_playback(stream)) {
 		for (i = 0; i < MAX_ISR; i++)
 			writel(0, kmb_i2s->i2s_base + TER(i));
 	} else {
@@ -184,7 +184,7 @@ static inline void kmb_i2s_clear_irqs(struct kmb_i2s_info *kmb_i2s, u32 stream)
 	struct i2s_clk_config_data *config = &kmb_i2s->config;
 	u32 i;
 
-	if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
+	if (snd_pcm_is_playback(stream)) {
 		for (i = 0; i < config->chan_nr / 2; i++)
 			readl(kmb_i2s->i2s_base + TOR(i));
 	} else {
@@ -199,7 +199,7 @@ static inline void kmb_i2s_irq_trigger(struct kmb_i2s_info *kmb_i2s,
 	u32 i, irq;
 	u32 flag;
 
-	if (stream == SNDRV_PCM_STREAM_PLAYBACK)
+	if (snd_pcm_is_playback(stream))
 		flag = TX_INT_FLAG;
 	else
 		flag = RX_INT_FLAG;
@@ -270,7 +270,7 @@ static int kmb_pcm_trigger(struct snd_soc_component *component,
 
 	switch (cmd) {
 	case SNDRV_PCM_TRIGGER_START:
-		if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+		if (snd_pcm_is_playback(substream)) {
 			kmb_i2s->tx_ptr = 0;
 			kmb_i2s->tx_substream = substream;
 		} else {
@@ -279,7 +279,7 @@ static int kmb_pcm_trigger(struct snd_soc_component *component,
 		}
 		break;
 	case SNDRV_PCM_TRIGGER_STOP:
-		if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+		if (snd_pcm_is_playback(substream))
 			kmb_i2s->tx_substream = NULL;
 		else
 			kmb_i2s->rx_substream = NULL;
@@ -378,7 +378,7 @@ static snd_pcm_uframes_t kmb_pcm_pointer(struct snd_soc_component *component,
 	struct kmb_i2s_info *kmb_i2s = runtime->private_data;
 	snd_pcm_uframes_t pos;
 
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+	if (snd_pcm_is_playback(substream))
 		pos = kmb_i2s->tx_ptr;
 	else
 		pos = kmb_i2s->rx_ptr;
@@ -419,7 +419,7 @@ static inline void kmb_i2s_enable_dma(struct kmb_i2s_info *kmb_i2s, u32 stream)
 
 	dma_reg = readl(kmb_i2s->i2s_base + I2S_DMACR);
 	/* Enable DMA handshake for stream */
-	if (stream == SNDRV_PCM_STREAM_PLAYBACK)
+	if (snd_pcm_is_playback(stream))
 		dma_reg |= I2S_DMAEN_TXBLOCK;
 	else
 		dma_reg |= I2S_DMAEN_RXBLOCK;
@@ -433,7 +433,7 @@ static inline void kmb_i2s_disable_dma(struct kmb_i2s_info *kmb_i2s, u32 stream)
 
 	dma_reg = readl(kmb_i2s->i2s_base + I2S_DMACR);
 	/* Disable DMA handshake for stream */
-	if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
+	if (snd_pcm_is_playback(stream)) {
 		dma_reg &= ~I2S_DMAEN_TXBLOCK;
 		writel(1, kmb_i2s->i2s_base + I2S_RTXDMA);
 	} else {
@@ -451,7 +451,7 @@ static void kmb_i2s_start(struct kmb_i2s_info *kmb_i2s,
 	/* I2S Programming sequence in Keem_Bay_VPU_DB_v1.1 */
 	writel(1, kmb_i2s->i2s_base + IER);
 
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+	if (snd_pcm_is_playback(substream))
 		writel(1, kmb_i2s->i2s_base + ITER);
 	else
 		writel(1, kmb_i2s->i2s_base + IRER);
@@ -474,7 +474,7 @@ static void kmb_i2s_stop(struct kmb_i2s_info *kmb_i2s,
 	/* I2S Programming sequence in Keem_Bay_VPU_DB_v1.1 */
 	kmb_i2s_clear_irqs(kmb_i2s, substream->stream);
 
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+	if (snd_pcm_is_playback(substream))
 		writel(0, kmb_i2s->i2s_base + ITER);
 	else
 		writel(0, kmb_i2s->i2s_base + IRER);
@@ -556,7 +556,7 @@ static void kmb_i2s_config(struct kmb_i2s_info *kmb_i2s, int stream)
 	kmb_i2s_disable_channels(kmb_i2s, stream);
 
 	for (ch_reg = 0; ch_reg < config->chan_nr / 2; ch_reg++) {
-		if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
+		if (snd_pcm_is_playback(stream)) {
 			writel(kmb_i2s->xfer_resolution,
 			       kmb_i2s->i2s_base + TCR(ch_reg));
 
@@ -678,7 +678,7 @@ static int kmb_dai_prepare(struct snd_pcm_substream *substream,
 {
 	struct kmb_i2s_info *kmb_i2s = snd_soc_dai_get_drvdata(cpu_dai);
 
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+	if (snd_pcm_is_playback(substream))
 		writel(1, kmb_i2s->i2s_base + TXFFR);
 	else
 		writel(1, kmb_i2s->i2s_base + RXFFR);
@@ -695,7 +695,7 @@ static int kmb_dai_startup(struct snd_pcm_substream *substream,
 	if (kmb_i2s->use_pio)
 		return 0;
 
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+	if (snd_pcm_is_playback(substream))
 		dma_data = &kmb_i2s->play_dma_data;
 	else
 		dma_data = &kmb_i2s->capture_dma_data;
@@ -713,7 +713,7 @@ static int kmb_dai_hw_free(struct snd_pcm_substream *substream,
 	if (kmb_i2s->use_pio)
 		kmb_i2s_clear_irqs(kmb_i2s, substream->stream);
 
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+	if (snd_pcm_is_playback(substream))
 		writel(0, kmb_i2s->i2s_base + ITER);
 	else
 		writel(0, kmb_i2s->i2s_base + IRER);
diff --git a/sound/soc/intel/skylake/skl-pcm.c b/sound/soc/intel/skylake/skl-pcm.c
index 613b27b8da134..2ffd511eedfe4 100644
--- a/sound/soc/intel/skylake/skl-pcm.c
+++ b/sound/soc/intel/skylake/skl-pcm.c
@@ -189,7 +189,7 @@ int skl_pcm_link_dma_prepare(struct device *dev, struct skl_pipe_params *params)
 	snd_hdac_ext_stream_setup(stream, format_val);
 
 	stream_tag = hstream->stream_tag;
-	if (stream->hstream.direction == SNDRV_PCM_STREAM_PLAYBACK) {
+	if (snd_pcm_is_playback(stream->hstream.direction)) {
 		list_for_each_entry(link, &bus->hlink_list, list) {
 			if (link->index == params->link_index)
 				snd_hdac_ext_bus_link_set_stream_id(link,
@@ -225,7 +225,7 @@ static int skl_pcm_open(struct snd_pcm_substream *substream,
 	 * disable WALLCLOCK timestamps for capture streams
 	 * until we figure out how to handle digital inputs
 	 */
-	if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
+	if (snd_pcm_is_capture(substream)) {
 		runtime->hw.info &= ~SNDRV_PCM_INFO_HAS_WALL_CLOCK; /* legacy */
 		runtime->hw.info &= ~SNDRV_PCM_INFO_HAS_LINK_ATIME;
 	}
@@ -319,7 +319,7 @@ static int skl_pcm_hw_params(struct snd_pcm_substream *substream,
 	p_params.host_dma_id = dma_id;
 	p_params.stream = substream->stream;
 	p_params.format = params_format(params);
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+	if (snd_pcm_is_playback(substream))
 		p_params.host_bps = dai->driver->playback.sig_bits;
 	else
 		p_params.host_bps = dai->driver->capture.sig_bits;
@@ -574,7 +574,7 @@ static int skl_link_hw_params(struct snd_pcm_substream *substream,
 	p_params.link_index = link->index;
 	p_params.format = params_format(params);
 
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+	if (snd_pcm_is_playback(substream))
 		p_params.link_bps = codec_dai->driver->playback.sig_bits;
 	else
 		p_params.link_bps = codec_dai->driver->capture.sig_bits;
@@ -645,7 +645,7 @@ static int skl_link_hw_free(struct snd_pcm_substream *substream,
 	if (!link)
 		return -EINVAL;
 
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+	if (snd_pcm_is_playback(substream)) {
 		stream_tag = hdac_stream(link_dev)->stream_tag;
 		snd_hdac_ext_bus_link_clear_stream_id(link, stream_tag);
 	}
@@ -1193,7 +1193,7 @@ static snd_pcm_uframes_t skl_platform_soc_pointer(
 	 * or greater than period boundary.
 	 */
 
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+	if (snd_pcm_is_playback(substream)) {
 		pos = readl(bus->remap_addr + AZX_REG_VS_SDXDPIB_XBASE +
 				(AZX_REG_VS_SDXDPIB_XINTERVAL *
 				hdac_stream(hstream)->index));
@@ -1226,7 +1226,7 @@ static u64 skl_adjust_codec_delay(struct snd_pcm_substream *substream,
 	codec_nsecs = div_u64(codec_frames * 1000000000LL,
 			      substream->runtime->rate);
 
-	if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
+	if (snd_pcm_is_capture(substream))
 		return nsec + codec_nsecs;
 
 	return (nsec > codec_nsecs) ? nsec - codec_nsecs : 0;
diff --git a/sound/soc/intel/skylake/skl-topology.c b/sound/soc/intel/skylake/skl-topology.c
index 602ef43211221..cb51b98b92c9a 100644
--- a/sound/soc/intel/skylake/skl-topology.c
+++ b/sound/soc/intel/skylake/skl-topology.c
@@ -198,7 +198,7 @@ static void skl_tplg_update_params_fixup(struct skl_module_cfg *m_cfg,
 	in_fmt = &m_cfg->module->formats[m_cfg->fmt_idx].inputs[0].fmt;
 	out_fmt = &m_cfg->module->formats[m_cfg->fmt_idx].outputs[0].fmt;
 
-	if (params->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+	if (snd_pcm_is_playback(params->stream)) {
 		if (is_fe) {
 			in_fixup = m_cfg->params_fixup;
 			out_fixup = (~m_cfg->converter) &
@@ -618,9 +618,9 @@ skl_tplg_get_pipe_config(struct skl_dev *skl, struct skl_module_cfg *mconfig)
 	}
 
 	if ((pipe->conn_type == SKL_PIPE_CONN_TYPE_FE &&
-	     pipe->direction == SNDRV_PCM_STREAM_PLAYBACK) ||
+	     snd_pcm_is_playback(pipe->direction)) ||
 	     (pipe->conn_type == SKL_PIPE_CONN_TYPE_BE &&
-	     pipe->direction == SNDRV_PCM_STREAM_CAPTURE))
+	      snd_pcm_is_capture(pipe->direction)))
 		in_fmt = true;
 
 	for (i = 0; i < pipe->nr_cfgs; i++) {
@@ -1612,7 +1612,7 @@ int skl_tplg_update_pipe_params(struct device *dev,
 	if (skl->nr_modules)
 		return 0;
 
-	if (params->stream == SNDRV_PCM_STREAM_PLAYBACK)
+	if (snd_pcm_is_playback(params->stream))
 		format = &mconfig->module->formats[mconfig->fmt_idx].inputs[0].fmt;
 	else
 		format = &mconfig->module->formats[mconfig->fmt_idx].outputs[0].fmt;
@@ -1642,7 +1642,7 @@ int skl_tplg_update_pipe_params(struct device *dev,
 		return -EINVAL;
 	}
 
-	if (params->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+	if (snd_pcm_is_playback(params->stream)) {
 		res->ibs = (format->s_freq / 1000) *
 				(format->channels) *
 				(format->bit_depth >> 3);
@@ -1666,7 +1666,7 @@ skl_tplg_fe_get_cpr_module(struct snd_soc_dai *dai, int stream)
 	struct snd_soc_dapm_widget *w = snd_soc_dai_get_widget(dai, stream);
 	struct snd_soc_dapm_path *p = NULL;
 
-	if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
+	if (snd_pcm_is_playback(stream)) {
 		snd_soc_dapm_widget_for_each_sink_path(w, p) {
 			if (p->connect && p->sink->power &&
 				!is_skl_dsp_widget_type(p->sink, dai->dev))
@@ -1745,7 +1745,7 @@ skl_tplg_be_get_cpr_module(struct snd_soc_dai *dai, int stream)
 	struct snd_soc_dapm_widget *w = snd_soc_dai_get_widget(dai, stream);
 	struct skl_module_cfg *mconfig;
 
-	if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
+	if (snd_pcm_is_playback(stream)) {
 		mconfig = skl_get_mconfig_pb_cpr(dai, w);
 	} else {
 		mconfig = skl_get_mconfig_cap_cpr(dai, w);
@@ -1813,7 +1813,7 @@ static int skl_tplg_be_fill_pipe_params(struct snd_soc_dai *dai,
 		goto err;
 
 	dev_dbg(skl->dev, "%s using pipe config: %d\n", __func__, pipe->cur_config_idx);
-	if (pipe->direction == SNDRV_PCM_STREAM_PLAYBACK)
+	if (snd_pcm_is_playback(pipe->direction))
 		pipe_fmt = &pipe->configs[pipe->cur_config_idx].out_fmt;
 	else
 		pipe_fmt = &pipe->configs[pipe->cur_config_idx].in_fmt;
@@ -1903,7 +1903,7 @@ int skl_tplg_be_update_params(struct snd_soc_dai *dai,
 {
 	struct snd_soc_dapm_widget *w = snd_soc_dai_get_widget(dai, params->stream);
 
-	if (params->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+	if (snd_pcm_is_playback(params->stream)) {
 		return skl_tplg_be_set_src_pipe_params(dai, w, params);
 	} else {
 		return skl_tplg_be_set_sink_pipe_params(dai, w, params);
-- 
2.43.0





[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux