[PATCH 0/7] ASoC: add soc-link
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 patch-set creates new snd_soc_link_xxx() functions which handle dai_link related operation, and implmement these at new soc-link.c.
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 | 30 ++++++++ include/sound/soc.h | 1 + sound/soc/Makefile | 2 +- sound/soc/soc-compress.c | 45 ++++-------- sound/soc/soc-core.c | 17 +++-- sound/soc/soc-dai.c | 8 +-- sound/soc/soc-link.c | 149 +++++++++++++++++++++++++++++++++++++++ sound/soc/soc-pcm.c | 86 ++++------------------ 8 files changed, 220 insertions(+), 118 deletions(-) create mode 100644 include/sound/soc-link.h create mode 100644 sound/soc/soc-link.c
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Current ALSA SoC has many dai_link->xxx() functions. But, it is implemented randomly at random place.
This patch creates new soc-link.c to collect dai_link related operation into it.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- include/sound/soc-link.h | 13 +++++++++++++ include/sound/soc.h | 1 + sound/soc/Makefile | 2 +- sound/soc/soc-core.c | 11 +++-------- sound/soc/soc-link.c | 36 ++++++++++++++++++++++++++++++++++++ 5 files changed, 54 insertions(+), 9 deletions(-) create mode 100644 include/sound/soc-link.h create mode 100644 sound/soc/soc-link.c
diff --git a/include/sound/soc-link.h b/include/sound/soc-link.h new file mode 100644 index 000000000000..7fc5cead5942 --- /dev/null +++ b/include/sound/soc-link.h @@ -0,0 +1,13 @@ +/* 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); + +#endif /* __SOC_LINK_H */ diff --git a/include/sound/soc.h b/include/sound/soc.h index a7fa64260108..81d5337963ce 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -1449,5 +1449,6 @@ static inline void snd_soc_dapm_mutex_unlock(struct snd_soc_dapm_context *dapm) }
#include <sound/soc-component.h> +#include <sound/soc-link.h>
#endif diff --git a/sound/soc/Makefile b/sound/soc/Makefile index 861a21b79484..70a5f19ea3a1 100644 --- a/sound/soc/Makefile +++ b/sound/soc/Makefile @@ -1,6 +1,6 @@ # 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),) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index e697258d2ffc..d5450e61626a 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1049,14 +1049,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); - return 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); diff --git a/sound/soc/soc-link.c b/sound/soc/soc-link.c new file mode 100644 index 000000000000..4bdd8d0dd93a --- /dev/null +++ b/sound/soc/soc-link.c @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// soc-link.c +// +// Copyright (C) 2019 Renesas Electronics Corp. +// Kuninori Morimoto kuninori.morimoto.gx@renesas.com +// +#include <sound/soc.h> + +#define soc_link_ret(rtd, ret) _soc_link_ret(rtd, __func__, ret) +static inline int _soc_link_ret(struct snd_soc_pcm_runtime *rtd, + const char *func, int ret) +{ + switch (ret) { + case -EPROBE_DEFER: + case -ENOTSUPP: + case 0: + break; + default: + dev_err(rtd->dev, + "ASoC: error at %s on %s: %d\n", + func, rtd->dai_link->name, ret); + } + + return ret; +} + +int snd_soc_link_init(struct snd_soc_pcm_runtime *rtd) +{ + int ret = 0; + + if (rtd->dai_link->init) + ret = rtd->dai_link->init(rtd); + + return soc_link_ret(rtd, ret); +}
On Tue, 2020-05-19 at 10:01 +0900, Kuninori Morimoto wrote:
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Current ALSA SoC has many dai_link->xxx() functions. But, it is implemented randomly at random place.
This patch creates new soc-link.c to collect dai_link related operation into it.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
include/sound/soc-link.h | 13 +++++++++++++ include/sound/soc.h | 1 + sound/soc/Makefile | 2 +- sound/soc/soc-core.c | 11 +++-------- sound/soc/soc-link.c | 36 ++++++++++++++++++++++++++++++++++++ 5 files changed, 54 insertions(+), 9 deletions(-) create mode 100644 include/sound/soc-link.h create mode 100644 sound/soc/soc-link.c
diff --git a/include/sound/soc-link.h b/include/sound/soc-link.h new file mode 100644 index 000000000000..7fc5cead5942 --- /dev/null +++ b/include/sound/soc-link.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0
- soc-link.h
- Copyright (C) 2019 Renesas Electronics Corp.
2020?
- 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);
+#endif /* __SOC_LINK_H */ diff --git a/include/sound/soc.h b/include/sound/soc.h index a7fa64260108..81d5337963ce 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -1449,5 +1449,6 @@ static inline void snd_soc_dapm_mutex_unlock(struct snd_soc_dapm_context *dapm) }
#include <sound/soc-component.h> +#include <sound/soc-link.h>
Why do we need to include this in soc.h? Is it to ensure that soc- link.h included in all files that include soc.h?
I think the right way to do this would be include soc-link.h where it is needed, say for example in soc-pcm.c etc.
#endif diff --git a/sound/soc/Makefile b/sound/soc/Makefile index 861a21b79484..70a5f19ea3a1 100644 --- a/sound/soc/Makefile +++ b/sound/soc/Makefile @@ -1,6 +1,6 @@ # 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),) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index e697258d2ffc..d5450e61626a 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1049,14 +1049,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);
return 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);
diff --git a/sound/soc/soc-link.c b/sound/soc/soc-link.c new file mode 100644 index 000000000000..4bdd8d0dd93a --- /dev/null +++ b/sound/soc/soc-link.c @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// soc-link.c +// +// Copyright (C) 2019 Renesas Electronics Corp.
2020? Thanks, Ranjani
Hi Ranjani
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Current ALSA SoC has many dai_link->xxx() functions. But, it is implemented randomly at random place.
This patch creates new soc-link.c to collect dai_link related operation into it.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
(snip)
#include <sound/soc-component.h> +#include <sound/soc-link.h>
Why do we need to include this in soc.h? Is it to ensure that soc- link.h included in all files that include soc.h?
I think the right way to do this would be include soc-link.h where it is needed, say for example in soc-pcm.c etc.
OK. Will check and update it in v2
Thank you for your help !!
Best regards --- Kuninori Morimoto
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
dai_link related function should be implemented at soc-link.c. This patch moves soc-pcm soc_rtd_xxx() to soc-link as snd_soc_link_xxx()
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- include/sound/soc-link.h | 13 ++++++++ sound/soc/soc-link.c | 65 ++++++++++++++++++++++++++++++++++++ sound/soc/soc-pcm.c | 72 +++++----------------------------------- 3 files changed, 87 insertions(+), 63 deletions(-)
diff --git a/include/sound/soc-link.h b/include/sound/soc-link.h index 7fc5cead5942..689aa93be78e 100644 --- a/include/sound/soc-link.h +++ b/include/sound/soc-link.h @@ -9,5 +9,18 @@ #define __SOC_LINK_H
int snd_soc_link_init(struct snd_soc_pcm_runtime *rtd); +int snd_soc_link_startup(struct snd_soc_pcm_runtime *rtd, + struct snd_pcm_substream *substream); +void snd_soc_link_shutdown(struct snd_soc_pcm_runtime *rtd, + struct snd_pcm_substream *substream); +int snd_soc_link_prepare(struct snd_soc_pcm_runtime *rtd, + struct snd_pcm_substream *substream); +int snd_soc_link_hw_params(struct snd_soc_pcm_runtime *rtd, + struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params); +void snd_soc_link_hw_free(struct snd_soc_pcm_runtime *rtd, + struct snd_pcm_substream *substream); +int snd_soc_link_trigger(struct snd_soc_pcm_runtime *rtd, + struct snd_pcm_substream *substream, int cmd);
#endif /* __SOC_LINK_H */ diff --git a/sound/soc/soc-link.c b/sound/soc/soc-link.c index 4bdd8d0dd93a..be6a6ecfc9dc 100644 --- a/sound/soc/soc-link.c +++ b/sound/soc/soc-link.c @@ -34,3 +34,68 @@ int snd_soc_link_init(struct snd_soc_pcm_runtime *rtd)
return soc_link_ret(rtd, ret); } + +int snd_soc_link_startup(struct snd_soc_pcm_runtime *rtd, + struct snd_pcm_substream *substream) +{ + int ret = 0; + + if (rtd->dai_link->ops && + rtd->dai_link->ops->startup) + ret = rtd->dai_link->ops->startup(substream); + + return soc_link_ret(rtd, ret); +} + +void snd_soc_link_shutdown(struct snd_soc_pcm_runtime *rtd, + struct snd_pcm_substream *substream) +{ + if (rtd->dai_link->ops && + rtd->dai_link->ops->shutdown) + rtd->dai_link->ops->shutdown(substream); +} + +int snd_soc_link_prepare(struct snd_soc_pcm_runtime *rtd, + struct snd_pcm_substream *substream) +{ + int ret = 0; + + if (rtd->dai_link->ops && + rtd->dai_link->ops->prepare) + ret = rtd->dai_link->ops->prepare(substream); + + return soc_link_ret(rtd, ret); +} + +int snd_soc_link_hw_params(struct snd_soc_pcm_runtime *rtd, + struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + int ret = 0; + + if (rtd->dai_link->ops && + rtd->dai_link->ops->hw_params) + ret = rtd->dai_link->ops->hw_params(substream, params); + + return soc_link_ret(rtd, ret); +} + +void snd_soc_link_hw_free(struct snd_soc_pcm_runtime *rtd, + struct snd_pcm_substream *substream) +{ + if (rtd->dai_link->ops && + rtd->dai_link->ops->hw_free) + rtd->dai_link->ops->hw_free(substream); +} + +int snd_soc_link_trigger(struct snd_soc_pcm_runtime *rtd, + struct snd_pcm_substream *substream, int cmd) +{ + int ret = 0; + + if (rtd->dai_link->ops && + rtd->dai_link->ops->trigger) + ret = rtd->dai_link->ops->trigger(substream, cmd); + + return soc_link_ret(rtd, ret); +} diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index b7899da4217e..20857145bd6d 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -202,60 +202,6 @@ static inline void dpcm_remove_debugfs_state(struct snd_soc_dpcm *dpcm) } #endif
-static int soc_rtd_startup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_substream *substream) -{ - if (rtd->dai_link->ops && - rtd->dai_link->ops->startup) - return rtd->dai_link->ops->startup(substream); - return 0; -} - -static void soc_rtd_shutdown(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_substream *substream) -{ - if (rtd->dai_link->ops && - rtd->dai_link->ops->shutdown) - rtd->dai_link->ops->shutdown(substream); -} - -static int soc_rtd_prepare(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_substream *substream) -{ - if (rtd->dai_link->ops && - rtd->dai_link->ops->prepare) - return rtd->dai_link->ops->prepare(substream); - return 0; -} - -static int soc_rtd_hw_params(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - if (rtd->dai_link->ops && - rtd->dai_link->ops->hw_params) - return rtd->dai_link->ops->hw_params(substream, params); - return 0; -} - -static void soc_rtd_hw_free(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_substream *substream) -{ - if (rtd->dai_link->ops && - rtd->dai_link->ops->hw_free) - rtd->dai_link->ops->hw_free(substream); -} - -static int soc_rtd_trigger(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_substream *substream, - int cmd) -{ - if (rtd->dai_link->ops && - rtd->dai_link->ops->trigger) - return rtd->dai_link->ops->trigger(substream, cmd); - return 0; -} - /** * snd_soc_runtime_action() - Increment/Decrement active count for * PCM runtime components @@ -736,7 +682,7 @@ static int soc_pcm_close(struct snd_pcm_substream *substream) for_each_rtd_dais(rtd, i, dai) snd_soc_dai_shutdown(dai, substream);
- soc_rtd_shutdown(rtd, substream); + snd_soc_link_shutdown(rtd, substream);
soc_pcm_components_close(substream);
@@ -783,7 +729,7 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) if (ret < 0) goto component_err;
- ret = soc_rtd_startup(rtd, substream); + ret = snd_soc_link_startup(rtd, substream); if (ret < 0) { pr_err("ASoC: %s startup failed: %d\n", rtd->dai_link->name, ret); @@ -870,7 +816,7 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) for_each_rtd_dais(rtd, i, dai) snd_soc_dai_shutdown(dai, substream);
- soc_rtd_shutdown(rtd, substream); + snd_soc_link_shutdown(rtd, substream); rtd_startup_err: soc_pcm_components_close(substream); component_err: @@ -912,7 +858,7 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream)
mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
- ret = soc_rtd_prepare(rtd, substream); + ret = snd_soc_link_prepare(rtd, substream); if (ret < 0) { dev_err(rtd->card->dev, "ASoC: machine prepare error: %d\n", ret); @@ -1002,7 +948,7 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream, if (ret) goto out;
- ret = soc_rtd_hw_params(rtd, substream, params); + ret = snd_soc_link_hw_params(rtd, substream, params); if (ret < 0) { dev_err(rtd->card->dev, "ASoC: machine hw_params failed: %d\n", ret); @@ -1117,7 +1063,7 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream, codec_dai->rate = 0; }
- soc_rtd_hw_free(rtd, substream); + snd_soc_link_hw_free(rtd, substream);
mutex_unlock(&rtd->card->pcm_mutex); return ret; @@ -1149,7 +1095,7 @@ static int soc_pcm_hw_free(struct snd_pcm_substream *substream) }
/* free any machine hw params */ - soc_rtd_hw_free(rtd, substream); + snd_soc_link_hw_free(rtd, substream);
/* free any component resources */ soc_pcm_components_hw_free(substream, NULL); @@ -1172,7 +1118,7 @@ static int soc_pcm_trigger_start(struct snd_pcm_substream *substream, int cmd) struct snd_soc_component *component; int i, ret;
- ret = soc_rtd_trigger(rtd, substream, cmd); + ret = snd_soc_link_trigger(rtd, substream, cmd); if (ret < 0) return ret;
@@ -1201,7 +1147,7 @@ static int soc_pcm_trigger_stop(struct snd_pcm_substream *substream, int cmd) return ret; }
- ret = soc_rtd_trigger(rtd, substream, cmd); + ret = snd_soc_link_trigger(rtd, substream, cmd); if (ret < 0) return ret;
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
"rtd" can be created from "substream". Let's cleanup snd_soc_link_xxx().
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- include/sound/soc-link.h | 18 ++++++------------ sound/soc/soc-link.c | 26 ++++++++++++++------------ sound/soc/soc-pcm.c | 18 +++++++++--------- 3 files changed, 29 insertions(+), 33 deletions(-)
diff --git a/include/sound/soc-link.h b/include/sound/soc-link.h index 689aa93be78e..2a81dca945cd 100644 --- a/include/sound/soc-link.h +++ b/include/sound/soc-link.h @@ -9,18 +9,12 @@ #define __SOC_LINK_H
int snd_soc_link_init(struct snd_soc_pcm_runtime *rtd); -int snd_soc_link_startup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_substream *substream); -void snd_soc_link_shutdown(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_substream *substream); -int snd_soc_link_prepare(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_substream *substream); -int snd_soc_link_hw_params(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_substream *substream, +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_soc_pcm_runtime *rtd, - struct snd_pcm_substream *substream); -int snd_soc_link_trigger(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_substream *substream, int cmd); +void snd_soc_link_hw_free(struct snd_pcm_substream *substream); +int snd_soc_link_trigger(struct snd_pcm_substream *substream, int cmd);
#endif /* __SOC_LINK_H */ diff --git a/sound/soc/soc-link.c b/sound/soc/soc-link.c index be6a6ecfc9dc..691910e82bff 100644 --- a/sound/soc/soc-link.c +++ b/sound/soc/soc-link.c @@ -35,9 +35,9 @@ int snd_soc_link_init(struct snd_soc_pcm_runtime *rtd) return soc_link_ret(rtd, ret); }
-int snd_soc_link_startup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_substream *substream) +int snd_soc_link_startup(struct snd_pcm_substream *substream) { + struct snd_soc_pcm_runtime *rtd = substream->private_data; int ret = 0;
if (rtd->dai_link->ops && @@ -47,17 +47,18 @@ int snd_soc_link_startup(struct snd_soc_pcm_runtime *rtd, return soc_link_ret(rtd, ret); }
-void snd_soc_link_shutdown(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_substream *substream) +void snd_soc_link_shutdown(struct snd_pcm_substream *substream) { + struct snd_soc_pcm_runtime *rtd = substream->private_data; + if (rtd->dai_link->ops && rtd->dai_link->ops->shutdown) rtd->dai_link->ops->shutdown(substream); }
-int snd_soc_link_prepare(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_substream *substream) +int snd_soc_link_prepare(struct snd_pcm_substream *substream) { + struct snd_soc_pcm_runtime *rtd = substream->private_data; int ret = 0;
if (rtd->dai_link->ops && @@ -67,10 +68,10 @@ int snd_soc_link_prepare(struct snd_soc_pcm_runtime *rtd, return soc_link_ret(rtd, ret); }
-int snd_soc_link_hw_params(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_substream *substream, +int snd_soc_link_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { + struct snd_soc_pcm_runtime *rtd = substream->private_data; int ret = 0;
if (rtd->dai_link->ops && @@ -80,17 +81,18 @@ int snd_soc_link_hw_params(struct snd_soc_pcm_runtime *rtd, return soc_link_ret(rtd, ret); }
-void snd_soc_link_hw_free(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_substream *substream) +void snd_soc_link_hw_free(struct snd_pcm_substream *substream) { + struct snd_soc_pcm_runtime *rtd = substream->private_data; + if (rtd->dai_link->ops && rtd->dai_link->ops->hw_free) rtd->dai_link->ops->hw_free(substream); }
-int snd_soc_link_trigger(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_substream *substream, int cmd) +int snd_soc_link_trigger(struct snd_pcm_substream *substream, int cmd) { + struct snd_soc_pcm_runtime *rtd = substream->private_data; int ret = 0;
if (rtd->dai_link->ops && diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 20857145bd6d..2b5068001efb 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -682,7 +682,7 @@ static int soc_pcm_close(struct snd_pcm_substream *substream) for_each_rtd_dais(rtd, i, dai) snd_soc_dai_shutdown(dai, substream);
- snd_soc_link_shutdown(rtd, substream); + snd_soc_link_shutdown(substream);
soc_pcm_components_close(substream);
@@ -729,7 +729,7 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) if (ret < 0) goto component_err;
- ret = snd_soc_link_startup(rtd, substream); + ret = snd_soc_link_startup(substream); if (ret < 0) { pr_err("ASoC: %s startup failed: %d\n", rtd->dai_link->name, ret); @@ -816,7 +816,7 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) for_each_rtd_dais(rtd, i, dai) snd_soc_dai_shutdown(dai, substream);
- snd_soc_link_shutdown(rtd, substream); + snd_soc_link_shutdown(substream); rtd_startup_err: soc_pcm_components_close(substream); component_err: @@ -858,7 +858,7 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream)
mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
- ret = snd_soc_link_prepare(rtd, substream); + ret = snd_soc_link_prepare(substream); if (ret < 0) { dev_err(rtd->card->dev, "ASoC: machine prepare error: %d\n", ret); @@ -948,7 +948,7 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream, if (ret) goto out;
- ret = snd_soc_link_hw_params(rtd, substream, params); + ret = snd_soc_link_hw_params(substream, params); if (ret < 0) { dev_err(rtd->card->dev, "ASoC: machine hw_params failed: %d\n", ret); @@ -1063,7 +1063,7 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream, codec_dai->rate = 0; }
- snd_soc_link_hw_free(rtd, substream); + snd_soc_link_hw_free(substream);
mutex_unlock(&rtd->card->pcm_mutex); return ret; @@ -1095,7 +1095,7 @@ static int soc_pcm_hw_free(struct snd_pcm_substream *substream) }
/* free any machine hw params */ - snd_soc_link_hw_free(rtd, substream); + snd_soc_link_hw_free(substream);
/* free any component resources */ soc_pcm_components_hw_free(substream, NULL); @@ -1118,7 +1118,7 @@ static int soc_pcm_trigger_start(struct snd_pcm_substream *substream, int cmd) struct snd_soc_component *component; int i, ret;
- ret = snd_soc_link_trigger(rtd, substream, cmd); + ret = snd_soc_link_trigger(substream, cmd); if (ret < 0) return ret;
@@ -1147,7 +1147,7 @@ static int soc_pcm_trigger_stop(struct snd_pcm_substream *substream, int cmd) return ret; }
- ret = snd_soc_link_trigger(rtd, substream, cmd); + ret = snd_soc_link_trigger(substream, cmd); if (ret < 0) return ret;
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
dai_link related function should be implemented at soc-link.c. This patch adds snd_soc_link_be_hw_params_fixup().
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- include/sound/soc-link.h | 3 +++ sound/soc/soc-core.c | 6 +++++- sound/soc/soc-dai.c | 8 +++----- sound/soc/soc-link.c | 11 +++++++++++ sound/soc/soc-pcm.c | 14 +++++--------- 5 files changed, 27 insertions(+), 15 deletions(-)
diff --git a/include/sound/soc-link.h b/include/sound/soc-link.h index 2a81dca945cd..aae72f668de6 100644 --- a/include/sound/soc-link.h +++ b/include/sound/soc-link.h @@ -9,6 +9,9 @@ #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); diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index d5450e61626a..d6818f8c7f1d 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1655,7 +1655,11 @@ static void soc_check_tplg_fes(struct snd_soc_card *card) 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;
diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c index ce4e1fd1ab79..39959cc99bc9 100644 --- a/sound/soc/soc-dai.c +++ b/sound/soc/soc-dai.c @@ -313,11 +313,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); - if (ret < 0) - goto end; - } + ret = snd_soc_link_be_hw_params_fixup(rtd, params); + if (ret < 0) + goto end;
if (dai->driver->ops && dai->driver->ops->hw_params) diff --git a/sound/soc/soc-link.c b/sound/soc/soc-link.c index 691910e82bff..a735b3ba2385 100644 --- a/sound/soc/soc-link.c +++ b/sound/soc/soc-link.c @@ -35,6 +35,17 @@ int snd_soc_link_init(struct snd_soc_pcm_runtime *rtd) return soc_link_ret(rtd, ret); }
+int snd_soc_link_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, + struct snd_pcm_hw_params *params) +{ + int ret = 0; + + if (rtd->dai_link->be_hw_params_fixup) + ret = rtd->dai_link->be_hw_params_fixup(rtd, params); + + return soc_link_ret(rtd, ret); +} + int snd_soc_link_startup(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 2b5068001efb..26246228d8c5 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -2087,15 +2087,11 @@ int dpcm_be_dai_hw_params(struct snd_soc_pcm_runtime *fe, int stream) sizeof(struct snd_pcm_hw_params));
/* perform any hw_params fixups */ - if (be->dai_link->be_hw_params_fixup) { - ret = be->dai_link->be_hw_params_fixup(be, - &dpcm->hw_params); - if (ret < 0) { - dev_err(be->dev, - "ASoC: hw_params BE fixup failed %d\n", - ret); - goto unwind; - } + ret = snd_soc_link_be_hw_params_fixup(be, &dpcm->hw_params); + if (ret < 0) { + dev_err(be->dev, + "ASoC: hw_params BE fixup failed %d\n", ret); + goto unwind; }
/* copy the fixed-up hw params for BE dai */
On Tue, 2020-05-19 at 10:02 +0900, Kuninori Morimoto wrote:
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
dai_link related function should be implemented at soc-link.c. This patch adds snd_soc_link_be_hw_params_fixup().
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
include/sound/soc-link.h | 3 +++ sound/soc/soc-core.c | 6 +++++- sound/soc/soc-dai.c | 8 +++----- sound/soc/soc-link.c | 11 +++++++++++ sound/soc/soc-pcm.c | 14 +++++--------- 5 files changed, 27 insertions(+), 15 deletions(-)
diff --git a/include/sound/soc-link.h b/include/sound/soc-link.h index 2a81dca945cd..aae72f668de6 100644 --- a/include/sound/soc-link.h +++ b/include/sound/soc-link.h @@ -9,6 +9,9 @@ #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); diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index d5450e61626a..d6818f8c7f1d 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1655,7 +1655,11 @@ static void soc_check_tplg_fes(struct snd_soc_card *card) 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;
diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c index ce4e1fd1ab79..39959cc99bc9 100644 --- a/sound/soc/soc-dai.c +++ b/sound/soc/soc-dai.c @@ -313,11 +313,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);
if (ret < 0)
goto end;
- }
ret = snd_soc_link_be_hw_params_fixup(rtd, params);
if (ret < 0)
goto end;
if (dai->driver->ops && dai->driver->ops->hw_params)
diff --git a/sound/soc/soc-link.c b/sound/soc/soc-link.c index 691910e82bff..a735b3ba2385 100644 --- a/sound/soc/soc-link.c +++ b/sound/soc/soc-link.c @@ -35,6 +35,17 @@ int snd_soc_link_init(struct snd_soc_pcm_runtime *rtd) return soc_link_ret(rtd, ret); }
+int snd_soc_link_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
struct snd_pcm_hw_params *params)
+{
- int ret = 0;
- if (rtd->dai_link->be_hw_params_fixup)
ret = rtd->dai_link->be_hw_params_fixup(rtd, params);
- return soc_link_ret(rtd, ret);
+}
int snd_soc_link_startup(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 2b5068001efb..26246228d8c5 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -2087,15 +2087,11 @@ int dpcm_be_dai_hw_params(struct snd_soc_pcm_runtime *fe, int stream) sizeof(struct snd_pcm_hw_params));
/* perform any hw_params fixups */
if (be->dai_link->be_hw_params_fixup) {
ret = be->dai_link->be_hw_params_fixup(be,
&dpcm->hw_params);
if (ret < 0) {
dev_err(be->dev,
"ASoC: hw_params BE fixup
failed %d\n",
ret);
goto unwind;
}
ret = snd_soc_link_be_hw_params_fixup(be, &dpcm-
hw_params);
if (ret < 0) {
dev_err(be->dev,
"ASoC: hw_params BE fixup failed %d\n",
ret);
We can remove this error too isnt it? snd_soc_link_be_hw_params_fixup() would already have printed an error and this would be a duplicate?
Thanks, Ranjani
Hi Ranjani
Thank you for reviewing
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
dai_link related function should be implemented at soc-link.c. This patch adds snd_soc_link_be_hw_params_fixup().
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
(snip)
if (ret < 0) {
dev_err(be->dev,
"ASoC: hw_params BE fixup failed %d\n",
ret);
We can remove this error too isnt it? snd_soc_link_be_hw_params_fixup() would already have printed an error and this would be a duplicate?
Oh, yes. Will fixup it in v2
Thank you for your help !!
Best regards --- Kuninori Morimoto
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
dai_link related function should be implemented at soc-link.c. This patch adds snd_soc_link_compr_startup().
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- include/sound/soc-link.h | 3 +++ sound/soc/soc-compress.c | 23 ++++++----------------- sound/soc/soc-link.c | 13 +++++++++++++ 3 files changed, 22 insertions(+), 17 deletions(-)
diff --git a/include/sound/soc-link.h b/include/sound/soc-link.h index aae72f668de6..c152576cbd87 100644 --- a/include/sound/soc-link.h +++ b/include/sound/soc-link.h @@ -20,4 +20,7 @@ int snd_soc_link_hw_params(struct snd_pcm_substream *substream, 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_soc_pcm_runtime *rtd, + struct snd_compr_stream *cstream); + #endif /* __SOC_LINK_H */ diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c index 62ece729e425..35b0af86325a 100644 --- a/sound/soc/soc-compress.c +++ b/sound/soc/soc-compress.c @@ -95,15 +95,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); - goto machine_err; - } - } + ret = snd_soc_link_compr_startup(rtd, cstream); + if (ret < 0) + goto machine_err;
snd_soc_runtime_activate(rtd, cstream->direction);
@@ -179,14 +173,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); - goto machine_err; - } - } + ret = snd_soc_link_compr_startup(fe, cstream); + if (ret < 0) + goto machine_err;
dpcm_clear_pending_state(fe, stream); dpcm_path_put(&list); diff --git a/sound/soc/soc-link.c b/sound/soc/soc-link.c index a735b3ba2385..dddc4a35a0ac 100644 --- a/sound/soc/soc-link.c +++ b/sound/soc/soc-link.c @@ -112,3 +112,16 @@ int snd_soc_link_trigger(struct snd_pcm_substream *substream, int cmd)
return soc_link_ret(rtd, ret); } + +int snd_soc_link_compr_startup(struct snd_soc_pcm_runtime *rtd, + struct snd_compr_stream *cstream) +{ + int ret = 0; + + if (rtd->dai_link->compr_ops && + rtd->dai_link->compr_ops->startup) + ret = rtd->dai_link->compr_ops->startup(cstream); + + return soc_link_ret(rtd, ret); +} +EXPORT_SYMBOL_GPL(snd_soc_link_compr_startup);
On Tue, 2020-05-19 at 10:02 +0900, Kuninori Morimoto wrote:
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
dai_link related function should be implemented at soc-link.c. This patch adds snd_soc_link_compr_startup().
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
include/sound/soc-link.h | 3 +++ sound/soc/soc-compress.c | 23 ++++++----------------- sound/soc/soc-link.c | 13 +++++++++++++ 3 files changed, 22 insertions(+), 17 deletions(-)
diff --git a/include/sound/soc-link.h b/include/sound/soc-link.h index aae72f668de6..c152576cbd87 100644 --- a/include/sound/soc-link.h +++ b/include/sound/soc-link.h @@ -20,4 +20,7 @@ int snd_soc_link_hw_params(struct snd_pcm_substream *substream, 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_soc_pcm_runtime *rtd,
struct snd_compr_stream *cstream);
#endif /* __SOC_LINK_H */ diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c index 62ece729e425..35b0af86325a 100644 --- a/sound/soc/soc-compress.c +++ b/sound/soc/soc-compress.c @@ -95,15 +95,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);
goto machine_err;
}
- }
ret = snd_soc_link_compr_startup(rtd, cstream);
if (ret < 0)
goto machine_err;
snd_soc_runtime_activate(rtd, cstream->direction);
@@ -179,14 +173,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);
goto machine_err;
}
- }
ret = snd_soc_link_compr_startup(fe, cstream);
if (ret < 0)
goto machine_err;
dpcm_clear_pending_state(fe, stream); dpcm_path_put(&list);
diff --git a/sound/soc/soc-link.c b/sound/soc/soc-link.c index a735b3ba2385..dddc4a35a0ac 100644 --- a/sound/soc/soc-link.c +++ b/sound/soc/soc-link.c @@ -112,3 +112,16 @@ int snd_soc_link_trigger(struct snd_pcm_substream *substream, int cmd)
return soc_link_ret(rtd, ret); }
+int snd_soc_link_compr_startup(struct snd_soc_pcm_runtime *rtd,
struct snd_compr_stream *cstream)
Can we do the same think as for pcm substream and remove the rtd param?
Thanks, Ranjani
Hi Ranjani
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
dai_link related function should be implemented at soc-link.c. This patch adds snd_soc_link_compr_startup().
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
(snip)
+int snd_soc_link_compr_startup(struct snd_soc_pcm_runtime *rtd,
struct snd_compr_stream *cstream)
Can we do the same think as for pcm substream and remove the rtd param?
Yes, Indeed ! Will update it in v2
Thank you for your help !!
Best regards --- Kuninori Morimoto
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
dai_link related function should be implemented at soc-link.c. This patch adds snd_soc_link_compr_shutdown().
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- include/sound/soc-link.h | 2 ++ sound/soc/soc-compress.c | 6 ++---- sound/soc/soc-link.c | 9 +++++++++ 3 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/include/sound/soc-link.h b/include/sound/soc-link.h index c152576cbd87..83ca7301c91b 100644 --- a/include/sound/soc-link.h +++ b/include/sound/soc-link.h @@ -22,5 +22,7 @@ int snd_soc_link_trigger(struct snd_pcm_substream *substream, int cmd);
int snd_soc_link_compr_startup(struct snd_soc_pcm_runtime *rtd, struct snd_compr_stream *cstream); +void snd_soc_link_compr_shutdown(struct snd_soc_pcm_runtime *rtd, + struct snd_compr_stream *cstream);
#endif /* __SOC_LINK_H */ diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c index 35b0af86325a..9db7810bbe04 100644 --- a/sound/soc/soc-compress.c +++ b/sound/soc/soc-compress.c @@ -226,8 +226,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(rtd, cstream);
soc_compr_components_free(cstream, NULL);
@@ -282,8 +281,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(fe, cstream);
soc_compr_components_free(cstream, NULL);
diff --git a/sound/soc/soc-link.c b/sound/soc/soc-link.c index dddc4a35a0ac..bad719176379 100644 --- a/sound/soc/soc-link.c +++ b/sound/soc/soc-link.c @@ -125,3 +125,12 @@ int snd_soc_link_compr_startup(struct snd_soc_pcm_runtime *rtd, return soc_link_ret(rtd, ret); } EXPORT_SYMBOL_GPL(snd_soc_link_compr_startup); + +void snd_soc_link_compr_shutdown(struct snd_soc_pcm_runtime *rtd, + struct snd_compr_stream *cstream) +{ + if (rtd->dai_link->compr_ops && + rtd->dai_link->compr_ops->shutdown) + rtd->dai_link->compr_ops->shutdown(cstream); +} +EXPORT_SYMBOL_GPL(snd_soc_link_compr_shutdown);
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
dai_link related function should be implemented at soc-link.c. This patch adds snd_soc_link_compr_set_params().
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- include/sound/soc-link.h | 2 ++ sound/soc/soc-compress.c | 16 ++++++---------- sound/soc/soc-link.c | 13 +++++++++++++ 3 files changed, 21 insertions(+), 10 deletions(-)
diff --git a/include/sound/soc-link.h b/include/sound/soc-link.h index 83ca7301c91b..f1fb9036335e 100644 --- a/include/sound/soc-link.h +++ b/include/sound/soc-link.h @@ -24,5 +24,7 @@ int snd_soc_link_compr_startup(struct snd_soc_pcm_runtime *rtd, struct snd_compr_stream *cstream); void snd_soc_link_compr_shutdown(struct snd_soc_pcm_runtime *rtd, struct snd_compr_stream *cstream); +int snd_soc_link_compr_set_params(struct snd_soc_pcm_runtime *rtd, + struct snd_compr_stream *cstream);
#endif /* __SOC_LINK_H */ diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c index 9db7810bbe04..7806bb5b46bd 100644 --- a/sound/soc/soc-compress.c +++ b/sound/soc/soc-compress.c @@ -438,11 +438,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); - if (ret < 0) - goto err; - } + ret = snd_soc_link_compr_set_params(rtd, cstream); + if (ret < 0) + goto err;
if (cstream->direction == SND_COMPRESS_PLAYBACK) snd_soc_dapm_stream_event(rtd, SNDRV_PCM_STREAM_PLAYBACK, @@ -506,11 +504,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); - if (ret < 0) - goto out; - } + ret = snd_soc_link_compr_set_params(fe, 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; diff --git a/sound/soc/soc-link.c b/sound/soc/soc-link.c index bad719176379..e9b20a9c05e8 100644 --- a/sound/soc/soc-link.c +++ b/sound/soc/soc-link.c @@ -134,3 +134,16 @@ void snd_soc_link_compr_shutdown(struct snd_soc_pcm_runtime *rtd, rtd->dai_link->compr_ops->shutdown(cstream); } EXPORT_SYMBOL_GPL(snd_soc_link_compr_shutdown); + +int snd_soc_link_compr_set_params(struct snd_soc_pcm_runtime *rtd, + struct snd_compr_stream *cstream) +{ + int ret = 0; + + if (rtd->dai_link->compr_ops && + rtd->dai_link->compr_ops->set_params) + ret = rtd->dai_link->compr_ops->set_params(cstream); + + return soc_link_ret(rtd, ret); +} +EXPORT_SYMBOL_GPL(snd_soc_link_compr_set_params);
participants (2)
-
Kuninori Morimoto
-
Ranjani Sridharan