public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 RESEND] ASoC: sdw_utils: cs42l43: allow spk component names to be combined
@ 2026-04-20 11:48 Maciej Strozek
  2026-04-21  9:59 ` Aaron Ma
  0 siblings, 1 reply; 2+ messages in thread
From: Maciej Strozek @ 2026-04-20 11:48 UTC (permalink / raw)
  To: Mark Brown, Jaroslav Kysela, Aaron Ma
  Cc: Takashi Iwai, Bard Liao, linux-kernel, linux-sound, patches,
	Maciej Strozek

Move handling of cs42l43-spk component string into SOF mechanism [1]
which will allow it to be aggregated with other speakers.
Likewise handle the cs35l56-bridge special case which should not be
combined to keep compatibility with UCM.

Link: https://github.com/thesofproject/linux/pull/5445 [1]
Link: https://github.com/alsa-project/alsa-ucm-conf/pull/747
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Signed-off-by: Maciej Strozek <mstrozek@opensource.cirrus.com>
---
Changes in v2: use dai->component instead of snd_soc_rtd_to_codec(rtd, 0)->component
---
 sound/soc/sdw_utils/soc_sdw_bridge_cs35l56.c |  6 ------
 sound/soc/sdw_utils/soc_sdw_cs42l43.c        | 12 +-----------
 sound/soc/sdw_utils/soc_sdw_utils.c          | 20 ++++++++++++++++----
 3 files changed, 17 insertions(+), 21 deletions(-)

diff --git a/sound/soc/sdw_utils/soc_sdw_bridge_cs35l56.c b/sound/soc/sdw_utils/soc_sdw_bridge_cs35l56.c
index 2a7109d53cbe3..e0e32a279787c 100644
--- a/sound/soc/sdw_utils/soc_sdw_bridge_cs35l56.c
+++ b/sound/soc/sdw_utils/soc_sdw_bridge_cs35l56.c
@@ -40,12 +40,6 @@ static int asoc_sdw_bridge_cs35l56_asp_init(struct snd_soc_pcm_runtime *rtd)
 	struct snd_soc_dai *codec_dai;
 	struct snd_soc_dai *cpu_dai;

-	card->components = devm_kasprintf(card->dev, GFP_KERNEL,
-					  "%s spk:cs35l56-bridge",
-					  card->components);
-	if (!card->components)
-		return -ENOMEM;
-
 	ret = snd_soc_dapm_new_controls(dapm, bridge_widgets,
 					ARRAY_SIZE(bridge_widgets));
 	if (ret) {
diff --git a/sound/soc/sdw_utils/soc_sdw_cs42l43.c b/sound/soc/sdw_utils/soc_sdw_cs42l43.c
index 4a451b9d4f137..e99ea3c4e5dde 100644
--- a/sound/soc/sdw_utils/soc_sdw_cs42l43.c
+++ b/sound/soc/sdw_utils/soc_sdw_cs42l43.c
@@ -107,21 +107,11 @@ EXPORT_SYMBOL_NS(asoc_sdw_cs42l43_hs_rtd_init, "SND_SOC_SDW_UTILS");

 int asoc_sdw_cs42l43_spk_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai)
 {
-	struct snd_soc_component *component = snd_soc_rtd_to_codec(rtd, 0)->component;
+	struct snd_soc_component *component = dai->component;
 	struct snd_soc_card *card = rtd->card;
 	struct snd_soc_dapm_context *dapm = snd_soc_card_to_dapm(card);
-	struct asoc_sdw_mc_private *ctx = snd_soc_card_get_drvdata(card);
 	int ret;

-	if (!(ctx->mc_quirk & SOC_SDW_SIDECAR_AMPS)) {
-		/* Will be set by the bridge code in this case */
-		card->components = devm_kasprintf(card->dev, GFP_KERNEL,
-						  "%s spk:cs42l43-spk",
-						  card->components);
-		if (!card->components)
-			return -ENOMEM;
-	}
-
 	ret = snd_soc_limit_volume(card, "cs42l43 Speaker Digital Volume",
 				   CS42L43_SPK_VOLUME_0DB);
 	if (ret)
diff --git a/sound/soc/sdw_utils/soc_sdw_utils.c b/sound/soc/sdw_utils/soc_sdw_utils.c
index 2807f536eef0c..1637cc3f3d598 100644
--- a/sound/soc/sdw_utils/soc_sdw_utils.c
+++ b/sound/soc/sdw_utils/soc_sdw_utils.c
@@ -758,6 +758,7 @@ struct asoc_sdw_codec_info codec_info_list[] = {
 			{
 				.direction = {true, false},
 				.codec_name = "cs42l43-codec",
+				.component_name = "cs42l43-spk",
 				.dai_name = "cs42l43-dp6",
 				.dai_type = SOC_SDW_DAI_TYPE_AMP,
 				.dailink = {SOC_SDW_AMP_OUT_DAI_ID, SOC_SDW_UNUSED_DAI_ID},
@@ -1104,6 +1105,7 @@ static int asoc_sdw_find_codec_info_dai_index(const struct asoc_sdw_codec_info *
 int asoc_sdw_rtd_init(struct snd_soc_pcm_runtime *rtd)
 {
 	struct snd_soc_card *card = rtd->card;
+	struct asoc_sdw_mc_private *ctx = snd_soc_card_get_drvdata(card);
 	struct snd_soc_dapm_context *dapm = snd_soc_card_to_dapm(card);
 	struct asoc_sdw_codec_info *codec_info;
 	struct snd_soc_dai *dai;
@@ -1179,16 +1181,26 @@ int asoc_sdw_rtd_init(struct snd_soc_pcm_runtime *rtd)
 		/* Generate the spk component string for card->components string */
 		if (codec_info->dais[dai_index].dai_type == SOC_SDW_DAI_TYPE_AMP &&
 		    codec_info->dais[dai_index].component_name) {
+			const char *component;
+
+			/*
+			 * For the special case of cs42l43 with sidecar amps, use only
+			 * "cs35l56-bridge" as the component name in card->components
+			 */
+			if (ctx->mc_quirk & SOC_SDW_SIDECAR_AMPS &&
+			    !strcmp(codec_info->dais[dai_index].component_name, "cs42l43-spk"))
+				component = "cs35l56-bridge";
+			else
+				component = codec_info->dais[dai_index].component_name;
+
 			if (strlen (spk_components) == 0)
 				spk_components =
-					devm_kasprintf(card->dev, GFP_KERNEL, "%s",
-						       codec_info->dais[dai_index].component_name);
+					devm_kasprintf(card->dev, GFP_KERNEL, "%s", component);
 			else
 				/* Append component name to spk_components */
 				spk_components =
 					devm_kasprintf(card->dev, GFP_KERNEL,
-						       "%s+%s", spk_components,
-						       codec_info->dais[dai_index].component_name);
+						       "%s+%s", spk_components, component);
 		}

 		codec_info->dais[dai_index].rtd_init_done = true;
--
2.47.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2 RESEND] ASoC: sdw_utils: cs42l43: allow spk component names to be combined
  2026-04-20 11:48 [PATCH v2 RESEND] ASoC: sdw_utils: cs42l43: allow spk component names to be combined Maciej Strozek
@ 2026-04-21  9:59 ` Aaron Ma
  0 siblings, 0 replies; 2+ messages in thread
