From patchwork Wed Mar 8 23:31:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matjaz Hegedic X-Patchwork-Id: 9612183 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 B541560414 for ; Thu, 9 Mar 2017 01:32:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8B9A728643 for ; Thu, 9 Mar 2017 01:32:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7ECBB28646; Thu, 9 Mar 2017 01:32:56 +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 ECE5428643 for ; Thu, 9 Mar 2017 01:32:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754763AbdCIBcr (ORCPT ); Wed, 8 Mar 2017 20:32:47 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:35006 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754766AbdCIBcp (ORCPT ); Wed, 8 Mar 2017 20:32:45 -0500 Received: by mail-wm0-f68.google.com with SMTP id z63so8690885wmg.2 for ; Wed, 08 Mar 2017 17:32:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=HrOOQ+I2YFDnhD/irfSosGxsqEFLdW5WHtnnRUVd3n4=; b=ZPNlSX+pHicokJ009GiM5uYEgrI4klhezdKUsW1WmGbtIzrCTFSDb1DXiVe3r9OCp5 ZxHLpcdb5ozG8zkF60lvEldlr0OWKlPZCTf9HwLxKNf8AeHTTYHzaYoAKig5JRdIaWip 8uCP0PbisITRRysY/GHXCJhQILQm872RLJAxtNjYISM/fpxffmTaOuAsi5VLzEBpgcgR XB+LmPh4YAQLRLmuM8voAZ741p/52hTl617JlSH8AqSFH8J62U8tMp3JqwudlZzY0Gu4 E5DrXFez8FXAdx4VwtcMyxHZLkus+Bh6K1yGD7jm6VV/Hgv1816bcF6ygCxUGji4PvJp P0DQ== 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; bh=HrOOQ+I2YFDnhD/irfSosGxsqEFLdW5WHtnnRUVd3n4=; b=szS+S2X5kkVWqe0Q8IGY383VskhmimJh2aDGrC+anZxwTQzl3ILb0S9X3NMCAjwt8C bMKtQN3BWo61bE5pldPDrJiwgfMPIbzBJll+FZnIU5nFg9Pymgmi/E4txkhsa58Mt3nl WhRkL4iJQGBiDLmDrfisB3hsCpc2inCEhGVbtDlM8GnoUNt4vtoYZAl9cKNQTWmRZ2/e KxyaEygNR4321ThPiJFt2800jhC2jJxZct+VvvRd/M7fBdj3h8jlGnVBB7WHEFyP8rG+ JlXUWC2E9RDF2MyJ23rMMb3ga+g4Fk/CtZ3QCIwfjJ+y6uqkXv3KbiExSUgxCZteNGd2 abhw== X-Gm-Message-State: AMke39npkrDpe4ipkbqC9TSFY/zkdBUltp3davfglEXyCp4g4DZgCh7tmupzAR0itMyy/A== X-Received: by 10.28.84.18 with SMTP id i18mr8249655wmb.12.1489015889852; Wed, 08 Mar 2017 15:31:29 -0800 (PST) Received: from X205TA.upc.at (213-47-29-34.cable.dynamic.surfer.at. [213.47.29.34]) by smtp.gmail.com with ESMTPSA id x23sm6010430wrb.49.2017.03.08.15.31.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 08 Mar 2017 15:31:28 -0800 (PST) From: Matjaz Hegedic To: jikos@kernel.org Cc: benjamin.tissoires@redhat.com, linux-input@vger.kernel.org, Matjaz Hegedic Subject: [PATCH v2 1/3] HID: asus: fix and generalize ambiguous preprocessor macros Date: Thu, 9 Mar 2017 00:31:13 +0100 Message-Id: <1489015875-3558-1-git-send-email-matjaz.hegedic@gmail.com> X-Mailer: git-send-email 2.7.4 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 Before commits a1cbda7a65a7a ("HID: asus: drop dependency on I2C_HID") and 64a403c6555fd ("HID: asus: support Republic Of Gamers special keys") hid-asus only pertained to a single I2C keyboard model found in ASUS X205TA, F205TA, & X200HA. The aforementioned commits expanded this support to other ASUS laptop keyboard models. In order to clarify that existing keyboard and touchpad quirks only apply to the I2C devices, and not ASUS keyboards in general, I2C HID IDs and their corresponding quirk sets have been renamed. In addition, the latter commit introduced special key handling, which also applies to the I2C keyboard, not just Republic of Gamers series. Therefore, the rog_map_key_clear() macro is renamed to asus_map_key_clear() for the sake of generality. Signed-off-by: Matjaz Hegedic --- drivers/hid/hid-asus.c | 38 +++++++++++++++++++------------------- drivers/hid/hid-core.c | 4 ++-- drivers/hid/hid-ids.h | 4 ++-- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c index 5bae6ff..20fe97f 100644 --- a/drivers/hid/hid-asus.c +++ b/drivers/hid/hid-asus.c @@ -64,9 +64,9 @@ MODULE_DESCRIPTION("Asus HID Keyboard and TouchPad"); #define QUIRK_SKIP_INPUT_MAPPING BIT(2) #define QUIRK_IS_MULTITOUCH BIT(3) -#define KEYBOARD_QUIRKS (QUIRK_FIX_NOTEBOOK_REPORT | \ +#define I2C_KEYBOARD_QUIRKS (QUIRK_FIX_NOTEBOOK_REPORT | \ QUIRK_NO_INIT_REPORTS) -#define TOUCHPAD_QUIRKS (QUIRK_NO_INIT_REPORTS | \ +#define I2C_TOUCHPAD_QUIRKS (QUIRK_NO_INIT_REPORTS | \ QUIRK_SKIP_INPUT_MAPPING | \ QUIRK_IS_MULTITOUCH) @@ -199,7 +199,7 @@ static int asus_input_configured(struct hid_device *hdev, struct hid_input *hi) return 0; } -#define rog_map_key_clear(c) hid_map_usage_clear(hi, usage, bit, \ +#define asus_map_key_clear(c) hid_map_usage_clear(hi, usage, bit, \ max, EV_KEY, (c)) static int asus_input_mapping(struct hid_device *hdev, struct hid_input *hi, struct hid_field *field, @@ -215,31 +215,31 @@ static int asus_input_mapping(struct hid_device *hdev, return -1; } - /* ASUS Republic of Gamers laptop keyboard hotkeys */ + /* ASUS-specific keyboard hotkeys */ if ((usage->hid & HID_USAGE_PAGE) == 0xff310000) { set_bit(EV_REP, hi->input->evbit); switch (usage->hid & HID_USAGE) { - case 0x10: rog_map_key_clear(KEY_BRIGHTNESSDOWN); break; - case 0x20: rog_map_key_clear(KEY_BRIGHTNESSUP); break; - case 0x35: rog_map_key_clear(KEY_DISPLAY_OFF); break; - case 0x6c: rog_map_key_clear(KEY_SLEEP); break; - case 0x82: rog_map_key_clear(KEY_CAMERA); break; - case 0x88: rog_map_key_clear(KEY_WLAN); break; - case 0xb5: rog_map_key_clear(KEY_CALC); break; - case 0xc4: rog_map_key_clear(KEY_KBDILLUMUP); break; - case 0xc5: rog_map_key_clear(KEY_KBDILLUMDOWN); break; + case 0x10: asus_map_key_clear(KEY_BRIGHTNESSDOWN); break; + case 0x20: asus_map_key_clear(KEY_BRIGHTNESSUP); break; + case 0x35: asus_map_key_clear(KEY_DISPLAY_OFF); break; + case 0x6c: asus_map_key_clear(KEY_SLEEP); break; + case 0x82: asus_map_key_clear(KEY_CAMERA); break; + case 0x88: asus_map_key_clear(KEY_WLAN); break; + case 0xb5: asus_map_key_clear(KEY_CALC); break; + case 0xc4: asus_map_key_clear(KEY_KBDILLUMUP); break; + case 0xc5: asus_map_key_clear(KEY_KBDILLUMDOWN); break; /* ASUS touchpad toggle */ - case 0x6b: rog_map_key_clear(KEY_F21); break; + case 0x6b: asus_map_key_clear(KEY_F21); break; /* ROG key */ - case 0x38: rog_map_key_clear(KEY_PROG1); break; + case 0x38: asus_map_key_clear(KEY_PROG1); break; /* Fn+C ASUS Splendid */ - case 0xba: rog_map_key_clear(KEY_PROG2); break; + case 0xba: asus_map_key_clear(KEY_PROG2); break; /* Fn+Space Power4Gear Hybrid */ - case 0x5c: rog_map_key_clear(KEY_PROG3); break; + case 0x5c: asus_map_key_clear(KEY_PROG3); break; default: return 0; @@ -354,9 +354,9 @@ static __u8 *asus_report_fixup(struct hid_device *hdev, __u8 *rdesc, static const struct hid_device_id asus_devices[] = { { HID_I2C_DEVICE(USB_VENDOR_ID_ASUSTEK, - USB_DEVICE_ID_ASUSTEK_NOTEBOOK_KEYBOARD), KEYBOARD_QUIRKS}, + USB_DEVICE_ID_ASUSTEK_I2C_KEYBOARD), I2C_KEYBOARD_QUIRKS}, { HID_I2C_DEVICE(USB_VENDOR_ID_ASUSTEK, - USB_DEVICE_ID_ASUSTEK_TOUCHPAD), TOUCHPAD_QUIRKS }, + USB_DEVICE_ID_ASUSTEK_I2C_TOUCHPAD), I2C_TOUCHPAD_QUIRKS }, { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_ROG_KEYBOARD1) }, { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index bbc3c3b..6298675 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -1852,8 +1852,8 @@ static const struct hid_device_id hid_have_special_driver[] = { { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_ANSI) }, { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) }, { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) }, - { HID_I2C_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_NOTEBOOK_KEYBOARD) }, - { HID_I2C_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_TOUCHPAD) }, + { HID_I2C_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_I2C_KEYBOARD) }, + { 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_AUREAL, USB_DEVICE_ID_AUREAL_W01RN) }, diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index ea5b968..e267a95 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h @@ -173,8 +173,8 @@ #define USB_VENDOR_ID_ASUSTEK 0x0b05 #define USB_DEVICE_ID_ASUSTEK_LCM 0x1726 #define USB_DEVICE_ID_ASUSTEK_LCM2 0x175b -#define USB_DEVICE_ID_ASUSTEK_NOTEBOOK_KEYBOARD 0x8585 -#define USB_DEVICE_ID_ASUSTEK_TOUCHPAD 0x0101 +#define USB_DEVICE_ID_ASUSTEK_I2C_KEYBOARD 0x8585 +#define USB_DEVICE_ID_ASUSTEK_I2C_TOUCHPAD 0x0101 #define USB_DEVICE_ID_ASUSTEK_ROG_KEYBOARD1 0x1854 #define USB_DEVICE_ID_ASUSTEK_ROG_KEYBOARD2 0x1837