From patchwork Thu Sep 7 19:17:28 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: 9942755 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 C2535602CC for ; Thu, 7 Sep 2017 19:17:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B824E1FF8F for ; Thu, 7 Sep 2017 19:17:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ABABD20121; Thu, 7 Sep 2017 19:17:50 +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 40CD11FF8F for ; Thu, 7 Sep 2017 19:17:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751634AbdIGTRs (ORCPT ); Thu, 7 Sep 2017 15:17:48 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:38866 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751424AbdIGTRs (ORCPT ); Thu, 7 Sep 2017 15:17:48 -0400 Received: by mail-wm0-f68.google.com with SMTP id x17so316741wmd.5; Thu, 07 Sep 2017 12:17:47 -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=W2BwN1KgLr42oCqLyPKB7YbOq0ZZaFwhMe5kY7invtQ=; b=qc4nJ1ItwkA5GnyeKfCCN6oW1+hXO8Jj3JInMTuqLAHZPhFYOkBznmjwJe74Wvi6sW nmW6SyZEf2ukhQWIQuO8nspihUEAvRqiCCAf0dk/bArvayRqXBNUBe5QEbpv997nhPUT i3GDf7LAxvagpK9uVApEjKCzwDkiZt/GlGGtOXHapIcYOtzfj/ibvxUpfjHeX/1sFQrn GL9b2nYvmhexLvvpN/GwHNcyK1l00a6wbRudVWPx77D7dIStF8zrQp0f59rlyBnSI1QS 3nzok3SuDiZiQ4q8Ny6ZM/gtYfNk798p1/PI+CpTpjfpmbMAvLddCzOhmUUMvH//S/KV 8/VQ== 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=W2BwN1KgLr42oCqLyPKB7YbOq0ZZaFwhMe5kY7invtQ=; b=tjw2IwvRIgg0QflVZATsl1ztocs93kf/6VGyY1q/eAOakqy7/oq3mLIuktRca3w/zG QRTD/7VLr+aPaaVyfFkT7XjaHcvoOpd1nrcFpfuYgeNMTBIVlRRaWNWAzmQYhi5/QFze pSO3C2ZsHk6WCsBQusxeLf5R3bU73Q3fzuN8+B/KVlk9alDk6DRh3F3IRjAQTamz95SM x0Gje4+GIGynCRdHj2/9q5vs/CY677FKJ4oMbZKP0XvwxhLwCcd/PHzKjI1wDnefxnu3 Yf/3kp2mjgj8+1UOg1Xjo1XeQcCTZumnvNB5HyHdnqkiyTZl4LW9ynzSmbe+c6vnZrlF v9bA== X-Gm-Message-State: AHPjjUjZ6s2WNK7umZ022RQAH9W7xFalg6iQnkut8yqf5mvj2AGjbrJo aFymJVeDstyjMQ== X-Google-Smtp-Source: AOwi7QCVDFufyYdQMjn8YRd1C2nclg5g4XZrYMjlchViBkfUK2XEIQVkCcOIJZ6ROcCYkFM8KXD7uw== X-Received: by 10.28.223.195 with SMTP id w186mr213520wmg.105.1504811866429; Thu, 07 Sep 2017 12:17:46 -0700 (PDT) Received: from typhoon.home (ARennes-651-1-168-229.w86-214.abo.wanadoo.fr. [86.214.175.229]) by smtp.gmail.com with ESMTPSA id y99sm599547wmh.1.2017.09.07.12.17.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 07 Sep 2017 12:17:45 -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 v2] HID: asus: Add support for Fn keys on Asus ROG G752 Date: Thu, 7 Sep 2017 21:17:28 +0200 Message-Id: <20170907191728.19018-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. Resent fix white space fixes 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 50c294be8324..9bc8a0f87e64 100644 --- a/drivers/hid/hid-asus.c +++ b/drivers/hid/hid-asus.c @@ -67,6 +67,7 @@ MODULE_DESCRIPTION("Asus HID Keyboard and TouchPad"); #define QUIRK_USE_KBD_BACKLIGHT BIT(5) #define QUIRK_T100_KEYBOARD BIT(6) #define QUIRK_T100CHI BIT(7) +#define QUIRK_G752_KEYBOARD BIT(8) #define I2C_KEYBOARD_QUIRKS (QUIRK_FIX_NOTEBOOK_REPORT | \ QUIRK_NO_INIT_REPORTS | \ @@ -670,6 +671,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) { @@ -708,6 +714,27 @@ static __u8 *asus_report_fixup(struct hid_device *hdev, __u8 *rdesc, rdesc[391] = 0xff; rdesc[402] = 0x00; } + 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; } @@ -721,6 +748,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 9bc91160819b..af31a68da616 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) }, @@ -3119,4 +3120,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 b397a14ab970..1b1fca0560f2 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h @@ -182,6 +182,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