Apply next HAL architecture (hal api + backend)
authorlokilee73 <changjoo.lee@samsung.com>
Thu, 14 Jan 2021 04:13:52 +0000 (13:13 +0900)
committerlokilee73 <changjoo.lee@samsung.com>
Thu, 14 Jan 2021 04:17:25 +0000 (13:17 +0900)
Change-Id: I1ba0af9db43ec8e7e40e6c7f82a8ad9f1d0a63d4
Signed-off-by: lokilee73 <changjoo.lee@samsung.com>
15 files changed:
CMakeLists.txt
hw/battery/CMakeLists.txt
hw/battery/battery.c
hw/bezel/CMakeLists.txt
hw/bezel/bezel.c
hw/display/CMakeLists.txt
hw/display/display.c
hw/external_connection/CMakeLists.txt
hw/external_connection/external_connection.c
hw/thermal/CMakeLists.txt
hw/thermal/thermal.c
hw/touchscreen/CMakeLists.txt
hw/touchscreen/touchscreen.c
hw/touchsensitivity/CMakeLists.txt [deleted file]
hw/touchsensitivity/touchsensitivity.c [deleted file]

index 056de09..06d9e1e 100644 (file)
@@ -14,5 +14,4 @@ ADD_SUBDIRECTORY(hw/usb_client)
 ADD_SUBDIRECTORY(hw/usb_cfs_client)
 ADD_SUBDIRECTORY(hw/thermal)
 ADD_SUBDIRECTORY(hw/bezel)
-ADD_SUBDIRECTORY(hw/touchsensitivity)
 ADD_SUBDIRECTORY(hw/haptic)
index 820c168..614bae4 100644 (file)
@@ -1,12 +1,14 @@
 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(battery C)
+PROJECT(hal-backend-device-battery C)
 
 SET(PREFIX ${CMAKE_INSTALL_PREFIX})
 
+INCLUDE_DIRECTORIES(../common)
+
 INCLUDE(FindPkgConfig)
-pkg_check_modules(battery_pkgs REQUIRED hwcommon dlog glib-2.0 libudev)
+pkg_check_modules(hal-backend-device-battery_pkgs REQUIRED dlog glib-2.0 libudev)
 
-FOREACH(flag ${battery_pkgs_CFLAGS})
+FOREACH(flag ${hal-backend-device-battery_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 battery.c ../udev.c)
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${battery_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-battery_pkgs_LDFLAGS})
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /hal/lib COMPONENT RuntimeLibraries)
index 45ffe8f..f52d0b5 100644 (file)
 #include <linux/limits.h>
 #include <dirent.h>
 
-#include <hw/battery.h>
-#include <hw/shared.h>
+#include <hal/device/hal-battery-interface.h>
+#include <hal/hal-common-interface.h>
+
+#include "common.h"
 #include "../udev.h"
 
 #define BATTERY_ROOT_PATH "/sys/class/power_supply"
@@ -303,45 +305,36 @@ static int battery_get_current_state(
        return 0;
 }
 
-static int battery_open(struct hw_info *info,
-               const char *id, struct hw_common **common)
+static int battery_init(void **data)
 {
-       struct battery_device *battery_dev;
-
-       if (!info || !common)
-               return -EINVAL;
+       hal_backend_battery_funcs *battery_funcs;
 
-       battery_dev = calloc(1, sizeof(struct battery_device));
-       if (!battery_dev)
+       battery_funcs = calloc(1, sizeof(hal_backend_battery_funcs));
+       if (!battery_funcs)
                return -ENOMEM;
 
-       battery_dev->common.info = info;
-       battery_dev->register_changed_event
-               = battery_register_changed_event;
-       battery_dev->unregister_changed_event
-               = battery_unregister_changed_event;
-       battery_dev->get_current_state
-               = battery_get_current_state;
+       battery_funcs->register_changed_event = battery_register_changed_event;
+       battery_funcs->unregister_changed_event = battery_unregister_changed_event;
+       battery_funcs->get_current_state = battery_get_current_state;
+
+       *data = (void *)battery_funcs;
 
-       *common = (struct hw_common *)battery_dev;
        return 0;
 }
 
