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

Enable setting idProduct per mode

Signed-off-by: default avatarPhilippe De Swert <philippe.deswert@jollamobile.com>
parent 7289239c
......@@ -12,4 +12,4 @@ sysfs_reset_value = none
softconnect_path = /sys/class/android_usb/android0/enable
softconnect = 1
softconnec_disconnect = 0
idProduct = 0003
......@@ -11,4 +11,4 @@ sysfs_reset_value = none
softconnect_path = /sys/class/android_usb/android0/enable
softconnect = 1
softconnec_disconnect = 0
idProduct = 0002
......@@ -2,10 +2,12 @@
name = diag_mode
module = none
appsync = 1
network = 1
network_interface = rndis0
[options]
sysfs_path = /sys/class/android_usb/android0/functions
sysfs_value = diag,serial
sysfs_value = rndis,adb,diag,serial
sysfs_reset_value = none
softconnect_path = /sys/class/android_usb/android0/enable
softconnect = 1
......@@ -14,3 +16,4 @@ android_extra_sysfs_path = /sys/class/android_usb/android0/f_diag/clients
android_extra_sysfs_value = diag,diag_mdm
android_extra_sysfs_path2 = /sys/class/android_usb/android0/f_serial/transports
android_extra_sysfs_value2 = smd,tty
idProduct = 0004
......@@ -9,4 +9,4 @@ sysfs_reset_value = none
softconnect_path = /sys/class/android_usb/android0/enable
softconnect = 1
softconnec_disconnect = 0
idProduct = 0001
......@@ -91,6 +91,7 @@ int set_android_charging_mode(void)
/* disable, set functions to "mass_storage", re-enable */
write_to_file("/sys/class/android_usb/android0/enable", "0");
write_to_file("/sys/class/android_usb/android0/idProduct", "9999");
write_to_file("/sys/class/android_usb/android0/functions", "mass_storage");
ret = write_to_file("/sys/class/android_usb/android0/enable", "1");
if(ret < 0)
......@@ -98,3 +99,19 @@ int set_android_charging_mode(void)
else
return(ret);
}
/* Set a product id for the android gadget
*
* @return 0 if successful, 1 on failure
*/
int set_android_productid(char *id)
{
int ret = 0;
/* disable, set functions to "mass_storage", re-enable */
write_to_file("/sys/class/android_usb/android0/idProduct", id);
if(ret < 0)
return(1);
else
return(ret);
}
......@@ -23,3 +23,4 @@
int android_settings(void);
void android_init_values(void);
int set_android_charging_mode(void);
int set_android_productid(char *id);
......@@ -96,6 +96,8 @@ static struct mode_list_elem *read_mode_file(const gchar *filename)
list_item->android_extra_sysfs_value = g_key_file_get_string(settingsfile, MODE_OPTIONS_ENTRY, MODE_ANDROID_EXTRA_SYSFS_VALUE, NULL);
list_item->android_extra_sysfs_value2 = g_key_file_get_string(settingsfile, MODE_OPTIONS_ENTRY, MODE_ANDROID_EXTRA_SYSFS_VALUE2, NULL);
//log_debug("Android extra value2 = %s\n", list_item->android_extra_sysfs_value2);
list_item->idProduct = g_key_file_get_string(settingsfile, MODE_OPTIONS_ENTRY, MODE_IDPRODUCT, NULL);
g_key_file_free(settingsfile);
if(list_item->mode_name == NULL || list_item->mode_module == NULL)
{
......
......@@ -45,6 +45,8 @@ android engineers prefered to have sysfs entries... go figure... */
/* in combined android gadgets we sometime need more than one extra sysfs path or value */
#define MODE_ANDROID_EXTRA_SYSFS_PATH2 "android_extra_sysfs_path2"
#define MODE_ANDROID_EXTRA_SYSFS_VALUE2 "android_extra_sysfs_value2"
/* For windows different modes/usb profiles need their own idProduct */
#define MODE_IDPRODUCT "idProduct"
/**
* Struct keeping all the data needed for the definition of a dynamic mode
......@@ -52,21 +54,22 @@ android engineers prefered to have sysfs entries... go figure... */
typedef struct mode_list_elem
{
/*@{ */
char *mode_name; /* mode name */
char *mode_module; /* needed module for given mode */
int appsync; /* requires appsync or not */
int network; /* bring up network or not */
char *network_interface; /* Which network interface to bring up if network needs to be enabled */
char *sysfs_path; /* path to set sysfs options */
char *sysfs_value; /* option name/value to write to sysfs */
char *sysfs_reset_value; /* value to reset the the sysfs to default */
char *softconnect; /* value to be written to softconnect interface */
char *softconnect_disconnect; /* value to set on the softconnect interface to disable after disconnect */
char *softconnect_path; /* path for the softconnect */
char *android_extra_sysfs_path; /* path for static value that never changes that needs to be set by sysfs :( */
char *android_extra_sysfs_value; /* static value that never changes that needs to be set by sysfs :( */
char *android_extra_sysfs_path2; /* path for static value that never changes that needs to be set by sysfs :( */
char *android_extra_sysfs_value2; /* static value that never changes that needs to be set by sysfs :( */
char *mode_name; /* mode name */
char *mode_module; /* needed module for given mode */
int appsync; /* requires appsync or not */
int network; /* bring up network or not */
char *network_interface; /* Which network interface to bring up if network needs to be enabled */
char *sysfs_path; /* path to set sysfs options */
char *sysfs_value; /* option name/value to write to sysfs */
char *sysfs_reset_value; /* value to reset the the sysfs to default */
char *softconnect; /* value to be written to softconnect interface */
char *softconnect_disconnect; /* value to set on the softconnect interface to disable after disconnect */
char *softconnect_path; /* path for the softconnect */
char *android_extra_sysfs_path; /* path for static value that never changes that needs to be set by sysfs :( */
char *android_extra_sysfs_value; /* static value that never changes that needs to be set by sysfs :( */
char *android_extra_sysfs_path2; /* path for static value that never changes that needs to be set by sysfs :( */
char *android_extra_sysfs_value2; /* static value that never changes that needs to be set by sysfs :( */
char *idProduct; /* product id to assign to a specific profile */
/*@} */
}mode_list_elem;
......
......@@ -40,6 +40,7 @@
#include "usb_moded-modesetting.h"
#include "usb_moded-network.h"
#include "usb_moded-upstart.h"
#include "usb_moded-android.h"
static void report_mass_storage_blocker(const char *mountpoint, int try);
......@@ -377,6 +378,12 @@ int set_dynamic_mode(void)
write_to_file(data->sysfs_path, data->sysfs_value);
log_debug("writing to file %s, value %s\n", data->sysfs_path, data->sysfs_value);
}
if(data->idProduct)
{
/* only works for android since the idProduct is a module parameter */
set_android_productid(data->idProduct);
}
/* enable the device */
if(data->softconnect)
{
write_to_file(data->softconnect_path, data->softconnect);
......
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