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-19 14:35:05 +0900
commitbea5bd17f1daa4afb6105057de266b4eba3376e5 (patch)
tree5fab5ce9442b53edf6a9227c643bcf7c8ba2a1cc
parent035a2922c8dfcd90867cf928465a4cb27a33f0ff (diff)
downloaddevice-manager-plugin-artik-resf/for/tizen.tar.gz
device-manager-plugin-artik-resf/for/tizen.tar.bz2
device-manager-plugin-artik-resf/for/tizen.zip
usb_gadget: apply next HAL architecture (hal api + backend)resf/for/tizen
Change-Id: I839eb4fd883facb066ab5730fda063f6032b3c0a
-rw-r--r--hw/usb_gadget/CMakeLists.txt13
-rw-r--r--hw/usb_gadget/usb_gadget.c69
2 files changed, 68 insertions, 14 deletions
diff --git a/hw/usb_gadget/CMakeLists.txt b/hw/usb_gadget/CMakeLists.txt
index 039baa4..8a2b329 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 hwcommon)
-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..f5abd72 100644
--- a/hw/usb_gadget/usb_gadget.c
+++ b/hw/usb_gadget/usb_gadget.c
@@ -17,13 +17,66 @@
*/
#include <hw/usb_gadget.h>
+#include <hal/hal-common-interface.h>
+#include <hal/device/hal-usb_gadget-interface.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 "common.h"
+
+static int usb_gadget_init(void **data)
+{
+ hal_backend_usb_gadget_funcs *usb_gadget_funcs;
+
+ // TODO. Need reimplement ///////////////////////////////////////////
+ struct hw_info info;
+ struct hw_common *common;
+ struct usb_gadget_translator *gadget_translator;
+
+ // from deviced
+ if (simple_translator_open(&info, NULL, &common)) {
+ _E("No USB gadget translator.");
+ return -1;
+ }
+
+ gadget_translator = container_of(common, struct usb_gadget_translator, common);
+ if (!gadget_translator->id_to_gadget || !gadget_translator->cleanup_gadget) {
+ _E("Invalid USB gadget translator.");
+
+ if (gadget_translator->common.info)
+ gadget_translator->common.info->close(&gadget_translator->common);
+
+ return -1;
+ }
+ //////////////////////////////////////////////////////////////////////
+
+ usb_gadget_funcs = calloc(1, sizeof(hal_backend_usb_gadget_funcs));
+ if (!usb_gadget_funcs)
+ return -ENOMEM;
+
+ usb_gadget_funcs->id_to_gadget = gadget_translator->id_to_gadget;
+ usb_gadget_funcs->cleanup_gadget = gadget_translator->cleanup_gadget;
+ usb_gadget_funcs->enable = NULL; // TODO
+ usb_gadget_funcs->disable = NULL; // TODO
+ usb_gadget_funcs->reconfigure_gadget = NULL; // TORO
+
+ *data = (void *)usb_gadget_funcs;
+
+ return 0;
+}
+
+static int usb_gadget_exit(void *data)
+{
+ // TODO free gadget
+
+ if (data)
+ free(data);
+
+ return 0;
+}
+
+hal_backend EXPORT hal_backend_device_usb_gadget_data = {
+ .name = "usb_gadget",
+ .vendor = "RPI",
+ .abi_version = HAL_ABI_VERSION_TIZEN_6_5,
+ .init = usb_gadget_init,
+ .exit = usb_gadget_exit,
};