Skip to content

Commit 1a3f83f

Browse files
jdcoleJiri Kosina
authored andcommitted
HID: plantronics: fix errant mouse events
This version of the driver prevents Telephony pages which are not mapped as Consumer Control applications AND are not on the Consumer Page from being registered by the hid-input driver. Signed-off-by: JD Cole <[email protected]> Reviewed-by: Dmitry Torokhov <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 7f474df commit 1a3f83f

File tree

6 files changed

+92
-0
lines changed

6 files changed

+92
-0
lines changed

drivers/hid/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,13 @@ config HID_PICOLCD_CIR
613613
---help---
614614
Provide access to PicoLCD's CIR interface via remote control (LIRC).
615615

616+
config HID_PLANTRONICS
617+
tristate "Plantronics USB HID Driver"
618+
default !EXPERT
619+
depends on HID
620+
---help---
621+
Provides HID support for Plantronics telephony devices.
622+
616623
config HID_PRIMAX
617624
tristate "Primax non-fully HID-compliant devices"
618625
depends on HID

drivers/hid/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ ifdef CONFIG_DEBUG_FS
9494
hid-picolcd-y += hid-picolcd_debugfs.o
9595
endif
9696

97+
obj-$(CONFIG_HID_PLANTRONICS) += hid-plantronics.o
9798
obj-$(CONFIG_HID_PRIMAX) += hid-primax.o
9899
obj-$(CONFIG_HID_ROCCAT) += hid-roccat.o hid-roccat-common.o \
99100
hid-roccat-arvo.o hid-roccat-isku.o hid-roccat-kone.o \

drivers/hid/hid-core.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1886,6 +1886,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
18861886
{ HID_USB_DEVICE(USB_VENDOR_ID_ORTEK, USB_DEVICE_ID_ORTEK_WKB2000) },
18871887
{ HID_USB_DEVICE(USB_VENDOR_ID_PENMOUNT, USB_DEVICE_ID_PENMOUNT_6000) },
18881888
{ HID_USB_DEVICE(USB_VENDOR_ID_PETALYNX, USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE) },
1889+
{ HID_USB_DEVICE(USB_VENDOR_ID_PLANTRONICS, HID_ANY_ID) },
18891890
{ HID_USB_DEVICE(USB_VENDOR_ID_PRIMAX, USB_DEVICE_ID_PRIMAX_KEYBOARD) },
18901891
#if IS_ENABLED(CONFIG_HID_ROCCAT)
18911892
{ HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_ARVO) },

drivers/hid/hid-ids.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,8 @@
715715
#define USB_DEVICE_ID_ORTEK_PKB1700 0x1700
716716
#define USB_DEVICE_ID_ORTEK_WKB2000 0x2000
717717

718+
#define USB_VENDOR_ID_PLANTRONICS 0x047f
719+
718720
#define USB_VENDOR_ID_PANASONIC 0x04da
719721
#define USB_DEVICE_ID_PANABOARD_UBT780 0x1044
720722
#define USB_DEVICE_ID_PANABOARD_UBT880 0x104d

drivers/hid/hid-plantronics.c

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/*
2+
* Plantronics USB HID Driver
3+
*
4+
* Copyright (c) 2014 JD Cole <[email protected]>
5+
* Copyright (c) 2014 Terry Junge <[email protected]>
6+
*/
7+
8+
/*
9+
* This program is free software; you can redistribute it and/or modify it
10+
* under the terms of the GNU General Public License as published by the Free
11+
* Software Foundation; either version 2 of the License, or (at your option)
12+
* any later version.
13+
*/
14+
15+
#include "hid-ids.h"
16+
17+
#include <linux/hid.h>
18+
#include <linux/module.h>
19+
20+
static int plantronics_input_mapping(struct hid_device *hdev,
21+
struct hid_input *hi,
22+
struct hid_field *field,
23+
struct hid_usage *usage,
24+
unsigned long **bit, int *max)
25+
{
26+
if (field->application == HID_CP_CONSUMERCONTROL
27+
&& (usage->hid & HID_USAGE_PAGE) == HID_UP_CONSUMER) {
28+
hid_dbg(hdev, "usage: %08x (appl: %08x) - defaulted\n",
29+
usage->hid, field->application);
30+
return 0;
31+
}
32+
33+
hid_dbg(hdev, "usage: %08x (appl: %08x) - ignored\n",
34+
usage->hid, field->application);
35+
36+
return -1;
37+
}
38+
39+
static int plantronics_probe(struct hid_device *hdev,
40+
const struct hid_device_id *id)
41+
{
42+
int ret;
43+
44+
ret = hid_parse(hdev);
45+
if (ret) {
46+
hid_err(hdev, "parse failed\n");
47+
goto err;
48+
}
49+
50+
ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
51+
if (ret) {
52+
hid_err(hdev, "hw start failed\n");
53+
goto err;
54+
}
55+
56+
return 0;
57+
err:
58+
return ret;
59+
}
60+
61+
static const struct hid_device_id plantronics_devices[] = {
62+
{ HID_USB_DEVICE(USB_VENDOR_ID_PLANTRONICS, HID_ANY_ID) },
63+
{ }
64+
};
65+
MODULE_DEVICE_TABLE(hid, plantronics_devices);
66+
67+
static struct hid_driver plantronics_driver = {
68+
.name = "plantronics",
69+
.id_table = plantronics_devices,
70+
.input_mapping = plantronics_input_mapping,
71+
.probe = plantronics_probe,
72+
};
73+
module_hid_driver(plantronics_driver);
74+
75+
MODULE_AUTHOR("JD Cole <[email protected]>");
76+
MODULE_AUTHOR("Terry Junge <[email protected]>");
77+
MODULE_DESCRIPTION("Plantronics USB HID Driver");
78+
MODULE_LICENSE("GPL");

include/linux/hid.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,9 @@ struct hid_item {
234234
#define HID_DG_BARRELSWITCH 0x000d0044
235235
#define HID_DG_ERASER 0x000d0045
236236
#define HID_DG_TABLETPICK 0x000d0046
237+
238+
#define HID_CP_CONSUMERCONTROL 0x000c0001
239+
237240
#define HID_DG_CONFIDENCE 0x000d0047
238241
#define HID_DG_WIDTH 0x000d0048
239242
#define HID_DG_HEIGHT 0x000d0049

0 commit comments

Comments
 (0)