From patchwork Tue Jan 13 13:54:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bastien Nocera X-Patchwork-Id: 5620631 Return-Path: X-Original-To: patchwork-linux-acpi@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 69BF19F2ED for ; Tue, 13 Jan 2015 13:55:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 68C0020614 for ; Tue, 13 Jan 2015 13:55:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0EED2205F9 for ; Tue, 13 Jan 2015 13:55:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751637AbbAMNzL (ORCPT ); Tue, 13 Jan 2015 08:55:11 -0500 Received: from relay6-d.mail.gandi.net ([217.70.183.198]:35025 "EHLO relay6-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752392AbbAMNzK convert rfc822-to-8bit (ORCPT ); Tue, 13 Jan 2015 08:55:10 -0500 Received: from mfilter14-d.gandi.net (mfilter14-d.gandi.net [217.70.178.142]) by relay6-d.mail.gandi.net (Postfix) with ESMTP id 062B5FB8E5; Tue, 13 Jan 2015 14:55:08 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at mfilter14-d.gandi.net Received: from relay6-d.mail.gandi.net ([217.70.183.198]) by mfilter14-d.gandi.net (mfilter14-d.gandi.net [10.0.15.180]) (amavisd-new, port 10024) with ESMTP id Q4s0fPcIMJi8; Tue, 13 Jan 2015 14:55:06 +0100 (CET) X-Originating-IP: 83.155.44.161 Received: from nuvo (mon69-7-83-155-44-161.fbx.proxad.net [83.155.44.161]) (Authenticated sender: hadess@hadess.net) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 2A940FB8B3; Tue, 13 Jan 2015 14:55:05 +0100 (CET) Message-ID: <1421157259.2542.13.camel@hadess.net> Subject: More X1 Carbon (2nd gen) adaptive keyboard support From: Bastien Nocera To: ibm-acpi-devel@lists.sourceforge.net, linux-acpi@vger.kernel.org Date: Tue, 13 Jan 2015 14:54:19 +0100 X-Mailer: Evolution 3.12.9 (3.12.9-1.fc21) Mime-Version: 1.0 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 Hey, I'm currently working on adding support for the extra "adaptive" keys for the X1 Carbon 2014 (2nd gen). Below is the (non-working) patch to add support for some of those keys. I'm working with Benjamin Tissoires to add the necessary, missing, Linux keycodes. A couple of questions though: - Should I expand the main "hotkey" keymap? I don't really understand that code (and don't really want to read the archives since 2007 ;) - A couple of keys don't go through the same "hotkey" interface: - show all applications - show overview/exposé - search - webcam on/off - wireless on/off Any ideas how those could be exported? Any specific data you would need (de-compiled DSDT?)? Debug I can turn on? Some interesting kernel messages: --8<-- [13747.860235] thinkpad_acpi_adaptive: ThinkPad BIOS GRET42WW (1.19 ), EC unknown [13747.860236] thinkpad_acpi_adaptive: Lenovo ThinkPad X1 Carbon 2nd, model 20A7002WUS [13747.860865] thinkpad_acpi_adaptive: tpacpi_acpi_handle_locate: Found ACPI handle for video [13747.861114] thinkpad_acpi_adaptive: Unsupported brightness interface, please contact ibm-acpi-devel@lists.sourceforge.net [13747.861127] thinkpad_acpi_adaptive: drv_acpi_handle_init: Found ACPI handle HKEY for hkey [13747.861141] thinkpad_acpi_adaptive: unknown version of the HKEY interface: 0x200 [13747.861142] thinkpad_acpi_adaptive: please report this to ibm-acpi-devel@lists.sourceforge.net --8<-- Patch below, Cheers --- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index 721905b..ebf2fb2 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -3526,6 +3526,31 @@ const int adaptive_keyboard_modes[] = { #define DFR_CHANGE_ROW 0x101 #define DFR_SHOW_QUICKVIEW_ROW 0x102 +#define FIRST_ADAPTIVE_KEY 0x105 + +/* The first item in this list is the Clipping tool button + * which is emitted with 0x105 through + * adaptive_keyboard_hotkey_notify_hotkey ()*/ +static int adaptive_keycodes[] = { + KEY_RESERVED, /* Clipping tool, 0x105 */ + KEY_RESERVED, /* Cloud */ + KEY_RESERVED, + KEY_RESERVED, /* Voice */ + KEY_RESERVED, + KEY_RESERVED, /* Gestures */ + KEY_RESERVED, + KEY_RESERVED, + KEY_RESERVED, + KEY_RESERVED, /* Settings */ + KEY_RESERVED, /* New tab */ + KEY_REFRESH, /* Reload */ + KEY_BACK, /* Back */ + KEY_RESERVED, /* Microphone down */ + KEY_RESERVED, /* Microphone up */ + KEY_RESERVED, /* Microphone cancellation */ + KEY_RESERVED, /* Camera mode */ + KEY_RESERVED, /* Rotate display, 0x116 */ +}; /* press Fn key a while second, it will switch to Function Mode. Then * release Fn key, previous mode be restored. @@ -3583,6 +3608,7 @@ static bool adaptive_keyboard_hotkey_notify_hotkey(unsigned int scancode) { u32 current_mode = 0; int new_mode = 0; + int keycode; switch (scancode) { case DFR_CHANGE_ROW: @@ -3615,7 +3641,26 @@ static bool adaptive_keyboard_hotkey_notify_hotkey(unsigned int scancode) return true; default: - return false; + if (scancode < FIRST_ADAPTIVE_KEY || + scancode > FIRST_ADAPTIVE_KEY + + ARRAY_SIZE(adaptive_keycodes)) { + pr_info("Unhandled adaptive keyboard key: 0x%x\n", + scancode); + return false; + } + keycode = adaptive_keycodes[scancode - FIRST_ADAPTIVE_KEY]; + if (keycode != KEY_RESERVED) { + mutex_lock(&tpacpi_inputdev_send_mutex); + + input_report_key(tpacpi_inputdev, keycode, 1); + input_sync(tpacpi_inputdev); + + input_report_key(tpacpi_inputdev, keycode, 0); + input_sync(tpacpi_inputdev); + + mutex_unlock(&tpacpi_inputdev_send_mutex); + } + return true; } } @@ -3628,6 +3673,8 @@ static bool hotkey_notify_hotkey(const u32 hkey, *send_acpi_ev = true; *ignore_acpi_ev = false; + pr_err ("hotkey_notify_hotkey: 0x%x\n", hkey); + /* HKEY event 0x1001 is scancode 0x00 */ if (scancode > 0 && scancode <= TPACPI_HOTKEY_MAP_LEN) { scancode--; @@ -3639,6 +3686,7 @@ static bool hotkey_notify_hotkey(const u32 hkey, } return true; } else { + pr_err ("scancode: 0x%x\n", scancode); return adaptive_keyboard_hotkey_notify_hotkey(scancode); } return false;