From: Aaron Ma @ 2026-04-21  9:59 UTC (permalink / raw)
  To: Maciej Strozek
  Cc: Mark Brown, Jaroslav Kysela, Takashi Iwai, Bard Liao,
	linux-kernel, linux-sound, patches

With alsa-ucm-conf PR #748,
after applying this patch, the kernel correctly produces the combined
component string:

  spk:cs35l56+cs42l43-spk hs:cs42l43 mic:cs42l43-dmic

Speaker playback, mute LED, mic LED, and remap all work correctly.

Suggested-by: Aaron Ma <aaron.ma@canonical.com>
Tested-by: Aaron Ma <aaron.ma@canonical.com>

On Mon, Apr 20, 2026 at 7:48 PM Maciej Strozek
<mstrozek@opensource.cirrus.com> wrote:
>
> Move handling of cs42l43-spk component string into SOF mechanism [1]
> which will allow it to be aggregated with other speakers.
> Likewise handle the cs35l56-bridge special case which should not be
> combined to keep compatibility with UCM.
>
> Link: https://github.com/thesofproject/linux/pull/5445 [1]
> Link: https://github.com/alsa-project/alsa-ucm-conf/pull/747
> Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
> Signed-off-by: Maciej Strozek <mstrozek@opensource.cirrus.com>
> ---
> Changes in v2: use dai->component instead of snd_soc_rtd_to_codec(rtd, 0)->component
> ---
>  sound/soc/sdw_utils/soc_sdw_bridge_cs35l56.c |  6 ------
>  sound/soc/sdw_utils/soc_sdw_cs42l43.c        | 12 +-----------
>  sound/soc/sdw_utils/soc_sdw_utils.c          | 20 ++++++++++++++++----
>  3 files changed, 17 insertions(+), 21 deletions(-)
>
> diff --git a/sound/soc/sdw_utils/soc_sdw_bridge_cs35l56.c b/sound/soc/sdw_utils/soc_sdw_bridge_cs35l56.c
> index 2a7109d53cbe3..e0e32a279787c 100644
> --- a/sound/soc/sdw_utils/soc_sdw_bridge_cs35l56.c
> +++ b/sound/soc/sdw_utils/soc_sdw_bridge_cs35l56.c
> @@ -40,12 +40,6 @@ static int asoc_sdw_bridge_cs35l56_asp_init(struct snd_soc_pcm_runtime *rtd)
>         struct snd_soc_dai *codec_dai;
>         struct snd_soc_dai *cpu_dai;
>
> -       card->components = devm_kasprintf(card->dev, GFP_KERNEL,
> -                                         "%s spk:cs35l56-bridge",
> -                                         card->components);
> -       if (!card->components)
> -               return -ENOMEM;
> -
>         ret = snd_soc_dapm_new_controls(dapm, bridge_widgets,
>                                         ARRAY_SIZE(bridge_widgets));
>         if (ret) {
> diff --git a/sound/soc/sdw_utils/soc_sdw_cs42l43.c b/sound/soc/sdw_utils/soc_sdw_cs42l43.c
> index 4a451b9d4f137..e99ea3c4e5dde 100644
> --- a/sound/soc/sdw_utils/soc_sdw_cs42l43.c
> +++ b/sound/soc/sdw_utils/soc_sdw_cs42l43.c
> @@ -107,21 +107,11 @@ EXPORT_SYMBOL_NS(asoc_sdw_cs42l43_hs_rtd_init, "SND_SOC_SDW_UTILS");
>
>  int asoc_sdw_cs42l43_spk_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai)
>  {
> -       struct snd_soc_component *component = snd_soc_rtd_to_codec(rtd, 0)->component;
> +       struct snd_soc_component *component = dai->component;
>         struct snd_soc_card *card = rtd->card;
>         struct snd_soc_dapm_context *dapm = snd_soc_card_to_dapm(card);
> -       struct asoc_sdw_mc_private *ctx = snd_soc_card_get_drvdata(card);
>         int ret;
>
> -       if (!(ctx->mc_quirk & SOC_SDW_SIDECAR_AMPS)) {
> -               /* Will be set by the bridge code in this case */
> -               card->components = devm_kasprintf(card->dev, GFP_KERNEL,
> -                                                 "%s spk:cs42l43-spk",
> -                                                 card->components);
> -               if (!card->components)
> -                       return -ENOMEM;
> -       }
> -
>         ret = snd_soc_limit_volume(card, "cs42l43 Speaker Digital Volume",
>                                    CS42L43_SPK_VOLUME_0DB);
>         if (ret)
> diff --git a/sound/soc/sdw_utils/soc_sdw_utils.c b/sound/soc/sdw_utils/soc_sdw_utils.c
> index 2807f536eef0c..1637cc3f3d598 100644
> --- a/sound/soc/sdw_utils/soc_sdw_utils.c
> +++ b/sound/soc/sdw_utils/soc_sdw_utils.c
> @@ -758,6 +758,7 @@ struct asoc_sdw_codec_info codec_info_list[] = {
>                         {
>                                 .direction = {true, false},
>                                 .codec_name = "cs42l43-codec",
> +                               .component_name = "cs42l43-spk",
>                                 .dai_name = "cs42l43-dp6",
>                                 .dai_type = SOC_SDW_DAI_TYPE_AMP,
>                                 .dailink = {SOC_SDW_AMP_OUT_DAI_ID, SOC_SDW_UNUSED_DAI_ID},
> @@ -1104,6 +1105,7 @@ static int asoc_sdw_find_codec_info_dai_index(const struct asoc_sdw_codec_info *
>  int asoc_sdw_rtd_init(struct snd_soc_pcm_runtime *rtd)
>  {
>         struct snd_soc_card *card = rtd->card;
> +       struct asoc_sdw_mc_private *ctx = snd_soc_card_get_drvdata(card);
>         struct snd_soc_dapm_context *dapm = snd_soc_card_to_dapm(card);
>         struct asoc_sdw_codec_info *codec_info;
>         struct snd_soc_dai *dai;
> @@ -1179,16 +1181,26 @@ int asoc_sdw_rtd_init(struct snd_soc_pcm_runtime *rtd)
>                 /* Generate the spk component string for card->components string */
>                 if (codec_info->dais[dai_index].dai_type == SOC_SDW_DAI_TYPE_AMP &&
>                     codec_info->dais[dai_index].component_name) {
> +                       const char *component;
> +
> +                       /*
> +                        * For the special case of cs42l43 with sidecar amps, use only
> +                        * "cs35l56-bridge" as the component name in card->components
> +                        */
> +                       if (ctx->mc_quirk & SOC_SDW_SIDECAR_AMPS &&
> +                           !strcmp(codec_info->dais[dai_index].component_name, "cs42l43-spk"))
> +                               component = "cs35l56-bridge";
> +                       else
> +                               component = codec_info->dais[dai_index].component_name;
> +
>                         if (strlen (spk_components) == 0)
>                                 spk_components =
> -                                       devm_kasprintf(card->dev, GFP_KERNEL, "%s",
> -                                                      codec_info->dais[dai_index].component_name);
> +                                       devm_kasprintf(card->dev, GFP_KERNEL, "%s", component);
>                         else
>                                 /* Append component name to spk_components */
>                                 spk_components =
>                                         devm_kasprintf(card->dev, GFP_KERNEL,
> -                                                      "%s+%s", spk_components,
> -                                                      codec_info->dais[dai_index].component_name);
> +                                                      "%s+%s", spk_components, component);
>                 }
>
>                 codec_info->dais[dai_index].rtd_init_done = true;
> --
> 2.47.3
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-04-21  9:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-20 11:48 [PATCH v2 RESEND] ASoC: sdw_utils: cs42l43: allow spk component names to be combined Maciej Strozek
2026-04-21  9:59 ` Aaron Ma

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox