Initialization 35/259335/1
authorHyotaek Shim <hyotaek.shim@samsung.com>
Fri, 4 Jun 2021 09:27:22 +0000 (18:27 +0900)
committerHyotaek Shim <hyotaek.shim@samsung.com>
Fri, 4 Jun 2021 09:28:30 +0000 (18:28 +0900)
Change-Id: I60f42bbb5bc0d9dfdc55ac8a29bd3ec6be1c8bc4
Signed-off-by: Hyotaek Shim <hyotaek.shim@samsung.com>
18 files changed:
CMakeLists.txt [new file with mode: 0644]
LICENSE.Apache-2.0 [new file with mode: 0644]
hw/board/CMakeLists.txt [new file with mode: 0644]
hw/board/board.c [new file with mode: 0644]
hw/display/CMakeLists.txt [new file with mode: 0644]
hw/display/display.c [new file with mode: 0644]
hw/haptic/CMakeLists.txt [new file with mode: 0644]
hw/haptic/gpio.c [new file with mode: 0644]
hw/memory/CMakeLists.txt [new file with mode: 0644]
hw/memory/memory.c [new file with mode: 0644]
hw/thermal/CMakeLists.txt [new file with mode: 0644]
hw/thermal/thermal.c [new file with mode: 0644]
hw/touchscreen/CMakeLists.txt [new file with mode: 0644]
hw/touchscreen/touchscreen.c [new file with mode: 0644]
hw/usb_gadget/CMakeLists.txt [new file with mode: 0644]
hw/usb_gadget/usb_gadget.c [new file with mode: 0644]
packaging/hal-backend-device-vim3.manifest [new file with mode: 0644]
packaging/hal-backend-device-vim3.spec [new file with mode: 0644]

diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644 (file)
index 0000000..45ba039
--- /dev/null
@@ -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 (file)
index 0000000..fef8c29
--- /dev/null
@@ -0,0 +1,202 @@
+                                 Apache License\r
+                           Version 2.0, January 2004\r
+                        http://www.apache.org/licenses/\r
+\r
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\r
+\r
+   1. Definitions.\r
+\r
+      "License" shall mean the terms and conditions for use, reproduction,\r
+      and distribution as defined by Sections 1 through 9 of this document.\r
+\r
+      "Licensor" shall mean the copyright owner or entity authorized by\r
+      the copyright owner that is granting the License.\r
+\r
+      "Legal Entity" shall mean the union of the acting entity and all\r
+      other entities that control, are controlled by, or are under common\r
+      control with that entity. For the purposes of this definition,\r
+      "control" means (i) the power, direct or indirect, to cause the\r
+      direction or management of such entity, whether by contract or\r
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the\r
+      outstanding shares, or (iii) beneficial ownership of such entity.\r
+\r
+      "You" (or "Your") shall mean an individual or Legal Entity\r
+      exercising permissions granted by this License.\r
+\r
+      "Source" form shall mean the preferred form for making modifications,\r
+      including but not limited to software source code, documentation\r
+      source, and configuration files.\r
+\r
+      "Object" form shall mean any form resulting from mechanical\r
+      transformation or translation of a Source form, including but\r
+      not limited to compiled object code, generated documentation,\r
+      and conversions to other media types.\r
+\r
+      "Work" shall mean the work of authorship, whether in Source or\r
+      Object form, made available under the License, as indicated by a\r
+      copyright notice that is included in or attached to the work\r
+      (an example is provided in the Appendix below).\r
+\r
+      "Derivative Works" shall mean any work, whether in Source or Object\r
+      form, that is based on (or derived from) the Work and for which the\r
+      editorial revisions, annotations, elaborations, or other modifications\r
+      represent, as a whole, an original work of authorship. For the purposes\r
+      of this License, Derivative Works shall not include works that remain\r
+      separable from, or merely link (or bind by name) to the interfaces of,\r
+      the Work and Derivative Works thereof.\r
+\r
+      "Contribution" shall mean any work of authorship, including\r
+      the original version of the Work and any modifications or additions\r
+      to that Work or Derivative Works thereof, that is intentionally\r
+      submitted to Licensor for inclusion in the Work by the copyright owner\r
+      or by an individual or Legal Entity authorized to submit on behalf of\r
+      the copyright owner. For the purposes of this definition, "submitted"\r
+      means any form of electronic, verbal, or written communication sent\r
+      to the Licensor or its representatives, including but not limited to\r
+      communication on electronic mailing lists, source code control systems,\r
+      and issue tracking systems that are managed by, or on behalf of, the\r
+      Licensor for the purpose of discussing and improving the Work, but\r
+      excluding communication that is conspicuously marked or otherwise\r
+      designated in writing by the copyright owner as "Not a Contribution."\r
+\r
+      "Contributor" shall mean Licensor and any individual or Legal Entity\r
+      on behalf of whom a Contribution has been received by Licensor and\r
+      subsequently incorporated within the Work.\r
+\r
+   2. Grant of Copyright License. Subject to the terms and conditions of\r
+      this License, each Contributor hereby grants to You a perpetual,\r
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+      copyright license to reproduce, prepare Derivative Works of,\r
+      publicly display, publicly perform, sublicense, and distribute the\r
+      Work and such Derivative Works in Source or Object form.\r
+\r
+   3. Grant of Patent License. Subject to the terms and conditions of\r
+      this License, each Contributor hereby grants to You a perpetual,\r
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+      (except as stated in this section) patent license to make, have made,\r
+      use, offer to sell, sell, import, and otherwise transfer the Work,\r
+      where such license applies only to those patent claims licensable\r
+      by such Contributor that are necessarily infringed by their\r
+      Contribution(s) alone or by combination of their Contribution(s)\r
+      with the Work to which such Contribution(s) was submitted. If You\r
+      institute patent litigation against any entity (including a\r
+      cross-claim or counterclaim in a lawsuit) alleging that the Work\r
+      or a Contribution incorporated within the Work constitutes direct\r
+      or contributory patent infringement, then any patent licenses\r
+      granted to You under this License for that Work shall terminate\r
+      as of the date such litigation is filed.\r
+\r
+   4. Redistribution. You may reproduce and distribute copies of the\r
+      Work or Derivative Works thereof in any medium, with or without\r
+      modifications, and in Source or Object form, provided that You\r
+      meet the following conditions:\r
+\r
+      (a) You must give any other recipients of the Work or\r
+          Derivative Works a copy of this License; and\r
+\r
+      (b) You must cause any modified files to carry prominent notices\r
+          stating that You changed the files; and\r
+\r
+      (c) You must retain, in the Source form of any Derivative Works\r
+          that You distribute, all copyright, patent, trademark, and\r
+          attribution notices from the Source form of the Work,\r
+          excluding those notices that do not pertain to any part of\r
+          the Derivative Works; and\r
+\r
+      (d) If the Work includes a "NOTICE" text file as part of its\r
+          distribution, then any Derivative Works that You distribute must\r
+          include a readable copy of the attribution notices contained\r
+          within such NOTICE file, excluding those notices that do not\r
+          pertain to any part of the Derivative Works, in at least one\r
+          of the following places: within a NOTICE text file distributed\r
+          as part of the Derivative Works; within the Source form or\r
+          documentation, if provided along with the Derivative Works; or,\r
+          within a display generated by the Derivative Works, if and\r
+          wherever such third-party notices normally appear. The contents\r
+          of the NOTICE file are for informational purposes only and\r
+          do not modify the License. You may add Your own attribution\r
+          notices within Derivative Works that You distribute, alongside\r
+          or as an addendum to the NOTICE text from the Work, provided\r
+          that such additional attribution notices cannot be construed\r
+          as modifying the License.\r
+\r
+      You may add Your own copyright statement to Your modifications and\r
+      may provide additional or different license terms and conditions\r
+      for use, reproduction, or distribution of Your modifications, or\r
+      for any such Derivative Works as a whole, provided Your use,\r
+      reproduction, and distribution of the Work otherwise complies with\r
+      the conditions stated in this License.\r
+\r
+   5. Submission of Contributions. Unless You explicitly state otherwise,\r
+      any Contribution intentionally submitted for inclusion in the Work\r
+      by You to the Licensor shall be under the terms and conditions of\r
+      this License, without any additional terms or conditions.\r
+      Notwithstanding the above, nothing herein shall supersede or modify\r
+      the terms of any separate license agreement you may have executed\r
+      with Licensor regarding such Contributions.\r
+\r
+   6. Trademarks. This License does not grant permission to use the trade\r
+      names, trademarks, service marks, or product names of the Licensor,\r
+      except as required for reasonable and customary use in describing the\r
+      origin of the Work and reproducing the content of the NOTICE file.\r
+\r
+   7. Disclaimer of Warranty. Unless required by applicable law or\r
+      agreed to in writing, Licensor provides the Work (and each\r
+      Contributor provides its Contributions) on an "AS IS" BASIS,\r
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\r
+      implied, including, without limitation, any warranties or conditions\r
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\r
+      PARTICULAR PURPOSE. You are solely responsible for determining the\r
+      appropriateness of using or redistributing the Work and assume any\r
+      risks associated with Your exercise of permissions under this License.\r
+\r
+   8. Limitation of Liability. In no event and under no legal theory,\r
+      whether in tort (including negligence), contract, or otherwise,\r
+      unless required by applicable law (such as deliberate and grossly\r
+      negligent acts) or agreed to in writing, shall any Contributor be\r
+      liable to You for damages, including any direct, indirect, special,\r
+      incidental, or consequential damages of any character arising as a\r
+      result of this License or out of the use or inability to use the\r
+      Work (including but not limited to damages for loss of goodwill,\r
+      work stoppage, computer failure or malfunction, or any and all\r
+      other commercial damages or losses), even if such Contributor\r
+      has been advised of the possibility of such damages.\r
+\r
+   9. Accepting Warranty or Additional Liability. While redistributing\r
+      the Work or Derivative Works thereof, You may choose to offer,\r
+      and charge a fee for, acceptance of support, warranty, indemnity,\r
+      or other liability obligations and/or rights consistent with this\r
+      License. However, in accepting such obligations, You may act only\r
+      on Your own behalf and on Your sole responsibility, not on behalf\r
+      of any other Contributor, and only if You agree to indemnify,\r
+      defend, and hold each Contributor harmless for any liability\r
+      incurred by, or claims asserted against, such Contributor by reason\r
+      of your accepting any such warranty or additional liability.\r
+\r
+   END OF TERMS AND CONDITIONS\r
+\r
+   APPENDIX: How to apply the Apache License to your work.\r
+\r
+      To apply the Apache License to your work, attach the following\r
+      boilerplate notice, with the fields enclosed by brackets "[]"\r
+      replaced with your own identifying information. (Don't include\r
+      the brackets!)  The text should be enclosed in the appropriate\r
+      comment syntax for the file format. We also recommend that a\r
+      file or class name and description of purpose be included on the\r
+      same "printed page" as the copyright notice for easier\r
+      identification within third-party archives.\r
+\r
+   Copyright [yyyy] [name of copyright owner]\r
+\r
+   Licensed under the Apache License, Version 2.0 (the "License");\r
+   you may not use this file except in compliance with the License.\r
+   You may obtain a copy of the License at\r
+\r
+       http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+   Unless required by applicable law or agreed to in writing, software\r
+   distributed under the License is distributed on an "AS IS" BASIS,\r
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+   See the License for the specific language governing permissions and\r
+   limitations under the License.\r
+\r
diff --git a/hw/board/CMakeLists.txt b/hw/board/CMakeLists.txt
new file mode 100644 (file)
index 0000000..de3acea
--- /dev/null
@@ -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 (file)
index 0000000..56a2d7d
--- /dev/null
@@ -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 <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 </hal/include/device/hal-backend-common.h>
+
+#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 (file)
index 0000000..116adfa
--- /dev/null
@@ -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 (file)
index 0000000..1f11726
--- /dev/null
@@ -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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <linux/limits.h>
+
+#include <hal/device/hal-display-interface.h>
+#include <hal/hal-common-interface.h>
+#include <libsyscommon/file.h>
+
+#include </hal/include/device/hal-backend-common.h>
+
+#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 (file)
index 0000000..d3b5d3c
--- /dev/null
@@ -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 (file)
index 0000000..3d4b20c
--- /dev/null
@@ -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 <stdlib.h>
+#include <glib.h>
+#include <peripheral_io.h>
+#include <libsyscommon/list.h>
+#include <hal/device/hal-haptic-interface.h>
+
+#include </hal/include/device/hal-backend-common.h>
+
+#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 (file)
index 0000000..a35248a
--- /dev/null
@@ -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 (file)
index 0000000..90157ab
--- /dev/null
@@ -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 <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+
+#include <hal/device/hal-memory-interface.h>
+#include <hal/hal-common-interface.h>
+
+#include </hal/include/device/hal-backend-common.h>
+
+#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 (file)
index 0000000..197833c
--- /dev/null
@@ -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 (file)
index 0000000..903e7d2
--- /dev/null
@@ -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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <glib.h>
+
+#include <hal/device/hal-thermal-interface.h>
+#include <hal/hal-common-interface.h>
+
+#include </hal/include/device/hal-backend-common.h>
+
+#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 (file)
index 0000000..e18741e
--- /dev/null
@@ -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 (file)
index 0000000..ff4e9b8
--- /dev/null
@@ -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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <linux/limits.h>
+#include <dirent.h>
+
+#include <hal/device/hal-touchscreen-interface.h>
+#include <hal/hal-common-interface.h>
+#include <libsyscommon/file.h>
+
+#include </hal/include/device/hal-backend-common.h>
+
+#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 (file)
index 0000000..7146f92
--- /dev/null
@@ -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 (file)
index 0000000..3a35e4f
--- /dev/null
@@ -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 <errno.h>
+#include <stdlib.h>
+
+#include <hal/hal-common-interface.h>
+#include <hal/device/hal-usb_gadget-interface.h>
+
+#include </hal/include/device/hal-backend-common-usb_gadget.h>
+#include </hal/include/device/hal-backend-common.h>
+
+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 (file)
index 0000000..af9b883
--- /dev/null
@@ -0,0 +1,5 @@
+<manifest>\r
+       <request>\r
+               <domain name="_" />\r
+       </request>\r
+</manifest>\r
diff --git a/packaging/hal-backend-device-vim3.spec b/packaging/hal-backend-device-vim3.spec
new file mode 100644 (file)
index 0000000..576a7a0
--- /dev/null
@@ -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