From 674379cd80b8ca880ef7c996876b423e3d5b3c86 Mon Sep 17 00:00:00 2001 From: James Calligeros Date: Sat, 28 Sep 2024 18:49:44 +1000 Subject: [PATCH 1/2] ASoC: cs42l84: delay headset detect to prevent misdetections The tip sense interrupt is quite trigger happy. There are instances where we kick off - and finish - headset detection before the user has had a chance to even finish plugging in the jack. This leads to misdetections, including detecting headsets as not having a microphone. The only way to fix this is to unplug the headset and plug it back in. Give the user 1.5 seconds to fully plug in their headset/headphones before running the headset/button detection logic. This reduces the chance of misdetections. Signed-off-by: James Calligeros --- sound/soc/codecs/cs42l84.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sound/soc/codecs/cs42l84.c b/sound/soc/codecs/cs42l84.c index d8fc7bdb89bb00..479cb392bb1736 100644 --- a/sound/soc/codecs/cs42l84.c +++ b/sound/soc/codecs/cs42l84.c @@ -840,6 +840,8 @@ static irqreturn_t cs42l84_irq_thread(int irq, void *data) cs42l84->plug_state = CS42L84_PLUG; dev_dbg(cs42l84->dev, "Plug event\n"); + /* Give the user time to fully seat the plug */ + msleep(1500); cs42l84_detect_hs(cs42l84); /* From 720992fc45143eda310a362379f2f35040de5152 Mon Sep 17 00:00:00 2001 From: James Calligeros Date: Sat, 28 Sep 2024 18:30:15 +1000 Subject: [PATCH 2/2] ASoC: cs42l84: halve headset detection delay Still works reliably. Makes up for some lost time due to new spurious connection handling. Signed-off-by: James Calligeros --- sound/soc/codecs/cs42l84.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/cs42l84.c b/sound/soc/codecs/cs42l84.c index 479cb392bb1736..c18b520eaf0c99 100644 --- a/sound/soc/codecs/cs42l84.c +++ b/sound/soc/codecs/cs42l84.c @@ -724,7 +724,7 @@ static void cs42l84_detect_hs(struct cs42l84_private *cs42l84) CS42L84_MISC_DET_CTL_PDN_MIC_LVL_DET, 0); /* TODO: Optimize */ - msleep(100); + msleep(50); /* Connect HSBIAS in CTIA wiring */ /* TODO: Should likely be subject of detection */ @@ -745,7 +745,7 @@ static void cs42l84_detect_hs(struct cs42l84_private *cs42l84) FIELD_PREP(CS42L84_MISC_DET_CTL_DETECT_MODE, 3)); /* TODO: Optimize */ - msleep(100); + msleep(50); regmap_read(cs42l84->regmap, CS42L84_HS_DET_STATUS2, ®); regmap_update_bits(cs42l84->regmap,