aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/input/hid-core.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/input/hid-core.c')
-rw-r--r--drivers/usb/input/hid-core.c81
1 files changed, 58 insertions, 23 deletions
diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c
index b2cb2b35892e..a99865c689c5 100644
--- a/drivers/usb/input/hid-core.c
+++ b/drivers/usb/input/hid-core.c
@@ -2,7 +2,8 @@
2 * USB HID support for Linux 2 * USB HID support for Linux
3 * 3 *
4 * Copyright (c) 1999 Andreas Gal 4 * Copyright (c) 1999 Andreas Gal
5 * Copyright (c) 2000-2001 Vojtech Pavlik <vojtech@suse.cz> 5 * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz>
6 * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc
6 */ 7 */
7 8
8/* 9/*
@@ -38,7 +39,7 @@
38 * Version Information 39 * Version Information
39 */ 40 */
40 41
41#define DRIVER_VERSION "v2.01" 42#define DRIVER_VERSION "v2.6"
42#define DRIVER_AUTHOR "Andreas Gal, Vojtech Pavlik" 43#define DRIVER_AUTHOR "Andreas Gal, Vojtech Pavlik"
43#define DRIVER_DESC "USB HID core driver" 44#define DRIVER_DESC "USB HID core driver"
44#define DRIVER_LICENSE "GPL" 45#define DRIVER_LICENSE "GPL"
@@ -1058,8 +1059,8 @@ static int hid_submit_ctrl(struct hid_device *hid)
1058 if (maxpacket > 0) { 1059 if (maxpacket > 0) {
1059 padlen = (len + maxpacket - 1) / maxpacket; 1060 padlen = (len + maxpacket - 1) / maxpacket;
1060 padlen *= maxpacket; 1061 padlen *= maxpacket;
1061 if (padlen > HID_BUFFER_SIZE) 1062 if (padlen > hid->bufsize)
1062 padlen = HID_BUFFER_SIZE; 1063 padlen = hid->bufsize;
1063 } else 1064 } else
1064 padlen = 0; 1065 padlen = 0;
1065 hid->urbctrl->transfer_buffer_length = padlen; 1066 hid->urbctrl->transfer_buffer_length = padlen;
@@ -1096,6 +1097,7 @@ static void hid_irq_out(struct urb *urb, struct pt_regs *regs)
1096 1097
1097 switch (urb->status) { 1098 switch (urb->status) {
1098 case 0: /* success */ 1099 case 0: /* success */
1100 break;
1099 case -ESHUTDOWN: /* unplug */ 1101 case -ESHUTDOWN: /* unplug */
1100 case -EILSEQ: /* unplug timeout on uhci */ 1102 case -EILSEQ: /* unplug timeout on uhci */
1101 unplug = 1; 1103 unplug = 1;
@@ -1143,6 +1145,7 @@ static void hid_ctrl(struct urb *urb, struct pt_regs *regs)
1143 case 0: /* success */ 1145 case 0: /* success */
1144 if (hid->ctrl[hid->ctrltail].dir == USB_DIR_IN) 1146 if (hid->ctrl[hid->ctrltail].dir == USB_DIR_IN)
1145 hid_input_report(hid->ctrl[hid->ctrltail].report->type, urb, 0, regs); 1147 hid_input_report(hid->ctrl[hid->ctrltail].report->type, urb, 0, regs);
1148 break;
1146 case -ESHUTDOWN: /* unplug */ 1149 case -ESHUTDOWN: /* unplug */
1147 case -EILSEQ: /* unplug timectrl on uhci */ 1150 case -EILSEQ: /* unplug timectrl on uhci */
1148 unplug = 1; 1151 unplug = 1;
@@ -1284,13 +1287,8 @@ void hid_init_reports(struct hid_device *hid)
1284 struct hid_report *report; 1287 struct hid_report *report;
1285 int err, ret; 1288 int err, ret;
1286 1289
1287 list_for_each_entry(report, &hid->report_enum[HID_INPUT_REPORT].report_list, list) { 1290 list_for_each_entry(report, &hid->report_enum[HID_INPUT_REPORT].report_list, list)
1288 int size = ((report->size - 1) >> 3) + 1 + hid->report_enum[HID_INPUT_REPORT].numbered;
1289 if (size > HID_BUFFER_SIZE) size = HID_BUFFER_SIZE;
1290 if (size > hid->urbin->transfer_buffer_length)
1291 hid->urbin->transfer_buffer_length = size;
1292 hid_submit_report(hid, report, USB_DIR_IN); 1291 hid_submit_report(hid, report, USB_DIR_IN);
1293 }
1294 1292
1295 list_for_each_entry(report, &hid->report_enum[HID_FEATURE_REPORT].report_list, list) 1293 list_for_each_entry(report, &hid->report_enum[HID_FEATURE_REPORT].report_list, list)
1296 hid_submit_report(hid, report, USB_DIR_IN); 1294 hid_submit_report(hid, report, USB_DIR_IN);
@@ -1372,12 +1370,14 @@ void hid_init_reports(struct hid_device *hid)
1372#define USB_VENDOR_ID_A4TECH 0x09da 1370#define USB_VENDOR_ID_A4TECH 0x09da
1373#define USB_DEVICE_ID_A4TECH_WCP32PU 0x0006 1371#define USB_DEVICE_ID_A4TECH_WCP32PU 0x0006
1374 1372
1375#define USB_VENDOR_ID_AASHIMA 0x06D6 1373#define USB_VENDOR_ID_AASHIMA 0x06d6
1376#define USB_DEVICE_ID_AASHIMA_GAMEPAD 0x0025 1374#define USB_DEVICE_ID_AASHIMA_GAMEPAD 0x0025
1375#define USB_DEVICE_ID_AASHIMA_PREDATOR 0x0026
1377 1376
1378#define USB_VENDOR_ID_CYPRESS 0x04b4 1377#define USB_VENDOR_ID_CYPRESS 0x04b4
1379#define USB_DEVICE_ID_CYPRESS_MOUSE 0x0001 1378#define USB_DEVICE_ID_CYPRESS_MOUSE 0x0001
1380#define USB_DEVICE_ID_CYPRESS_HIDCOM 0x5500 1379#define USB_DEVICE_ID_CYPRESS_HIDCOM 0x5500
1380#define USB_DEVICE_ID_CYPRESS_ULTRAMOUSE 0x7417
1381 1381
1382#define USB_VENDOR_ID_BERKSHIRE 0x0c98 1382#define USB_VENDOR_ID_BERKSHIRE 0x0c98
1383#define USB_DEVICE_ID_BERKSHIRE_PCWD 0x1140 1383#define USB_DEVICE_ID_BERKSHIRE_PCWD 0x1140
@@ -1432,7 +1432,7 @@ void hid_init_reports(struct hid_device *hid)
1432#define USB_DEVICE_ID_VERNIER_CYCLOPS 0x0004 1432#define USB_DEVICE_ID_VERNIER_CYCLOPS 0x0004
1433 1433
1434#define USB_VENDOR_ID_LD 0x0f11 1434#define USB_VENDOR_ID_LD 0x0f11
1435#define USB_DEVICE_ID_CASSY 0x1000 1435#define USB_DEVICE_ID_CASSY 0x1000
1436#define USB_DEVICE_ID_POCKETCASSY 0x1010 1436#define USB_DEVICE_ID_POCKETCASSY 0x1010
1437#define USB_DEVICE_ID_MOBILECASSY 0x1020 1437#define USB_DEVICE_ID_MOBILECASSY 0x1020
1438#define USB_DEVICE_ID_JWM 0x1080 1438#define USB_DEVICE_ID_JWM 0x1080
@@ -1444,6 +1444,8 @@ void hid_init_reports(struct hid_device *hid)
1444#define USB_DEVICE_ID_NETWORKANALYSER 0x2020 1444#define USB_DEVICE_ID_NETWORKANALYSER 0x2020
1445#define USB_DEVICE_ID_POWERCONTROL 0x2030 1445#define USB_DEVICE_ID_POWERCONTROL 0x2030
1446 1446
1447#define USB_VENDOR_ID_APPLE 0x05ac
1448#define USB_DEVICE_ID_APPLE_POWERMOUSE 0x0304
1447 1449
1448/* 1450/*
1449 * Alphabetically sorted blacklist by quirk type. 1451 * Alphabetically sorted blacklist by quirk type.
@@ -1468,6 +1470,7 @@ static struct hid_blacklist {
1468 { USB_VENDOR_ID_CODEMERCS, USB_DEVICE_ID_CODEMERCS_IOW48, HID_QUIRK_IGNORE }, 1470 { USB_VENDOR_ID_CODEMERCS, USB_DEVICE_ID_CODEMERCS_IOW48, HID_QUIRK_IGNORE },
1469 { USB_VENDOR_ID_CODEMERCS, USB_DEVICE_ID_CODEMERCS_IOW28, HID_QUIRK_IGNORE }, 1471 { USB_VENDOR_ID_CODEMERCS, USB_DEVICE_ID_CODEMERCS_IOW28, HID_QUIRK_IGNORE },
1470 { USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_HIDCOM, HID_QUIRK_IGNORE }, 1472 { USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_HIDCOM, HID_QUIRK_IGNORE },
1473 { USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_ULTRAMOUSE, HID_QUIRK_IGNORE },
1471 { USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EARTHMATE, HID_QUIRK_IGNORE }, 1474 { USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EARTHMATE, HID_QUIRK_IGNORE },
1472 { USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EM_LT20, HID_QUIRK_IGNORE }, 1475 { USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EM_LT20, HID_QUIRK_IGNORE },
1473 { USB_VENDOR_ID_ESSENTIAL_REALITY, USB_DEVICE_ID_ESSENTIAL_REALITY_P5, HID_QUIRK_IGNORE }, 1476 { USB_VENDOR_ID_ESSENTIAL_REALITY, USB_DEVICE_ID_ESSENTIAL_REALITY_P5, HID_QUIRK_IGNORE },
@@ -1548,10 +1551,12 @@ static struct hid_blacklist {
1548 { USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_USBHUB_KB, HID_QUIRK_NOGET}, 1551 { USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_USBHUB_KB, HID_QUIRK_NOGET},
1549 { USB_VENDOR_ID_TANGTOP, USB_DEVICE_ID_TANGTOP_USBPS2, HID_QUIRK_NOGET }, 1552 { USB_VENDOR_ID_TANGTOP, USB_DEVICE_ID_TANGTOP_USBPS2, HID_QUIRK_NOGET },
1550 1553
1554 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_POWERMOUSE, HID_QUIRK_2WHEEL_POWERMOUSE },
1551 { USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU, HID_QUIRK_2WHEEL_MOUSE_HACK_7 }, 1555 { USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU, HID_QUIRK_2WHEEL_MOUSE_HACK_7 },
1552 { USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_MOUSE, HID_QUIRK_2WHEEL_MOUSE_HACK_5 }, 1556 { USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_MOUSE, HID_QUIRK_2WHEEL_MOUSE_HACK_5 },
1553 1557
1554 { USB_VENDOR_ID_AASHIMA, USB_DEVICE_ID_AASHIMA_GAMEPAD, HID_QUIRK_BADPAD }, 1558 { USB_VENDOR_ID_AASHIMA, USB_DEVICE_ID_AASHIMA_GAMEPAD, HID_QUIRK_BADPAD },
1559 { USB_VENDOR_ID_AASHIMA, USB_DEVICE_ID_AASHIMA_PREDATOR, HID_QUIRK_BADPAD },
1555 { USB_VENDOR_ID_ALPS, USB_DEVICE_ID_IBM_GAMEPAD, HID_QUIRK_BADPAD }, 1560 { USB_VENDOR_ID_ALPS, USB_DEVICE_ID_IBM_GAMEPAD, HID_QUIRK_BADPAD },
1556 { USB_VENDOR_ID_CHIC, USB_DEVICE_ID_CHIC_GAMEPAD, HID_QUIRK_BADPAD }, 1561 { USB_VENDOR_ID_CHIC, USB_DEVICE_ID_CHIC_GAMEPAD, HID_QUIRK_BADPAD },
1557 { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_DRIVING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT }, 1562 { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_DRIVING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT },
@@ -1564,15 +1569,32 @@ static struct hid_blacklist {
1564 { 0, 0 } 1569 { 0, 0 }
1565}; 1570};
1566 1571
1572/*
1573 * Traverse the supplied list of reports and find the longest
1574 */
1575static void hid_find_max_report(struct hid_device *hid, unsigned int type, int *max)
1576{
1577 struct hid_report *report;
1578 int size;
1579
1580 list_for_each_entry(report, &hid->report_enum[type].report_list, list) {
1581 size = ((report->size - 1) >> 3) + 1;
1582 if (type == HID_INPUT_REPORT && hid->report_enum[type].numbered)
1583 size++;
1584 if (*max < size)
1585 *max = size;
1586 }
1587}
1588
1567static int hid_alloc_buffers(struct usb_device *dev, struct hid_device *hid) 1589static int hid_alloc_buffers(struct usb_device *dev, struct hid_device *hid)
1568{ 1590{
1569 if (!(hid->inbuf = usb_buffer_alloc(dev, HID_BUFFER_SIZE, SLAB_ATOMIC, &hid->inbuf_dma))) 1591 if (!(hid->inbuf = usb_buffer_alloc(dev, hid->bufsize, SLAB_ATOMIC, &hid->inbuf_dma)))
1570 return -1; 1592 return -1;
1571 if (!(hid->outbuf = usb_buffer_alloc(dev, HID_BUFFER_SIZE, SLAB_ATOMIC, &hid->outbuf_dma))) 1593 if (!(hid->outbuf = usb_buffer_alloc(dev, hid->bufsize, SLAB_ATOMIC, &hid->outbuf_dma)))
1572 return -1; 1594 return -1;
1573 if (!(hid->cr = usb_buffer_alloc(dev, sizeof(*(hid->cr)), SLAB_ATOMIC, &hid->cr_dma))) 1595 if (!(hid->cr = usb_buffer_alloc(dev, sizeof(*(hid->cr)), SLAB_ATOMIC, &hid->cr_dma)))
1574 return -1; 1596 return -1;
1575 if (!(hid->ctrlbuf = usb_buffer_alloc(dev, HID_BUFFER_SIZE, SLAB_ATOMIC, &hid->ctrlbuf_dma))) 1597 if (!(hid->ctrlbuf = usb_buffer_alloc(dev, hid->bufsize, SLAB_ATOMIC, &hid->ctrlbuf_dma)))
1576 return -1; 1598 return -1;
1577 1599
1578 return 0; 1600 return 0;
@@ -1581,13 +1603,13 @@ static int hid_alloc_buffers(struct usb_device *dev, struct hid_device *hid)
1581static void hid_free_buffers(struct usb_device *dev, struct hid_device *hid) 1603static void hid_free_buffers(struct usb_device *dev, struct hid_device *hid)
1582{ 1604{
1583 if (hid->inbuf) 1605 if (hid->inbuf)
1584 usb_buffer_free(dev, HID_BUFFER_SIZE, hid->inbuf, hid->inbuf_dma); 1606 usb_buffer_free(dev, hid->bufsize, hid->inbuf, hid->inbuf_dma);
1585 if (hid->outbuf) 1607 if (hid->outbuf)
1586 usb_buffer_free(dev, HID_BUFFER_SIZE, hid->outbuf, hid->outbuf_dma); 1608 usb_buffer_free(dev, hid->bufsize, hid->outbuf, hid->outbuf_dma);
1587 if (hid->cr) 1609 if (hid->cr)
1588 usb_buffer_free(dev, sizeof(*(hid->cr)), hid->cr, hid->cr_dma); 1610 usb_buffer_free(dev, sizeof(*(hid->cr)), hid->cr, hid->cr_dma);
1589 if (hid->ctrlbuf) 1611 if (hid->ctrlbuf)
1590 usb_buffer_free(dev, HID_BUFFER_SIZE, hid->ctrlbuf, hid->ctrlbuf_dma); 1612 usb_buffer_free(dev, hid->bufsize, hid->ctrlbuf, hid->ctrlbuf_dma);
1591} 1613}
1592 1614
1593static struct hid_device *usb_hid_configure(struct usb_interface *intf) 1615static struct hid_device *usb_hid_configure(struct usb_interface *intf)
@@ -1598,7 +1620,7 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf)
1598 struct hid_device *hid; 1620 struct hid_device *hid;
1599 unsigned quirks = 0, rsize = 0; 1621 unsigned quirks = 0, rsize = 0;
1600 char *buf, *rdesc; 1622 char *buf, *rdesc;
1601 int n; 1623 int n, insize = 0;
1602 1624
1603 for (n = 0; hid_blacklist[n].idVendor; n++) 1625 for (n = 0; hid_blacklist[n].idVendor; n++)
1604 if ((hid_blacklist[n].idVendor == le16_to_cpu(dev->descriptor.idVendor)) && 1626 if ((hid_blacklist[n].idVendor == le16_to_cpu(dev->descriptor.idVendor)) &&
@@ -1652,6 +1674,19 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf)
1652 kfree(rdesc); 1674 kfree(rdesc);
1653 hid->quirks = quirks; 1675 hid->quirks = quirks;
1654 1676
1677 hid->bufsize = HID_MIN_BUFFER_SIZE;
1678 hid_find_max_report(hid, HID_INPUT_REPORT, &hid->bufsize);
1679 hid_find_max_report(hid, HID_OUTPUT_REPORT, &hid->bufsize);
1680 hid_find_max_report(hid, HID_FEATURE_REPORT, &hid->bufsize);
1681
1682 if (hid->bufsize > HID_MAX_BUFFER_SIZE)
1683 hid->bufsize = HID_MAX_BUFFER_SIZE;
1684
1685 hid_find_max_report(hid, HID_INPUT_REPORT, &insize);
1686
1687 if (insize > HID_MAX_BUFFER_SIZE)
1688 insize = HID_MAX_BUFFER_SIZE;
1689
1655 if (hid_alloc_buffers(dev, hid)) { 1690 if (hid_alloc_buffers(dev, hid)) {
1656 hid_free_buffers(dev, hid); 1691 hid_free_buffers(dev, hid);
1657 goto fail; 1692 goto fail;
@@ -1682,10 +1717,10 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf)
1682 if (!(hid->urbin = usb_alloc_urb(0, GFP_KERNEL))) 1717 if (!(hid->urbin = usb_alloc_urb(0, GFP_KERNEL)))
1683 goto fail; 1718 goto fail;
1684 pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress); 1719 pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress);
1685 usb_fill_int_urb(hid->urbin, dev, pipe, hid->inbuf, 0, 1720 usb_fill_int_urb(hid->urbin, dev, pipe, hid->inbuf, insize,
1686 hid_irq_in, hid, interval); 1721 hid_irq_in, hid, interval);
1687 hid->urbin->transfer_dma = hid->inbuf_dma; 1722 hid->urbin->transfer_dma = hid->inbuf_dma;
1688 hid->urbin->transfer_flags |=(URB_NO_TRANSFER_DMA_MAP | URB_ASYNC_UNLINK); 1723 hid->urbin->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
1689 } else { 1724 } else {
1690 if (hid->urbout) 1725 if (hid->urbout)
1691 continue; 1726 continue;
@@ -1695,7 +1730,7 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf)
1695 usb_fill_int_urb(hid->urbout, dev, pipe, hid->outbuf, 0, 1730 usb_fill_int_urb(hid->urbout, dev, pipe, hid->outbuf, 0,
1696 hid_irq_out, hid, interval); 1731 hid_irq_out, hid, interval);
1697 hid->urbout->transfer_dma = hid->outbuf_dma; 1732 hid->urbout->transfer_dma = hid->outbuf_dma;
1698 hid->urbout->transfer_flags |= (URB_NO_TRANSFER_DMA_MAP | URB_ASYNC_UNLINK); 1733 hid->urbout->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
1699 } 1734 }
1700 } 1735 }
1701 1736
@@ -1747,7 +1782,7 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf)
1747 hid->ctrlbuf, 1, hid_ctrl, hid); 1782 hid->ctrlbuf, 1, hid_ctrl, hid);
1748 hid->urbctrl->setup_dma = hid->cr_dma; 1783 hid->urbctrl->setup_dma = hid->cr_dma;
1749 hid->urbctrl->transfer_dma = hid->ctrlbuf_dma; 1784 hid->urbctrl->transfer_dma = hid->ctrlbuf_dma;
1750 hid->urbctrl->transfer_flags |= (URB_NO_TRANSFER_DMA_MAP | URB_NO_SETUP_DMA_MAP | URB_ASYNC_UNLINK); 1785 hid->urbctrl->transfer_flags |= (URB_NO_TRANSFER_DMA_MAP | URB_NO_SETUP_DMA_MAP);
1751 1786
1752 return hid; 1787 return hid;
1753 1788