From: sashiko-bot@kernel.org
To: "H. Nikolaus Schaller" <hns@goldelico.com>
Cc: linux-gpio@vger.kernel.org, devicetree@vger.kernel.org,
dri-devel@lists.freedesktop.org, linux-leds@vger.kernel.org,
linux-sound@vger.kernel.org, robh@kernel.org,
conor+dt@kernel.org, lee@kernel.org
Subject: Re: [PATCH v2 07/20] ASoC: ti: omap3pandora: Convert sound card to DT
Date: Tue, 24 Nov 2026 07:45:26 +0000 [thread overview]
Message-ID: <sashiko-outbox-230666@kernel.org> (raw)
In-Reply-To: <57d9a8b26bd2282deb9188d6913976cfee41aee9.1795505160.git.hns@goldelico.com>
Thank you for your contribution! Sashiko AI review found 8 potential
issues to consider:
- [High] ASoC: ti: omap3pandora: broken built-in McBSP names and missing
DT DAI parsing
- [High] ASoC: ti: omap3pandora: missing SND_SOC_PCM1754 select in
Kconfig
- [Medium] ASoC: ti: omap3pandora: grab_sample_rate() rejects
single-stream rate change
- [Medium] ASoC: ti: omap3pandora: static open-time rate constraint in
startup()
- [Medium] ASoC: ti: omap3pandora: missing snd_soc_pm_ops on
omap3pandora_driver
- [Medium] ASoC: ti: omap3pandora: missing TWL4030_CLOCK_APLL setup in
capture hw_params
- [Low] ASoC: ti: omap3pandora: omap3pandora_probe() requires optional
DT properties
- [Low] ASoC: ti: omap3pandora: unused codec_dai variable and
mach-types.h include
--
commit b90618564a61935165b508799b8ef7f6f6a36708
Author: Stefan Leichter <sle85276@gmx.de>
ASoC: ti: omap3pandora: Convert sound card to DT
This commit converts the OpenPandora ASoC machine driver to probe via a
Device Tree sound-card node, separates playback and capture handling
with shared TWL4030 APLL rate accounting, and switches to device-managed
resource registration.
> diff --git a/sound/soc/ti/omap3pandora.c b/sound/soc/ti/omap3pandora.c
> index 6c9c184cd9d6f..d747c0e6b48cb 100644
> --- a/sound/soc/ti/omap3pandora.c
> +++ b/sound/soc/ti/omap3pandora.c
> @@ -6,138 +6,274 @@
[ ... ]
> +#include <asm/mach-types.h>
> +#include <linux/mfd/twl4030-audio.h>
> #include <linux/platform_data/asoc-ti-mcbsp.h>
>
> #include "omap-mcbsp.h"
>
> -#define PREFIX "ASoC omap3pandora: "
> +struct omap3pandora_sound {
> + struct gpio_desc *amp_gpio;
> + struct regulator *amp_regulator;
> +
> + struct snd_pcm_substream *playback_stream;
> + struct snd_pcm_substream *capture_stream;
> +
> + struct mutex sample_rate_lock; // protects all fields after
> + unsigned int sample_rate;
> + int sample_rate_users;
> +};
>
> -static struct regulator *omap3pandora_dac_reg;
> -static struct gpio_desc *dac_power_gpio;
> -static struct gpio_desc *amp_power_gpio;
> +static struct snd_soc_dai_link omap3pandora_dai[];
>
> -static int omap3pandora_hw_params(struct snd_pcm_substream *substream,
> - struct snd_pcm_hw_params *params)
> +static int omap3pandora_common_hw_params(struct snd_pcm_substream *substream,
> + struct snd_pcm_hw_params *params)
> {
> struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
> - struct snd_soc_dai *codec_dai = snd_soc_rtd_to_codec(rtd, 0);
> + __maybe_unused struct snd_soc_dai *codec_dai = snd_soc_rtd_to_codec(rtd, 0);
[Severity: Low]
This isn't a bug, but codec_dai in omap3pandora_common_hw_params() and the
new <asm/mach-types.h> include are both unused and can be dropped.
[ ... ]
> +/* The McBSP playback and capture interfaces share the TWL4030 APLL. */
> +static int grab_sample_rate(struct omap3pandora_sound *ctx,
> + struct snd_pcm_substream **owner,
> + struct snd_pcm_substream *substream,
> + struct snd_pcm_hw_params *params,
> + bool *new_owner)
> +{
> + unsigned int rate = params_rate(params);
> + int ret = 0;
> +
> + *new_owner = false;
> + mutex_lock(&ctx->sample_rate_lock);
> + if (*owner == substream) {
> + if (ctx->sample_rate != rate)
> + ret = -EINVAL;
> + } else if (*owner || (ctx->sample_rate_users &&
> + ctx->sample_rate != rate)) {
> + ret = -EINVAL;
> + } else {
> + ctx->sample_rate = rate;
> + ctx->sample_rate_users++;
> + *owner = substream;
> + *new_owner = true;
> + }
> + mutex_unlock(&ctx->sample_rate_lock);
> +
> + return ret;
> +}
[Severity: Medium]
Does grab_sample_rate() reject sample-rate changes on a substream even
when no other stream is active?
ALSA allows userspace to call SNDRV_PCM_IOCTL_HW_PARAMS more than once on
an open substream without an intervening hw_free(). When *owner ==
substream and ctx->sample_rate_users == 1, returning -EINVAL on
ctx->sample_rate != rate causes snd_pcm_hw_params() to fail and call
hw_free(), dropping the reservation anyway. If ctx->sample_rate_users ==
1, *owner == substream should be allowed to update ctx->sample_rate to the
new rate.
[ ... ]
> +static int omap3pandora_capture_hw_params(struct snd_pcm_substream *substream,
> + struct snd_pcm_hw_params *params)
> +{
> + struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
> + struct snd_soc_dai *codec_dai = snd_soc_rtd_to_codec(rtd, 0);
> + struct device *dev = rtd->dev;
> + struct snd_soc_card *card = rtd->card;
> + struct omap3pandora_sound *ctx = snd_soc_card_get_drvdata(card);
> + bool new_owner;
> + int ret;
> +
> + /* Set the codec system clock for DAC and ADC */
> + ret = snd_soc_dai_set_sysclk(codec_dai, 0, 26000000,
> + SND_SOC_CLOCK_IN);
> + if (ret < 0) {
> + dev_err(dev, "cannot set TWL4030 system clock: %d\n", ret);
> + return ret;
> + }
> +
> + ret = grab_sample_rate(ctx, &ctx->capture_stream, substream,
> + params, &new_owner);
> + if (ret)
> + return ret;
> +
> + ret = omap3pandora_common_hw_params(substream, params);
> + if (ret)
> + goto err_release;
> return 0;
[Severity: Medium]
Does omap3pandora_capture_hw_params() also need to program
TWL4030_CLOCK_APLL via snd_soc_dai_set_sysclk()?
In sound/soc/codecs/twl4030.c, twl4030_hw_params() sets
twl4030->configured = 1 on the first hw_params() call and returns early
without updating TWL4030_REG_CODEC_MODE until twl4030_shutdown() clears
twl4030->configured:
sound/soc/codecs/twl4030.c:twl4030_hw_params() {
...
/* If the substream has no subscribers, the Giacinto
* is already configured, so we can return */
if (twl4030->configured)
return 0;
...
}
If an open capture substream runs hw_params(), hw_free() (which releases
ctx->capture_stream), and then hw_params() at a new rate (or if playback
changed the APLL rate in the meantime), McBSP4 is reconfigured to 256 *
new_rate while the TWL4030 APLL stays at the old frequency.
[ ... ]
> +static int omap3pandora_common_startup(struct snd_pcm_substream *substream)
> +{
> + struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
> + struct snd_soc_card *card = rtd->card;
> + struct omap3pandora_sound *ctx = snd_soc_card_get_drvdata(card);
> + unsigned int sample_rate;
> +
> + mutex_lock(&ctx->sample_rate_lock);
> + sample_rate = ctx->sample_rate;
> + mutex_unlock(&ctx->sample_rate_lock);
> +
> + if (!sample_rate)
> + return 0;
> +
> + return constrain_sample_rate(substream, sample_rate);
> +}
[Severity: Medium]
Can constraining the rate from a snapshot of ctx->sample_rate in startup()
leave a substream either unconstrained or locked to a stale rate?
Because ctx->sample_rate is only set later in hw_params(), a full-duplex
application that opens both playback and capture before configuring
hw_params() sees ctx->sample_rate == 0 in both startup() calls and gets no
rate constraint. Conversely, if stream B opens while stream A is running
at rate R1, stream B is permanently constrained to R1 via
snd_pcm_hw_constraint_single(); if stream A then closes and reopens at
rate R2 != R1 before stream B runs hw_params(), stream B cannot succeed at
any rate.
> @@ -171,20 +307,40 @@ static int omap3pandora_in_init(struct snd_soc_pcm_runtime *rtd)
[ ... ]
> /* Digital audio interface glue - connects codec <--> CPU */
> +#if IS_BUILTIN(CONFIG_SND_SOC_OMAP3_PANDORA)
> SND_SOC_DAILINK_DEFS(out,
> DAILINK_COMP_ARRAY(COMP_CPU("omap-mcbsp.2")),
> - DAILINK_COMP_ARRAY(COMP_CODEC("twl4030-codec", "twl4030-hifi")),
> + DAILINK_COMP_ARRAY(COMP_CODEC("pcm1773-codec", "pcm1773")),
> DAILINK_COMP_ARRAY(COMP_PLATFORM("omap-mcbsp.2")));
>
> SND_SOC_DAILINK_DEFS(in,
> DAILINK_COMP_ARRAY(COMP_CPU("omap-mcbsp.4")),
> DAILINK_COMP_ARRAY(COMP_CODEC("twl4030-codec", "twl4030-hifi")),
> DAILINK_COMP_ARRAY(COMP_PLATFORM("omap-mcbsp.4")));
> +#else /* IS_BUILTIN(CONFIG_SND_SOC_OMAP3_PANDORA) */
> +SND_SOC_DAILINK_DEFS(out,
> + DAILINK_COMP_ARRAY(COMP_CPU("49022000.mcbsp")),
> + DAILINK_COMP_ARRAY(COMP_CODEC("pcm1773-codec", "pcm1773")),
> + DAILINK_COMP_ARRAY(COMP_PLATFORM("49022000.mcbsp")));
> +
> +SND_SOC_DAILINK_DEFS(in,
> + DAILINK_COMP_ARRAY(COMP_CPU("49026000.mcbsp")),
> + DAILINK_COMP_ARRAY(COMP_CODEC("twl4030-codec", "twl4030-hifi")),
> + DAILINK_COMP_ARRAY(COMP_PLATFORM("49026000.mcbsp")));
> +#endif /* IS_BUILTIN(CONFIG_SND_SOC_OMAP3_PANDORA) */
[Severity: High]
Does SND_SOC_OMAP3_PANDORA in sound/soc/ti/Kconfig need to select
SND_SOC_PCM1754 now that the playback DAI link binds to the pcm1773 DAI?
Without select SND_SOC_PCM1754 in Kconfig, configs enabling
CONFIG_SND_SOC_OMAP3_PANDORA (such as omap2plus_defconfig) do not build
sound/soc/codecs/pcm1754.c, leaving the playback link unbound.
[Severity: High]
Why do the DAI links hardcode component names and branch on
IS_BUILTIN(CONFIG_SND_SOC_OMAP3_PANDORA) instead of populating the DAI
link of_node pointers from Device Tree?
On DT-based OMAP3 kernels, the McBSP devices are always named
"49022000.mcbsp" and "49026000.mcbsp" regardless of whether this driver is
built-in or a module, so CONFIG_SND_SOC_OMAP3_PANDORA=y searches for
"omap-mcbsp.2" and "omap-mcbsp.4" and never binds. In addition,
sound/soc/codecs/pcm1754.c leaves soc_component_dev_pcm1754.name NULL, so
the codec component is named after the DT node (for example "dac" in the
binding example) rather than "pcm1773-codec", and omap3pandora_probe()
never parses the sound-dai phandles into cpus->of_node, platforms->of_node
and codecs->of_node.
> @@ -192,100 +348,122 @@ static struct snd_soc_dai_link omap3pandora_dai[] = {
[ ... ]
> + if (dev->of_node) {
> + ret = snd_soc_of_parse_card_name(card, "label");
> + if (ret)
> + card->name = "omap3pandora";
> +
> + ret = snd_soc_of_parse_audio_simple_widgets(card, "widgets");
> + if (ret) {
> + dev_err(dev, "Failed to parse DAPM widgets: %d\n", ret);
> + return ret;
> + }
> +
> + ret = snd_soc_of_parse_audio_routing(card, "routing");
> + if (ret) {
> + dev_err(dev, "Failed to parse audio routing: %d\n", ret);
> + return ret;
> + }
> }
[Severity: Low]
Should omap3pandora_probe() check whether the "widgets" and "routing"
properties exist before calling snd_soc_of_parse_audio_simple_widgets()
and snd_soc_of_parse_audio_routing()?
Both helpers return -EINVAL when the property is absent, whereas the DT
binding only lists compatible and sound-dai as required.
[ ... ]
> +static struct platform_driver omap3pandora_driver = {
> + .driver = {
> + .name = "omap3pandora-sound",
> + .of_match_table = omap3pandora_of_match,
> + },
> + .probe = omap3pandora_probe,
> +};
[Severity: Medium]
Should omap3pandora_driver.driver set .pm = &snd_soc_pm_ops?
Previously, registering a "soc-audio" platform device bound the card to
soc_driver in sound/soc/soc-core.c, which wires up snd_soc_pm_ops.
Omitting .pm here disables ASoC card suspend, resume, and poweroff
callbacks.
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1795505160.git.hns@goldelico.com?part=7
next prev parent reply other threads:[~2026-11-24 7:45 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 7:25 [PATCH v2 00/20] ARM: omap3: pandora: Modernize audio and backlight to use Device Tree to finally remove pdata-quirks H. Nikolaus Schaller
2026-11-24 7:25 ` [PATCH v2 01/20] dt-bindings: gpio: twl4030: Document REGEN GPIO H. Nikolaus Schaller
2026-11-24 7:25 ` [PATCH v2 02/20] gpio: twl4030: Support " H. Nikolaus Schaller
2026-11-24 7:43 ` sashiko-bot
2026-11-24 7:25 ` [PATCH v2 03/20] ASoC: twl4030: Allow APLL rate selection through set_sysclk() H. Nikolaus Schaller
2026-11-24 7:25 ` [PATCH v2 04/20] dt-bindings: sound: pcm1754: Describe PCM1773 H. Nikolaus Schaller
2026-11-24 7:25 ` [PATCH v2 05/20] ASoC: codecs: pcm1754: Add PCM1773 support H. Nikolaus Schaller
2026-11-24 7:25 ` [PATCH v2 06/20] dt-bindings: sound: Document OpenPandora sound card H. Nikolaus Schaller
2026-11-24 7:40 ` sashiko-bot
2026-11-24 7:25 ` [PATCH v2 07/20] ASoC: ti: omap3pandora: Convert sound card to DT H. Nikolaus Schaller
2026-11-24 7:45 ` sashiko-bot [this message]
2026-11-24 7:25 ` [PATCH v2 08/20] dt-bindings: mfd: twl4030: Document 64-cycle PWM H. Nikolaus Schaller
2026-11-24 7:25 ` [PATCH v2 09/20] pwm: twl: Support 64-cycle PWM frame H. Nikolaus Schaller
2026-11-24 7:37 ` sashiko-bot
2026-11-24 7:25 ` [PATCH v2 10/20] dt-bindings: backlight: pwm: Document enable guard H. Nikolaus Schaller
2026-11-24 7:25 ` [PATCH v2 11/20] backlight: pwm: Support enable guard period H. Nikolaus Schaller
2026-11-24 7:36 ` sashiko-bot
2026-11-24 7:25 ` [PATCH v2 12/20] drm/panel: td043mtea1: Attach DT backlight H. Nikolaus Schaller
2026-11-24 7:25 ` [PATCH v2 13/20] ARM: dts: omap3pandora: Disable unused DMA channels H. Nikolaus Schaller
2026-11-24 7:25 ` [PATCH v2 14/20] ARM: dts: omap3-pandora: Model LCD power enable dependencies H. Nikolaus Schaller
2026-11-24 7:45 ` sashiko-bot
2026-11-24 7:25 ` [PATCH v2 15/20] ARM: dts: omap3pandora: Enable audio interfaces H. Nikolaus Schaller
2026-11-24 7:25 ` [PATCH v2 16/20] ARM: dts: omap3pandora: Describe PCM1773 H. Nikolaus Schaller
2026-11-24 7:40 ` sashiko-bot
2026-11-24 7:25 ` [PATCH v2 17/20] ARM: dts: omap3pandora: Describe sound card H. Nikolaus Schaller
2026-11-24 7:47 ` sashiko-bot
2026-11-24 7:25 ` [PATCH v2 18/20] ARM: dts: omap3pandora: Switch backlight to PWM H. Nikolaus Schaller
2026-11-24 7:46 ` sashiko-bot
2026-11-24 7:25 ` [PATCH v2 19/20] backlight: Remove legacy Pandora driver H. Nikolaus Schaller
2026-11-24 7:26 ` [PATCH v2 20/20] ARM: OMAP2+: Remove Pandora platform-data quirks H. Nikolaus Schaller
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=sashiko-outbox-230666@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=hns@goldelico.com \
--cc=lee@kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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