From 283c4d88c2df000957cba69aa36725368de5cbf1 Mon Sep 17 00:00:00 2001 From: Adriana Reus Date: Thu, 31 Jul 2014 17:37:46 +0300 Subject: [PATCH] Add the ordering flag to the quirks array L introduces a "flags" field in sensor_t to express the reporting mode for a sensor. To avoid confusion, remove the "flags" field from sensor_info_t, that expressed the axes reordering and add it to the quirks array. Change-Id: Ie42f6ef9705572b6f6bf20663268dd56907b21c2 Signed-off-by: Adriana Reus --- common.h | 5 +---- description.c | 6 +++--- description.h | 5 +++-- entry.c | 4 ++-- enumeration.c | 2 +- transform.c | 7 ++++--- 6 files changed, 14 insertions(+), 15 deletions(-) diff --git a/common.h b/common.h index b89199f..d63d3c9 100644 --- a/common.h +++ b/common.h @@ -34,8 +34,6 @@ #define ARRAY_SIZE(x) sizeof(x)/sizeof(x[0]) -#define FLAG_FIELD_ORDERING 0x01 - #ifdef __LP64__ typedef uint64_t flag_t; #else @@ -175,10 +173,9 @@ struct sensor_info_t /* Note: we may have to explicitely serialize access to some fields */ - uint32_t flags; /* - * If the FLAG_FIELD_ORDERING bit is set in flags, the contents of + * If the QUIRK_FIELD_ORDERING bit is set in quirks, the contents of * this array are used in the finalization stage to swap sample fields * before transmitting them to Android ; they form a mapping between * the indices of the input and output arrays: ex: 0123 is identity for diff --git a/description.c b/description.c index b9d5e9f..e630c47 100644 --- a/description.c +++ b/description.c @@ -215,12 +215,12 @@ uint32_t sensor_get_quirks (int s) char quirks_buf[MAX_NAME_SIZE]; /* Read and decode quirks property on first reference */ - if (!(sensor_info[s].quirks & QUIRKS_ALREADY_DECODED)) { + if (!(sensor_info[s].quirks & QUIRK_ALREADY_DECODED)) { quirks_buf[0] = '\0'; sensor_get_st_prop(s, "quirks", quirks_buf); if (strstr(quirks_buf, "init-rate")) - sensor_info[s].quirks |= QUIRKS_INITIAL_RATE; + sensor_info[s].quirks |= QUIRK_INITIAL_RATE; if (strstr(quirks_buf, "terse")) sensor_info[s].quirks |= QUIRK_TERSE_DRIVER; @@ -228,7 +228,7 @@ uint32_t sensor_get_quirks (int s) if (strstr(quirks_buf, "noisy")) sensor_info[s].quirks |= QUIRK_NOISY; - sensor_info[s].quirks |= QUIRKS_ALREADY_DECODED; + sensor_info[s].quirks |= QUIRK_ALREADY_DECODED; } return sensor_info[s].quirks; diff --git a/description.h b/description.h index 40619c1..8807122 100644 --- a/description.h +++ b/description.h @@ -7,8 +7,9 @@ #include "common.h" -#define QUIRKS_ALREADY_DECODED 0x01 /* Sensor quirks have been read */ -#define QUIRKS_INITIAL_RATE 0x02 /* Force initial sensor sampling rate */ +#define QUIRK_ALREADY_DECODED 0x01 /* Sensor quirks have been read */ +#define QUIRK_INITIAL_RATE 0x02 /* Force initial sensor sampling rate */ +#define QUIRK_FIELD_ORDERING 0x04 #define QUIRK_TERSE_DRIVER 0x08 /* Force duplicate events generation */ #define QUIRK_NOISY 0x10 /* High noise level on readings */ diff --git a/entry.c b/entry.c index 2be3acd..df449db 100644 --- a/entry.c +++ b/entry.c @@ -26,14 +26,14 @@ static int activate(struct sensors_poll_device_t* dev, int handle, int enabled) * a workaround for this behavior. We set the initial sampling rate to * 10 events per second when the sensor is enabled for the first time. */ - if (enabled && sensor_get_quirks(handle) & QUIRKS_INITIAL_RATE) { + if (enabled && sensor_get_quirks(handle) & QUIRK_INITIAL_RATE) { ALOGI("Forcing initial sampling rate\n"); sensor_activate(handle, 1); sensor_set_delay(handle, 100000000L); /* Start with 100 ms */ sensor_activate(handle, 0); /* Clear flag for this sensor as do this only once */ - sensor_info[handle].quirks ^= QUIRKS_INITIAL_RATE; + sensor_info[handle].quirks ^= QUIRK_INITIAL_RATE; } return sensor_activate(handle, enabled); diff --git a/enumeration.c b/enumeration.c index f60d126..852f4d4 100644 --- a/enumeration.c +++ b/enumeration.c @@ -212,7 +212,7 @@ static void add_sensor (int dev_num, int catalog_index, int use_polling) /* Check if we have a special ordering property on this sensor */ if (sensor_get_order(s, sensor_info[s].order)) - sensor_info[s].flags |= FLAG_FIELD_ORDERING; + sensor_info[s].quirks |= QUIRK_FIELD_ORDERING; sensor_count++; } diff --git a/transform.c b/transform.c index bce192b..e8fa707 100644 --- a/transform.c +++ b/transform.c @@ -7,10 +7,11 @@ #include #include #include +#include "calibration.h" #include "common.h" +#include "description.h" #include "transform.h" #include "utils.h" -#include "calibration.h" /*----------------------------------------------------------------------------*/ @@ -193,7 +194,7 @@ static int finalize_sample_default(int s, struct sensors_event_t* data) int sensor_type = sensor_catalog[i].type; /* Swap fields if we have a custom channel ordering on this sensor */ - if (sensor_info[s].flags & FLAG_FIELD_ORDERING) + if (sensor_info[s].quirks & QUIRK_FIELD_ORDERING) reorder_fields(data->data, sensor_info[s].order); switch (sensor_type) { @@ -255,7 +256,7 @@ static int finalize_sample_ISH(int s, struct sensors_event_t* data) float pitch, roll, yaw; /* Swap fields if we have a custom channel ordering on this sensor */ - if (sensor_info[s].flags & FLAG_FIELD_ORDERING) + if (sensor_info[s].quirks & QUIRK_FIELD_ORDERING) reorder_fields(data->data, sensor_info[s].order); if (sensor_type == SENSOR_TYPE_ORIENTATION) { -- 2.11.0