usb: mtp disable in tv profile 05/172705/2 accepted/tizen/unified/20180315.150809 submit/tizen/20180315.085746
authorINSUN PYO <insun.pyo@samsung.com>
Thu, 15 Mar 2018 08:48:51 +0000 (17:48 +0900)
committerINSUN PYO <insun.pyo@samsung.com>
Thu, 15 Mar 2018 08:52:48 +0000 (17:52 +0900)
Signed-off-by: INSUN PYO <insun.pyo@samsung.com>
Change-Id: I0e1713d17cb32b344e340f92e14298eb8f8d9b47

hw/usb_gadget/CMakeLists.txt
hw/usb_gadget/usb_gadget.c
packaging/device-manager-plugin-odroid.spec

index 2e28b15..0f365ff 100644 (file)
@@ -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}")
index 36ff095..8f6aea6 100644 (file)
@@ -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) {
index 8a65507..4466f2f 100644 (file)
@@ -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.