Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1960487imm; Thu, 21 Jun 2018 05:11:59 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLgCUcKr+seDMxL0lRMu6WwdO/DqrQpL3L2S3h9/DQynTvFrmqavf3PiD41gY4CH64a18cx X-Received: by 2002:a62:3ad8:: with SMTP id v85-v6mr27365371pfj.184.1529583119668; Thu, 21 Jun 2018 05:11:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529583119; cv=none; d=google.com; s=arc-20160816; b=OV+nCK/yHuZNsZpF+WtQqxSvBXh7rv9u8ZkJZwPiasR0crOriMysOOXvetJV0kgiPd l6g5VbfihoLZWLVSIqwE2UBfj++71B4jtRv0Ps8B5dX33r4ysFjIHPazuYREKj8Aa/H9 1a2gclVhjI7xCWyxQqcrn6SYzFJmNY1ybYMjBVRQKdhC7NTRrqQkF+ccVmCeiQq5e4qf 74FZnIlrs0qNIQjwpdonunJxJMgtBkfQ964mxauiizgpVVZwFmZ3kWtLYEopMwxH6P3U hj/XQEXjaiNXxcQhAL/g+gyD9oakXthJFjUatPhoOGIW1d3zqzxV0PB92/I9Un7f0Uqb 1o7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=cr96ZvXo/A9TltPB6orbe9qceZwEQj8Oc395cLnfkDU=; b=pZsJxBpkJVNdeDDl0zW0EyPEswG3oUmoBwv/+91/+faPSDxgf17L7qn5rnoLvyT7V+ ieEYE9XkktI9jf8d88DENYxDECuNmEiZ99w2YcnYKmRmeOgfCnwRTUxEK3yXOlEupnBs +tgGFdDKNf91C8BHdlE1d2r5romEZxXTYMdlx/NCPQGCbYLhdVki/RgisMwKiMcAP9/M ADx+U6rGQ76OODwBkH1caAtl88Pr+4tf/9jMyGcSaTCMBL7Voqr2EAC5Ke0xJvYnHzBb iEf6ZiFvIlP9OMB8xN4oI7Hhso7bQdn3KxRrGEaESOfWYBS+zyhRrqMFegXZOrV6TNyl 9+qA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h67-v6si4571719pfh.240.2018.06.21.05.11.45; Thu, 21 Jun 2018 05:11:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933624AbeFUMKb (ORCPT + 99 others); Thu, 21 Jun 2018 08:10:31 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:38990 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933199AbeFUMJ2 (ORCPT ); Thu, 21 Jun 2018 08:09:28 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6AFC44002248; Thu, 21 Jun 2018 12:09:27 +0000 (UTC) Received: from plouf.banquise.eu.com (ovpn-117-99.ams2.redhat.com [10.36.117.99]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2B1842026D6B; Thu, 21 Jun 2018 12:09:26 +0000 (UTC) From: Benjamin Tissoires To: Jiri Kosina , Dmitry Torokhov Cc: Mario.Limonciello@dell.com, Peter Hutterer , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Benjamin Tissoires Subject: [PATCH v3 09/12] HID: microsoft: support the Surface Dial Date: Thu, 21 Jun 2018 14:09:05 +0200 Message-Id: <20180621120908.16706-10-benjamin.tissoires@redhat.com> In-Reply-To: <20180621120908.16706-1-benjamin.tissoires@redhat.com> References: <20180621120908.16706-1-benjamin.tissoires@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Thu, 21 Jun 2018 12:09:27 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Thu, 21 Jun 2018 12:09:27 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'benjamin.tissoires@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The tool works nicely with hid-generic, but it ends up creating 9 different input nodes with most of them only having ABS_MISC set. Filter the axis out, which reduces the amount of devices to 2. One is the proper System Multi-axis collection, the other exported device seems to provide SLEEP and POWER Key, not sure how one can trigger those events though. Filtering the ABS_X and ABS_Y axes also prevents udev to detect this as a touchscreen. Signed-off-by: Benjamin Tissoires --- no changes in v2 no changes in v3 --- drivers/hid/hid-microsoft.c | 49 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 6 deletions(-) diff --git a/drivers/hid/hid-microsoft.c b/drivers/hid/hid-microsoft.c index 96e7d3231d2f..72d983626afd 100644 --- a/drivers/hid/hid-microsoft.c +++ b/drivers/hid/hid-microsoft.c @@ -22,12 +22,13 @@ #include "hid-ids.h" -#define MS_HIDINPUT 0x01 -#define MS_ERGONOMY 0x02 -#define MS_PRESENTER 0x04 -#define MS_RDESC 0x08 -#define MS_NOGET 0x10 -#define MS_DUPLICATE_USAGES 0x20 +#define MS_HIDINPUT BIT(0) +#define MS_ERGONOMY BIT(1) +#define MS_PRESENTER BIT(2) +#define MS_RDESC BIT(3) +#define MS_NOGET BIT(4) +#define MS_DUPLICATE_USAGES BIT(5) +#define MS_SURFACE_DIAL BIT(6) static __u8 *ms_report_fixup(struct hid_device *hdev, __u8 *rdesc, unsigned int *rsize) @@ -130,6 +131,30 @@ static int ms_presenter_8k_quirk(struct hid_input *hi, struct hid_usage *usage, return 1; } +static int ms_surface_dial_quirk(struct hid_input *hi, struct hid_field *field, + struct hid_usage *usage, unsigned long **bit, int *max) +{ + switch (usage->hid & HID_USAGE_PAGE) { + case 0xff070000: + /* fall-through */ + case HID_UP_DIGITIZER: + /* ignore those axis */ + return -1; + case HID_UP_GENDESK: + switch (usage->hid) { + case HID_GD_X: + /* fall-through */ + case HID_GD_Y: + /* fall-through */ + case HID_GD_RFKILL_BTN: + /* ignore those axis */ + return -1; + } + } + + return 0; +} + static int ms_input_mapping(struct hid_device *hdev, struct hid_input *hi, struct hid_field *field, struct hid_usage *usage, unsigned long **bit, int *max) @@ -146,6 +171,13 @@ static int ms_input_mapping(struct hid_device *hdev, struct hid_input *hi, ms_presenter_8k_quirk(hi, usage, bit, max)) return 1; + if (quirks & MS_SURFACE_DIAL) { + int ret = ms_surface_dial_quirk(hi, field, usage, bit, max); + + if (ret) + return ret; + } + return 0; } @@ -229,6 +261,9 @@ static int ms_probe(struct hid_device *hdev, const struct hid_device_id *id) if (quirks & MS_NOGET) hdev->quirks |= HID_QUIRK_NOGET; + if (quirks & MS_SURFACE_DIAL) + hdev->quirks |= HID_QUIRK_INPUT_PER_APP; + ret = hid_parse(hdev); if (ret) { hid_err(hdev, "parse failed\n"); @@ -281,6 +316,8 @@ static const struct hid_device_id ms_devices[] = { { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_BT), .driver_data = MS_PRESENTER }, + { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, 0x091B), + .driver_data = MS_SURFACE_DIAL }, { } }; MODULE_DEVICE_TABLE(hid, ms_devices); -- 2.14.3