From 823fab6b5d92a8433d80687d9c16755b4c09be60 Mon Sep 17 00:00:00 2001 From: Patrick Porlan Date: Mon, 13 Apr 2015 17:05:17 +0200 Subject: [PATCH] GMINL-7944: Add quirks for disabling data acquisition methods 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 --- description.c | 9 +++++++++ description.h | 5 ++++- enumeration.c | 35 ++++++++++++++++++++++------------- iio-sensors.txt | 3 +++ 4 files changed, 38 insertions(+), 14 deletions(-) diff --git a/description.c b/description.c index 31b55f8..6a3bec1 100644 --- a/description.c +++ b/description.c @@ -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; } diff --git a/description.h b/description.h index 9dffeec..3e0a724 100644 --- a/description.h +++ b/description.h @@ -14,7 +14,10 @@ #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; diff --git a/enumeration.c b/enumeration.c index 0d744a9..c4e8ead 100644 --- a/enumeration.c +++ b/enumeration.c @@ -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