From: Antonio Ospite <ospite@studenti.unina.it>
Date: Thu, 10 May 2012 06:16:04 +0000 (+0200)
Subject: am7xxx: fix setting the USB configuration
X-Git-Tag: v0.1.3~37^2~8
X-Git-Url: https://git.ao2.it/libam7xxx.git/commitdiff_plain/2e98c1f8f71883805ba96e3691c692a568858ca9

am7xxx: fix setting the USB configuration

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
---

diff --git a/src/am7xxx.c b/src/am7xxx.c
index 528c1b6..d22a417 100644
--- a/src/am7xxx.c
+++ b/src/am7xxx.c
@@ -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;
 				}