Add touchsensitivity for HAL 98/200698/2 accepted/tizen/unified/20190311.072449 accepted/tizen/unified/20190312.113038 submit/tizen/20190308.023010 submit/tizen/20190311.073252
authorlokilee73 <changjoo.lee@samsung.com>
Thu, 28 Feb 2019 10:48:37 +0000 (19:48 +0900)
committerlokilee73 <changjoo.lee@samsung.com>
Thu, 28 Feb 2019 10:52:54 +0000 (19:52 +0900)
Change-Id: Ie9fbaf35f8b95dbf14b06211d084ec93fa90baf5
Signed-off-by: lokilee73 <changjoo.lee@samsung.com>
CMakeLists.txt
hw/touchsensitivity/CMakeLists.txt [new file with mode: 0644]
hw/touchsensitivity/touchsensitivity.c [new file with mode: 0644]

index 89092ae..fb224ba 100644 (file)
@@ -10,4 +10,5 @@ ADD_SUBDIRECTORY(hw/touchscreen)
 ADD_SUBDIRECTORY(hw/usb_gadget)
 ADD_SUBDIRECTORY(hw/usb_client)
 ADD_SUBDIRECTORY(hw/thermal)
-ADD_SUBDIRECTORY(hw/bezel)
\ No newline at end of file
+ADD_SUBDIRECTORY(hw/bezel)
+ADD_SUBDIRECTORY(hw/touchsensitivity)
\ No newline at end of file
diff --git a/hw/touchsensitivity/CMakeLists.txt b/hw/touchsensitivity/CMakeLists.txt
new file mode 100644 (file)
index 0000000..7be54da
--- /dev/null
@@ -0,0 +1,19 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(touchsensitivity C)
+
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(touchsensitivity_pkgs REQUIRED hwcommon dlog)
+
+FOREACH(flag ${touchsensitivity_pkgs_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+
+ADD_LIBRARY(${PROJECT_NAME} MODULE touchsensitivity.c)
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${touchsensitivity_pkgs_LDFLAGS})
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES PREFIX "")
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR}/hw COMPONENT RuntimeLibraries)
diff --git a/hw/touchsensitivity/touchsensitivity.c b/hw/touchsensitivity/touchsensitivity.c
new file mode 100644 (file)
index 0000000..343de41
--- /dev/null
@@ -0,0 +1,116 @@
+/*
+ * device-node
+ *
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <linux/limits.h>
+#include <dirent.h>
+
+#include <hw/touchsensitivity.h>
+#include <hw/shared.h>
+
+#define TOUCHSENSITIVITY_GLOVE_MODE_PATH       "/sys/class/sec/tsp/glove_mode"
+
+static int glove_mode_get_state(int *state)
+{
+       int ret, val;
+
+       if (!state)
+               return -EINVAL;
+
+       ret = sys_get_int(TOUCHSENSITIVITY_GLOVE_MODE_PATH, &val);
+       if (ret < 0) {
+               _E("Failed to get touch glove mode state (%d)", ret);
+               return ret;
+       }
+
+       switch (val) {
+       case TOUCHSENSITIVITY_GLOVE_MODE_OFF:
+       case TOUCHSENSITIVITY_GLOVE_MODE_ON:
+               *state = val;
+               break;
+       default:
+               _E("Failed to get touch glove mode state (%d)", val);
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
+static int glove_mode_set_state(int state)
+{
+       int ret, val;
+
+       switch (state) {
+       case TOUCHSENSITIVITY_GLOVE_MODE_OFF:
+       case TOUCHSENSITIVITY_GLOVE_MODE_ON:
+               val = state;
+               break;
+       default:
+               _E("Invalid input (%d)", state);
+               return -EINVAL;
+       }
+
+       ret = sys_set_int(TOUCHSENSITIVITY_GLOVE_MODE_PATH, val);
+       if (ret < 0)
+               _E("Failed to change touch glove mode state (%d)", ret);
+
+       return ret;
+}
+
+static int touchsensitivity_open(struct hw_info *info,
+               const char *id, struct hw_common **common)
+{
+       struct touchsensitivity_device *touchsensitivity_dev;
+
+       if (!info || !common)
+               return -EINVAL;
+
+       touchsensitivity_dev = calloc(1, sizeof(struct touchsensitivity_device));
+       if (!touchsensitivity_dev)
+               return -ENOMEM;
+
+       touchsensitivity_dev->common.info = info;
+       touchsensitivity_dev->glove_mode_get_state = glove_mode_get_state;
+       touchsensitivity_dev->glove_mode_set_state = glove_mode_set_state;
+
+       *common = (struct hw_common *)touchsensitivity_dev;
+       return 0;
+}
+
+static int touchsensitivity_close(struct hw_common *common)
+{
+       if (!common)
+               return -EINVAL;
+
+       free(common);
+       return 0;
+}
+
+HARDWARE_MODULE_STRUCTURE = {
+       .magic = HARDWARE_INFO_TAG,
+       .hal_version = HARDWARE_INFO_VERSION,
+       .device_version = TOUCHSENSITIVITY_HARDWARE_DEVICE_VERSION,
+       .id = TOUCHSENSITIVITY_HARDWARE_DEVICE_ID,
+       .name = "touchsensitivity",
+       .open = touchsensitivity_open,
+       .close = touchsensitivity_close,
+};