X86 platform drivers
 help / color / mirror / Atom feed
* [PATCH v2 1/2] platform/x86: thinkpad_acpi: guard generic hotkey case
@ 2017-02-28 16:10 Christian Kellner
  2017-02-28 16:10 ` [PATCH v2 2/2] platform/x86: thinkpad_acpi: add mapping for new hotkeys Christian Kellner
       [not found] ` <20170228161057.28394-1-ckellner-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
  0 siblings, 2 replies; 5+ messages in thread
From: Christian Kellner @ 2017-02-28 16:10 UTC (permalink / raw)
  To: Henrique de Moraes Holschuh, Darren Hart, Andy Shevchenko,
	ibm-acpi-devel, platform-driver-x86
  Cc: Christian Kellner, Christian Kellner

From: Christian Kellner <christian@kellner.me>

Currently when dispatching hotkeys we check if the scancode is in
the range of 0 and TPACPI_HOTKEY_MAP_LEN, although the bottom 20
entries in the hotkey keymap are already adaptive keycodes.
Therefore we introduce a TP_ACPI_HOTKEYSCAN_ADAPTIVE_START and
ensure that we are in the range 0 and ADAPTIVE_START for the generic
keycode case.

Signed-off-by: Christian Kellner <ckellner@redhat.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
---
Changes in v2:
- Don't initialize TP_ACPI_HOTKEYSCAN_ADAPTIVE_START manually, but use
  it to initialize TP_ACPI_HOTKEYSCAN_MUTE2
- Add a comment before the adaptive keycodes block
---
 drivers/platform/x86/thinkpad_acpi.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index 1d18b32628ec..e2b962f0fdc4 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -1922,7 +1922,9 @@ enum {	/* hot key scan codes (derived from ACPI DSDT) */
 	TP_ACPI_HOTKEYSCAN_UNK7,
 	TP_ACPI_HOTKEYSCAN_UNK8,
 
-	TP_ACPI_HOTKEYSCAN_MUTE2,
+	/* Adaptive keyboard keycodes */
+	TP_ACPI_HOTKEYSCAN_ADAPTIVE_START,
+	TP_ACPI_HOTKEYSCAN_MUTE2        = TP_ACPI_HOTKEYSCAN_ADAPTIVE_START,
 	TP_ACPI_HOTKEYSCAN_BRIGHTNESS_ZERO,
 	TP_ACPI_HOTKEYSCAN_CLIPPING_TOOL,
 	TP_ACPI_HOTKEYSCAN_CLOUD,
@@ -3656,7 +3658,6 @@ static const int adaptive_keyboard_modes[] = {
 #define DFR_CHANGE_ROW			0x101
 #define DFR_SHOW_QUICKVIEW_ROW		0x102
 #define FIRST_ADAPTIVE_KEY		0x103
-#define ADAPTIVE_KEY_OFFSET		0x020
 
 /* press Fn key a while second, it will switch to Function Mode. Then
  * release Fn key, previous mode be restored.
@@ -3747,12 +3748,13 @@ static bool adaptive_keyboard_hotkey_notify_hotkey(unsigned int scancode)
 	default:
 		if (scancode < FIRST_ADAPTIVE_KEY ||
 		    scancode >= FIRST_ADAPTIVE_KEY + TPACPI_HOTKEY_MAP_LEN -
-				ADAPTIVE_KEY_OFFSET) {
+				TP_ACPI_HOTKEYSCAN_ADAPTIVE_START) {
 			pr_info("Unhandled adaptive keyboard key: 0x%x\n",
 					scancode);
 			return false;
 		}
-		keycode = hotkey_keycode_map[scancode - FIRST_ADAPTIVE_KEY + ADAPTIVE_KEY_OFFSET];
+		keycode = hotkey_keycode_map[scancode - FIRST_ADAPTIVE_KEY +
+					     TP_ACPI_HOTKEYSCAN_ADAPTIVE_START];
 		if (keycode != KEY_RESERVED) {
 			mutex_lock(&tpacpi_inputdev_send_mutex);
 
@@ -3778,7 +3780,7 @@ static bool hotkey_notify_hotkey(const u32 hkey,
 	*ignore_acpi_ev = false;
 
 	/* HKEY event 0x1001 is scancode 0x00 */
-	if (scancode > 0 && scancode <= TPACPI_HOTKEY_MAP_LEN) {
+	if (scancode > 0 && scancode <= TP_ACPI_HOTKEYSCAN_ADAPTIVE_START) {
 		scancode--;
 		if (!(hotkey_source_mask & (1 << scancode))) {
 			tpacpi_input_send_key_masked(scancode);
-- 
2.11.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-03-03 18:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-28 16:10 [PATCH v2 1/2] platform/x86: thinkpad_acpi: guard generic hotkey case Christian Kellner
2017-02-28 16:10 ` [PATCH v2 2/2] platform/x86: thinkpad_acpi: add mapping for new hotkeys Christian Kellner
     [not found]   ` <20170228161057.28394-2-ckellner-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-02-28 20:03     ` Henrique de Moraes Holschuh
     [not found] ` <20170228161057.28394-1-ckellner-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-02-28 20:02   ` [PATCH v2 1/2] platform/x86: thinkpad_acpi: guard generic hotkey case Henrique de Moraes Holschuh
2017-03-03 18:28     ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox