* [PATCH v3 1/2] ASoC: soc-dai: add snd_soc_dai_prepare() and use it internally
2025-01-14 21:56 [PATCH v3 0/2] ASoC: prepare streams on codec-to-codec links Martin Blumenstingl
@ 2025-01-14 21:56 ` Martin Blumenstingl
2025-01-15 2:08 ` Kuninori Morimoto
2025-01-14 21:56 ` [PATCH v3 2/2] ASoC: dapm: add support for preparing streams Martin Blumenstingl
2025-01-15 19:38 ` [PATCH v3 0/2] ASoC: prepare streams on codec-to-codec links Mark Brown
2 siblings, 1 reply; 5+ messages in thread
From: Martin Blumenstingl @ 2025-01-14 21:56 UTC (permalink / raw)
To: linux-sound, linux-amlogic
Cc: s.nawrocki, lgirdwood, broonie, linux-kernel, jbrunet, ckeepax,
Martin Blumenstingl
Add a new snd_soc_dai_prepare() which can be used (in an upcoming patch)
by soc-dapm.c. Use this new function internally in
snd_soc_pcm_dai_prepare() to avoid duplicating code.
Suggested-by: Jerome Brunet <jbrunet@baylibre.com>
Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Reviewed-by: Jerome Brunet <jbrunet@baylibre.com>
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
Changes in v1 -> v2:
- none
Changes in v2 -> v3:
- add Reviewed-by from Charles and Jerome (thank you!)
include/sound/soc-dai.h | 3 +++
sound/soc/soc-dai.c | 27 +++++++++++++++++++--------
2 files changed, 22 insertions(+), 8 deletions(-)
diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
index aab57c19f62b..a11501752637 100644
--- a/include/sound/soc-dai.h
+++ b/include/sound/soc-dai.h
@@ -193,6 +193,9 @@ int snd_soc_dai_set_channel_map(struct snd_soc_dai *dai,
int snd_soc_dai_set_tristate(struct snd_soc_dai *dai, int tristate);
+int snd_soc_dai_prepare(struct snd_soc_dai *dai,
+ struct snd_pcm_substream *substream);
+
/* Digital Audio Interface mute */
int snd_soc_dai_digital_mute(struct snd_soc_dai *dai, int mute,
int direction);
diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c
index 34ba1a93a4c9..ca0308f6d41c 100644
--- a/sound/soc/soc-dai.c
+++ b/sound/soc/soc-dai.c
@@ -360,6 +360,22 @@ int snd_soc_dai_set_tristate(struct snd_soc_dai *dai, int tristate)
}
EXPORT_SYMBOL_GPL(snd_soc_dai_set_tristate);
+int snd_soc_dai_prepare(struct snd_soc_dai *dai,
+ struct snd_pcm_substream *substream)
+{
+ int ret = 0;
+
+ if (!snd_soc_dai_stream_valid(dai, substream->stream))
+ return 0;
+
+ if (dai->driver->ops &&
+ dai->driver->ops->prepare)
+ ret = dai->driver->ops->prepare(substream, dai);
+
+ return soc_dai_ret(dai, ret);
+}
+EXPORT_SYMBOL_GPL(snd_soc_dai_prepare);
+
/**
* snd_soc_dai_digital_mute - configure DAI system or master clock.
* @dai: DAI
@@ -577,14 +593,9 @@ int snd_soc_pcm_dai_prepare(struct snd_pcm_substream *substream)
int i, ret;
for_each_rtd_dais(rtd, i, dai) {
- if (!snd_soc_dai_stream_valid(dai, substream->stream))
- continue;
- if (dai->driver->ops &&
- dai->driver->ops->prepare) {
- ret = dai->driver->ops->prepare(substream, dai);
- if (ret < 0)
- return soc_dai_ret(dai, ret);
- }
+ ret = snd_soc_dai_prepare(dai, substream);
+ if (ret < 0)
+ return ret;
}
return 0;
--
2.48.0
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH v3 1/2] ASoC: soc-dai: add snd_soc_dai_prepare() and use it internally
2025-01-14 21:56 ` [PATCH v3 1/2] ASoC: soc-dai: add snd_soc_dai_prepare() and use it internally Martin Blumenstingl
@ 2025-01-15 2:08 ` Kuninori Morimoto
0 siblings, 0 replies; 5+ messages in thread
From: Kuninori Morimoto @ 2025-01-15 2:08 UTC (permalink / raw)
To: Martin Blumenstingl
Cc: linux-sound, linux-amlogic, s.nawrocki, lgirdwood, broonie,
linux-kernel, jbrunet, ckeepax
Hi Martin
> Add a new snd_soc_dai_prepare() which can be used (in an upcoming patch)
> by soc-dapm.c. Use this new function internally in
> snd_soc_pcm_dai_prepare() to avoid duplicating code.
>
> Suggested-by: Jerome Brunet <jbrunet@baylibre.com>
> Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>
> Reviewed-by: Jerome Brunet <jbrunet@baylibre.com>
> Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
> ---
Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Thank you for your help !!
Best regards
---
Kuninori Morimoto
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v3 2/2] ASoC: dapm: add support for preparing streams
2025-01-14 21:56 [PATCH v3 0/2] ASoC: prepare streams on codec-to-codec links Martin Blumenstingl
2025-01-14 21:56 ` [PATCH v3 1/2] ASoC: soc-dai: add snd_soc_dai_prepare() and use it internally Martin Blumenstingl
@ 2025-01-14 21:56 ` Martin Blumenstingl
2025-01-15 19:38 ` [PATCH v3 0/2] ASoC: prepare streams on codec-to-codec links Mark Brown
2 siblings, 0 replies; 5+ messages in thread
From: Martin Blumenstingl @ 2025-01-14 21:56 UTC (permalink / raw)
To: linux-sound, linux-amlogic
Cc: s.nawrocki, lgirdwood, broonie, linux-kernel, jbrunet, ckeepax,
Martin Blumenstingl
Codec driver can implement .hw_params and/or .prepare from struct
snd_soc_dai_ops. For codec-to-codec links only the former (.hw_params)
callback has been called.
On platforms like Amlogic Meson8/8b/8m2 the SoC's sound card
(sound/soc/meson/gx-card.c) uses a codec-to-codec link for the HDMI
codec output because further digital routing is required after the
backend. The new DRM HDMI (audio) codec framework (which internally
uses sound/soc/codecs/hdmi-codec.c) relies on the .prepare callback
of the hdmi-codec to be called. Implement calls to
snd_soc_dai_prepare() so the .prepare callback is called. In this
case the mandatory part is the call to prepare the sink (which is
the hdmi-codec on those platforms). Also call snd_soc_dai_prepare()
for the source to stay consistent with the rest of the code (even
though it's not strictly necessary to make the DRM HDMI codec
framework work on Amlogic Meson8/8b/8m2).
For platforms or sound cards without a codec-to-codec link with
additional parameters (which applies to most hardware) this changes
nothing as the .prepare callback is already called via
snd_pcm_do_prepare() (as well as dpcm_fe_dai_prepare() and
dpcm_be_dai_prepare()) on those.
Suggested-by: Jerome Brunet <jbrunet@baylibre.com>
Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Reviewed-by: Jerome Brunet <jbrunet@baylibre.com>
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
Changes in v1 -> v2:
- also call snd_soc_dai_prepare() as suggested by Jerome/Mark for the
source to keep things symmetrical (this is not strictly necessary
for the Amlogic Meson SoC as it doesn't implement the .prepare
callback in the platform drivers - but having it symmetrical means
less confusion for future platform maintainers)
Changes in v2 -> v3:
- add Reviewed-by from Charles and Jerome (thank you!)
sound/soc/soc-dapm.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 99521c784a9b..ebb181aac7b7 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -4013,6 +4013,18 @@ static int snd_soc_dai_link_event(struct snd_soc_dapm_widget *w,
break;
case SND_SOC_DAPM_POST_PMU:
+ snd_soc_dapm_widget_for_each_source_path(w, path) {
+ source = path->source->priv;
+
+ snd_soc_dai_prepare(source, substream);
+ }
+
+ snd_soc_dapm_widget_for_each_sink_path(w, path) {
+ sink = path->sink->priv;
+
+ snd_soc_dai_prepare(sink, substream);
+ }
+
snd_soc_dapm_widget_for_each_sink_path(w, path) {
sink = path->sink->priv;
--
2.48.0
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH v3 0/2] ASoC: prepare streams on codec-to-codec links
2025-01-14 21:56 [PATCH v3 0/2] ASoC: prepare streams on codec-to-codec links Martin Blumenstingl
2025-01-14 21:56 ` [PATCH v3 1/2] ASoC: soc-dai: add snd_soc_dai_prepare() and use it internally Martin Blumenstingl
2025-01-14 21:56 ` [PATCH v3 2/2] ASoC: dapm: add support for preparing streams Martin Blumenstingl
@ 2025-01-15 19:38 ` Mark Brown
2 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2025-01-15 19:38 UTC (permalink / raw)
To: linux-sound, linux-amlogic, Martin Blumenstingl
Cc: s.nawrocki, lgirdwood, linux-kernel, jbrunet, ckeepax
On Tue, 14 Jan 2025 22:56:15 +0100, Martin Blumenstingl wrote:
> the DRM subsystem has recently gained a HDMI audio codec framework [0].
> This is already queued for Linux 6.14.
>
> I want to implement a HDMI controller driver for the Amlogic
> Meson8/8b/8m2 SoCs using the DRM HDMI audio codec framework. Internally
> the DRM HDMI audio codec framework relies on hdmi-codec's .prepare
> callback to be called. This unfortunately is not happening on Amlogic
> Meson8/8b/8m2 platforms [1].
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/2] ASoC: soc-dai: add snd_soc_dai_prepare() and use it internally
commit: d4e91adfc261de1454538ee6437e6014a2d1fca1
[2/2] ASoC: dapm: add support for preparing streams
commit: e436d43551764bd6ca22a1ab1e80e98939b8aec7
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 5+ messages in thread