summaryrefslogtreecommitdiff
path: root/drivers/platform
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2024-04-24 14:28:18 +0200
committerHans de Goede <hdegoede@redhat.com>2024-04-29 11:44:12 +0200
commit0a1f7f576082cad93d2c663fc0a5f0108aad5105 (patch)
tree99cd8189743ada5d3f2b77e041a9cb9a64af8baf /drivers/platform
parent33dc2efda4e2ec48a77338c75b55325801492f09 (diff)
platform/x86: thinkpad_acpi: Move adaptive kbd event handling to tpacpi_driver_event()
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 which do not emit a key press event together in tpacpi_driver_event(). This also drops the returning of false as known-event value when adaptive_keyboard_get_mode() / adaptive_keyboard_set_mode() fail. These functions already log an error on failure, returning false just leads to an extra messgae being logged about the hkey event being unknown, which is wrong as the event is not unknown. Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca> Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Link: https://lore.kernel.org/r/20240424122834.19801-9-hdegoede@redhat.com
Diffstat (limited to 'drivers/platform')
-rw-r--r--drivers/platform/x86/thinkpad_acpi.c76
1 files changed, 41 insertions, 35 deletions
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index f7b999543870..153de035e3e2 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -3677,51 +3677,51 @@ static int adaptive_keyboard_get_next_mode(int mode)
return adaptive_keyboard_modes[i];
}
-static bool adaptive_keyboard_hotkey_notify_hotkey(const u32 hkey)
+static void adaptive_keyboard_change_row(void)
{
- int current_mode = 0;
- int new_mode = 0;
+ int mode;
- switch (hkey) {
- case TP_HKEY_EV_DFR_CHANGE_ROW:
- if (adaptive_keyboard_mode_is_saved) {
- new_mode = adaptive_keyboard_prev_mode;
- adaptive_keyboard_mode_is_saved = false;
- } else {
- current_mode = adaptive_keyboard_get_mode();
- if (current_mode < 0)
- return false;
- new_mode = adaptive_keyboard_get_next_mode(
- current_mode);
- }
+ if (adaptive_keyboard_mode_is_saved) {
+ mode = adaptive_keyboard_prev_mode;
+ adaptive_keyboard_mode_is_saved = false;
+ } else {
+ mode = adaptive_keyboard_get_mode();
+ if (mode < 0)
+ return;
+ mode = adaptive_keyboard_get_next_mode(mode);
+ }
- if (adaptive_keyboard_set_mode(new_mode) < 0)
- return false;
+ adaptive_keyboard_set_mode(mode);
+}
- return true;
+static void adaptive_keyboard_s_quickview_row(void)
+{
+ int mode;
- case TP_HKEY_EV_DFR_S_QUICKVIEW_ROW:
- current_mode = adaptive_keyboard_get_mode();
- if (current_mode < 0)
- return false;
+ mode = adaptive_keyboard_get_mode();
+ if (mode < 0)
+ return;
- adaptive_keyboard_prev_mode = current_mode;
- adaptive_keyboard_mode_is_saved = true;
+ adaptive_keyboard_prev_mode = mode;
+ adaptive_keyboard_mode_is_saved = true;
- if (adaptive_keyboard_set_mode (FUNCTION_MODE) < 0)
- return false;
- return true;
+ adaptive_keyboard_set_mode(FUNCTION_MODE);
+}
- default:
- if (hkey < TP_HKEY_EV_ADAPTIVE_KEY_START ||
- hkey > TP_HKEY_EV_ADAPTIVE_KEY_END) {
- pr_info("Unhandled adaptive keyboard key: 0x%x\n", hkey);
- return false;
- }
- tpacpi_input_send_key(hkey - TP_HKEY_EV_ADAPTIVE_KEY_START +
- TP_ACPI_HOTKEYSCAN_ADAPTIVE_START);
+static bool adaptive_keyboard_hotkey_notify_hotkey(const u32 hkey)
+{
+ if (tpacpi_driver_event(hkey))
return true;
+
+ if (hkey < TP_HKEY_EV_ADAPTIVE_KEY_START ||
+ hkey > TP_HKEY_EV_ADAPTIVE_KEY_END) {
+ pr_info("Unhandled adaptive keyboard key: 0x%x\n", hkey);
+ return false;
}
+
+ tpacpi_input_send_key(hkey - TP_HKEY_EV_ADAPTIVE_KEY_START +
+ TP_ACPI_HOTKEYSCAN_ADAPTIVE_START);
+ return true;
}
static bool hotkey_notify_extended_hotkey(const u32 hkey)
@@ -11117,6 +11117,12 @@ static bool tpacpi_driver_event(const unsigned int hkey_event)
}
/* Key events are suppressed by default hotkey_user_mask */
return false;
+ case TP_HKEY_EV_DFR_CHANGE_ROW:
+ adaptive_keyboard_change_row();
+ return true;
+ case TP_HKEY_EV_DFR_S_QUICKVIEW_ROW:
+ adaptive_keyboard_s_quickview_row();
+ return true;
case TP_HKEY_EV_THM_CSM_COMPLETED:
lapsensor_refresh();
/* If we are already accessing DYTC then skip dytc update */