Commit c234d503 authored by Philippe De Swert's avatar Philippe De Swert

Implement charging mode for the android gadget. The g_file/mass_storage module

might not be available so trick the android gadget into an empty configuration for
charging enumeration.

[usb-moded] Charging mode with android gadget
Signed-off-by: default avatarPhilippe De Swert <philippe.deswert@jollamobile.com>
parent 82c4e2f4
......@@ -81,4 +81,20 @@ void android_init_values(void)
}
}
/* Set a charging mode for the android gadget
*
* @return 0 if successful, 1 on failure
*/
int set_android_charging_mode(void)
{
int ret = 0;
/* disable, set functions to "null", re-enable */
write_to_file("/sys/class/android_usb/android0/enable", "0");
write_to_file("/sys/class/android_usb/android0/functions", "null");
ret = write_to_file("/sys/class/android_usb/android0/enable", "1");
if(ret < 0)
return(1);
else
return(ret);
}
......@@ -22,3 +22,4 @@
int android_settings(void);
void android_init_values(void);
int set_android_charging_mode(void);
......@@ -247,6 +247,9 @@ void set_usb_mode(const char *mode)
set_usb_module(MODULE_MASS_STORAGE);
/* MODULE_CHARGING has all the parameters defined, so it will not match the g_file_storage rule in usb_moded_load_module */
ret = usb_moded_load_module(MODULE_CHARGING);
/* if charging mode setting did not succeed we might be dealing with android */
if(ret)
ret = set_android_charging_mode();
goto end;
}
else if(!strcmp(mode, MODE_ASK) || !strcmp(mode, MODE_CHARGER))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment