Skip to content

Commit 0f1b1e6

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: - substantial cleanup of the generic and transport layers, in the direction of an ultimate goal of making struct hid_device completely transport independent, by Benjamin Tissoires - cp2112 driver from David Barksdale - a lot of fixes and new hardware support (Dualshock 4) to hid-sony driver, by Frank Praznik - support for Win 8.1 multitouch protocol by Andrew Duggan - other smaller fixes / device ID additions * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid: (75 commits) HID: sony: fix force feedback mismerge HID: sony: Set the quriks flag for Bluetooth controllers HID: sony: Fix Sixaxis cable state detection HID: uhid: Add UHID_CREATE2 + UHID_INPUT2 HID: hyperv: fix _raw_request() prototype HID: hyperv: Implement a stub raw_request() entry point HID: hid-sensor-hub: fix sleeping function called from invalid context HID: multitouch: add support for Win 8.1 multitouch touchpads HID: remove hid_output_raw_report transport implementations HID: sony: do not rely on hid_output_raw_report HID: cp2112: remove the last hid_output_raw_report() call HID: cp2112: remove various hid_out_raw_report calls HID: multitouch: add support of other generic collections in hid-mt HID: multitouch: remove pen special handling HID: multitouch: remove registered devices with default behavior HID: hidp: Add a comment that some devices depend on the current behavior of uniq HID: sony: Prevent duplicate controller connections. HID: sony: Perform a boundry check on the sixaxis battery level index. HID: sony: Fix work queue issues HID: sony: Fix multi-line comment styling ...
2 parents 159d813 + 3ae821e commit 0f1b1e6

29 files changed

+3022
-658
lines changed

Documentation/hid/hid-transport.txt

Lines changed: 317 additions & 0 deletions
Large diffs are not rendered by default.

Documentation/hid/uhid.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ the request was handled successfully.
9393
event to the kernel. The payload is of type struct uhid_create_req and
9494
contains information about your device. You can start I/O now.
9595

96+
UHID_CREATE2:
97+
Same as UHID_CREATE, but the HID report descriptor data (rd_data) is an array
98+
inside struct uhid_create2_req, instead of a pointer to a separate array.
99+
Enables use from languages that don't support pointers, e.g. Python.
100+
96101
UHID_DESTROY:
97102
This destroys the internal HID device. No further I/O will be accepted. There
98103
may still be pending messages that you can receive with read() but no further
@@ -105,6 +110,12 @@ the request was handled successfully.
105110
contains a data-payload. This is the raw data that you read from your device.
106111
The kernel will parse the HID reports and react on it.
107112

113+
UHID_INPUT2:
114+
Same as UHID_INPUT, but the data array is the last field of uhid_input2_req.
115+
Enables userspace to write only the required bytes to kernel (ev.type +
116+
ev.u.input2.size + the part of the data array that matters), instead of
117+
the entire struct uhid_input2_req.
118+
108119
UHID_FEATURE_ANSWER:
109120
If you receive a UHID_FEATURE request you must answer with this request. You
110121
must copy the "id" field from the request into the answer. Set the "err" field

drivers/hid/Kconfig

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,15 @@ config HID_PRODIKEYS
175175
multimedia keyboard, but will lack support for the musical keyboard
176176
and some additional multimedia keys.
177177

178+
config HID_CP2112
179+
tristate "Silicon Labs CP2112 HID USB-to-SMBus Bridge support"
180+
depends on USB_HID && I2C && GPIOLIB
181+
---help---
182+
Support for Silicon Labs CP2112 HID USB to SMBus Master Bridge.
183+
This is a HID device driver which registers as an i2c adapter
184+
and gpiochip to expose these functions of the CP2112. The
185+
customizable USB descriptor fields are exposed as sysfs attributes.
186+
178187
config HID_CYPRESS
179188
tristate "Cypress mouse and barcode readers" if EXPERT
180189
depends on HID
@@ -608,25 +617,27 @@ config HID_SAMSUNG
608617
Support for Samsung InfraRed remote control or keyboards.
609618

610619
config HID_SONY
611-
tristate "Sony PS2/3 accessories"
620+
tristate "Sony PS2/3/4 accessories"
612621
depends on USB_HID
613622
depends on NEW_LEDS
614623
depends on LEDS_CLASS
624+
select POWER_SUPPLY
615625
---help---
616626
Support for
617627

618628
* Sony PS3 6-axis controllers
629+
* Sony PS4 DualShock 4 controllers
619630
* Buzz controllers
620631
* Sony PS3 Blue-ray Disk Remote Control (Bluetooth)
621632
* Logitech Harmony adapter for Sony Playstation 3 (Bluetooth)
622633

623634
config SONY_FF
624-
bool "Sony PS2/3 accessories force feedback support"
635+
bool "Sony PS2/3/4 accessories force feedback support"
625636
depends on HID_SONY
626637
select INPUT_FF_MEMLESS
627638
---help---
628-
Say Y here if you have a Sony PS2/3 accessory and want to enable force
629-
feedback support for it.
639+
Say Y here if you have a Sony PS2/3/4 accessory and want to enable
640+
force feedback support for it.
630641

631642
config HID_SPEEDLINK
632643
tristate "Speedlink VAD Cezanne mouse support"

drivers/hid/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ obj-$(CONFIG_HID_AUREAL) += hid-aureal.o
4141
obj-$(CONFIG_HID_BELKIN) += hid-belkin.o
4242
obj-$(CONFIG_HID_CHERRY) += hid-cherry.o
4343
obj-$(CONFIG_HID_CHICONY) += hid-chicony.o
44+
obj-$(CONFIG_HID_CP2112) += hid-cp2112.o
4445
obj-$(CONFIG_HID_CYPRESS) += hid-cypress.o
4546
obj-$(CONFIG_HID_DRAGONRISE) += hid-dr.o
4647
obj-$(CONFIG_HID_EMS_FF) += hid-emsff.o

drivers/hid/hid-core.c

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1248,6 +1248,11 @@ void hid_output_report(struct hid_report *report, __u8 *data)
12481248
}
12491249
EXPORT_SYMBOL_GPL(hid_output_report);
12501250

1251+
static int hid_report_len(struct hid_report *report)
1252+
{
1253+
return ((report->size - 1) >> 3) + 1 + (report->id > 0) + 7;
1254+
}
1255+
12511256
/*
12521257
* Allocator for buffer that is going to be passed to hid_output_report()
12531258
*/
@@ -1258,7 +1263,7 @@ u8 *hid_alloc_report_buf(struct hid_report *report, gfp_t flags)
12581263
* of implement() working on 8 byte chunks
12591264
*/
12601265

1261-
int len = ((report->size - 1) >> 3) + 1 + (report->id > 0) + 7;
1266+
int len = hid_report_len(report);
12621267

12631268
return kmalloc(len, flags);
12641269
}
@@ -1314,6 +1319,41 @@ static struct hid_report *hid_get_report(struct hid_report_enum *report_enum,
13141319
return report;
13151320
}
13161321

1322+
/*
1323+
* Implement a generic .request() callback, using .raw_request()
1324+
* DO NOT USE in hid drivers directly, but through hid_hw_request instead.
1325+
*/
1326+
void __hid_request(struct hid_device *hid, struct hid_report *report,
1327+
int reqtype)
1328+
{
1329+
char *buf;
1330+
int ret;
1331+
int len;
1332+
1333+
buf = hid_alloc_report_buf(report, GFP_KERNEL);
1334+
if (!buf)
1335+
return;
1336+
1337+
len = hid_report_len(report);
1338+
1339+
if (reqtype == HID_REQ_SET_REPORT)
1340+
hid_output_report(report, buf);
1341+
1342+
ret = hid->ll_driver->raw_request(hid, report->id, buf, len,
1343+
report->type, reqtype);
1344+
if (ret < 0) {
1345+
dbg_hid("unable to complete request: %d\n", ret);
1346+
goto out;
1347+
}
1348+
1349+
if (reqtype == HID_REQ_GET_REPORT)
1350+
hid_input_report(hid, report->type, buf, ret, 0);
1351+
1352+
out:
1353+
kfree(buf);
1354+
}
1355+
EXPORT_SYMBOL_GPL(__hid_request);
1356+
13171357
int hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size,
13181358
int interrupt)
13191359
{
@@ -1693,6 +1733,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
16931733
{ HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS2) },
16941734
{ HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_AK1D) },
16951735
{ HID_USB_DEVICE(USB_VENDOR_ID_CREATIVELABS, USB_DEVICE_ID_PRODIKEYS_PCMIDI) },
1736+
{ HID_USB_DEVICE(USB_VENDOR_ID_CYGNAL, USB_DEVICE_ID_CYGNAL_CP2112) },
16961737
{ HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_1) },
16971738
{ HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_2) },
16981739
{ HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_3) },
@@ -1782,6 +1823,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
17821823
{ HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_WIRELESS_OPTICAL_DESKTOP_3_0) },
17831824
{ HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_2) },
17841825
{ HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TOUCH_COVER_2) },
1826+
{ HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_OFFICE_KB) },
17851827
{ HID_USB_DEVICE(USB_VENDOR_ID_MONTEREY, USB_DEVICE_ID_GENIUS_KB29E) },
17861828
{ HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN) },
17871829
{ HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_1) },
@@ -2433,6 +2475,14 @@ int hid_add_device(struct hid_device *hdev)
24332475
if (hid_ignore(hdev))
24342476
return -ENODEV;
24352477

2478+
/*
2479+
* Check for the mandatory transport channel.
2480+
*/
2481+
if (!hdev->ll_driver->raw_request) {
2482+
hid_err(hdev, "transport driver missing .raw_request()\n");
2483+
return -EINVAL;
2484+
}
2485+
24362486
/*
24372487
* Read the device report descriptor once and use as template
24382488
* for the driver-specific modifications.

0 commit comments

Comments
 (0)