summaryrefslogtreecommitdiff
path: root/firmware/target/hosted/ibasso/usb-ibasso.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/hosted/ibasso/usb-ibasso.c')
-rw-r--r--firmware/target/hosted/ibasso/usb-ibasso.c92
1 files changed, 92 insertions, 0 deletions
diff --git a/firmware/target/hosted/ibasso/usb-ibasso.c b/firmware/target/hosted/ibasso/usb-ibasso.c
new file mode 100644
index 0000000000..e1b134e545
--- /dev/null
+++ b/firmware/target/hosted/ibasso/usb-ibasso.c
@@ -0,0 +1,92 @@
1/***************************************************************************
2 * __________ __ ___
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 * Copyright (C) 2014 by Ilia Sergachev: Initial Rockbox port to iBasso DX50
10 * Copyright (C) 2014 by Mario Basister: iBasso DX90 port
11 * Copyright (C) 2014 by Simon Rothen: Initial Rockbox repository submission, additional features
12 * Copyright (C) 2014 by Udo Schläpfer: Code clean up, additional features
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
18 *
19 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 * KIND, either express or implied.
21 *
22 ****************************************************************************/
23
24
25#include <stdlib.h>
26
27#include "config.h"
28#include "debug.h"
29
30#include "debug-ibasso.h"
31#include "usb-ibasso.h"
32
33
34static void usb_enable_adb(void)
35{
36 TRACE;
37
38 if(system(NULL))
39 {
40 system("setprop persist.sys.usb.config adb");
41 system("setprop persist.usb.debug 1");
42 return;
43 }
44
45 DEBUGF("ERROR %s: No command processor available.", __func__);
46}
47
48
49static void usb_enable_mass_storage(void)
50{
51 TRACE;
52
53 if(system(NULL))
54 {
55 system("setprop persist.sys.usb.config mass_storage");
56 system("setprop persist.usb.debug 0");
57 return;
58 }
59
60 DEBUGF("ERROR %s: No command processor available.", __func__);
61}
62
63
64/* Default at boot not known. */
65static int _last_usb_mode = -1;
66
67
68void ibasso_set_usb_mode(int mode)
69{
70 DEBUGF("DEBUG %s: _last_usb_mode: %d, mode: %d.", __func__, _last_usb_mode, mode);
71
72 if(_last_usb_mode != mode)
73 {
74 switch(mode)
75 {
76 case USB_MODE_MASS_STORAGE:
77 {
78 _last_usb_mode = mode;
79 usb_enable_mass_storage();
80 break;
81 }
82
83 case USB_MODE_CHARGE: /* Work around. */
84 case USB_MODE_ADB:
85 {
86 _last_usb_mode = mode;
87 usb_enable_adb();
88 break;
89 }
90 }
91 }
92}