From patchwork Sun Aug 20 12:58:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Maxime_Belleng=C3=A9?= X-Patchwork-Id: 9911137 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 7BF7B600C8 for ; Sun, 20 Aug 2017 12:58:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6BCAF2874C for ; Sun, 20 Aug 2017 12:58:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 602B1287BE; Sun, 20 Aug 2017 12:58:23 +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.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID 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 4F4512874C for ; Sun, 20 Aug 2017 12:58:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752844AbdHTM6U (ORCPT ); Sun, 20 Aug 2017 08:58:20 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:33242 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752843AbdHTM6T (ORCPT ); Sun, 20 Aug 2017 08:58:19 -0400 Received: by mail-wr0-f194.google.com with SMTP id 30so1069835wrk.0; Sun, 20 Aug 2017 05:58:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=3hdu2ck2y8WTxndJsPZB6pf+Cw+Aekr8xruLiyqgP1A=; b=Pz+UzpvAudyInMVc87pBKdAQ8sbYijJ2I6V5s9emtQ8jKl+onq4N2v739PrSp1UuoP aYt+/gPe/9WcmyXDXdwwi0vd6e/ARI63auSIzBNl6M9oEfYYL76yCdgRHu2U7xYex2ID RNACze8miyY8vef63ugW/I7zqDrPOYOObhMOqzcWqnatCBNsSWO+k2ro4k7z0VJGjjA8 iaggzT0ugtftKd7sAThWiQpQIRfbcUwAp/JJCNngIAdhummwnYXxb3vRBtvAjvlDGF6x 9gvXBDZksuKfZom69TYbo6iTzKE5qgo5myIlSjd/eel8FCKl0MpF04GCbDTy6ylBXPbg fHhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=3hdu2ck2y8WTxndJsPZB6pf+Cw+Aekr8xruLiyqgP1A=; b=Pkg8+2PygWU6HzutV0Z7ABAHor4v4iYplV2CG55Q8LxacB7bdLPUICFB8Q91IyLQgH 5hB5C/s3Cb3Ma9dEUvYPNpFyIdzvdm1TWt1hPaqV7i+cEFqbQQwQN4IMEPPwkb9f9wtq je0HudGTfhsoPQr9xDVma2LgbS1eWunRVsJWk4QZ5Xw3UiC5BLzs1q+dAKWSlEwO/F6i pzMNRCB3QSyvno04e9lI9jBWQQ5nk0EBDYNaPZ2DJ1wAOjmpx+Fsoe9OaOn6CS/KDSNA uUbSbm7dbTYcMH14V+0dKBri7reWONI0YBht7majyhO/LiuCZrkgcHxP4HUhYGUe8OXI ggHw== X-Gm-Message-State: AHYfb5i8qo0tmY1WPwiqrk5TaMqmIJMXfYE0zQcN2M/n4PluGhJrOjAy /2lgT1rwKct80g== X-Received: by 10.28.175.65 with SMTP id y62mr5196117wme.77.1503233897553; Sun, 20 Aug 2017 05:58:17 -0700 (PDT) Received: from typhoon.home (ARennes-651-1-296-206.w2-11.abo.wanadoo.fr. [2.11.175.206]) by smtp.gmail.com with ESMTPSA id e21sm6868077wme.17.2017.08.20.05.58.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 20 Aug 2017 05:58:16 -0700 (PDT) From: =?UTF-8?q?Maxime=20Belleng=C3=A9?= To: Jiri Kosina , Benjamin Tissoires , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Maxime=20Belleng=C3=A9?= Subject: [PATCH] HID: asus: Add support for Fn keys on Asus ROG G752 Date: Sun, 20 Aug 2017 14:58:14 +0200 Message-Id: <20170820125814.21641-1-maxime.bellenge@gmail.com> X-Mailer: git-send-email 2.13.5 MIME-Version: 1.0 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 This patch adds support for Fn keys on Asus ROG G752 laptop. The report descriptor is broken so I fixed it. Tested on an Asus G752VT. Signed-off-by: Maxime Bellengé Reviewed-by: Benjamin Tissoires --- drivers/hid/hid-asus.c | 29 +++++++++++++++++++++++++++++ drivers/hid/hid-core.c | 2 +- drivers/hid/hid-ids.h | 1 + 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c index a4a3c38bc145..2a03ed842186 100644 --- a/drivers/hid/hid-asus.c +++ b/drivers/hid/hid-asus.c @@ -70,6 +70,7 @@ MODULE_DESCRIPTION("Asus HID Keyboard and TouchPad"); #define QUIRK_NO_CONSUMER_USAGES BIT(4) #define QUIRK_USE_KBD_BACKLIGHT BIT(5) #define QUIRK_T100_KEYBOARD BIT(6) +#define QUIRK_G752_KEYBOARD BIT(7) #define I2C_KEYBOARD_QUIRKS (QUIRK_FIX_NOTEBOOK_REPORT | \ QUIRK_NO_INIT_REPORTS | \ @@ -568,6 +569,11 @@ static void asus_remove(struct hid_device *hdev) hid_hw_stop(hdev); } +static const __u8 asus_g752_fixed_rdesc[] = { + 0x19, 0x00, /* Usage Minimum (0x00) */ + 0x2A, 0xFF, 0x00, /* Usage Maximum (0xFF) */ +}; + static __u8 *asus_report_fixup(struct hid_device *hdev, __u8 *rdesc, unsigned int *rsize) { @@ -583,6 +589,27 @@ static __u8 *asus_report_fixup(struct hid_device *hdev, __u8 *rdesc, hid_info(hdev, "Fixing up Asus T100 keyb report descriptor\n"); rdesc[74] &= ~HID_MAIN_ITEM_CONSTANT; } + if (drvdata->quirks & QUIRK_G752_KEYBOARD && + *rsize == 75 && rdesc[61] == 0x15 && rdesc[62] == 0x00) { + /* report is missing usage mninum and maximum */ + __u8 *new_rdesc; + size_t new_size = *rsize + sizeof(asus_g752_fixed_rdesc); + + new_rdesc = devm_kzalloc(&hdev->dev, new_size, GFP_KERNEL); + if (new_rdesc == NULL) + return rdesc; + + hid_info(hdev, "Fixing up Asus G752 keyb report descriptor\n"); + /* copy the valid part */ + memcpy(new_rdesc, rdesc, 61); + /* insert missing part */ + memcpy(new_rdesc + 61, asus_g752_fixed_rdesc, sizeof(asus_g752_fixed_rdesc)); + /* copy remaining data */ + memcpy(new_rdesc + 61 + sizeof(asus_g752_fixed_rdesc), rdesc + 61, *rsize - 61); + + *rsize = new_size; + rdesc = new_rdesc; + } return rdesc; } @@ -596,6 +623,8 @@ static const struct hid_device_id asus_devices[] = { USB_DEVICE_ID_ASUSTEK_ROG_KEYBOARD1) }, { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_ROG_KEYBOARD2), QUIRK_USE_KBD_BACKLIGHT }, + { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, + USB_DEVICE_ID_ASUSTEK_ROG_KEYBOARD3), QUIRK_G752_KEYBOARD }, { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_T100_KEYBOARD), QUIRK_T100_KEYBOARD | QUIRK_NO_CONSUMER_USAGES }, diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 9017dcc14502..45369f5dad6e 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -1979,6 +1979,7 @@ static const struct hid_device_id hid_have_special_driver[] = { { HID_I2C_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_I2C_TOUCHPAD) }, { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_ROG_KEYBOARD1) }, { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_ROG_KEYBOARD2) }, + { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_ROG_KEYBOARD3) }, { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_T100_KEYBOARD) }, { HID_USB_DEVICE(USB_VENDOR_ID_JESS, USB_DEVICE_ID_ASUS_MD_5112) }, { HID_USB_DEVICE(USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_ASUS_MD_5110) }, @@ -3125,4 +3126,3 @@ MODULE_AUTHOR("Andreas Gal"); MODULE_AUTHOR("Vojtech Pavlik"); MODULE_AUTHOR("Jiri Kosina"); MODULE_LICENSE("GPL"); - diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index c9ba4c6db74c..602409663743 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h @@ -180,6 +180,7 @@ #define USB_DEVICE_ID_ASUSTEK_I2C_TOUCHPAD 0x0101 #define USB_DEVICE_ID_ASUSTEK_ROG_KEYBOARD1 0x1854 #define USB_DEVICE_ID_ASUSTEK_ROG_KEYBOARD2 0x1837 +#define USB_DEVICE_ID_ASUSTEK_ROG_KEYBOARD3 0x1822 #define USB_VENDOR_ID_ATEN 0x0557 #define USB_DEVICE_ID_ATEN_UC100KM 0x2004