Use only hal-rootstrap package to build 16/313816/3 accepted/tizen/unified/20240704.075638 accepted/tizen/unified/dev/20240708.001623 accepted/tizen/unified/x/20240705.012359
authorYunhee Seo <yuni.seo@samsung.com>
Tue, 2 Jul 2024 05:25:20 +0000 (14:25 +0900)
committerYunhee Seo <yuni.seo@samsung.com>
Wed, 3 Jul 2024 02:23:33 +0000 (11:23 +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: I828813ef12dc695ddf66885269df5aabf2cd8717
Signed-off-by: Yunhee Seo <yuni.seo@samsung.com>
18 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/led/CMakeLists.txt
hw/led/led.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-rpi.spec
src/util.c [new file with mode: 0644]

index f8bf84e6c492f1cc1d5b803a0f115b824ec8315d..391daa1e1452d6c36d03bbe8103441210209ea52 100644 (file)
@@ -5,10 +5,19 @@ SET(PREFIX ${CMAKE_INSTALL_PREFIX})
 
 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall -Werror")
 
+INCLUDE(FindPkgConfig)
+pkg_check_modules(hal-backend-device-rpi_pkgs REQUIRED hal-rootstrap)
+
+FOREACH(flag ${hal-backend-device-rpi_pkgs_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
 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 52340914c4ebbeb9be78b4490decf3965166df9b..358723c623a398070a0a8f76ac1bb39175987763 100644 (file)
@@ -3,11 +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
-       libsyscommon
-       )
+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}")
@@ -16,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 caa213e336b54121b7ce936061c4e7b504c55813..3e9233a25b4d74035db881e040a20216a6bd1aab 100644 (file)
@@ -26,8 +26,7 @@
 #include <unistd.h>
 #include <ctype.h>
 
-#include </hal/include/device/hal-backend-common.h>
-#include <libsyscommon/file.h>
+#include "util.h"
 
 #define INFORM_MNT_PATH                        "/mnt/inform"
 #define PARTITION_AB_PATH              INFORM_MNT_PATH"/partition-ab.info"
@@ -73,7 +72,7 @@ static int clear_boot_mode(void)
                return -ferror;
        }
 
-       return sys_set_str(REBOOT_PARAM_PATH, BOOT_MODE_NORMAL);
+       return sysfs_write_str(REBOOT_PARAM_PATH, BOOT_MODE_NORMAL);
 }
 
 static int get_boot_mode(char *buffer, const int max_len)
@@ -83,7 +82,7 @@ static int get_boot_mode(char *buffer, const int max_len)
 
        snprintf(scan_format, sizeof(scan_format), "bootmode=%%%ds", max_len - 1);
 
-       ret = syscommon_parse_cmdline_scanf(scan_format, buffer);
+       ret = parse_cmdline_scanf(scan_format, buffer);
 
        if (ret <= 0) {
                return -ENOENT;
@@ -99,7 +98,7 @@ static int get_boot_mode(char *buffer, const int max_len)
 
 static int get_current_partition(char *partition_ab)
 {
-       int ret_parse = syscommon_parse_cmdline_scanf("partition_ab=%c", partition_ab);
+       int ret_parse = parse_cmdline_scanf("partition_ab=%c", partition_ab);
 
        if (ret_parse <= 0) {
                return -ENOENT;
@@ -136,22 +135,22 @@ static int switch_partition(char partition_ab)
                return -EINVAL;
        }
 
-       return sys_write_buf(PARTITION_AB_PATH, next_partition_ab);
+       return sysfs_write_buf(PARTITION_AB_PATH, next_partition_ab);
 }
 
 static int set_partition_ab_cloned(void)
 {
-       return sys_write_buf(PARTITION_AB_CLONED_PATH, "1");
+       return sysfs_write_buf(PARTITION_AB_CLONED_PATH, "1");
 }
 
 static int clear_partition_ab_cloned(void)
 {
-       return sys_write_buf(PARTITION_AB_CLONED_PATH, "0");
+       return sysfs_write_buf(PARTITION_AB_CLONED_PATH, "0");
 }
 
 static int get_partition_ab_cloned(int *cloned)
 {
-       int ret_get_int = sys_get_int(PARTITION_AB_CLONED_PATH, cloned);
+       int ret_get_int = sysfs_read_int(PARTITION_AB_CLONED_PATH, cloned);
 
        if (ret_get_int < 0) {
                return ret_get_int;
@@ -198,7 +197,7 @@ static int set_partition_status(char partition_ab, const char *status)
                return -ferror;
        }
 
-       return sys_set_str(path, (char *)status);
+       return sysfs_write_str(path, (char *)status);
 }
 
 static int get_partition_status(char partition_ab, char *buffer, const int max_len)
@@ -227,7 +226,7 @@ static int get_partition_status(char partition_ab, char *buffer, const int max_l
                return -EINVAL;
        }
 
-       int res_get_str = sys_get_str(path, buffer, max_len);
+       int res_get_str = sysfs_read_str(path, buffer, max_len);
        if (res_get_str < 0) {
                return res_get_str;
        }
@@ -258,12 +257,12 @@ static int set_upgrade_progress_status(int status)
                return -ferror;
        }
 
