From patchwork Wed Mar 8 23:31:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matjaz Hegedic X-Patchwork-Id: 9612109 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 371386016C for ; Wed, 8 Mar 2017 23:39:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 28B4128633 for ; Wed, 8 Mar 2017 23:39:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1B7B128640; Wed, 8 Mar 2017 23:39:49 +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 BEE0028633 for ; Wed, 8 Mar 2017 23:39:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754376AbdCHXjb (ORCPT ); Wed, 8 Mar 2017 18:39:31 -0500 Received: from mail-wr0-f193.google.com ([209.85.128.193]:35373 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753348AbdCHXjE (ORCPT ); Wed, 8 Mar 2017 18:39:04 -0500 Received: by mail-wr0-f193.google.com with SMTP id u108so5985209wrb.2 for ; Wed, 08 Mar 2017 15:38:17 -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:in-reply-to:references; bh=VgC9d31GNiDdhRtPhf1UeKREOiiExEOgYnH8A7wdxWU=; b=Va7pOOO6r3fZcD32/Yi/5uFt6oj7qwjbHvYDHoq6H9Qq9vQD4Fi50+kyUMwZzymyFY aFA7FrmW7dvdQ57TSihEiDr3Eu+H8yxkkp3ZpePNZ40njAfTSQhhfZR770k1o5KMDr+P fimmpqj74277i3K08fXyq1nzbm3Jz97sZqfXeszZtGj9v70ltId37uLIqPZzSKkKT5zm vsa6QUV8CIbM9Wq1tVYXgn+IxR35Xzrf0WyfqK1f/tYgBexaoepfqB2eCOMUadgIVRhR kfg6+DjwtxuF3/Q89lyzvwWoBwLHUPpleM1XwHQfEMFBK3We1NviJUdT7kVsY2t6zCbV sH6w== 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:in-reply-to :references; bh=VgC9d31GNiDdhRtPhf1UeKREOiiExEOgYnH8A7wdxWU=; b=TuFqeeybkWCxvaiXyEZrqqwfOjeMwiuSMnEFXkKPK04fZYVsrRN48iPl992nj60fWq Yy5xqqRMP1sJQvYl7QgaoBOKSE+Eq06+JaqZjEGwcNf6czKMAfsOrbqzTi/h+FnULKlX 0YnqQIVu0ffoFTtYgM32X13l9OSeDdCm54QUzuiq5oT9h5Qe8HZQd/W6t9jOhwdFmaVT WZsls0IOlq6Oo6sdYlyb2GeEdq11dUCTDeSaxWiwKiSqec7ubVwUY7+9JJgu7wT5gtRf +fEwxHc1aUzy8L1zG15QJhNtFnwf/etTEMiY8mvBwjjpbMybIbBzWWPJ/Qa6i1xU9Yvb FGCA== X-Gm-Message-State: AMke39lEvEkqrEkLwoL0PAemNbX0PXPL/bLa3uxCXCwQA4frqriAFmkBSxtL+Qr+7bz+cQ== X-Received: by 10.223.164.201 with SMTP id h9mr7274026wrb.175.1489015902330; Wed, 08 Mar 2017 15:31:42 -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.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 08 Mar 2017 15:31:41 -0800 (PST) From: Matjaz Hegedic To: jikos@kernel.org Cc: benjamin.tissoires@redhat.com, linux-input@vger.kernel.org, Matjaz Hegedic Subject: [PATCH v2 2/3] HID: asus: ignore declared dummy usages Date: Thu, 9 Mar 2017 00:31:14 +0100 Message-Id: <1489015875-3558-2-git-send-email-matjaz.hegedic@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1489015875-3558-1-git-send-email-matjaz.hegedic@gmail.com> References: <1489015875-3558-1-git-send-email-matjaz.hegedic@gmail.com> 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 Keyboards handled by hid-asus declare special key functions using a vendor-specific page, however, alongside legitimate key functions, dummy usages with seemingly arbitrary values are also declared and can lead to keyboards being detected as pointer devices by some software (such as X.org). In addition, for the I2C keyboard volume controls are separately declared in a Consumer Usage page, with the same dummy usage problem. The fix in 1989dada7ce0 ("HID: input: ignore System Control application usages if not System Controls") does not mitigate the problem described above, therefore dummy usages need to be ignored in the driver itself. This fix properly ignores dummy usages and introduces a quirk for custom handling of the Consumer Usages on the I2C keyboard. Signed-off-by: Matjaz Hegedic --- drivers/hid/hid-asus.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c index 20fe97f..e0de54b 100644 --- a/drivers/hid/hid-asus.c +++ b/drivers/hid/hid-asus.c @@ -63,9 +63,11 @@ MODULE_DESCRIPTION("Asus HID Keyboard and TouchPad"); #define QUIRK_NO_INIT_REPORTS BIT(1) #define QUIRK_SKIP_INPUT_MAPPING BIT(2) #define QUIRK_IS_MULTITOUCH BIT(3) +#define QUIRK_NO_CONSUMER_USAGES BIT(4) #define I2C_KEYBOARD_QUIRKS (QUIRK_FIX_NOTEBOOK_REPORT | \ - QUIRK_NO_INIT_REPORTS) + QUIRK_NO_INIT_REPORTS | \ + QUIRK_NO_CONSUMER_USAGES) #define I2C_TOUCHPAD_QUIRKS (QUIRK_NO_INIT_REPORTS | \ QUIRK_SKIP_INPUT_MAPPING | \ QUIRK_IS_MULTITOUCH) @@ -242,11 +244,28 @@ static int asus_input_mapping(struct hid_device *hdev, case 0x5c: asus_map_key_clear(KEY_PROG3); break; default: - return 0; + /* ASUS lazily declares 256 usages, ignore the rest, + * as some make the keyboard appear as a pointer device. */ + return -1; } return 1; } + if (drvdata->quirks & QUIRK_NO_CONSUMER_USAGES && + (usage->hid & HID_USAGE_PAGE) == HID_UP_CONSUMER) { + switch (usage->hid & HID_USAGE) { + case 0xe2: /* Mute */ + case 0xe9: /* Volume up */ + case 0xea: /* Volume down */ + return 0; + default: + /* Ignore dummy Consumer usages which make the + * keyboard incorrectly appear as a pointer device. + */ + return -1; + } + } + return 0; }