FORUMS

Milestone 2 keyboard double-pressing - fix!

58 posts
Thanks Meter: 15
 
By aithnea, Member on 1st May 2011, 08:21 AM
Post Reply Email Thread
18th May 2011, 12:12 PM |#41  
Senior Member
Flag Hong Kong
Thanks Meter: 17
 
More
Recently I spotted the same issue happening to my MS2 running A2S 1.8... but only occurs to the letter "o". Sometimes it is not responding, while sometimes it got doubled...
18th May 2011, 01:44 PM |#42  
agent008my's Avatar
Senior Member
Flag Belfast
Thanks Meter: 50
 
More
Quote:
Originally Posted by Liori

Recently I spotted the same issue happening to my MS2 running A2S 1.8... but only occurs to the letter "o". Sometimes it is not responding, while sometimes it got doubled...

is it possible that a software glitch or bug would cause different people from experiencing over or less sensitivity with different keys? should everybody be experiencing this issue with the same key if this is truly software related?
18th May 2011, 02:10 PM |#43  
Senior Member
Flag Recife
Thanks Meter: 46
 
More
Since Argen2Stone is based on stock ROM, it's not possible to be sure if it's a soft or hardware problem. I reseted my phone (some problems with the touchscreen, had to send it to warranty) and the problem still exists.
18th May 2011, 10:43 PM |#44  
Inactive Recognized Developer
Flag Fürth
Thanks Meter: 1,714
 
More
The double-pressing is definitely a software-bug, as motorola forgot to enable the generic android gpio debounce code in their keyboard-driver.

If you look at the kernel from Motorola (opensource.motorola.com/sf/projects/milestone) (Milestone-2 2.2.16), kernel.tar.gz, you will find the following code in arch/arm/mach-omap2/board-sholes-keypad.c:
Code:
static struct gpio_event_matrix_info sholes_keypad_matrix_info = {
        .info.func = gpio_event_matrix_func,
        .keymap = sholes_p3_keymap,
        .output_gpios = sholes_col_gpios,
        .input_gpios = sholes_row_gpios,
        .noutputs = ARRAY_SIZE(sholes_col_gpios),
        .ninputs = ARRAY_SIZE(sholes_row_gpios),
        .settle_time.tv.nsec = 40 * NSEC_PER_USEC,
        .poll_time.tv.nsec = 20 * NSEC_PER_MSEC,
        .flags = GPIOKPF_LEVEL_TRIGGERED_IRQ | GPIOKPF_REMOVE_PHANTOM_KEYS |
                 GPIOKPF_PRINT_UNMAPPED_KEYS /*| GPIOKPF_PRINT_MAPPED_KEYS*/
};
But the header defining this struct (include/linux/gpio_event.h) adds another very interesting member:
Code:
struct gpio_event_matrix_info {
        ...
        ktime_t debounce_delay;
        ...
};
This debounce_delay is 0 as it is never initialized, and so the debouncing code in drivers/input/misc/gpio_matrix.c does nothing. The easy fix for this problem would be to recompile the kernel and set this member to the value used in other android handsets (5ms). But "thanks" to the locked bootloader this is impossible.
So the only solution to this is an ugly hack, which searches for the structure in memory and sets debounce_delay to an useful value. I have written a kernel-module which does just that, you can finde the code at: git.zerfleddert.de/cgi-bin/gitweb.cgi/ms2-fixes
As I assume not everybody wants to go through the pain of setting up a toolchain which can be used to compile modules for the motorola kernel, I have also put up a precompiled version of the module at rmdir.de/~michael/ms2-fixes/debounce.ko

This version should work at least on MS2 2.2.16 and MS2 2.4.24 (which I am using), as I have built it against the 2.2.16 kernel sources (which are the only ones I can find...)

To use this module, you need a rooted phone. Copy the module to /tmp and run "insmod /tmp/debounce.ko".
After that, you should see the following output in "dmesg":
Code:
<6>[ 1226.493377] Searching for gpio-event...
<6>[ 1226.493804] Found it!
<6>[ 1226.494079] And there is a sholes-keypad connected...
<6>[ 1226.494842] settle_time: 40000
<6>[ 1226.495117] poll_time: 20000000
<6>[ 1226.495391] debounce_delay: 0
<6>[ 1226.495635] Activating debounce!
<6>[ 1226.496917] debounce_delay: 5000000
Please test this module and see if it fixes your keyboard problems. (I have only slight double presses, which are not really reproducible (but I had none since activating the debouncing)). I would be happy to hear that it works for other people, too.

