/*
- * Copyright (C) 2014 Intel Corporation.
+ * Copyright (C) 2014-2015 Intel Corporation.
*/
#include <stdlib.h>
#define MIN_ON_CHANGE_SAMPLING_PERIOD_US 200000 /* For on change sensors (temperature, proximity, ALS, etc.) report we support 5 Hz max (0.2 s min period) */
#define MAX_ON_CHANGE_SAMPLING_PERIOD_US 10000000 /* 0.1 Hz min (10 s max period)*/
+#define ANDROID_MAX_FREQ 1000 /* 1000 Hz - This is how much Android requests for the fastest frequency */
/*
* About properties
/* Fall back to simple form, like ro.iio.anglvel.name */
- sprintf(prop_name, PROP_BASE, prefix, sel);
+ snprintf(prop_name, PROP_NAME_MAX, PROP_BASE, prefix, sel);
if (property_get(prop_name, prop_val, "")) {
strncpy(val, prop_val, MAX_NAME_SIZE-1);
/* We should cap returned samples accordingly... */
- switch (sensor[s].type) {
+ switch (sensor_desc[s].type) {
case SENSOR_TYPE_ACCELEROMETER: /* m/s^2 */
return 50;
if (!sensor_get_fl_prop(s, "max_freq", &max_freq))
return max_freq;
- return 1000;
+ return ANDROID_MAX_FREQ;
}
int sensor_get_cal_steps (int s)
if (strstr(quirks_buf, "noisy"))
sensor[s].quirks |= QUIRK_NOISY;
+ if (strstr(quirks_buf, "biased"))
+ sensor[s].quirks |= QUIRK_BIASED;
+
+ 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;
}
char* sensor_get_string_type (int s)
{
- switch (sensor[s].type) {
+ switch (sensor_desc[s].type) {
case SENSOR_TYPE_ACCELEROMETER:
return SENSOR_STRING_TYPE_ACCELEROMETER;
{
flag_t flags = 0;
- switch (sensor[s].type) {
+ switch (sensor_desc[s].type) {
case SENSOR_TYPE_LIGHT:
case SENSOR_TYPE_AMBIENT_TEMPERATURE:
case SENSOR_TYPE_TEMPERATURE:
case SENSOR_TYPE_RELATIVE_HUMIDITY:
+ case SENSOR_TYPE_STEP_COUNTER:
flags |= SENSOR_FLAG_ON_CHANGE_MODE;
break;
flags |= SENSOR_FLAG_WAKE_UP;
flags |= SENSOR_FLAG_ON_CHANGE_MODE;
break;
-
+ case SENSOR_TYPE_STEP_DETECTOR:
+ flags |= SENSOR_FLAG_SPECIAL_REPORTING_MODE;
+ break;
default:
break;
}
static int get_cdd_freq (int s, int must)
{
- switch (sensor[s].type) {
+ switch (sensor_desc[s].type) {
case SENSOR_TYPE_ACCELEROMETER:
return (must ? 100 : 200); /* must 100 Hz, should 200 Hz, CDD compliant */
char freqs_buf[100];
char* cursor;
float max_supported_rate = 0;
+ float max_from_prop = sensor_get_max_freq(s);
float sr;
/* continuous, on change: minimum sampling period allowed in microseconds.
if (sysfs_read_str(avail_sysfs_path, freqs_buf, sizeof(freqs_buf)) < 0) {
if (sensor[s].mode == MODE_POLL) {
- /* The should rate */
- max_supported_rate = get_cdd_freq(s, 0);
+ /* If we have max specified via a property use it */
+ if (max_from_prop != ANDROID_MAX_FREQ)
+ max_supported_rate = max_from_prop;
+ else
+ /* The should rate */
+ max_supported_rate = get_cdd_freq(s, 0);
}
} else {
cursor = freqs_buf;
/* Decode a single value */
sr = strtod(cursor, NULL);
- if (sr > max_supported_rate && sr <= sensor_get_max_freq(s))
+ if (sr > max_supported_rate && sr <= max_from_prop)
max_supported_rate = sr;
/* Skip digits */