[PATCH 0/3] ASoC: imx-rpmsg: Add headphone jack detection and driver_name support

Chancel Liu posted 3 patches 1 week, 6 days ago
There is a newer version of this series
Documentation/devicetree/bindings/sound/fsl,rpmsg.yaml | 4 ++++
sound/soc/fsl/imx-rpmsg.c                              | 9 +++++++++
2 files changed, 13 insertions(+)
[PATCH 0/3] ASoC: imx-rpmsg: Add headphone jack detection and driver_name support
Posted by Chancel Liu 1 week, 6 days ago
This series adds two features to the i.MX RPMSG ASoC card:
1. Headphone jack detection via GPIO: Introduce the "hp-det-gpios"
   device tree property and use simple_util_init_jack() to
   register a headphone jack with GPIO-based insertion detection.

2. driver_name assignment: Set driver_name on the snd_soc_card to
   "imx-audio-rpmsg", enabling userspace tools such as UCM to reliably
   identify the card by driver name regardless of the board-specific
   card name.

Chancel Liu (3):
  ASoC: dt-bindings: fsl,rpmsg: Add hp-det-gpios property
  ASoC: imx-rpmsg: Support headphone jack detection
  ASoC: imx-rpmsg: Set driver_name for snd_soc_card

 Documentation/devicetree/bindings/sound/fsl,rpmsg.yaml | 4 ++++
 sound/soc/fsl/imx-rpmsg.c                              | 9 +++++++++
 2 files changed, 13 insertions(+)

--
2.50.1
[PATCH v2 0/3] ASoC: imx-rpmsg: Add headphone jack detection and driver_name support
Posted by Chancel Liu 1 week, 4 days ago
This series adds two features to the i.MX RPMSG ASoC card:
1. Headphone jack detection via GPIO: Introduce the "hp-det-gpios"
   device tree property and use simple_util_init_jack() to
   register a headphone jack with GPIO-based insertion detection.

2. driver_name assignment: Set driver_name on the snd_soc_card to
   "imx-audio-rpmsg", enabling userspace tools such as UCM to reliably
   identify the card by driver name regardless of the board-specific
   card name.

Changes in v2:
- Add Kconfig dependency on SND_SOC_SIMPLE_CARD_UTILS
- Moved headphone jack initialization from probe() to late_probe()
to avoid interaction issues with deferred probe

Chancel Liu (3):
  ASoC: dt-bindings: fsl,rpmsg: Add hp-det-gpios property
  ASoC: imx-rpmsg: Support headphone jack detection
  ASoC: imx-rpmsg: Set driver_name for snd_soc_card

 .../devicetree/bindings/sound/fsl,rpmsg.yaml         |  4 ++++
 sound/soc/fsl/Kconfig                                |  1 +
 sound/soc/fsl/imx-rpmsg.c                            | 12 ++++++++++++
 3 files changed, 17 insertions(+)

--
2.50.1
Re: [PATCH v2 0/3] ASoC: imx-rpmsg: Add headphone jack detection and driver_name support
Posted by Andrew Lunn 1 week, 4 days ago
On Thu, May 28, 2026 at 11:07:22AM +0900, Chancel Liu wrote:
> This series adds two features to the i.MX RPMSG ASoC card:
> 1. Headphone jack detection via GPIO: Introduce the "hp-det-gpios"
>    device tree property and use simple_util_init_jack() to
>    register a headphone jack with GPIO-based insertion detection.

I'm not familiar with ASoC, but have been in a long discussion about
RPMSG and GPIO....

I just want to confirm the GPIO you are talking about is a local GPIO?
You are not tunnelling the GPIO over RPMSG using some vendor protocol?

	Andrew
Re: [PATCH v2 0/3] ASoC: imx-rpmsg: Add headphone jack detection and driver_name support
Posted by Mark Brown 1 week, 4 days ago
On Thu, May 28, 2026 at 04:12:58PM +0200, Andrew Lunn wrote:
> On Thu, May 28, 2026 at 11:07:22AM +0900, Chancel Liu wrote:

> > This series adds two features to the i.MX RPMSG ASoC card:
> > 1. Headphone jack detection via GPIO: Introduce the "hp-det-gpios"
> >    device tree property and use simple_util_init_jack() to
> >    register a headphone jack with GPIO-based insertion detection.

> I'm not familiar with ASoC, but have been in a long discussion about
> RPMSG and GPIO....

> I just want to confirm the GPIO you are talking about is a local GPIO?
> You are not tunnelling the GPIO over RPMSG using some vendor protocol?

This is a GPIO accessed via gpiolib, the driver is for an audio
subsystem accessed via rpmsg.
Re: [PATCH v2 0/3] ASoC: imx-rpmsg: Add headphone jack detection and driver_name support
Posted by Andrew Lunn 1 week, 4 days ago
On Thu, May 28, 2026 at 03:18:05PM +0100, Mark Brown wrote:
> On Thu, May 28, 2026 at 04:12:58PM +0200, Andrew Lunn wrote:
> > On Thu, May 28, 2026 at 11:07:22AM +0900, Chancel Liu wrote:
> 
> > > This series adds two features to the i.MX RPMSG ASoC card:
> > > 1. Headphone jack detection via GPIO: Introduce the "hp-det-gpios"
> > >    device tree property and use simple_util_init_jack() to
> > >    register a headphone jack with GPIO-based insertion detection.
> 
> > I'm not familiar with ASoC, but have been in a long discussion about
> > RPMSG and GPIO....
> 
> > I just want to confirm the GPIO you are talking about is a local GPIO?
> > You are not tunnelling the GPIO over RPMSG using some vendor protocol?
> 
> This is a GPIO accessed via gpiolib, the driver is for an audio
> subsystem accessed via rpmsg.

Great, thanks.

When we eventually get GPIO over RPMSG, it should also just look like
a standard gpiolib GPIO. But we are not there yet, defining the one
protocol that all vendors must use, rather than each vendor doing
their own thing.

  Andrew
[PATCH v2 1/3] ASoC: dt-bindings: fsl,rpmsg: Add hp-det-gpios property
Posted by Chancel Liu 1 week, 4 days ago
Sound cards using the i.MX RPMSG audio interface may connect a
headphone jack with GPIO-based insertion detection. Add the
"hp-det-gpios" property to the fsl,rpmsg binding to support this
configuration.

Signed-off-by: Chancel Liu <chancel.liu@nxp.com>
---
 Documentation/devicetree/bindings/sound/fsl,rpmsg.yaml | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/sound/fsl,rpmsg.yaml b/Documentation/devicetree/bindings/sound/fsl,rpmsg.yaml
index 3a32f7517d0c..e3cadb93c183 100644
--- a/Documentation/devicetree/bindings/sound/fsl,rpmsg.yaml
+++ b/Documentation/devicetree/bindings/sound/fsl,rpmsg.yaml
@@ -98,6 +98,10 @@ properties:
       - rpmsg-audio-channel
       - rpmsg-micfil-channel
 
+  hp-det-gpios:
+    maxItems: 1
+    description: The GPIO that detect headphones are plugged in
+
 required:
   - compatible
 
-- 
2.50.1
[PATCH v2 2/3] ASoC: imx-rpmsg: Support headphone jack detection
Posted by Chancel Liu 1 week, 4 days ago
Add headphone jack detection support for i.MX RPMSG audio cards.
When the "hp-det-gpios" property is present in the device tree node,
use simple_util_init_jack() from the ASoC simple card utilities to
register a headphone jack with GPIO-based insertion detection.

Signed-off-by: Chancel Liu <chancel.liu@nxp.com>
---
 sound/soc/fsl/Kconfig     |  1 +
 sound/soc/fsl/imx-rpmsg.c | 11 +++++++++++
 2 files changed, 12 insertions(+)

diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig
index ae8774e11873..8ae59c094878 100644
--- a/sound/soc/fsl/Kconfig
+++ b/sound/soc/fsl/Kconfig
@@ -358,6 +358,7 @@ config SND_SOC_IMX_RPMSG
 	depends on OF && I2C
 	select SND_SOC_IMX_PCM_RPMSG
 	select SND_SOC_IMX_AUDIO_RPMSG
+	select SND_SIMPLE_CARD_UTILS
 	help
 	  SoC Audio support for i.MX boards with rpmsg.
 	  There should be rpmsg devices defined in other core (M core)
diff --git a/sound/soc/fsl/imx-rpmsg.c b/sound/soc/fsl/imx-rpmsg.c
index fd4624786b62..48fe471499ba 100644
--- a/sound/soc/fsl/imx-rpmsg.c
+++ b/sound/soc/fsl/imx-rpmsg.c
@@ -12,6 +12,7 @@
 #include <sound/control.h>
 #include <sound/pcm_params.h>
 #include <sound/soc-dapm.h>
+#include <sound/simple_card_utils.h>
 #include "imx-pcm-rpmsg.h"
 
 struct imx_rpmsg {
@@ -19,6 +20,7 @@ struct imx_rpmsg {
 	struct snd_soc_card card;
 	unsigned long sysclk;
 	bool lpa;
+	struct simple_util_jack hp_jack;
 };
 
 static struct dev_pm_ops lpa_pm;
@@ -86,6 +88,15 @@ static int imx_rpmsg_late_probe(struct snd_soc_card *card)
 	struct device *dev = card->dev;
 	int ret;
 
+	if (of_property_present(card->dev->of_node, "hp-det-gpios")) {
+		ret = simple_util_init_jack(card, &data->hp_jack,
+					    1, NULL, "Headphone Jack");
+		if (ret) {
+			dev_err(dev, "failed to init hp jack\n");
+			return ret;
+		}
+	}
+
 	if (data->lpa) {
 		struct device_node *codec_np;
 		struct device_driver *codec_drv;
-- 
2.50.1
[PATCH v2 3/3] ASoC: imx-rpmsg: Set driver_name for snd_soc_card
Posted by Chancel Liu 1 week, 4 days ago
Set driver_name to "imx-audio-rpmsg" for the i.MX RPMSG sound card.
This allows userspace audio configuration tools (e.g., UCM) to match
the card by driver name independently of the card name, which may vary
across board configurations.

Signed-off-by: Chancel Liu <chancel.liu@nxp.com>
---
 sound/soc/fsl/imx-rpmsg.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sound/soc/fsl/imx-rpmsg.c b/sound/soc/fsl/imx-rpmsg.c
index 48fe471499ba..5f1af258caf2 100644
--- a/sound/soc/fsl/imx-rpmsg.c
+++ b/sound/soc/fsl/imx-rpmsg.c
@@ -250,6 +250,7 @@ static int imx_rpmsg_probe(struct platform_device *pdev)
 	data->card.dapm_widgets = imx_rpmsg_dapm_widgets;
 	data->card.num_dapm_widgets = ARRAY_SIZE(imx_rpmsg_dapm_widgets);
 	data->card.late_probe = imx_rpmsg_late_probe;
+	data->card.driver_name = "imx-audio-rpmsg";
 	/*
 	 * Inoder to use common api to get card name and audio routing.
 	 * Use parent of_node for this device, revert it after finishing using
-- 
2.50.1