[ibm-acpi-devel] [PATCH v2 00/24] platform/x86: thinkpad_acpi: Refactor hotkey handling and add support for some new hotkeys

2024-04-24 Thread Hans de Goede
Hi All, Here is v2 of my patch-series to refactor thinkpad_acpi's hotkey handling and to add support for some new hotkeys on new models. Changes in v2: - Some small code style tweaks in response to reviews - Add various Reviewed-by and Tested-by tags Relevant parts of v1 cover-letter: I have be

[ibm-acpi-devel] [PATCH v2 02/24] platform/x86: thinkpad_acpi: Provide hotkey_poll_stop_sync() dummy

2024-04-24 Thread Hans de Goede
Provide a hotkey_poll_stop_sync() dummy implementation when CONFIG_THINKPAD_ACPI_HOTKEY_POLL, so that the #ifdef-ery around hotkey_poll_stop_sync() can be removed from hotkey_exit(). Tested-by: Mark Pearson Signed-off-by: Hans de Goede --- drivers/platform/x86/thinkpad_acpi.c | 5 +++-- 1 file

[ibm-acpi-devel] [PATCH v2 04/24] platform/x86: thinkpad_acpi: Drop ignore_acpi_ev

2024-04-24 Thread Hans de Goede
Setting ignore_acpi_ev to true has the same result as setting send_acpi_ev to false, so there is no need to have both. Drop ignore_acpi_ev. Tested-by: Mark Pearson Signed-off-by: Hans de Goede --- drivers/platform/x86/thinkpad_acpi.c | 56 +--- 1 file changed, 17 insert

[ibm-acpi-devel] [PATCH v2 09/24] platform/x86: thinkpad_acpi: Move special original hotkeys handling out of switch-case

2024-04-24 Thread Hans de Goede
Move the special handling (send_acpi_ev = false, hotkey_source_mask check) for original hotkeys out of the switch-case in hotkey_notify_hotkey(). This is a preparation patch for further refactoring. Tested-by: Mark Pearson Signed-off-by: Hans de Goede --- drivers/platform/x86/thinkpad_acpi.c |

[ibm-acpi-devel] [PATCH v2 06/24] platform/x86: thinkpad_acpi: Do hkey to scancode translation later

2024-04-24 Thread Hans de Goede
Modify hotkey_notify_hotkey() and it helpers to mostly directly operate on hkey codes (TP_HKEY_EV_* returned by "MHKP") instead of on the 0 - TPACPI_HOTKEY_MAP_LEN scancodes used for scancode -> keycode translation. Keeping things in the hkey format as long a possible is a bit cleaner and this pat

[ibm-acpi-devel] [PATCH v2 03/24] platform/x86: thinkpad_acpi: Drop setting send_/ignore_acpi_ev defaults twice

2024-04-24 Thread Hans de Goede
send_acpi_ev and ignore_acpi_ev are already initialized to true and false respectively by hotkey_notify() before calling the various helpers. Drop the needless re-initialization from the helpers. Reviewed-by: Ilpo Järvinen Tested-by: Mark Pearson Signed-off-by: Hans de Goede --- drivers/platfo

[ibm-acpi-devel] [PATCH v2 13/24] platform/x86: thinkpad_acpi: Move hkey > scancode mapping to tpacpi_input_send_key()

2024-04-24 Thread Hans de Goede
Move the mapping of hkey events to scancodes to tpacpi_input_send_key(), this results in a nice cleanup and prepares things for adding sparse-keymap support. Tested-by: Mark Pearson Signed-off-by: Hans de Goede --- drivers/platform/x86/thinkpad_acpi.c | 81 +--- 1 file c

[ibm-acpi-devel] [PATCH v2 01/24] platform/x86: thinkpad_acpi: Take hotkey_mutex during hotkey_exit()

2024-04-24 Thread Hans de Goede
hotkey_exit() already takes the mutex around the hotkey_poll_stop_sync() call, but not around the other calls. commit 38831eaf7d4c ("platform/x86: thinkpad_acpi: use lockdep annotations") has added lockdep_assert_held() checks to various hotkey functions. These lockdep_assert_held() checks fail c

[ibm-acpi-devel] [PATCH v2 11/24] platform/x86: thinkpad_acpi: Always call tpacpi_driver_event() for hotkeys

2024-04-24 Thread Hans de Goede
Call tpacpi_driver_event() at the top of hotkey_notify_hotkey() for all (orig / adaptive / extended) hotkey types, rather then having the orig code path call tpacpi_input_send_key_masked() which calls it through hotkey_driver_event() and having the adaptive / extended helpers call it separately. T

[ibm-acpi-devel] [PATCH v2 08/24] platform/x86: thinkpad_acpi: Move adaptive kbd event handling to tpacpi_driver_event()

2024-04-24 Thread Hans de Goede
Factor out the adaptive kbd non hotkey event handling into adaptive_keyboard_change_row() and adaptive_keyboard_s_quickview_row() helpers and move the handling of TP_HKEY_EV_DFR_CHANGE_ROW and TP_HKEY_EV_DFR_S_QUICKVIEW_ROW to tpacpi_driver_event(). This groups all the handling of hotkey events wh

[ibm-acpi-devel] [PATCH v2 14/24] platform/x86: thinkpad_acpi: Move tpacpi_driver_event() call to tpacpi_input_send_key()

2024-04-24 Thread Hans de Goede
All callers of tpacpi_input_send_key() first call tpacpi_driver_event(), move the tpacpi_driver_event() inside tpacpi_input_send_key() to avoid code duplication. For the original hotkey codes 0x1001 - 0x1020 tpacpi_driver_event() never returns true. So the added "return true;" inside tpacpi_input_

[ibm-acpi-devel] [PATCH v2 05/24] platform/x86: thinkpad_acpi: Use tpacpi_input_send_key() in adaptive kbd code

2024-04-24 Thread Hans de Goede
Use tpacpi_input_send_key() in adaptive_keyboard_hotkey_notify_hotkey() instead of re-implementing it there. Note this change will also result in a behavioral change, key presses on the adaptive keyboard will now also send a EV_MSC event with the scancode, just like all other hotkey presses alread

[ibm-acpi-devel] [PATCH v2 10/24] platform/x86: thinkpad_acpi: Move hotkey_user_mask check to tpacpi_input_send_key()

2024-04-24 Thread Hans de Goede
Move hotkey_user_mask check to tpacpi_input_send_key(), this is a preparation patch for further refactoring. Tested-by: Mark Pearson Signed-off-by: Hans de Goede --- drivers/platform/x86/thinkpad_acpi.c | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/platform/

[ibm-acpi-devel] [PATCH v2 07/24] platform/x86: thinkpad_acpi: Make tpacpi_driver_event() return if it handled the event

2024-04-24 Thread Hans de Goede
tpacpi_driver_event() already only responds to hkey events which it knows about. Make it return a bool and return true when it has handled the event. This avoids the need to list TP_HKEY_EV_foo values to which it responds both in its caller and in the function itself. Instead callers can now call

[ibm-acpi-devel] [PATCH v2 19/24] platform/x86: thinkpad_acpi: Switch to using sparse-keymap helpers

2024-04-24 Thread Hans de Goede
Switch the hotkey keymap handling over to the sparse-keymap helpers, there should be no functional changes from this. Note all the mappings to KEY_UNKNOWN are removed since that is the default behavior of sparse_keymap_report_event() for unknown scancodes. Also drop the big comment about making c

[ibm-acpi-devel] [PATCH v2 20/24] platform/x86: thinkpad_acpi: Add mappings for adaptive kbd clipping-tool and cloud keys

2024-04-24 Thread Hans de Goede
The X1 carbon 2014 / 2nd gen's adaptive keyboard top row's "Home" mode, which is 1 of the 2 modes Linux supports, has clipping-tool and cloud buttons which so far are not mapped. I assume these were left as KEY_RESERVED because no suitable KEY_FOO codes were available when support was added. In t

[ibm-acpi-devel] [PATCH v2 12/24] platform/x86: thinkpad_acpi: Drop tpacpi_input_send_key_masked() and hotkey_driver_event()

