* [PATCH v3 1/4] ASoC: dt-bindings: mediatek,mt8188-mt6359: Add mediatek,accdet
2025-03-06 19:52 [PATCH v3 0/4] Allow retrieving accessory detection reference on MT8188 Nícolas F. R. A. Prado
@ 2025-03-06 19:52 ` Nícolas F. R. A. Prado
2025-03-06 19:52 ` [PATCH v3 2/4] ASoC: mediatek: common: Handle mediatek,accdet property Nícolas F. R. A. Prado
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-03-06 19:52 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Matthias Brugger, AngeloGioacchino Del Regno,
Trevor Wu, Jaroslav Kysela, Takashi Iwai
Cc: kernel, linux-sound, devicetree, linux-kernel, linux-arm-kernel,
linux-mediatek, Nícolas F. R. A. Prado
Add a mediatek,accdet phandle property to allow getting a reference to
the MT6359 ACCDET block, which is responsible for detecting jack
insertion/removal.
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: Rob Herring (Arm) <robh@kernel.org>
Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---
.../devicetree/bindings/sound/mediatek,mt8188-mt6359.yaml | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/Documentation/devicetree/bindings/sound/mediatek,mt8188-mt6359.yaml b/Documentation/devicetree/bindings/sound/mediatek,mt8188-mt6359.yaml
index 8c77e7f68ad7b6f5b88b53cedccb291139a2eeea..76d5a437dc8f4ad1f31c21f84304bad326b0facd 100644
--- a/Documentation/devicetree/bindings/sound/mediatek,mt8188-mt6359.yaml
+++ b/Documentation/devicetree/bindings/sound/mediatek,mt8188-mt6359.yaml
@@ -40,6 +40,14 @@ properties:
hardware that provides additional audio functionalities if present.
The AFE will link to ADSP when the phandle is provided.
+ mediatek,accdet:
+ $ref: /schemas/types.yaml#/definitions/phandle
+ description:
+ The phandle to the MT6359 accessory detection block, which detects audio
+ jack insertion and removal. This property should only be present if the
+ accdet block is actually wired to the audio jack pins and to be used for
+ jack detection.
+
patternProperties:
"^dai-link-[0-9]+$":
type: object
--
2.48.1
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH v3 2/4] ASoC: mediatek: common: Handle mediatek,accdet property
2025-03-06 19:52 [PATCH v3 0/4] Allow retrieving accessory detection reference on MT8188 Nícolas F. R. A. Prado
2025-03-06 19:52 ` [PATCH v3 1/4] ASoC: dt-bindings: mediatek,mt8188-mt6359: Add mediatek,accdet Nícolas F. R. A. Prado
@ 2025-03-06 19:52 ` Nícolas F. R. A. Prado
2025-03-06 19:52 ` [PATCH v3 3/4] ASoC: mediatek: mt6359: Add stub for mt6359_accdet_enable_jack_detect Nícolas F. R. A. Prado
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-03-06 19:52 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Matthias Brugger, AngeloGioacchino Del Regno,
Trevor Wu, Jaroslav Kysela, Takashi Iwai
Cc: kernel, linux-sound, devicetree, linux-kernel, linux-arm-kernel,
linux-mediatek, Nícolas F. R. A. Prado
Handle the optional mediatek,accdet property. When present, retrieve the
sound component from its phandle, so the machine sound driver can use it
to register the audio jack and initialize the MT6359 ACCDET for jack
detection.
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---
sound/soc/mediatek/common/mtk-soc-card.h | 1 +
sound/soc/mediatek/common/mtk-soundcard-driver.c | 19 ++++++++++++++++++-
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/sound/soc/mediatek/common/mtk-soc-card.h b/sound/soc/mediatek/common/mtk-soc-card.h
index 3f6e24dd22df13ddb3aef1625a77d2e29e46fccf..a1d2794ac1f717997fb47023d5951a9ac4897788 100644
--- a/sound/soc/mediatek/common/mtk-soc-card.h
+++ b/sound/soc/mediatek/common/mtk-soc-card.h
@@ -16,6 +16,7 @@ struct mtk_soc_card_data {
const struct mtk_sof_priv *sof_priv;
struct list_head sof_dai_link_list;
struct mtk_platform_card_data *card_data;
+ struct snd_soc_component *accdet;
void *mach_priv;
};
diff --git a/sound/soc/mediatek/common/mtk-soundcard-driver.c b/sound/soc/mediatek/common/mtk-soundcard-driver.c
index f4314dddc46075d554b4e3f3aae8bcb5498f8ab5..713a368f79cf049f7879075c675457e91ba8332d 100644
--- a/sound/soc/mediatek/common/mtk-soundcard-driver.c
+++ b/sound/soc/mediatek/common/mtk-soundcard-driver.c
@@ -8,6 +8,7 @@
#include <linux/module.h>
#include <linux/of.h>
+#include <linux/of_platform.h>
#include <sound/soc.h>
#include "mtk-dsp-sof-common.h"
@@ -192,7 +193,9 @@ EXPORT_SYMBOL_GPL(mtk_soundcard_common_capture_ops);
int mtk_soundcard_common_probe(struct platform_device *pdev)
{
- struct device_node *platform_node, *adsp_node;
+ struct device_node *platform_node, *adsp_node, *accdet_node;
+ struct snd_soc_component *accdet_comp;
+ struct platform_device *accdet_pdev;
const struct mtk_soundcard_pdata *pdata;
struct mtk_soc_card_data *soc_card_data;
struct snd_soc_dai_link *orig_dai_link, *dai_link;
@@ -250,6 +253,20 @@ int mtk_soundcard_common_probe(struct platform_device *pdev)
soc_card_data->card_data->jacks = jacks;
+ accdet_node = of_parse_phandle(pdev->dev.of_node, "mediatek,accdet", 0);
+ if (accdet_node) {
+ accdet_pdev = of_find_device_by_node(accdet_node);
+ if (accdet_pdev) {
+ accdet_comp = snd_soc_lookup_component(&accdet_pdev->dev, NULL);
+ if (accdet_comp)
+ soc_card_data->accdet = accdet_comp;
+ else
+ dev_err(&pdev->dev, "No sound component found from mediatek,accdet property\n");
+ } else {
+ dev_err(&pdev->dev, "No device found from mediatek,accdet property\n");
+ }
+ }
+
platform_node = of_parse_phandle(pdev->dev.of_node, "mediatek,platform", 0);
if (!platform_node)
return dev_err_probe(&pdev->dev, -EINVAL,
--
2.48.1
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH v3 3/4] ASoC: mediatek: mt6359: Add stub for mt6359_accdet_enable_jack_detect
2025-03-06 19:52 [PATCH v3 0/4] Allow retrieving accessory detection reference on MT8188 Nícolas F. R. A. Prado
2025-03-06 19:52 ` [PATCH v3 1/4] ASoC: dt-bindings: mediatek,mt8188-mt6359: Add mediatek,accdet Nícolas F. R. A. Prado
2025-03-06 19:52 ` [PATCH v3 2/4] ASoC: mediatek: common: Handle mediatek,accdet property Nícolas F. R. A. Prado
@ 2025-03-06 19:52 ` Nícolas F. R. A. Prado
2025-03-06 19:52 ` [PATCH v3 4/4] ASoC: mediatek: mt8188-mt6359: Add accdet headset jack detect support Nícolas F. R. A. Prado
2025-03-17 18:47 ` [PATCH v3 0/4] Allow retrieving accessory detection reference on MT8188 Mark Brown
4 siblings, 0 replies; 6+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-03-06 19:52 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Matthias Brugger, AngeloGioacchino Del Regno,
Trevor Wu, Jaroslav Kysela, Takashi Iwai
Cc: kernel, linux-sound, devicetree, linux-kernel, linux-arm-kernel,
linux-mediatek, Nícolas F. R. A. Prado
Add a stub for mt6359_accdet_enable_jack_detect() to prevent linker
failures in the machine sound drivers calling it when
CONFIG_SND_SOC_MT6359_ACCDET is not enabled.
Suggested-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---
sound/soc/codecs/mt6359-accdet.h | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/sound/soc/codecs/mt6359-accdet.h b/sound/soc/codecs/mt6359-accdet.h
index c234f2f4276a12853a6fe0b13c4198dfc551b6b4..78ada3a5bfae55308135f37acc4c3857057bd203 100644
--- a/sound/soc/codecs/mt6359-accdet.h
+++ b/sound/soc/codecs/mt6359-accdet.h
@@ -123,6 +123,15 @@ struct mt6359_accdet {
struct workqueue_struct *jd_workqueue;
};
+#if IS_ENABLED(CONFIG_SND_SOC_MT6359_ACCDET)
int mt6359_accdet_enable_jack_detect(struct snd_soc_component *component,
struct snd_soc_jack *jack);
+#else
+static inline int
+mt6359_accdet_enable_jack_detect(struct snd_soc_component *component,
+ struct snd_soc_jack *jack)
+{
+ return -EOPNOTSUPP;
+}
+#endif
#endif
--
2.48.1
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH v3 4/4] ASoC: mediatek: mt8188-mt6359: Add accdet headset jack detect support
2025-03-06 19:52 [PATCH v3 0/4] Allow retrieving accessory detection reference on MT8188 Nícolas F. R. A. Prado
` (2 preceding siblings ...)
2025-03-06 19:52 ` [PATCH v3 3/4] ASoC: mediatek: mt6359: Add stub for mt6359_accdet_enable_jack_detect Nícolas F. R. A. Prado
@ 2025-03-06 19:52 ` Nícolas F. R. A. Prado
2025-03-17 18:47 ` [PATCH v3 0/4] Allow retrieving accessory detection reference on MT8188 Mark Brown
4 siblings, 0 replies; 6+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-03-06 19:52 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Matthias Brugger, AngeloGioacchino Del Regno,
Trevor Wu, Jaroslav Kysela, Takashi Iwai
Cc: kernel, linux-sound, devicetree, linux-kernel, linux-arm-kernel,
linux-mediatek, Nícolas F. R. A. Prado, Zoran Zhan
Enable headset jack detection for MT8188 platforms that use the MT6359
ACCDET block for it, indicated by the mediatek,accdet property in DT.
For those platforms, register a jack and initialize the ACCDET block to
report jack events through it.
Co-developed-by: Zoran Zhan <zoran.zhan@mediatek.com>
Signed-off-by: Zoran Zhan <zoran.zhan@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---
sound/soc/mediatek/mt8188/mt8188-mt6359.c | 43 +++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
diff --git a/sound/soc/mediatek/mt8188/mt8188-mt6359.c b/sound/soc/mediatek/mt8188/mt8188-mt6359.c
index 420b1427b71dc1424a52f7ab6140c14659036733..20dc9470ba76b2a750e79a5ae3dafabd7c597f40 100644
--- a/sound/soc/mediatek/mt8188/mt8188-mt6359.c
+++ b/sound/soc/mediatek/mt8188/mt8188-mt6359.c
@@ -17,6 +17,7 @@
#include "mt8188-afe-common.h"
#include "../../codecs/nau8825.h"
#include "../../codecs/mt6359.h"
+#include "../../codecs/mt6359-accdet.h"
#include "../../codecs/rt5682.h"
#include "../common/mtk-afe-platform-driver.h"
#include "../common/mtk-soundcard-driver.h"
@@ -271,6 +272,17 @@ static struct snd_soc_jack_pin nau8825_jack_pins[] = {
},
};
+static struct snd_soc_jack_pin mt8188_headset_jack_pins[] = {
+ {
+ .pin = "Headphone",
+ .mask = SND_JACK_HEADPHONE,
+ },
+ {
+ .pin = "Headset Mic",
+ .mask = SND_JACK_MICROPHONE,
+ },
+};
+
static const struct snd_kcontrol_new mt8188_dumb_spk_controls[] = {
SOC_DAPM_PIN_SWITCH("Ext Spk"),
};
@@ -506,6 +518,35 @@ static int mt8188_mt6359_mtkaif_calibration(struct snd_soc_pcm_runtime *rtd)
return 0;
}
+static int mt8188_mt6359_accdet_init(struct snd_soc_pcm_runtime *rtd)
+{
+ struct mtk_soc_card_data *soc_card_data = snd_soc_card_get_drvdata(rtd->card);
+ struct snd_soc_jack *jack = &soc_card_data->card_data->jacks[MT8188_JACK_HEADSET];
+ int ret;
+
+ if (!soc_card_data->accdet)
+ return 0;
+
+ ret = snd_soc_card_jack_new_pins(rtd->card, "Headset Jack",
+ SND_JACK_HEADSET | SND_JACK_BTN_0 |
+ SND_JACK_BTN_1 | SND_JACK_BTN_2 |
+ SND_JACK_BTN_3,
+ jack, mt8188_headset_jack_pins,
+ ARRAY_SIZE(mt8188_headset_jack_pins));
+ if (ret) {
+ dev_err(rtd->dev, "Headset Jack create failed: %d\n", ret);
+ return ret;
+ }
+
+ ret = mt6359_accdet_enable_jack_detect(soc_card_data->accdet, jack);
+ if (ret) {
+ dev_err(rtd->dev, "Headset Jack enable failed: %d\n", ret);
+ return ret;
+ }
+
+ return 0;
+}
+
static int mt8188_mt6359_init(struct snd_soc_pcm_runtime *rtd)
{
struct snd_soc_component *cmpnt_codec =
@@ -518,6 +559,8 @@ static int mt8188_mt6359_init(struct snd_soc_pcm_runtime *rtd)
/* mtkaif calibration */
mt8188_mt6359_mtkaif_calibration(rtd);
+ mt8188_mt6359_accdet_init(rtd);
+
return 0;
}
--
2.48.1
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH v3 0/4] Allow retrieving accessory detection reference on MT8188
2025-03-06 19:52 [PATCH v3 0/4] Allow retrieving accessory detection reference on MT8188 Nícolas F. R. A. Prado
` (3 preceding siblings ...)
2025-03-06 19:52 ` [PATCH v3 4/4] ASoC: mediatek: mt8188-mt6359: Add accdet headset jack detect support Nícolas F. R. A. Prado
@ 2025-03-17 18:47 ` Mark Brown
4 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2025-03-17 18:47 UTC (permalink / raw)
To: Liam Girdwood, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Matthias Brugger, AngeloGioacchino Del Regno, Trevor Wu,
Jaroslav Kysela, Takashi Iwai, Nícolas F. R. A. Prado
Cc: kernel, linux-sound, devicetree, linux-kernel, linux-arm-kernel,
linux-mediatek, Zoran Zhan
On Thu, 06 Mar 2025 16:52:14 -0300, Nícolas F. R. A. Prado wrote:
> This series enables the MT8188-MT6359 sound driver to retrieve the
> MT6359 ACCDET sound component from a mediatek,accdet DT property, which
> allows detecting jack insertion/removal.
>
> Patch 1 describes the new property in the binding. Patch 2 implements
> the sound component retrieval in the common MTK soundcard driver. Patch
> 4 updates the MT8188-MT6359 sound driver to register the audio jack and
> initialize the ACCDET driver for detection, if the property is present.
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/4] ASoC: dt-bindings: mediatek,mt8188-mt6359: Add mediatek,accdet
commit: 3fec903f2cb18805b1ef22a0e310498020c1f15e
[2/4] ASoC: mediatek: common: Handle mediatek,accdet property
commit: cf536e2622e2b0a60c99e799995b6e9acf539c17
[3/4] ASoC: mediatek: mt6359: Add stub for mt6359_accdet_enable_jack_detect
commit: 0116a7d84b32537a10d9bea1fd1bfc06577ef527
[4/4] ASoC: mediatek: mt8188-mt6359: Add accdet headset jack detect support
commit: f35d834d67adbbf121ee4397376d9eac21d99a85
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] 6+ messages in thread