[PATCH] Hardware keyboard dropped key press fix (10/19/11, GB support)

Search This thread

mkasick

Retired Recognized Developer
Aug 10, 2009
470
830
10/19/11 Update: Added patches for the recently released GB sources to keyboard_patches-GB.tar.gz.

7/9/11 Update: New patch to export the "column-switch delay", which allows for much decreased CPU utilization/much better efficiency. See below for details.

3/23/11 Update: Add alternate "timer delay" patch to enable runtime configuration of keypad_timer delay. See below for details.

Attached is a kernel source patch that fixes the EB13 hardware keyboard dropped/skipped key press problem, at least for twice-pressed keys. It restores DI18-level responsiveness for the hardware keyboard.

I know dropped keypresses on the hardware keyboard has been a problem for a long time, even with DI18. There are likely multiple factors at play here, and this patch only corrects one of them. However, DK28/EB13 are particularly bad at dropping twice-pressed keys, and hopefully this patch alleviates this issue for most folks who experience it.

Bug details:

Sesquipedalian points out in one of the General threads concerning the issue that EB13 often drops twice-pressed letters on the hardware keyboard. For example, if one types "hello", often "helo" is emitted.

Yesterday I performed some timing tests and discovered that the EB13 keyboard driver delays 1/10th of a second (100 ms) between reporting "key_press" & "key_release" events. Unfortunately this delay is on the order of human muscle response, and when folks press the same letter twice in that 100 ms, the kernel will only be able to acknowledge one of the presses.

Keyboard driver background:

The Epic's keyboard driver is located at drivers/input/keyboard/victory/s3c-keypad.c in the EB13 kernel sources.

On initialization, the driver establishes an interrupt handler (s3c_keypad_isr) for keyboard ("keypad") events, which is executed whenever the kernel is interrupted with a key press. During an interrupt, the handler starts a timer (keypad_timer) to expire after "3 * HZ/100" jiffies (27 ms), and clears the interrupt request. The driver actually figures out which key was pressed/released in a separate routine that executes after the timer expires. Also, the interrupt is not immediately reenabled, so if a second keyboard event (either a key press or release) comes in before the timer expires, nothing additional happens.

When keypad_timer expires, the keypad_timer_handler function is invoked. This routine scans through each of the six "columns" (which roughly corresponds to the rows) of the keyboard looking for key presses & releases. In doing so, the driver delays 0.3 ms to ensure each column switch is accepted by the hardware, so the enitre routine should take rougly 1.8 ms to execute. This is actually quite a long time (but not inappropriately so) relative to the clockspeed of the processor, which is partly why the scanning is done outside the keyboard interrupt where operations "that take a while" are discouraged. So this isn't a bad setup, even if it might appear a bit unusual at first.

The end of the scanning routine (keypad_timer_handler) checks to see if any keys are currently held down, and if so it restarts keypad_timer. It must do this, becuase if a key is pressed & released "quickly", before the timer actually expires, then a release interrupt would never be generated (even if the interrupt was immediately reenabled). Hence, if a key is pressed & released "quickly", it is detected by the scanning routine after the second timer expiration. It's likely that the keybord only generates an interrupt on key press, so the timer is necessary to detect key releases. While a key is held down, the scanning routine keeps resetting the timer. Once a key release is detected, the timer is deactivated and the interrupt reenabled.

The bug:

Now, the problem is that keypad_timer, when restarted by the scanning routine, is set to expire after "HZ/10" jiffies (98 ms). This is an unusually long waiting time--four times as long as the original timer. If the same key is pressed twice in this interval, the scanning routine will pick it up only as a single press/release pair. If multiple, different keys are pressed in this interval, I believe the scanning routine will pick all of them up, but not necessarilly in the right order.

So the fix is to change the keypad_timer's restart expiration time to something more reasonable, like the 27 ms used by the interrupt handler. This decreases the waiting time to one in which it's unlikely that someone will be able to press multiple, or repeatedly press a key. As it turns out, that's exactly what DI18 does, so we know it works. It's totally unclear why Samsung changed it.

Oh well.

