diff options
author | Wootak Jung <wootak.jung@samsung.com> | 2021-01-20 15:47:50 +0900 |
---|---|---|
committer | Wootak Jung <wootak.jung@samsung.com> | 2021-01-20 15:48:17 +0900 |
commit | 539c774ca605fdbc1a12392a4436b28331547775 (patch) | |
tree | ce0a3b6dce89bac81a0bda8df4817ba602307278 | |
parent | 9d783d13c780c5c3215437a61bd7e74afee0615b (diff) | |
download | bluetooth-firmware-marvell-539c774ca605fdbc1a12392a4436b28331547775.tar.gz bluetooth-firmware-marvell-539c774ca605fdbc1a12392a4436b28331547775.tar.bz2 bluetooth-firmware-marvell-539c774ca605fdbc1a12392a4436b28331547775.zip |
Apply next HAL architecture (hal api + backend)
Change-Id: I4d0402656b973ad3f9d6d43f5cfce2a05b06e6a3
Signed-off-by: Wootak Jung <wootak.jung@samsung.com>
-rw-r--r-- | CMakeLists.txt | 1 | ||||
-rw-r--r-- | packaging/bluetooth-firmware-marvell.spec | 4 | ||||
-rw-r--r-- | src/CMakeLists.txt | 25 | ||||
-rw-r--r-- | src/hal-backend-bluetooth.c | 75 |
4 files changed, 105 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 9e3ce88..6a34dca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,3 +11,4 @@ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror -fPIE") SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie") ADD_SUBDIRECTORY(scripts) +ADD_SUBDIRECTORY(src) diff --git a/packaging/bluetooth-firmware-marvell.spec b/packaging/bluetooth-firmware-marvell.spec index b82d889..e923e32 100644 --- a/packaging/bluetooth-firmware-marvell.spec +++ b/packaging/bluetooth-firmware-marvell.spec @@ -11,6 +11,9 @@ Provides: bluetooth-scripts Requires: openssl1.1 BuildRequires: cmake +BuildRequires: pkgconfig(dlog) +BuildRequires: pkgconfig(hal-api-common) +BuildRequires: pkgconfig(hal-api-bluetooth) %description firmware and tools for bluetooth @@ -46,3 +49,4 @@ rm -rf %{buildroot} %attr(755,-,-) %{_prefix}/etc/bluetooth/bt-dev-end.sh %attr(755,-,-) %{_prefix}/etc/bluetooth/bt-dev-start.sh %attr(755,-,-) %{_prefix}/etc/bluetooth/bt-set-addr.sh +/hal/lib/*.so* diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..ca1fc73 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,25 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(hal-backend-bluetooth C) + +INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/include) + +INCLUDE(FindPkgConfig) +pkg_check_modules(hal-backend-bluetooth_pkgs REQUIRED + dlog + hal-api-common + hal-api-bluetooth +) + +SET(SRCS + ${PROJECT_SOURCE_DIR}/${PROJECT_NAME}.c) + +FOREACH(flag ${hal-backend-bluetooth_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} SHARED ${SRCS}) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${hal-backend-bluetooth_pkgs_LDFLAGS}) +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /hal/lib COMPONENT RuntimeLibraries) diff --git a/src/hal-backend-bluetooth.c b/src/hal-backend-bluetooth.c new file mode 100644 index 0000000..6aec23b --- /dev/null +++ b/src/hal-backend-bluetooth.c @@ -0,0 +1,75 @@ +#include <stdio.h> +#include <stdlib.h> +#include <stdint.h> +#include <errno.h> +#include <dlog.h> + +#include <hal/hal-bluetooth-interface.h> + +#undef LOG_TAG +#define LOG_TAG "HALAPI_BLUETOOTH" + +#define EXPORT __attribute__ ((visibility("default"))) + +static int bluetooth_artik_start(void) +{ + int ret; + ret = system("/usr/etc/bluetooth/bt-stack-up.sh"); + if (ret == 0x100) { + LOGE("script internal failed"); + return HAL_BACKEND_ERROR_INTERNAL; + } else if (ret == 0x200) { + LOGE("script timeout failed"); + return HAL_BACKEND_ERROR_TIMEOUT; + } + LOGD("script started successfully"); + return HAL_BACKEND_ERROR_NONE; +} + +static int bluetooth_artik_stop(void) +{ + int ret; + ret = system("/usr/etc/bluetooth/bt-stack-down.sh"); + if (ret == 0x100) { + LOGE("script internal failed"); + return HAL_BACKEND_ERROR_INTERNAL; + } else if (ret == 0x200) { + LOGE("script timeout failed"); + return HAL_BACKEND_ERROR_TIMEOUT; + } + LOGD("script started successfully"); + return HAL_BACKEND_ERROR_NONE; +} + +static int bluetooth_artik_init(void **data) +{ + hal_backend_bluetooth_funcs *bluetooth_funcs; + + bluetooth_funcs = calloc(1, sizeof(hal_backend_bluetooth_funcs)); + if (!bluetooth_funcs) + return -ENOMEM; + + bluetooth_funcs->start = bluetooth_artik_start; + bluetooth_funcs->stop = bluetooth_artik_stop; + + *data = (void *)bluetooth_funcs; + + return 0; +} + +static int bluetooth_artik_exit(void *data) +{ + if (!data) + return -EINVAL; + free(data); + + return 0; +} + +hal_backend EXPORT hal_backend_bluetooth_data = { + .name = "bluetooth", + .vendor = "artik", + .abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .init = bluetooth_artik_init, + .exit = bluetooth_artik_exit, +}; |