-static int battery_close(struct hw_common *common)
+static int battery_exit(void *data)
 {
-       if (!common)
-               return -EINVAL;
+       if (!data)
+               return 0;
 
-       free(common);
+       free(data);
        return 0;
 }
 
-HARDWARE_MODULE_STRUCTURE = {
-       .magic = HARDWARE_INFO_TAG,
-       .hal_version = HARDWARE_INFO_VERSION,
-       .device_version = BATTERY_HARDWARE_DEVICE_VERSION,
-       .id = BATTERY_HARDWARE_DEVICE_ID,
+hal_backend EXPORT hal_backend_device_battery_data = {
        .name = "battery",
-       .open = battery_open,
-       .close = battery_close,
+       .vendor = "R800",
+       .abi_version = HAL_ABI_VERSION_TIZEN_6_5,
+       .init = battery_init,
+       .exit = battery_exit,
 };
index 36a47e7..ca3ec6a 100644 (file)
@@ -1,12 +1,14 @@
 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(bezel C)
+PROJECT(hal-backend-device-bezel C)
 
 SET(PREFIX ${CMAKE_INSTALL_PREFIX})
 
+INCLUDE_DIRECTORIES(../common)
+
 INCLUDE(FindPkgConfig)
-pkg_check_modules(bezel_pkgs REQUIRED hwcommon dlog)
+pkg_check_modules(hal-backend-device-bezel_pkgs REQUIRED dlog)
 
-FOREACH(flag ${bezel_pkgs_CFLAGS})
+FOREACH(flag ${hal-backend-device-bezel_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 bezel.c)
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${bezel_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-bezel_pkgs_LDFLAGS})
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /hal/lib COMPONENT RuntimeLibraries)
index 289d443..e77460c 100644 (file)
 #include <linux/limits.h>
 #include <dirent.h>
 
-#include <hw/bezel.h>
-#include <hw/shared.h>
+#include <hal/device/hal-bezel-interface.h>
+#include <hal/hal-common-interface.h>
+
+#include "common.h"
 
 #define INPUT_PATH      "/sys/class/input/"
 #define KEY_CAPABILITIES_PATH  "/device/capabilities/key"
@@ -133,49 +135,38 @@ static int bezel_set_state(enum bezel_state state)
        return ret;
 }
 
-static int bezel_open(struct hw_info *info,
-               const char *id, struct hw_common **common)
+static int bezel_init(void **data)
 {
-       struct bezel_device *bezel_dev;
-
-       if (!info || !common)
-               return -EINVAL;
+       hal_backend_bezel_funcs *bezel_funcs;
 
        if (bezel_probe() < 0)
                return -ENOTSUP;
 
-       bezel_dev = calloc(1, sizeof(struct bezel_device));
-       if (!bezel_dev)
+       bezel_funcs = calloc(1, sizeof(hal_backend_bezel_funcs));
+       if (!bezel_funcs)
                return -ENOMEM;
 
-       bezel_dev->common.info = info;
-       bezel_dev->get_state = bezel_get_state;
-       bezel_dev->set_state = bezel_set_state;
+       bezel_funcs->get_state = bezel_get_state;
+       bezel_funcs->set_state = bezel_set_state;
+
+       *data = (void *)bezel_funcs;
 
-       *common = (struct hw_common *)bezel_dev;
        return 0;
 }
 
-static int bezel_close(struct hw_common *common)
+static int bezel_exit(void *data)
 {
-       if (!common)
-               return -EINVAL;
-
-       free(common);
-       if (bezel_node) {
-               free(bezel_node);
-               bezel_node = NULL;
-       }
+       if (!data)
+               return 0;
 
+       free(data);
        return 0;
 }
 
-HARDWARE_MODULE_STRUCTURE = {
-       .magic = HARDWARE_INFO_TAG,
-       .hal_version = HARDWARE_INFO_VERSION,
-       .device_version = BEZEL_HARDWARE_DEVICE_VERSION,
-       .id = BEZEL_HARDWARE_DEVICE_ID,
+hal_backend EXPORT hal_backend_device_bezel_data = {
        .name = "bezel",
-       .open = bezel_open,
-       .close = bezel_close,
+       .vendor = "R800",
+       .abi_version = HAL_ABI_VERSION_TIZEN_6_5,
+       .init = bezel_init,
+       .exit = bezel_exit,
 };
index 46589ee..bd9aa92 100644 (file)
@@ -1,12 +1,14 @@
 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(display C)
+PROJECT(hal-backend-device-display C)
 
 SET(PREFIX ${CMAKE_INSTALL_PREFIX})
 
+INCLUDE_DIRECTORIES(../common)
+
 INCLUDE(FindPkgConfig)
-pkg_check_modules(display_pkgs REQUIRED hwcommon dlog capi-system-info)
+pkg_check_modules(hal-backend-device-display_pkgs REQUIRED dlog capi-system-info)
 
-FOREACH(flag ${display_pkgs_CFLAGS})
+FOREACH(flag ${hal-backend-device-display_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 display.c)
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${display_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-display_pkgs_LDFLAGS})
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /hal/lib COMPONENT RuntimeLibraries)
index 2992a0b..1608ddf 100644 (file)
 #include <errno.h>
 #include <linux/limits.h>
 #include <system_info.h>
-#include <hw/display.h>
-#include <hw/shared.h>
+
+#include <hal/device/hal-display-interface.h>
+#include <hal/hal-common-interface.h>
+
+#include "common.h"
 
 #define MODEL_NAME      "http://tizen.org/system/model_name"
 
@@ -187,45 +190,39 @@ static int display_set_image_effect(enum display_image_effect effect)
        return 0;
 }
 
-static int display_open(struct hw_info *info,
-               const char *id, struct hw_common **common)
+static int display_init(void **data)
 {
-       struct display_device *display_dev;
-
-       if (!info || !common)
-               return -EINVAL;
+       hal_backend_display_funcs *display_funcs;
 
-       display_dev = calloc(1, sizeof(struct display_device));
-       if (!display_dev)
+       display_funcs = calloc(1, sizeof(hal_backend_display_funcs));
+       if (!display_funcs)
                return -ENOMEM;
 
-       display_dev->common.info = info;
-       display_dev->get_max_brightness = display_get_max_brightness;
-       display_dev->get_brightness = display_get_brightness;
-       display_dev->set_brightness = display_set_brightness;
-       display_dev->get_state = display_get_state;
-       display_dev->get_image_effect = display_get_image_effect;
-       display_dev->set_image_effect = display_set_image_effect;
+       display_funcs->get_max_brightness = display_get_max_brightness;
+       display_funcs->get_brightness = display_get_brightness;
+       display_funcs->set_brightness = display_set_brightness;
+       display_funcs->get_state = display_get_state;
+       display_funcs->get_image_effect = display_get_image_effect;
+       display_funcs->set_image_effect = display_set_image_effect;
+
+       *data = (void *)display_funcs;
 
-       *common = (struct hw_common *)display_dev;
        return 0;
 }
 
-static int display_close(struct hw_common *common)
+static int display_exit(void *data)
 {
-       if (!common)
-               return -EINVAL;
+       if (!data)
+               return 0;
 
-       free(common);
+       free(data);
        return 0;
 }
 
-HARDWARE_MODULE_STRUCTURE = {
-       .magic = HARDWARE_INFO_TAG,
-       .hal_version = HARDWARE_INFO_VERSION,
-       .device_version = DISPLAY_HARDWARE_DEVICE_VERSION,
-       .id = DISPLAY_HARDWARE_DEVICE_ID,
-       .name = "Display",
-       .open = display_open,
-       .close = display_close,
+hal_backend EXPORT hal_backend_device_display_data = {
+       .name = "display",
+       .vendor = "R800",
+       .abi_version = HAL_ABI_VERSION_TIZEN_6_5,
+       .init = display_init,
+       .exit = display_exit,
 };
index b1f2f83..1164421 100644 (file)
@@ -1,12 +1,14 @@
 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(external_connection C)
+PROJECT(hal-backend-device-external-connection C)
 
 SET(PREFIX ${CMAKE_INSTALL_PREFIX})
 
+INCLUDE_DIRECTORIES(../common)
+
 INCLUDE(FindPkgConfig)
-pkg_check_modules(external_connection_pkgs REQUIRED hwcommon dlog glib-2.0 libudev)
+pkg_check_modules(hal-backend-device-external-connection_pkgs REQUIRED dlog glib-2.0 libudev)
 
-FOREACH(flag ${external_connection_pkgs_CFLAGS})
+FOREACH(flag ${hal-backend-device-external-connection_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 external_connection.c ../udev.c)
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${external_connection_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-external-connection_pkgs_LDFLAGS})
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /hal/lib COMPONENT RuntimeLibraries)
index 2536b42..c22d1aa 100644 (file)
 #include <linux/limits.h>
 #include <dirent.h>
 
-#include <hw/external_connection.h>
-#include <hw/shared.h>
+#include <hal/device/hal-external_connection-interface.h>
+#include <hal/hal-common-interface.h>
+
+#include "common.h"
 #include "../udev.h"
 
 #define SWITCH_ROOT_PATH "/sys/devices/virtual/switch"
@@ -172,45 +174,36 @@ static int external_connection_get_current_state(
        return 0;
 }
 
-static int external_connection_open(struct hw_info *info,
-               const char *id, struct hw_common **common)
+static int external_connection_init(void **data)
 {
-       struct external_connection_device *external_connection_dev;
-
-       if (!info || !common)
-               return -EINVAL;
+       hal_backend_external_connection_funcs *external_connection_funcs;
 
-       external_connection_dev = calloc(1, sizeof(struct external_connection_device));
-       if (!external_connection_dev)
+       external_connection_funcs = calloc(1, sizeof(hal_backend_external_connection_funcs));
+       if (!external_connection_funcs)
                return -ENOMEM;
 
-       external_connection_dev->common.info = info;
-       external_connection_dev->register_changed_event
-               = external_connection_register_changed_event;
-       external_connection_dev->unregister_changed_event
-               = external_connection_unregister_changed_event;
-       external_connection_dev->get_current_state
-               = external_connection_get_current_state;
+       external_connection_funcs->register_changed_event = external_connection_register_changed_event;
+       external_connection_funcs->unregister_changed_event = external_connection_unregister_changed_event;
+       external_connection_funcs->get_current_state = external_connection_get_current_state;
+
+       *data = (void *)external_connection_funcs;
 
-       *common = (struct hw_common *)external_connection_dev;
        return 0;
 }
 
-static int external_connection_close(struct hw_common *common)
+static int external_connection_exit(void *data)
 {
-       if (!common)
-               return -EINVAL;
+       if (!data)
+               return 0;
 
-       free(common);
+       free(data);
        return 0;
 }
 
-HARDWARE_MODULE_STRUCTURE = {
-       .magic = HARDWARE_INFO_TAG,
-       .hal_version = HARDWARE_INFO_VERSION,
-       .device_version = EXTERNAL_CONNECTION_HARDWARE_DEVICE_VERSION,
-       .id = EXTERNAL_CONNECTION_HARDWARE_DEVICE_ID,
-       .name = "external_connection",
-       .open = external_connection_open,
-       .close = external_connection_close,
+hal_backend EXPORT hal_backend_device_external_connection_data = {
+       .name = "external-connection",
+       .vendor = "R800",
+       .abi_version = HAL_ABI_VERSION_TIZEN_6_5,
+       .init = external_connection_init,
+       .exit = external_connection_exit,
 };
index 42bcc20..82f0dd2 100644 (file)
@@ -1,12 +1,14 @@
 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(thermal C)
+PROJECT(hal-backend-device-thermal C)
 
 SET(PREFIX ${CMAKE_INSTALL_PREFIX})
 
+INCLUDE_DIRECTORIES(../common)
+
 INCLUDE(FindPkgConfig)
-pkg_check_modules(thermal_pkgs REQUIRED hwcommon dlog glib-2.0 libudev)
+pkg_check_modules(hal-backend-device-thermal_pkgs REQUIRED dlog glib-2.0 libudev)
 
-FOREACH(flag ${thermal_pkgs_CFLAGS})
+FOREACH(flag ${hal-backend-device-thermal_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 thermal.c ../udev.c)
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${thermal_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-thermal_pkgs_LDFLAGS})
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /hal/lib COMPONENT RuntimeLibraries)
index ccd2c94..279ce1e 100644 (file)
 #include <errno.h>
 #include <glib.h>
 
-#include <hw/thermal.h>
-#include <hw/shared.h>
+#include <hal/device/hal-thermal-interface.h>
+#include <hal/hal-common-interface.h>
+
+#include "common.h"
 
 #define AP_PATH                "/sys/class/sec/temperature/ap_therm"
 #define BATTERY_PATH   "/sys/class/sec/temperature/batt_therm"
@@ -130,45 +132,36 @@ static int thermal_unregister_changed_event(ThermalUpdated updated_cb)
        return 0;
 }
 
-static int thermal_open(struct hw_info *info,
-               const char *id, struct hw_common **common)
+static int thermal_init(void **data)
 {
-       struct thermal_device *thermal_dev;
-
-       if (!info || !common)
-               return -EINVAL;
+       hal_backend_thermal_funcs *thermal_funcs;
 
-       thermal_dev = calloc(1, sizeof(struct thermal_device));
-       if (!thermal_dev)
+       thermal_funcs = calloc(1, sizeof(hal_backend_thermal_funcs));
+       if (!thermal_funcs)
                return -ENOMEM;
 
-       thermal_dev->common.info = info;
-       thermal_dev->register_changed_event
-               = thermal_register_changed_event;
-       thermal_dev->unregister_changed_event
-               = thermal_unregister_changed_event;
-       thermal_dev->get_info
-               = thermal_get_info;
+       thermal_funcs->get_info = thermal_get_info;
+       thermal_funcs->register_changed_event = thermal_register_changed_event;
+       thermal_funcs->unregister_changed_event = thermal_unregister_changed_event;
+
+       *data = (void *)thermal_funcs;
 
-       *common = (struct hw_common *)thermal_dev;
        return 0;
 }
 
-static int thermal_close(struct hw_common *common)
+static int thermal_exit(void *data)
 {
-       if (!common)
-               return -EINVAL;
+       if (!data)
+               return 0;
 
-       free(common);
+       free(data);
        return 0;
 }
 
-HARDWARE_MODULE_STRUCTURE = {
-       .magic = HARDWARE_INFO_TAG,
-       .hal_version = HARDWARE_INFO_VERSION,
-       .device_version = THERMAL_HARDWARE_DEVICE_VERSION,
-       .id = THERMAL_HARDWARE_DEVICE_ID,
+hal_backend EXPORT hal_backend_device_thermal_data = {
        .name = "thermal",
-       .open = thermal_open,
-       .close = thermal_close,
+       .vendor = "R800",
+       .abi_version = HAL_ABI_VERSION_TIZEN_6_5,
+       .init = thermal_init,
+       .exit = thermal_exit,
 };
index f364805..c9de46a 100644 (file)
@@ -1,12 +1,14 @@
 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(touchscreen C)
+PROJECT(hal-backend-device-touchscreen C)
 
 SET(PREFIX ${CMAKE_INSTALL_PREFIX})
 
+INCLUDE_DIRECTORIES(../common)
+
 INCLUDE(FindPkgConfig)
-pkg_check_modules(touchscreen_pkgs REQUIRED hwcommon dlog)
+pkg_check_modules(hal-backend-device-touchscreen_pkgs REQUIRED dlog)
 
-FOREACH(flag ${touchscreen_pkgs_CFLAGS})
+FOREACH(flag ${hal-backend-device-touchscreen_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 touchscreen.c)
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${touchscreen_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-touchscreen_pkgs_LDFLAGS})
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /hal/lib COMPONENT RuntimeLibraries)
index 3623557..c1474ee 100644 (file)
 #include <linux/limits.h>
 #include <dirent.h>
 
-#include <hw/touchscreen.h>
-#include <hw/shared.h>
+#include <hal/device/hal-touchscreen-interface.h>
+#include <hal/hal-common-interface.h>
+
+#include "common.h"
 
 #define INPUT_PATH      "/sys/class/input/"
 #define KEY_CAPABILITIES_PATH  "/device/capabilities/key"