Edit: Originally I thought keys were latched, so press events would be detected by the scanning routine even if the key is released before keypad_timer expires. They're most certainly not though, the scanning routine likely polls the instantenous key (up or down) state, so a key press must be held for at least 27 ms so that the scanning may complete after the interrupt is serviced. If a key is held shorter than this, it will not be detected.

3/23/11: Alternate "timer delay" patch:

Also attached is an alternate patch that supercedes the original. It allows for runtime configuration of the keypad_timer delay via a sysfs exported timer_delay variable.

The current delay may be read with:
Code:
cat /sys/devices/platform/s3c-keypad/timer_delay
and a new delay may be set with:
Code:
echo N > /sys/devices/platform/s3c-keypad/timer_delay
where N is the delay in jiffies.

A delay of "1" yields the shortest timer, and the most responsive keypad possible, whereas a delay of "256" (1 second) (in most kernels) is the longest allowed. At that point the keyboard is already useless since any keypress results in either repeated characters or the "alternate character popup".

In most kernels (where HZ=256), the default delay is "7" (27 ms), which is the same as the original patch and DI18. A delay of "16" (63 ms) approximates the behavior of stock EB13/EC05.

Basically, the delay is the minimum amount of time one must hold a key down for a keypress to register. It's also the maxmimum time the kernel believes a key is "held down" after it's let go. For example, with a delay of "7" one must hold a key down for 27 ms to register as pressed, and no-more-than 55 ms later does the key register as being released.

Or for a better example, with a delay of "128" one must hold a key down for half a second, and once registered, the key is "held down" for an additional half a second. Which almost guarantees an application-level repeated keypress or the alternate character popup.

Ideally one would start with a delay of "7" and reduce by one until the timer is fast enough for your typing rate that you no longer have dropped keypresses. Although many folks will find that a delay of "7" is fast enough for them.

7/9/11: New "column-switch delay" patch:

Attached are two (mutually exclusive) patches to export the "column-switch delay" (column_delay) in addition to the timer_delay variable. The first applies against stock EC05 and supercedes all previous patches. The second (alt patch) applies against stock EC05 with the previous timer_delay patch already applied and should be used for custom kernels already containing that patch.

The column-switch delay is the amount of time, in µs, that the driver delays while switching between the six keyboard "columns" (actually rows) in the keyboard scaning routine. A delay is necessary to ensure that the column switch has been performed by the hardware before scanning a new column, otherwise ghost keypresses result.

However, the 300 µs delay specified by Samsung is very inefficient, particularly for "reasonable" timer_delay values. With theimpaler747's suggested timer_delay of 5, the keyboard driver, while holding a key down, consumes 9.7% of CPU time (empirically tested), at any clock rate. This is quite-likely responsible for folks' previous complaints that use of the hardware keyboard causes audio skips, poor game performance, decreased battery life, etc.

This patch allows this (default) 300 µs delay value to be modified through a sysfs exported column_delay variable. Similar to the timer_delay, it may be read with:
Code:
cat /sys/devices/platform/s3c-keypad/column_delay
and a new delay may be set with:
Code:
echo N > /sys/devices/platform/s3c-keypad/column_delay
where N is the delay in µs.

A delay of "1" is the most efficient (only 0.02% CPU utilization) but results in ghost key presses. In testing, I've found ghosting to disappear at delays of "3" and above. To provide some buffer, I've been using (and recommend) a delay of "5" for both column_delay and timer_delay values for the past week, and I've not run into any issues.

At a delay of "5", the keyboard driver is far more efficient, consuming only 0.2% of CPU time while keys are held. This hopefully translates into less stuttering/performance problems and better battery life.

Testing on other devices is needed (and appreciated!) to find a reasonable delay where ghosting doesn't appear, assuming that "5" is too low on some devices. Even delays of "10" and "50" (comparable to other keyboard drivers) result in ~0.3% and 1.7% CPU utilization respectively, which is much better than the Samsung default.

Mirror links:
GB kernel patches: keyboard_patches-GB.tar.gz
Column-switch & timer delay patch: epic_keypad_delays-EC05.diff (for stock EC05)
Column-switch & timer delay patch: epic_keypad_delays_alt-EC05.diff (for kernels with timer delay patch already applied)

