aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlberto96 <albertoguanti@gmail.com>2015-09-10 18:48:51 +0200
committerGerrit Code Review <gerrit@cyanogenmod.org>2015-09-10 10:43:06 -0700
commitb456198a9b9d3411882c172007c4bee254881925 (patch)
tree592afa8383ff52df308bd31372473e6b07b03806
parent7c7fd5d44faf9f9aebce795cbe847705d807b9e2 (diff)
i9500: Add touchkey disabler power HAL
* Disable touchkeys/touchscreen/gpio-keys when display is blanked. Change-Id: Ic5e2cba1c8884f38acdf2ccf478ecb3d41b5207d
-rw-r--r--i9500.mk4
-rw-r--r--power/Android.mk29
-rw-r--r--power/power.c93
3 files changed, 126 insertions, 0 deletions
diff --git a/i9500.mk b/i9500.mk
index a8f5a04..ce9a6a2 100644
--- a/i9500.mk
+++ b/i9500.mk
@@ -152,6 +152,10 @@ PRODUCT_PACKAGES += \
libOMX.Exynos.WMV.Decoder \
libstagefrighthw
+# Power
+PRODUCT_PACKAGES += \
+ power.universal5410
+
# Radio
PRODUCT_PACKAGES += \
libsecril-client \
diff --git a/power/Android.mk b/power/Android.mk
new file mode 100644
index 0000000..c382b3f
--- /dev/null
+++ b/power/Android.mk
@@ -0,0 +1,29 @@
+# Copyright (C) 2015, The CyanogenMod Project <http://www.cyanogenmod.org>
+#
+# 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.
+
+LOCAL_PATH := $(call my-dir)
+
+ifeq ($(TARGET_POWERHAL_VARIANT),universal5410)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := power.universal5410
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
+LOCAL_SRC_FILES := power.c
+LOCAL_SHARED_LIBRARIES := liblog
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_SHARED_LIBRARY)
+
+endif # TARGET_POWERHAL_VARIANT == universal5410
diff --git a/power/power.c b/power/power.c
new file mode 100644
index 0000000..daa0be2
--- /dev/null
+++ b/power/power.c
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2015, The CyanogenMod Project <http://www.cyanogenmod.org>
+ *
+ * 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 LOG_TAG "power"
+
+#include <errno.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include <utils/Log.h>
+
+#include <hardware/hardware.h>
+#include <hardware/power.h>
+
+#define PATH_GPIO_KEYS "/sys/class/input/input14/enabled"
+#define PATH_TOUCHKEY "/sys/class/input/input15/enabled"
+#define PATH_TOUCHSCREEN "/sys/class/input/input1/enabled"
+
+static void sysfs_write(char *path, char *s)
+{
+ char buf[80];
+ int len;
+ int fd;
+
+ if (path == NULL)
+ return;
+
+ if ((fd = open(path, O_WRONLY)) < 0) {
+ strerror_r(errno, buf, sizeof(buf));
+ ALOGE("Error opening %s: %s\n", path, buf);
+ return;
+ }
+
+ len = write(fd, s, strlen(s));
+ if (len < 0) {
+ strerror_r(errno, buf, sizeof(buf));
+ ALOGE("Error writing to %s: %s\n", path, buf);
+ }
+
+ close(fd);
+}
+
+static void power_init(struct power_module *module)
+{
+}
+
+static void power_set_interactive(struct power_module *module, int on)
+{
+ ALOGD("%s: %s input devices", __func__, on ? "enabling" : "disabling");
+
+ sysfs_write(PATH_TOUCHSCREEN, on ? "1" : "0");
+ sysfs_write(PATH_TOUCHKEY, on ? "1" : "0");
+ sysfs_write(PATH_GPIO_KEYS, on ? "1" : "0");
+}
+
+static void power_hint(struct power_module *module, power_hint_t hint,
+ void *data)
+{
+}
+
+static struct hw_module_methods_t power_module_methods = {
+ .open = NULL,
+};
+
+struct power_module HAL_MODULE_INFO_SYM = {
+ .common = {
+ .tag = HARDWARE_MODULE_TAG,
+ .module_api_version = POWER_MODULE_API_VERSION_0_2,
+ .hal_api_version = HARDWARE_HAL_API_VERSION,
+ .id = POWER_HARDWARE_MODULE_ID,
+ .name = "JA3G Power Module",
+ .author = "The CyanogenMod Project",
+ .methods = &power_module_methods,
+ },
+
+ .init = power_init,
+ .setInteractive = power_set_interactive,
+ .powerHint = power_hint,
+};