Re: Unitech USB barcode scanner issues

Jiri Kosina <[email protected]>
Newsgroups gmane.linux.usb.devel
Message-ID <[email protected]>
On Sun, 29 Apr 2007, Bret Towe wrote:

> > There might be various reasons for this, most probably the report 
> > descriptor of the device is broken. It might then be easy to fix the 
> > report descriptor on the fly before it gets parsed, we are doing this 
> > for various broken hardware already.
> so this is a rather common issue then?

Hi Bret,

well not that common, but there are a few devices out there which have 
broken report descriptors and we are fixing them before they enter the 
parser. (some logitech keyboards, certain cymotion keyboard, etc.)

> > What product ID and vendor ID does your device have please? (you can 
> > find out from the output of lsusb command).
> Bus 005 Device 002: ID 04b4:de64 Cypress Semiconductor Corp.
> this is one of the new ones that have the broken upper case bit I'll dig 
> around see if I can find a working old one to see if its id changed 
> since old and new were both broken with hid

Please try the patch below (against 2.6.21), it could solve your problem. 
If it does, I would be interested in all other product IDs you are able to 
reproduce this bug with, so that I can prepare proper patch, handling all 
cypress hardware which is broken in the same way.

diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c
index 827a75a..7cfee8d 100644
--- a/drivers/usb/input/hid-core.c
+++ b/drivers/usb/input/hid-core.c
@@ -1053,6 +1053,30 @@ static void hid_fixup_s510_descriptor(un
 	}
 }
 
+#define rdesc_swap(n1,n2) 	tmp = rdesc[n2]; \
+				rdesc[n2] = rdesc[n1]; \
+				rdesc[n1] = tmp;
+static void hid_fixup_cypress_descriptor(unsigned char *rdesc, int rsize)
+{
+	char tmp;
+
+	if (rdesc[10] == 0x29 && rdesc[12] == 0x19 &&
+	    rdesc[36] == 0x29 && rdesc[38] == 0x19 &&
+	    rdesc[59] == 0x29 && rdesc[61] == 0x19 &&
+	    rdesc[74] == 0x29 && rdesc[76] == 0x19 &&
+	    rdesc[86] == 0x29 && rdesc[88] == 0x19) {
+		info("Fixing up Cypress report descriptor\n");
+		rdesc[10] = rdesc[36] = rdesc[59] = rdesc[74] = rdesc[86] = 0x19;
+		rdesc[12] = rdesc[38] = rdesc[61] = rdesc[76] = rdesc[88] = 0x29;
+		rdesc_swap(11, 13);
+		rdesc_swap(37, 39);
+		rdesc_swap(60, 62);
+		rdesc_swap(75, 77);
+		rdesc_swap(87, 89);
+	} else
+		info("Not fixing Cypress report descriptor");
+}
+
 static struct hid_device *usb_hid_configure(struct usb_interface *intf)
 {
 	struct usb_host_interface *interface = intf->cur_altsetting;
@@ -1129,6 +1153,10 @@ static struct hid_device *usb_hid_config
 	if (quirks & HID_QUIRK_LOGITECH_S510_DESCRIPTOR)
 		hid_fixup_s510_descriptor(rdesc, rsize);
 
+	if (le16_to_cpu(dev->descriptor.idVendor) == 0x04b4 &&
+			le16_to_cpu(dev->descriptor.idProduct == 0xde64))
+			hid_fixup_cypress_descriptor(rdesc, rsize);
+
 #ifdef CONFIG_HID_DEBUG
 	printk(KERN_DEBUG __FILE__ ": report descriptor (size %u, read %d) = ", rsize, n);
 	for (n = 0; n < rsize; n++)

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.