summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorINSUN PYO <insun.pyo@samsung.com>2018-03-14 10:23:57 +0900
committerINSUN PYO <insun.pyo@samsung.com>2018-03-14 10:27:46 +0900
commit333771abc90defa75d5e7f1337b159dd44c518e5 (patch)
treedf49d6d01166b02925c29548291789d965038b1f
parent766ee8120d710f3661462a920d3b49277ceab5ce (diff)
downloaddevice-manager-plugin-odroid-333771abc90defa75d5e7f1337b159dd44c518e5.tar.gz
device-manager-plugin-odroid-333771abc90defa75d5e7f1337b159dd44c518e5.tar.bz2
device-manager-plugin-odroid-333771abc90defa75d5e7f1337b159dd44c518e5.zip
usb: patches to selectively support both slp and functionfs
If /sys/class/usb_mode/usb0/enable exists, it is slp usb_hal. Otherwise it is configfs usb_hal. Signed-off-by: INSUN PYO <insun.pyo@samsung.com> Change-Id: I8e6b74ffbc6287fe7b5f0a7ab475edff16b2fd88
-rw-r--r--CMakeLists.txt1
-rw-r--r--hw/usb_cfs_client/CMakeLists.txt19
-rw-r--r--hw/usb_cfs_client/usb_cfs_client.c (renamed from hw/usb_client/usb_client_configfs.c)7
-rw-r--r--hw/usb_client/usb_client.c5
-rw-r--r--packaging/device-manager-plugin-odroid.spec1
5 files changed, 32 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4858e21..90a976c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -6,3 +6,4 @@ SET(PREFIX ${CMAKE_INSTALL_PREFIX})
ADD_SUBDIRECTORY(hw/display)
ADD_SUBDIRECTORY(hw/usb_gadget)
ADD_SUBDIRECTORY(hw/usb_client)
+ADD_SUBDIRECTORY(hw/usb_cfs_client)
diff --git a/hw/usb_cfs_client/CMakeLists.txt b/hw/usb_cfs_client/CMakeLists.txt
new file mode 100644
index 0000000..15e7cbc
--- /dev/null
+++ b/hw/usb_cfs_client/CMakeLists.txt
@@ -0,0 +1,19 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(usb_cfs_client C)
+
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(usb_cfs_client_pkgs REQUIRED hwcommon dlog glib-2.0 libsystemd libusbgx)
+
+FOREACH(flag ${usb_cfs_client_pkgs_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+
+ADD_LIBRARY(${PROJECT_NAME} MODULE usb_cfs_client.c ../shared.c)
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${usb_cfs_client_pkgs_LDFLAGS})
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES PREFIX "")
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR}/hw COMPONENT RuntimeLibraries)
diff --git a/hw/usb_client/usb_client_configfs.c b/hw/usb_cfs_client/usb_cfs_client.c
index d48ae0d..e32112d 100644
--- a/hw/usb_client/usb_client_configfs.c
+++ b/hw/usb_cfs_client/usb_cfs_client.c
@@ -27,6 +27,7 @@
#include <sys/types.h>
#include <sys/mount.h>
#include <usbg/usbg.h>
+#include <unistd.h>
#include <systemd/sd-bus.h>
#include <unistd.h>
@@ -964,6 +965,10 @@ static int cfs_gadget_open(struct hw_info *info,
if (!info || !common)
return -EINVAL;
+ /* used exclusively with slp usb_client*/
+ if (!access("/sys/class/usb_mode/usb0/enable", F_OK))
+ return -ENOENT;
+
cfs_client = zalloc(sizeof(*cfs_client));
if (!cfs_client)
return -ENOMEM;
@@ -1030,7 +1035,7 @@ HARDWARE_MODULE_STRUCTURE = {
.magic = HARDWARE_INFO_TAG,
.hal_version = HARDWARE_INFO_VERSION,
.device_version = USB_CLIENT_HARDWARE_DEVICE_VERSION,
- .id = USB_CLIENT_HARDWARE_DEVICE_ID,
+ .id = USB_CFS_CLIENT_HARDWARE_DEVICE_ID,
.name = "cfs-gadget",
.open = cfs_gadget_open,
.close = cfs_gadget_close,
diff --git a/hw/usb_client/usb_client.c b/hw/usb_client/usb_client.c
index f8bdd3a..4f6baf2 100644
--- a/hw/usb_client/usb_client.c
+++ b/hw/usb_client/usb_client.c
@@ -23,6 +23,7 @@
#include <limits.h>
#include <stdio.h>
#include <string.h>
+#include <unistd.h>
#include <systemd/sd-bus.h>
#define zalloc(amount) calloc(1, amount)
@@ -712,6 +713,10 @@ static int legacy_gadget_open(struct hw_info *info,
if (!info || !common)
return -EINVAL;
+ /* check if slp usb gadget exists */
+ if (access("/sys/class/usb_mode/usb0/enable", F_OK))
+ return -ENOENT;
+
legacy = zalloc(sizeof(*legacy));
if (!legacy)
return -ENOMEM;
diff --git a/packaging/device-manager-plugin-odroid.spec b/packaging/device-manager-plugin-odroid.spec
index c87dedb..8a65507 100644
--- a/packaging/device-manager-plugin-odroid.spec
+++ b/packaging/device-manager-plugin-odroid.spec
@@ -13,6 +13,7 @@ BuildRequires: pkgconfig(dlog)
BuildRequires: pkgconfig(hwcommon)
BuildRequires: pkgconfig(glib-2.0)
BuildRequires: pkgconfig(libsystemd)
+BuildRequires: pkgconfig(libusbgx)
%description
Device manager plugin for ODROID development board.