From f45e645abfb0e58bd52488ab0e8d1e0a4f2103b2 Mon Sep 17 00:00:00 2001 From: codeworkx Date: Tue, 26 Jul 2011 15:17:02 -0700 Subject: [PATCH] vibrator: fix enabling amp, disable kernel timer Change-Id: Ie575a735a93bf4a5e93b1161cd25a0757ee41b5a --- vibrator/tspdrv.c | 41 +++++++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/vibrator/tspdrv.c b/vibrator/tspdrv.c index 6f218d3..38ae1d3 100644 --- a/vibrator/tspdrv.c +++ b/vibrator/tspdrv.c @@ -28,24 +28,39 @@ int sendit(int timeout_ms) { - int nwr, ret, fd, tspd, tspret; + int nwr, ret, fd, tspd, tspret, actuators; char value[20]; tspd = open(TSPDRV_DEVICE, O_RDWR); - if(tspd < 0) + if(tspd < 0) { LOGE("failed on opening /dev/tspdrv"); + } else { + LOGV("opened device /dev/tspdrv"); + } /* send tspdrv magic number */ tspret = ioctl(tspd, TSPDRV_MAGIC_NUMBER); - if(tspret != 0) + if(tspret != 0) { LOGE("TSPDRV_MAGIC_NUMBER error"); + } else { + LOGV("sent TSPDRV_MAGIC_NUMBER"); + } - /* enable tspdrv amp */ - tspret = ioctl(tspd, TSPDRV_ENABLE_AMP); - if(tspret != 0) - LOGE("failed on enabling AMP"); + /* get number of actuators */ + actuators = ioctl(tspd, TSPDRV_GET_NUM_ACTUATORS); + if(actuators < 0) { + LOGE("TSPDRV_GET_NUM_ACTUATORS error, no actuators available"); + } else { + LOGV("TSPDRV_GET_NUM_ACTUATORS success, actuators = %d", actuators); - close(tspd); + /* enable tspdrv amp */ + tspret = ioctl(tspd, TSPDRV_ENABLE_AMP, actuators); + if(tspret != 0) { + LOGE("failed on enabling AMP"); + } else { + LOGV("enabled AMP"); + } + } fd = open(THE_DEVICE, O_RDWR); if(fd < 0) @@ -56,5 +71,15 @@ int sendit(int timeout_ms) close(fd); + /* stop tspdrv kernel timer */ + tspret = ioctl(tspd, TSPDRV_STOP_KERNEL_TIMER); + if(tspret != 0) { + LOGE("failed on stopping kernel timer"); + } else { + LOGV("stopped kernel timer"); + } + + close(tspd); + return (ret == nwr) ? 0 : -1; }