From 4da361b69102cdffe73006771eae7504d2cb8736 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Pr=C3=A9mont?= Date: Mon, 15 Mar 2010 14:55:40 +0100 Subject: [PATCH 01/22] HID: register debugfs entries before adding device MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Register debugfs entries before calling device_add() so debugfs entries are already present when HID driver's probe function gets called on device hotplug. Also undo debugfs entry registration if device_add() fails so status HID_STAT_ADDED and debugfs registration status remain consistent and we don't leak the debugfs entries. Signed-off-by: Bruno Prémont Cc: Alan Stern Signed-off-by: Jiri Kosina --- drivers/hid/hid-core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 368fbb0c4ca6..7396f47c79db 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -1768,11 +1768,12 @@ int hid_add_device(struct hid_device *hdev) dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus, hdev->vendor, hdev->product, atomic_inc_return(&id)); + hid_debug_register(hdev, dev_name(&hdev->dev)); ret = device_add(&hdev->dev); if (!ret) hdev->status |= HID_STAT_ADDED; - - hid_debug_register(hdev, dev_name(&hdev->dev)); + else + hid_debug_unregister(hdev); return ret; } From 59d2334ac9f4255f5f8f3e4e1bf41653e0bba99e Mon Sep 17 00:00:00 2001 From: Przemo Firszt Date: Mon, 15 Mar 2010 19:16:23 +0000 Subject: [PATCH 02/22] HID: expose wacom pen tablet battery through power_supply class This patch exposes wacom pen tablet battery capacity and ac state thru power_supply class is sysfs. Signed-off-by: Przemo Firszt Signed-off-by: Jiri Kosina --- drivers/hid/Kconfig | 8 +++ drivers/hid/hid-wacom.c | 127 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 135 insertions(+) diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig index 71d4c0703629..8e1b505b5bf2 100644 --- a/drivers/hid/Kconfig +++ b/drivers/hid/Kconfig @@ -357,6 +357,14 @@ config HID_WACOM ---help--- Support for Wacom Graphire Bluetooth tablet. +config HID_WACOM_POWER_SUPPLY + bool "Wacom Bluetooth devices power supply status support" + depends on HID_WACOM + select POWER_SUPPLY + ---help--- + Say Y here if you want to enable power supply status monitoring for + Wacom Bluetooth devices. + config HID_ZEROPLUS tristate "Zeroplus based game controller support" if EMBEDDED depends on USB_HID diff --git a/drivers/hid/hid-wacom.c b/drivers/hid/hid-wacom.c index 8d3b46f5d149..4d2d2a2e1a5f 100644 --- a/drivers/hid/hid-wacom.c +++ b/drivers/hid/hid-wacom.c @@ -21,14 +21,88 @@ #include #include #include +#ifdef CONFIG_HID_WACOM_POWER_SUPPLY +#include +#endif #include "hid-ids.h" struct wacom_data { __u16 tool; unsigned char butstate; +#ifdef CONFIG_HID_WACOM_POWER_SUPPLY + int battery_capacity; + struct power_supply battery; + struct power_supply ac; +#endif }; +#ifdef CONFIG_HID_WACOM_POWER_SUPPLY +/*percent of battery capacity, 0 means AC online*/ +static unsigned short batcap[8] = { 1, 15, 25, 35, 50, 70, 100, 0 }; + +static enum power_supply_property wacom_battery_props[] = { + POWER_SUPPLY_PROP_PRESENT, + POWER_SUPPLY_PROP_CAPACITY +}; + +static enum power_supply_property wacom_ac_props[] = { + POWER_SUPPLY_PROP_PRESENT, + POWER_SUPPLY_PROP_ONLINE +}; + +static int wacom_battery_get_property(struct power_supply *psy, + enum power_supply_property psp, + union power_supply_propval *val) +{ + struct wacom_data *wdata = container_of(psy, + struct wacom_data, battery); + int power_state = batcap[wdata->battery_capacity]; + int ret = 0; + + switch (psp) { + case POWER_SUPPLY_PROP_PRESENT: + val->intval = 1; + break; + case POWER_SUPPLY_PROP_CAPACITY: + /* show 100% battery capacity when charging */ + if (power_state == 0) + val->intval = 100; + else + val->intval = power_state; + break; + default: + ret = -EINVAL; + break; + } + return ret; +} + +static int wacom_ac_get_property(struct power_supply *psy, + enum power_supply_property psp, + union power_supply_propval *val) +{ + struct wacom_data *wdata = container_of(psy, struct wacom_data, ac); + int power_state = batcap[wdata->battery_capacity]; + int ret = 0; + + switch (psp) { + case POWER_SUPPLY_PROP_PRESENT: + /* fall through */ + case POWER_SUPPLY_PROP_ONLINE: + if (power_state == 0) + val->intval = 1; + else + val->intval = 0; + break; + default: + ret = -EINVAL; + break; + } + return ret; +} +#endif + static int wacom_raw_event(struct hid_device *hdev, struct hid_report *report, u8 *raw_data, int size) { @@ -147,6 +221,12 @@ static int wacom_raw_event(struct hid_device *hdev, struct hid_report *report, input_sync(input); } +#ifdef CONFIG_HID_WACOM_POWER_SUPPLY + /* Store current battery capacity */ + rw = (data[7] >> 2 & 0x07); + if (rw != wdata->battery_capacity) + wdata->battery_capacity = rw; +#endif return 1; } @@ -206,6 +286,45 @@ static int wacom_probe(struct hid_device *hdev, if (ret < 0) dev_warn(&hdev->dev, "failed to poke device #2, %d\n", ret); +#ifdef CONFIG_HID_WACOM_POWER_SUPPLY + wdata->battery.properties = wacom_battery_props; + wdata->battery.num_properties = ARRAY_SIZE(wacom_battery_props); + wdata->battery.get_property = wacom_battery_get_property; + wdata->battery.name = "wacom_battery"; + wdata->battery.type = POWER_SUPPLY_TYPE_BATTERY; + wdata->battery.use_for_apm = 0; + + ret = power_supply_register(&hdev->dev, &wdata->battery); + if (ret) { + dev_warn(&hdev->dev, + "can't create sysfs battery attribute, err: %d\n", ret); + /* + * battery attribute is not critical for the tablet, but if it + * failed then there is no need to create ac attribute + */ + goto move_on; + } + + wdata->ac.properties = wacom_ac_props; + wdata->ac.num_properties = ARRAY_SIZE(wacom_ac_props); + wdata->ac.get_property = wacom_ac_get_property; + wdata->ac.name = "wacom_ac"; + wdata->ac.type = POWER_SUPPLY_TYPE_MAINS; + wdata->ac.use_for_apm = 0; + + ret = power_supply_register(&hdev->dev, &wdata->ac); + if (ret) { + dev_warn(&hdev->dev, + "can't create ac battery attribute, err: %d\n", ret); + /* + * ac attribute is not critical for the tablet, but if it + * failed then we don't want to battery attribute to exist + */ + power_supply_unregister(&wdata->battery); + } + +move_on: +#endif hidinput = list_entry(hdev->inputs.next, struct hid_input, list); input = hidinput->input; @@ -250,7 +369,15 @@ static int wacom_probe(struct hid_device *hdev, static void wacom_remove(struct hid_device *hdev) { +#ifdef CONFIG_HID_WACOM_POWER_SUPPLY + struct wacom_data *wdata = hid_get_drvdata(hdev); +#endif hid_hw_stop(hdev); + +#ifdef CONFIG_HID_WACOM_POWER_SUPPLY + power_supply_unregister(&wdata->battery); + power_supply_unregister(&wdata->ac); +#endif kfree(hid_get_drvdata(hdev)); } From 06c7c313b5605471e321337c770683cf70464197 Mon Sep 17 00:00:00 2001 From: Przemo Firszt Date: Mon, 22 Mar 2010 09:55:04 +0100 Subject: [PATCH 03/22] HID: separate mode switching function for wacom bluetooth driver wacom_poke function allows to switch tablet reporting speed. The patch dosen't add any new functionality, but it's preparation for user-space speed switching through sysfs. Signed-off-by: Przemo Firszt Signed-off-by: Bastien Nocera Signed-off-by: Jiri Kosina --- drivers/hid/hid-wacom.c | 66 +++++++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 26 deletions(-) diff --git a/drivers/hid/hid-wacom.c b/drivers/hid/hid-wacom.c index 4d2d2a2e1a5f..f9d493931b02 100644 --- a/drivers/hid/hid-wacom.c +++ b/drivers/hid/hid-wacom.c @@ -103,6 +103,44 @@ static int wacom_ac_get_property(struct power_supply *psy, } #endif +static void wacom_poke(struct hid_device *hdev, u8 speed) +{ + int limit, ret; + char rep_data[2]; + + rep_data[0] = 0x03 ; rep_data[1] = 0x00; + limit = 3; + do { + ret = hdev->hid_output_raw_report(hdev, rep_data, 2, + HID_FEATURE_REPORT); + } while (ret < 0 && limit-- > 0); + + if (ret >= 0) { + if (speed == 0) + rep_data[0] = 0x05; + else + rep_data[0] = 0x06; + + rep_data[1] = 0x00; + limit = 3; + do { + ret = hdev->hid_output_raw_report(hdev, rep_data, 2, + HID_FEATURE_REPORT); + } while (ret < 0 && limit-- > 0); + + if (ret >= 0) + return; + } + + /* + * Note that if the raw queries fail, it's not a hard failure and it + * is safe to continue + */ + dev_warn(&hdev->dev, "failed to poke device, command %d, err %d\n", + rep_data[0], ret); + return; +} + static int wacom_raw_event(struct hid_device *hdev, struct hid_report *report, u8 *raw_data, int size) { @@ -236,9 +274,7 @@ static int wacom_probe(struct hid_device *hdev, struct hid_input *hidinput; struct input_dev *input; struct wacom_data *wdata; - char rep_data[2]; int ret; - int limit; wdata = kzalloc(sizeof(*wdata), GFP_KERNEL); if (wdata == NULL) { @@ -261,30 +297,8 @@ static int wacom_probe(struct hid_device *hdev, goto err_free; } - /* - * Note that if the raw queries fail, it's not a hard failure and it - * is safe to continue - */ - - /* Set Wacom mode2 */ - rep_data[0] = 0x03; rep_data[1] = 0x00; - limit = 3; - do { - ret = hdev->hid_output_raw_report(hdev, rep_data, 2, - HID_FEATURE_REPORT); - } while (ret < 0 && limit-- > 0); - if (ret < 0) - dev_warn(&hdev->dev, "failed to poke device #1, %d\n", ret); - - /* 0x06 - high reporting speed, 0x05 - low speed */ - rep_data[0] = 0x06; rep_data[1] = 0x00; - limit = 3; - do { - ret = hdev->hid_output_raw_report(hdev, rep_data, 2, - HID_FEATURE_REPORT); - } while (ret < 0 && limit-- > 0); - if (ret < 0) - dev_warn(&hdev->dev, "failed to poke device #2, %d\n", ret); + /* Set Wacom mode 2 with high reporting speed */ + wacom_poke(hdev, 1); #ifdef CONFIG_HID_WACOM_POWER_SUPPLY wdata->battery.properties = wacom_battery_props; From 20a3ce7e490c5015d051f78414f6dd146eec283f Mon Sep 17 00:00:00 2001 From: Przemo Firszt Date: Thu, 18 Mar 2010 14:34:34 +0000 Subject: [PATCH 04/22] HID: add sysfs speed attribute for wacom bluetooth tablet The attribute allows to change reporting speed of tablet from userspace through sysfs file. The attribute is RW, valid values: 0 is low speed, 1 is high speed. High speed is the default setting. Using low speed is a workaround if you experience lag when using the tablet. Signed-off-by: Przemo Firszt Signed-off-by: Jiri Kosina --- drivers/hid/hid-wacom.c | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/drivers/hid/hid-wacom.c b/drivers/hid/hid-wacom.c index f9d493931b02..97ef6260fda0 100644 --- a/drivers/hid/hid-wacom.c +++ b/drivers/hid/hid-wacom.c @@ -30,6 +30,7 @@ struct wacom_data { __u16 tool; unsigned char butstate; + unsigned char high_speed; #ifdef CONFIG_HID_WACOM_POWER_SUPPLY int battery_capacity; struct power_supply battery; @@ -105,6 +106,7 @@ static int wacom_ac_get_property(struct power_supply *psy, static void wacom_poke(struct hid_device *hdev, u8 speed) { + struct wacom_data *wdata = hid_get_drvdata(hdev); int limit, ret; char rep_data[2]; @@ -128,8 +130,10 @@ static void wacom_poke(struct hid_device *hdev, u8 speed) HID_FEATURE_REPORT); } while (ret < 0 && limit-- > 0); - if (ret >= 0) + if (ret >= 0) { + wdata->high_speed = speed; return; + } } /* @@ -141,6 +145,35 @@ static void wacom_poke(struct hid_device *hdev, u8 speed) return; } +static ssize_t wacom_show_speed(struct device *dev, + struct device_attribute + *attr, char *buf) +{ + struct wacom_data *wdata = dev_get_drvdata(dev); + + return snprintf(buf, PAGE_SIZE, "%i\n", wdata->high_speed); +} + +static ssize_t wacom_store_speed(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct hid_device *hdev = container_of(dev, struct hid_device, dev); + int new_speed; + + if (sscanf(buf, "%1d", &new_speed ) != 1) + return -EINVAL; + + if (new_speed == 0 || new_speed == 1) { + wacom_poke(hdev, new_speed); + return strnlen(buf, PAGE_SIZE); + } else + return -EINVAL; +} + +static DEVICE_ATTR(speed, S_IRUGO | S_IWUGO, + wacom_show_speed, wacom_store_speed); + static int wacom_raw_event(struct hid_device *hdev, struct hid_report *report, u8 *raw_data, int size) { @@ -297,6 +330,11 @@ static int wacom_probe(struct hid_device *hdev, goto err_free; } + ret = device_create_file(&hdev->dev, &dev_attr_speed); + if (ret) + dev_warn(&hdev->dev, + "can't create sysfs speed attribute err: %d\n", ret); + /* Set Wacom mode 2 with high reporting speed */ wacom_poke(hdev, 1); From 3d61510f4ecacfe47c75c0eb51c0659dfa77fb1b Mon Sep 17 00:00:00 2001 From: Alan Stern Date: Fri, 2 Apr 2010 13:21:58 -0400 Subject: [PATCH 05/22] HID: usbhid: enable remote wakeup for keyboards This patch (as1365) enables remote wakeup by default for USB keyboard devices. Keyboards in general are supposed to be wakeup devices, but the correct place to enable it depends on the device's bus; no single approach will work for all keyboard devices. In particular, this covers only USB keyboards (and then only those supporting the boot protocol). Signed-off-by: Alan Stern Signed-off-by: Jiri Kosina --- drivers/hid/usbhid/hid-core.c | 7 +++++-- drivers/hid/usbhid/usbkbd.c | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c index 56d06cd8075b..9cd61a52e9e3 100644 --- a/drivers/hid/usbhid/hid-core.c +++ b/drivers/hid/usbhid/hid-core.c @@ -1026,12 +1026,15 @@ static int usbhid_start(struct hid_device *hid) /* Some keyboards don't work until their LEDs have been set. * Since BIOSes do set the LEDs, it must be safe for any device * that supports the keyboard boot protocol. + * In addition, enable remote wakeup by default for all keyboard + * devices supporting the boot protocol. */ if (interface->desc.bInterfaceSubClass == USB_INTERFACE_SUBCLASS_BOOT && interface->desc.bInterfaceProtocol == - USB_INTERFACE_PROTOCOL_KEYBOARD) + USB_INTERFACE_PROTOCOL_KEYBOARD) { usbhid_set_leds(hid); - + device_set_wakeup_enable(&dev->dev, 1); + } return 0; fail: diff --git a/drivers/hid/usbhid/usbkbd.c b/drivers/hid/usbhid/usbkbd.c index f843443ba5c3..b2fd0b00de92 100644 --- a/drivers/hid/usbhid/usbkbd.c +++ b/drivers/hid/usbhid/usbkbd.c @@ -313,6 +313,7 @@ static int usb_kbd_probe(struct usb_interface *iface, goto fail2; usb_set_intfdata(iface, kbd); + device_set_wakeup_enable(&dev->dev, 1); return 0; fail2: From 6dec143a50c01ca0cc0afcbf5ea4bb8e87981edf Mon Sep 17 00:00:00 2001 From: Stephane Chatty Date: Sun, 11 Apr 2010 14:51:24 +0200 Subject: [PATCH 06/22] HID: add support for 3M multitouch 22" display Now support the 22" display and its updated firmware, including touch width and height. The number of touches can now go up to 60, and our single touch emulation will fail when there are more than 6-7 touches; further work is needed on this. Signed-off-by: Stephane Chatty Signed-off-by: Jiri Kosina --- drivers/hid/hid-3m-pct.c | 31 ++++++++++++++++++++++++++++--- drivers/hid/hid-core.c | 1 + drivers/hid/hid-ids.h | 1 + 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/drivers/hid/hid-3m-pct.c b/drivers/hid/hid-3m-pct.c index 2370aefc86b2..883fd1af3c4c 100644 --- a/drivers/hid/hid-3m-pct.c +++ b/drivers/hid/hid-3m-pct.c @@ -1,7 +1,7 @@ /* * HID driver for 3M PCT multitouch panels * - * Copyright (c) 2009 Stephane Chatty + * Copyright (c) 2009-2010 Stephane Chatty * */ @@ -24,7 +24,7 @@ MODULE_LICENSE("GPL"); #include "hid-ids.h" struct mmm_finger { - __s32 x, y; + __s32 x, y, w, h; __u8 rank; bool touch, valid; }; @@ -81,7 +81,18 @@ static int mmm_input_mapping(struct hid_device *hdev, struct hid_input *hi, /* touchscreen emulation */ hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_TOUCH); return 1; + case HID_DG_WIDTH: + hid_map_usage(hi, usage, bit, max, + EV_ABS, ABS_MT_TOUCH_MAJOR); + return 1; + case HID_DG_HEIGHT: + hid_map_usage(hi, usage, bit, max, + EV_ABS, ABS_MT_TOUCH_MINOR); + input_set_abs_params(hi->input, ABS_MT_ORIENTATION, + 1, 1, 0, 0); + return 1; case HID_DG_CONTACTID: + field->logical_maximum = 59; hid_map_usage(hi, usage, bit, max, EV_ABS, ABS_MT_TRACKING_ID); return 1; @@ -127,9 +138,15 @@ static void mmm_filter_event(struct mmm_data *md, struct input_dev *input) /* this finger is just placeholder data, ignore */ } else if (f->touch) { /* this finger is on the screen */ + int wide = (f->w > f->h); input_event(input, EV_ABS, ABS_MT_TRACKING_ID, i); input_event(input, EV_ABS, ABS_MT_POSITION_X, f->x); input_event(input, EV_ABS, ABS_MT_POSITION_Y, f->y); + input_event(input, EV_ABS, ABS_MT_ORIENTATION, wide); + input_event(input, EV_ABS, ABS_MT_TOUCH_MAJOR, + wide ? f->w : f->h); + input_event(input, EV_ABS, ABS_MT_TOUCH_MINOR, + wide ? f->h : f->w); input_mt_sync(input); /* * touchscreen emulation: maintain the age rank @@ -196,6 +213,14 @@ static int mmm_event(struct hid_device *hid, struct hid_field *field, case HID_DG_CONFIDENCE: md->valid = value; break; + case HID_DG_WIDTH: + if (md->valid) + md->f[md->curid].w = value; + break; + case HID_DG_HEIGHT: + if (md->valid) + md->f[md->curid].h = value; + break; case HID_DG_CONTACTID: if (md->valid) { md->curid = value; @@ -254,6 +279,7 @@ static void mmm_remove(struct hid_device *hdev) static const struct hid_device_id mmm_devices[] = { { HID_USB_DEVICE(USB_VENDOR_ID_3M, USB_DEVICE_ID_3M1968) }, + { HID_USB_DEVICE(USB_VENDOR_ID_3M, USB_DEVICE_ID_3M2256) }, { } }; MODULE_DEVICE_TABLE(hid, mmm_devices); @@ -286,5 +312,4 @@ static void __exit mmm_exit(void) module_init(mmm_init); module_exit(mmm_exit); -MODULE_LICENSE("GPL"); diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 7396f47c79db..9f92f629d448 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -1251,6 +1251,7 @@ EXPORT_SYMBOL_GPL(hid_disconnect); /* a list of devices for which there is a specialized driver on HID bus */ static const struct hid_device_id hid_blacklist[] = { { HID_USB_DEVICE(USB_VENDOR_ID_3M, USB_DEVICE_ID_3M1968) }, + { HID_USB_DEVICE(USB_VENDOR_ID_3M, USB_DEVICE_ID_3M2256) }, { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU) }, { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_X5_005D) }, { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ATV_IRCONTROL) }, diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index 72c05f90553c..e1b4ce4eeb6e 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h @@ -20,6 +20,7 @@ #define USB_VENDOR_ID_3M 0x0596 #define USB_DEVICE_ID_3M1968 0x0500 +#define USB_DEVICE_ID_3M2256 0x0502 #define USB_VENDOR_ID_A4TECH 0x09da #define USB_DEVICE_ID_A4TECH_WCP32PU 0x0006 From 75c28df87eb6d8e1389af67f26fbe2394e28385e Mon Sep 17 00:00:00 2001 From: Pete Zaitcev Date: Mon, 12 Apr 2010 12:16:11 -0600 Subject: [PATCH 07/22] HID: non-overlapping zeroing of extra bits From my review of the way the unused bits of report are being zeroed, it seems like there must be a bug. Currently, the zeroing is done in hid_output_field and it covers any bits between the last used bit and the end of the byte. But in case of, say, my keyboard, NumLock is mask 0x01 and CapsLock is 0x02. Invoking hid_output_field for NumLock definitely zeroes across CapsLock. The only reason this works is that the fields are sorted by the offset. It would be more correct and simpler to zero-fill the buffer into which the fields are set. The patch is tested with an IBM keyboard that is improperly sensitive to out-of-report pad bits, the extra bits are still zeroed and the fields continue to work as expected. It is also tested with good keyboards. In case, a related bug in RHEL 5 is tracked with Red Hat bug 513934. Signed-off-by: Pete Zaitcev Signed-off-by: Jiri Kosina --- drivers/hid/hid-core.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 9f92f629d448..8617aa97a9c8 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -940,13 +940,8 @@ static void hid_output_field(struct hid_field *field, __u8 *data) unsigned count = field->report_count; unsigned offset = field->report_offset; unsigned size = field->report_size; - unsigned bitsused = offset + count * size; unsigned n; - /* make sure the unused bits in the last byte are zeros */ - if (count > 0 && size > 0 && (bitsused % 8) != 0) - data[(bitsused-1)/8] &= (1 << (bitsused % 8)) - 1; - for (n = 0; n < count; n++) { if (field->logical_minimum < 0) /* signed values */ implement(data, offset + n * size, size, s32ton(field->value[n], size)); @@ -966,6 +961,7 @@ void hid_output_report(struct hid_report *report, __u8 *data) if (report->id > 0) *data++ = report->id; + memset(data, 0, ((report->size - 1) >> 3) + 1); for (n = 0; n < report->maxfield; n++) hid_output_field(report->field[n], data); } From b5e5a37e36cd4d355b875665312d7aaae4e5833c Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Fri, 16 Apr 2010 17:19:50 +0100 Subject: [PATCH 08/22] HID: add HID_QUIRK_HIDDEV_FORCE and HID_QUIRK_NO_IGNORE Add two quirks to make it possible for usbhid module options to override whether a device is ignored (HID_QUIRK_NO_IGNORE) and whether to connect a hiddev device (HID_QUIRK_HIDDEV_FORCE). Passing HID_QUIRK_NO_IGNORE for your device means that it will not be ignored by the HID layer, even if present in a blacklist. HID_QUIRK_HIDDEV_FORCE will force the creation of a hiddev for that device, making it accessible from user-space. Tested with an Apple IR Receiver, switching it from using appleir to using lirc's macmini driver. Signed-off-by: Bastien Nocera Signed-off-by: Jiri Kosina --- drivers/hid/hid-core.c | 4 +++- drivers/hid/usbhid/hid-core.c | 1 + include/linux/hid.h | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 8617aa97a9c8..468c6c2d4ad5 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -1168,6 +1168,8 @@ int hid_connect(struct hid_device *hdev, unsigned int connect_mask) unsigned int i; int len; + if (hdev->quirks & HID_QUIRK_HIDDEV_FORCE) + connect_mask |= (HID_CONNECT_HIDDEV_FORCE | HID_CONNECT_HIDDEV); if (hdev->bus != BUS_USB) connect_mask &= ~HID_CONNECT_HIDDEV; if (hid_hiddev(hdev)) @@ -1757,7 +1759,7 @@ int hid_add_device(struct hid_device *hdev) /* we need to kill them here, otherwise they will stay allocated to * wait for coming driver */ - if (hid_ignore(hdev)) + if (!(hdev->quirks & HID_QUIRK_NO_IGNORE) && hid_ignore(hdev)) return -ENODEV; /* XXX hack, any other cleaner solution after the driver core diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c index 9cd61a52e9e3..245aef0de8f2 100644 --- a/drivers/hid/usbhid/hid-core.c +++ b/drivers/hid/usbhid/hid-core.c @@ -1143,6 +1143,7 @@ static int usbhid_probe(struct usb_interface *intf, const struct usb_device_id * hid->vendor = le16_to_cpu(dev->descriptor.idVendor); hid->product = le16_to_cpu(dev->descriptor.idProduct); hid->name[0] = 0; + hid->quirks = usbhid_lookup_quirk(hid->vendor, hid->product); if (intf->cur_altsetting->desc.bInterfaceProtocol == USB_INTERFACE_PROTOCOL_MOUSE) hid->type = HID_TYPE_USBMOUSE; diff --git a/include/linux/hid.h b/include/linux/hid.h index b1344ec4b7fc..f1f2b6f0d1c4 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -308,11 +308,13 @@ struct hid_item { #define HID_QUIRK_NOTOUCH 0x00000002 #define HID_QUIRK_IGNORE 0x00000004 #define HID_QUIRK_NOGET 0x00000008 +#define HID_QUIRK_HIDDEV_FORCE 0x00000010 #define HID_QUIRK_BADPAD 0x00000020 #define HID_QUIRK_MULTI_INPUT 0x00000040 #define HID_QUIRK_SKIP_OUTPUT_REPORTS 0x00010000 #define HID_QUIRK_FULLSPEED_INTERVAL 0x10000000 #define HID_QUIRK_NO_INIT_REPORTS 0x20000000 +#define HID_QUIRK_NO_IGNORE 0x40000000 /* * This is the global environment of the parser. This information is From 18392212932ecbdc71bc6a298ad301328eefb09d Mon Sep 17 00:00:00 2001 From: Lorenzo Castelli Date: Fri, 16 Apr 2010 19:00:31 +0200 Subject: [PATCH 09/22] HID: add mappings for a few keys found on Logitech MX3200 The keys are added to the generic wireless mappings in case other keyboards use them. Note that the product ID for the MX3200 is the same as USB_DEVICE_ID_S510_RECEIVER_2. Signed-off-by: Lorenzo Castelli Signed-off-by: Jiri Kosina --- drivers/hid/hid-lg.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/hid/hid-lg.c b/drivers/hid/hid-lg.c index 3677c9037a11..f6433d8050a9 100644 --- a/drivers/hid/hid-lg.c +++ b/drivers/hid/hid-lg.c @@ -126,6 +126,9 @@ static int lg_wireless_mapping(struct hid_input *hi, struct hid_usage *usage, case 0x1004: lg_map_key_clear(KEY_VIDEO); break; case 0x1005: lg_map_key_clear(KEY_AUDIO); break; case 0x100a: lg_map_key_clear(KEY_DOCUMENTS); break; + /* The following two entries are Playlist 1 and 2 on the MX3200 */ + case 0x100f: lg_map_key_clear(KEY_FN_1); break; + case 0x1010: lg_map_key_clear(KEY_FN_2); break; case 0x1011: lg_map_key_clear(KEY_PREVIOUSSONG); break; case 0x1012: lg_map_key_clear(KEY_NEXTSONG); break; case 0x1013: lg_map_key_clear(KEY_CAMERA); break; @@ -137,6 +140,7 @@ static int lg_wireless_mapping(struct hid_input *hi, struct hid_usage *usage, case 0x1019: lg_map_key_clear(KEY_PROG1); break; case 0x101a: lg_map_key_clear(KEY_PROG2); break; case 0x101b: lg_map_key_clear(KEY_PROG3); break; + case 0x101c: lg_map_key_clear(KEY_CYCLEWINDOWS); break; case 0x101f: lg_map_key_clear(KEY_ZOOMIN); break; case 0x1020: lg_map_key_clear(KEY_ZOOMOUT); break; case 0x1021: lg_map_key_clear(KEY_ZOOMRESET); break; @@ -147,6 +151,11 @@ static int lg_wireless_mapping(struct hid_input *hi, struct hid_usage *usage, case 0x1029: lg_map_key_clear(KEY_SHUFFLE); break; case 0x102a: lg_map_key_clear(KEY_BACK); break; case 0x102b: lg_map_key_clear(KEY_CYCLEWINDOWS); break; + case 0x102d: lg_map_key_clear(KEY_WWW); break; + /* The following two are 'Start/answer call' and 'End/reject call' + on the MX3200 */ + case 0x1031: lg_map_key_clear(KEY_OK); break; + case 0x1032: lg_map_key_clear(KEY_CANCEL); break; case 0x1041: lg_map_key_clear(KEY_BATTERY); break; case 0x1042: lg_map_key_clear(KEY_WORDPROCESSOR); break; case 0x1043: lg_map_key_clear(KEY_SPREADSHEET); break; From ed9eac5b493c679ef5fc52273758fe334de82714 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Wed, 21 Apr 2010 14:52:00 +0100 Subject: [PATCH 10/22] HID: add support for the Wacom Intuos 4 wireless Same command set as the Graphire Bluetooth tablet. Signed-off-by: Bastien Nocera Signed-off-by: Jiri Kosina --- drivers/hid/hid-ids.h | 1 + drivers/hid/hid-wacom.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index e1b4ce4eeb6e..0786bbdafb4a 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h @@ -456,6 +456,7 @@ #define USB_VENDOR_ID_WACOM 0x056a #define USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH 0x81 +#define USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH 0xbd #define USB_VENDOR_ID_WISEGROUP 0x0925 #define USB_DEVICE_ID_SMARTJOY_PLUS 0x0005 diff --git a/drivers/hid/hid-wacom.c b/drivers/hid/hid-wacom.c index 97ef6260fda0..51d7d77eb43b 100644 --- a/drivers/hid/hid-wacom.c +++ b/drivers/hid/hid-wacom.c @@ -435,7 +435,7 @@ static void wacom_remove(struct hid_device *hdev) static const struct hid_device_id wacom_devices[] = { { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH) }, - + { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH) }, { } }; MODULE_DEVICE_TABLE(hid, wacom_devices); From 4afb032068ff78b4fef5bb2dc33e8ac7d1079e98 Mon Sep 17 00:00:00 2001 From: Jiri Kosina Date: Wed, 21 Apr 2010 16:22:30 +0200 Subject: [PATCH 11/22] HID: fix support for Wacom Intuos 4 wireless Commit ed9eac5b493c679 ("HID: add support for the Wacom Intuos 4 wireles") forgot to add VID/PID to hid_blacklist[]. Fix that up. Signed-off-by: Jiri Kosina --- drivers/hid/hid-core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 468c6c2d4ad5..2d8f79d8f888 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -1361,6 +1361,7 @@ static const struct hid_device_id hid_blacklist[] = { { HID_USB_DEVICE(USB_VENDOR_ID_TWINHAN, USB_DEVICE_ID_TWINHAN_IR_REMOTE) }, { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_SMARTJOY_PLUS) }, { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH) }, + { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH) } { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0005) }, { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0030) }, From 96a7813736a6aa1e2561ecc0d499817daecb4860 Mon Sep 17 00:00:00 2001 From: Jiri Kosina Date: Fri, 23 Apr 2010 00:22:07 +0200 Subject: [PATCH 12/22] HID: fix build failure Fix build failure introduced by 4afb032068f ("HID: fix support for Wacom Intuos 4 wireless") due to missing coma. Signed-off-by: Jiri Kosina --- drivers/hid/hid-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 2d8f79d8f888..34429d7d89af 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -1361,7 +1361,7 @@ static const struct hid_device_id hid_blacklist[] = { { HID_USB_DEVICE(USB_VENDOR_ID_TWINHAN, USB_DEVICE_ID_TWINHAN_IR_REMOTE) }, { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_SMARTJOY_PLUS) }, { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH) }, - { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH) } + { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH) }, { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0005) }, { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0030) }, From 15d8ee9a96e5019e698ad3c2c181970deb8ff888 Mon Sep 17 00:00:00 2001 From: Przemo Firszt Date: Wed, 21 Apr 2010 22:16:25 +0100 Subject: [PATCH 13/22] HID: wacom: add ABI doc entry for speed attribute Signed-off-by: Przemo Firszt Signed-off-by: Jiri Kosina --- Documentation/ABI/testing/sysfs-wacom | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-wacom diff --git a/Documentation/ABI/testing/sysfs-wacom b/Documentation/ABI/testing/sysfs-wacom new file mode 100644 index 000000000000..1517976e25c4 --- /dev/null +++ b/Documentation/ABI/testing/sysfs-wacom @@ -0,0 +1,10 @@ +What: /sys/class/hidraw/hidraw*/device/speed +Date: April 2010 +Kernel Version: 2.6.35 +Contact: linux-bluetooth@vger.kernel.org +Description: + The /sys/class/hidraw/hidraw*/device/speed file controls + reporting speed of wacom bluetooth tablet. Reading from + this file returns 1 if tablet reports in high speed mode + or 0 otherwise. Writing to this file one of these values + switches reporting speed. From bf280628fca93c4c341587ec914863dcc395af72 Mon Sep 17 00:00:00 2001 From: Wayne Thomas Date: Thu, 29 Apr 2010 00:45:01 +0200 Subject: [PATCH 14/22] HID: add support for BTC Emprex 3009URF III Vista MCE Remote The Behavior Tech. Computer Corp. (BTC) remote branded as "Emprex 3009URF III Vista Remote Controller" uses non-standard mappings for all of its 'special purpose' keys (0xffbc usage page). This patch modifies the existing hid-topseed quirky driver to support both remotes in order to prevent proliferation of in-kernel quirky drivers until such a time that udev remapping works with these devices. Tested successfully with both the "Emprex" remote and the "CyberLink" remote originally supported by the hid-topseed driver. Signed-off-by: Wayne Thomas Signed-off-by: Jiri Kosina --- drivers/hid/Kconfig | 2 +- drivers/hid/hid-core.c | 1 + drivers/hid/hid-ids.h | 3 +++ drivers/hid/hid-topseed.c | 38 ++++++++++++++++++++++++-------------- 4 files changed, 29 insertions(+), 15 deletions(-) diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig index 8e1b505b5bf2..631ede69c012 100644 --- a/drivers/hid/Kconfig +++ b/drivers/hid/Kconfig @@ -332,7 +332,7 @@ config HID_TOPSEED depends on USB_HID default !EMBEDDED ---help--- - Say Y if you have a TopSeed Cyberlink remote control. + Say Y if you have a TopSeed Cyberlink or BTC Emprex remote control. config HID_THRUSTMASTER tristate "ThrustMaster devices support" if EMBEDDED diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 34429d7d89af..b9f99f9c4b2f 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -1294,6 +1294,7 @@ static const struct hid_device_id hid_blacklist[] = { { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) }, { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) }, { HID_USB_DEVICE(USB_VENDOR_ID_BELKIN, USB_DEVICE_ID_FLIP_KVM) }, + { HID_USB_DEVICE(USB_VENDOR_ID_BTC, USB_DEVICE_ID_BTC_EMPREX_REMOTE) }, { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION) }, { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_TACTICAL_PAD) }, { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_1) }, diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index 0786bbdafb4a..9791d0a8d16d 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h @@ -124,6 +124,9 @@ #define USB_VENDOR_ID_BERKSHIRE 0x0c98 #define USB_DEVICE_ID_BERKSHIRE_PCWD 0x1140 +#define USB_VENDOR_ID_BTC 0x046e +#define USB_DEVICE_ID_BTC_EMPREX_REMOTE 0x5578 + #define USB_VENDOR_ID_CH 0x068e #define USB_DEVICE_ID_CH_PRO_PEDALS 0x00f2 #define USB_DEVICE_ID_CH_COMBATSTICK 0x00f4 diff --git a/drivers/hid/hid-topseed.c b/drivers/hid/hid-topseed.c index 6925eda1081a..2eebdcc57bcf 100644 --- a/drivers/hid/hid-topseed.c +++ b/drivers/hid/hid-topseed.c @@ -3,6 +3,9 @@ * * Copyright (c) 2008 Lev Babiev * based on hid-cherry driver + * + * Modified to also support BTC "Emprex 3009URF III Vista MCE Remote" by + * Wayne Thomas 2010. */ /* @@ -24,23 +27,29 @@ static int ts_input_mapping(struct hid_device *hdev, struct hid_input *hi, struct hid_field *field, struct hid_usage *usage, unsigned long **bit, int *max) { - if ((usage->hid & HID_USAGE_PAGE) != 0x0ffbc0000) + if ((usage->hid & HID_USAGE_PAGE) != HID_UP_LOGIVENDOR) return 0; switch (usage->hid & HID_USAGE) { - case 0x00d: ts_map_key_clear(KEY_HOME); break; - case 0x024: ts_map_key_clear(KEY_MENU); break; - case 0x025: ts_map_key_clear(KEY_TV); break; - case 0x048: ts_map_key_clear(KEY_RED); break; - case 0x047: ts_map_key_clear(KEY_GREEN); break; - case 0x049: ts_map_key_clear(KEY_YELLOW); break; - case 0x04a: ts_map_key_clear(KEY_BLUE); break; - case 0x04b: ts_map_key_clear(KEY_ANGLE); break; - case 0x04c: ts_map_key_clear(KEY_LANGUAGE); break; - case 0x04d: ts_map_key_clear(KEY_SUBTITLE); break; - case 0x031: ts_map_key_clear(KEY_AUDIO); break; - case 0x032: ts_map_key_clear(KEY_TEXT); break; - case 0x033: ts_map_key_clear(KEY_CHANNEL); break; + case 0x00d: ts_map_key_clear(KEY_MEDIA); break; + case 0x024: ts_map_key_clear(KEY_MENU); break; + case 0x025: ts_map_key_clear(KEY_TV); break; + case 0x031: ts_map_key_clear(KEY_AUDIO); break; + case 0x032: ts_map_key_clear(KEY_TEXT); break; + case 0x033: ts_map_key_clear(KEY_CHANNEL); break; + case 0x047: ts_map_key_clear(KEY_MP3); break; + case 0x048: ts_map_key_clear(KEY_TV2); break; + case 0x049: ts_map_key_clear(KEY_CAMERA); break; + case 0x04a: ts_map_key_clear(KEY_VIDEO); break; + case 0x04b: ts_map_key_clear(KEY_ANGLE); break; + case 0x04c: ts_map_key_clear(KEY_LANGUAGE); break; + case 0x04d: ts_map_key_clear(KEY_SUBTITLE); break; + case 0x050: ts_map_key_clear(KEY_RADIO); break; + case 0x05a: ts_map_key_clear(KEY_TEXT); break; + case 0x05b: ts_map_key_clear(KEY_RED); break; + case 0x05c: ts_map_key_clear(KEY_GREEN); break; + case 0x05d: ts_map_key_clear(KEY_YELLOW); break; + case 0x05e: ts_map_key_clear(KEY_BLUE); break; default: return 0; } @@ -50,6 +59,7 @@ static int ts_input_mapping(struct hid_device *hdev, struct hid_input *hi, static const struct hid_device_id ts_devices[] = { { HID_USB_DEVICE(USB_VENDOR_ID_TOPSEED, USB_DEVICE_ID_TOPSEED_CYBERLINK) }, + { HID_USB_DEVICE(USB_VENDOR_ID_BTC, USB_DEVICE_ID_BTC_EMPREX_REMOTE) }, { } }; MODULE_DEVICE_TABLE(hid, ts_devices); From fe6065dc30c8cdd4beaffd6d3fa110222ad08795 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 2 Feb 2010 13:40:40 +1000 Subject: [PATCH 15/22] HID: add multi-input quirk for eGalax Touchcontroller I've got one of these devices on my desk and it seems that it suffers from the ABS_Z/ABS_RX issue that we've seen in other devices before. This patch uses the same reasoning as 9db630b48 ("HID: add multi-input quirk for NextWindow Touchscreen"). Signed-off-by: Peter Hutterer Signed-off-by: Jiri Kosina --- drivers/hid/hid-ids.h | 3 +++ drivers/hid/usbhid/hid-quirks.c | 1 + 2 files changed, 4 insertions(+) diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index 9791d0a8d16d..513e75e0f65d 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h @@ -174,6 +174,9 @@ #define USB_VENDOR_ID_DRAGONRISE 0x0079 +#define USB_VENDOR_ID_EGALAX 0x0EEF +#define USB_DEVICE_ID_EGALAX_TOUCHCONTROLLER 0x0001 + #define USB_VENDOR_ID_ELO 0x04E7 #define USB_DEVICE_ID_ELO_TS2700 0x0020 diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c index 7844280897d1..8ea185246a78 100644 --- a/drivers/hid/usbhid/hid-quirks.c +++ b/drivers/hid/usbhid/hid-quirks.c @@ -32,6 +32,7 @@ static const struct hid_blacklist { { USB_VENDOR_ID_AASHIMA, USB_DEVICE_ID_AASHIMA_PREDATOR, HID_QUIRK_BADPAD }, { USB_VENDOR_ID_ALPS, USB_DEVICE_ID_IBM_GAMEPAD, HID_QUIRK_BADPAD }, { USB_VENDOR_ID_CHIC, USB_DEVICE_ID_CHIC_GAMEPAD, HID_QUIRK_BADPAD }, + { USB_VENDOR_ID_EGALAX, USB_DEVICE_ID_EGALAX_TOUCHCONTROLLER, HID_QUIRK_MULTI_INPUT }, { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_DRIVING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT }, { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_FLYING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT }, { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_FIGHTING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT }, From 81cd584394e54514c57b18e0f23e0b5ca40070b2 Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Fri, 30 Apr 2010 21:49:58 +0200 Subject: [PATCH 16/22] HID: hidraw: fix indentation Signed-off-by: Antonio Ospite Signed-off-by: Jiri Kosina --- drivers/hid/hidraw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c index d04476700b7b..a758ead3df61 100644 --- a/drivers/hid/hidraw.c +++ b/drivers/hid/hidraw.c @@ -310,7 +310,7 @@ static long hidraw_ioctl(struct file *file, unsigned int cmd, -EFAULT : len; break; } - } + } ret = -ENOTTY; } From 1721a238ba5df9e870ed952464d38714261f5be9 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Sat, 15 May 2010 23:19:30 +0200 Subject: [PATCH 17/22] HID: Use kmemdup Use kmemdup when some other buffer is immediately copied into the allocated region. A simplified version of the semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @@ expression from,to,size,flag; statement S; @@ - to = \(kmalloc\|kzalloc\)(size,flag); + to = kmemdup(from,size,flag); if (to==NULL || ...) S - memcpy(to, from, size); // Signed-off-by: Julia Lawall Signed-off-by: Jiri Kosina --- drivers/hid/hid-core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index b9f99f9c4b2f..c9eb2d08f396 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -653,10 +653,9 @@ int hid_parse_report(struct hid_device *device, __u8 *start, if (device->driver->report_fixup) device->driver->report_fixup(device, start, size); - device->rdesc = kmalloc(size, GFP_KERNEL); + device->rdesc = kmemdup(start, size, GFP_KERNEL); if (device->rdesc == NULL) return -ENOMEM; - memcpy(device->rdesc, start, size); device->rsize = size; parser = vmalloc(sizeof(struct hid_parser)); From a9885c8f7bf62e251fc178f838b9f0ee897c158a Mon Sep 17 00:00:00 2001 From: Don Prince Date: Fri, 14 May 2010 17:30:59 +0100 Subject: [PATCH 18/22] HID: Zydacron Remote Control driver A specialised HID driver for the Zydacron Remote Control (usb id: 13ec:0006). The specialised HID driver adds support for the buttons which are not currently handled by the default HID driver. Signed-off-by: Don Prince Signed-off-by: Jiri Kosina --- drivers/hid/Kconfig | 7 +++++++ drivers/hid/Makefile | 1 + drivers/hid/hid-core.c | 1 + drivers/hid/hid-ids.h | 3 +++ 4 files changed, 12 insertions(+) diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig index 631ede69c012..3cf69a0a8b77 100644 --- a/drivers/hid/Kconfig +++ b/drivers/hid/Kconfig @@ -380,6 +380,13 @@ config ZEROPLUS_FF Say Y here if you have a Zeroplus based game controller and want to have force feedback support for it. +config HID_ZYDACRON + tristate "Zydacron remote control support" if EMBEDDED + depends on USB_HID + default !EMBEDDED + ---help--- + Support for Zydacron remote control. + endmenu endif # HID_SUPPORT diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile index 0b2618f092ca..d1f1b448977d 100644 --- a/drivers/hid/Makefile +++ b/drivers/hid/Makefile @@ -54,6 +54,7 @@ obj-$(CONFIG_HID_THRUSTMASTER) += hid-tmff.o obj-$(CONFIG_HID_TOPSEED) += hid-topseed.o obj-$(CONFIG_HID_TWINHAN) += hid-twinhan.o obj-$(CONFIG_HID_ZEROPLUS) += hid-zpff.o +obj-$(CONFIG_HID_ZYDACRON) += hid-zydacron.o obj-$(CONFIG_HID_WACOM) += hid-wacom.o obj-$(CONFIG_USB_HID) += usbhid/ diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index c9eb2d08f396..7c77c64d3e99 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -1364,6 +1364,7 @@ static const struct hid_device_id hid_blacklist[] = { { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH) }, { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0005) }, { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0030) }, + { HID_USB_DEVICE(USB_VENDOR_ID_ZYDACRON, USB_DEVICE_ID_ZYDACRON_REMOTE_CONTROL) }, { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_BT) }, { } diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index 513e75e0f65d..30cba94cfb0c 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h @@ -481,6 +481,9 @@ #define USB_VENDOR_ID_ZEROPLUS 0x0c12 +#define USB_VENDOR_ID_ZYDACRON 0x13EC +#define USB_DEVICE_ID_ZYDACRON_REMOTE_CONTROL 0x0006 + #define USB_VENDOR_ID_KYE 0x0458 #define USB_DEVICE_ID_KYE_ERGO_525V 0x0087 #define USB_DEVICE_ID_KYE_GPEN_560 0x5003 From b355850ba383232d4e0e357c1cda8cb7bfcc60bc Mon Sep 17 00:00:00 2001 From: Don Prince Date: Mon, 17 May 2010 11:42:39 +0100 Subject: [PATCH 19/22] HID: hid-samsung: add support for Creative Desktop Wireless 6000 Add support for the multimedia buttons of the Creative Desktop Wireless 6000 keyboard/mouse combo which are not currently handled by the default/samsung HID driver. Signed-off-by: Don Prince Signed-off-by: Jiri Kosina --- drivers/hid/Kconfig | 2 +- drivers/hid/hid-core.c | 1 + drivers/hid/hid-ids.h | 1 + drivers/hid/hid-samsung.c | 102 +++++++++++++++++++++++++++++++++----- 4 files changed, 93 insertions(+), 13 deletions(-) diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig index 3cf69a0a8b77..ac8e12d00c0f 100644 --- a/drivers/hid/Kconfig +++ b/drivers/hid/Kconfig @@ -273,7 +273,7 @@ config HID_SAMSUNG depends on USB_HID default !EMBEDDED ---help--- - Support for Samsung InfraRed remote control. + Support for Samsung InfraRed remote control or keyboards. config HID_SONY tristate "Sony" if EMBEDDED diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 7c77c64d3e99..c625c3419a8c 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -1346,6 +1346,7 @@ static const struct hid_device_id hid_blacklist[] = { { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH) }, { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_PIXART_IMAGING_INC_OPTICAL_TOUCH_SCREEN) }, { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE) }, + { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE) }, { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) }, { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) }, { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE) }, diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index 30cba94cfb0c..ba071b1aba3e 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h @@ -415,6 +415,7 @@ #define USB_VENDOR_ID_SAMSUNG 0x0419 #define USB_DEVICE_ID_SAMSUNG_IR_REMOTE 0x0001 +#define USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE 0x0600 #define USB_VENDOR_ID_SONY 0x054c #define USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE 0x024b diff --git a/drivers/hid/hid-samsung.c b/drivers/hid/hid-samsung.c index 510dd1340597..869a5acfc0ba 100644 --- a/drivers/hid/hid-samsung.c +++ b/drivers/hid/hid-samsung.c @@ -7,6 +7,18 @@ * Copyright (c) 2006-2007 Jiri Kosina * Copyright (c) 2007 Paul Walmsley * Copyright (c) 2008 Jiri Slaby + * Copyright (c) 2010 Don Prince + * + * + * This driver supports several HID devices: + * + * [0419:0001] Samsung IrDA remote controller (reports as Cypress USB Mouse). + * various hid report fixups for different variants. + * + * [0419:0600] Creative Desktop Wireless 6000 keyboard/mouse combo + * several key mappings used from the consumer usage page + * deviate from the USB HUT 1.12 standard. + * */ /* @@ -17,14 +29,13 @@ */ #include +#include #include #include #include "hid-ids.h" /* - * Samsung IrDA remote controller (reports as Cypress USB Mouse). - * * There are several variants for 0419:0001: * * 1. 184 byte report descriptor @@ -43,21 +54,21 @@ * 4. 171 byte report descriptor * Report #3 has an array field with logical range 0..1 instead of 1..3. */ -static inline void samsung_dev_trace(struct hid_device *hdev, +static inline void samsung_irda_dev_trace(struct hid_device *hdev, unsigned int rsize) { dev_info(&hdev->dev, "fixing up Samsung IrDA %d byte report " "descriptor\n", rsize); } -static void samsung_report_fixup(struct hid_device *hdev, __u8 *rdesc, +static void samsung_irda_report_fixup(struct hid_device *hdev, __u8 *rdesc, unsigned int rsize) { if (rsize == 184 && rdesc[175] == 0x25 && rdesc[176] == 0x40 && rdesc[177] == 0x75 && rdesc[178] == 0x30 && rdesc[179] == 0x95 && rdesc[180] == 0x01 && rdesc[182] == 0x40) { - samsung_dev_trace(hdev, 184); + samsung_irda_dev_trace(hdev, 184); rdesc[176] = 0xff; rdesc[178] = 0x08; rdesc[180] = 0x06; @@ -65,24 +76,87 @@ static void samsung_report_fixup(struct hid_device *hdev, __u8 *rdesc, } else if (rsize == 203 && rdesc[192] == 0x15 && rdesc[193] == 0x0 && rdesc[194] == 0x25 && rdesc[195] == 0x12) { - samsung_dev_trace(hdev, 203); + samsung_irda_dev_trace(hdev, 203); rdesc[193] = 0x1; rdesc[195] = 0xf; } else if (rsize == 135 && rdesc[124] == 0x15 && rdesc[125] == 0x0 && rdesc[126] == 0x25 && rdesc[127] == 0x11) { - samsung_dev_trace(hdev, 135); + samsung_irda_dev_trace(hdev, 135); rdesc[125] = 0x1; rdesc[127] = 0xe; } else if (rsize == 171 && rdesc[160] == 0x15 && rdesc[161] == 0x0 && rdesc[162] == 0x25 && rdesc[163] == 0x01) { - samsung_dev_trace(hdev, 171); + samsung_irda_dev_trace(hdev, 171); rdesc[161] = 0x1; rdesc[163] = 0x3; } } +#define samsung_kbd_mouse_map_key_clear(c) \ + hid_map_usage_clear(hi, usage, bit, max, EV_KEY, (c)) + +static int samsung_kbd_mouse_input_mapping(struct hid_device *hdev, + struct hid_input *hi, struct hid_field *field, struct hid_usage *usage, + unsigned long **bit, int *max) +{ + struct usb_interface *intf = to_usb_interface(hdev->dev.parent); + unsigned short ifnum = intf->cur_altsetting->desc.bInterfaceNumber; + + if (1 != ifnum || HID_UP_CONSUMER != (usage->hid & HID_USAGE_PAGE)) + return 0; + + dbg_hid("samsung wireless keyboard/mouse input mapping event [0x%x]\n", + usage->hid & HID_USAGE); + + switch (usage->hid & HID_USAGE) { + /* report 2 */ + case 0x0b5: samsung_kbd_mouse_map_key_clear(KEY_NEXTSONG); break; + case 0x0b6: samsung_kbd_mouse_map_key_clear(KEY_PREVIOUSSONG); break; + case 0x0b7: samsung_kbd_mouse_map_key_clear(KEY_STOPCD); break; + case 0x0cd: samsung_kbd_mouse_map_key_clear(KEY_PLAYPAUSE); break; + case 0x0e2: samsung_kbd_mouse_map_key_clear(KEY_MUTE); break; + case 0x0e9: samsung_kbd_mouse_map_key_clear(KEY_VOLUMEUP); break; + case 0x0ea: samsung_kbd_mouse_map_key_clear(KEY_VOLUMEDOWN); break; + case 0x183: samsung_kbd_mouse_map_key_clear(KEY_MEDIA); break; + case 0x195: samsung_kbd_mouse_map_key_clear(KEY_EMAIL); break; + case 0x196: samsung_kbd_mouse_map_key_clear(KEY_CALC); break; + case 0x197: samsung_kbd_mouse_map_key_clear(KEY_COMPUTER); break; + case 0x22b: samsung_kbd_mouse_map_key_clear(KEY_SEARCH); break; + case 0x22c: samsung_kbd_mouse_map_key_clear(KEY_WWW); break; + case 0x22d: samsung_kbd_mouse_map_key_clear(KEY_BACK); break; + case 0x22e: samsung_kbd_mouse_map_key_clear(KEY_FORWARD); break; + case 0x22f: samsung_kbd_mouse_map_key_clear(KEY_FAVORITES); break; + case 0x230: samsung_kbd_mouse_map_key_clear(KEY_REFRESH); break; + case 0x231: samsung_kbd_mouse_map_key_clear(KEY_STOP); break; + default: + return 0; + } + + return 1; +} + +static void samsung_report_fixup(struct hid_device *hdev, __u8 *rdesc, + unsigned int rsize) +{ + if (USB_DEVICE_ID_SAMSUNG_IR_REMOTE == hdev->product) + samsung_irda_report_fixup(hdev, rdesc, rsize); +} + +static int samsung_input_mapping(struct hid_device *hdev, struct hid_input *hi, + struct hid_field *field, struct hid_usage *usage, + unsigned long **bit, int *max) +{ + int ret = 0; + + if (USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE == hdev->product) + ret = samsung_kbd_mouse_input_mapping(hdev, + hi, field, usage, bit, max); + + return ret; +} + static int samsung_probe(struct hid_device *hdev, const struct hid_device_id *id) { @@ -95,10 +169,12 @@ static int samsung_probe(struct hid_device *hdev, goto err_free; } - if (hdev->rsize == 184) { - /* disable hidinput, force hiddev */ - cmask = (cmask & ~HID_CONNECT_HIDINPUT) | - HID_CONNECT_HIDDEV_FORCE; + if (USB_DEVICE_ID_SAMSUNG_IR_REMOTE == hdev->product) { + if (hdev->rsize == 184) { + /* disable hidinput, force hiddev */ + cmask = (cmask & ~HID_CONNECT_HIDINPUT) | + HID_CONNECT_HIDDEV_FORCE; + } } ret = hid_hw_start(hdev, cmask); @@ -114,6 +190,7 @@ static int samsung_probe(struct hid_device *hdev, static const struct hid_device_id samsung_devices[] = { { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE) }, + { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE) }, { } }; MODULE_DEVICE_TABLE(hid, samsung_devices); @@ -122,6 +199,7 @@ static struct hid_driver samsung_driver = { .name = "samsung", .id_table = samsung_devices, .report_fixup = samsung_report_fixup, + .input_mapping = samsung_input_mapping, .probe = samsung_probe, }; From d0742abaa1c396a26bb3d3ce2732988cd3faa020 Mon Sep 17 00:00:00 2001 From: Jiri Kosina Date: Mon, 17 May 2010 20:57:02 +0200 Subject: [PATCH 20/22] HID: add omitted hid-zydacron.c file Commit a9885c8f7bf62e251fc178 ("HID: Zydacron Remote Control driver") added hid-zydracon driver by Don Prince, but mistakenly omitted hid-zydracon.c file itself. Properly add the file. Reported-by: Don Prince Signed-off-by: Jiri Kosina --- drivers/hid/hid-zydacron.c | 237 +++++++++++++++++++++++++++++++++++++ 1 file changed, 237 insertions(+) create mode 100644 drivers/hid/hid-zydacron.c diff --git a/drivers/hid/hid-zydacron.c b/drivers/hid/hid-zydacron.c new file mode 100644 index 000000000000..9e8d35a203e4 --- /dev/null +++ b/drivers/hid/hid-zydacron.c @@ -0,0 +1,237 @@ +/* +* HID driver for zydacron remote control +* +* Copyright (c) 2010 Don Prince +*/ + +/* +* 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 + +#include "hid-ids.h" + +struct zc_device { + struct input_dev *input_ep81; + unsigned short last_key[4]; +}; + + +/* +* Zydacron remote control has an invalid HID report descriptor, +* that needs fixing before we can parse it. +*/ +static void zc_report_fixup(struct hid_device *hdev, __u8 *rdesc, + unsigned int rsize) +{ + if (rsize >= 253 && + rdesc[0x96] == 0xbc && rdesc[0x97] == 0xff && + rdesc[0xca] == 0xbc && rdesc[0xcb] == 0xff && + rdesc[0xe1] == 0xbc && rdesc[0xe2] == 0xff) { + dev_info(&hdev->dev, + "fixing up zydacron remote control report " + "descriptor\n"); + rdesc[0x96] = rdesc[0xca] = rdesc[0xe1] = 0x0c; + rdesc[0x97] = rdesc[0xcb] = rdesc[0xe2] = 0x00; + } +} + +#define zc_map_key_clear(c) \ + hid_map_usage_clear(hi, usage, bit, max, EV_KEY, (c)) + +static int zc_input_mapping(struct hid_device *hdev, struct hid_input *hi, + struct hid_field *field, struct hid_usage *usage, + unsigned long **bit, int *max) +{ + int i; + struct zc_device *zc = hid_get_drvdata(hdev); + zc->input_ep81 = hi->input; + + if ((usage->hid & HID_USAGE_PAGE) != HID_UP_CONSUMER) + return 0; + + dbg_hid("zynacron input mapping event [0x%x]\n", + usage->hid & HID_USAGE); + + switch (usage->hid & HID_USAGE) { + /* report 2 */ + case 0x10: + zc_map_key_clear(KEY_MODE); + break; + case 0x30: + zc_map_key_clear(KEY_SCREEN); + break; + case 0x70: + zc_map_key_clear(KEY_INFO); + break; + /* report 3 */ + case 0x04: + zc_map_key_clear(KEY_RADIO); + break; + /* report 4 */ + case 0x0d: + zc_map_key_clear(KEY_PVR); + break; + case 0x25: + zc_map_key_clear(KEY_TV); + break; + case 0x47: + zc_map_key_clear(KEY_AUDIO); + break; + case 0x49: + zc_map_key_clear(KEY_AUX); + break; + case 0x4a: + zc_map_key_clear(KEY_VIDEO); + break; + case 0x48: + zc_map_key_clear(KEY_DVD); + break; + case 0x24: + zc_map_key_clear(KEY_MENU); + break; + case 0x32: + zc_map_key_clear(KEY_TEXT); + break; + default: + return 0; + } + + for (i = 0; i < 4; i++) + zc->last_key[i] = 0; + + return 1; +} + +static int zc_raw_event(struct hid_device *hdev, struct hid_report *report, + u8 *data, int size) +{ + struct zc_device *zc = hid_get_drvdata(hdev); + int ret = 0; + unsigned key; + unsigned short index; + + if (report->id == data[0]) { + + /* break keys */ + for (index = 0; index < 4; index++) { + key = zc->last_key[index]; + if (key) { + input_event(zc->input_ep81, EV_KEY, key, 0); + zc->last_key[index] = 0; + } + } + + key = 0; + switch (report->id) { + case 0x02: + case 0x03: + switch (data[1]) { + case 0x10: + key = KEY_MODE; + index = 0; + break; + case 0x30: + key = KEY_SCREEN; + index = 1; + break; + case 0x70: + key = KEY_INFO; + index = 2; + break; + case 0x04: + key = KEY_RADIO; + index = 3; + break; + } + + if (key) { + input_event(zc->input_ep81, EV_KEY, key, 1); + zc->last_key[index] = key; + } + + ret = 1; + break; + } + } + + return ret; +} + +static int zc_probe(struct hid_device *hdev, const struct hid_device_id *id) +{ + int ret; + struct zc_device *zc; + + zc = kzalloc(sizeof(*zc), GFP_KERNEL); + if (zc == NULL) { + dev_err(&hdev->dev, "zydacron: can't alloc descriptor\n"); + return -ENOMEM; + } + + hid_set_drvdata(hdev, zc); + + ret = hid_parse(hdev); + if (ret) { + dev_err(&hdev->dev, "zydacron: parse failed\n"); + goto err_free; + } + + ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); + if (ret) { + dev_err(&hdev->dev, "zydacron: hw start failed\n"); + goto err_free; + } + + return 0; +err_free: + kfree(zc); + + return ret; +} + +static void zc_remove(struct hid_device *hdev) +{ + struct zc_device *zc = hid_get_drvdata(hdev); + + hid_hw_stop(hdev); + + if (NULL != zc) + kfree(zc); +} + +static const struct hid_device_id zc_devices[] = { + { HID_USB_DEVICE(USB_VENDOR_ID_ZYDACRON, USB_DEVICE_ID_ZYDACRON_REMOTE_CONTROL) }, + { } +}; +MODULE_DEVICE_TABLE(hid, zc_devices); + +static struct hid_driver zc_driver = { + .name = "zydacron", + .id_table = zc_devices, + .report_fixup = zc_report_fixup, + .input_mapping = zc_input_mapping, + .raw_event = zc_raw_event, + .probe = zc_probe, + .remove = zc_remove, +}; + +static int __init zc_init(void) +{ + return hid_register_driver(&zc_driver); +} + +static void __exit zc_exit(void) +{ + hid_unregister_driver(&zc_driver); +} + +module_init(zc_init); +module_exit(zc_exit); +MODULE_LICENSE("GPL"); From 117ea33a18392685b92928bbaa4e84dbc5be8f93 Mon Sep 17 00:00:00 2001 From: Don Prince Date: Mon, 17 May 2010 20:18:21 +0100 Subject: [PATCH 21/22] HID: hid-samsung: remove redundant key mappings Remove 7 redundant key mappings from Desktop Wireless 6000 that are already handled by the default hid code. Reported-by: Robert Schedel Signed-off-by: Don Prince Signed-off-by: Jiri Kosina --- drivers/hid/hid-samsung.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/hid/hid-samsung.c b/drivers/hid/hid-samsung.c index 869a5acfc0ba..bda0fd60c98d 100644 --- a/drivers/hid/hid-samsung.c +++ b/drivers/hid/hid-samsung.c @@ -112,13 +112,6 @@ static int samsung_kbd_mouse_input_mapping(struct hid_device *hdev, switch (usage->hid & HID_USAGE) { /* report 2 */ - case 0x0b5: samsung_kbd_mouse_map_key_clear(KEY_NEXTSONG); break; - case 0x0b6: samsung_kbd_mouse_map_key_clear(KEY_PREVIOUSSONG); break; - case 0x0b7: samsung_kbd_mouse_map_key_clear(KEY_STOPCD); break; - case 0x0cd: samsung_kbd_mouse_map_key_clear(KEY_PLAYPAUSE); break; - case 0x0e2: samsung_kbd_mouse_map_key_clear(KEY_MUTE); break; - case 0x0e9: samsung_kbd_mouse_map_key_clear(KEY_VOLUMEUP); break; - case 0x0ea: samsung_kbd_mouse_map_key_clear(KEY_VOLUMEDOWN); break; case 0x183: samsung_kbd_mouse_map_key_clear(KEY_MEDIA); break; case 0x195: samsung_kbd_mouse_map_key_clear(KEY_EMAIL); break; case 0x196: samsung_kbd_mouse_map_key_clear(KEY_CALC); break; From a8ab5d58b0238b8199cc699b8dff7c5e1da24138 Mon Sep 17 00:00:00 2001 From: Alan Ott Date: Sun, 16 May 2010 18:07:09 -0400 Subject: [PATCH 22/22] HID: hidraw: Use Interrupt Endpoint for OUT Transfers if Available This patch makes the hidraw driver use the first Interrupt OUT endpoint for HID transfers to the device if such an endpoint exists. This is consistent with the behavior of the hiddev driver, and the logic is similar. From the USB HID specification: The Interrupt Out pipe is optional. If a device declares an Interrupt Out endpoint then Output reports are transmitted by the host to the device through the Interrupt Out endpoint. If no Interrupt Out endpoint is declared then Output reports are transmitted to a device through the Control endpoint, using Set_Report(Output) requests. Signed-off-by: Alan Ott Signed-off-by: Jiri Kosina --- drivers/hid/usbhid/hid-core.c | 40 ++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c index 245aef0de8f2..f9640a362caa 100644 --- a/drivers/hid/usbhid/hid-core.c +++ b/drivers/hid/usbhid/hid-core.c @@ -807,16 +807,36 @@ static int usbhid_output_raw_report(struct hid_device *hid, __u8 *buf, size_t co struct usb_host_interface *interface = intf->cur_altsetting; int ret; - ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), - HID_REQ_SET_REPORT, - USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE, - ((report_type + 1) << 8) | *buf, - interface->desc.bInterfaceNumber, buf + 1, count - 1, - USB_CTRL_SET_TIMEOUT); - - /* count also the report id */ - if (ret > 0) - ret++; + if (usbhid->urbout) { + int actual_length; + int skipped_report_id = 0; + if (buf[0] == 0x0) { + /* Don't send the Report ID */ + buf++; + count--; + skipped_report_id = 1; + } + ret = usb_interrupt_msg(dev, usbhid->urbout->pipe, + buf, count, &actual_length, + USB_CTRL_SET_TIMEOUT); + /* return the number of bytes transferred */ + if (ret == 0) { + ret = actual_length; + /* count also the report id */ + if (skipped_report_id) + ret++; + } + } else { + ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), + HID_REQ_SET_REPORT, + USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE, + ((report_type + 1) << 8) | *buf, + interface->desc.bInterfaceNumber, buf + 1, count - 1, + USB_CTRL_SET_TIMEOUT); + /* count also the report id */ + if (ret > 0) + ret++; + } return ret; }