Skip to content

Commit 851328f

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid
Pull HID updates from Jiri Kosina: "to receive patches queued for 4.3 merge window in HID tree. Highlights: - a lot of improvements (regarding supported features and devices) to Wacom driver, from Aaron Skomra and Jason Gerecke - a lot of functional fixes and support for large I2C transfer to cp2112 driver, from Ellen Wang - HW support improvements to RMI driver, from Andrew Duggan - quite some small fixes and device ID additions all over the place" * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid: (44 commits) HID: wacom: wacom_setup_numbered_buttons is local to wacom_wac HID: wacom: Add support for Express Key Remote. HID: wacom: Set button bits based on a new numbered_buttons HID: quirks: add QUIRK_NOGET for an other TPV touchscreen HID: usbhid: Fix the check for HID_RESET_PENDING in hid_io_error HID: i2c-hid: Only disable irq wake if it was successfully enabled during suspend HID: wacom: Use tablet-provided touch height/width values for INTUOSHT HID: gembird: add new driver to fix Gembird JPD-DualForce 2 HID: lenovo: Hide middle-button press until release HID: lenovo: Add missing return-value check HID: lenovo: Use constants for axes names HID: wacom: Simplify 'wacom_pl_irq' HID: wacom: Do not repeatedly attempt to set device mode on error HID: wacom: Do not repeatedly attempt to set device mode on error HID: wacom: Remove WACOM_QUIRK_NO_INPUT HID: wacom: Replace WACOM_QUIRK_MONITOR with WACOM_DEVICETYPE_WL_MONITOR HID: wacom: Use calculated pkglen for wireless touch interface HID: sony: Fix DS4 controller reporting rate issues HID: chicony: Add support for Acer Aspire Switch 12 HID: hid-lg: Add USBID for Logitech G29 Wheel ...
2 parents 2d678b6 + f212bd9 commit 851328f

26 files changed

+1144
-308
lines changed

Documentation/ABI/testing/sysfs-driver-wacom

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,22 @@ Description:
7777
The format is also scrambled, like in the USB mode, and it can
7878
be summarized by converting 76543210 into GECA6420.
7979
HGFEDCBA HFDB7531
80+
81+
What: /sys/bus/hid/devices/<bus>:<vid>:<pid>.<n>/wacom_remote/unpair_remote
82+
Date: July 2015
83+
84+
Description:
85+
Writing the character sequence '*' followed by a newline to
86+
this file will delete all of the current pairings on the
87+
device. Other character sequences are reserved. This file is
88+
write only.
89+
90+
What: /sys/bus/hid/devices/<bus>:<vid>:<pid>.<n>/wacom_remote/<serial_number>/remote_mode
91+
Date: July 2015
92+
93+
Description:
94+
Reading from this file reports the mode status of the
95+
remote as indicated by the LED lights on the device. If no
96+
reports have been received from the paired device, reading
97+
from this file will report '-1'. The mode is read-only
98+
and cannot be set through the driver.

drivers/hid/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,12 @@ config HID_EZKEY
251251
---help---
252252
Support for Ezkey BTC 8193 keyboard.
253253

254+
config HID_GEMBIRD
255+
tristate "Gembird Joypad"
256+
depends on HID
257+
---help---
258+
Support for Gembird JPD-DualForce 2.
259+
254260
config HID_HOLTEK
255261
tristate "Holtek HID devices"
256262
depends on USB_HID
@@ -480,6 +486,7 @@ config HID_MULTITOUCH
480486
- Atmel panels
481487
- Cando dual touch panels
482488
- Chunghwa panels
489+
- CJTouch panels
483490
- CVTouch panels
484491
- Cypress TrueTouch panels
485492
- Elan Microelectronics touch panels

drivers/hid/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ obj-$(CONFIG_HID_EMS_FF) += hid-emsff.o
3636
obj-$(CONFIG_HID_ELECOM) += hid-elecom.o
3737
obj-$(CONFIG_HID_ELO) += hid-elo.o
3838
obj-$(CONFIG_HID_EZKEY) += hid-ezkey.o
39+
obj-$(CONFIG_HID_GEMBIRD) += hid-gembird.o
3940
obj-$(CONFIG_HID_GT683R) += hid-gt683r.o
4041
obj-$(CONFIG_HID_GYRATION) += hid-gyration.o
4142
obj-$(CONFIG_HID_HOLTEK) += hid-holtek-kbd.o

drivers/hid/hid-chicony.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <linux/input.h>
2121
#include <linux/hid.h>
2222
#include <linux/module.h>
23+
#include <linux/usb.h>
2324

2425
#include "hid-ids.h"
2526

@@ -57,17 +58,42 @@ static int ch_input_mapping(struct hid_device *hdev, struct hid_input *hi,
5758
return 1;
5859
}
5960

