summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSaadi Maalem <saadi.maalem@intel.com>2015-11-02 22:25:51 +0100
committerZhengyin Qian <qianzy@google.com>2015-11-02 14:09:19 -0800
commit4d9b8f68d6614c957803247f5f2970f0d91930c6 (patch)
tree5b59faa5fd522bf0440c7b04fc78b52f3ac9f50a
parentdb6e001aa1a7beff7549d2515946189599487a8f (diff)
downloadsensors-4d9b8f68d6614c957803247f5f2970f0d91930c6.tar.gz
sensor: increase pipe size to avoid pipe overrun
When the HAL writes to the pipe, each sensor sample is 104 bytes. Adjust the pipe size to handle the worst case, where the full FIFO is written to the pipe in one chunk. Change-Id: If04b7246083e199832d31d8d58a37b7a1d3cf220 Signed-off-by: Guillaume Ranquet <guillaumex.ranquet@intel.com>
-rw-r--r--libsensors_iio/src/SensorBase.cpp2
-rw-r--r--libsensors_iio/src/SensorHAL.cpp4
2 files changed, 4 insertions, 2 deletions
diff --git a/libsensors_iio/src/SensorBase.cpp b/libsensors_iio/src/SensorBase.cpp
index c6cb908..e6904e4 100644
--- a/libsensors_iio/src/SensorBase.cpp
+++ b/libsensors_iio/src/SensorBase.cpp
@@ -367,8 +367,6 @@ int SensorBase::FlushData(int)
flush_event_data.type = SENSOR_TYPE_META_DATA;
flush_event_data.version = META_DATA_VERSION;
- usleep(ST_SENSOR_BASE_WAIT_US_BEFORE_SEND_FLUSH);
-
err = write(android_pipe_fd, &flush_event_data, sizeof(sensor_event));
if (err < 0) {
ALOGE("%s: Failed to write flush event data to pipe.", android_name);
diff --git a/libsensors_iio/src/SensorHAL.cpp b/libsensors_iio/src/SensorHAL.cpp
index 90f1931..1bf5018 100644
--- a/libsensors_iio/src/SensorHAL.cpp
+++ b/libsensors_iio/src/SensorHAL.cpp
@@ -690,6 +690,9 @@ static int st_hal_dev_close(struct hw_device_t *dev)
return 0;
}
+
+#define PIPE_SIZE (64 * 1024)
+
/**
* st_hal_create_android_pipe() - Create dev_poll pipe
* @hal_data: hal common data.
@@ -706,6 +709,7 @@ static int st_hal_create_android_pipe(STSensorHAL_data *hal_data)
fcntl(pipe_fd[0], F_SETFL, O_NONBLOCK);
fcntl(pipe_fd[1], F_SETFL, O_NONBLOCK);
+ fcntl(pipe_fd[1], F_SETPIPE_SZ, PIPE_SIZE);
hal_data->android_pollfd.events = POLLIN;
hal_data->android_pollfd.fd = pipe_fd[0];