diff options
author | INSUN PYO <insun.pyo@samsung.com> | 2018-03-14 10:23:57 +0900 |
---|---|---|
committer | Paweł Szewczyk <p.szewczyk@samsung.com> | 2018-04-09 14:23:55 +0200 |
commit | 1624d9ddfd5efc5b298b38630a6cb40456158994 (patch) | |
tree | 5e6fdb5afa1850b17d06fe8f7b0fa2f26f592053 | |
parent | 834135cf60aa15ccb76d676f3f7f7bc1a9cf23ca (diff) | |
download | device-manager-plugin-artik-1624d9ddfd5efc5b298b38630a6cb40456158994.tar.gz device-manager-plugin-artik-1624d9ddfd5efc5b298b38630a6cb40456158994.tar.bz2 device-manager-plugin-artik-1624d9ddfd5efc5b298b38630a6cb40456158994.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
-rwxr-xr-x | CMakeLists.txt | 1 | ||||
-rw-r--r-- | hw/usb_cfs_client/CMakeLists.txt | 19 | ||||
-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.c | 5 | ||||
-rwxr-xr-x | packaging/device-manager-plugin-artik.spec | 1 |
5 files changed, 32 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index a12e14b..7fab672 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,3 +10,4 @@ ADD_SUBDIRECTORY(hw/led) ADD_SUBDIRECTORY(hw/touchscreen) 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 deaafcd..0e76f3b 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> @@ -965,6 +966,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; @@ -1031,7 +1036,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 df5229a..824e562 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) @@ -715,6 +716,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-artik.spec b/packaging/device-manager-plugin-artik.spec index 5feaf0e..7268a6a 100755 --- a/packaging/device-manager-plugin-artik.spec +++ b/packaging/device-manager-plugin-artik.spec @@ -16,6 +16,7 @@ BuildRequires: pkgconfig(libudev) BuildRequires: pkgconfig(capi-system-peripheral-io) BuildRequires: pkgconfig(libusbgx) BuildRequires: pkgconfig(libsystemd) +BuildRequires: pkgconfig(libusbgx) %description Device manager plugin artik |