-       return sys_set_int(UPGRADE_PROGRESS_STATUS_PATH, status);
+       return sysfs_write_int(UPGRADE_PROGRESS_STATUS_PATH, status);
 }
 
 static int get_upgrade_progress_status(int *status)
 {
-       int ret_get_int = sys_get_int(UPGRADE_PROGRESS_STATUS_PATH, status);
+       int ret_get_int = sysfs_read_int(UPGRADE_PROGRESS_STATUS_PATH, status);
 
        if (ret_get_int < 0) {
                return ret_get_int;
@@ -289,7 +288,7 @@ static int set_upgrade_state(char *state)
                return -ferror;
        }
 
-       return sys_set_str(UPGRADE_STATE_PATH, state);
+       return sysfs_write_str(UPGRADE_STATE_PATH, state);
 }
 
 static void trim_str(char *str)
@@ -330,7 +329,7 @@ static int get_upgrade_state(char *buffer, const int max_len)
        if (max_len < 1)
                return -EINVAL;
 
-       ret = sys_get_str(UPGRADE_STATE_PATH, buffer, max_len - 1);
+       ret = sysfs_read_str(UPGRADE_STATE_PATH, buffer, max_len - 1);
        if (ret < 0)
                return ret;
 
index 5fa6a8e39380ea360a6bd36f6be264a1d93e3d61..ef0b4c7d1e42909a4efe2a1488a212fd884dc1dd 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}")
@@ -14,13 +16,13 @@ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
 
 SET(HAL_BACKEND_DEVICE_DISPLAY_RPI3 ${PROJECT_NAME}.rpi3)
-ADD_LIBRARY(${HAL_BACKEND_DEVICE_DISPLAY_RPI3} MODULE display.c)
+ADD_LIBRARY(${HAL_BACKEND_DEVICE_DISPLAY_RPI3} MODULE display.c ${CMAKE_SOURCE_DIR}/src/util.c)
 TARGET_COMPILE_DEFINITIONS(${HAL_BACKEND_DEVICE_DISPLAY_RPI3} PUBLIC RPI3)
 TARGET_LINK_LIBRARIES(${HAL_BACKEND_DEVICE_DISPLAY_RPI3} ${hal-backend-device-display_pkgs_LDFLAGS})
 INSTALL(TARGETS ${HAL_BACKEND_DEVICE_DISPLAY_RPI3} DESTINATION ${HAL_LIB_DIR} COMPONENT RuntimeLibraries)
 
 SET(HAL_BACKEND_DEVICE_DISPLAY_RPI4 ${PROJECT_NAME}.rpi4)
-ADD_LIBRARY(${HAL_BACKEND_DEVICE_DISPLAY_RPI4} MODULE display.c)
+ADD_LIBRARY(${HAL_BACKEND_DEVICE_DISPLAY_RPI4} MODULE display.c ${CMAKE_SOURCE_DIR}/src/util.c)
 TARGET_COMPILE_DEFINITIONS(${HAL_BACKEND_DEVICE_DISPLAY_RPI4} PUBLIC RPI4)
 TARGET_LINK_LIBRARIES(${HAL_BACKEND_DEVICE_DISPLAY_RPI4} ${hal-backend-device-display_pkgs_LDFLAGS})
 INSTALL(TARGETS ${HAL_BACKEND_DEVICE_DISPLAY_RPI4} DESTINATION ${HAL_LIB_DIR} COMPONENT RuntimeLibraries)
index 059f4335106c4dc87e0e809d204715c339015351..e4c9fe00deb612cb7287187e674c307d41c2d692 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"
 
 #if defined(RPI3)
 #define BACKLIGHT_PATH  "/sys/class/backlight/rpi_backlight"
@@ -46,7 +45,7 @@ static int display_get_max_brightness(int *val)
                return -EINVAL;
 
        if (max < 0) {
-               r = sys_get_int(BACKLIGHT_PATH"/max_brightness", &max);
+               r = sysfs_read_int(BACKLIGHT_PATH"/max_brightness", &max);
                if (r < 0)
                        return -ENOTSUP;
        }
@@ -64,7 +63,7 @@ static int display_get_brightness(int *brightness)
                return -EINVAL;
        }
 
-       r = sys_get_int(BACKLIGHT_PATH"/brightness", &v);
+       r = sysfs_read_int(BACKLIGHT_PATH"/brightness", &v);
        if (r < 0) {
                _E("fail to get brightness (errno:%d)", r);
                return -ENOTSUP;
@@ -89,7 +88,7 @@ static int display_set_brightness(int brightness)
                return -EINVAL;
        }
 
