[Galaxy S Plus I9001 Android Development] Christopher83:
K^Kernel 3.0.73 v1.6 for JB 4.1.2 and JB 4.2.2

Hi guys,

I released the new v1.6 kernel builds which include the new phantom key presses filter module:

- Kernel 3.0.73
- Sources synched with jb-3.0 repos of Ivendor and Arco68 for JB-4.1.2 (CM 10) kernel builds
- Sources synched with cm-10.1 repo of Arco68 for JB 4.2.2 (CM 10.1) kernel builds
- Built with my latest custom Linaro 4.7.3-2013.04 toolchain optimized for Cortex-A8
- Phantom key presses filter (new module developed by me)
- New display drivers s6e63m0 from Samsung Galaxy SII (Thanks and credits to CastagnaIT)

The followings are the infos related to the new module, you can also find them inside the second post of the first thread page.

Phantom Key Presses filter

This feature is an attempt to workaround a well known hardware bug of some Samsung devices.

Pratically, the high activity of the radio hardware, in particular the antenna, could cause interference on Melfas chip, which is located very close to the antenna.

This interference could induce bad interrupts that are seen by the chip as possible HOME, MENU or BACK key presses.

These phantom key presses are happening expecially in 2G mode.

The solution includes a new device module (phantom_kp_filter), which also allow the filtering parameters customization, and various changes to cypress-touchkey and pmic8xxx-keypad modules.

The phantom key presses filtering is enabled by default for incoming MENU and BACK touch keys, because for these keys is simpler to recognize a bad interrupt or an invalid key press, instead it's disabled for incoming HOME key (read the next howto infos to enable it).

The software side solution related to the phantom touchkeys presses is in part based and readapted on the work of Electric Bill (a big thanks to him): http://xdaforums.com/showthread.php?t=1551580

You can find my developed solution on my GitHub repo, the commit is the following:

input: Phantom Key Presses filtering​

How to enable/disable the feauture and customize the filtering parameters:

The new device module allows to show the number of ignored key presses and to customize the filtering parameters by means of a sysfs interface, at the following system path: /sys/class/misc/phantom_kp_filter

The interface exposes these files:

- home_enabled:

- home_allowed_irqs:

- home_report_wait:

- home_ignored_kp:

- menuback_enabled:

- menuback_interrupt_checks:

- menuback_first_err_wait:

- menuback_last_err_wait:

- menuback_ignored_kp:

- version:

To change the filtering parameters:

1) By using a customized init.d script (the custom value will be always restored after a reboot, if you don't format the system partition)

- Download the script named 05pkf

- If the file has been saved with .txt extension (stock browser), rename it by removing the .txt extension

- Edit the file by setting your preferred filtering parameters (the downloaded script has the default filtering parameter values and enables the phantom HOME key presses filtering)

- Copy the new file inside /etc/init.d

- Give the rwxr-xr-x permissions to the file (read, write, execution for owner, read and execution for group users, read and execution for others)

- Reboot

2) By directly editing the files inside /sys/class/misc/phantom_kp_filter (the values you set will be lost after a reboot/shutdown)

3) By using Terminal Emulator (note that set values will be lost after a reboot/shutdown)

- Open Terminal Emulator

- Run these commands

su
echo [COLOR="Blue"][I]value[/I][/COLOR] > /sys/class/misc/phantom_kp_filter/[COLOR="Green"][I]parameter_name[/I][/COLOR]

where value is the value you want to set and parameter_name is one of the previously described editable parameters

For example, these commands will enable phantom HOME key presses filtering:

su
echo 1 > /sys/class/misc/phantom_kp_filter/home_enabled

To show the number of ignored key presses (possible phantom key presses):

1) By directly opening the files /sys/class/misc/phantom_kp_filter/home_ignored_kp and /sys/class/misc/phantom_kp_filter/menuback_ignored_kp

2) By using Terminal Emulator

- Open Terminal Emulator

