ASoC: rt5651: Rewrite jack-type detection
authorHans de Goede <hdegoede@redhat.com>
Sun, 4 Mar 2018 14:35:57 +0000 (15:35 +0100)
committerMark Brown <broonie@kernel.org>
Wed, 7 Mar 2018 12:55:29 +0000 (12:55 +0000)
commitee68096826fa16bca2f7bb555b3e0cbbe798d330
tree36a661694a93a3dc13e3c98cbd4e66e3252ba7f2
parent0fe9474598890b4bd8a7228c9b1872ed7fe3c2c5
ASoC: rt5651: Rewrite jack-type detection

We get the insertion event before the jack is fully inserted at which point
the second ring on a TRRS connector may short the 2nd ring and sleeve
contacts. Testing has shown that this short-circuit may happen as late
as 500ms after the insertion event, but it never lasts longer then 300ms.

This commit changes the detection algorithm to require 5 identical OVCD
values in a row at 100 ms intervals to fix the jack-type sometimes getting
mis-detected.

Tested-by: Carlo Caione <carlo@endlessm.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/rt5651.c
sound/soc/codecs/rt5651.h