-       r = sys_set_int(BACKLIGHT_PATH"/brightness", brightness);
+       r = sysfs_write_int(BACKLIGHT_PATH"/brightness", brightness);
        if (r < 0) {
                _E("fail to set brightness (errno:%d)", r);
                return r;
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 ecd82a5c6982f0774f76f3eb4f6567b7f7ca9190..81f9bdb501fd98428a2c94668e19b6abbac02092 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 c0e158337d4adfde547c1cc26e442ce16cc4f316..5571f029e17c5e9c577fc6cf9633bc6a454ec717 100644 (file)
@@ -3,8 +3,10 @@ PROJECT(hal-backend-device-led  C)
 
 SET(PREFIX ${CMAKE_INSTALL_PREFIX})
 
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
+
 INCLUDE(FindPkgConfig)
-pkg_check_modules(hal-backend-device-led_pkgs REQUIRED hal-backend-device-common glib-2.0 capi-system-peripheral-io)
+pkg_check_modules(hal-backend-device-led_pkgs REQUIRED hal-rootstrap)
 
 FOREACH(flag ${hal-backend-device-led_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 led.c)
+ADD_LIBRARY(${PROJECT_NAME} MODULE led.c ${CMAKE_SOURCE_DIR}/src/util.c)
 TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${hal-backend-device-led_pkgs_LDFLAGS})
 INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${HAL_LIB_DIR} COMPONENT RuntimeLibraries)
index 92bb67bb6f97e526749a4f87976c1a7fcb62032b..e07ab7d1d42c3af7d853d85108d98fe357dff9b1 100644 (file)
 #include <hal/hal-device-led-interface.h>
 #include <hal/hal-common-interface.h>
 
-#include </hal/include/device/hal-backend-common.h>
-
 #include <peripheral_io.h>
 
+#include "util.h"
+
 #define GET_BRIGHTNESS(val)     (((val) >> 24) & 0xFF)
 
 #define GET_TYPE(a)       (((a) >> 24) & 0xFF)
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 3347d23f3df34c78d47fcf36396bb998a31f188a..28f99c25bbb6bc8b0c13a074d9f302aa3b240cef 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 GEM_INFO_PATH1    "/sys/kernel/debug/dri/1/gem_info"
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 fb59d28524faa6cd52fe6fd92241d454dfee510d..91c36c0a490643638f8f30b6e003852bc7f580e5 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 cf732934a6b2f930c33ba46167782ca6d2f5bf9e..32bd1eafb4a4bd8caa361e6f494d1fbd0e822a1b 100644 (file)
@@ -27,9 +27,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"
 
@@ -48,7 +47,7 @@ static int touchscreen_get_state(hal_device_touchscreen_state_e *state)
        if (access(TOUCHSCREEN_CON_FILE, F_OK) != 0)
                return -ENODEV;
 
-       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;
@@ -90,7 +89,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..abec175
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * 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_RPI"
+       #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_buf(char *path, char *buf);
+int sysfs_write_int(char *path, int val);
+int sysfs_write_str(char *path, char *str);
+
+/**
+ * @brief Parse format from /proc/cmdline
+ *
+ * @param[in] format Format string
+ * @param[out] ... Variable argument
+ *
+ * @return zero if cannot read else the number of matched and assigned items
+ */
+int parse_cmdline_scanf(const char *format, ...);
index 67bb5c3f7f6df5257fef80ded1f66967576cf66e..1e108d9108d7820d2c413bb7c4ac0cfb75d0f916 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 Raspberry Pi targets
diff --git a/src/util.c b/src/util.c
new file mode 100644 (file)
index 0000000..e2abf4b
--- /dev/null
@@ -0,0 +1,159 @@
+/*
+ * 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;
+}
+
+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;
+}
+
+int parse_cmdline_scanf(const char *format, ...)
+{
+       FILE *fp = NULL;
+       char *token = NULL;
+       size_t len = 0;
+       va_list ap;
+       int ret = 0;
+       char buffer[MAX_BUF_SIZE + 1];
+
+       fp = fopen("/proc/cmdline", "r");
+       if (!fp)
+               return 0;
+
+       va_start(ap, format);
+
+       while (getdelim(&token, &len, ' ', fp) != EOF) {
+               if (len > MAX_BUF_SIZE)
+                       len = MAX_BUF_SIZE;
+               strncpy(buffer, token, len);
+               buffer[MAX_BUF_SIZE] = '\0';
+               ret = vsscanf(buffer, format, ap);
+               memset(buffer, 0, sizeof(buffer));
+               if (ret > 0)
+                       break;
+       }
+
+       free(token);
+       va_end(ap);
+       fclose(fp);
+
+       return ret;
+}
\ No newline at end of file