- Run these commands

su
cat /sys/class/misc/phantom_kp_filter/home_ignored_kp
cat /sys/class/misc/phantom_kp_filter/menuback_ignored_kp

Ready to use filtering settings, with phantom HOME key presses filtering and phantom MENU and BACK key presses both enabled (they differ only for the phantom HOME key presses filtering parameters):

- 05pkf (filter parameter values are similar to Test9 kernel version)

#!/system/bin/sh

if [ -d /sys/class/misc/phantom_kp_filter ]; then
echo "Enabling HOME, MENU and BACK phantom key presses filtering"
echo 1 > /sys/class/misc/phantom_kp_filter/home_enabled
echo 1 > /sys/class/misc/phantom_kp_filter/menuback_enabled

echo "Setting the HOME phantom key presses filtering parameters"
[B]echo 2 > /sys/class/misc/phantom_kp_filter/home_allowed_irqs
echo 12 > /sys/class/misc/phantom_kp_filter/home_report_wait[/B]

echo "Setting the MENU and BACK phantom key presses filtering parameters"
echo 10 > /sys/class/misc/phantom_kp_filter/menuback_interrupt_checks
echo 500 > /sys/class/misc/phantom_kp_filter/menuback_first_err_wait
echo 100 > /sys/class/misc/phantom_kp_filter/menuback_last_err_wait
fi

- 05pkf_test8 (filter parameter values are similar to Test8 kernel version)

#!/system/bin/sh

if [ -d /sys/class/misc/phantom_kp_filter ]; then
echo "Enabling HOME, MENU and BACK phantom key presses filtering"
echo 1 > /sys/class/misc/phantom_kp_filter/home_enabled
echo 1 > /sys/class/misc/phantom_kp_filter/menuback_enabled

echo "Setting the HOME phantom key presses filtering parameters"
[B]echo 3 > /sys/class/misc/phantom_kp_filter/home_allowed_irqs
echo 15 > /sys/class/misc/phantom_kp_filter/home_report_wait[/B]

echo "Setting the MENU and BACK phantom key presses filtering parameters"
echo 10 > /sys/class/misc/phantom_kp_filter/menuback_interrupt_checks
echo 500 > /sys/class/misc/phantom_kp_filter/menuback_first_err_wait
echo 100 > /sys/class/misc/phantom_kp_filter/menuback_last_err_wait
fi

- 05pkf_alt (more permissive, tested by KTulu84 with positive feedbacks)

#!/system/bin/sh

if [ -d /sys/class/misc/phantom_kp_filter ]; then
echo "Enabling HOME, MENU and BACK phantom key presses filtering"
echo 1 > /sys/class/misc/phantom_kp_filter/home_enabled
echo 1 > /sys/class/misc/phantom_kp_filter/menuback_enabled

echo "Setting the HOME phantom key presses filtering parameters"
[B]echo 4 > /sys/class/misc/phantom_kp_filter/home_allowed_irqs
echo 10 > /sys/class/misc/phantom_kp_filter/home_report_wait[/B]

echo "Setting the MENU and BACK phantom key presses filtering parameters"
echo 10 > /sys/class/misc/phantom_kp_filter/menuback_interrupt_checks
echo 500 > /sys/class/misc/phantom_kp_filter/menuback_first_err_wait
echo 100 > /sys/class/misc/phantom_kp_filter/menuback_last_err_wait
fi

The differences related to HOME key are the following:

05pkf) A HOME key press is considered valid if there aren't more than 2 interrupts in a small time range of 12 ms

05pkf_test8) A HOME key press is considered valid if there aren't more than 3 interrupts in a small time range of 15 ms

05pkf_alt) A HOME key press is considered valid if there aren't more than 4 interrupts in a small time range of 10 ms (more permissive)

A big thanks to Davidteri91, Ktulu84, Sziggins, Rhonin86, Anuseb89 and Dr.Wtf for their support in testing!!!

You're great!