aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid/hid-core.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hid/hid-core.c')
-rw-r--r--drivers/hid/hid-core.c61
1 files changed, 50 insertions, 11 deletions
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index f4109fd657ff..eb2ee11b6412 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -92,6 +92,7 @@ EXPORT_SYMBOL_GPL(hid_register_report);
92static struct hid_field *hid_register_field(struct hid_report *report, unsigned usages, unsigned values) 92static struct hid_field *hid_register_field(struct hid_report *report, unsigned usages, unsigned values)
93{ 93{
94 struct hid_field *field; 94 struct hid_field *field;
95 int i;
95 96
96 if (report->maxfield == HID_MAX_FIELDS) { 97 if (report->maxfield == HID_MAX_FIELDS) {
97 hid_err(report->device, "too many fields in report\n"); 98 hid_err(report->device, "too many fields in report\n");
@@ -110,6 +111,9 @@ static struct hid_field *hid_register_field(struct hid_report *report, unsigned
110 field->value = (s32 *)(field->usage + usages); 111 field->value = (s32 *)(field->usage + usages);
111 field->report = report; 112 field->report = report;
112 113
114 for (i = 0; i < usages; i++)
115 field->usage[i].usage_index = i;
116
113 return field; 117 return field;
114} 118}
115 119
@@ -315,6 +319,7 @@ static s32 item_sdata(struct hid_item *item)
315 319
316static int hid_parser_global(struct hid_parser *parser, struct hid_item *item) 320static int hid_parser_global(struct hid_parser *parser, struct hid_item *item)
317{ 321{
322 __u32 raw_value;
318 switch (item->tag) { 323 switch (item->tag) {
319 case HID_GLOBAL_ITEM_TAG_PUSH: 324 case HID_GLOBAL_ITEM_TAG_PUSH:
320 325
@@ -365,7 +370,14 @@ static int hid_parser_global(struct hid_parser *parser, struct hid_item *item)
365 return 0; 370 return 0;
366 371
367 case HID_GLOBAL_ITEM_TAG_UNIT_EXPONENT: 372 case HID_GLOBAL_ITEM_TAG_UNIT_EXPONENT:
368 parser->global.unit_exponent = item_sdata(item); 373 /* Units exponent negative numbers are given through a
374 * two's complement.
375 * See "6.2.2.7 Global Items" for more information. */
376 raw_value = item_udata(item);
377 if (!(raw_value & 0xfffffff0))
378 parser->global.unit_exponent = hid_snto32(raw_value, 4);
379 else
380 parser->global.unit_exponent = raw_value;
369 return 0; 381 return 0;
370 382
371 case HID_GLOBAL_ITEM_TAG_UNIT: 383 case HID_GLOBAL_ITEM_TAG_UNIT:
@@ -713,7 +725,12 @@ static int hid_scan_report(struct hid_device *hid)
713 hid_scan_usage(hid, u); 725 hid_scan_usage(hid, u);
714 break; 726 break;
715 } 727 }
716 } 728 } else if (page == HID_UP_SENSOR &&
729 item.type == HID_ITEM_TYPE_MAIN &&
730 item.tag == HID_MAIN_ITEM_TAG_BEGIN_COLLECTION &&
731 (item_udata(&item) & 0xff) == HID_COLLECTION_PHYSICAL &&
732 hid->bus == BUS_USB)
733 hid->group = HID_GROUP_SENSOR_HUB;
717 } 734 }
718 735
719 return 0; 736 return 0;
@@ -865,6 +882,12 @@ static s32 snto32(__u32 value, unsigned n)
865 return value & (1 << (n - 1)) ? value | (-1 << n) : value; 882 return value & (1 << (n - 1)) ? value | (-1 << n) : value;
866} 883}
867 884
885s32 hid_snto32(__u32 value, unsigned n)
886{
887 return snto32(value, n);
888}
889EXPORT_SYMBOL_GPL(hid_snto32);
890
868/* 891/*
869 * Convert a signed 32-bit integer to a signed n-bit integer. 892 * Convert a signed 32-bit integer to a signed n-bit integer.
870 */ 893 */
@@ -1465,6 +1488,10 @@ EXPORT_SYMBOL_GPL(hid_disconnect);
1465 * there is a proper autodetection and autoloading in place (based on presence 1488 * there is a proper autodetection and autoloading in place (based on presence
1466 * of HID_DG_CONTACTID), so those devices don't need to be added to this list, 1489 * of HID_DG_CONTACTID), so those devices don't need to be added to this list,
1467 * as we are doing the right thing in hid_scan_usage(). 1490 * as we are doing the right thing in hid_scan_usage().
1491 *
1492 * Autodetection for (USB) HID sensor hubs exists too. If a collection of type
1493 * physical is found inside a usage page of type sensor, hid-sensor-hub will be
1494 * used as a driver. See hid_scan_report().
1468 */ 1495 */
1469static const struct hid_device_id hid_have_special_driver[] = { 1496static const struct hid_device_id hid_have_special_driver[] = {
1470 { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU) }, 1497 { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU) },
@@ -1538,6 +1565,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
1538 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI) }, 1565 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI) },
1539 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO) }, 1566 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO) },
1540 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS) }, 1567 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS) },
1568 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ANSI) },
1541 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ISO) }, 1569 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ISO) },
1542 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) }, 1570 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) },
1543 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) }, 1571 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) },
@@ -1571,10 +1599,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
1571 { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE_3) }, 1599 { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE_3) },
1572 { HID_USB_DEVICE(USB_VENDOR_ID_HOLTEK, USB_DEVICE_ID_HOLTEK_ON_LINE_GRIP) }, 1600 { HID_USB_DEVICE(USB_VENDOR_ID_HOLTEK, USB_DEVICE_ID_HOLTEK_ON_LINE_GRIP) },
1573 { HID_USB_DEVICE(USB_VENDOR_ID_HOLTEK_ALT, USB_DEVICE_ID_HOLTEK_ALT_KEYBOARD) }, 1601 { HID_USB_DEVICE(USB_VENDOR_ID_HOLTEK_ALT, USB_DEVICE_ID_HOLTEK_ALT_KEYBOARD) },
1574 { HID_USB_DEVICE(USB_VENDOR_ID_INTEL_8086, USB_DEVICE_ID_SENSOR_HUB_1020) }, 1602 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ION, USB_DEVICE_ID_ICADE) },
1575 { HID_USB_DEVICE(USB_VENDOR_ID_INTEL_8086, USB_DEVICE_ID_SENSOR_HUB_09FA) },
1576 { HID_USB_DEVICE(USB_VENDOR_ID_INTEL_8087, USB_DEVICE_ID_SENSOR_HUB_1020) },
1577 { HID_USB_DEVICE(USB_VENDOR_ID_INTEL_8087, USB_DEVICE_ID_SENSOR_HUB_09FA) },
1578 { HID_USB_DEVICE(USB_VENDOR_ID_KENSINGTON, USB_DEVICE_ID_KS_SLIMBLADE) }, 1603 { HID_USB_DEVICE(USB_VENDOR_ID_KENSINGTON, USB_DEVICE_ID_KS_SLIMBLADE) },
1579 { HID_USB_DEVICE(USB_VENDOR_ID_KEYTOUCH, USB_DEVICE_ID_KEYTOUCH_IEC) }, 1604 { HID_USB_DEVICE(USB_VENDOR_ID_KEYTOUCH, USB_DEVICE_ID_KEYTOUCH_IEC) },
1580 { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_ERGO_525V) }, 1605 { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_ERGO_525V) },
@@ -1658,6 +1683,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
1658 { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_ISKU) }, 1683 { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_ISKU) },
1659 { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONEPLUS) }, 1684 { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONEPLUS) },
1660 { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KOVAPLUS) }, 1685 { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KOVAPLUS) },
1686 { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_LUA) },
1661 { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_PYRA_WIRED) }, 1687 { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_PYRA_WIRED) },
1662 { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_PYRA_WIRELESS) }, 1688 { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_PYRA_WIRELESS) },
1663 { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_SAVU) }, 1689 { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_SAVU) },
@@ -1672,7 +1698,6 @@ static const struct hid_device_id hid_have_special_driver[] = {
1672 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) }, 1698 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },
1673 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE) }, 1699 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE) },
1674 { HID_USB_DEVICE(USB_VENDOR_ID_SUNPLUS, USB_DEVICE_ID_SUNPLUS_WDESKTOP) }, 1700 { HID_USB_DEVICE(USB_VENDOR_ID_SUNPLUS, USB_DEVICE_ID_SUNPLUS_WDESKTOP) },
1675 { HID_USB_DEVICE(USB_VENDOR_ID_STANTUM_STM, USB_DEVICE_ID_SENSOR_HUB_7014) },
1676 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb300) }, 1701 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb300) },
1677 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb304) }, 1702 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb304) },
1678 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb323) }, 1703 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb323) },
@@ -2150,8 +2175,13 @@ static const struct hid_device_id hid_mouse_ignore_list[] = {
2150 { } 2175 { }
2151}; 2176};
2152 2177
2153static bool hid_ignore(struct hid_device *hdev) 2178bool hid_ignore(struct hid_device *hdev)
2154{ 2179{
2180 if (hdev->quirks & HID_QUIRK_NO_IGNORE)
2181 return false;
2182 if (hdev->quirks & HID_QUIRK_IGNORE)
2183 return true;
2184
2155 switch (hdev->vendor) { 2185 switch (hdev->vendor) {
2156 case USB_VENDOR_ID_CODEMERCS: 2186 case USB_VENDOR_ID_CODEMERCS:
2157 /* ignore all Code Mercenaries IOWarrior devices */ 2187 /* ignore all Code Mercenaries IOWarrior devices */
@@ -2188,7 +2218,16 @@ static bool hid_ignore(struct hid_device *hdev)
2188 if (hdev->product == USB_DEVICE_ID_JESS_YUREX && 2218 if (hdev->product == USB_DEVICE_ID_JESS_YUREX &&
2189 hdev->type == HID_TYPE_USBNONE) 2219 hdev->type == HID_TYPE_USBNONE)
2190 return true; 2220 return true;
2191 break; 2221 break;
2222 case USB_VENDOR_ID_DWAV:
2223 /* These are handled by usbtouchscreen. hdev->type is probably
2224 * HID_TYPE_USBNONE, but we say !HID_TYPE_USBMOUSE to match
2225 * usbtouchscreen. */
2226 if ((hdev->product == USB_DEVICE_ID_EGALAX_TOUCHCONTROLLER ||
2227 hdev->product == USB_DEVICE_ID_DWAV_TOUCHCONTROLLER) &&
2228 hdev->type != HID_TYPE_USBMOUSE)
2229 return true;
2230 break;
2192 } 2231 }
2193 2232
2194 if (hdev->type == HID_TYPE_USBMOUSE && 2233 if (hdev->type == HID_TYPE_USBMOUSE &&
@@ -2197,6 +2236,7 @@ static bool hid_ignore(struct hid_device *hdev)
2197 2236
2198 return !!hid_match_id(hdev, hid_ignore_list); 2237 return !!hid_match_id(hdev, hid_ignore_list);
2199} 2238}
2239EXPORT_SYMBOL_GPL(hid_ignore);
2200 2240
2201int hid_add_device(struct hid_device *hdev) 2241int hid_add_device(struct hid_device *hdev)
2202{ 2242{
@@ -2208,8 +2248,7 @@ int hid_add_device(struct hid_device *hdev)
2208 2248
2209 /* we need to kill them here, otherwise they will stay allocated to 2249 /* we need to kill them here, otherwise they will stay allocated to
2210 * wait for coming driver */ 2250 * wait for coming driver */
2211 if (!(hdev->quirks & HID_QUIRK_NO_IGNORE) 2251 if (hid_ignore(hdev))
2212 && (hid_ignore(hdev) || (hdev->quirks & HID_QUIRK_IGNORE)))
2213 return -ENODEV; 2252 return -ENODEV;
2214 2253
2215 /* 2254 /*