Historical links:
Timer delay patch: epic_keypad_timer_delay-EB13.diff
Original patch: epic_keypad_timer_fix-EB13.diff
 

Attachments

  • epic_keypad_delays-EC05.diff.txt
    5.3 KB · Views: 59
  • epic_keypad_delays_alt-EC05.diff.txt
    6 KB · Views: 63
  • epic_keypad_timer_delay-EB13.diff.txt
    3.9 KB · Views: 16
  • epic_keypad_timer_fix-EB13.diff.txt
    452 bytes · Views: 21
  • keyboard_patches-GB.tar
    3.8 KB · Views: 47
Last edited:

biscojams

Senior Member
Oct 1, 2010
117
6
Wow , nice work! I wish we had people as smart as you working @ Samsung or Sprint.

Sent from my SPH-D700 using XDA App
 

BeerChameleon

Senior Member
Aug 21, 2008
16,212
1,174
Tucson,Arizona.
Nice WORK!!!

Since you have this fix, this will definetly improve it a little, now u just need to find a fix to fix all missed letters. :D

Great Job, cant wait for an updated kernal with this in it.

Our poor developers on here work so hard to clean up manufactures phones issues and bugs and do an amazing job. They should fire everyone at samsung and hire all the devlopers here. :D lol
 

TheDub

Retired Recognized Developer
Feb 28, 2010
532
147
Well... downloaded Genocides kernel, was able to compile it after getting the toolchain and everything. Worked great. Loaded it on my zip, flashed it..

Kernel doesn't boot and suddenly my SD card is unreadable.. LOL! Guess I'll leave it to the pro's as I try to recover some data off my SD card...

Tried Genocides kernel flash zip, still didn't work, dang.
 

biscojams

Senior Member
Oct 1, 2010
117
6
Lol , sorry I dont know why that is funny to me. Hope you get it working!

Sent from my SPH-D700 using XDA App
 

Top Nurse

Senior Member
Sep 20, 2010
1,077
62
Palm Bay, FL
This fix seems to be worse as the special key popup is even more noticeable than before. Perhaps a change in timing would be better. Maybe Samsung changed this in response to complaints of the popup coming up when unwanted.

Sent from Bonsai 6.0.3
 

MeetFace

Senior Member
Dec 31, 2010
2,196
525
Nice work!

Building Genocide with this patch applied for all interested testers...

Rodderick will need to be the one to officially include it in HIS! :) Kernel but now we all have something we can test... will post link when it's done compiling.

Rodderik is already all over it broham. =]
 

Rodderik

Inactive Recognized Developer
Sep 8, 2010
1,300
1,295
devphone.org
Well... downloaded Genocides kernel, was able to compile it after getting the toolchain and everything. Worked great. Loaded it on my zip, flashed it..

Kernel doesn't boot and suddenly my SD card is unreadable.. LOL! Guess I'll leave it to the pro's as I try to recover some data off my SD card...

Tried Genocides kernel flash zip, still didn't work, dang.

thats my bad your sdcard got nuked it has to do with the i9000 having and internal and external sdcard storage...for now use my modified initramfs and not the new ported one on my git (says not to use i9000 initramfs in README on github)

mkasick thx for the info and i will put it in the kernel immediately and test
 
Last edited:

mkasick

Retired Recognized Developer
Aug 10, 2009
470
830
This fix seems to be worse as the special key popup is even more noticeable than before.
I've seen mention of this before, but I'm not particularly familiar with the issue.

When the does the special key popup happen (besides long-pressing a letter)? Can you give an example that would somewhat-reliably recreate the problem?
 

Rodderik

Inactive Recognized Developer
Sep 8, 2010
1,300
1,295
devphone.org
mkasick the patch works beautifully! one note you might want to mention is any kernel developers that attempt to change the Kconfig or CONFIG_HZ=256 (it is set to 256 here but the Kconfig sets it to 1000 anyway) then that will throw this timer off (patched or not)

