From a3cf88acf076d2d87fe6356697920ebde2046af4 Mon Sep 17 00:00:00 2001 From: Michael Gernoth Date: Thu, 19 May 2011 00:01:45 +0200 Subject: [PATCH] add README (based on xda post) --- README | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 README diff --git a/README b/README new file mode 100644 index 0000000..727ef56 --- /dev/null +++ b/README @@ -0,0 +1,76 @@ +The double-pressing plaguing the Motorola Milestone 2 is a software-bug, as +Motorola forgot to enable the generic android gpio debounce code in their +keyboard-driver. + +When looking at the Motorola Milestone 2 kernel, which is available at +https://opensource.motorola.com/sf/projects/milestone (Milestone-2 2.2.16, +kernel.tar.gz), the following code can be found in the file +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*/ +}; +[/CODE] + +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; + ... +}; +[/CODE] + +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. It's code can be found at: +http://git.zerfleddert.de/cgi-bin/gitweb.cgi/ms2-fixes +(And this is its README file) + +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 uploaded a precompiled version of the module at +http://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 +[/CODE] + +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 Gernoth -- 2.39.2