Skip to content

Commit f35d834

Browse files
nfrapradobroonie
authored andcommitted
ASoC: mediatek: mt8188-mt6359: Add accdet headset jack detect support
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 <[email protected]> Signed-off-by: Zoran Zhan <[email protected]> Reviewed-by: AngeloGioacchino Del Regno <[email protected]> Signed-off-by: Nícolas F. R. A. Prado <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 0116a7d commit f35d834

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

sound/soc/mediatek/mt8188/mt8188-mt6359.c

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "mt8188-afe-common.h"
1818
#include "../../codecs/nau8825.h"
1919
#include "../../codecs/mt6359.h"
20+
#include "../../codecs/mt6359-accdet.h"
2021
#include "../../codecs/rt5682.h"
2122
#include "../common/mtk-afe-platform-driver.h"
2223
#include "../common/mtk-soundcard-driver.h"
@@ -271,6 +272,17 @@ static struct snd_soc_jack_pin nau8825_jack_pins[] = {
271272
},
272273
};
273274

275+
static struct snd_soc_jack_pin mt8188_headset_jack_pins[] = {
276+
{
277+
.pin = "Headphone",
278+
.mask = SND_JACK_HEADPHONE,
279+
},
280+
{
281+
.pin = "Headset Mic",
282+
.mask = SND_JACK_MICROPHONE,
283+
},
284+
};
285+
274286
static const struct snd_kcontrol_new mt8188_dumb_spk_controls[] = {
275287
SOC_DAPM_PIN_SWITCH("Ext Spk"),
276288
};
@@ -506,6 +518,35 @@ static int mt8188_mt6359_mtkaif_calibration(struct snd_soc_pcm_runtime *rtd)
506518
return 0;
507519
}
508520

521+
static int mt8188_mt6359_accdet_init(struct snd_soc_pcm_runtime *rtd)
522+
{
523+
struct mtk_soc_card_data *soc_card_data = snd_soc_card_get_drvdata(rtd->card);
524+
struct snd_soc_jack *jack = &soc_card_data->card_data->jacks[MT8188_JACK_HEADSET];
525+
int ret;
526+
527+
if (!soc_card_data->accdet)
528+
return 0;
529+
530+
ret = snd_soc_card_jack_new_pins(rtd->card, "Headset Jack",
531+
SND_JACK_HEADSET | SND_JACK_BTN_0 |
532+
SND_JACK_BTN_1 | SND_JACK_BTN_2 |
533+
SND_JACK_BTN_3,
534+
jack, mt8188_headset_jack_pins,
535+
ARRAY_SIZE(mt8188_headset_jack_pins));
536+
if (ret) {
537+
dev_err(rtd->dev, "Headset Jack create failed: %d\n", ret);
538+
return ret;
539+
}
540+
541+
ret = mt6359_accdet_enable_jack_detect(soc_card_data->accdet, jack);
542+
if (ret) {
543+
dev_err(rtd->dev, "Headset Jack enable failed: %d\n", ret);
544+
return ret;
545+
}
546+
547+
return 0;
548+
}
549+
509550
static int mt8188_mt6359_init(struct snd_soc_pcm_runtime *rtd)
510551
{
511552
struct snd_soc_component *cmpnt_codec =
@@ -518,6 +559,8 @@ static int mt8188_mt6359_init(struct snd_soc_pcm_runtime *rtd)
518559
/* mtkaif calibration */
519560
mt8188_mt6359_mtkaif_calibration(rtd);
520561

562+
mt8188_mt6359_accdet_init(rtd);
563+
521564
return 0;
522565
}
523566

0 commit comments

Comments
 (0)