61+
static __u8 *ch_switch12_report_fixup(struct hid_device *hdev, __u8 *rdesc,
62+
unsigned int *rsize)
63+
{
64+
struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
65+
66+
if (intf->cur_altsetting->desc.bInterfaceNumber == 1) {
67+
/* Change usage maximum and logical maximum from 0x7fff to
68+
* 0x2fff, so they don't exceed HID_MAX_USAGES */
69+
switch (hdev->product) {
70+
case USB_DEVICE_ID_CHICONY_ACER_SWITCH12:
71+
if (*rsize >= 128 && rdesc[64] == 0xff && rdesc[65] == 0x7f
72+
&& rdesc[69] == 0xff && rdesc[70] == 0x7f) {
73+
hid_info(hdev, "Fixing up report descriptor\n");
74+
rdesc[65] = rdesc[70] = 0x2f;
75+
}
76+
break;
77+
}
78+
79+
}
80+
return rdesc;
81+
}
82+
83+
6084
static const struct hid_device_id ch_devices[] = {
6185
{ HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_TACTICAL_PAD) },
6286
{ HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS2) },
6387
{ HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_AK1D) },
88+
{ HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_ACER_SWITCH12) },
6489
{ }
6590
};
6691
MODULE_DEVICE_TABLE(hid, ch_devices);
6792

6893
static struct hid_driver ch_driver = {
6994
.name = "chicony",
7095
.id_table = ch_devices,
96+
.report_fixup = ch_switch12_report_fixup,
7197
.input_mapping = ch_input_mapping,
7298
};
7399
module_hid_driver(ch_driver);

drivers/hid/hid-core.c

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,7 @@ static int hid_parser_local(struct hid_parser *parser, struct hid_item *item)
427427
{
428428
__u32 data;
429429
unsigned n;
430+
__u32 count;
430431

431432
data = item_udata(item);
432433

@@ -490,6 +491,24 @@ static int hid_parser_local(struct hid_parser *parser, struct hid_item *item)
490491
if (item->size <= 2)
491492
data = (parser->global.usage_page << 16) + data;
492493

494+
count = data - parser->local.usage_minimum;
495+
if (count + parser->local.usage_index >= HID_MAX_USAGES) {
496+
/*
497+
* We do not warn if the name is not set, we are
498+
* actually pre-scanning the device.
499+
*/
500+
if (dev_name(&parser->device->dev))
501+
hid_warn(parser->device,
502+
"ignoring exceeding usage max\n");
503+
data = HID_MAX_USAGES - parser->local.usage_index +
504+
parser->local.usage_minimum - 1;
505+
if (data <= 0) {
506+
hid_err(parser->device,
507+
"no more usage index available\n");
508+
return -1;
509+
}
510+
}
511+
493512
for (n = parser->local.usage_minimum; n <= data; n++)
494513
if (hid_add_usage(parser, n)) {
495514
dbg_hid("hid_add_usage failed\n");
@@ -705,8 +724,9 @@ static void hid_scan_collection(struct hid_parser *parser, unsigned type)
705724
hid->group = HID_GROUP_SENSOR_HUB;
706725

707726
if (hid->vendor == USB_VENDOR_ID_MICROSOFT &&
708-
(hid->product == USB_DEVICE_ID_MS_TYPE_COVER_3 ||
709-
hid->product == USB_DEVICE_ID_MS_TYPE_COVER_3_JP ||
727+
(hid->product == USB_DEVICE_ID_MS_TYPE_COVER_PRO_3 ||
728+
hid->product == USB_DEVICE_ID_MS_TYPE_COVER_PRO_3_JP ||
729+
hid->product == USB_DEVICE_ID_MS_TYPE_COVER_3 ||
710730
hid->product == USB_DEVICE_ID_MS_POWER_COVER) &&
711731
hid->group == HID_GROUP_MULTITOUCH)
712732
hid->group = HID_GROUP_GENERIC;
@@ -1807,6 +1827,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
18071827
{ HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS) },
18081828
{ HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS2) },
18091829
{ HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_AK1D) },
1830+
{ HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_ACER_SWITCH12) },
18101831
{ HID_USB_DEVICE(USB_VENDOR_ID_CREATIVELABS, USB_DEVICE_ID_PRODIKEYS_PCMIDI) },
18111832
{ HID_USB_DEVICE(USB_VENDOR_ID_CYGNAL, USB_DEVICE_ID_CYGNAL_CP2112) },
18121833
{ HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_1) },
@@ -1823,6 +1844,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
18231844
{ HID_USB_DEVICE(USB_VENDOR_ID_EZKEY, USB_DEVICE_ID_BTC_8193) },
18241845
{ HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PSX_ADAPTOR) },
18251846
{ HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PCS_ADAPTOR) },
1847+
{ HID_USB_DEVICE(USB_VENDOR_ID_GEMBIRD, USB_DEVICE_ID_GEMBIRD_JPD_DUALFORCE2) },
18261848
{ HID_USB_DEVICE(USB_VENDOR_ID_GREENASIA, 0x0003) },
18271849
{ HID_USB_DEVICE(USB_VENDOR_ID_GREENASIA, 0x0012) },
18281850
{ HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE) },
@@ -1905,8 +1927,9 @@ static const struct hid_device_id hid_have_special_driver[] = {
19051927
{ HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_DIGITAL_MEDIA_3K) },
19061928
{ HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_WIRELESS_OPTICAL_DESKTOP_3_0) },
19071929
{ HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_OFFICE_KB) },
1930+
{ HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_PRO_3) },
1931+
{ HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_PRO_3_JP) },
19081932
{ HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_3) },
1909-
{ HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_3_JP) },
19101933
{ HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_POWER_COVER) },
19111934
{ HID_USB_DEVICE(USB_VENDOR_ID_MONTEREY, USB_DEVICE_ID_GENIUS_KB29E) },
19121935
{ HID_USB_DEVICE(USB_VENDOR_ID_MSI, USB_DEVICE_ID_MSI_GT683R_LED_PANEL) },

