diff options
author | Vineeta Srivastava <vsrivastava@google.com> | 2014-08-17 02:31:28 -0700 |
---|---|---|
committer | Vineeta Srivastava <vsrivastava@google.com> | 2014-08-19 21:56:31 +0000 |
commit | 407be7113791428bcfe0d8df79a40390fe0b0d54 (patch) | |
tree | 16f108cc9863a248eb3bd614c3eba98ecfdc565d /power | |
parent | 5c1b1f8663a480733b3b8ef5bcccc880da626475 (diff) | |
download | shamu-407be7113791428bcfe0d8df79a40390fe0b0d54.tar.gz |
shamu: add power hal.
Turn on "double tap" wake up gesture when interactive mode is off.
Chown /sys/bus/i2c/devices/1-004a/tsp to "system"
Bug: 16960142
Change-Id: Ie6eb2b269864044a05241ead62b89c2063caadaa
Diffstat (limited to 'power')
-rw-r--r-- | power/Android.mk | 25 | ||||
-rw-r--r-- | power/power_shamu.c | 92 |
2 files changed, 117 insertions, 0 deletions
diff --git a/power/Android.mk b/power/Android.mk new file mode 100644 index 00000000..96c98b83 --- /dev/null +++ b/power/Android.mk @@ -0,0 +1,25 @@ +# +# Copyright 2014 The Android Open Source Project +# +# 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) + +include $(CLEAR_VARS) +LOCAL_MODULE_RELATIVE_PATH := hw +LOCAL_SRC_FILES := power_shamu.c +LOCAL_SHARED_LIBRARIES := liblog libcutils +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE := power.shamu +include $(BUILD_SHARED_LIBRARY) diff --git a/power/power_shamu.c b/power/power_shamu.c new file mode 100644 index 00000000..63da2ece --- /dev/null +++ b/power/power_shamu.c @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * 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 <string.h> +#include <sys/types.h> +#include <sys/un.h> +#include <fcntl.h> +#include <dlfcn.h> +#include <stdlib.h> +#include <stdbool.h> + +#define LOG_TAG "PowerHAL" +#include <utils/Log.h> + +#include <hardware/hardware.h> +#include <hardware/power.h> + +#define TOUCH_INTERACTIVE_PATH "/sys/bus/i2c/devices/1-004a/tsp" + +static int sysfs_write(const char *path, char *s) +{ + char buf[80]; + int len; + int fd = open(path, O_WRONLY); + + if (fd < 0) { + strerror_r(errno, buf, sizeof(buf)); + ALOGE("Error opening %s: %s\n", path, buf); + return -1; + } + + 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); + return -1; + } + + close(fd); + return 0; +} + +static void power_init(__attribute__((unused)) struct power_module *module) +{ + ALOGI("%s", __func__); +} + +static void power_set_interactive(__attribute__((unused)) struct power_module *module, int on) +{ + ALOGV("%s %s", __func__, (on ? "ON" : "OFF")); + sysfs_write(TOUCH_INTERACTIVE_PATH, on ? "AUTO" : "ON"); +} + +static void power_hint( __attribute__((unused)) struct power_module *module, + __attribute__((unused)) power_hint_t hint, + __attribute__((unused)) 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 = "Shamu Power HAL", + .author = "The Android Open Source Project", + .methods = &power_module_methods, + }, + + .init = power_init, + .setInteractive = power_set_interactive, + .powerHint = power_hint, +}; |