OSDN Git Service

Add change buffer length option
authorIrina Patru <irina.patru@intel.com>
Fri, 17 Jul 2015 13:04:48 +0000 (16:04 +0300)
committerbuildslave <sys_buildbot@intel.com>
Fri, 17 Jul 2015 19:46:42 +0000 (19:46 +0000)
Some samples were lost in userspace because the FIFO
size was 2 and sometimes they were overwritten before
they were read.
The buffer length is now configurable from HALD using
system prop and the default value is increased to 16.

Tracked-On: https://jira01.devtools.intel.com/browse/GMINL-13814
Change-Id: I7aed65942005fb14691a4239cd3e389b53037208
Signed-off-by: Irina Patru <irina.patru@intel.com>
Reviewed-on: https://android.intel.com:443/391412

common.h
enumeration.c

index aa2951a..9858758 100644 (file)
--- a/common.h
+++ b/common.h
@@ -18,6 +18,7 @@
 
 #define CHANNEL_PATH           BASE_PATH "scan_elements/"
 #define ENABLE_PATH            BASE_PATH "buffer/enable"
+#define BUFFER_LENGTH_PATH     BASE_PATH "buffer/length"
 #define NAME_PATH              BASE_PATH "name"
 #define TRIGGER_PATH           BASE_PATH "trigger/current_trigger"
 #define EVENTS_PATH            BASE_PATH "events/"
index 041196d..1aa6f51 100644 (file)
@@ -225,6 +225,9 @@ unsigned int catalog_size = ARRAY_SIZE(sensor_catalog);
 #define PANEL_FRONT    4
 #define PANEL_BACK     5
 
+/* Buffer default length */
+#define BUFFER_LENGTH  16
+
 /* We equate sensor handles to indices in these tables */
 
 struct sensor_t        sensor_desc[MAX_SENSORS];       /* Android-level descriptors */
@@ -489,6 +492,7 @@ static int add_sensor (int dev_num, int catalog_index, int mode)
        int num_channels;
        char suffix[MAX_NAME_SIZE + 8];
        int calib_bias;
+       int buffer_length;
 
        if (sensor_count == MAX_SENSORS) {
                ALOGE("Too many sensors!\n");
@@ -565,6 +569,19 @@ static int add_sensor (int dev_num, int catalog_index, int mode)
                                sysfs_write_int(sysfs_path, calib_bias);
                        }
 
+       /* Change buffer length according to the property or use default value */
+       if (mode == MODE_TRIGGER) {
+                if (sensor_get_prop(s, "buffer_length", &buffer_length)) {
+                        buffer_length = BUFFER_LENGTH;
+                }
+
+                sprintf(sysfs_path, BUFFER_LENGTH_PATH, dev_num);
+
+                if (sysfs_write_int(sysfs_path, buffer_length) <= 0) {
+                        ALOGE("Failed to set buffer length on dev%d", dev_num);
+                }
+        }
+
        /* Read name attribute, if available */
        sprintf(sysfs_path, NAME_PATH, dev_num);
        sysfs_read_str(sysfs_path, sensor[s].internal_name, MAX_NAME_SIZE);