[PATCH 2/2] ASoC: simple-card-utils: Add support of "hp-pin-name-headphone" property

Shengjiu Wang posted 2 patches 1 month, 1 week ago
[PATCH 2/2] ASoC: simple-card-utils: Add support of "hp-pin-name-headphone" property
Posted by Shengjiu Wang 1 month, 1 week ago
The 'Headphones Jack' name used in current simple-card and audio-graph
card driver can't be recognized by user space service daemon like
pulseaudio and pipewire, which only recognize the 'Headphone Jack',
so add 'hp-pin-name-headphone' property for this case and it won't block
original use cases for 'Headphones Jack'

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
---
 sound/soc/generic/simple-card-utils.c | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c
index bdc02e85b089..3d2194e23373 100644
--- a/sound/soc/generic/simple-card-utils.c
+++ b/sound/soc/generic/simple-card-utils.c
@@ -779,6 +779,24 @@ int simple_util_parse_pin_switches(struct snd_soc_card *card,
 }
 EXPORT_SYMBOL_GPL(simple_util_parse_pin_switches);
 
+static const char *simple_util_parse_hp_pin_name(struct snd_soc_card *card,
+						 char *prefix, char *pin)
+{
+	struct device_node *node = card->dev->of_node;
+	const char *str = NULL;
+	char prop[128];
+
+	if (!prefix)
+		prefix = "";
+
+	snprintf(prop, sizeof(prop), "%s%s", prefix, "hp-pin-name-headphone");
+
+	if (of_property_present(node, prop))
+		str = "Headphone";
+
+	return pin ? pin : (str ? str : "Headphones");
+}
+
 int simple_util_init_jack(struct snd_soc_card *card,
 			  struct simple_util_jack *sjack,
 			  int is_hp, char *prefix,
@@ -787,7 +805,7 @@ int simple_util_init_jack(struct snd_soc_card *card,
 	struct device *dev = card->dev;
 	struct gpio_desc *desc;
 	char prop[128];
-	char *pin_name;
+	const char *pin_name;
 	char *gpio_name;
 	int mask;
 	int error;
@@ -797,7 +815,7 @@ int simple_util_init_jack(struct snd_soc_card *card,
 
 	if (is_hp) {
 		snprintf(prop, sizeof(prop), "%shp-det", prefix);
-		pin_name	= pin ? pin : "Headphones";
+		pin_name = simple_util_parse_hp_pin_name(card, prefix, pin);
 		gpio_name	= "Headphone detection";
 		mask		= SND_JACK_HEADPHONE;
 	} else {
-- 
2.34.1
Re: [PATCH 2/2] ASoC: simple-card-utils: Add support of "hp-pin-name-headphone" property
Posted by Shengjiu Wang 1 month ago
On Mon, Dec 29, 2025 at 7:23 PM Shengjiu Wang <shengjiu.wang@nxp.com> wrote:
>
> The 'Headphones Jack' name used in current simple-card and audio-graph
> card driver can't be recognized by user space service daemon like
> pulseaudio and pipewire, which only recognize the 'Headphone Jack',
> so add 'hp-pin-name-headphone' property for this case and it won't block
> original use cases for 'Headphones Jack'
>
> Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
> ---
>  sound/soc/generic/simple-card-utils.c | 22 ++++++++++++++++++++--
>  1 file changed, 20 insertions(+), 2 deletions(-)
>
> diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c
> index bdc02e85b089..3d2194e23373 100644
> --- a/sound/soc/generic/simple-card-utils.c
> +++ b/sound/soc/generic/simple-card-utils.c
> @@ -779,6 +779,24 @@ int simple_util_parse_pin_switches(struct snd_soc_card *card,
>  }
>  EXPORT_SYMBOL_GPL(simple_util_parse_pin_switches);
>
> +static const char *simple_util_parse_hp_pin_name(struct snd_soc_card *card,
> +                                                char *prefix, char *pin)
> +{
> +       struct device_node *node = card->dev->of_node;
> +       const char *str = NULL;
> +       char prop[128];
> +
> +       if (!prefix)
> +               prefix = "";
> +
> +       snprintf(prop, sizeof(prop), "%s%s", prefix, "hp-pin-name-headphone");
> +
> +       if (of_property_present(node, prop))
> +               str = "Headphone";
> +
> +       return pin ? pin : (str ? str : "Headphones");
> +}
> +
>  int simple_util_init_jack(struct snd_soc_card *card,
>                           struct simple_util_jack *sjack,
>                           int is_hp, char *prefix,
> @@ -787,7 +805,7 @@ int simple_util_init_jack(struct snd_soc_card *card,
>         struct device *dev = card->dev;
>         struct gpio_desc *desc;
>         char prop[128];
> -       char *pin_name;
> +       const char *pin_name;
>         char *gpio_name;
>         int mask;
>         int error;
> @@ -797,7 +815,7 @@ int simple_util_init_jack(struct snd_soc_card *card,
>
>         if (is_hp) {
>                 snprintf(prop, sizeof(prop), "%shp-det", prefix);
> -               pin_name        = pin ? pin : "Headphones";

If the DT binding is not a choice,  shall I change the "Headphones" to
"Headphone"
directly?  I don't know if this change will block any case?

    pin_name        = pin ? pin : "Headphone";

best regards
Shengjiu Wang

> +               pin_name = simple_util_parse_hp_pin_name(card, prefix, pin);
>                 gpio_name       = "Headphone detection";
>                 mask            = SND_JACK_HEADPHONE;
>         } else {
> --
> 2.34.1
>
>
Re: [PATCH 2/2] ASoC: simple-card-utils: Add support of "hp-pin-name-headphone" property
Posted by Krzysztof Kozlowski 1 month, 1 week ago
On 29/12/2025 12:18, Shengjiu Wang wrote:
> The 'Headphones Jack' name used in current simple-card and audio-graph
> card driver can't be recognized by user space service daemon like
> pulseaudio and pipewire, which only recognize the 'Headphone Jack',
> so add 'hp-pin-name-headphone' property for this case and it won't block
> original use cases for 'Headphones Jack'
> 
> Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
> ---
>  sound/soc/generic/simple-card-utils.c | 22 ++++++++++++++++++++--
>  1 file changed, 20 insertions(+), 2 deletions(-)
> 
> diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c
> index bdc02e85b089..3d2194e23373 100644
> --- a/sound/soc/generic/simple-card-utils.c
> +++ b/sound/soc/generic/simple-card-utils.c
> @@ -779,6 +779,24 @@ int simple_util_parse_pin_switches(struct snd_soc_card *card,
>  }
>  EXPORT_SYMBOL_GPL(simple_util_parse_pin_switches);
>  
> +static const char *simple_util_parse_hp_pin_name(struct snd_soc_card *card,
> +						 char *prefix, char *pin)
> +{
> +	struct device_node *node = card->dev->of_node;
> +	const char *str = NULL;
> +	char prop[128];
> +
> +	if (!prefix)
> +		prefix = "";
> +
> +	snprintf(prop, sizeof(prop), "%s%s", prefix, "hp-pin-name-headphone");
> +

That's different name than you defined in the bindings.

Best regards,
Krzysztof