2024-04-24 Thread Hans de Goede
Both are only 1 / 2 lines and both only have 1 caller fold the contents into tpacpi_hotkey_send_key() which is their single caller. Tested-by: Mark Pearson Signed-off-by: Hans de Goede --- drivers/platform/x86/thinkpad_acpi.c | 16 ++-- 1 file changed, 2 insertions(+), 14 deletions(

[ibm-acpi-devel] [PATCH v2 23/24] platform/x86: thinkpad_acpi: Support for system debug info hotkey

2024-04-24 Thread Hans de Goede
From: Mark Pearson New Lenovo platforms are adding the FN+N key to generate system debug details that support can use for collecting important details on any customer cases for Windows. Add the infrastructure so we can do the same on Linux by sending a KEY_VENDOR keycode to userspace. Signed-off

[ibm-acpi-devel] [PATCH v2 17/24] platform/x86: thinkpad_acpi: Use correct keycodes for volume and brightness keys

2024-04-24 Thread Hans de Goede
Change the default keymap to report the correct keycodes for the volume and brightness keys. Reporting key events for these is already filtered out by the hotkey_reserved_mask which masks these keys out of hotkey_user_mask at initialization time, so there is no need to also map them to KEY_RESERVED

[ibm-acpi-devel] [PATCH v2 16/24] platform/x86: thinkpad_acpi: Change hotkey_reserved_mask initialization

2024-04-24 Thread Hans de Goede
Change the hotkey_reserved_mask initialization to hardcode the list of reserved keys. There are only a few reserved keys and the code to iterate over the keymap will be removed when moving to sparse-keymaps. Tested-by: Mark Pearson Signed-off-by: Hans de Goede --- drivers/platform/x86/thinkpad_

[ibm-acpi-devel] [PATCH v2 15/24] platform/x86: thinkpad_acpi: Do not send ACPI netlink events for unknown hotkeys

2024-04-24 Thread Hans de Goede
Do not send ACPI netlink events for unknown hotkeys, to avoid userspace starting to rely on them. Instead these should be added to the keymap to send evdev events. This should not cause a behavior change for existing laptop models since all currently known 0x1xxx events have a mapping. In hindsig

[ibm-acpi-devel] [PATCH v2 21/24] platform/x86: thinkpad_acpi: Simplify known_ev handling

2024-04-24 Thread Hans de Goede
From: Mark Pearson Modify how known_ev event is handled in preparation for adding new hkey event range. Signed-off-by: Mark Pearson Link: https://lore.kernel.org/r/20240417173124.9953-1-mpearson-len...@squebb.ca Reviewed-by: Hans de Goede Tested-by: Mark Pearson Signed-off-by: Hans de Goede

[ibm-acpi-devel] [PATCH v2 22/24] platform/x86: thinkpad_acpi: Support for trackpoint doubletap

2024-04-24 Thread Hans de Goede
From: Mark Pearson Lenovo trackpoints are adding the ability to generate a doubletap event. This handles the doubletap event and sends the KEY_PROG4 event to userspace. Despite the driver itself not using KEY_PROG1 - KEY_PROG3 this still uses KEY_PROG4 because of some keys being remapped to KEY_P

[ibm-acpi-devel] [PATCH v2 18/24] platform/x86: thinkpad_acpi: Drop KEY_RESERVED special handling

2024-04-24 Thread Hans de Goede
The input core already filters out EV_KEY events for KEY_RESERVED, remove the check for this in tpacpi_input_send_key() and rely on the input core filtering instead. Also change tpacpi_input_send_key() to only report the scancode once instead of reporting it on both press and release. Together the

[ibm-acpi-devel] [PATCH v2 24/24] platform/x86: thinkpad_acpi: Support hotkey to disable trackpoint doubletap

2024-04-24 Thread Hans de Goede
From: Mark Pearson The hotkey combination Fn + G can be used to disable the trackpoint doubletap feature on Windows. Add matching functionality for Linux. Signed-off-by: Mark Pearson Signed-off-by: Vishnu Sankar Link: https://lore.kernel.org/r/20240417173124.9953-4-mpearson-len...@squebb.ca [h

Re: [ibm-acpi-devel] [PATCH v2 16/24] platform/x86: thinkpad_acpi: Change hotkey_reserved_mask initialization

2024-04-24 Thread Mark Pearson
Hi Hans, On Wed, Apr 24, 2024, at 8:28 AM, Hans de Goede wrote: > Change the hotkey_reserved_mask initialization to hardcode the list > of reserved keys. There are only a few reserved keys and the code to > iterate over the keymap will be removed when moving to sparse-keymaps. > > Tested-by: Mark

Re: [ibm-acpi-devel] [PATCH v2 16/24] platform/x86: thinkpad_acpi: Change hotkey_reserved_mask initialization

2024-04-24 Thread Hans de Goede
Hi Mark, On 4/24/24 4:17 PM, Mark Pearson wrote: > Hi Hans, > > On Wed, Apr 24, 2024, at 8:28 AM, Hans de Goede wrote: >> Change the hotkey_reserved_mask initialization to hardcode the list >> of reserved keys. There are only a few reserved keys and the code to >> iterate over the keymap will be

Re: [ibm-acpi-devel] [PATCH v2 16/24] platform/x86: thinkpad_acpi: Change hotkey_reserved_mask initialization

2024-04-24 Thread Mark Pearson
On Wed, Apr 24, 2024, at 10:47 AM, Hans de Goede wrote: > Hi Mark, > > On 4/24/24 4:17 PM, Mark Pearson wrote: >> Hi Hans, >> >> On Wed, Apr 24, 2024, at 8:28 AM, Hans de Goede wrote: >>> Change the hotkey_reserved_mask initialization to hardcode the list >>> of reserved keys. There are only a

Re: [ibm-acpi-devel] [PATCH v2 22/24] platform/x86: thinkpad_acpi: Support for trackpoint doubletap

2024-04-24 Thread Mark Pearson
Hi Hans, On Wed, Apr 24, 2024, at 8:28 AM, Hans de Goede wrote: > From: Mark Pearson > > Lenovo trackpoints are adding the ability to generate a doubletap event. > This handles the doubletap event and sends the KEY_PROG4 event to > userspace. Despite the driver itself not using KEY_PROG1 - KEY_PR

Re: [ibm-acpi-devel] [PATCH v2 00/24] platform/x86: thinkpad_acpi: Refactor hotkey handling and add support for some new hotkeys

2024-04-24 Thread Mark Pearson
On Wed, Apr 24, 2024, at 8:28 AM, Hans de Goede wrote: > Hi All, > > Here is v2 of my patch-series to refactor thinkpad_acpi's hotkey handling > and to add support for some new hotkeys on new models. > > Changes in v2: > - Some small code style tweaks in response to reviews > - Add various Revie