Skip to content

Commit 8c4de9b

Browse files
author
Jiri Kosina
committed
Merge branches 'for-4.3/chicony', 'for-4.3/cp2112', 'for-4.3/i2c-hid', 'for-4.3/lenovo', 'for-4.3/logitech', 'for-4.3/multitouch', 'for-4.3/picolcd', 'for-4.3/rmi', 'for-4.3/sensor-hub', 'for-4.3/sony' and 'for-4.3/wacom' into for-linus
12 parents 067e260 + 9a1d78a + 29e2d6d + d1c4803 + 3cb5ff0 + c873d9a + 070f63b + 4b8a826 + 9a98b33 + 21589eb + 824deff + 5397df1 commit 8c4de9b

20 files changed

+972
-291
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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,7 @@ config HID_MULTITOUCH
486486
- Atmel panels
487487
- Cando dual touch panels
488488
- Chunghwa panels
489+
- CJTouch panels
489490
- CVTouch panels
490491
- Cypress TrueTouch panels
491492
- Elan Microelectronics touch panels

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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1826,6 +1826,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
18261826
{ HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS) },
18271827
{ HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS2) },
18281828
{ HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_AK1D) },
1829+
{ HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_ACER_SWITCH12) },
18291830
{ HID_USB_DEVICE(USB_VENDOR_ID_CREATIVELABS, USB_DEVICE_ID_PRODIKEYS_PCMIDI) },
18301831
{ HID_USB_DEVICE(USB_VENDOR_ID_CYGNAL, USB_DEVICE_ID_CYGNAL_CP2112) },
18311832
{ HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_1) },

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);

drivers/hid/hid-ids.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,12 +233,17 @@
233233
#define USB_DEVICE_ID_CHICONY_PIXART_USB_OPTICAL_MOUSE 0x1053
234234
#define USB_DEVICE_ID_CHICONY_WIRELESS2 0x1123
235235
#define USB_DEVICE_ID_CHICONY_AK1D 0x1125
236+
#define USB_DEVICE_ID_CHICONY_ACER_SWITCH12 0x1421
236237

237238
#define USB_VENDOR_ID_CHUNGHWAT 0x2247
238239
#define USB_DEVICE_ID_CHUNGHWAT_MULTITOUCH 0x0001
239240

240241
#define USB_VENDOR_ID_CIDC 0x1677
241242

243+
#define USB_VENDOR_ID_CJTOUCH 0x24b8
244+
#define USB_DEVICE_ID_CJTOUCH_MULTI_TOUCH_0020 0x0020
245+
#define USB_DEVICE_ID_CJTOUCH_MULTI_TOUCH_0040 0x0040
246+
242247
#define USB_VENDOR_ID_CMEDIA 0x0d8c
243248
#define USB_DEVICE_ID_CM109 0x000e
244249

@@ -503,6 +508,9 @@
503508
#define USB_VENDOR_ID_IRTOUCHSYSTEMS 0x6615
504509
#define USB_DEVICE_ID_IRTOUCH_INFRARED_USB 0x0070
505510

511+
#define USB_VENDOR_ID_ITE 0x048d
512+
#define USB_DEVICE_ID_ITE_LENOVO_YOGA 0x8386
513+
506514
#define USB_VENDOR_ID_JABRA 0x0b0e
507515
#define USB_DEVICE_ID_JABRA_SPEAK_410 0x0412
508516
#define USB_DEVICE_ID_JABRA_SPEAK_510 0x0420
@@ -605,6 +613,7 @@
605613
#define USB_DEVICE_ID_LOGITECH_DUAL_ACTION 0xc216
606614
#define USB_DEVICE_ID_LOGITECH_RUMBLEPAD2 0xc218
607615
#define USB_DEVICE_ID_LOGITECH_RUMBLEPAD2_2 0xc219
616+
#define USB_DEVICE_ID_LOGITECH_G29_WHEEL 0xc24f
608617
#define USB_DEVICE_ID_LOGITECH_WINGMAN_F3D 0xc283
609618
#define USB_DEVICE_ID_LOGITECH_FORCE3D_PRO 0xc286
610619
#define USB_DEVICE_ID_LOGITECH_FLIGHT_SYSTEM_G940 0xc287

0 commit comments

Comments
 (0)