summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRicardo Cerqueira <cyanogenmod@cerqueira.org>2011-02-08 02:25:18 +0000
committerRicardo Cerqueira <cyanogenmod@cerqueira.org>2012-11-23 01:02:04 +0000
commitd72b7ba66fdeb88bcbb63b0049e9bd38f88f0e28 (patch)
tree620e8a784ba1ebfa20cbe1ac1a7ceb2879c01e12
parentff8e103bae6deafbce4bfc2b4bedcada6f0b7752 (diff)
downloadhardware_libhardware_legacy-d72b7ba66fdeb88bcbb63b0049e9bd38f88f0e28.zip
hardware_libhardware_legacy-d72b7ba66fdeb88bcbb63b0049e9bd38f88f0e28.tar.gz
hardware_libhardware_legacy-d72b7ba66fdeb88bcbb63b0049e9bd38f88f0e28.tar.bz2
hardware_legacy: allow alternative vibrator implementations
The native vibrator code in libhardware_legacy assumes the vibrator is always controlled by inputting timers into sysfs (at /sys/class/timed_output/vibrator/enable). This isn't necessarily true, there's an upcoming device which has the vibrator controlled by ioctl() calls. This patch lets the device configuration specify an alternative vibrator implementation throught the variable BOARD_HAS_VIBRATOR_IMPLEMENTATION That variable should point to a sourcefile that implements the vibrator "int sendit(timeout_ms)" function, like this: BOARD_HAS_VIBRATOR_IMPLEMENTATION := ../../device/vendor/model/vibrator.c Change-Id: I78d60480f87ef00a0bab096d7f42e47501def936
-rw-r--r--vibrator/Android.mk5
-rw-r--r--vibrator/vibrator.c7
2 files changed, 12 insertions, 0 deletions
diff --git a/vibrator/Android.mk b/vibrator/Android.mk
index 6681f84..6f7e262 100644
--- a/vibrator/Android.mk
+++ b/vibrator/Android.mk
@@ -2,3 +2,8 @@
LOCAL_SRC_FILES += vibrator/vibrator.c
+## Must point to a source file that implements the sendit() function
+ifneq ($(BOARD_HAS_VIBRATOR_IMPLEMENTATION),)
+ LOCAL_SRC_FILES += $(BOARD_HAS_VIBRATOR_IMPLEMENTATION)
+ LOCAL_CFLAGS += -DUSE_ALTERNATIVE_VIBRATOR
+endif
diff --git a/vibrator/vibrator.c b/vibrator/vibrator.c
index f946ce1..b1c98eb 100644
--- a/vibrator/vibrator.c
+++ b/vibrator/vibrator.c
@@ -21,6 +21,11 @@
#include <fcntl.h>
#include <errno.h>
+
+#ifdef USE_ALTERNATIVE_VIBRATOR
+extern int sendit(int timeout_ms);
+#else
+
#define THE_DEVICE "/sys/class/timed_output/vibrator/enable"
int vibrator_exists()
@@ -63,6 +68,8 @@ static int sendit(int timeout_ms)
return (ret == nwr) ? 0 : -1;
}
+#endif
+
int vibrator_on(int timeout_ms)
{
/* constant on, up to maximum allowed time */