i think samsung missed the CONFIG_HZ=256 being used in the Kconfig...if we used the config's value in original settings (256/10) then that would give us 25.6 where as your patch is giving us 30 (3*1000/100)...i may fix this later but using your diff patch for now...thanks again
 
  • Like
Reactions: mattallica76

Top Nurse

Senior Member
Sep 20, 2010
1,077
62
Palm Bay, FL
I've seen mention of this before, but I'm not particularly familiar with the issue.

When the does the special key popup happen (besides long-pressing a letter)? Can you give an example that would somewhat-reliably recreate the problem?

Typing two letters quickly brings up the popup. Also the arrow keys act somewhat funny.



Sent from Bonsai 6.0.3
 
Last edited:

TheDub

Retired Recognized Developer
Feb 28, 2010
532
147
I hate to be "THAT" guy but..

If you press and old A for about a second you get that popup everyone is referring to.

Now if we are decreasing that timer unintentionally with this patch it could produce it popping up all the dang time on accident.

It was a known issue in DI18 I believe, that it would come up to frequently, Samsung probably fixed it by increasing that timer..

On genocide .3a and my rom I can't produce the hello bug reliably, the missed keys seem completely random and happen very very rarely with Swype gone.

Just a thought.

Originally Posted by TheDub View Post

Nice work!

Building Genocide with this patch applied for all interested testers...

Rodderick will need to be the one to officially include it in HIS! Kernel but now we all have something we can test... will post link when it's done compiling.

Rodderik is already all over it broham. =]

Nice to see, mine was a horrible fail anyways lol! but hey I was bored and you can't hurt anything by trying :D
 

BeerChameleon

Senior Member
Aug 21, 2008
16,212
1,174
Tucson,Arizona.
I hate to be "THAT" guy but..

If you press and old A for about a second you get that popup everyone is referring to.

Now if we are decreasing that timer unintentionally with this patch it could produce it popping up all the dang time on accident.

It was a known issue in DI18 I believe, that it would come up to frequently, Samsung probably fixed it by increasing that timer..


On genocide .3a and my rom I can't produce the hello bug reliably, the missed keys seem completely random and happen very very rarely with Swype gone.

Just a thought.



Nice to see, mine was a horrible fail anyways lol! but hey I was bored and you can't hurt anything by trying :D

i never new that would pop up til u just told me, i guess i dont type multiple "A's" often..
 

mkasick

Retired Recognized Developer
Aug 10, 2009
470
830
Now fix the QAOL bug :p
I wasn't sure what this was. Then I saw this post which describes it. Amusing.

Sadly I don't think it's an easy fix. This bug is known as ghosting, and it's due to the way the keyboard matrix works. If you simultaneously press keys in two different rows ("columns" in driver-speak), e.g., Q & A, pressing L is ambiguous. The hardware, since it lacks diodes, can't differentiate between L & O. Basically, if multiple buttons are pressed simultaneously all bets are off.

If this was a serious issue, as in folks were seeing spurious keypresses when not intentionally trying to perturb the hardware, we could fix it by modifying the keyboard driver to just ignore all press events when multiple columns have non-zero key masks. Basically this would result in simultaneous key presses not registering, whether they're in conflict or not.

one note you might want to mention is any kernel developers that attempt to change the Kconfig or CONFIG_HZ=256 ... then that will throw this timer off (patched or not)
I don't think it should. Keep in mind that jiffies (the unit timers use) are defined in terms of CONFIG_HZ anyways. Specifically, HZ=CONFIG_HZ (in kernel space), and time_in_seconds = time_in_jiffies/HZ.

So a delay of (3*HZ/100) is nominally 30 ms regardless of HZ. It only deviates because it's integer division, so while (3*1000/100) = 30 ms, (3*256/100) is 23 27 ms (edit: foolish math! multiply before divide). For the most part, it shouldn't matter too much.

(it is set to 256 here but the Kconfig sets it to 1000 anyway) then that will throw this timer off (patched or not)
Wait what? CONFIG_HZ is 256 in both my .config and autoconf.h. Is there some bug I'm not aware of that resets it to 1000, or are you using 1000 in your config?

