Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
usb-moded
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
3
Merge Requests
3
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
mer-core
usb-moded
Commits
d6a30bf3
Commit
d6a30bf3
authored
Aug 23, 2013
by
Philippe De Swert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable setting idProduct per mode
Signed-off-by:
Philippe De Swert
<
philippe.deswert@jollamobile.com
>
parent
7289239c
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
52 additions
and
19 deletions
+52
-19
config/dyn-modes/adb_mode.ini
config/dyn-modes/adb_mode.ini
+1
-1
config/dyn-modes/developer_mode-android.ini
config/dyn-modes/developer_mode-android.ini
+1
-1
config/dyn-modes/diag_mode.ini
config/dyn-modes/diag_mode.ini
+4
-1
config/dyn-modes/pc_suite-android.ini
config/dyn-modes/pc_suite-android.ini
+1
-1
src/usb_moded-android.c
src/usb_moded-android.c
+17
-0
src/usb_moded-android.h
src/usb_moded-android.h
+1
-0
src/usb_moded-dyn-config.c
src/usb_moded-dyn-config.c
+2
-0
src/usb_moded-dyn-config.h
src/usb_moded-dyn-config.h
+18
-15
src/usb_moded-modesetting.c
src/usb_moded-modesetting.c
+7
-0
No files found.
config/dyn-modes/adb_mode.ini
View file @
d6a30bf3
...
...
@@ -12,4 +12,4 @@ sysfs_reset_value = none
softconnect_path
=
/sys/class/android_usb/android0/enable
softconnect
=
1
softconnec_disconnect
=
0
idProduct
=
0003
config/dyn-modes/developer_mode-android.ini
View file @
d6a30bf3
...
...
@@ -11,4 +11,4 @@ sysfs_reset_value = none
softconnect_path
=
/sys/class/android_usb/android0/enable
softconnect
=
1
softconnec_disconnect
=
0
idProduct
=
0002
config/dyn-modes/diag_mode.ini
View file @
d6a30bf3
...
...
@@ -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
config/dyn-modes/pc_suite-android.ini
View file @
d6a30bf3
...
...
@@ -9,4 +9,4 @@ sysfs_reset_value = none
softconnect_path
=
/sys/class/android_usb/android0/enable
softconnect
=
1
softconnec_disconnect
=
0
idProduct
=
0001
src/usb_moded-android.c
View file @
d6a30bf3
...
...
@@ -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
);
}
src/usb_moded-android.h
View file @
d6a30bf3
...
...
@@ -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
);
src/usb_moded-dyn-config.c
View file @
d6a30bf3
...
...
@@ -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
)
{
...
...
src/usb_moded-dyn-config.h
View file @
d6a30bf3
...
...
@@ -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
;
...
...
src/usb_moded-modesetting.c
View file @
d6a30bf3
...
...
@@ -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
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment