]> www.infradead.org Git - users/jedix/linux-maple.git/commit
ASoC: sun8i-codec: Implement jack and accessory detection
authorArnaud Ferraris <arnaud.ferraris@collabora.com>
Sat, 2 Mar 2024 14:00:38 +0000 (15:00 +0100)
committerMark Brown <broonie@kernel.org>
Mon, 25 Mar 2024 00:32:32 +0000 (00:32 +0000)
commit21fa98f4197bb3365dda1417708b318f403c13c1
treefe6f41fde8b55d97990b1515bbdd48f70a5e64bd
parentd5961e43b28668088087befbf4f7a043bd0ae65c
ASoC: sun8i-codec: Implement jack and accessory detection

Add support for the jack detection functionality in the A64 variant,
which uses a pair of IRQs; and microphone accessory (button) detection,
which uses an ADC with an IRQ trigger.

IRQs will only be triggered if the JACKDETEN, HMICBIASEN, and MICADCEN
bits are set appropriately in the analog codec component
(sun50i-codec-analog), but there is no direct software dependency
between the two components.

Setup ADC so that it samples with period of 16ms, disable smoothing
and enable MDATA threshold (should be below idle voltage/HMIC_DATA
value). Also enable HMIC_N, which makes sure we get HMIC_N samples
after HMIC_DATA crosses the threshold.

This allows us to perform steady state detection of HMIC_DATA, by
comparing current and previous ADC samples, to detect end of the
transient when the user de-presses the button. Otherwise ADC could
sample anywhere within the transient, and the driver may mis-issue
key-press events for other buttons attached to the resistor ladder.

[Ondrej: Almost complete rewrite of the patch, change to use set_jack
API. Better de-bounce, fix mic button handling, better interrupt
processing.]

Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>
[Samuel: Decouple from analog codec, fixes]
Co-developed-by: Samuel Holland <samuel@sholland.org>
Signed-off-by: Samuel Holland <samuel@sholland.org>
Co-developed-by: Ondrej Jirman <megi@xff.cz>
Signed-off-by: Ondrej Jirman <megi@xff.cz>
Link: https://msgid.link/r/20240302140042.1990256-5-megi@xff.cz
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sunxi/sun50i-codec-analog.c
sound/soc/sunxi/sun8i-codec.c