summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlokilee73 <changjoo.lee@samsung.com>2021-01-12 17:26:22 +0900
committerlokilee73 <changjoo.lee@samsung.com>2021-01-13 10:57:01 +0900
commit5c113430df445df57890f8468d58db1c38a8411e (patch)
treec249b7606670362612db72c0bfe575b36e0ca821
parent96d1f6b556bef588752053eb0866b2a115c0191a (diff)
downloaddevice-rpi-5c113430df445df57890f8468d58db1c38a8411e.tar.gz
device-rpi-5c113430df445df57890f8468d58db1c38a8411e.tar.bz2
device-rpi-5c113430df445df57890f8468d58db1c38a8411e.zip
Apply next HAL architecture (hal api + backend)
Change-Id: Ifec0a7e4acf0b296ca7b18814a94deaaf25e4b7a Signed-off-by: lokilee73 <changjoo.lee@samsung.com>
-rw-r--r--hw/board/CMakeLists.txt13
-rw-r--r--hw/board/board.c49
-rw-r--r--hw/common/common.h147
-rw-r--r--hw/display/CMakeLists.txt13
-rw-r--r--hw/display/display.c49
-rw-r--r--hw/led/CMakeLists.txt14
-rw-r--r--hw/led/led.c60
-rw-r--r--hw/thermal/CMakeLists.txt13
-rw-r--r--hw/thermal/thermal.c50
-rw-r--r--hw/touchscreen/CMakeLists.txt13
-rw-r--r--hw/touchscreen/touchscreen.c45
-rw-r--r--hw/udev.c2
-rw-r--r--packaging/device-manager-plugin-rpi3.spec3
13 files changed, 293 insertions, 178 deletions
diff --git a/hw/board/CMakeLists.txt b/hw/board/CMakeLists.txt
index 5b8b5b4..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(usb_gadget_pkgs REQUIRED hwcommon)
+pkg_check_modules(hal-backend-device-board_pkgs REQUIRED dlog)
-FOREACH(flag ${usb_gadget_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} ${usb_gadget_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 3c6b42d..15654a5 100644
--- a/hw/board/board.c
+++ b/hw/board/board.c
@@ -17,13 +17,16 @@
*/
#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 "common.h"
+
#define SERIAL_FILE_PATH "/sys/firmware/devicetree/base/serial-number"
#define LINE_LEN 64
@@ -48,44 +51,34 @@ static int get_device_serial(char **out)
return 0;
}
-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(*b));
- 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;
+ board_funcs->get_device_serial = get_device_serial;
+
+ *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 = "rpi3",
+ .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
new file mode 100644
index 0000000..d286e0e
--- /dev/null
+++ b/hw/common/common.h
@@ -0,0 +1,147 @@
+/*
+ * Copyright (c) 2021 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.
+ */
+
+#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>
+ #define _D(fmt, args...) SLOGD(fmt, ##args)
+ #define _I(fmt, args...) SLOGI(fmt, ##args)
+ #define _W(fmt, args...) SLOGW(fmt, ##args)
+ #define _E(fmt, args...) SLOGE(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 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__ */ \ No newline at end of file
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 9eb4f89..bb863da 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/rpi_backlight"
@@ -91,42 +92,36 @@ static int display_set_brightness(int brightness)
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_funcs->get_max_brightness = display_get_max_brightness;
+ display_funcs->get_brightness = display_get_brightness;
+ display_funcs->set_brightness = display_set_brightness;
+
+ *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 = "rpi3",
+ .abi_version = HAL_ABI_VERSION_TIZEN_6_5,
+ .init = display_init,
+ .exit = display_exit,
};
diff --git a/hw/led/CMakeLists.txt b/hw/led/CMakeLists.txt
index dfe38d5..39a9526 100644
--- a/hw/led/CMakeLists.txt
+++ b/hw/led/CMakeLists.txt
@@ -1,12 +1,14 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(led C)
+PROJECT(hal-backend-device-led C)
SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+INCLUDE_DIRECTORIES(../common)
+
INCLUDE(FindPkgConfig)
-pkg_check_modules(led_pkgs REQUIRED hwcommon dlog glib-2.0 capi-system-peripheral-io)
+pkg_check_modules(hal-backend-device-led_pkgs REQUIRED dlog glib-2.0 capi-system-peripheral-io)
-FOREACH(flag ${led_pkgs_CFLAGS})
+FOREACH(flag ${hal-backend-device-led_pkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
ENDFOREACH(flag)
@@ -14,7 +16,5 @@ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
ADD_LIBRARY(${PROJECT_NAME} MODULE led.c)
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${led_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-led_pkgs_LDFLAGS})
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /hal/lib COMPONENT RuntimeLibraries)
diff --git a/hw/led/led.c b/hw/led/led.c
index bc8da82..cc1c362 100644
--- a/hw/led/led.c
+++ b/hw/led/led.c
@@ -20,8 +20,9 @@
#include <stdlib.h>
#include <glib.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"
#include <peripheral_io.h>
@@ -325,53 +326,38 @@ static int gpio_rgb_set_state(struct led_state *state)
return gpio_rgb_turn_on(state);
}
-static int led_open(struct hw_info *info,
- const char *id, struct hw_common **common)
+static int led_init(void **data)
{
- struct led_device *led_dev;
- size_t len;
+ hal_backend_led_funcs *led_funcs;
- if (!info || !id || !common)
- return -EINVAL;
-
- led_dev = calloc(1, sizeof(struct led_device));
- if (!led_dev)
+ led_funcs = calloc(1, sizeof(hal_backend_led_funcs));
+ if (!led_funcs)
return -ENOMEM;
- led_dev->common.info = info;
+ if (gpio_rgb_init_led()) {
+ free(led_funcs);
+ return -EIO;
+ } else
+ led_funcs->set_state = gpio_rgb_set_state;
- len = strlen(id) + 1;
- if (!strncmp(id, LED_ID_NOTIFICATION, len)) {
- if (gpio_rgb_init_led()) {
- free(led_dev);
- return -EIO;
- } else
- led_dev->set_state = gpio_rgb_set_state;
+ *data = (void *)led_funcs;
- } else {
- free(led_dev);
- return -ENOTSUP;
- }
-
- *common = (struct hw_common *)led_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 = "I2C RGB LED",
- .open = led_open,
- .close = led_close,
+hal_backend EXPORT hal_backend_device_led_data = {
+ .name = "led",
+ .vendor = "rpi3",
+ .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 10eaea4..73a4e33 100644
--- a/hw/thermal/thermal.c
+++ b/hw/thermal/thermal.c
@@ -23,8 +23,9 @@
#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/thermal/thermal_zone0/temp"
@@ -112,45 +113,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;
+ hal_backend_thermal_funcs *thermal_funcs;
- if (!info || !common)
- return -EINVAL;
-
- 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 = "rpi3",
+ .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 afe6b57..c05d2ec 100644
--- a/hw/touchscreen/touchscreen.c
+++ b/hw/touchscreen/touchscreen.c
@@ -24,8 +24,9 @@
#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 TOUCHSCREEN_CON_FILE "/sys/devices/platform/rpi_ft5406/enable"
@@ -85,41 +86,35 @@ 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_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_funcs->get_state = touchscreen_get_state;
+ touchscreen_funcs->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(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 = "rpi3",
+ .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"
diff --git a/packaging/device-manager-plugin-rpi3.spec b/packaging/device-manager-plugin-rpi3.spec
index 840044d..90d6f62 100644
--- a/packaging/device-manager-plugin-rpi3.spec
+++ b/packaging/device-manager-plugin-rpi3.spec
@@ -14,6 +14,8 @@ BuildRequires: pkgconfig(hwcommon)
BuildRequires: pkgconfig(glib-2.0)
BuildRequires: pkgconfig(libudev)
BuildRequires: pkgconfig(capi-system-peripheral-io)
+BuildRequires: pkgconfig(hal-api-common)
+BuildRequires: pkgconfig(hal-api-device)
%description
Device manager plugin Raspberry Pi 3
@@ -37,6 +39,7 @@ make %{?jobs:-j%jobs}
/sbin/ldconfig
%files
+/hal/lib/libhal*.so*
%{_libdir}/hw/*.so
%manifest %{name}.manifest
%license LICENSE