From d610274b0301e5ef35811fa736036d022f707564 Mon Sep 17 00:00:00 2001 From: Benjamin Tissoires Date: Tue, 30 Sep 2014 13:18:25 -0400 Subject: HID: logitech-dj: rely on hid groups to separate receivers from dj devices Several benefits here: - we can drop the macro is_dj_device: I never been really conviced by this macro as we could fall into a null pointer anytime. Anyway time showed that this never happened. - we can simplify the hid driver logitech-djdevice, and make it aware of any new receiver VID/PID. - we can use the Wireless PID of the DJ device as the product id of the hid device, this way the sysfs will differentiate between different DJ devices. Signed-off-by: Benjamin Tisssoires Tested-by: Andrew de los Reyes Signed-off-by: Jiri Kosina --- include/linux/hid.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include/linux/hid.h') diff --git a/include/linux/hid.h b/include/linux/hid.h index 5b1ff6110e25..7d6e0556302a 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -313,6 +313,7 @@ struct hid_item { */ #define HID_GROUP_RMI 0x0100 #define HID_GROUP_WACOM 0x0101 +#define HID_GROUP_LOGITECH_DJ_DEVICE 0x0102 /* * This is the global environment of the parser. This information is -- cgit v1.2.3 From 1a3f83f6493f9d78aa0fe31401fd530b0fe296da Mon Sep 17 00:00:00 2001 From: JD Cole Date: Fri, 31 Oct 2014 17:34:42 -0700 Subject: 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 Reviewed-by: Dmitry Torokhov Signed-off-by: Jiri Kosina --- drivers/hid/Kconfig | 7 ++++ drivers/hid/Makefile | 1 + drivers/hid/hid-core.c | 1 + drivers/hid/hid-ids.h | 2 ++ drivers/hid/hid-plantronics.c | 78 +++++++++++++++++++++++++++++++++++++++++++ include/linux/hid.h | 3 ++ 6 files changed, 92 insertions(+) create mode 100644 drivers/hid/hid-plantronics.c (limited to 'include/linux/hid.h') diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig index f42df4dd58d2..bf1c74e19c75 100644 --- a/drivers/hid/Kconfig +++ b/drivers/hid/Kconfig @@ -613,6 +613,13 @@ config HID_PICOLCD_CIR ---help--- Provide access to PicoLCD's CIR interface via remote control (LIRC). +config HID_PLANTRONICS + tristate "Plantronics USB HID Driver" + default !EXPERT + depends on HID + ---help--- + Provides HID support for Plantronics telephony devices. + config HID_PRIMAX tristate "Primax non-fully HID-compliant devices" depends on HID diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile index e2850d8af9ca..5e7ac59447d8 100644 --- a/drivers/hid/Makefile +++ b/drivers/hid/Makefile @@ -94,6 +94,7 @@ ifdef CONFIG_DEBUG_FS hid-picolcd-y += hid-picolcd_debugfs.o endif +obj-$(CONFIG_HID_PLANTRONICS) += hid-plantronics.o obj-$(CONFIG_HID_PRIMAX) += hid-primax.o obj-$(CONFIG_HID_ROCCAT) += hid-roccat.o hid-roccat-common.o \ hid-roccat-arvo.o hid-roccat-isku.o hid-roccat-kone.o \ diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 73bd9e2e42bc..d50313ca64a6 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -1886,6 +1886,7 @@ static const struct hid_device_id hid_have_special_driver[] = { { HID_USB_DEVICE(USB_VENDOR_ID_ORTEK, USB_DEVICE_ID_ORTEK_WKB2000) }, { HID_USB_DEVICE(USB_VENDOR_ID_PENMOUNT, USB_DEVICE_ID_PENMOUNT_6000) }, { HID_USB_DEVICE(USB_VENDOR_ID_PETALYNX, USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE) }, + { HID_USB_DEVICE(USB_VENDOR_ID_PLANTRONICS, HID_ANY_ID) }, { HID_USB_DEVICE(USB_VENDOR_ID_PRIMAX, USB_DEVICE_ID_PRIMAX_KEYBOARD) }, #if IS_ENABLED(CONFIG_HID_ROCCAT) { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_ARVO) }, diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index e23ab8b30626..f9f476db671c 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h @@ -715,6 +715,8 @@ #define USB_DEVICE_ID_ORTEK_PKB1700 0x1700 #define USB_DEVICE_ID_ORTEK_WKB2000 0x2000 +#define USB_VENDOR_ID_PLANTRONICS 0x047f + #define USB_VENDOR_ID_PANASONIC 0x04da #define USB_DEVICE_ID_PANABOARD_UBT780 0x1044 #define USB_DEVICE_ID_PANABOARD_UBT880 0x104d diff --git a/drivers/hid/hid-plantronics.c b/drivers/hid/hid-plantronics.c new file mode 100644 index 000000000000..215cdbd10dea --- /dev/null +++ b/drivers/hid/hid-plantronics.c @@ -0,0 +1,78 @@ +/* + * Plantronics USB HID Driver + * + * Copyright (c) 2014 JD Cole + * Copyright (c) 2014 Terry Junge + */ + +/* + * 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 "hid-ids.h" + +#include +#include + +static int plantronics_input_mapping(struct hid_device *hdev, + struct hid_input *hi, + struct hid_field *field, + struct hid_usage *usage, + unsigned long **bit, int *max) +{ + if (field->application == HID_CP_CONSUMERCONTROL + && (usage->hid & HID_USAGE_PAGE) == HID_UP_CONSUMER) { + hid_dbg(hdev, "usage: %08x (appl: %08x) - defaulted\n", + usage->hid, field->application); + return 0; + } + + hid_dbg(hdev, "usage: %08x (appl: %08x) - ignored\n", + usage->hid, field->application); + + return -1; +} + +static int plantronics_probe(struct hid_device *hdev, + const struct hid_device_id *id) +{ + int ret; + + ret = hid_parse(hdev); + if (ret) { + hid_err(hdev, "parse failed\n"); + goto err; + } + + ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); + if (ret) { + hid_err(hdev, "hw start failed\n"); + goto err; + } + + return 0; + err: + return ret; +} + +static const struct hid_device_id plantronics_devices[] = { + { HID_USB_DEVICE(USB_VENDOR_ID_PLANTRONICS, HID_ANY_ID) }, + { } +}; +MODULE_DEVICE_TABLE(hid, plantronics_devices); + +static struct hid_driver plantronics_driver = { + .name = "plantronics", + .id_table = plantronics_devices, + .input_mapping = plantronics_input_mapping, + .probe = plantronics_probe, +}; +module_hid_driver(plantronics_driver); + +MODULE_AUTHOR("JD Cole "); +MODULE_AUTHOR("Terry Junge "); +MODULE_DESCRIPTION("Plantronics USB HID Driver"); +MODULE_LICENSE("GPL"); diff --git a/include/linux/hid.h b/include/linux/hid.h index 78ea9bf941cd..a63f2aaed646 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -234,6 +234,9 @@ struct hid_item { #define HID_DG_BARRELSWITCH 0x000d0044 #define HID_DG_ERASER 0x000d0045 #define HID_DG_TABLETPICK 0x000d0046 + +#define HID_CP_CONSUMERCONTROL 0x000c0001 + #define HID_DG_CONFIDENCE 0x000d0047 #define HID_DG_WIDTH 0x000d0048 #define HID_DG_HEIGHT 0x000d0049 -- cgit v1.2.3 From a45c30ec59342c47604ea074bcf56a43a8cde8aa Mon Sep 17 00:00:00 2001 From: JD Cole Date: Fri, 31 Oct 2014 17:44:42 -0700 Subject: HID: added missing HID Consumer Page identifiers Adds CA and NAry usage type identifiers. Signed-off-by: JD Cole Signed-off-by: Jiri Kosina --- include/linux/hid.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'include/linux/hid.h') diff --git a/include/linux/hid.h b/include/linux/hid.h index a63f2aaed646..58a89ed86acc 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -236,6 +236,30 @@ struct hid_item { #define HID_DG_TABLETPICK 0x000d0046 #define HID_CP_CONSUMERCONTROL 0x000c0001 +#define HID_CP_NUMERICKEYPAD 0x000c0002 +#define HID_CP_PROGRAMMABLEBUTTONS 0x000c0003 +#define HID_CP_MICROPHONE 0x000c0004 +#define HID_CP_HEADPHONE 0x000c0005 +#define HID_CP_GRAPHICEQUALIZER 0x000c0006 +#define HID_CP_FUNCTIONBUTTONS 0x000c0036 +#define HID_CP_SELECTION 0x000c0080 +#define HID_CP_MEDIASELECTION 0x000c0087 +#define HID_CP_SELECTDISC 0x000c00ba +#define HID_CP_PLAYBACKSPEED 0x000c00f1 +#define HID_CP_PROXIMITY 0x000c0109 +#define HID_CP_SPEAKERSYSTEM 0x000c0160 +#define HID_CP_CHANNELLEFT 0x000c0161 +#define HID_CP_CHANNELRIGHT 0x000c0162 +#define HID_CP_CHANNELCENTER 0x000c0163 +#define HID_CP_CHANNELFRONT 0x000c0164 +#define HID_CP_CHANNELCENTERFRONT 0x000c0165 +#define HID_CP_CHANNELSIDE 0x000c0166 +#define HID_CP_CHANNELSURROUND 0x000c0167 +#define HID_CP_CHANNELLOWFREQUENCYENHANCEMENT 0x000c0168 +#define HID_CP_CHANNELTOP 0x000c0169 +#define HID_CP_CHANNELUNKNOWN 0x000c016a +#define HID_CP_APPLICATIONLAUNCHBUTTONS 0x000c0180 +#define HID_CP_GENERICGUIAPPLICATIONCONTROLS 0x000c0200 #define HID_DG_CONFIDENCE 0x000d0047 #define HID_DG_WIDTH 0x000d0048 -- cgit v1.2.3 From dabb05c6670e6e4415d7b56cd5864a5dbd90207f Mon Sep 17 00:00:00 2001 From: Mathieu Magnaudet Date: Thu, 27 Nov 2014 16:02:36 +0100 Subject: HID: make hid_report_len as a static inline function in hid.h In several hid drivers it is necessary to calculate the length of an hid_report. This patch exports the existing static function hid_report_len of hid-core.c as an inline function in hid.h Signed-off-by: Mathieu Magnaudet Reviewed-by: Benjamin Tissoires Reviewed-by: David Herrmann Signed-off-by: Jiri Kosina --- drivers/hid/hid-core.c | 6 ------ drivers/hid/hid-input.c | 2 +- drivers/hid/hid-multitouch.c | 2 +- drivers/hid/usbhid/hid-core.c | 3 +-- drivers/hid/wacom_sys.c | 8 +------- include/linux/hid.h | 11 +++++++++++ 6 files changed, 15 insertions(+), 17 deletions(-) (limited to 'include/linux/hid.h') diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 3402033fa52a..ee6ba7625e77 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -1280,12 +1280,6 @@ void hid_output_report(struct hid_report *report, __u8 *data) } EXPORT_SYMBOL_GPL(hid_output_report); -static int hid_report_len(struct hid_report *report) -{ - /* equivalent to DIV_ROUND_UP(report->size, 8) + !!(report->id > 0) */ - return ((report->size - 1) >> 3) + 1 + (report->id > 0); -} - /* * Allocator for buffer that is going to be passed to hid_output_report() */ diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c index 725f22ca47fc..1e95f4df4146 100644 --- a/drivers/hid/hid-input.c +++ b/drivers/hid/hid-input.c @@ -1215,7 +1215,7 @@ static void hidinput_led_worker(struct work_struct *work) return hid->ll_driver->request(hid, report, HID_REQ_SET_REPORT); /* fall back to generic raw-output-report */ - len = ((report->size - 1) >> 3) + 1 + (report->id > 0); + len = hid_report_len(report); buf = hid_alloc_report_buf(report, GFP_KERNEL); if (!buf) return; diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c index 683cda6c60ce..f65e78b46999 100644 --- a/drivers/hid/hid-multitouch.c +++ b/drivers/hid/hid-multitouch.c @@ -827,7 +827,7 @@ static void mt_set_input_mode(struct hid_device *hdev) r = re->report_id_hash[td->inputmode]; if (r) { if (cls->quirks & MT_QUIRK_FORCE_GET_FEATURE) { - report_len = ((r->size - 1) >> 3) + 1 + (r->id > 0); + report_len = hid_report_len(r); buf = hid_alloc_report_buf(r, GFP_KERNEL); if (!buf) { hid_err(hdev, "failed to allocate buffer for report\n"); diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c index ca6849a0121e..b6cb7a5e4b27 100644 --- a/drivers/hid/usbhid/hid-core.c +++ b/drivers/hid/usbhid/hid-core.c @@ -338,8 +338,7 @@ static int hid_submit_out(struct hid_device *hid) report = usbhid->out[usbhid->outtail].report; raw_report = usbhid->out[usbhid->outtail].raw_report; - usbhid->urbout->transfer_buffer_length = ((report->size - 1) >> 3) + - 1 + (report->id > 0); + usbhid->urbout->transfer_buffer_length = hid_report_len(report); usbhid->urbout->dev = hid_to_usb_dev(hid); if (raw_report) { memcpy(usbhid->outbuf, raw_report, diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c index 8593047bb726..8e02a4a6fde0 100644 --- a/drivers/hid/wacom_sys.c +++ b/drivers/hid/wacom_sys.c @@ -1321,12 +1321,6 @@ static void wacom_calculate_res(struct wacom_features *features) features->unitExpo); } -static int wacom_hid_report_len(struct hid_report *report) -{ - /* equivalent to DIV_ROUND_UP(report->size, 8) + !!(report->id > 0) */ - return ((report->size - 1) >> 3) + 1 + (report->id > 0); -} - static size_t wacom_compute_pktlen(struct hid_device *hdev) { struct hid_report_enum *report_enum; @@ -1336,7 +1330,7 @@ static size_t wacom_compute_pktlen(struct hid_device *hdev) report_enum = hdev->report_enum + HID_INPUT_REPORT; list_for_each_entry(report, &report_enum->report_list, list) { - size_t report_size = wacom_hid_report_len(report); + size_t report_size = hid_report_len(report); if (report_size > size) size = report_size; } diff --git a/include/linux/hid.h b/include/linux/hid.h index 78ea9bf941cd..2366fda010c8 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -1063,6 +1063,17 @@ static inline void hid_hw_wait(struct hid_device *hdev) hdev->ll_driver->wait(hdev); } +/** + * hid_report_len - calculate the report length + * + * @report: the report we want to know the length + */ +static inline int hid_report_len(struct hid_report *report) +{ + /* equivalent to DIV_ROUND_UP(report->size, 8) + !!(report->id > 0) */ + return ((report->size - 1) >> 3) + 1 + (report->id > 0); +} + int hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size, int interrupt); -- cgit v1.2.3