Use only hal-rootstrap package to build 99/313799/4 accepted/tizen/unified/20240703.100116 accepted/tizen/unified/dev/20240704.065626
authorYunhee Seo <yuni.seo@samsung.com>
Mon, 1 Jul 2024 08:15:18 +0000 (17:15 +0900)
committerYunhee Seo <yuni.seo@samsung.com>
Tue, 2 Jul 2024 10:10:40 +0000 (19:10 +0900)
As support hal-abi-versioning, the hal-backend package should be built
using only the hal-rootstrap.
Other packages not included in the hal-roostrap have been deleted to remove dependencies.
util is added to replace functions of dlog and libsyscommon package.

Change-Id: Ie478da1afe4dc6dca876d521ebb2a8e501f732fb
Signed-off-by: Yunhee Seo <yuni.seo@samsung.com>
16 files changed:
CMakeLists.txt
hw/board/CMakeLists.txt
hw/board/board.c
hw/display/CMakeLists.txt
hw/display/display.c
hw/haptic/CMakeLists.txt
hw/haptic/gpio.c
hw/memory/CMakeLists.txt
hw/memory/memory.c
hw/thermal/CMakeLists.txt
hw/thermal/thermal.c
hw/touchscreen/CMakeLists.txt
hw/touchscreen/touchscreen.c
include/util.h [new file with mode: 0644]
packaging/hal-backend-device-vim3.spec
src/util.c [new file with mode: 0644]

index c626cb40742f151bde3df8ae6e5f7b3107a00181..54c8c11eacd50c354440da2872a4aaac5fceb071 100644 (file)
@@ -3,12 +3,21 @@ PROJECT(hal-backend-device-vim3 C)
 
 SET(PREFIX ${CMAKE_INSTALL_PREFIX})
 
+INCLUDE(FindPkgConfig)
+pkg_check_modules(hal-backend-device-vim3_pkgs REQUIRED hal-rootstrap)
+
+FOREACH(flag ${hal-backend-device-vim3_pkgs_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall -Werror")
 
 IF(ENABLE_DLOG STREQUAL on)
        ADD_DEFINITIONS("-DFEATURE_DLOG")
 ENDIF()
 
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
+
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.Apache-2.0 DESTINATION ${HAL_LICENSE_DIR}/${PROJECT_NAME})
 
 ADD_SUBDIRECTORY(hw/board)
index de3acea9a55e024e5347a8976cd50844d2d0f119..358723c623a398070a0a8f76ac1bb39175987763 100644 (file)
@@ -3,8 +3,10 @@ PROJECT(hal-backend-device-board C)
 
 SET(PREFIX ${CMAKE_INSTALL_PREFIX})
 
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
+
 INCLUDE(FindPkgConfig)
-pkg_check_modules(hal-backend-device-board_pkgs REQUIRED hal-backend-device-common)
+pkg_check_modules(hal-backend-device-board_pkgs REQUIRED hal-rootstrap)
 
 FOREACH(flag ${hal-backend-device-board_pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
@@ -13,6 +15,6 @@ ENDFOREACH(flag)
 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
 
-ADD_LIBRARY(${PROJECT_NAME} MODULE board.c)
+ADD_LIBRARY(${PROJECT_NAME} MODULE board.c ${CMAKE_SOURCE_DIR}/src/util.c)
 TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${hal-backend-device-board_pkgs_LDFLAGS})
 INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${HAL_LIB_DIR} COMPONENT RuntimeLibraries)
index 22d4136554c0c9c5d341d17ce75b51d0472e9ce2..6a9abede23b3eca8919962b340df881d0302aa30 100644 (file)
@@ -23,7 +23,7 @@
 #include <errno.h>
 #include <string.h>
 
-#include </hal/include/device/hal-backend-common.h>
+#include "util.h"
 
 #define DATA_BUFF_MAX       256
 #define CPUINFO_PATH        "/proc/cpuinfo"
index 8d73dd550af32a9710eef964f30ff24e6c8b1802..da3385c2fb7a93b665c42299a3be05cf87ce24b0 100644 (file)
@@ -3,8 +3,10 @@ PROJECT(hal-backend-device-display C)
 
 SET(PREFIX ${CMAKE_INSTALL_PREFIX})
 
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
+
 INCLUDE(FindPkgConfig)
-pkg_check_modules(hal-backend-device-display_pkgs REQUIRED hal-backend-device-common libsyscommon)
+pkg_check_modules(hal-backend-device-display_pkgs REQUIRED hal-rootstrap)
 
 FOREACH(flag ${hal-backend-device-display_pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
@@ -13,6 +15,6 @@ ENDFOREACH(flag)
 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
 
-ADD_LIBRARY(${PROJECT_NAME} MODULE display.c)
+ADD_LIBRARY(${PROJECT_NAME} MODULE display.c ${CMAKE_SOURCE_DIR}/src/util.c)
 TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${hal-backend-device-display_pkgs_LDFLAGS})
 INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${HAL_LIB_DIR} COMPONENT RuntimeLibraries)
index 78f5d398f302c267d08c9df71150af2b26739bc2..8c91c842ec21a6036bcb65275878368aa59197d1 100644 (file)
@@ -25,9 +25,8 @@
 
 #include <hal/hal-device-display-interface.h>
 #include <hal/hal-common-interface.h>
-#include <libsyscommon/file.h>
 
-#include </hal/include/device/hal-backend-common.h>
+#include "util.h"
 
 #ifndef BACKLIGHT_PATH
 #define BACKLIGHT_PATH  "/sys/class/backlight/rpi_backlight"
index d3b5d3c1a0398f10704c26f29a01882f823efca3..c04a36225fd06876144d8a84229886d1e0868dfe 100644 (file)
@@ -3,12 +3,10 @@ PROJECT(hal-backend-device-haptic C)
 
 SET(PREFIX ${CMAKE_INSTALL_PREFIX})
 
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
+
 INCLUDE(FindPkgConfig)
-pkg_check_modules(haptic_pkgs REQUIRED
-               hal-backend-device-common
-               glib-2.0
-               libsyscommon
-               capi-system-peripheral-io)
+pkg_check_modules(haptic_pkgs REQUIRED hal-rootstrap)
 
 FOREACH(flag ${haptic_pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
@@ -17,7 +15,7 @@ ENDFOREACH(flag)
 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
 
-ADD_LIBRARY(${PROJECT_NAME} MODULE gpio.c)
+ADD_LIBRARY(${PROJECT_NAME} MODULE gpio.c ${CMAKE_SOURCE_DIR}/src/util.c)
 TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${haptic_pkgs_LDFLAGS})
 
 INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${HAL_LIB_DIR} COMPONENT RuntimeLibraries)
index bd9f4ed4b72cde1dcd99ce27cfeae6e97272aeb9..7281172383f621a8f3f69498a1f04060cbc16035 100644 (file)
 #include <stdlib.h>
 #include <glib.h>
 #include <peripheral_io.h>
-#include <libsyscommon/list.h>
 #include <hal/hal-device-haptic-interface.h>
 
-#include </hal/include/device/hal-backend-common.h>
+#include "util.h"
 
 #define GPIO_I2C_BUS_INDEX             1
 #define MAX_HAPIC                              1
@@ -85,7 +84,7 @@ static bool find_from_list(int handle)
 {
        GList *elem;
 
-       elem = SYS_G_LIST_FIND(handle_list, (gpointer)(long)handle);
+       elem = g_list_find(handle_list, (gpointer)(long)handle);
        if (elem)
                return true;
 
@@ -140,7 +139,7 @@ static int gpio_haptic_open_device(int *handle)
                return -EINVAL;
 
        /* if it is the first element */
-       n = SYS_G_LIST_LENGTH(handle_list);
+       n = g_list_length(handle_list);
        if (n == 0) {
                _I("Peripheral Device Open.");
                if (device_handle == NULL) {
@@ -156,13 +155,13 @@ static int gpio_haptic_open_device(int *handle)
 
        while (found != true) {
                ++unique_number;
-               elem = SYS_G_LIST_FIND(handle_list, (gpointer)(long)unique_number);
+               elem = g_list_find(handle_list, (gpointer)(long)unique_number);
                if (!elem)
                        found = true;
        }
 
        /* add info to local list */
-       SYS_G_LIST_APPEND(handle_list, (gpointer)(long)unique_number);
+       handle_list = g_list_append(handle_list, (gpointer)(long)unique_number);
 
        *handle = unique_number;
        return 0;
@@ -190,10 +189,10 @@ static int gpio_haptic_close_device(int handle)
                _I("Already stopped or failed to stop effect: %d", r);
 
        _D("Handle(%d) is closed and timer deleted.", handle);
-       SYS_G_LIST_REMOVE(handle_list, (gpointer)(long)handle);
+       handle_list = g_list_remove(handle_list, (gpointer)(long)handle);
 
        /* if it is the last element */
-       n = SYS_G_LIST_LENGTH(handle_list);
+       n = g_list_length(handle_list);
        if (n == 0) {
                _I("Peripheral Device Close.");
                if (device_handle != NULL) {
index a35248a5828afb5efd9c345ad3a99a4e8b04f34f..77b4f9c6a3a9b8bfa08e965e95533b1e037afb71 100644 (file)
@@ -3,8 +3,10 @@ PROJECT(hal-backend-device-memory C)
 
 SET(PREFIX ${CMAKE_INSTALL_PREFIX})
 
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
+
 INCLUDE(FindPkgConfig)
-pkg_check_modules(hal-backend-device-memory_pkgs REQUIRED dlog)
+pkg_check_modules(hal-backend-device-memory_pkgs REQUIRED hal-rootstrap)
 
 FOREACH(flag ${hal-backend-device-memory_pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
@@ -13,6 +15,6 @@ ENDFOREACH(flag)
 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
 
-ADD_LIBRARY(${PROJECT_NAME} MODULE memory.c)
+ADD_LIBRARY(${PROJECT_NAME} MODULE memory.c ${CMAKE_SOURCE_DIR}/src/util.c)
 TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${hal-backend-device-memory_pkgs_LDFLAGS})
 INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${HAL_LIB_DIR} COMPONENT RuntimeLibraries)
index a09633726089dd35ef3cca054fcc943073d66193..ae65cf80c900b13dbc5b9f2e83167e64f07578aa 100644 (file)
@@ -21,7 +21,7 @@
 #include <hal/hal-device-memory-interface.h>
 #include <hal/hal-common-interface.h>
 
-#include </hal/include/device/hal-backend-common.h>
+#include "util.h"
 
 #define GEM_INFO_PATH     "/sys/kernel/debug/dri/0/gem_info"
 #define BYTES_PER_KBYTE   1024
index 197833c7642af091298ca5b19a502be99ccd17ff..ee95e00284027264697e681da89f2930656217aa 100644 (file)
@@ -3,8 +3,10 @@ PROJECT(hal-backend-device-thermal C)
 
 SET(PREFIX ${CMAKE_INSTALL_PREFIX})
 
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
+
 INCLUDE(FindPkgConfig)
-pkg_check_modules(hal-backend-device-thermal_pkgs REQUIRED hal-backend-device-common glib-2.0)
+pkg_check_modules(hal-backend-device-thermal_pkgs REQUIRED hal-rootstrap)
 
 FOREACH(flag ${hal-backend-device-thermal_pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
@@ -13,6 +15,6 @@ ENDFOREACH(flag)
 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
 
-ADD_LIBRARY(${PROJECT_NAME} MODULE thermal.c)
+ADD_LIBRARY(${PROJECT_NAME} MODULE thermal.c ${CMAKE_SOURCE_DIR}/src/util.c)
 TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${hal-backend-device-thermal_pkgs_LDFLAGS})
 INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${HAL_LIB_DIR} COMPONENT RuntimeLibraries)
index 14c9c1dcb77d41873826c18484e1c6b919887876..9c2fc21cfc20d5aaedf7d80590ce901ca9b07963 100644 (file)
@@ -26,7 +26,7 @@
 #include <hal/hal-device-thermal-interface.h>
 #include <hal/hal-common-interface.h>
 
-#include </hal/include/device/hal-backend-common.h>
+#include "util.h"
 
 #define AP_PATH                "/sys/class/thermal/thermal_zone0/temp"
 
index 207d23ffc80bc1336a38dd8fcd066b76f69e81b5..d9b00fa6d892eb71309e758a520dcd09ba44cbef 100644 (file)
@@ -3,8 +3,10 @@ PROJECT(hal-backend-device-touchscreen C)
 
 SET(PREFIX ${CMAKE_INSTALL_PREFIX})
 
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
+
 INCLUDE(FindPkgConfig)
-pkg_check_modules(hal-backend-device-touchscreen_pkgs REQUIRED hal-backend-device-common libsyscommon)
+pkg_check_modules(hal-backend-device-touchscreen_pkgs REQUIRED hal-rootstrap)
 
 FOREACH(flag ${hal-backend-device-touchscreen_pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
@@ -13,6 +15,6 @@ ENDFOREACH(flag)
 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
 
-ADD_LIBRARY(${PROJECT_NAME} MODULE touchscreen.c)
+ADD_LIBRARY(${PROJECT_NAME} MODULE touchscreen.c ${CMAKE_SOURCE_DIR}/src/util.c)
 TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${hal-backend-device-touchscreen_pkgs_LDFLAGS})
 INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${HAL_LIB_DIR} COMPONENT RuntimeLibraries)
index 6af87547822a7a46ebc231c1e3b33a432d7ef380..b79e86e20083071c10d6e89b985598e0ab54346a 100644 (file)
@@ -26,9 +26,8 @@
 
 #include <hal/hal-device-touchscreen-interface.h>
 #include <hal/hal-common-interface.h>
-#include <libsyscommon/file.h>
 
-#include </hal/include/device/hal-backend-common.h>
+#include "util.h"
 
 #define TOUCHSCREEN_CON_FILE   "/sys/devices/platform/rpi_ft5406/enable"
 
@@ -43,7 +42,7 @@ static int touchscreen_get_state(hal_device_touchscreen_state_e *state)
        if (!state)
                return -EINVAL;
 
-       ret = sys_get_int(TOUCHSCREEN_CON_FILE, &val);
+       ret = sysfs_read_int(TOUCHSCREEN_CON_FILE, &val);
        if (ret < 0) {
                _E("Failed to get touchscreen state (%d)", ret);
                return ret;
@@ -81,7 +80,7 @@ static int touchscreen_set_state(hal_device_touchscreen_state_e state)
                return -EINVAL;
        }
 
-       ret = sys_set_int(TOUCHSCREEN_CON_FILE, val);
+       ret = sysfs_write_int(TOUCHSCREEN_CON_FILE, val);
        if (ret < 0)
                _E("Failed to change touchscreen state (%d)", ret);
 
diff --git a/include/util.h b/include/util.h
new file mode 100644 (file)
index 0000000..11f4fbe
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+
+
+#ifdef FEATURE_DLOG
+       #define LOG_TAG "HAL_BACKEND_DEVICE_VIM3"
+       #include <dlog.h>
+       #define _D(fmt, args...)        dlog_print(DLOG_DEBUG, LOG_TAG, fmt, ##args)
+       #define _I(fmt, args...)        dlog_print(DLOG_INFO, LOG_TAG, fmt, ##args)
+       #define _W(fmt, args...)        dlog_print(DLOG_WARN, LOG_TAG, fmt, ##args)
+       #define _E(fmt, args...)        dlog_print(DLOG_ERROR, LOG_TAG, fmt, ##args)
+#else
+       #define _D(x, ...)
+       #define _I(x, ...)
+       #define _W(x, ...)
+       #define _E(x, ...)
+#endif
+
+#define EXPORT __attribute__ ((visibility("default")))
+
+#define ARRAY_SIZE(name) (sizeof(name)/sizeof(name[0]))
+#define MAX_BUF_SIZE   255
+
+int sysfs_read_int(char *path, int *val);
+int sysfs_read_str(char *path, char *str, int len);
+int sysfs_write_int(char *path, int val);
+int sysfs_write_str(char *path, char *str);
index fa21eb7a2ca0541826bbf705a43eb2edbcc68b2b..413fa6911e0a26c60ba569e04c70b3cb54ef51b2 100644 (file)
@@ -10,12 +10,7 @@ ExclusiveArch:  %{arm} aarch64
 Requires(post): /sbin/ldconfig
 Requires(postun): /sbin/ldconfig
 BuildRequires:  cmake
-BuildRequires:  pkgconfig(glib-2.0)
-BuildRequires:  pkgconfig(capi-system-peripheral-io)
-BuildRequires:  pkgconfig(hal-api-common)
-BuildRequires:  pkgconfig(hal-api-device)
-BuildRequires:  pkgconfig(libsyscommon)
-BuildRequires:  pkgconfig(hal-backend-device-common)
+BuildRequires:  pkgconfig(hal-rootstrap)
 
 %description
 Device HAL backend drivers for Amlogic vim3 targets
diff --git a/src/util.c b/src/util.c
new file mode 100644 (file)
index 0000000..80660b5
--- /dev/null
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2024 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 <errno.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include "util.h"
+
+static int sysfs_read_buf(char *path, char *buf, int len)
+{
+       int r, fd;
+
+       if ((!path) || (!buf) || (len < 0))
+               return -EINVAL;
+
+       fd = open(path, O_RDONLY);
+       if (fd == -1)
+               return -ENOENT;
+
+       r = read(fd, buf, len);
+       close(fd);
+
+       if ((r < 0) || (r > len))
+               return -EIO;
+
+       /* Replace '\n' with space (ascii code is 32) */
+       buf[strcspn(buf, "\n")] = (char)32;
+       buf[r] = '\0';
+
+       return 0;
+}
+
+static int sysfs_write_buf(char *path, char *buf)
+{
+       int w, fd;
+
+       if ((!path) || (!buf))
+               return -EINVAL;
+
+       fd = open(path, O_WRONLY);
+       if (fd == -1)
+               return -ENOENT;
+
+       w = write(fd, buf, strlen(buf));
+       close(fd);
+
+       if (w < 0)
+               return -EIO;
+
+       return 0;
+}
+
+int sysfs_read_int(char *path, int *val)
+{
+       char buf[MAX_BUF_SIZE + 1];
+       int r;
+
+       if ((!path) || (!val))
+               return -EINVAL;
+
+       r = sysfs_read_buf(path, buf, MAX_BUF_SIZE);
+       if (r < 0)
+               return r;
+
+       *val = atoi(buf);
+       return 0;
+}
+
+int sysfs_read_str(char *path, char *str, int len)
+{
+       int r;
+
+       if ((!path) || (!str) || (len <= 0))
+               return -EINVAL;
+
+       r = sysfs_read_buf(path, str, len);
+       if (r < 0)
+               return r;
+
+       return 0;
+}
+
+int sysfs_write_int(char *path, int val)
+{
+       char buf[MAX_BUF_SIZE + 1];
+       int w;
+
+       if (!path)
+               return -EINVAL;
+
+       snprintf(buf, MAX_BUF_SIZE, "%d", val);
+       w = sysfs_write_buf(path, buf);
+       if (w < 0)
+               return w;
+
+       return 0;
+}
+
+int sysfs_write_str(char *path, char *str)
+{
+       int w;
+
+       if ((!path) || (!str))
+               return -EINVAL;
+
+       w = sysfs_write_buf(path, str);
+       if (w < 0)
+               return w;
+
+       return 0;
+}