diff options
author | INSUN PYO <insun.pyo@samsung.com> | 2018-03-15 17:48:51 +0900 |
---|---|---|
committer | INSUN PYO <insun.pyo@samsung.com> | 2018-03-15 17:52:48 +0900 |
commit | c42989ff40878adc31490f4d895b1248b94dac62 (patch) | |
tree | 2c41561fbf80c52389bbade5a7bf8985dc39a5b6 | |
parent | 35171555725ea09c7ef09df8747075e8976a7540 (diff) | |
download | device-manager-plugin-odroid-c42989ff40878adc31490f4d895b1248b94dac62.tar.gz device-manager-plugin-odroid-c42989ff40878adc31490f4d895b1248b94dac62.tar.bz2 device-manager-plugin-odroid-c42989ff40878adc31490f4d895b1248b94dac62.zip |
usb: mtp disable in tv profilesubmit/tizen/20180315.085746accepted/tizen/unified/20180315.150809
Signed-off-by: INSUN PYO <insun.pyo@samsung.com>
Change-Id: I0e1713d17cb32b344e340f92e14298eb8f8d9b47
-rw-r--r-- | hw/usb_gadget/CMakeLists.txt | 2 | ||||
-rw-r--r-- | hw/usb_gadget/usb_gadget.c | 60 | ||||
-rw-r--r-- | packaging/device-manager-plugin-odroid.spec | 1 |
3 files changed, 53 insertions, 10 deletions
diff --git a/hw/usb_gadget/CMakeLists.txt b/hw/usb_gadget/CMakeLists.txt index 2e28b15..0f365ff 100644 --- a/hw/usb_gadget/CMakeLists.txt +++ b/hw/usb_gadget/CMakeLists.txt @@ -4,7 +4,7 @@ PROJECT(usb_gadget C) SET(PREFIX ${CMAKE_INSTALL_PREFIX}) INCLUDE(FindPkgConfig) -pkg_check_modules(usb_gadget_pkgs REQUIRED hwcommon) +pkg_check_modules(usb_gadget_pkgs REQUIRED hwcommon capi-system-info) FOREACH(flag ${usb_gadget_pkgs_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") diff --git a/hw/usb_gadget/usb_gadget.c b/hw/usb_gadget/usb_gadget.c index 36ff095..8f6aea6 100644 --- a/hw/usb_gadget/usb_gadget.c +++ b/hw/usb_gadget/usb_gadget.c @@ -23,6 +23,7 @@ #include <stdlib.h> #include <errno.h> #include <string.h> +#include <system_info.h> #define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0])) #define zalloc(amount) calloc(1, amount) @@ -181,6 +182,25 @@ static inline struct usb_function *find_func(struct usb_gadget *gadget, return gadget->funcs[i]; } +static int is_tv_profile(void) +{ + int ret; + char *profile_name = NULL; + const char const *tv_profile_name = "tv"; + + ret = system_info_get_platform_string("http://tizen.org/feature/profile", &profile_name); + + if (ret == SYSTEM_INFO_ERROR_NONE) { + ret = strncmp(profile_name, tv_profile_name, strlen(tv_profile_name)); + free(profile_name); + + if (ret == 0) + return 1; + } + + return 0; +} + static int simple_id_to_gadget(struct usb_gadget_id *gadget_id, struct usb_gadget **_gadget) { @@ -200,6 +220,10 @@ static int simple_id_to_gadget(struct usb_gadget_id *gadget_id, if (ret) goto out; + /* XU3 TV profile does not support mtp */ + if (is_tv_profile()) + gadget_id->function_mask &= ~USB_FUNCTION_MTP; + /* * Currently all gadgets use inly single configuration but * slp-gadget is capable to handle two of them @@ -214,36 +238,38 @@ static int simple_id_to_gadget(struct usb_gadget_id *gadget_id, functions[0][1] = 0; gadget->attrs.idProduct = 0x685d; break; + case USB_FUNCTION_MTP: n_configs = 1; functions[0][0] = USB_FUNCTION_MTP; functions[0][1] = 0; gadget->attrs.idProduct = 0x6860; break; + case USB_FUNCTION_RNDIS: n_configs = 1; functions[0][0] = USB_FUNCTION_RNDIS; functions[0][1] = 0; gadget->attrs.idProduct = 0x6863; break; - case USB_FUNCTION_MTP | USB_FUNCTION_ACM | USB_FUNCTION_SDB: + + case USB_FUNCTION_ACM | USB_FUNCTION_SDB: n_configs = 1; - functions[0][0] = USB_FUNCTION_MTP; - functions[0][1] = USB_FUNCTION_ACM; - functions[0][2] = USB_FUNCTION_SDB; - functions[0][3] = 0; + functions[0][0] = USB_FUNCTION_ACM; + functions[0][1] = USB_FUNCTION_SDB; + functions[0][2] = 0; gadget->attrs.idProduct = 0x6860; break; - case USB_FUNCTION_MTP | USB_FUNCTION_ACM | USB_FUNCTION_SDB - | USB_FUNCTION_DIAG: + + case USB_FUNCTION_MTP | USB_FUNCTION_ACM | USB_FUNCTION_SDB: n_configs = 1; functions[0][0] = USB_FUNCTION_MTP; functions[0][1] = USB_FUNCTION_ACM; functions[0][2] = USB_FUNCTION_SDB; - functions[0][3] = USB_FUNCTION_DIAG; - functions[0][4] = 0; + functions[0][3] = 0; gadget->attrs.idProduct = 0x6860; break; + case USB_FUNCTION_RNDIS | USB_FUNCTION_SDB: n_configs = 1; functions[0][0] = USB_FUNCTION_RNDIS; @@ -251,6 +277,18 @@ static int simple_id_to_gadget(struct usb_gadget_id *gadget_id, functions[0][2] = 0; gadget->attrs.idProduct = 0x6864; break; + +#if 0 + case USB_FUNCTION_MTP | USB_FUNCTION_ACM | USB_FUNCTION_SDB | USB_FUNCTION_DIAG: + n_configs = 1; + functions[0][0] = USB_FUNCTION_MTP; + functions[0][1] = USB_FUNCTION_ACM; + functions[0][2] = USB_FUNCTION_SDB; + functions[0][3] = USB_FUNCTION_DIAG; + functions[0][4] = 0; + gadget->attrs.idProduct = 0x6860; + break; + case USB_FUNCTION_RNDIS | USB_FUNCTION_SDB | USB_FUNCTION_ACM | USB_FUNCTION_DIAG: n_configs = 1; functions[0][0] = USB_FUNCTION_RNDIS; @@ -260,6 +298,7 @@ static int simple_id_to_gadget(struct usb_gadget_id *gadget_id, functions[0][4] = 0; gadget->attrs.idProduct = 0x6864; break; + case USB_FUNCTION_RNDIS | USB_FUNCTION_DIAG: n_configs = 1; functions[0][0] = USB_FUNCTION_RNDIS; @@ -267,6 +306,7 @@ static int simple_id_to_gadget(struct usb_gadget_id *gadget_id, functions[0][2] = 0; gadget->attrs.idProduct = 0x6864; break; + case USB_FUNCTION_ACM | USB_FUNCTION_SDB | USB_FUNCTION_DM: n_configs = 1; functions[0][0] = USB_FUNCTION_ACM; @@ -275,6 +315,7 @@ static int simple_id_to_gadget(struct usb_gadget_id *gadget_id, functions[0][3] = 0; gadget->attrs.idProduct = 0x6860; break; + case USB_FUNCTION_DIAG | USB_FUNCTION_ACM | USB_FUNCTION_RMNET: n_configs = 1; functions[0][0] = USB_FUNCTION_DIAG; @@ -283,6 +324,7 @@ static int simple_id_to_gadget(struct usb_gadget_id *gadget_id, functions[0][3] = 0; gadget->attrs.idProduct = 0x685d; break; +#endif }; if (n_configs > 2 || n_configs <= 0) { diff --git a/packaging/device-manager-plugin-odroid.spec b/packaging/device-manager-plugin-odroid.spec index 8a65507..4466f2f 100644 --- a/packaging/device-manager-plugin-odroid.spec +++ b/packaging/device-manager-plugin-odroid.spec @@ -14,6 +14,7 @@ BuildRequires: pkgconfig(hwcommon) BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(libsystemd) BuildRequires: pkgconfig(libusbgx) +BuildRequires: pkgconfig(capi-system-info) %description Device manager plugin for ODROID development board. |