]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ASoC: imx-rpmsg: Support headphone jack detection
authorChancel Liu <chancel.liu@nxp.com>
Thu, 28 May 2026 02:07:24 +0000 (11:07 +0900)
committerMark Brown <broonie@kernel.org>
Mon, 8 Jun 2026 17:53:21 +0000 (18:53 +0100)
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>
Link: https://patch.msgid.link/20260528020725.2265321-3-chancel.liu@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/fsl/Kconfig
sound/soc/fsl/imx-rpmsg.c

index ae8774e11873dca06f96e2597de29932b0af3018..8ae59c0948788080c351c4c21287f954ce2608b1 100644 (file)
@@ -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)
index fd4624786b627e0c24fd64d563ae2afbf0174845..48fe471499bacf7ac8ede4b9b1fa175a3e80b111 100644 (file)
@@ -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;