From patchwork Fri Sep 1 12:43:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: nolsen@jabra.com X-Patchwork-Id: 9934051 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 CADA360309 for ; Fri, 1 Sep 2017 12:50:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B862A28644 for ; Fri, 1 Sep 2017 12:50:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AD20528650; Fri, 1 Sep 2017 12:50:20 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 19CA828644 for ; Fri, 1 Sep 2017 12:50:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751914AbdIAMuT (ORCPT ); Fri, 1 Sep 2017 08:50:19 -0400 Received: from prime.nsonet.eu ([178.63.75.197]:44251 "EHLO prime.nsonet.eu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751839AbdIAMuT (ORCPT ); Fri, 1 Sep 2017 08:50:19 -0400 X-Greylist: delayed 346 seconds by postgrey-1.27 at vger.kernel.org; Fri, 01 Sep 2017 08:50:18 EDT Received: from localhost.localdomain (77.241.134.208.mobile.3.dk [77.241.134.208]) by prime.nsonet.eu (Postfix) with ESMTPA id 2FCDA20628A3; Fri, 1 Sep 2017 14:44:30 +0200 (CEST) From: nolsen@jabra.com To: linux-input@vger.kernel.org Cc: jikos@kernel.org, benjamin.tissoires@redhat.com, dmitry.torokhov@gmail.com, Niels Skou Olsen Subject: [PATCH] HID: Add special driver for Jabra devices Date: Fri, 1 Sep 2017 14:43:52 +0200 Message-Id: <1504269832-23142-1-git-send-email-nolsen@jabra.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 From: Niels Skou Olsen Add a hid-jabra driver to the list of special drivers in hid-core. The driver prevents vendor defined HID usages (FF00-FFFF) in Jabra devices from being mapped to input events that become unintended mouse events in the X11 server. Signed-off-by: Niels Skou Olsen --- drivers/hid/Kconfig | 11 ++++++++++ drivers/hid/Makefile | 1 + drivers/hid/hid-core.c | 3 +++ drivers/hid/hid-jabra.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 73 insertions(+) create mode 100644 drivers/hid/hid-jabra.c diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig index 0a3117c..d9d2843 100644 --- a/drivers/hid/Kconfig +++ b/drivers/hid/Kconfig @@ -395,6 +395,17 @@ config HID_ITE ---help--- Support for ITE devices not fully compliant with HID standard. +config HID_JABRA + tristate "Jabra USB HID Driver" + depends on HID + ---help--- + Support for Jabra USB HID devices. + + Prevents mapping of vendor defined HID usages to input events. Without + this driver HID reports from Jabra devices may incorrectly be seen as + mouse button events. + Say M here if you may ever plug in a Jabra USB device. + config HID_TWINHAN tristate "Twinhan IR remote control" depends on HID diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile index 8659d7e..d2563e5 100644 --- a/drivers/hid/Makefile +++ b/drivers/hid/Makefile @@ -51,6 +51,7 @@ obj-$(CONFIG_HID_HOLTEK) += hid-holtekff.o obj-$(CONFIG_HID_HYPERV_MOUSE) += hid-hyperv.o obj-$(CONFIG_HID_ICADE) += hid-icade.o obj-$(CONFIG_HID_ITE) += hid-ite.o +obj-$(CONFIG_HID_JABRA) += hid-jabra.o obj-$(CONFIG_HID_KENSINGTON) += hid-kensington.o obj-$(CONFIG_HID_KEYTOUCH) += hid-keytouch.o obj-$(CONFIG_HID_KYE) += hid-kye.o diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 9bc9116..0603012 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -2077,6 +2077,9 @@ static const struct hid_device_id hid_have_special_driver[] = { #if IS_ENABLED(CONFIG_HID_ITE) { HID_USB_DEVICE(USB_VENDOR_ID_ITE, USB_DEVICE_ID_ITE8595) }, #endif +#if IS_ENABLED(CONFIG_HID_JABRA) + { HID_USB_DEVICE(USB_VENDOR_ID_JABRA, HID_ANY_ID) }, +#endif #if IS_ENABLED(CONFIG_HID_KENSINGTON) { HID_USB_DEVICE(USB_VENDOR_ID_KENSINGTON, USB_DEVICE_ID_KS_SLIMBLADE) }, #endif diff --git a/drivers/hid/hid-jabra.c b/drivers/hid/hid-jabra.c new file mode 100644 index 0000000..1f52daf --- /dev/null +++ b/drivers/hid/hid-jabra.c @@ -0,0 +1,58 @@ +/* + * Jabra USB HID Driver + * + * Copyright (c) 2017 Niels Skou Olsen + */ + +/* + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + */ + +#include +#include + +#include "hid-ids.h" + +#define HID_UP_VENDOR_DEFINED_MIN 0xff000000 +#define HID_UP_VENDOR_DEFINED_MAX 0xffff0000 + +static int jabra_input_mapping(struct hid_device *hdev, + struct hid_input *hi, + struct hid_field *field, + struct hid_usage *usage, + unsigned long **bit, int *max) +{ + int is_vendor_defined = + ((usage->hid & HID_USAGE_PAGE) >= HID_UP_VENDOR_DEFINED_MIN && + (usage->hid & HID_USAGE_PAGE) <= HID_UP_VENDOR_DEFINED_MAX); + + dbg_hid("hid=0x%08x appl=0x%08x coll_idx=0x%02x usage_idx=0x%02x: %s\n", + usage->hid, + field->application, + usage->collection_index, + usage->usage_index, + is_vendor_defined ? "ignored" : "defaulted"); + + /* Ignore vendor defined usages, default map standard usages */ + return is_vendor_defined ? -1 : 0; +} + +static const struct hid_device_id jabra_devices[] = { + { HID_USB_DEVICE(USB_VENDOR_ID_JABRA, HID_ANY_ID) }, + { } +}; +MODULE_DEVICE_TABLE(hid, jabra_devices); + +static struct hid_driver jabra_driver = { + .name = "jabra", + .id_table = jabra_devices, + .input_mapping = jabra_input_mapping, +}; +module_hid_driver(jabra_driver); + +MODULE_AUTHOR("Niels Skou Olsen "); +MODULE_DESCRIPTION("Jabra USB HID Driver"); +MODULE_LICENSE("GPL");