[Gta04-owner] Reliable headset detection with raw values

Dr. H. Nikolaus Schaller hns at goldelico.com
Mon May 19 07:03:07 CEST 2014


Hi,
that is great progress.

Am 18.05.2014 um 23:04 schrieb Paul Kocialkowski:

> In my previous email, commenting on the recent changes I brought to the
> Replicant 4.2 port, there was a part about headset detection done with
> better results.
> 
> Until this week-end, I was unsure whether this was just an improvement
> for my own device or was working on any device. I had the occasion to
> test on another unit, GNUtoo's GTA04A3, both with headphones (no mic)
> and a headset (mic) and button press. The results are pretty good and
> detection works flawlessly on both devices.
> 
> It's supposed to be reliable because each state has to be detected twice
> to be reported (headset/headphones detection) as well as button press
> (for instance, removing headphones seems like a button press, because
> the pin is shorted to ground for a short time).
> 
> The important change to make this work seems to be the use of raw values
> in the twl4030-madc convert code. I'm guessing that when this isn't
> used, the twl4030-madc tries to somehow adapt the value to have it
> matching the actual volts or something like this. I got the idea looking
> at the Galaxy Nexus's twl6030 madc code, which uses only raw values.
> 
> Using raw values, we get quite similar values on both devices and across
> reboots and at different points in time. For instance, here are some raw
> values (ranges)
> 
> My GTA04A4:
> * open: 19-21
> * headphones (no mic): 338
> * headset (mic): 177-185
> * headset button press: 334-335 (very stable)
> 
> GNUtoo's GTA04A3:
> * open: 9-11
> * headphones (no mic): 344
> * headset (mic): 170-176
> * headset button press: 348-353
> 
> Hence the values I took for the thresholds:
> * open/mic (headset): 50
> * mic (headset)/short (headphones/button): 300
> 
> The relevant commits from the Replicant GTA04 kernel[0] tree are the
> following, perhaps you want to consider adding them to the GNU/Linux
> kernel tree as well:
> 
> commit 6a93c9be394d42c085811b85cefa3284511533a4
> Author: Paul Kocialkowski <contact at paulk.fr>
> Date:   Sun May 11 11:51:36 2014 +0200
> 
>    gta04-audio: Wait for two consecutive button press values to report
> 
>    Signed-off-by: Paul Kocialkowski <contact at paulk.fr>
> 
> Mostly, this is because the 50ms polling time is short enough to report
> a button press when the headset is removed (for a short moment, the
> detection line is connected to ground before open circuit).
> 
> commit bdb7dbfe8039225429584f294233a909daedf69f
> Author: Paul Kocialkowski <contact at paulk.fr>
> Date:   Sun May 11 01:33:49 2014 +0200
> 
>    gta04-audio: Reliable headphones, headset and button press detection
> 
>    Signed-off-by: Paul Kocialkowski <contact at paulk.fr>
> 
> This only takes one button, though one can set more precise values for
> other buttons (volume control on a samsung headset provided reliably
> stable values, now that the twl4030-madc values are raw, so one could
> easily report these buttons too).
> 
> commit 12f9fdbbccadde55fb6d8441ac2f9744f16f0372
> Author: Paul Kocialkowski <contact at paulk.fr>
> Date:   Sun May 11 01:32:53 2014 +0200
> 
>    twl4030-madc: Return raw values from twl4030_get_madc_conversion
> 
>    Signed-off-by: Paul Kocialkowski <contact at paulk.fr>

For this last patch I have to add that it patches a driver not owned by us
and we don't know who else may rely on the fact that this function has raw=0.
So this way it can never be upstreamed because it may break the API.

But the solution is simple: copy&paste&rename the function twl4030_get_madc_conversion
into our sound/soc/omap/gta04-audio.c which is a driver we "own".

That way I think we could even apply your patches to the upstream kernel.

BR and thanks for finding out,
Nikolaus

> 
> [0]:
> https://gitorious.org/replicant/kernel_goldelico_gta04/source/6a93c9be394d42c085811b85cefa3284511533a4:
> 
> -- 
> Paul Kocialkowski, Replicant developer
> 
> Replicant is a fully free Android distribution
> 
> Website: http://www.replicant.us/
> Redmine: http://redmine.replicant.us/
> _______________________________________________
> Gta04-owner mailing list
> Gta04-owner at goldelico.com
> http://lists.goldelico.com/mailman/listinfo.cgi/gta04-owner



More information about the Gta04-owner mailing list