Thanks Motorola for making our lives so easy with a locked bootloader!

Michael

P.S. sorry for the non-clickable-links, but I am not allowed to post outside links...
The Following 10 Users Say Thank You to stargo For This Useful Post: [ View ] Gift stargo Ad-Free
19th May 2011, 12:42 AM |#45  
dangpzanco's Avatar
Senior Member
Thanks Meter: 86
 
More
Quote:
Originally Posted by stargo

This version should work at least on MS2 2.2.16 and MS2 2.4.24 (which I am using), as I have built it against the 2.2.16 kernel sources (which are the only ones I can find...)

Milestone 2 Latam is Version 3.12.0 : here

And your Links:

Precompiled

Project

-----------------------------------------------------------------------------------------------------------------------------------------

By the way, since you seem to have some experience with kernels, do you think it's possible for you to create a kexec module for M2? It is a bypass solution for locked bootloader.
19th May 2011, 07:22 AM |#46  
RDUKE7777777's Avatar
Member
Flag Koblenz
Thanks Meter: 7
 
More
I knew it was a debouncing error, but i couldnt imagine Moto would make such a noob mistake...

Sent from my Motorola Milestone 2 using Tapatalk
19th May 2011, 04:27 PM |#47  
Senior Member
Flag Sao Paulo
Thanks Meter: 40
 
More
would this work for the Latam? I'm also using a Brazilian Milestone...
19th May 2011, 05:36 PM |#48  
Inactive Recognized Developer
Flag Fürth
Thanks Meter: 1,714
 
More
Quote:
Originally Posted by dangpzanco

Milestone 2 Latam is Version 3.12.0 : here

And your Links:

Precompiled

Project

-----------------------------------------------------------------------------------------------------------------------------------------

By the way, since you seem to have some experience with kernels, do you think it's possible for you to create a kexec module for M2? It is a bypass solution for locked bootloader.

Thanks for posting the links :)

Regarding kexec, I don't think that I have the time to work on it, sorry :(

Quote:
Originally Posted by AdrienC

would this work for the Latam? I'm also using a Brazilian Milestone...

I just downloaded the kernel sources dangpzanco linked to and they are (nearly) identical to the 2.2.16 sources I used (only missing changelog and gitignore-files). So the module should work on the LATAM version.

I've also updated the module to make sure the debounce-flag is set, but this should already be done by the motorola code. (Which makes the uninitialized debounce_delay even worse, as it causes an immediate rescan of the keyboard matrix when the keystate changes, which is exactly what leads to bouncing.)

Just as a heads-up: I've got no bounced keys since I loaded the module yesterday :)
19th May 2011, 06:43 PM |#49  
Member
Thanks Meter: 2
 
More
Thanks first!

however, i can use some tutorial. I have a terminal emulator. but everytime i try to insmod, it turned out to be "access denied". I have rooted my device.

Thanks again.
19th May 2011, 06:49 PM |#50  
dangpzanco's Avatar
Senior Member
Thanks Meter: 86
 
More
Quote:
Originally Posted by chris0202

Thanks first!

however, i can use some tutorial. I have a terminal emulator. but everytime i try to insmod, it turned out to be "access denied". I have rooted my device.

Thanks again.

First execute "su" command to enter root.

Sent from my Milestone 2 XDA App
19th May 2011, 07:07 PM |#51  
Inactive Recognized Developer
Flag Fürth
Thanks Meter: 1,714
 
More
Another problem could be too restrictive permissions on debounce.ko, like when copied from the sdcard. Just a short walkthrough, assuming you have debounce.ko in the root of your sdcard:

Code:
$ su
# cp /sdcard/debounce.ko /tmp/
# chmod 644 /tmp/debounce.ko
# insmod /tmp/debounce.ko
When insmod returns without an error, try:
Code:
# dmesg
This should produce info from the debounce-module in the last few lines (starting with Searching for gpio-event)

@dangpzanco: I lied ;) I just tried to compile kexec_mod, but it seems I have toolchain-problems for this module. I'll try to do it on a native ARM system (beagleboard, so no cross-compilation) on the weekend. (If I find the time...)
The Following 4 Users Say Thank You to stargo For This Useful Post: [ View ] Gift stargo Ad-Free
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes