summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlokilee73 <changjoo.lee@samsung.com>2021-01-13 12:30:57 +0900
committerlokilee73 <changjoo.lee@samsung.com>2021-01-13 13:51:30 +0900
commit5aab89aadaa7d3372889d4cef4be2c7661326fad (patch)
treefc7ed48ee72847465b658a35c078b5192a0b1f6e
parent2eba93eb14b0ff625e13c76437181b09503f0d87 (diff)
downloaddevice-tm1-5aab89aadaa7d3372889d4cef4be2c7661326fad.tar.gz
device-tm1-5aab89aadaa7d3372889d4cef4be2c7661326fad.tar.bz2
device-tm1-5aab89aadaa7d3372889d4cef4be2c7661326fad.zip
Apply next HAL architecture (hal api + backend)
Change-Id: I636fca58e89ed90a40ffe7ff769ab2b137628403 Signed-off-by: lokilee73 <changjoo.lee@samsung.com>
-rw-r--r--hw/battery/CMakeLists.txt13
-rw-r--r--[-rwxr-xr-x]hw/battery/battery.c53
-rw-r--r--hw/board/CMakeLists.txt13
-rw-r--r--hw/board/board.c52
-rw-r--r--hw/common/common.h111
-rw-r--r--hw/display/CMakeLists.txt13
-rw-r--r--hw/display/display.c51
-rw-r--r--hw/external_connection/CMakeLists.txt13
-rw-r--r--hw/external_connection/external_connection.c53
-rw-r--r--hw/haptic/standard.c2
-rw-r--r--hw/ir/CMakeLists.txt9
-rw-r--r--hw/ir/ir.c46
-rw-r--r--hw/led/CMakeLists.txt9
-rw-r--r--hw/led/led.c78
-rw-r--r--hw/thermal/CMakeLists.txt13
-rw-r--r--hw/thermal/thermal.c51
-rw-r--r--hw/touchscreen/CMakeLists.txt13
-rw-r--r--hw/touchscreen/touchscreen.c47
-rw-r--r--hw/udev.c2
19 files changed, 340 insertions, 302 deletions
diff --git a/hw/battery/CMakeLists.txt b/hw/battery/CMakeLists.txt
index 820c168..614bae4 100644
--- a/hw/battery/CMakeLists.txt
+++ b/hw/battery/CMakeLists.txt
@@ -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)
diff --git a/hw/battery/battery.c b/hw/battery/battery.c
index b82897e..d5ce2c0 100755..100644
--- a/hw/battery/battery.c
+++ b/hw/battery/battery.c
@@ -24,8 +24,10 @@
#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"
@@ -204,8 +206,6 @@ static int battery_get_current_state(
if (!updated_cb)
return -EINVAL;
- info.name = BATTERY_HARDWARE_DEVICE_ID;
-
path = BATTERY_ROOT_PATH"/battery/status";
ret = sys_get_str(path, status, sizeof(status));
if (ret < 0) {
@@ -301,45 +301,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 = "SC7730",
+ .abi_version = HAL_ABI_VERSION_TIZEN_6_5,
+ .init = battery_init,
+ .exit = battery_exit,
};
diff --git a/hw/board/CMakeLists.txt b/hw/board/CMakeLists.txt
index 5416ed1..9ed63d3 100644
--- a/hw/board/CMakeLists.txt
+++ b/hw/board/CMakeLists.txt
@@ -1,12 +1,14 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(board C)
+PROJECT(hal-backend-device-board C)
SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+INCLUDE_DIRECTORIES(../common)
+
INCLUDE(FindPkgConfig)
-pkg_check_modules(board_pkgs REQUIRED hwcommon dlog)
+pkg_check_modules(hal-backend-device-board_pkgs REQUIRED dlog)
-FOREACH(flag ${board_pkgs_CFLAGS})
+FOREACH(flag ${hal-backend-device-board_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 board.c)
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${board_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-board_pkgs_LDFLAGS})
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /hal/lib COMPONENT RuntimeLibraries)
diff --git a/hw/board/board.c b/hw/board/board.c
index 3d11a86..9857c4d 100644
--- a/hw/board/board.c
+++ b/hw/board/board.c
@@ -17,13 +17,15 @@
*/
#define _GNU_SOURCE
-#include <hw/board.h>
+#include <hal/device/hal-board-interface.h>
+#include <hal/hal-common-interface.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
-#include <hw/shared.h>
+
+#include "common.h"
#define DATA_BUFF_MAX 256
@@ -185,45 +187,35 @@ static int get_device_revision(int *out)
return -EIO;
}
-static int board_open(struct hw_info *info,
- const char *id, struct hw_common **common)
+static int board_init(void **data)
{
- struct hw_board *b;
-
- if (!info || !common)
- return -EINVAL;
+ hal_backend_board_funcs *board_funcs;
- b = calloc(1, sizeof(struct hw_board));
- if (!b)
+ board_funcs = calloc(1, sizeof(hal_backend_board_funcs));
+ if (!board_funcs)
return -ENOMEM;
- b->common.info = info;
- b->get_device_serial = get_device_serial;
- b->get_device_revision = get_device_revision;
+ board_funcs->get_device_serial = get_device_serial;
+ board_funcs->get_device_revision = get_device_revision;
+
+ *data = (void *)board_funcs;
- *common = &b->common;
return 0;
}
-static int board_close(struct hw_common *common)
+static int board_exit(void *data)
{
- struct hw_board *b;
-
- if (!common)
- return -EINVAL;
-
- b = container_of(common, struct hw_board, common);
- free(b);
+ if (!data)
+ return 0;
+ free(data);
return 0;
}
-HARDWARE_MODULE_STRUCTURE = {
- .magic = HARDWARE_INFO_TAG,
- .hal_version = HARDWARE_INFO_VERSION,
- .device_version = BOARD_HARDWARE_DEVICE_VERSION,
- .id = BOARD_HARDWARE_DEVICE_ID,
- .name = "device",
- .open = board_open,
- .close = board_close,
+hal_backend EXPORT hal_backend_device_board_data = {
+ .name = "board",
+ .vendor = "SC7730",
+ .abi_version = HAL_ABI_VERSION_TIZEN_6_5,
+ .init = board_init,
+ .exit = board_exit,
};
diff --git a/hw/common/common.h b/hw/common/common.h
index c8b84f1..3c506ff 100644
--- a/hw/common/common.h
+++ b/hw/common/common.h
@@ -17,6 +17,13 @@
#ifndef __HAL_BACKEND_COMMON_H__
#define __HAL_BACKEND_COMMON_H__
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
#ifdef FEATURE_DLOG
#define LOG_TAG "HALBACKEND_DEVICE"
#include <dlog.h>
@@ -33,4 +40,108 @@
#define EXPORT __attribute__ ((visibility("default")))
+#define ARRAY_SIZE(name) (sizeof(name)/sizeof(name[0]))
+
+#define SHARED_H_BUF_MAX 255
+
+static inline int sys_read_buf(char *file, char *buf, int len)
+{
+ int fd, r;
+
+ if (!file || !buf || len < 0)
+ return -EINVAL;
+
+ fd = open(file, O_RDONLY);
+ if (fd == -1)
+ return -ENOENT;
+
+ r = read(fd, buf, len);
+ close(fd);
+ if ((r >= 0) && (r < len))
+ buf[r] = '\0';
+ else
+ return -EIO;
+
+ return 0;
+}
+
+static inline int sys_write_buf(char *file, char *buf)
+{
+ int fd, r;
+
+ if (!file || !buf)
+ return -EINVAL;
+
+ fd = open(file, O_WRONLY);
+ if (fd == -1)
+ return -EPERM;
+
+ r = write(fd, buf, strlen(buf));
+ close(fd);
+ if (r < 0)
+ return -EIO;
+
+ return 0;
+}
+
+static inline int sys_get_int(char *fname, int *val)
+{
+ char buf[SHARED_H_BUF_MAX];
+ int r;
+
+ if (!fname || !val)
+ return -EINVAL;
+
+ r = sys_read_buf(fname, buf, sizeof(buf));
+ if (r < 0)
+ return r;
+
+ *val = atoi(buf);
+ return 0;
+}
+
+static inline int sys_get_str(char *fname, char *str, int len)
+{
+ int r;
+
+ if (!fname || !str || len < 0)
+ return -EINVAL;
+
+ r = sys_read_buf(fname, str, len);
+ if (r < 0)
+ return r;
+
+ return 0;
+}
+
+static inline int sys_set_int(char *fname, int val)
+{
+ char buf[SHARED_H_BUF_MAX];
+ int r;
+
+ if (!fname)
+ return -EINVAL;
+
+ snprintf(buf, sizeof(buf), "%d", val);
+ r = sys_write_buf(fname, buf);
+ if (r < 0)
+ return r;
+
+ return 0;
+}
+
+static inline int sys_set_str(char *fname, char *val)
+{
+ int r;
+
+ if (!fname || !val)
+ return -EINVAL;
+
+ r = sys_write_buf(fname, val);
+ if (r < 0)
+ return r;
+
+ return 0;
+}
+
#endif /* __HAL_BACKEND_COMMON_H__ */
diff --git a/hw/display/CMakeLists.txt b/hw/display/CMakeLists.txt
index 08c293d..44639b7 100644
--- a/hw/display/CMakeLists.txt
+++ b/hw/display/CMakeLists.txt
@@ -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)
+pkg_check_modules(hal-backend-device-display_pkgs REQUIRED dlog)
-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)
diff --git a/hw/display/display.c b/hw/display/display.c
index 2a85da7..c95b564 100644
--- a/hw/display/display.c
+++ b/hw/display/display.c
@@ -23,8 +23,9 @@
#include <errno.h>
#include <linux/limits.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"
#ifndef BACKLIGHT_PATH
#define BACKLIGHT_PATH "/sys/class/backlight/panel"
@@ -121,43 +122,37 @@ static int display_get_state(enum display_state *state)
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;
+ hal_backend_display_funcs *display_funcs;
- if (!info || !common)
- return -EINVAL;
-
- 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_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;
+
+ *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 = "SC7730",
+ .abi_version = HAL_ABI_VERSION_TIZEN_6_5,
+ .init = display_init,
+ .exit = display_exit,
};
diff --git a/hw/external_connection/CMakeLists.txt b/hw/external_connection/CMakeLists.txt
index b1f2f83..1164421 100644
--- a/hw/external_connection/CMakeLists.txt
+++ b/hw/external_connection/CMakeLists.txt
@@ -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)
diff --git a/hw/external_connection/external_connection.c b/hw/external_connection/external_connection.c
index b79b88d..5acee31 100644
--- a/hw/external_connection/external_connection.c
+++ b/hw/external_connection/external_connection.c
@@ -24,8 +24,10 @@
#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"
@@ -173,45 +175,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 = "SC7730",
+ .abi_version = HAL_ABI_VERSION_TIZEN_6_5,
+ .init = external_connection_init,
+ .exit = external_connection_exit,
};
diff --git a/hw/haptic/standard.c b/hw/haptic/standard.c
index 466dd54..123ae6c 100644
--- a/hw/haptic/standard.c
+++ b/hw/haptic/standard.c
@@ -580,7 +580,7 @@ static int haptic_exit(void *data)
hal_backend EXPORT hal_backend_device_haptic_data = {
.name = "haptic-standard",
- .vendor = "",
+ .vendor = "SC7730",
.abi_version = HAL_ABI_VERSION_TIZEN_6_5,
.init = haptic_init,
.exit = haptic_exit,
diff --git a/hw/ir/CMakeLists.txt b/hw/ir/CMakeLists.txt
index a50cc82..97baed8 100644
--- a/hw/ir/CMakeLists.txt
+++ b/hw/ir/CMakeLists.txt
@@ -1,8 +1,10 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(ir C)
+PROJECT(hal-backend-device-ir C)
+
+INCLUDE_DIRECTORIES(../common)
INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED dlog hwcommon)
+pkg_check_modules(pkgs REQUIRED dlog)
FOREACH(flag ${pkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
@@ -12,5 +14,4 @@ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
ADD_LIBRARY(${PROJECT_NAME} MODULE ir.c)
-SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES PREFIX "")
-INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR}/hw COMPONENT RuntimeLibraries)
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /hal/lib COMPONENT RuntimeLibraries)
diff --git a/hw/ir/ir.c b/hw/ir/ir.c
index 57b66c5..48efe18 100644
--- a/hw/ir/ir.c
+++ b/hw/ir/ir.c
@@ -25,8 +25,10 @@
#include <linux/limits.h>
#include <dirent.h>
-#include <hw/ir.h>
-#include <hw/shared.h>
+#include <hal/device/hal-ir-interface.h>
+#include <hal/hal-common-interface.h>
+
+#include "common.h"
#define IRLED_CONTROL_PATH "/sys/class/sec/sec_ir/ir_send"
@@ -53,41 +55,35 @@ static int ir_transmit(int *frequency_pattern, int size)
return 0;
}
-static int ir_open(struct hw_info *info,
- const char *id, struct hw_common **common)
+static int ir_init(void **data)
{
- struct ir_device *ir_dev;
-
- if (!info || !common)
- return -EINVAL;
+ hal_backend_ir_funcs *ir_funcs;
- ir_dev = calloc(1, sizeof(struct ir_device));
- if (!ir_dev)
+ ir_funcs = calloc(1, sizeof(hal_backend_ir_funcs));
+ if (!ir_funcs)
return -ENOMEM;
- ir_dev->common.info = info;
- ir_dev->is_available = ir_is_available;
- ir_dev->transmit = ir_transmit;
+ ir_funcs->is_available = ir_is_available;
+ ir_funcs->transmit = ir_transmit;
+
+ *data = (void *)ir_funcs;
- *common = (struct hw_common *)ir_dev;
return 0;
}
-static int ir_close(struct hw_common *common)
+static int ir_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 = IR_HARDWARE_DEVICE_VERSION,
- .id = IR_HARDWARE_DEVICE_ID,
+hal_backend EXPORT hal_backend_device_ir_data = {
.name = "ir",
- .open = ir_open,
- .close = ir_close,
+ .vendor = "SC7730",
+ .abi_version = HAL_ABI_VERSION_TIZEN_6_5,
+ .init = ir_init,
+ .exit = ir_exit,
};
diff --git a/hw/led/CMakeLists.txt b/hw/led/CMakeLists.txt
index 4604c29..811a279 100644
--- a/hw/led/CMakeLists.txt
+++ b/hw/led/CMakeLists.txt
@@ -1,8 +1,10 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(led C)
+PROJECT(hal-backend-device-led C)
+
+INCLUDE_DIRECTORIES(../common)
INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED dlog hwcommon)
+pkg_check_modules(pkgs REQUIRED dlog)
FOREACH(flag ${pkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
@@ -12,5 +14,4 @@ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
ADD_LIBRARY(${PROJECT_NAME} MODULE led.c)
-SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES PREFIX "")
-INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR}/hw COMPONENT RuntimeLibraries)
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /hal/lib COMPONENT RuntimeLibraries)
diff --git a/hw/led/led.c b/hw/led/led.c
index c075cbd..84b6efc 100644
--- a/hw/led/led.c
+++ b/hw/led/led.c
@@ -23,8 +23,10 @@
#include <errno.h>
#include <linux/limits.h>
-#include <hw/led.h>
-#include <hw/shared.h>
+#include <hal/device/hal-led-interface.h>
+#include <hal/hal-common-interface.h>
+
+#include "common.h"
#ifndef CAMERA_BACK_PATH
#define CAMERA_BACK_PATH "/sys/class/leds/torch-sec1"
@@ -65,72 +67,34 @@ static int camera_back_set_state(struct led_state *state)
return 0;
}
-struct led_device camera_back_dev = {
- .set_state = camera_back_set_state,
-};
-
-struct led_device_list {
- const char *id;
- struct led_device *operations;
- struct led_device *dev;
-} led_list[] = {
- { LED_ID_CAMERA_BACK, &camera_back_dev, NULL },
- { LED_ID_CAMERA_FRONT, NULL, NULL },
- { LED_ID_NOTIFICATION, NULL, NULL },
- { LED_ID_TOUCH_KEY, NULL, NULL },
-};
-
-static int led_open(struct hw_info *info,
- const char *id, struct hw_common **common)
+static int led_init(void **data)
{
- int i, list_len, id_len;
-
- if (!info || !id || !common)
- return -EINVAL;
-
- list_len = ARRAY_SIZE(led_list);
- id_len = strlen(id) + 1;
- for (i = 0 ; i < list_len ; i++) {
- if (strncmp(id, led_list[i].id, id_len))
- continue;
- if (!led_list[i].operations)
- return -ENOTSUP;
- if (led_list[i].dev)
- goto out;
- break;
- }
+ hal_backend_led_funcs *led_funcs;
- if (i >= list_len)
- return -EINVAL;
- led_list[i].dev = calloc(1, sizeof(struct led_device));
- if (!led_list[i].dev)
+ led_funcs = calloc(1, sizeof(hal_backend_led_funcs));
+ if (!led_funcs)
return -ENOMEM;
- led_list[i].dev->common.info = info;
- led_list[i].dev->set_state
- = led_list[i].operations->set_state;
+ led_funcs->set_state = camera_back_set_state;
+
+ *data = (void *)led_funcs;
-out:
- *common = (struct hw_common *)led_list[i].dev;
return 0;
}
-static int led_close(struct hw_common *common)
+static int led_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 = LED_HARDWARE_DEVICE_VERSION,
- .id = LED_HARDWARE_DEVICE_ID,
- .name = "Default LED",
- .author = "Jiyoung Yun <jy910.yun@samsung.com>",
- .open = led_open,
- .close = led_close,
+hal_backend EXPORT hal_backend_device_led_data = {
+ .name = "led",
+ .vendor = "SC7730",
+ .abi_version = HAL_ABI_VERSION_TIZEN_6_5,
+ .init = led_init,
+ .exit = led_exit,
};
diff --git a/hw/thermal/CMakeLists.txt b/hw/thermal/CMakeLists.txt
index 42bcc20..82f0dd2 100644
--- a/hw/thermal/CMakeLists.txt
+++ b/hw/thermal/CMakeLists.txt
@@ -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)
diff --git a/hw/thermal/thermal.c b/hw/thermal/thermal.c
index 08579fb..294a3bb 100644
--- a/hw/thermal/thermal.c
+++ b/hw/thermal/thermal.c
@@ -23,8 +23,10 @@
#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 = "SC7730",
+ .abi_version = HAL_ABI_VERSION_TIZEN_6_5,
+ .init = thermal_init,
+ .exit = thermal_exit,
};
diff --git a/hw/touchscreen/CMakeLists.txt b/hw/touchscreen/CMakeLists.txt
index f364805..c9de46a 100644
--- a/hw/touchscreen/CMakeLists.txt
+++ b/hw/touchscreen/CMakeLists.txt
@@ -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)
diff --git a/hw/touchscreen/touchscreen.c b/hw/touchscreen/touchscreen.c
index e384d34..33d1389 100644
--- a/hw/touchscreen/touchscreen.c
+++ b/hw/touchscreen/touchscreen.c
@@ -24,8 +24,10 @@
#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"
@@ -133,45 +135,38 @@ static int touchscreen_set_state(enum touchscreen_state state)
return ret;
}
-static int touchscreen_open(struct hw_info *info,
- const char *id, struct hw_common **common)
+static int touchscreen_init(void **data)
{
- struct touchscreen_device *touchscreen_dev;
+ hal_backend_touchscreen_funcs *touchscreen_funcs;
- if (!info || !common)
- return -EINVAL;
+ touchscreen_funcs = calloc(1, sizeof(hal_backend_touchscreen_funcs));
+ if (!touchscreen_funcs)
+ return -ENOMEM;
if (touchscreen_probe() < 0)
return -ENOTSUP;
- touchscreen_dev = calloc(1, sizeof(struct touchscreen_device));
- if (!touchscreen_dev)
- return -ENOMEM;
+ touchscreen_funcs->get_state = touchscreen_get_state;
+ touchscreen_funcs->set_state = touchscreen_set_state;
- touchscreen_dev->common.info = info;
- touchscreen_dev->get_state = touchscreen_get_state;
- touchscreen_dev->set_state = touchscreen_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 = "SC7730",
+ .abi_version = HAL_ABI_VERSION_TIZEN_6_5,
+ .init = touchscreen_init,
+ .exit = touchscreen_exit,
};
diff --git a/hw/udev.c b/hw/udev.c
index e0c0d13..91d1aa2 100644
--- a/hw/udev.c
+++ b/hw/udev.c
@@ -23,7 +23,7 @@
#include <libudev.h>
#include <glib.h>
#include <string.h>
-#include <hw/shared.h>
+#include "common.h"
#include "udev.h"
#define EVENT_KERNEL "kernel"