From: Valerio Setti <vsetti@baylibre.com>
To: Jerome Brunet <jbrunet@baylibre.com>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>,
Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
Neil Armstrong <neil.armstrong@linaro.org>,
Kevin Hilman <khilman@baylibre.com>,
Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Cc: linux-sound@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org,
Valerio Setti <vsetti@baylibre.com>
Subject: [PATCH 1/2] ASoC: meson: gx-formatter: prepare on attach
Date: Thu, 02 Jul 2026 12:56:40 +0200 [thread overview]
Message-ID: <20260702-fix-24-bit-i2s-playback-v1-1-bcd3a43fe32a@baylibre.com> (raw)
In-Reply-To: <20260702-fix-24-bit-i2s-playback-v1-0-bcd3a43fe32a@baylibre.com>
Instead of calling the formatter driver prepare and enable at the same
time when 'gx_stream_start' is called (which happens at trigger time),
split the operation in 2: prepare is called when the widget is powered
up, whereas enable is kept on 'gx_stream_start'.
This resolves a problem related to i2s playback in 24-bit mode. Commit
c7852d2dcf66 ("ASoC: meson: aiu: align I2S design to the AXG one") moved
the content of what was once called 'aiu_encoder_i2s_setup_desc' from
'aiu-encoder-i2s' to 'aiu-formatter-i2s'.
'aiu_encoder_i2s_setup_desc' was basically accomplishing two tasks:
- reset the i2s pipeline.
- configure number of channels and physical samples width.
Before being moved 'aiu_encoder_i2s_setup_desc' was called in the encoder
DAI 'hw_params()', whereas after the move it is called at trigger time
('aiu_encoder_i2s_trigger'->'gx_stream_start' -> 'gx_formatter_enable' ->
'aiu_formatter_i2s_prepare').
In parallel 'aiu-fifo-i2s' (DAI FE) already performs the very same reset
of the pipeline at trigger time in 'aiu_fifo_i2s_trigger' and then it
triggers the playback.
Since the DAI triggering order is the default one (FE before BE) this
means that the pipeline reset happens when the BE already did it and
started the playback. This cause the 24-bit playback mode to be
corrupted.
This commit re-orders operations so that 'aiu_formatter_i2s_prepare' is
called after DAIs' prepare, but before triggering them.
Signed-off-by: Valerio Setti <vsetti@baylibre.com>
---
sound/soc/meson/gx-formatter.c | 33 +++++++++++++++++++++++++--------
1 file changed, 25 insertions(+), 8 deletions(-)
diff --git a/sound/soc/meson/gx-formatter.c b/sound/soc/meson/gx-formatter.c
index 311e63affb23..c7333f624b15 100644
--- a/sound/soc/meson/gx-formatter.c
+++ b/sound/soc/meson/gx-formatter.c
@@ -15,27 +15,38 @@ struct gx_formatter {
struct gx_stream *stream;
const struct gx_formatter_driver *drv;
bool enabled;
+ bool prepared;
struct regmap *map;
};
-static int gx_formatter_enable(struct gx_formatter *formatter)
+static int gx_formatter_prepare(struct gx_formatter *formatter)
{
int ret;
- /* Do nothing if the formatter is already enabled */
- if (formatter->enabled)
+ if (formatter->prepared)
return 0;
/* Setup the stream parameter in the formatter */
if (formatter->drv->ops->prepare) {
ret = formatter->drv->ops->prepare(formatter->map,
- formatter->drv->quirks,
- formatter->stream);
+ formatter->drv->quirks,
+ formatter->stream);
if (ret)
return ret;
}
- /* Finally, actually enable the formatter */
+ formatter->prepared = true;
+
+ return 0;
+}
+
+static int gx_formatter_enable(struct gx_formatter *formatter)
+{
+ /* Do nothing if the formatter is already enabled */
+ if (formatter->enabled)
+ return 0;
+
+ /* Enable the formatter */
if (formatter->drv->ops->enable)
formatter->drv->ops->enable(formatter->map);
@@ -63,6 +74,12 @@ static int gx_formatter_attach(struct gx_formatter *formatter)
mutex_lock(&ts->lock);
+ ret = gx_formatter_prepare(formatter);
+ if (ret) {
+ pr_err("failed to prepare the formatter\n");
+ goto out;
+ }
+
/* Catch up if the stream is already running when we attach */
if (ts->ready) {
ret = gx_formatter_enable(formatter);
@@ -87,9 +104,9 @@ static void gx_formatter_detach(struct gx_formatter *formatter)
mutex_lock(&ts->lock);
list_del(&formatter->list);
- mutex_unlock(&ts->lock);
-
gx_formatter_disable(formatter);
+ formatter->prepared = false;
+ mutex_unlock(&ts->lock);
}
static int gx_formatter_power_up(struct gx_formatter *formatter,
--
2.47.3
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
next prev parent reply other threads:[~2026-07-02 10:57 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-02 10:56 [PATCH 0/2] ASoC: meson: aiu: fix playback issue for 24-bit mode Valerio Setti
2026-07-02 10:56 ` Valerio Setti [this message]
2026-07-02 11:10 ` [PATCH 1/2] ASoC: meson: gx-formatter: prepare on attach sashiko-bot
2026-07-02 20:34 ` Valerio Setti
2026-07-03 7:34 ` Jerome Brunet
2026-07-02 10:56 ` [PATCH 2/2] ASoC: meson: aiu-formatter: remove pipeline reset from prepare Valerio Setti
2026-07-02 11:14 ` sashiko-bot
2026-07-02 20:44 ` Valerio Setti
2026-07-03 7:58 ` Jerome Brunet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260702-fix-24-bit-i2s-playback-v1-1-bcd3a43fe32a@baylibre.com \
--to=vsetti@baylibre.com \
--cc=broonie@kernel.org \
--cc=jbrunet@baylibre.com \
--cc=khilman@baylibre.com \
--cc=lgirdwood@gmail.com \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=martin.blumenstingl@googlemail.com \
--cc=neil.armstrong@linaro.org \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®