drivers/hid/hid-cp2112.c

Lines changed: 80 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ struct cp2112_device {
156156
wait_queue_head_t wait;
157157
u8 read_data[61];
158158
u8 read_length;
159+
u8 hwversion;
159160
int xfer_status;
160161
atomic_t read_avail;
161162
atomic_t xfer_avail;
@@ -446,33 +447,71 @@ static int cp2112_i2c_write_req(void *buf, u8 slave_address, u8 *data,
446447
return data_length + 3;
447448
}
448449

450+
static int cp2112_i2c_write_read_req(void *buf, u8 slave_address,
451+
u8 *addr, int addr_length,
452+
int read_length)
453+
{
454+
struct cp2112_write_read_req_report *report = buf;
455+
456+
if (read_length < 1 || read_length > 512 ||
457+
addr_length > sizeof(report->target_address))
458+
return -EINVAL;
459+
460+
report->report = CP2112_DATA_WRITE_READ_REQUEST;
461+
report->slave_address = slave_address << 1;
462+
report->length = cpu_to_be16(read_length);
463+
report->target_address_length = addr_length;
464+
memcpy(report->target_address, addr, addr_length);
465+
return addr_length + 5;
466+
}
467+
449468
static int cp2112_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
450469
int num)
451470
{
452471
struct cp2112_device *dev = (struct cp2112_device *)adap->algo_data;
453472
struct hid_device *hdev = dev->hdev;
454473
u8 buf[64];
455474
ssize_t count;
475+
ssize_t read_length = 0;
476+
u8 *read_buf = NULL;
456477
unsigned int retries;
457478
int ret;
458479

459480
hid_dbg(hdev, "I2C %d messages\n", num);
460481

461-
if (num != 1) {
482+
if (num == 1) {
483+
if (msgs->flags & I2C_M_RD) {
484+
hid_dbg(hdev, "I2C read %#04x len %d\n",
485+
msgs->addr, msgs->len);
486+
read_length = msgs->len;
487+
read_buf = msgs->buf;
488+
count = cp2112_read_req(buf, msgs->addr, msgs->len);
489+
} else {
490+
hid_dbg(hdev, "I2C write %#04x len %d\n",
491+
msgs->addr, msgs->len);
492+
count = cp2112_i2c_write_req(buf, msgs->addr,
493+
msgs->buf, msgs->len);
494+
}
495+
if (count < 0)
496+
return count;
497+
} else if (dev->hwversion > 1 && /* no repeated start in rev 1 */
498+
num == 2 &&
499+
msgs[0].addr == msgs[1].addr &&
500+
!(msgs[0].flags & I2C_M_RD) && (msgs[1].flags & I2C_M_RD)) {
501+
hid_dbg(hdev, "I2C write-read %#04x wlen %d rlen %d\n",
502+
msgs[0].addr, msgs[0].len, msgs[1].len);
503+
read_length = msgs[1].len;
504+
read_buf = msgs[1].buf;
505+
count = cp2112_i2c_write_read_req(buf, msgs[0].addr,
506+
msgs[0].buf, msgs[0].len, msgs[1].len);
507+
if (count < 0)
508+
return count;
509+
} else {
462510
hid_err(hdev,
463511
"Multi-message I2C transactions not supported\n");
464512
return -EOPNOTSUPP;
465513
}
466514

467-
if (msgs->flags & I2C_M_RD)
468-
count = cp2112_read_req(buf, msgs->addr, msgs->len);
469-
else
470-
count = cp2112_i2c_write_req(buf, msgs->addr, msgs->buf,
471-
msgs->len);
472-
473-
if (count < 0)
474-
return count;
475-
476515
ret = hid_hw_power(hdev, PM_HINT_FULLON);
477516
if (ret < 0) {
478517
hid_err(hdev, "power management error: %d\n", ret);
@@ -508,21 +547,34 @@ static int cp2112_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
508547
goto power_normal;
509548
}
510549

511-
if (!(msgs->flags & I2C_M_RD))
512-
goto finish;
513-
514-
ret = cp2112_read(dev, msgs->buf, msgs->len);
515-
if (ret < 0)
516-
goto power_normal;
517-
if (ret != msgs->len) {
518-
hid_warn(hdev, "short read: %d < %d\n", ret, msgs->len);
519-
ret = -EIO;
520-
goto power_normal;
550+
for (count = 0; count < read_length;) {
551+
ret = cp2112_read(dev, read_buf + count, read_length - count);
552+
if (ret < 0)
553+
goto power_normal;
554+
if (ret == 0) {
555+
hid_err(hdev, "read returned 0\n");
556+
ret = -EIO;
557+
goto power_normal;
558+
}
559+
count += ret;
560+
if (count > read_length) {
561+
/*
562+
* The hardware returned too much data.
563+
* This is mostly harmless because cp2112_read()
564+
* has a limit check so didn't overrun our
565+
* buffer. Nevertheless, we return an error
566+
* because something is seriously wrong and
567+
* it shouldn't go unnoticed.
568+
*/
569+
hid_err(hdev, "long read: %d > %zd\n",
570+
ret, read_length - count + ret);
571+
ret = -EIO;
572+
goto power_normal;
573+
}
521574
}
522575

523-
finish:
524576
/* return the number of transferred messages */
525-
ret = 1;
577+
ret = num;
526578

527579
power_normal:
528580
hid_hw_power(hdev, PM_HINT_NORMAL);
@@ -537,7 +589,7 @@ static int cp2112_xfer(struct i2c_adapter *adap, u16 addr,
537589
struct cp2112_device *dev = (struct cp2112_device *)adap->algo_data;
538590
struct hid_device *hdev = dev->hdev;
539591
u8 buf[64];
540-
__be16 word;
592+
__le16 word;
541593
ssize_t count;
542594
size_t read_length = 0;
543595
unsigned int retries;
@@ -554,7 +606,7 @@ static int cp2112_xfer(struct i2c_adapter *adap, u16 addr,
554606
if (I2C_SMBUS_READ == read_write)
555607
count = cp2112_read_req(buf, addr, read_length);
556608
else
557-
count = cp2112_write_req(buf, addr, data->byte, NULL,
609+
count = cp2112_write_req(buf, addr, command, NULL,
558610
0);
559611
break;
560612
case I2C_SMBUS_BYTE_DATA:
@@ -569,7 +621,7 @@ static int cp2112_xfer(struct i2c_adapter *adap, u16 addr,
569621
break;
570622
case I2C_SMBUS_WORD_DATA:
571623
read_length = 2;
572-
word = cpu_to_be16(data->word);
624+
word = cpu_to_le16(data->word);
573625

574626
if (I2C_SMBUS_READ == read_write)
575627
count = cp2112_write_read_req(buf, addr, read_length,
@@ -582,7 +634,7 @@ static int cp2112_xfer(struct i2c_adapter *adap, u16 addr,
582634
size = I2C_SMBUS_WORD_DATA;
583635
read_write = I2C_SMBUS_READ;
584636
read_length = 2;
585-
word = cpu_to_be16(data->word);
637+
word = cpu_to_le16(data->word);
586638

587639
count = cp2112_write_read_req(buf, addr, read_length, command,
588640
(u8 *)&word, 2);
@@ -675,7 +727,7 @@ static int cp2112_xfer(struct i2c_adapter *adap, u16 addr,
675727
data->byte = buf[0];
676728
break;
677729
case I2C_SMBUS_WORD_DATA:
678-
data->word = be16_to_cpup((__be16 *)buf);
730+
data->word = le16_to_cpup((__le16 *)buf);
679731
break;
680732
case I2C_SMBUS_BLOCK_DATA:
681733
if (read_length > I2C_SMBUS_BLOCK_MAX) {
@@ -1030,6 +1082,7 @@ static int cp2112_probe(struct hid_device *hdev, const struct hid_device_id *id)
10301082
dev->adap.dev.parent = &hdev->dev;
10311083
snprintf(dev->adap.name, sizeof(dev->adap.name),
10321084
"CP2112 SMBus Bridge on hiddev%d", hdev->minor);
1085+
dev->hwversion = buf[2];
10331086
init_waitqueue_head(&dev->wait);
10341087

10351088
hid_device_io_start(hdev);

0 commit comments

Comments
 (0)