linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] ASoC: codecs: fix widget name comparisons
@ 2023-10-03 15:57 Krzysztof Kozlowski
  2023-10-03 15:57 ` [PATCH 1/2] ASoC: soc-dapm: Add helper for comparing widget name Krzysztof Kozlowski
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2023-10-03 15:57 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	Srinivas Kandagatla, Banajit Goswami, alsa-devel, linux-kernel
  Cc: Krzysztof Kozlowski

Hi,

Some codec drivers compare widget names with strcmp, ignoring the component
name prefix.  If prefix is used, the comparisons start failing.
Add a helper to fix the issue.

If the approach looks good, I will fix other codec drivers.

Best regards,
Krzysztof

Krzysztof Kozlowski (2):
  ASoC: soc-dapm: Add helper for comparing widget name
  ASoC: codecs: wsa-macro: handle component name prefix

 include/sound/soc-dapm.h           |  1 +
 sound/soc/codecs/lpass-wsa-macro.c |  4 ++--
 sound/soc/soc-component.c          |  1 +
 sound/soc/soc-dapm.c               | 12 ++++++++++++
 4 files changed, 16 insertions(+), 2 deletions(-)

-- 
2.34.1


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

* [PATCH 1/2] ASoC: soc-dapm: Add helper for comparing widget name
  2023-10-03 15:57 [PATCH 0/2] ASoC: codecs: fix widget name comparisons Krzysztof Kozlowski
@ 2023-10-03 15:57 ` Krzysztof Kozlowski
  2023-10-03 15:57 ` [PATCH 2/2] ASoC: codecs: wsa-macro: handle component name prefix Krzysztof Kozlowski
  2023-10-09 18:36 ` [PATCH 0/2] ASoC: codecs: fix widget name comparisons Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2023-10-03 15:57 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	Srinivas Kandagatla, Banajit Goswami, alsa-devel, linux-kernel
  Cc: Krzysztof Kozlowski

Some drivers use one event callback for multiple widgets but still need
to perform a bit different actions based on actual widget.  This is done
by comparing widget name, however drivers tend to miss possible name
prefix.  Add a helper to solve common mistakes.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
 include/sound/soc-dapm.h  |  1 +
 sound/soc/soc-component.c |  1 +
 sound/soc/soc-dapm.c      | 12 ++++++++++++
 3 files changed, 14 insertions(+)

diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h
index d2faec9a323e..433543eb82b9 100644
--- a/include/sound/soc-dapm.h
+++ b/include/sound/soc-dapm.h
@@ -469,6 +469,7 @@ void snd_soc_dapm_connect_dai_link_widgets(struct snd_soc_card *card);
 
 int snd_soc_dapm_update_dai(struct snd_pcm_substream *substream,
 			    struct snd_pcm_hw_params *params, struct snd_soc_dai *dai);
+int snd_soc_dapm_widget_name_cmp(struct snd_soc_dapm_widget *widget, const char *s);
 
 /* dapm path setup */
 int snd_soc_dapm_new_widgets(struct snd_soc_card *card);
diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c
index 69198de39e79..4d7c2e3c929a 100644
--- a/sound/soc/soc-component.c
+++ b/sound/soc/soc-component.c
@@ -242,6 +242,7 @@ int snd_soc_component_notify_control(struct snd_soc_component *component,
 	char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
 	struct snd_kcontrol *kctl;
 
+	/* When updating, change also snd_soc_dapm_widget_name_cmp() */
 	if (component->name_prefix)
 		snprintf(name, ARRAY_SIZE(name), "%s %s", component->name_prefix, ctl);
 	else
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 2512aadf95f7..8f22ce857f4a 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -2728,6 +2728,18 @@ int snd_soc_dapm_update_dai(struct snd_pcm_substream *substream,
 }
 EXPORT_SYMBOL_GPL(snd_soc_dapm_update_dai);
 
+int snd_soc_dapm_widget_name_cmp(struct snd_soc_dapm_widget *widget, const char *s)
+{
+	struct snd_soc_component *component = snd_soc_dapm_to_component(widget->dapm);
+	const char *wname = widget->name;
+
+	if (component->name_prefix)
+		wname += strlen(component->name_prefix) + 1; /* plus space */
+
+	return strcmp(wname, s);
+}
+EXPORT_SYMBOL_GPL(snd_soc_dapm_widget_name_cmp);
+
 /*
  * dapm_update_widget_flags() - Re-compute widget sink and source flags
  * @w: The widget for which to update the flags
-- 
2.34.1


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

* [PATCH 2/2] ASoC: codecs: wsa-macro: handle component name prefix
  2023-10-03 15:57 [PATCH 0/2] ASoC: codecs: fix widget name comparisons Krzysztof Kozlowski
  2023-10-03 15:57 ` [PATCH 1/2] ASoC: soc-dapm: Add helper for comparing widget name Krzysztof Kozlowski
@ 2023-10-03 15:57 ` Krzysztof Kozlowski
  2023-10-09 18:36 ` [PATCH 0/2] ASoC: codecs: fix widget name comparisons Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2023-10-03 15:57 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	Srinivas Kandagatla, Banajit Goswami, alsa-devel, linux-kernel
  Cc: Krzysztof Kozlowski

When comparing widget names in wsa_macro_spk_boost_event(), consider
also the component's name prefix.  Otherwise the WSA codec won't have
proper mixer setup resulting in no sound playback through speakers.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
 sound/soc/codecs/lpass-wsa-macro.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/soc/codecs/lpass-wsa-macro.c b/sound/soc/codecs/lpass-wsa-macro.c
index ea6e3fa7e9e1..7e21cec3c2fb 100644
--- a/sound/soc/codecs/lpass-wsa-macro.c
+++ b/sound/soc/codecs/lpass-wsa-macro.c
@@ -1675,12 +1675,12 @@ static int wsa_macro_spk_boost_event(struct snd_soc_dapm_widget *w,
 	u16 boost_path_ctl, boost_path_cfg1;
 	u16 reg, reg_mix;
 
-	if (!strcmp(w->name, "WSA_RX INT0 CHAIN")) {
+	if (!snd_soc_dapm_widget_name_cmp(w, "WSA_RX INT0 CHAIN")) {
 		boost_path_ctl = CDC_WSA_BOOST0_BOOST_PATH_CTL;
 		boost_path_cfg1 = CDC_WSA_RX0_RX_PATH_CFG1;
 		reg = CDC_WSA_RX0_RX_PATH_CTL;
 		reg_mix = CDC_WSA_RX0_RX_PATH_MIX_CTL;
-	} else if (!strcmp(w->name, "WSA_RX INT1 CHAIN")) {
+	} else if (!snd_soc_dapm_widget_name_cmp(w, "WSA_RX INT1 CHAIN")) {
 		boost_path_ctl = CDC_WSA_BOOST1_BOOST_PATH_CTL;
 		boost_path_cfg1 = CDC_WSA_RX1_RX_PATH_CFG1;
 		reg = CDC_WSA_RX1_RX_PATH_CTL;
-- 
2.34.1


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

* Re: [PATCH 0/2] ASoC: codecs: fix widget name comparisons
  2023-10-03 15:57 [PATCH 0/2] ASoC: codecs: fix widget name comparisons Krzysztof Kozlowski
  2023-10-03 15:57 ` [PATCH 1/2] ASoC: soc-dapm: Add helper for comparing widget name Krzysztof Kozlowski
  2023-10-03 15:57 ` [PATCH 2/2] ASoC: codecs: wsa-macro: handle component name prefix Krzysztof Kozlowski
@ 2023-10-09 18:36 ` Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2023-10-09 18:36 UTC (permalink / raw)
  To: Liam Girdwood, Jaroslav Kysela, Takashi Iwai,
	Srinivas Kandagatla, Banajit Goswami, alsa-devel, linux-kernel,
	Krzysztof Kozlowski

On Tue, 03 Oct 2023 17:57:08 +0200, Krzysztof Kozlowski wrote:
> Some codec drivers compare widget names with strcmp, ignoring the component
> name prefix.  If prefix is used, the comparisons start failing.
> Add a helper to fix the issue.
> 
> If the approach looks good, I will fix other codec drivers.
> 
> Best regards,
> Krzysztof
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/2] ASoC: soc-dapm: Add helper for comparing widget name
      commit: 76aca10ccb7c23a7b7a0d56e0bfde2c8cdddfe24
[2/2] ASoC: codecs: wsa-macro: handle component name prefix
      commit: c29e5263d32a6d0ec094d425ae7fef3fa8d4da1c

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


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

end of thread, other threads:[~2023-10-09 18:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-03 15:57 [PATCH 0/2] ASoC: codecs: fix widget name comparisons Krzysztof Kozlowski
2023-10-03 15:57 ` [PATCH 1/2] ASoC: soc-dapm: Add helper for comparing widget name Krzysztof Kozlowski
2023-10-03 15:57 ` [PATCH 2/2] ASoC: codecs: wsa-macro: handle component name prefix Krzysztof Kozlowski
2023-10-09 18:36 ` [PATCH 0/2] ASoC: codecs: fix widget name comparisons Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).