@@ -33,6 +35,7 @@
 #define TOUCHSCREEN_CAPABILITY 400
 
 #define TOUCH_POWERSAVING_NODE "/sys/class/sec/tsp/mode"
+#define TOUCHSENSITIVITY_GLOVE_MODE_PATH       "/sys/class/sec/tsp/glove_mode"
 
 #define TURNON_TOUCHSCREEN     1
 #define TURNOFF_TOUCHSCREEN    0
@@ -163,47 +166,89 @@ static int touchscreen_set_powersaving(int state)
        return ret;
 }
 
-static int touchscreen_open(struct hw_info *info,
-               const char *id, struct hw_common **common)
+static int glove_mode_get_state(int *state)
+{
+       int ret, val;
+
+       if (!state)
+               return -EINVAL;
+
+       ret = sys_get_int(TOUCHSENSITIVITY_GLOVE_MODE_PATH, &val);
+       if (ret < 0) {
+               _E("Failed to get touch glove mode state (%d)", ret);
+               return ret;
+       }
+
+       switch (val) {
+       case TOUCHSENSITIVITY_GLOVE_MODE_OFF:
+       case TOUCHSENSITIVITY_GLOVE_MODE_ON:
+               *state = val;
+               break;
+       default:
+               _E("Failed to get touch glove mode state (%d)", val);
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
+static int glove_mode_set_state(int state)
 {
-       struct touchscreen_device *touchscreen_dev;
+       int ret, val;
 
-       if (!info || !common)
+       switch (state) {
+       case TOUCHSENSITIVITY_GLOVE_MODE_OFF:
+       case TOUCHSENSITIVITY_GLOVE_MODE_ON:
+               val = state;
+               break;
+       default:
+               _E("Invalid input (%d)", state);
                return -EINVAL;
+       }
+
+       ret = sys_set_int(TOUCHSENSITIVITY_GLOVE_MODE_PATH, val);
+       if (ret < 0)
+               _E("Failed to change touch glove mode state (%d)", ret);
+
+       return ret;
+}
+
+static int touchscreen_init(void **data)
+{
+       hal_backend_touchscreen_funcs *touchscreen_funcs;
 
        if (touchscreen_probe() < 0)
                return -ENOTSUP;
 
-       touchscreen_dev = calloc(1, sizeof(struct touchscreen_device));
-       if (!touchscreen_dev)
+       touchscreen_funcs = calloc(1, sizeof(hal_backend_touchscreen_funcs));
+       if (!touchscreen_funcs)
                return -ENOMEM;
 
-       touchscreen_dev->common.info = info;
-       touchscreen_dev->get_state = touchscreen_get_state;
-       touchscreen_dev->set_state = touchscreen_set_state;
-       touchscreen_dev->get_powersaving = touchscreen_get_powersaving;
-       touchscreen_dev->set_powersaving = touchscreen_set_powersaving;
+       touchscreen_funcs->get_state = touchscreen_get_state;
+       touchscreen_funcs->set_state = touchscreen_set_state;
+       touchscreen_funcs->get_powersaving = touchscreen_get_powersaving;
+       touchscreen_funcs->set_powersaving = touchscreen_set_powersaving;
+       touchscreen_funcs->glove_mode_get_state = glove_mode_get_state;
+       touchscreen_funcs->glove_mode_set_state = glove_mode_set_state;
+
+       *data = (void *)touchscreen_funcs;
 
-       *common = (struct hw_common *)touchscreen_dev;
        return 0;
 }
 
-static int touchscreen_close(struct hw_common *common)
+static int touchscreen_exit(void *data)
 {
-       if (!common)
-               return -EINVAL;
+       if (!data)
+               return 0;
 
-       free(common);
-       free(touchscreen_node);
+       free(data);
        return 0;
 }
 
-HARDWARE_MODULE_STRUCTURE = {
-       .magic = HARDWARE_INFO_TAG,
-       .hal_version = HARDWARE_INFO_VERSION,
-       .device_version = TOUCHSCREEN_HARDWARE_DEVICE_VERSION,
-       .id = TOUCHSCREEN_HARDWARE_DEVICE_ID,
+hal_backend EXPORT hal_backend_device_touchscreen_data = {
        .name = "touchscreen",
-       .open = touchscreen_open,
-       .close = touchscreen_close,
+       .vendor = "R800",
+       .abi_version = HAL_ABI_VERSION_TIZEN_6_5,
+       .init = touchscreen_init,
+       .exit = touchscreen_exit,
 };
diff --git a/hw/touchsensitivity/CMakeLists.txt b/hw/touchsensitivity/CMakeLists.txt
deleted file mode 100644 (file)
index 7be54da..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(touchsensitivity C)
-
-SET(PREFIX ${CMAKE_INSTALL_PREFIX})
-
-INCLUDE(FindPkgConfig)
-pkg_check_modules(touchsensitivity_pkgs REQUIRED hwcommon dlog)
-
-FOREACH(flag ${touchsensitivity_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 touchsensitivity.c)
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${touchsensitivity_pkgs_LDFLAGS})
-SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES PREFIX "")
-INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR}/hw COMPONENT RuntimeLibraries)
diff --git a/hw/touchsensitivity/touchsensitivity.c b/hw/touchsensitivity/touchsensitivity.c
deleted file mode 100644 (file)
index 343de41..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * device-node
- *
- * Copyright (c) 2019 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 <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <linux/limits.h>
-#include <dirent.h>
-
-#include <hw/touchsensitivity.h>
-#include <hw/shared.h>
-
-#define TOUCHSENSITIVITY_GLOVE_MODE_PATH       "/sys/class/sec/tsp/glove_mode"
-
-static int glove_mode_get_state(int *state)
-{
-       int ret, val;
-
-       if (!state)
-               return -EINVAL;
-
-       ret = sys_get_int(TOUCHSENSITIVITY_GLOVE_MODE_PATH, &val);
-       if (ret < 0) {
-               _E("Failed to get touch glove mode state (%d)", ret);
-               return ret;
-       }
-
-       switch (val) {
-       case TOUCHSENSITIVITY_GLOVE_MODE_OFF:
-       case TOUCHSENSITIVITY_GLOVE_MODE_ON:
-               *state = val;
-               break;
-       default:
-               _E("Failed to get touch glove mode state (%d)", val);
-               return -EINVAL;
-       }
-
-       return 0;
-}
-
-static int glove_mode_set_state(int state)
-{
-       int ret, val;
-
-       switch (state) {
-       case TOUCHSENSITIVITY_GLOVE_MODE_OFF:
-       case TOUCHSENSITIVITY_GLOVE_MODE_ON:
-               val = state;
-               break;
-       default:
-               _E("Invalid input (%d)", state);
-               return -EINVAL;
-       }
-
-       ret = sys_set_int(TOUCHSENSITIVITY_GLOVE_MODE_PATH, val);
-       if (ret < 0)
-               _E("Failed to change touch glove mode state (%d)", ret);
-
-       return ret;
-}
-
-static int touchsensitivity_open(struct hw_info *info,
-               const char *id, struct hw_common **common)
-{
-       struct touchsensitivity_device *touchsensitivity_dev;
-
-       if (!info || !common)
-               return -EINVAL;
-
-       touchsensitivity_dev = calloc(1, sizeof(struct touchsensitivity_device));
-       if (!touchsensitivity_dev)
-               return -ENOMEM;
-
-       touchsensitivity_dev->common.info = info;
-       touchsensitivity_dev->glove_mode_get_state = glove_mode_get_state;
-       touchsensitivity_dev->glove_mode_set_state = glove_mode_set_state;
-
-       *common = (struct hw_common *)touchsensitivity_dev;
-       return 0;
-}
-
-static int touchsensitivity_close(struct hw_common *common)
-{
-       if (!common)
-               return -EINVAL;
-
-       free(common);
-       return 0;
-}
-
-HARDWARE_MODULE_STRUCTURE = {
-       .magic = HARDWARE_INFO_TAG,
-       .hal_version = HARDWARE_INFO_VERSION,
-       .device_version = TOUCHSENSITIVITY_HARDWARE_DEVICE_VERSION,
-       .id = TOUCHSENSITIVITY_HARDWARE_DEVICE_ID,
-       .name = "touchsensitivity",
-       .open = touchsensitivity_open,
-       .close = touchsensitivity_close,
-};