summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorINSUN PYO <insun.pyo@samsung.com>2021-01-19 14:35:05 +0900
committerINSUN PYO <insun.pyo@samsung.com>2021-01-25 20:00:22 +0900
commit19eb0f79ba1c7dd6e68a9261f2f63f249b9b0557 (patch)
tree6b7f4f509ca70a7cd4f4bb3bcd9bf69d97a8073d
parent887920a5feb7bfb28000216c4adb619a86fdb9ca (diff)
downloaddevice-manager-plugin-artik-19eb0f79ba1c7dd6e68a9261f2f63f249b9b0557.tar.gz
device-manager-plugin-artik-19eb0f79ba1c7dd6e68a9261f2f63f249b9b0557.tar.bz2
device-manager-plugin-artik-19eb0f79ba1c7dd6e68a9261f2f63f249b9b0557.zip
usb_gadget: apply next HAL architecture (hal api + backend)
Change-Id: I839eb4fd883facb066ab5730fda063f6032b3c0a
-rw-r--r--CMakeLists.txt2
-rw-r--r--hw/usb_cfs_client/CMakeLists.txt19
-rw-r--r--hw/usb_cfs_client/usb_cfs_client.c29
-rw-r--r--hw/usb_client/CMakeLists.txt19
-rw-r--r--hw/usb_client/usb_client.c29
-rw-r--r--hw/usb_gadget/CMakeLists.txt13
-rw-r--r--hw/usb_gadget/usb_gadget.c74
-rw-r--r--packaging/device-manager-plugin-artik.spec3
8 files changed, 72 insertions, 116 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3e85ff1..47bf058 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -14,7 +14,5 @@ ADD_SUBDIRECTORY(hw/display)
ADD_SUBDIRECTORY(hw/led)
ADD_SUBDIRECTORY(hw/touchscreen)
ADD_SUBDIRECTORY(hw/usb_gadget)
-ADD_SUBDIRECTORY(hw/usb_client)
-ADD_SUBDIRECTORY(hw/usb_cfs_client)
ADD_SUBDIRECTORY(hw/thermal)
ADD_SUBDIRECTORY(hw/haptic)
diff --git a/hw/usb_cfs_client/CMakeLists.txt b/hw/usb_cfs_client/CMakeLists.txt
deleted file mode 100644
index 70b054d..0000000
--- a/hw/usb_cfs_client/CMakeLists.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-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 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)
-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_cfs_client/usb_cfs_client.c b/hw/usb_cfs_client/usb_cfs_client.c
deleted file mode 100644
index 36da551..0000000
--- a/hw/usb_cfs_client/usb_cfs_client.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * device-node
- *
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <hw/usb_client.h>
-
-HARDWARE_MODULE_STRUCTURE = {
- .magic = HARDWARE_INFO_TAG,
- .hal_version = HARDWARE_INFO_VERSION,
- .device_version = USB_CLIENT_HARDWARE_DEVICE_VERSION,
- .id = USB_CFS_CLIENT_HARDWARE_DEVICE_ID,
- .name = "cfs-gadget",
- .open = hw_cfs_gadget_open,
- .close = hw_cfs_gadget_close,
-};
diff --git a/hw/usb_client/CMakeLists.txt b/hw/usb_client/CMakeLists.txt
deleted file mode 100644
index 28bab08..0000000
--- a/hw/usb_client/CMakeLists.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(usb_client C)
-
-SET(PREFIX ${CMAKE_INSTALL_PREFIX})
-
-INCLUDE(FindPkgConfig)
-pkg_check_modules(usb_client_pkgs REQUIRED hwcommon dlog glib-2.0 libusbgx)
-
-FOREACH(flag ${usb_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_client.c)
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${usb_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.c b/hw/usb_client/usb_client.c
deleted file mode 100644
index 5b4b61e..0000000
--- a/hw/usb_client/usb_client.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * device-node
- *
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <hw/usb_client.h>
-
-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,
- .name = "legacy-gadget",
- .open = hw_legacy_gadget_open,
- .close = hw_legacy_gadget_close,
-};
diff --git a/hw/usb_gadget/CMakeLists.txt b/hw/usb_gadget/CMakeLists.txt
index 039baa4..efebc32 100644
--- a/hw/usb_gadget/CMakeLists.txt
+++ b/hw/usb_gadget/CMakeLists.txt
@@ -1,12 +1,14 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(usb_gadget C)
+PROJECT(hal-backend-device-usb-gadget C)
SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+INCLUDE_DIRECTORIES(../common)
+
INCLUDE(FindPkgConfig)
-pkg_check_modules(usb_gadget_pkgs REQUIRED hwcommon)
+pkg_check_modules(hal-backend-device-usb-gadget_pkgs REQUIRED dlog hal-backend-device-common)
-FOREACH(flag ${usb_gadget_pkgs_CFLAGS})
+FOREACH(flag ${hal-backend-device-usb-gadget_pkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
ENDFOREACH(flag)
@@ -14,6 +16,5 @@ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
ADD_LIBRARY(${PROJECT_NAME} MODULE usb_gadget.c)
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${usb_gadget_pkgs_LDFLAGS})
-SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES PREFIX "")
-INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR}/hw COMPONENT RuntimeLibraries)
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${hal-backend-device-usb-gadget_pkgs_LDFLAGS})
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /hal/lib COMPONENT RuntimeLibraries)
diff --git a/hw/usb_gadget/usb_gadget.c b/hw/usb_gadget/usb_gadget.c
index 2bf9d96..daf0d82 100644
--- a/hw/usb_gadget/usb_gadget.c
+++ b/hw/usb_gadget/usb_gadget.c
@@ -16,14 +16,68 @@
* limitations under the License.
*/
-#include <hw/usb_gadget.h>
-
-HARDWARE_MODULE_STRUCTURE = {
- .magic = HARDWARE_INFO_TAG,
- .hal_version = HARDWARE_INFO_VERSION,
- .device_version = USB_GADGET_DEVICE_VERSION,
- .id = USB_GADGET_DEVICE_ID,
- .name = "simple_translator",
- .open = simple_translator_open,
- .close = simple_translator_close,
+#include <errno.h>
+#include <stdlib.h>
+
+#include <hal/hal-common-interface.h>
+#include <hal/device/hal-common-interface.h>
+#include <hal/device/hal-usb_gadget-interface.h>
+
+#include "common.h"
+
+static int usb_gadget_init(void **data)
+{
+ hal_backend_usb_gadget_funcs *usb_gadget_funcs;
+
+ if (!data)
+ return -EINVAL;
+
+ usb_gadget_funcs = calloc(1, sizeof(hal_backend_usb_gadget_funcs));
+ if (!usb_gadget_funcs)
+ return -ENOMEM;
+
+ // usb_gadget_translator
+ if (simple_translator_open(usb_gadget_funcs)) {
+ _E("No USB gadget translator");
+ goto error_translator_open;
+ }
+
+ // usb_client
+ if (hw_cfs_gadget_open(usb_gadget_funcs)) {
+ _I("No USB client");
+ goto error_gadget_open;
+ }
+
+ *data = (void *)usb_gadget_funcs;
+
+ return 0;
+
+error_gadget_open:
+ simple_translator_close(usb_gadget_funcs);
+
+error_translator_open:
+ free(usb_gadget_funcs);
+
+ return -ENODEV;
+}
+
+static int usb_gadget_exit(void *data)
+{
+ hal_backend_usb_gadget_funcs *usb_gadget_funcs = (hal_backend_usb_gadget_funcs *)data;
+
+ if (usb_gadget_funcs) {
+ hw_cfs_gadget_close(usb_gadget_funcs);
+ simple_translator_close(usb_gadget_funcs);
+ free(usb_gadget_funcs);
+ }
+
+ return 0;
+}
+
+hal_backend EXPORT hal_backend_device_usb_gadget_data = {
+ .name = "usb_gadget",
+ .vendor = "ARTIK",
+ .abi_version = HAL_ABI_VERSION_TIZEN_6_5,
+ .init = usb_gadget_init,
+ .exit = usb_gadget_exit,
};
diff --git a/packaging/device-manager-plugin-artik.spec b/packaging/device-manager-plugin-artik.spec
index 0eb74d9..0ab0f8d 100644
--- a/packaging/device-manager-plugin-artik.spec
+++ b/packaging/device-manager-plugin-artik.spec
@@ -10,7 +10,6 @@ Requires(post): /sbin/ldconfig
Requires(postun): /sbin/ldconfig
BuildRequires: cmake
BuildRequires: pkgconfig(dlog)
-BuildRequires: pkgconfig(hwcommon)
BuildRequires: pkgconfig(glib-2.0)
BuildRequires: pkgconfig(libudev)
BuildRequires: pkgconfig(capi-system-peripheral-io)
@@ -18,6 +17,7 @@ BuildRequires: pkgconfig(libusbgx)
BuildRequires: pkgconfig(hal-api-common)
BuildRequires: pkgconfig(hal-api-device)
BuildRequires: pkgconfig(libsyscommon)
+BuildRequires: pkgconfig(hal-backend-device-common)
%description
Device manager plugin artik
@@ -44,6 +44,5 @@ make %{?jobs:-j%jobs}
%files
/hal/lib/*.so*
-%{_libdir}/hw/*.so
%manifest %{name}.manifest
%license LICENSE