am7xxx: fix setting the USB configuration
authorAntonio Ospite <ospite@studenti.unina.it>
Thu, 10 May 2012 06:16:04 +0000 (08:16 +0200)
committerAntonio Ospite <ospite@studenti.unina.it>
Thu, 10 May 2012 13:57:59 +0000 (15:57 +0200)
libusb_set_configuration() expects the bConfigurationValue of the
configuration we wish to activate as the second parameter.

The am7xxx devices we know have bConfigurationValue=2 for the first and
only configuration available in the descriptor, use this value.

While the libusb linux back-end looks forgiving on this one, without this
change the WinUSB back-end will fail with an error like:

C:\Documents and Settings\Administrator\Desktop\win>picoproj.exe -f image.jpg -F 1 -l 5 -W 800 -H 480
JPEG format
scan_devices: am7xxx device found, index: 0, name: Acer C110
[timestamp] [threadID] facility level [function call] <message>
--------------------------------------------------------------------------------

[ 0.000000] [00000eb0] libusbx: warning [winusb_submit_control_transfer] cannot set configuration other than the default one
[ 0.031250] [00000eb0] libusbx: warning [winusb_submit_control_transfer] cannot set configuration other than the default one
[ 0.046875] [00000eb0] libusbx: error [winusb_submit_bulk_transfer] unable to match endpoint to an open interface - cancelling transfer
read_data[281]: ret: -5 transferred: 0 (expected 24)
am7xxx_get_info: No such file or directory

src/am7xxx.c

index 528c1b6..d22a417 100644 (file)
@@ -542,7 +542,7 @@ static int scan_devices(am7xxx_context *ctx, scan_op op,
                                                goto out;
                                        }
 
-                                       libusb_set_configuration((*dev)->usb_device, 1);
+                                       libusb_set_configuration((*dev)->usb_device, 2);
                                        libusb_claim_interface((*dev)->usb_device, 0);
                                        goto out;
                                }