i think samsung missed the CONFIG_HZ=256 being used in the Kconfig...
I think they used CONFIG_HZ=200 in DI18, and it was changed to 256 for Froyo. The Linux default (on i386 anways) is 250 IIRC. I'm not sure why Samsung bothered to change it, maybe it's a upstream thing. But 200 vs 250 vs 256 is somewhat arbitrary anyways.

Typing two letters quickly brings up the popup. Also the arrow keys act somewhat funny.
Hmm, I tried to induce both of these but I can't seem to. Any other thoughts on it?
 
Last edited:

TheDub

Retired Recognized Developer
Feb 28, 2010
532
147
i never new that would pop up til u just told me, i guess i dont type multiple "A's" often..

Please don't take my first comments as criticism of any kind! Just discussing the topic at hand :)

I don't type multiple A's either but when changing that timer to be much shorter does that make the time required to hold down A to produce that pop up shorter as well?

I saw a few people report that it makes it more noticeable (accidental pop ups).
 

mkasick

Retired Recognized Developer
Aug 10, 2009
470
830
Now if we are decreasing that timer unintentionally with this patch it could produce it popping up all the dang time on accident.
Ah, no, different timer. Changing the duration of keypad_timer merely changes how often the kernel keyboard driver checks to see if a key has been released. But if you hold a key down for 5 seconds, the kernel won't report a key_release event until 5 seconds after the key_press event. In the interim, other stuff might be happening like the "special character popup", or a key-repeat timer--but those are IME/app level and not controlled by the kernel.

