1 /* http://www.natox.be/ma8280p/
2 * http://www.leopold.dk/~martin/ma-8230p.html
3 * http://figvam.blogspot.com/2007/01/mobile-action-8730p-usb-cable-and-linux.html
8 * Code by davy hollevoet. This is simply an adaptation of code
9 * generated by usbsnoop2libusb. (http://iki.fi/lindi/usb/usbsnoop2libusb.pl)
11 * This code is released under both the GPL version 2 and BSD licenses.
12 * Either license may be used.
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License
18 * as published by the Free Software Foundation; either version 2
19 * of the License, or (at your option) any later version.
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
28 * Redistribution and use in source and binary forms, with or without
29 * modification, are permitted provided that the following conditions
32 * 1. Redistributions of source code must retain the above copyright
33 * notice, this list of conditions and the following disclaimer.
34 * 2. Redistributions in binary form must reproduce the above copyright
35 * notice, this list of conditions and the following disclaimer in the
36 * documentation and/or other materials provided with the distribution.
37 * 3. The name of the author may not be used to endorse or promote
38 * products derived from this software without specific prior written
41 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
42 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
43 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
45 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
46 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
47 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
49 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
50 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
51 * POSSIBILITY OF SUCH DAMAGE.
55 * Copyright (c) 1998, Regents of the University of California
56 * All rights reserved.
57 * Redistribution and use in source and binary forms, with or without
58 * modification, are permitted provided that the following conditions are met:
60 * * Redistributions of source code must retain the above copyright
61 * notice, this list of conditions and the following disclaimer.
62 * * Redistributions in binary form must reproduce the above copyright
63 * notice, this list of conditions and the following disclaimer in the
64 * documentation and/or other materials provided with the distribution.
65 * * Neither the name of the University of California, Berkeley nor the
66 * names of its contributors may be used to endorse or promote products
67 * derived from this software without specific prior written permission.
69 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS" AND ANY
70 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
71 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
72 * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
73 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
74 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
75 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
76 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
77 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
78 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
82 /* This file is (mostly) generated with usbsnoop2libusb.pl from a usbsnoop log file. */
83 /* Latest version of the script should be in http://iki.fi/lindi/usb/usbsnoop2libusb.pl */
93 #include "ma8280p_us.h"
95 int ma8280p_switch (struct usb_dev_handle *devh, struct usb_device *dev)
100 buf = malloc (65535);
102 error ("%s: not enough memory", dev->filename, ret);
106 ret = usb_get_descriptor(devh, 0x0000001, 0x0000000, buf, 0x0000012);
108 ret = usb_get_descriptor(devh, 0x0000001, 0x0000000, buf, 0x0000012);
110 ret = usb_get_descriptor(devh, 0x0000002, 0x0000000, buf, 0x0000400);
112 ret = usb_release_interface(devh, 0);
114 debug ("%s: failed to release interface before set_configuration: %d", dev->filename, ret);
115 ret = usb_set_configuration(devh, 0x0000001);
116 ret = usb_claim_interface(devh, 0);
118 debug ("%s: claim after set_configuration failed with error %d", dev->filename, ret);
119 //ret = usb_set_altinterface(devh, 0);
121 ret = usb_control_msg(devh, USB_TYPE_CLASS + USB_RECIP_INTERFACE + USB_ENDPOINT_IN, 0x0000001, 0x0000300, 0x0000000, buf, 0x0000008, 1000);
123 memcpy(buf, "\xb0\x04\x00\x00\x02\x90\x26\x86", 0x0000008);
124 ret = usb_control_msg(devh, USB_TYPE_CLASS + USB_RECIP_INTERFACE, 0x0000009, 0x0000300, 0x0000000, buf, 0x0000008, 1000);
126 memcpy(buf, "\xb0\x04\x00\x00\x02\x90\x26\x86", 0x0000008);
127 ret = usb_control_msg(devh, USB_TYPE_CLASS + USB_RECIP_INTERFACE, 0x0000009, 0x0000300, 0x0000000, buf, 0x0000008, 1000);
131 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
133 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
135 //URB_FUNCTION_GET_STATUS_FROM_ENDPOINT skipped
137 memcpy(buf, "\x37\x01\xfe\xdb\xc1\x33\x1f\x83", 0x0000008);
138 ret = usb_interrupt_write(devh, 0x00000002, buf, 0x0000008, 1000);
140 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
142 memcpy(buf, "\x37\x0e\xb5\x9d\x3b\x8a\x91\x51", 0x0000008);
143 ret = usb_interrupt_write(devh, 0x00000002, buf, 0x0000008, 1000);
145 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
147 memcpy(buf, "\x34\x87\xba\x0d\xfc\x8a\x91\x51", 0x0000008);
148 ret = usb_interrupt_write(devh, 0x00000002, buf, 0x0000008, 1000);
150 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
152 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
154 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
156 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
158 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
160 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
162 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
164 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
166 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
168 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
170 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
172 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
174 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
176 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
178 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
180 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
182 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
184 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
186 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
188 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
190 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
192 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
194 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
196 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
198 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
200 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
202 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
204 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
206 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
208 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
210 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
212 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
214 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
216 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
218 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
220 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
222 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
224 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
226 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
228 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
230 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
232 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
234 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
236 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
238 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
240 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
242 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
244 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
246 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
248 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
250 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
252 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
254 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
256 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
258 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
260 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
262 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
264 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
266 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
268 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
270 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
272 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
274 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
276 //URB_FUNCTION_GET_STATUS_FROM_ENDPOINT skipped
278 memcpy(buf, "\x37\x01\xfe\xdb\xc1\x33\x1f\x83", 0x0000008);
279 ret = usb_interrupt_write(devh, 0x00000002, buf, 0x0000008, 1000);
281 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
283 memcpy(buf, "\x37\x0e\xb5\x9d\x3b\x8a\x91\x51", 0x0000008);
284 ret = usb_interrupt_write(devh, 0x00000002, buf, 0x0000008, 1000);
286 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
288 memcpy(buf, "\x34\x87\xba\x0d\xfc\x8a\x91\x51", 0x0000008);
289 ret = usb_interrupt_write(devh, 0x00000002, buf, 0x0000008, 1000);
291 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
293 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
295 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
297 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
299 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
301 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
303 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
305 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
307 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
309 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
311 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
313 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
315 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
317 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
319 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
321 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
323 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
325 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
327 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
329 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
331 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
333 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
335 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
337 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
339 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
341 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
343 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
345 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
347 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
349 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
351 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
353 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
355 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
357 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
359 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
361 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
363 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
365 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
367 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
369 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
371 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
373 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
375 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
377 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
379 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
381 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
383 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
385 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
387 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
389 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
391 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
393 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
395 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
397 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
399 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
401 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
403 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
405 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
407 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
409 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
411 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
413 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
415 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
417 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
419 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
421 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
423 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
425 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
427 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
429 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
431 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
433 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
435 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
437 //URB_FUNCTION_GET_STATUS_FROM_ENDPOINT skipped
439 memcpy(buf, "\x33\x04\xfe\x00\xf4\x6c\x1f\xf0", 0x0000008);
440 ret = usb_interrupt_write(devh, 0x00000002, buf, 0x0000008, 1000);
442 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);
444 //URB_FUNCTION_GET_STATUS_FROM_ENDPOINT skipped
446 memcpy(buf, "\x32\x07\xfe\xf0\x29\xb9\x3a\xf0", 0x0000008);
447 ret = usb_interrupt_write(devh, 0x00000002, buf, 0x0000008, 1000);
449 ret = usb_interrupt_read(devh, 0x00000081, buf, 0x0000008, 1000);