[Gta04-owner] Detecting headset plug: twl4030-madc IRQ issue

Dr. H. Nikolaus Schaller hns at goldelico.com
Tue May 1 18:14:58 CEST 2012

Am 29.04.2012 um 00:32 schrieb NeilBrown:

> On Sat, 28 Apr 2012 19:15:37 +0200 PaulK <paulk at paulk.fr> wrote:
>> I am now working on adding sound to Replicant. Dealing with the controls
>> seems very clear to me now, thanks to the docs on:
>> http://projects.goldelico.com/p/gta04-kernel/doc/
>> Currently, I am trying to get the twl4030-madc to report headset
>> plug/unplug. If I read correctly the docs, ADC7 is MICSENSE. 
>> Now the driver reports data through channels, so I guess what I'm
>> looking for is chan 7. 
>> A threaded IRQ is requested at probe and, if I got it correctly, is
>> supposed to call the twl4030_madc_threaded_irq_handler function when the
>> value of one ADC changes. Except that I didn't see that function getting
>> called when the headset is plugged or unplugged. I even tried removing
>> the battery (as it should report battery-related infos), it it didn't
>> get called either. 
>> Now there are a few confusing elements: there is a
>> twl4030_madc_enable_irq function that could lead me to think that it is
>> somehow disabled by default and the ADCs chip must somehow be told to
>> make use of the IRQ line. 
>> I have never dealt with IRQ interrupts before so I may be missing
>> something obvious here. Though, I would appreciate help discovering what
>> is actually going on and why this handler function never gets called.
> I might be missing something, but I don't think you can get an interrupt when
> the headset is plugged in.

Yes, there is no hardware provision for generating an interrupt.

> All that ADC7 allows if for polling - you can ask it to measure the voltage
> level and then it sends an interrupt when the voltage has been measured.
> Then you can read it and interpret it.
> The voltage is proportional to the current through R706.  To get current
> through this resistor you need to set HSMICBIAS_EN so that VHSMIC.OUT is
> driven.
> When nothing is plugged in this will drive 2.2V through a resistor network of 
>  R707 - 330
>  R706 - 33
>  R705 - 2K4
>  R703 - 330
> I assume they are all Kohms, so that is about 700Kohm so we get about 3.1
> microamps so ADC7 sees about 0.3volts (10uA/V).
> When 3-connector headset is plugged in, R703 is shorted, so the resistance
> becomes 365K and we get 6uA, or 0.6 Volts.

> When a 3-connector headset with a mic is plugged in ... I suspect we don't
> see any DC current, just an AC current from the mic, so maybe ADC7 will see
> 0V???
> In any case, it is possible to ask and find out what it connected, but I
> cannot see any way to get an interrupt when that changes.
> Is that right Nikolaus??

this is the basic idea. It is intended that one can connect a remote control
unit with several buttons and a resistor ladder. Similar to what the Sharp Zaurus
did have.


And, it is planned that it can detect headsets with and without microphones.

But this circuit has not yet been tested if it does anything useful in practice.
So if some volunteer wants to play with it... And make some proposals how
to modify this circuit for future GTA04 devices.

So how important is it for Replicant to work useful to detect the headset
being plugged in? Can there be a too to manually switch off the speakers?
This could be a workaround until we have tested and made the MADC working.

> NeilBrown


More information about the Gta04-owner mailing list