From patchwork Sat Nov 14 05:49:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Lutomirski X-Patchwork-Id: 7616691 Return-Path: X-Original-To: patchwork-platform-driver-x86@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A43C79F6CD for ; Sat, 14 Nov 2015 05:49:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C7C912061A for ; Sat, 14 Nov 2015 05:49:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DF8A32061D for ; Sat, 14 Nov 2015 05:49:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750925AbbKNFtr (ORCPT ); Sat, 14 Nov 2015 00:49:47 -0500 Received: from mail.kernel.org ([198.145.29.136]:59681 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750854AbbKNFtp (ORCPT ); Sat, 14 Nov 2015 00:49:45 -0500 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 40E2C2061D; Sat, 14 Nov 2015 05:49:44 +0000 (UTC) Received: from localhost (c-71-202-137-17.hsd1.ca.comcast.net [71.202.137.17]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 74B4D2061A; Sat, 14 Nov 2015 05:49:43 +0000 (UTC) From: Andy Lutomirski To: =?UTF-8?q?Pali=20Roh=C3=A1r?= , platform-driver-x86@vger.kernel.org Cc: Matthew Garrett , Andy Lutomirski Subject: [PATCH 1/3] dell_wmi: Support new hotkeys on the XPS 13 Skylake Date: Fri, 13 Nov 2015 21:49:30 -0800 Message-Id: X-Mailer: git-send-email 2.5.0 In-Reply-To: References: In-Reply-To: References: X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Sender: platform-driver-x86-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The XPS 13 Skylake has an rfkill button and a switchvideomode button that aren't enumerated in the DMI table AFAICT. Add a table listing extra un-enumerated hotkeys. To avoid breaking things that worked before, these un-enumerated hotkeys won't be used if the DMI table maps them to something else. This also adds the Fn-lock key as a KE_IGNORE entry. Signed-off-by: Andy Lutomirski --- drivers/platform/x86/dell-wmi.c | 48 +++++++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 7 deletions(-) diff --git a/drivers/platform/x86/dell-wmi.c b/drivers/platform/x86/dell-wmi.c index f2d77fe696ac..5be1abec4f64 100644 --- a/drivers/platform/x86/dell-wmi.c +++ b/drivers/platform/x86/dell-wmi.c @@ -142,6 +142,16 @@ static const u16 bios_to_linux_keycode[256] __initconst = { 0, 0, 0, 0, 0, 0, 0, 0, 0, KEY_PROG3 }; +/* These are applied if the hk table is present and doesn't override them. */ +static const struct key_entry dell_wmi_extra_keymap[] __initconst = { + /* Fn-lock -- no action is required by the kernel. */ + { KE_IGNORE, 0x151, { KEY_RESERVED } }, + + /* Keys that need our help (on XPS 13 Skylake and maybe others. */ + { KE_KEY, 0x152, { KEY_SWITCHVIDEOMODE } }, + { KE_KEY, 0x153, { KEY_RFKILL } }, +}; + static struct input_dev *dell_wmi_input_dev; static void dell_wmi_process_key(int reported_key) @@ -300,9 +310,10 @@ static const struct key_entry * __init dell_wmi_prepare_new_keymap(void) int hotkey_num = (dell_bios_hotkey_table->header.length - 4) / sizeof(struct dell_bios_keymap_entry); struct key_entry *keymap; - int i; + int i, pos = 0, num_bios_keys; - keymap = kcalloc(hotkey_num + 1, sizeof(struct key_entry), GFP_KERNEL); + keymap = kcalloc(hotkey_num + ARRAY_SIZE(dell_wmi_extra_keymap), + sizeof(struct key_entry), GFP_KERNEL); if (!keymap) return NULL; @@ -314,14 +325,37 @@ static const struct key_entry * __init dell_wmi_prepare_new_keymap(void) KEY_RESERVED; if (keycode == KEY_KBDILLUMTOGGLE) - keymap[i].type = KE_IGNORE; + keymap[pos].type = KE_IGNORE; else - keymap[i].type = KE_KEY; - keymap[i].code = bios_entry->scancode; - keymap[i].keycode = keycode; + keymap[pos].type = KE_KEY; + keymap[pos].code = bios_entry->scancode; + keymap[pos].keycode = keycode; + + pos++; + } + + num_bios_keys = pos; + + for (i = 0; i < ARRAY_SIZE(dell_wmi_extra_keymap); i++) { + int j; + + /* + * Check if we've already found this scancode. This takes + * quadratic time, but it doesn't matter unless the list + * of extra keys gets very long. + */ + for (j = 0; j < num_bios_keys; j++) + if (keymap[j].code == dell_wmi_extra_keymap[i].code) + goto skip; + + keymap[pos] = dell_wmi_extra_keymap[i]; + pos++; + +skip: + ; } - keymap[hotkey_num].type = KE_END; + keymap[pos].type = KE_END; return keymap; }