aa2a8c8cb5812a385dcb02d80221659f898c9b66
[kinect-audio-setup.git] / debian / patches / 0001-kinect_upload_fw-fix-setting-configuration-for-some-.patch
1 From 6e31aa17271f90a443591719089688bbf2040765 Mon Sep 17 00:00:00 2001
2 From: Kristof Robot <krirobo@gmail.com>
3 Date: Sun, 8 Dec 2013 15:46:50 +0100
4 Subject: [PATCH] kinect_upload_fw: fix setting configuration for some devices
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8 X-Face: z*RaLf`X<@C75u6Ig9}{oW$H;1_\2t5)({*|jhM<pyWR#k60!#=#>/Vb;]yA5<GWI5`6u&+
9  ;6b'@y|8w"wB;4/e!7wYYrcqdJFY,~%Gk_4]cq$Ei/7<j&N3ah(m`ku?pX.&+~:_/wC~dwn^)MizBG
10  !pE^+iDQQ1yC6^,)YDKkxDd!T>\I~93>J<_`<4)A{':UrE
11
12 On some Kinect devices where the desired configuration is already the
13 currently active one libusb_set_configuration() fails in some way
14 causing the subsequent bulk transfer to fail, and the program to exit,
15 with this message:
16
17   libusbx: error [op_set_configuration] failed, error -1 errno 110
18   About to send: 09 20 02 06 01 00 00 00 60 00 00 00 00 00 00 00 15 00 00 00 00 00 00 00
19   libusbx: error [submit_bulk_transfer] submiturb failed error -1 errno=2
20   Error: res: -1    transferred: 0 (expected 24)
21
22 Only set the desired configuration if it hasn't been set already.
23 This prevents the problems from above.
24
25 Do the configuration check as illustrated in
26 http://libusbx.sourceforge.net/api-1.0/caveats.html that is by checking
27 that the current configuration is still the desired one after claiming
28 the device.
29 ---
30  kinect_upload_fw/kinect_upload_fw.c | 12 +++++++++++-
31  1 file changed, 11 insertions(+), 1 deletion(-)
32
33 diff --git a/kinect_upload_fw/kinect_upload_fw.c b/kinect_upload_fw/kinect_upload_fw.c
34 index b2188d6..e3b72db 100644
35 --- a/kinect_upload_fw/kinect_upload_fw.c
36 +++ b/kinect_upload_fw/kinect_upload_fw.c
37 @@ -155,9 +155,19 @@ int main(int argc, char** argv) {
38                 goto fail_libusb_open;
39         }
40  
41 -       libusb_set_configuration(dev, 1);
42 +       int current_configuration = 0;
43 +       libusb_get_configuration(dev, &current_configuration);
44 +       if (current_configuration != 1)
45 +               libusb_set_configuration(dev, 1);
46 +
47         libusb_claim_interface(dev, 0);
48  
49 +       libusb_get_configuration(dev, &current_configuration);
50 +       if (current_configuration != 1) {
51 +               res = -ENODEV;
52 +               goto cleanup;
53 +       }
54 +
55         seq = 1;
56  
57         bootloader_command cmd;
58 -- 
59 1.8.5.1
60