ASoC: es8316: Allow more time for headset mic bias to settle
Subsystems (3)
PATCH 1/1 ASoC: es8316: Allow more time for headset mic bias to settle
On the 3Logic Group Graviton N15i-K2, a TRRS headset is detected as headphones, leaving its microphone unavailable. The driver waits 20 ms after enabling microphone bias before reading GPIO_FLAG to distinguish a headset from headphones.
Register reads on this machine show that GM_NOT_SHORTED remains clear through 40 ms and becomes set at approximately 60 ms after enabling microphone bias. Reading the bit after only 20 ms therefore incorrectly identifies the headset microphone as shorted to ground.
Increase the settling delay to 100 ms to cover the observed settling time with some margin. This adds 80 ms to the microphone bias enable sequence used for jack detection.
--- sound/soc/codecs/es8316.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/es8316.c +1 -1
@@ -616,7 +616,7 @@ static void es8316_enable_micbias_for_mic_gnd_short_detect(snd_soc_dapm_sync_unlocked (dapm);snd_soc_dapm_mutex_unlock (dapm); -msleep (20 ); +msleep (100 ); } static void es8316_disable_micbias_for_mic_gnd_short_detect(
base-commit: b3dfbde62cf1981c4638939c159dfd087b7a72e9
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found no new issues in this patch, but noticed 1 related pre-existing issue it does not introduce: - [Medium] ASoC: es8316: uninitialized variable…
Thank you for your contribution! Sashiko AI review found no new issues in this patch, but noticed 1 related pre-existing issue it does not introduce:
- [Medium] ASoC: es8316: uninitialized variable read in es8316_irq() [1] --
commit 83fd03ee6536ad322b774377b945917b625ffca5
Author: Ilya Muhamadeev <[email protected]>
ASoC: es8316: Allow more time for headset mic bias to settle
This commit increases the settling delay in es8316_enable_micbias_for_mic_gnd_short_detect() from 20 ms to 100 ms so that ES8316_GPIO_FLAG_GM_NOT_SHORTED settles before jack detection reads ES8316_GPIO_FLAG.
sound/soc/codecs/es8316.c static void es8316_enable_micbias_for_mic_gnd_short_detect( · line 620
Quoted 11 lines
sound/soc/codecs/es8316.c +1
-1@@ -616,7 +616,7 @@ static void es8316_enable_micbias_for_mic_gnd_short_detect(snd_soc_dapm_sync_unlocked (dapm);snd_soc_dapm_mutex_unlock (dapm); -msleep (20 ); +msleep (100 ); }
[Severity: Medium]
This problem wasn't introduced by this patch, but can es8316_irq() evaluate an uninitialized flags variable [1] if regmap_read() fails?
sound/soc/codecs/es8316.c:es8316_irq() {
...
unsigned int flags;
guard(mutex)(&es8316->lock);
regmap_read(es8316->regmap, ES8316_GPIO_FLAG, &flags);
if (flags == 0x00)
return IRQ_HANDLED; /* Powered-down / reset */
...
} else if (!(es8316->jack->status & SND_JACK_HEADPHONE)) {
/* Jack inserted, determine type */
es8316_enable_micbias_for_mic_gnd_short_detect(comp);
regmap_read(es8316->regmap, ES8316_GPIO_FLAG, &flags);
if (es8316->jd_inverted)
flags ^= ES8316_GPIO_FLAG_HP_NOT_INSERTED;
...
}Neither regmap_read() call checks for errors. If an I2C read fails (or returns -EBUSY while the regcache is in cache-only mode during resume), es8316_irq() branches on indeterminate stack data, which can report bogus jack events to userspace or leave mic bias enabled in the wrong state.
[1] https://sashiko.dev/#/bug/linux-3f2856a8-3cfe-4dc1-bfa0-d15ea515aabd
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Mark Brown
maintainerQuoted 1 line · Ilya Muhamadeev
ASoC: es8316: Allow more time for headset mic bias to settle
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.5
Thanks!
[1/1] ASoC: es8316: Allow more time for headset mic bias to settle
https://git.kernel.org/broonie/sound/c/232ad4512a83
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