[HTC Sensation] loliman:
Hi there,

as I mentioned in different threads, I noticed, that it is not possible to change the volume of your device via headphones (in my case Beats Tour with ControlTalk). I did some research about it and found, that Apple has got a patent on this procedure, so it is not possible to implement this in Android devices.

As is did some further research I found the basics, how it is working. As far as I understood the volume control is possible because of different resistors (three) in the cable. Each of this resistor is bound to one button (vol+/play-pause/vol-). If you press one button, the amperage is reduced because of the resistor. Now the only thing that has to be done is to interpret this amperage and decide which button was pressed. I was wondering why exactly the Android devices are not able to recognize the clicks on vol+/-. I did some research and testing again and found out, that "Headset Droid" does not even recognize, that the button were pressed, "Headset monitor" does not show any event. The funny thing is, that, if I press vol+ and vol- together, the click IS recognized, but the device interprets it as a click on the play-pause button. With this I would say, it is not a

hardware issue, it should be software, kernel, related.

I looked into the latest XE kernel (pyramidLE-crc-2.6.35) and searched for different keywords, but can’t find the exact files, where the headset control is configured (there must be any files, cause htc headphones are working like a charm with previous/play-pause/next). I've got two ideas how this could work.

Add some code to recognize the button-presses and interpret them correctly. That would be the elegant, clean way.

Another idea is, that we could get every headphone treated like htc headphones (vol+ would be next track, vol- last track). There is an app to change the htc previous/next buttons to work like vol+/- so that would be enough. That would be the "easy" way, but more dirty.

Some more information: I did not change anything in the kernel and never compiled the kernel, so I can’t say, if I'm on the right track.

Here is what I found in the kernelfiles so far:

\arch\arm\mach-msm //it seems, that there are some amperages are configured here, but it does not seem to be the right ones...

/* HTC OTHC Driver - BEGIN */
[...]
static struct hsed_bias_config htc_headset_othc_bias_config = {
.othc_headset = OTHC_HEADSET_NO,
.othc_lowcurr_thresh_uA = 100,
.othc_highcurr_thresh_uA = 500,
.othc_hyst_prediv_us = 3000,
.othc_period_clkdiv_us = 3000,
.othc_hyst_clk_us = 45000,
.othc_period_clk_us = 6000,
.othc_wakeup = 1,
};
[...]

\arch\arm\mach-msm\htc_headset_mgr.c //here’s the headsetmanager, the type of headphone seems to be set here

[...]
switch (hi->hs_35mm_type) {
case HEADSET_UNPLUG:
state = "headset_unplug";
break;
case HEADSET_NO_MIC:
state = "headset_no_mic";
break;
case HEADSET_MIC:
state = "headset_mic";
break;
case HEADSET_METRICO:
state = "headset_metrico";
break;
case HEADSET_UNKNOWN_MIC:
state = "headset_unknown_mic";
break;
case HEADSET_TV_OUT:
state = "headset_tv_out";
break;
case HEADSET_UNSTABLE:
state = "headset_unstable";
break;
case HEADSET_BEATS:
state = "headset_beats";
break;
case HEADSET_BEATS_SOLO:
state = "headset_beats_solo";
break;
case HEADSET_INDICATOR:
state = "headset_indicator";
break;
default:
state = "error_state";
}
[...]

As I never worked in kernel before (I am experienced in C) I don’t know whether I'm doing it wrong or not. Some help and any suggestions would be helpful, perhaps we can get this working.

I hope you understand my thoughts and problems, it's hard to express them in german and it's even harder in englisch :D

Kind regards,