If anything, this patch should strictly help. Say the "special character popup" happens after holding down a key for 0.5 seconds (it's about this). Previously, if you held a key down for 0.43 s, the release might not be detected until after 0.5 s and the popup would happen. Now, if you hold a key down for 0.43 s, the release would be detected no later than 0.46 s, and the popup won't show.

Think of it this way: a shorter keypad_timer results in more accurate key event timing, but (somewhat negligibly) increases CPU load due to having to run the scan routine more often.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 24
    10/19/11 Update: Added patches for the recently released GB sources to keyboard_patches-GB.tar.gz.

    7/9/11 Update: New patch to export the "column-switch delay", which allows for much decreased CPU utilization/much better efficiency. See below for details.

    3/23/11 Update: Add alternate "timer delay" patch to enable runtime configuration of keypad_timer delay. See below for details.

    Attached is a kernel source patch that fixes the EB13 hardware keyboard dropped/skipped key press problem, at least for twice-pressed keys. It restores DI18-level responsiveness for the hardware keyboard.

    I know dropped keypresses on the hardware keyboard has been a problem for a long time, even with DI18. There are likely multiple factors at play here, and this patch only corrects one of them. However, DK28/EB13 are particularly bad at dropping twice-pressed keys, and hopefully this patch alleviates this issue for most folks who experience it.

    Bug details:

    Sesquipedalian points out in one of the General threads concerning the issue that EB13 often drops twice-pressed letters on the hardware keyboard. For example, if one types "hello", often "helo" is emitted.

    Yesterday I performed some timing tests and discovered that the EB13 keyboard driver delays 1/10th of a second (100 ms) between reporting "key_press" & "key_release" events. Unfortunately this delay is on the order of human muscle response, and when folks press the same letter twice in that 100 ms, the kernel will only be able to acknowledge one of the presses.

    Keyboard driver background:

    The Epic's keyboard driver is located at drivers/input/keyboard/victory/s3c-keypad.c in the EB13 kernel sources.

    On initialization, the driver establishes an interrupt handler (s3c_keypad_isr) for keyboard ("keypad") events, which is executed whenever the kernel is interrupted with a key press. During an interrupt, the handler starts a timer (keypad_timer) to expire after "3 * HZ/100" jiffies (27 ms), and clears the interrupt request. The driver actually figures out which key was pressed/released in a separate routine that executes after the timer expires. Also, the interrupt is not immediately reenabled, so if a second keyboard event (either a key press or release) comes in before the timer expires, nothing additional happens.

    When keypad_timer expires, the keypad_timer_handler function is invoked. This routine scans through each of the six "columns" (which roughly corresponds to the rows) of the keyboard looking for key presses & releases. In doing so, the driver delays 0.3 ms to ensure each column switch is accepted by the hardware, so the enitre routine should take rougly 1.8 ms to execute. This is actually quite a long time (but not inappropriately so) relative to the clockspeed of the processor, which is partly why the scanning is done outside the keyboard interrupt where operations "that take a while" are discouraged. So this isn't a bad setup, even if it might appear a bit unusual at first.

    The end of the scanning routine (keypad_timer_handler) checks to see if any keys are currently held down, and if so it restarts keypad_timer. It must do this, becuase if a key is pressed & released "quickly", before the timer actually expires, then a release interrupt would never be generated (even if the interrupt was immediately reenabled). Hence, if a key is pressed & released "quickly", it is detected by the scanning routine after the second timer expiration. It's likely that the keybord only generates an interrupt on key press, so the timer is necessary to detect key releases. While a key is held down, the scanning routine keeps resetting the timer. Once a key release is detected, the timer is deactivated and the interrupt reenabled.

    The bug:

    Now, the problem is that keypad_timer, when restarted by the scanning routine, is set to expire after "HZ/10" jiffies (98 ms). This is an unusually long waiting time--four times as long as the original timer. If the same key is pressed twice in this interval, the scanning routine will pick it up only as a single press/release pair. If multiple, different keys are pressed in this interval, I believe the scanning routine will pick all of them up, but not necessarilly in the right order.

    So the fix is to change the keypad_timer's restart expiration time to something more reasonable, like the 27 ms used by the interrupt handler. This decreases the waiting time to one in which it's unlikely that someone will be able to press multiple, or repeatedly press a key. As it turns out, that's exactly what DI18 does, so we know it works. It's totally unclear why Samsung changed it.

    Oh well.

    Edit: Originally I thought keys were latched, so press events would be detected by the scanning routine even if the key is released before keypad_timer expires. They're most certainly not though, the scanning routine likely polls the instantenous key (up or down) state, so a key press must be held for at least 27 ms so that the scanning may complete after the interrupt is serviced. If a key is held shorter than this, it will not be detected.

    3/23/11: Alternate "timer delay" patch:

    Also attached is an alternate patch that supercedes the original. It allows for runtime configuration of the keypad_timer delay via a sysfs exported timer_delay variable.

    The current delay may be read with:
    Code:
    cat /sys/devices/platform/s3c-keypad/timer_delay
    and a new delay may be set with:
    Code:
    echo N > /sys/devices/platform/s3c-keypad/timer_delay
    where N is the delay in jiffies.

    A delay of "1" yields the shortest timer, and the most responsive keypad possible, whereas a delay of "256" (1 second) (in most kernels) is the longest allowed. At that point the keyboard is already useless since any keypress results in either repeated characters or the "alternate character popup".

    In most kernels (where HZ=256), the default delay is "7" (27 ms), which is the same as the original patch and DI18. A delay of "16" (63 ms) approximates the behavior of stock EB13/EC05.

    Basically, the delay is the minimum amount of time one must hold a key down for a keypress to register. It's also the maxmimum time the kernel believes a key is "held down" after it's let go. For example, with a delay of "7" one must hold a key down for 27 ms to register as pressed, and no-more-than 55 ms later does the key register as being released.

    Or for a better example, with a delay of "128" one must hold a key down for half a second, and once registered, the key is "held down" for an additional half a second. Which almost guarantees an application-level repeated keypress or the alternate character popup.

    Ideally one would start with a delay of "7" and reduce by one until the timer is fast enough for your typing rate that you no longer have dropped keypresses. Although many folks will find that a delay of "7" is fast enough for them.

    7/9/11: New "column-switch delay" patch:

    Attached are two (mutually exclusive) patches to export the "column-switch delay" (column_delay) in addition to the timer_delay variable. The first applies against stock EC05 and supercedes all previous patches. The second (alt patch) applies against stock EC05 with the previous timer_delay patch already applied and should be used for custom kernels already containing that patch.

    The column-switch delay is the amount of time, in µs, that the driver delays while switching between the six keyboard "columns" (actually rows) in the keyboard scaning routine. A delay is necessary to ensure that the column switch has been performed by the hardware before scanning a new column, otherwise ghost keypresses result.

    However, the 300 µs delay specified by Samsung is very inefficient, particularly for "reasonable" timer_delay values. With theimpaler747's suggested timer_delay of 5, the keyboard driver, while holding a key down, consumes 9.7% of CPU time (empirically tested), at any clock rate. This is quite-likely responsible for folks' previous complaints that use of the hardware keyboard causes audio skips, poor game performance, decreased battery life, etc.

    This patch allows this (default) 300 µs delay value to be modified through a sysfs exported column_delay variable. Similar to the timer_delay, it may be read with:
    Code:
    cat /sys/devices/platform/s3c-keypad/column_delay
    and a new delay may be set with:
    Code:
    echo N > /sys/devices/platform/s3c-keypad/column_delay
    where N is the delay in µs.

    A delay of "1" is the most efficient (only 0.02% CPU utilization) but results in ghost key presses. In testing, I've found ghosting to disappear at delays of "3" and above. To provide some buffer, I've been using (and recommend) a delay of "5" for both column_delay and timer_delay values for the past week, and I've not run into any issues.

    At a delay of "5", the keyboard driver is far more efficient, consuming only 0.2% of CPU time while keys are held. This hopefully translates into less stuttering/performance problems and better battery life.

    Testing on other devices is needed (and appreciated!) to find a reasonable delay where ghosting doesn't appear, assuming that "5" is too low on some devices. Even delays of "10" and "50" (comparable to other keyboard drivers) result in ~0.3% and 1.7% CPU utilization respectively, which is much better than the Samsung default.

    Mirror links:
    GB kernel patches: keyboard_patches-GB.tar.gz
    Column-switch & timer delay patch: epic_keypad_delays-EC05.diff (for stock EC05)
    Column-switch & timer delay patch: epic_keypad_delays_alt-EC05.diff (for kernels with timer delay patch already applied)

    Historical links:
    Timer delay patch: epic_keypad_timer_delay-EB13.diff
    Original patch: epic_keypad_timer_fix-EB13.diff
    2
    Please do everything you can to fix it!!!!!
    I added a second patch to the OP that makes the timer delay configurable now. So, in any kernel that supports it, you can configure the timer delay to be short enough so that you no longer have dropped key presses. I added instructions for doing that in the OP.

    is this being pushed to all kernels and roms so u dont have to do the patch urself.
    I believe Genocide and Twilight Zone both currently implement the original fix.
    2
    A quick solution here would be to see if the 300 µs delay is really necessary. ... I'll see what I can do.
    I added a new patch to the OP that exports the "column-switch delay", which appears to tolerate much lower values (~5 µs) than the Samsung default. This should make the driver much more CPU efficient than it's been.

    Sorry it took so long, my testing was stymied for a while as Linux's CPU usage statistics weren't reporting the significant CPU usage by the driver that I was expecting. It turns out that this is an artifact of how the usage statistics are collected. The inefficient CPU usage is very much real, and this patch addresses it.
    1
    mkasick the patch works beautifully! one note you might want to mention is any kernel developers that attempt to change the Kconfig or CONFIG_HZ=256 (it is set to 256 here but the Kconfig sets it to 1000 anyway) then that will throw this timer off (patched or not)

    i think samsung missed the CONFIG_HZ=256 being used in the Kconfig...if we used the config's value in original settings (256/10) then that would give us 25.6 where as your patch is giving us 30 (3*1000/100)...i may fix this later but using your diff patch for now...thanks again
    1
    Bump! Any more progress?? So far so great!
    The patch is in Twilight Zone kernel. I believe it will be in Genocide soon enough if it isn't already.

    Is there outstanding issues with the patch? The QAOL bug is hardware-related, and isn't fixable in a useful sense. I'm not sure what's causing the "unexpected special character popup", other than, as far as I can tell it's not kernel related.