From 6b759b59fd09eaac676176dd65731275ba57a081 Mon Sep 17 00:00:00 2001 From: Hyotaek Shim Date: Fri, 4 Jun 2021 18:27:22 +0900 Subject: [PATCH] Initialization Change-Id: I60f42bbb5bc0d9dfdc55ac8a29bd3ec6be1c8bc4 Signed-off-by: Hyotaek Shim --- CMakeLists.txt | 20 ++ LICENSE.Apache-2.0 | 202 ++++++++++++ hw/board/CMakeLists.txt | 18 ++ hw/board/board.c | 82 +++++ hw/display/CMakeLists.txt | 18 ++ hw/display/display.c | 129 ++++++++ hw/haptic/CMakeLists.txt | 23 ++ hw/haptic/gpio.c | 352 +++++++++++++++++++++ hw/memory/CMakeLists.txt | 18 ++ hw/memory/memory.c | 114 +++++++ hw/thermal/CMakeLists.txt | 18 ++ hw/thermal/thermal.c | 149 +++++++++ hw/touchscreen/CMakeLists.txt | 18 ++ hw/touchscreen/touchscreen.c | 122 +++++++ hw/usb_gadget/CMakeLists.txt | 18 ++ hw/usb_gadget/usb_gadget.c | 81 +++++ packaging/hal-backend-device-vim3.manifest | 5 + packaging/hal-backend-device-vim3.spec | 45 +++ 18 files changed, 1432 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 LICENSE.Apache-2.0 create mode 100644 hw/board/CMakeLists.txt create mode 100644 hw/board/board.c create mode 100644 hw/display/CMakeLists.txt create mode 100644 hw/display/display.c create mode 100644 hw/haptic/CMakeLists.txt create mode 100644 hw/haptic/gpio.c create mode 100644 hw/memory/CMakeLists.txt create mode 100644 hw/memory/memory.c create mode 100644 hw/thermal/CMakeLists.txt create mode 100644 hw/thermal/thermal.c create mode 100644 hw/touchscreen/CMakeLists.txt create mode 100644 hw/touchscreen/touchscreen.c create mode 100644 hw/usb_gadget/CMakeLists.txt create mode 100644 hw/usb_gadget/usb_gadget.c create mode 100644 packaging/hal-backend-device-vim3.manifest create mode 100644 packaging/hal-backend-device-vim3.spec diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..45ba039 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,20 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(hal-backend-device-vim3 C) + +SET(PREFIX ${CMAKE_INSTALL_PREFIX}) + +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall -Werror") + +IF(ENABLE_DLOG STREQUAL on) + ADD_DEFINITIONS("-DFEATURE_DLOG") +ENDIF() + +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.Apache-2.0 DESTINATION ${HAL_LICENSE_DIR}/${PROJECT_NAME}) + +ADD_SUBDIRECTORY(hw/board) +ADD_SUBDIRECTORY(hw/display) +ADD_SUBDIRECTORY(hw/touchscreen) +ADD_SUBDIRECTORY(hw/thermal) +ADD_SUBDIRECTORY(hw/usb_gadget) +ADD_SUBDIRECTORY(hw/haptic) +ADD_SUBDIRECTORY(hw/memory) diff --git a/LICENSE.Apache-2.0 b/LICENSE.Apache-2.0 new file mode 100644 index 0000000..fef8c29 --- /dev/null +++ b/LICENSE.Apache-2.0 @@ -0,0 +1,202 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. + diff --git a/hw/board/CMakeLists.txt b/hw/board/CMakeLists.txt new file mode 100644 index 0000000..de3acea --- /dev/null +++ b/hw/board/CMakeLists.txt @@ -0,0 +1,18 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(hal-backend-device-board C) + +SET(PREFIX ${CMAKE_INSTALL_PREFIX}) + +INCLUDE(FindPkgConfig) +pkg_check_modules(hal-backend-device-board_pkgs REQUIRED hal-backend-device-common) + +FOREACH(flag ${hal-backend-device-board_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 board.c) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${hal-backend-device-board_pkgs_LDFLAGS}) +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${HAL_LIB_DIR} COMPONENT RuntimeLibraries) diff --git a/hw/board/board.c b/hw/board/board.c new file mode 100644 index 0000000..56a2d7d --- /dev/null +++ b/hw/board/board.c @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2016 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. + */ + +#define _GNU_SOURCE +#include +#include + +#include +#include +#include +#include + +#include + +#define SERIAL_FILE_PATH "/sys/firmware/devicetree/base/serial-number" +#define LINE_LEN 64 + +static int get_device_serial(char **out) +{ + FILE *fp; + char *line, *p; + + fp = fopen(SERIAL_FILE_PATH, "r"); + if (!fp) + return -1; + + line = malloc(LINE_LEN); + p = fgets(line, LINE_LEN, fp); + fclose(fp); + if (p == NULL) { + free(line); + return -1; + } + + *out = p; + return 0; +} + +static int board_init(void **data) +{ + hal_backend_board_funcs *board_funcs; + + board_funcs = calloc(1, sizeof(hal_backend_board_funcs)); + if (!board_funcs) + return -ENOMEM; + + board_funcs->get_device_serial = get_device_serial; + + *data = (void *)board_funcs; + + return 0; +} + +static int board_exit(void *data) +{ + if (!data) + return 0; + + free(data); + return 0; +} + +hal_backend EXPORT hal_backend_device_board_data = { + .name = "board", + .vendor = "RPI", + .abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .init = board_init, + .exit = board_exit, +}; diff --git a/hw/display/CMakeLists.txt b/hw/display/CMakeLists.txt new file mode 100644 index 0000000..116adfa --- /dev/null +++ b/hw/display/CMakeLists.txt @@ -0,0 +1,18 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(hal-backend-device-display C) + +SET(PREFIX ${CMAKE_INSTALL_PREFIX}) + +INCLUDE(FindPkgConfig) +pkg_check_modules(hal-backend-device-display_pkgs REQUIRED hal-backend-device-common) + +FOREACH(flag ${hal-backend-device-display_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 display.c) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${hal-backend-device-display_pkgs_LDFLAGS}) +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${HAL_LIB_DIR} COMPONENT RuntimeLibraries) diff --git a/hw/display/display.c b/hw/display/display.c new file mode 100644 index 0000000..1f11726 --- /dev/null +++ b/hw/display/display.c @@ -0,0 +1,129 @@ +/* + * device-node + * + * Copyright (c) 2015 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 +#include +#include +#include +#include + +#include +#include +#include + +#include + +#ifndef BACKLIGHT_PATH +#define BACKLIGHT_PATH "/sys/class/backlight/rpi_backlight" +#endif + +static int display_get_max_brightness(int *val) +{ + static int max = -1; + int r; + + if (!val) + return -EINVAL; + + if (max < 0) { + r = sys_get_int(BACKLIGHT_PATH"/max_brightness", &max); + if (r < 0) + return r; + } + + *val = max; + return 0; +} + +static int display_get_brightness(int *brightness) +{ + int r, v; + + if (!brightness) { + _E("wrong parameter"); + return -EINVAL; + } + + r = sys_get_int(BACKLIGHT_PATH"/brightness", &v); + if (r < 0) { + _E("fail to get brightness (errno:%d)", r); + return r; + } + + *brightness = v; + return 0; +} + +static int display_set_brightness(int brightness) +{ + int r, max; + + r = display_get_max_brightness(&max); + if (r < 0) { + _E("fail to get max brightness (errno:%d)", r); + return r; + } + + if (brightness < 0 || brightness > max) { + _E("wrong parameter"); + return -EINVAL; + } + + r = sys_set_int(BACKLIGHT_PATH"/brightness", brightness); + if (r < 0) { + _E("fail to set brightness (errno:%d)", r); + return r; + } + + return 0; +} + +static int display_init(void **data) +{ + hal_backend_display_funcs *display_funcs; + + display_funcs = calloc(1, sizeof(hal_backend_display_funcs)); + if (!display_funcs) + return -ENOMEM; + + 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; + + return 0; +} + +static int display_exit(void *data) +{ + if (!data) + return 0; + + free(data); + return 0; +} + +hal_backend EXPORT hal_backend_device_display_data = { + .name = "display", + .vendor = "RPI", + .abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .init = display_init, + .exit = display_exit, +}; diff --git a/hw/haptic/CMakeLists.txt b/hw/haptic/CMakeLists.txt new file mode 100644 index 0000000..d3b5d3c --- /dev/null +++ b/hw/haptic/CMakeLists.txt @@ -0,0 +1,23 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(hal-backend-device-haptic C) + +SET(PREFIX ${CMAKE_INSTALL_PREFIX}) + +INCLUDE(FindPkgConfig) +pkg_check_modules(haptic_pkgs REQUIRED + hal-backend-device-common + glib-2.0 + libsyscommon + capi-system-peripheral-io) + +FOREACH(flag ${haptic_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 gpio.c) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${haptic_pkgs_LDFLAGS}) + +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${HAL_LIB_DIR} COMPONENT RuntimeLibraries) diff --git a/hw/haptic/gpio.c b/hw/haptic/gpio.c new file mode 100644 index 0000000..3d4b20c --- /dev/null +++ b/hw/haptic/gpio.c @@ -0,0 +1,352 @@ +/* + * feedbackd + * + * Copyright (c) 2016 - 2017 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 +#include +#include +#include +#include + +#include + +#define GPIO_I2C_BUS_INDEX 1 +#define MAX_HAPIC 1 +#define DRV2605L_DEFAULT_ADDR 0x5A + +#define START_CMD_CODE 1 +#define STOP_CMD_CODE 0 + +#define DRV2605L_REGISTER_STATUS 0x00 +#define DRV2605L_REGISTER_MODE 0x01 +#define DRV2605L_REGISTER_RTPINPUT 0x02 +#define DRV2605L_REGISTER_LIBRARY 0x03 +#define DRV2605L_REGISTER_WAVESEQ1 0x04 +#define DRV2605L_REGISTER_WAVESEQ2 0x05 +#define DRV2605L_REGISTER_WAVESEQ3 0x06 +#define DRV2605L_REGISTER_WAVESEQ4 0x07 +#define DRV2605L_REGISTER_WAVESEQ5 0x08 +#define DRV2605L_REGISTER_WAVESEQ6 0x09 +#define DRV2605L_REGISTER_WAVESEQ7 0x0A +#define DRV2605L_REGISTER_WAVESEQ8 0x0B +#define DRV2605L_REGISTER_GO 0x0C + +/** + * Mode register + */ +#define MODE_INTERNAL_TRIGGER 0 +#define MODE_EXTERNAL_TRIGGER_EDGE 1 +#define MODE_EXTERNAL_TRIGGER_LEVEL 2 +#define MODE_PWM_INPUT_ANALOG_INPUT 3 +#define MODE_AUDIO_TO_VIBE 4 +#define MODE_REALTIME_PLAYBACK 5 +#define MODE_DIAGNOSTICS 6 +#define MODE_AUTO_CALIBRATION 7 +/** + * Library register + */ +#define EMPTY_LIBRARY 0 +#define TS2200_LIBRARY_A 1 +#define TS2200_LIBRARY_B 2 +#define TS2200_LIBRARY_C 3 +#define TS2200_LIBRARY_D 4 +#define TS2200_LIBRARY_E 5 +#define LRA_LIBRARY_E 6 +#define TS2200_LIBRARY_F 7 + +#define MAX_LEVEL 2 +#define MAX_INTENSITY 10000 + +static peripheral_i2c_h device_handle = NULL; + +static GList *handle_list; +static int unique_number; + +static bool state = false; +static guint stop_timer = 0; + +static int gpio_haptic_stop_device(int handle); + +static bool find_from_list(int handle) +{ + GList *elem; + + elem = SYS_G_LIST_FIND(handle_list, (gpointer)(long)handle); + if (elem) + return true; + + return false; +} + +static gboolean gpio_haptic_timer_cb(void *data) +{ + int handle = (int)(long)data; + bool found; + + _I("Stop vibration by timer."); + + found = find_from_list(handle); + if (!found) + return G_SOURCE_REMOVE; + + if (device_handle == NULL) { + if (peripheral_i2c_open(GPIO_I2C_BUS_INDEX, DRV2605L_DEFAULT_ADDR, &device_handle) < PERIPHERAL_ERROR_NONE) { + _E("Failed to open I2C."); + return -EIO; + } + } + + /* stop playing */ + peripheral_i2c_write_register_byte(device_handle, DRV2605L_REGISTER_MODE, MODE_INTERNAL_TRIGGER); + + stop_timer = 0; + return G_SOURCE_REMOVE; +} + +static int gpio_haptic_get_device_count(int *count) +{ + _I("HAL: The max number of DRV2605L is %d.", (int)MAX_HAPIC); + if (count) + *count = MAX_HAPIC; + + return 0; +} + +/** + * Only one handle + * return device_handle + */ +static int gpio_haptic_open_device(int *handle) +{ + int n; + bool found = false; + GList *elem; + + if (!handle) + return -EINVAL; + + /* if it is the first element */ + n = SYS_G_LIST_LENGTH(handle_list); + if (n == 0) { + _I("Peripheral Device Open."); + if (device_handle == NULL) { + if (peripheral_i2c_open(GPIO_I2C_BUS_INDEX, DRV2605L_DEFAULT_ADDR, &device_handle) < PERIPHERAL_ERROR_NONE) { + _E("Failed to open I2C."); + return -EIO; + } + } + } + + if (unique_number == INT_MAX) + unique_number = 0; + + while (found != true) { + ++unique_number; + elem = SYS_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 = unique_number; + return 0; +} + +static int gpio_haptic_close_device(int handle) +{ + int r, n; + bool found; + + found = find_from_list(handle); + if (!found) + return -EINVAL; + + if (device_handle == NULL) { + if (peripheral_i2c_open(GPIO_I2C_BUS_INDEX, DRV2605L_DEFAULT_ADDR, &device_handle) < PERIPHERAL_ERROR_NONE) { + _E("Failed to open I2C."); + return -EIO; + } + } + + /* stop vibration */ + r = gpio_haptic_stop_device(handle); + if (r < 0) + _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); + + /* if it is the last element */ + n = SYS_G_LIST_LENGTH(handle_list); + if (n == 0) { + _I("Peripheral Device Close."); + if (device_handle != NULL) { + if (peripheral_i2c_close(device_handle) < PERIPHERAL_ERROR_NONE) { + _E("Failed to close peripheral I2C."); + return -EIO; + } + device_handle = NULL; + } + } + return 0; +} + +static int gpio_haptic_vibrate_monotone(int handle, int duration, int frequency, int overdrive, int level, int intensity, int priority) +{ + bool found; + int feedback; + int max_level; + + if (level <= 0) + return -EINVAL; + + found = find_from_list(handle); + if (!found) + return -EINVAL; + + if (device_handle == NULL) { + if (peripheral_i2c_open(GPIO_I2C_BUS_INDEX, DRV2605L_DEFAULT_ADDR, &device_handle) < PERIPHERAL_ERROR_NONE) { + _E("Failed to open I2C."); + return -EIO; + } + } + + /* Zero(0) is the infinitely vibration value */ + if (duration == HAPTIC_MODULE_DURATION_UNLIMITED) + duration = 0; + + if (stop_timer) + gpio_haptic_stop_device(handle); + + max_level = (level <= MAX_LEVEL)? MAX_LEVEL: level; + if (intensity) + feedback = ((level/max_level) * intensity) / 100; + else + feedback = ((level/max_level) * MAX_INTENSITY) / 100; + + /* play vibration */ + peripheral_i2c_write_register_byte(device_handle, DRV2605L_REGISTER_LIBRARY, TS2200_LIBRARY_A); + /* continuously vibrate*/ + peripheral_i2c_write_register_byte(device_handle, DRV2605L_REGISTER_MODE, MODE_REALTIME_PLAYBACK); + peripheral_i2c_write_register_byte(device_handle, DRV2605L_REGISTER_RTPINPUT, (uint8_t)feedback); + + /* register timer */ + if (duration) { + //stop_timer = ecore_timer_add(duration/1000.f, gpio_haptic_timer_cb, (void *)(long)handle); + stop_timer = g_timeout_add(duration, gpio_haptic_timer_cb, (void *)(long)handle); + if (!stop_timer) + _E("Failed to add timer callback."); + } + _D("Device handle(%d) %dms", handle, duration); + + return 0; +} + +static int gpio_haptic_stop_device(int handle) +{ + bool found; + + found = find_from_list(handle); + if (!found) + return -EINVAL; + + if (device_handle == NULL) { + if (peripheral_i2c_open(GPIO_I2C_BUS_INDEX, DRV2605L_DEFAULT_ADDR, &device_handle) < PERIPHERAL_ERROR_NONE) { + _E("Failed to open I2C."); + return -EIO; + } + } + + /* stop playing */ + peripheral_i2c_write_register_byte(device_handle, DRV2605L_REGISTER_MODE, MODE_INTERNAL_TRIGGER); + + if (stop_timer) { + //ecore_timer_del(stop_timer); + g_source_remove(stop_timer); + stop_timer = 0; + } + + return 0; +} + +static bool is_valid(void) +{ + uint8_t result; + peripheral_i2c_h handle; + + if (peripheral_i2c_open(GPIO_I2C_BUS_INDEX, DRV2605L_DEFAULT_ADDR, &handle) < PERIPHERAL_ERROR_NONE) { + _E("Failed to open I2C."); + state = false; + return false; + } + if (peripheral_i2c_read_register_byte(handle, DRV2605L_REGISTER_STATUS, &result) < PERIPHERAL_ERROR_NONE) { + _E("Failed to read peripheral I2C."); + if (peripheral_i2c_close(handle) < PERIPHERAL_ERROR_NONE) + _E("Failed to close peripheral I2C."); + state = false; + return false; + } + if (peripheral_i2c_close(handle) < PERIPHERAL_ERROR_NONE) { + _E("Failed to close peripheral I2C."); + state = false; + return false; + } + + state = true; + _I("Support gpio haptic device."); + return true; +} + +static int haptic_init(void **data) +{ + hal_backend_haptic_funcs *haptic_funcs; + + haptic_funcs = calloc(1, sizeof(hal_backend_haptic_funcs)); + if (!haptic_funcs) + return -ENOMEM; + + haptic_funcs->get_device_count = gpio_haptic_get_device_count; + haptic_funcs->open_device = gpio_haptic_open_device; + haptic_funcs->close_device = gpio_haptic_close_device; + haptic_funcs->vibrate_monotone = gpio_haptic_vibrate_monotone; + haptic_funcs->stop_device = gpio_haptic_stop_device; + haptic_funcs->is_valid = is_valid; + + *data = (void *)haptic_funcs; + + return 0; +} + +static int haptic_exit(void *data) +{ + if (!data) + return -EINVAL; + + free(data); + return 0; +} + + +hal_backend EXPORT hal_backend_device_haptic_data = { + .name = "haptic", + .vendor = "RPI", + .abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .init = haptic_init, + .exit = haptic_exit, +}; diff --git a/hw/memory/CMakeLists.txt b/hw/memory/CMakeLists.txt new file mode 100644 index 0000000..a35248a --- /dev/null +++ b/hw/memory/CMakeLists.txt @@ -0,0 +1,18 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(hal-backend-device-memory C) + +SET(PREFIX ${CMAKE_INSTALL_PREFIX}) + +INCLUDE(FindPkgConfig) +pkg_check_modules(hal-backend-device-memory_pkgs REQUIRED dlog) + +FOREACH(flag ${hal-backend-device-memory_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 memory.c) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${hal-backend-device-memory_pkgs_LDFLAGS}) +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${HAL_LIB_DIR} COMPONENT RuntimeLibraries) diff --git a/hw/memory/memory.c b/hw/memory/memory.c new file mode 100644 index 0000000..90157ab --- /dev/null +++ b/hw/memory/memory.c @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2021 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 +#include +#include + +#include +#include + +#include + +#define GEM_INFO_PATH "/sys/kernel/debug/dri/0/gem_info" +#define BYTES_PER_KBYTE 1024 + +static int memory_get_gpu_info(const int pid, struct gpu_info *info) +{ + return -ENODEV; +} + +static int memory_get_gem_info(const int pid, struct gem_info *info) +{ + FILE *fp; + char line[1024]; + int p; + unsigned int hcount, total_hcount; + unsigned long rss, total_rss, temp; + + if (!info) + return -EINVAL; + + fp = fopen(GEM_INFO_PATH, "r"); + if (!fp) { + _E("Failed to open %s, %d", GEM_INFO_PATH, -errno); + /* Return the designated error(EIO) instead of general error(errno) + * for api-level error conversion compatibility, as the api(runtime-info) + * has no error enum for general error(errno) */ + return -EIO; + } + + total_hcount = 0; + total_rss = 0; + + /* TM1 format: + * pid tgid handle refcount hcount size flags pfnmap export_to_fd import_from_fd obj_addr name + * 2978 2978 1 2 2 0x0007f000 0x3 0 0 0 0xffffffc024941200 6 + */ + while (fgets(line, 1024, fp)) { + if (sscanf(line, "%d %*d %*d %*d %u %lx", &p, &hcount, &rss) != 3) + continue; + + if (p != pid) + continue; + + total_rss += rss; + total_hcount += hcount; + } + + temp = total_rss / (unsigned long)BYTES_PER_KBYTE; + info->rss = (int)temp; + + if (total_hcount > 0) { + temp = (total_rss / (unsigned long)total_hcount) / (unsigned long)BYTES_PER_KBYTE; + info->pss = (int)temp; + } else + info->pss = 0; + + fclose(fp); + + return 0; +} + +static int memory_init(void **data) +{ + hal_backend_memory_funcs *memory_funcs; + + memory_funcs = calloc(1, sizeof(hal_backend_memory_funcs)); + if (!memory_funcs) + return -ENOMEM; + + memory_funcs->get_gpu_info = memory_get_gpu_info; + memory_funcs->get_gem_info = memory_get_gem_info; + + *data = (void *)memory_funcs; + + return 0; +} + +static int memory_exit(void *data) +{ + free(data); + return 0; +} + +hal_backend EXPORT hal_backend_device_memory_data = { + .name = "memory", + .vendor = "RPI", + .abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .init = memory_init, + .exit = memory_exit, +}; diff --git a/hw/thermal/CMakeLists.txt b/hw/thermal/CMakeLists.txt new file mode 100644 index 0000000..197833c --- /dev/null +++ b/hw/thermal/CMakeLists.txt @@ -0,0 +1,18 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(hal-backend-device-thermal C) + +SET(PREFIX ${CMAKE_INSTALL_PREFIX}) + +INCLUDE(FindPkgConfig) +pkg_check_modules(hal-backend-device-thermal_pkgs REQUIRED hal-backend-device-common glib-2.0) + +FOREACH(flag ${hal-backend-device-thermal_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 thermal.c) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${hal-backend-device-thermal_pkgs_LDFLAGS}) +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${HAL_LIB_DIR} COMPONENT RuntimeLibraries) diff --git a/hw/thermal/thermal.c b/hw/thermal/thermal.c new file mode 100644 index 0000000..903e7d2 --- /dev/null +++ b/hw/thermal/thermal.c @@ -0,0 +1,149 @@ +/* + * 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 +#include +#include +#include +#include + +#include +#include + +#include + +#define AP_PATH "/sys/class/thermal/thermal_zone0/temp" + +static struct event_data { + ThermalUpdated updated_cb; + void *data; +} edata = { 0, }; + +static guint timer; + +static int thermal_get_info(device_thermal_e type, struct thermal_info *info) +{ + FILE *fp; + char buf[32]; + size_t len; + + if (!info) + return -EINVAL; + + fp = fopen(AP_PATH, "r"); + if (!fp) { + _E("Failed to open thermal path(%d)", errno); + return -errno; + } + + len = fread(buf, 1, sizeof(buf) - 1, fp); + fclose(fp); + if (len == 0) { + _E("Failed to read thermal value(%d)", errno); + return -errno; + } + buf[len] = '\0'; + info->temp = atoi(buf); + info->temp /= 1000; + info->adc = 0; + + _I("temp(%d) adc(%d)", info->temp, info->adc); + return 0; +} + +static gboolean thermal_timeout(gpointer data) +{ + struct thermal_info info; + int ret; + + ret = thermal_get_info(DEVICE_THERMAL_AP, &info); + if (ret < 0) { + _E("Failed to read thermal info (%d)", ret); + return G_SOURCE_CONTINUE; + } + + if (edata.updated_cb) + edata.updated_cb(&info, edata.data); + + return G_SOURCE_CONTINUE; +} + +static int thermal_register_changed_event(ThermalUpdated updated_cb, void *data) +{ + if (timer) + g_source_remove(timer); + + timer = g_timeout_add(10000, thermal_timeout, NULL); + if (timer == 0) { + _E("Failed to add timer for thermal"); + return -ENOENT; + } + + edata.updated_cb = updated_cb; + edata.data = data; + + return 0; +} + +static int thermal_unregister_changed_event(ThermalUpdated updated_cb) +{ + if (timer) { + g_source_remove(timer); + timer = 0; + } + + edata.updated_cb = NULL; + edata.data = NULL; + + return 0; +} + +static int thermal_init(void **data) +{ + hal_backend_thermal_funcs *thermal_funcs; + + thermal_funcs = calloc(1, sizeof(hal_backend_thermal_funcs)); + if (!thermal_funcs) + return -ENOMEM; + + 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; + + return 0; +} + +static int thermal_exit(void *data) +{ + if (!data) + return 0; + + free(data); + return 0; +} + +hal_backend EXPORT hal_backend_device_thermal_data = { + .name = "thermal", + .vendor = "RPI", + .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 new file mode 100644 index 0000000..e18741e --- /dev/null +++ b/hw/touchscreen/CMakeLists.txt @@ -0,0 +1,18 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(hal-backend-device-touchscreen C) + +SET(PREFIX ${CMAKE_INSTALL_PREFIX}) + +INCLUDE(FindPkgConfig) +pkg_check_modules(hal-backend-device-touchscreen_pkgs REQUIRED hal-backend-device-common) + +FOREACH(flag ${hal-backend-device-touchscreen_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 touchscreen.c) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${hal-backend-device-touchscreen_pkgs_LDFLAGS}) +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${HAL_LIB_DIR} COMPONENT RuntimeLibraries) diff --git a/hw/touchscreen/touchscreen.c b/hw/touchscreen/touchscreen.c new file mode 100644 index 0000000..ff4e9b8 --- /dev/null +++ b/hw/touchscreen/touchscreen.c @@ -0,0 +1,122 @@ +/* + * device-node + * + * Copyright (c) 2015 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 +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +#define TOUCHSCREEN_CON_FILE "/sys/devices/platform/rpi_ft5406/enable" + +#define TURNON_TOUCHSCREEN 1 +#define TURNOFF_TOUCHSCREEN 0 + +static int touchscreen_get_state(enum touchscreen_state *state) +{ + int ret; + int val; + + if (!state) + return -EINVAL; + + ret = sys_get_int(TOUCHSCREEN_CON_FILE, &val); + if (ret < 0) { + _E("Failed to get touchscreen state (%d)", ret); + return ret; + } + + switch (val) { + case TURNOFF_TOUCHSCREEN: + *state = TOUCHSCREEN_OFF; + break; + case TURNON_TOUCHSCREEN: + *state = TOUCHSCREEN_ON; + break; + default: + _E("Failed to get touchscreen state (%d)", val); + return -EINVAL; + } + + return 0; +} + +static int touchscreen_set_state(enum touchscreen_state state) +{ + int ret; + int val; + + switch (state) { + case TOUCHSCREEN_OFF: + val = TURNOFF_TOUCHSCREEN; + break; + case TOUCHSCREEN_ON: + val = TURNON_TOUCHSCREEN; + break; + default: + _E("Invalid input (%d)", state); + return -EINVAL; + } + + ret = sys_set_int(TOUCHSCREEN_CON_FILE, val); + if (ret < 0) + _E("Failed to change touchscreen state (%d)", ret); + + return ret; +} + +static int touchscreen_init(void **data) +{ + hal_backend_touchscreen_funcs *touchscreen_funcs; + + touchscreen_funcs = calloc(1, sizeof(hal_backend_touchscreen_funcs)); + if (!touchscreen_funcs) + return -ENOMEM; + + touchscreen_funcs->get_state = touchscreen_get_state; + touchscreen_funcs->set_state = touchscreen_set_state; + + *data = (void *)touchscreen_funcs; + + return 0; +} + +static int touchscreen_exit(void *data) +{ + if (!data) + return 0; + + free(data); + return 0; +} + +hal_backend EXPORT hal_backend_device_touchscreen_data = { + .name = "touchscreen", + .vendor = "RPI", + .abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .init = touchscreen_init, + .exit = touchscreen_exit, +}; diff --git a/hw/usb_gadget/CMakeLists.txt b/hw/usb_gadget/CMakeLists.txt new file mode 100644 index 0000000..7146f92 --- /dev/null +++ b/hw/usb_gadget/CMakeLists.txt @@ -0,0 +1,18 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(hal-backend-device-usb-gadget C) + +SET(PREFIX ${CMAKE_INSTALL_PREFIX}) + +INCLUDE(FindPkgConfig) +pkg_check_modules(hal-backend-device-usb-gadget_pkgs REQUIRED hal-backend-device-common) + +FOREACH(flag ${hal-backend-device-usb-gadget_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 usb_gadget.c) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${hal-backend-device-usb-gadget_pkgs_LDFLAGS}) +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${HAL_LIB_DIR} COMPONENT RuntimeLibraries) diff --git a/hw/usb_gadget/usb_gadget.c b/hw/usb_gadget/usb_gadget.c new file mode 100644 index 0000000..3a35e4f --- /dev/null +++ b/hw/usb_gadget/usb_gadget.c @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2016 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 +#include + +#include +#include + +#include +#include + +static int usb_gadget_init(void **data) +{ + hal_backend_usb_gadget_funcs *usb_gadget_funcs; + + if (!data) + return -EINVAL; + + usb_gadget_funcs = calloc(1, sizeof(hal_backend_usb_gadget_funcs)); + if (!usb_gadget_funcs) + return -ENOMEM; + + // usb_gadget_translator + if (simple_translator_open(usb_gadget_funcs)) { + _E("No USB gadget translator"); + goto error_translator_open; + } + + // usb_client + if (hw_cfs_gadget_open(usb_gadget_funcs)) { + _I("No USB client"); + goto error_gadget_open; + } + + *data = (void *)usb_gadget_funcs; + + return 0; + +error_gadget_open: + simple_translator_close(usb_gadget_funcs); + +error_translator_open: + free(usb_gadget_funcs); + + return -ENODEV; +} + +static int usb_gadget_exit(void *data) +{ + hal_backend_usb_gadget_funcs *usb_gadget_funcs = (hal_backend_usb_gadget_funcs *)data; + + if (usb_gadget_funcs) { + hw_cfs_gadget_close(usb_gadget_funcs); + simple_translator_close(usb_gadget_funcs); + free(usb_gadget_funcs); + } + + return 0; +} + +hal_backend EXPORT hal_backend_device_usb_gadget_data = { + .name = "usb_gadget", + .vendor = "RPI", + .abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .init = usb_gadget_init, + .exit = usb_gadget_exit, +}; diff --git a/packaging/hal-backend-device-vim3.manifest b/packaging/hal-backend-device-vim3.manifest new file mode 100644 index 0000000..af9b883 --- /dev/null +++ b/packaging/hal-backend-device-vim3.manifest @@ -0,0 +1,5 @@ + + + + + diff --git a/packaging/hal-backend-device-vim3.spec b/packaging/hal-backend-device-vim3.spec new file mode 100644 index 0000000..576a7a0 --- /dev/null +++ b/packaging/hal-backend-device-vim3.spec @@ -0,0 +1,45 @@ +Name: hal-backend-device-vim3 +Summary: Device HAL backend drivers for vim3 targets +Version: 0.0.1 +Release: 0 +Group: System/Hardware Adaptation +License: Apache-2.0 +Source0: %{name}-%{version}.tar.gz +Source1: %{name}.manifest +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) + +%description +Device HAL backend drivers for Amlogic vim3 targets + +%prep +%setup -q +cp %{SOURCE1} . + +%build +%cmake . -DENABLE_DLOG=on \ + -DHAL_LICENSE_DIR=%{_hal_licensedir} \ + -DHAL_LIB_DIR=%{_hal_libdir} + +make %{?jobs:-j%jobs} + +%install +%make_install + +%post +/sbin/ldconfig + +%postun +/sbin/ldconfig + +%files +%{_hal_libdir}/*.so* +%manifest %{name}.manifest +%{_hal_licensedir}/%{name}/LICENSE.Apache-2.0 -- 2.34.1