OSDN Git Service

GMINL-7944: Add quirks for disabling data acquisition methods
authorPatrick Porlan <patrick.porlan@intel.com>
Mon, 13 Apr 2015 15:05:17 +0000 (17:05 +0200)
committerAdriana Reus <adriana.reus@intel.com>
Wed, 15 Apr 2015 14:42:25 +0000 (17:42 +0300)
The current LTR-301 ALS driver is not exposing any events, but
expose channels, so we try to use it in trigger mode, only to
fail because it's not exposing any trigger name and doesn't
accept the default one (at least on ECS 10 edu, since no data
ready line is allocated). So let's force it to polling for now.

Change-Id: I910e0e52ebba536b81b0071dc9a201d11b846b35
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
description.c
description.h
enumeration.c
iio-sensors.txt

index 31b55f8..6a3bec1 100644 (file)
@@ -377,6 +377,15 @@ uint32_t sensor_get_quirks (int s)
                if (strstr(quirks_buf, "spotty"))
                        sensor[s].quirks |= QUIRK_SPOTTY;
 
+               if (strstr(quirks_buf, "no-event"))
+                       sensor[s].quirks |= QUIRK_NO_EVENT_MODE;
+
+               if (strstr(quirks_buf, "no-trig"))
+                       sensor[s].quirks |= QUIRK_NO_TRIG_MODE;
+
+               if (strstr(quirks_buf, "no-poll"))
+                       sensor[s].quirks |= QUIRK_NO_POLL_MODE;
+
                sensor[s].quirks |= QUIRK_ALREADY_DECODED;
        }
 
index 9dffeec..3e0a724 100644 (file)
 #define QUIRK_NOISY            0x10  /* High noise level on readings         */
 #define QUIRK_FORCE_CONTINUOUS 0x20  /* Force usage of continuous trigger    */
 #define QUIRK_BIASED           0x40  /* Biased sensor, requires compensation */
-#define QUIRK_SPOTTY           0x80  /* Driver may lose events */
+#define QUIRK_SPOTTY           0x80  /* Driver may lose events               */
+#define QUIRK_NO_EVENT_MODE    0x100 /* Disable event mode                   */
+#define QUIRK_NO_TRIG_MODE     0x200 /* Disable trigger mode                 */
+#define QUIRK_NO_POLL_MODE     0x400 /* Disable poll mode                    */
 
 #ifdef __LP64__
        typedef uint64_t        flag_t;
index 0d744a9..c4e8ead 100644 (file)
@@ -446,7 +446,7 @@ static void add_virtual_sensor (int catalog_index)
 }
 
 
-static void add_sensor (int dev_num, int catalog_index, int mode)
+static int add_sensor (int dev_num, int catalog_index, int mode)
 {
        int s;
        int sensor_type;
@@ -463,7 +463,7 @@ static void add_sensor (int dev_num, int catalog_index, int mode)
 
        if (sensor_count == MAX_SENSORS) {
                ALOGE("Too many sensors!\n");
-               return;
+               return -1;
        }
 
        sensor_type = sensor_catalog[catalog_index].type;
@@ -488,6 +488,17 @@ static void add_sensor (int dev_num, int catalog_index, int mode)
         else
                 sensor[s].num_channels = num_channels;
 
+       /* Populate the quirks array */
+       sensor_get_quirks(s);
+
+       /* Reject interfaces that may have been disabled through a quirk for this driver */
+       if ((mode == MODE_EVENT   && (sensor[s].quirks & QUIRK_NO_EVENT_MODE)) ||
+           (mode == MODE_TRIGGER && (sensor[s].quirks & QUIRK_NO_TRIG_MODE )) ||
+            (mode == MODE_POLL    && (sensor[s].quirks & QUIRK_NO_POLL_MODE ))) {
+               memset(&sensor[s], 0, sizeof(sensor[0]));
+               return -1;
+       }
+
        prefix = sensor_catalog[catalog_index].tag;
 
        /*
@@ -621,9 +632,6 @@ static void add_sensor (int dev_num, int catalog_index, int mode)
 
        populate_descriptors(s, sensor_type);
 
-       /* Populate the quirks array */
-       sensor_get_quirks(s);
-
        if (sensor[s].internal_name[0] == '\0') {
                /*
                 * In case the kernel-mode driver doesn't expose a name for
@@ -667,6 +675,7 @@ static void add_sensor (int dev_num, int catalog_index, int mode)
        sensor[s].needs_enable = get_needs_enable(dev_num, sensor_catalog[catalog_index].tag);
 
        sensor_count++;
+       return 0;
 }
 
 static void virtual_sensors_check (void)
@@ -881,19 +890,19 @@ void enumerate_sensors (void)
                discover_sensors(dev_num, EVENTS_PATH, event_sensors, check_event_sensors);
 
                for (i=0; i<catalog_size; i++) {
-                       if (event_sensors[i]) {
-                               add_sensor(dev_num, i, MODE_EVENT);
+                       /* Try using events interface */
+                       if (event_sensors[i] && !add_sensor(dev_num, i, MODE_EVENT))
                                continue;
-                       }
-                       if (trig_sensors[i]) {
-                               add_sensor(dev_num, i, MODE_TRIGGER);
+
+                       /* Then trigger */
+                       if (trig_sensors[i] && !add_sensor(dev_num, i, MODE_TRIGGER)) {
                                trig_found = 1;
                                continue;
                        }
-                       if (poll_sensors[i]) {
+
+                       /* Try polling otherwise */
+                       if (poll_sensors[i])
                                add_sensor(dev_num, i, MODE_POLL);
-                               continue;
-                       }
                }
 
                if (trig_found)
index 4d44b35..9add4ec 100644 (file)
@@ -152,6 +152,9 @@ continuous    : disable use of motion trigger even if the sensor supports it
 init-rate     : set sampling rate at 10 Hz after enabling that sensor
 biased        : the sensor has unusually high bias ; engage high bias detection and compensation routines
 spotty        : the sensor may have gaps in its events sequence ; adjust timestamps accordingly
+no-poll       : specifically disable the iio polling (sysfs) way of getting data from this driver, even if it's seemingly available
+no-trig       : specifically disable the iio trigger way of getting data from this driver, even if it's seemingly available
+no-event      : specifically disable the iio event way of getting data from this driver, even if it's seemingly available
 
 
 FILTERING