From patchwork Fri Dec 9 15:05:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dennis Wassenberg X-Patchwork-Id: 9468457 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EDC0B60231 for ; Fri, 9 Dec 2016 15:08:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DDFAD285AF for ; Fri, 9 Dec 2016 15:08:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D0CC5285F1; Fri, 9 Dec 2016 15:08:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 78C6E285AF for ; Fri, 9 Dec 2016 15:08:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933397AbcLIPIY (ORCPT ); Fri, 9 Dec 2016 10:08:24 -0500 Received: from a.mx.secunet.com ([62.96.220.36]:33404 "EHLO a.mx.secunet.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932763AbcLIPIX (ORCPT ); Fri, 9 Dec 2016 10:08:23 -0500 Received: from localhost (localhost [127.0.0.1]) by a.mx.secunet.com (Postfix) with ESMTP id 29A7620191; Fri, 9 Dec 2016 16:08:22 +0100 (CET) X-Virus-Scanned: by secunet Received: from a.mx.secunet.com ([127.0.0.1]) by localhost (a.mx.secunet.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id VXOy2MSkQeg0; Fri, 9 Dec 2016 16:08:16 +0100 (CET) Received: from mail-essen-01.secunet.de (204.40.53.10.in-addr.arpa [10.53.40.204]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by a.mx.secunet.com (Postfix) with ESMTPS id DDB762017F; Fri, 9 Dec 2016 16:08:16 +0100 (CET) Received: from [10.182.7.39] (10.182.7.39) by mail-essen-01.secunet.de (10.53.40.204) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 9 Dec 2016 16:08:16 +0100 From: Dennis Wassenberg Subject: [PATCH 3/4] hid-lenovo: Handle X1 Tablet cover FNLock function appropriately Organization: secunet Security Networks To: , , , Takashi Iwai , , Benjamin Tissoires , "Andrew Duggan" , , , , , Message-ID: <110694ef-bbad-f211-ac5d-3fe5e10600f2@secunet.com> Date: Fri, 9 Dec 2016 16:05:42 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 X-Originating-IP: [10.182.7.39] X-G-Data-MailSecurity-for-Exchange-State: 0 X-G-Data-MailSecurity-for-Exchange-Error: 0 X-G-Data-MailSecurity-for-Exchange-Sender: 23 X-G-Data-MailSecurity-for-Exchange-Server: d65e63f7-5c15-413f-8f63-c0d707471c93 X-EXCLAIMER-MD-CONFIG: 2c86f778-e09b-4440-8b15-867914633a10 X-G-Data-MailSecurity-for-Exchange-Guid: 8AC90B00-B994-40DF-ABFA-DD124EA8E74D Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The FNLock state is not handled by the X1 tablet cover itself. There is the need to set the FNLock LED which actually enables the FNLock state of the cover. This means activating the FNLock LED will enable FNLock state and FNLock LED. --- drivers/hid/hid-lenovo.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/hid/hid-lenovo.c b/drivers/hid/hid-lenovo.c index 2efd5b0..3ace8c3 100644 --- a/drivers/hid/hid-lenovo.c +++ b/drivers/hid/hid-lenovo.c @@ -526,6 +526,29 @@ static void lenovo_led_brightness_set_tpx1cover(struct led_classdev *led_cdev, } } +static int lenovo_event_tpx1cover(struct hid_device *hdev, + struct hid_field *field, struct hid_usage *usage, __s32 value) +{ + int ret = 0; + + if (usage->hid == HID_CP_CONSUMERCONTROL) { + if (usage->usage_index == 8 && value == 1) { + struct lenovo_drvdata_tpx1cover *drv_data = hid_get_drvdata(hdev); + + if (drv_data && drv_data->led_present) { + drv_data->fnlock_state = lenovo_led_brightness_get_tpx1cover( + &drv_data->led_fnlock) == LED_OFF ? 1 : 0; + lenovo_led_brightness_set_tpx1cover( + &drv_data->led_fnlock, + drv_data->fnlock_state ? LED_FULL : LED_OFF); + } + } + + } + + return ret; +} + static int lenovo_event(struct hid_device *hdev, struct hid_field *field, struct hid_usage *usage, __s32 value) { @@ -533,6 +556,8 @@ static int lenovo_event(struct hid_device *hdev, struct hid_field *field, case USB_DEVICE_ID_LENOVO_CUSBKBD: case USB_DEVICE_ID_LENOVO_CBTKBD: return lenovo_event_cptkbd(hdev, field, usage, value); + case USB_DEVICE_ID_LENOVO_X1_COVER: + return lenovo_event_tpx1cover(hdev, field, usage, value); default: return 0; }