Unverified Commit f202272c authored by Mark Brown's avatar Mark Brown
Browse files

Merge series "ASoC: add soc-link" from Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>:

Hi Mark

Current ALSA SoC is handling dai_link related operation,
but it is implmemented directly without using function/macro,
and at random place.

This v4 patch-set creates new snd_soc_link_xxx() functions
which handles dai_link related operation,
and implmement these at new soc-link.c.

v3 -> v4

	- add Reviewed-by from Ranjani and Pierre-Louis
	- fix bisection error at [2/7]

v2 -> v3

	- add missing #include <sound/soc-link.h> in soc-link.c

v1 -> v2
	- #include <sound/soc-link.h> is added on each c source file
	  instead of soc.h
	- not have extra error message after snd_soc_link_xxx(),
	  because it already indicate it via snc_link_ret()
	- snd_soc_link_compr_xxx() doesn't have rtd parameter,
	  because it can be created from cstream

Link: https://lore.kernel.org/r/87lflk4yk3.wl-kuninori.morimoto.gx@renesas.com
Link: https://lore.kernel.org/r/874ksa59wc.wl-kuninori.morimoto.gx@renesas.com
Link: https://lore.kernel.org/r/877dx868op.wl-kuninori.morimoto.gx@renesas.com

Kuninori Morimoto (7):
  ASoC: add soc-link.c
  ASoC: soc-link: move soc_rtd_xxx()
  ASoC: soc-link: remove unneeded parameter from snd_soc_link_xxx()
  ASoC: soc-link: add snd_soc_link_be_hw_params_fixup()
  ASoC: soc-link: add snd_soc_link_compr_startup()
  ASoC: soc-link: add snd_soc_link_compr_shutdown()
  ASoC: soc-link: add snd_soc_link_compr_set_params()

 include/sound/soc-link.h |  27 +++++++
 sound/soc/Makefile       |   2 +-
 sound/soc/soc-compress.c |  46 ++++--------
 sound/soc/soc-core.c     |  18 ++---
 sound/soc/soc-dai.c      |   9 ++-
 sound/soc/soc-link.c     | 150 +++++++++++++++++++++++++++++++++++++++
 sound/soc/soc-pcm.c      |  86 ++++------------------
 7 files changed, 219 insertions(+), 119 deletions(-)
 create mode 100644 include/sound/soc-link.h
 create mode 100644 sound/soc/soc-link.c

--
2.17.1

Thank you for your help !!

Best regards
---
Kuninori Morimoto
parents 3ca570da eab810f3
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0
 *
 * soc-link.h
 *
 * Copyright (C) 2019 Renesas Electronics Corp.
 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
 */
#ifndef __SOC_LINK_H
#define __SOC_LINK_H

int snd_soc_link_init(struct snd_soc_pcm_runtime *rtd);
int snd_soc_link_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
				    struct snd_pcm_hw_params *params);

int snd_soc_link_startup(struct snd_pcm_substream *substream);
void snd_soc_link_shutdown(struct snd_pcm_substream *substream);
int snd_soc_link_prepare(struct snd_pcm_substream *substream);
int snd_soc_link_hw_params(struct snd_pcm_substream *substream,
			   struct snd_pcm_hw_params *params);
void snd_soc_link_hw_free(struct snd_pcm_substream *substream);
int snd_soc_link_trigger(struct snd_pcm_substream *substream, int cmd);

int snd_soc_link_compr_startup(struct snd_compr_stream *cstream);
void snd_soc_link_compr_shutdown(struct snd_compr_stream *cstream);
int snd_soc_link_compr_set_params(struct snd_compr_stream *cstream);

#endif /* __SOC_LINK_H */
+1 −1
Original line number Diff line number Diff line
# SPDX-License-Identifier: GPL-2.0
snd-soc-core-objs := soc-core.o soc-dapm.o soc-jack.o soc-utils.o soc-dai.o soc-component.o
snd-soc-core-objs += soc-pcm.o soc-io.o soc-devres.o soc-ops.o
snd-soc-core-objs += soc-pcm.o soc-io.o soc-devres.o soc-ops.o soc-link.o
snd-soc-core-$(CONFIG_SND_SOC_COMPRESS) += soc-compress.o

ifneq ($(CONFIG_SND_SOC_TOPOLOGY),)
+15 −31
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
#include <sound/soc.h>
#include <sound/initval.h>
#include <sound/soc-dpcm.h>
#include <sound/soc-link.h>
#include <linux/pm_runtime.h>

static int soc_compr_components_open(struct snd_compr_stream *cstream,
@@ -95,15 +96,9 @@ static int soc_compr_open(struct snd_compr_stream *cstream)
	if (ret < 0)
		goto machine_err;

	if (rtd->dai_link->compr_ops && rtd->dai_link->compr_ops->startup) {
		ret = rtd->dai_link->compr_ops->startup(cstream);
		if (ret < 0) {
			dev_err(rtd->dev,
				"Compress ASoC: %s startup failed: %d\n",
				rtd->dai_link->name, ret);
	ret = snd_soc_link_compr_startup(cstream);
	if (ret < 0)
		goto machine_err;
		}
	}

	snd_soc_runtime_activate(rtd, cstream->direction);

@@ -179,14 +174,9 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream)
	if (ret < 0)
		goto open_err;

	if (fe->dai_link->compr_ops && fe->dai_link->compr_ops->startup) {
		ret = fe->dai_link->compr_ops->startup(cstream);
		if (ret < 0) {
			pr_err("Compress ASoC: %s startup failed: %d\n",
			       fe->dai_link->name, ret);
	ret = snd_soc_link_compr_startup(cstream);
	if (ret < 0)
		goto machine_err;
		}
	}

	dpcm_clear_pending_state(fe, stream);
	dpcm_path_put(&list);
@@ -237,8 +227,7 @@ static int soc_compr_free(struct snd_compr_stream *cstream)
	if (!snd_soc_dai_active(codec_dai))
		codec_dai->rate = 0;

	if (rtd->dai_link->compr_ops && rtd->dai_link->compr_ops->shutdown)
		rtd->dai_link->compr_ops->shutdown(cstream);
	snd_soc_link_compr_shutdown(cstream);

	soc_compr_components_free(cstream, NULL);

@@ -293,8 +282,7 @@ static int soc_compr_free_fe(struct snd_compr_stream *cstream)

	fe->dpcm[stream].runtime = NULL;

	if (fe->dai_link->compr_ops && fe->dai_link->compr_ops->shutdown)
		fe->dai_link->compr_ops->shutdown(cstream);
	snd_soc_link_compr_shutdown(cstream);

	soc_compr_components_free(cstream, NULL);

@@ -451,11 +439,9 @@ static int soc_compr_set_params(struct snd_compr_stream *cstream,
	if (ret < 0)
		goto err;

	if (rtd->dai_link->compr_ops && rtd->dai_link->compr_ops->set_params) {
		ret = rtd->dai_link->compr_ops->set_params(cstream);
	ret = snd_soc_link_compr_set_params(cstream);
	if (ret < 0)
		goto err;
	}

	if (cstream->direction == SND_COMPRESS_PLAYBACK)
		snd_soc_dapm_stream_event(rtd, SNDRV_PCM_STREAM_PLAYBACK,
@@ -519,11 +505,9 @@ static int soc_compr_set_params_fe(struct snd_compr_stream *cstream,
	if (ret < 0)
		goto out;

	if (fe->dai_link->compr_ops && fe->dai_link->compr_ops->set_params) {
		ret = fe->dai_link->compr_ops->set_params(cstream);
	ret = snd_soc_link_compr_set_params(cstream);
	if (ret < 0)
		goto out;
	}

	dpcm_dapm_stream_event(fe, stream, SND_SOC_DAPM_STREAM_START);
	fe->dpcm[stream].state = SND_SOC_DPCM_STATE_PREPARE;
+9 −9
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@
#include <sound/soc.h>
#include <sound/soc-dpcm.h>
#include <sound/soc-topology.h>
#include <sound/soc-link.h>
#include <sound/initval.h>

#define CREATE_TRACE_POINTS
@@ -1049,14 +1050,9 @@ static int soc_init_pcm_runtime(struct snd_soc_card *card,
	rtd->pmdown_time = pmdown_time;

	/* do machine specific initialization */
	if (dai_link->init) {
		ret = dai_link->init(rtd);
		if (ret < 0) {
			dev_err(card->dev, "ASoC: failed to init %s: %d\n",
				dai_link->name, ret);
	ret = snd_soc_link_init(rtd);
	if (ret < 0)
		return ret;
		}
	}

	if (dai_link->dai_fmt) {
		ret = snd_soc_runtime_set_dai_fmt(rtd, dai_link->dai_fmt);
@@ -1660,7 +1656,11 @@ match:
			dai_link->dpcm_playback = 1;
			dai_link->dpcm_capture = 1;

			/* override any BE fixups */
			/*
			 * override any BE fixups
			 * see
			 *	snd_soc_link_be_hw_params_fixup()
			 */
			dai_link->be_hw_params_fixup =
				component->driver->be_hw_params_fixup;

+4 −5
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@

#include <sound/soc.h>
#include <sound/soc-dai.h>
#include <sound/soc-link.h>

#define soc_dai_ret(dai, ret) _soc_dai_ret(dai, __func__, ret)
static inline int _soc_dai_ret(struct snd_soc_dai *dai,
@@ -313,11 +314,9 @@ int snd_soc_dai_hw_params(struct snd_soc_dai *dai,
	int ret = 0;

	/* perform any topology hw_params fixups before DAI  */
	if (rtd->dai_link->be_hw_params_fixup) {
		ret = rtd->dai_link->be_hw_params_fixup(rtd, params);
	ret = snd_soc_link_be_hw_params_fixup(rtd, params);
	if (ret < 0)
		goto end;
	}

	if (dai->driver->ops &&
	    dai->driver->ops->hw_params)
Loading