int i = sensor[s].catalog_index;
const char *prefix = sensor_catalog[i].tag;
+ const char *shorthand = sensor_catalog[i].shorthand;
/* First try most specialized form, like ro.iio.anglvel.bmg160.name */
return 0;
}
+ if (shorthand[0] != '\0') {
+ /* Try with shorthand instead of prefix */
+ snprintf(prop_name, PROP_NAME_MAX, PROP_BASE, shorthand, extended_sel);
+
+ if (property_get(prop_name, prop_val, "")) {
+ strncpy(val, prop_val, MAX_NAME_SIZE-1);
+ val[MAX_NAME_SIZE-1] = '\0';
+ return 0;
+ }
+ }
/* 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 (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;
+
+ if (strstr(quirks_buf, "hrtimer"))
+ sensor[s].quirks |= QUIRK_HRTIMER;
+
sensor[s].quirks |= QUIRK_ALREADY_DECODED;
}
return 1; /* OK to use modified ordering map */
}
+int sensor_get_mounting_matrix (int s, float mm[9])
+{
+ int dev_num = sensor[s].dev_num, err, i;
+ char mm_path[PATH_MAX], mm_buf[100];
+ char *tmp1 = mm_buf, *tmp2;
+
+ switch (sensor[s].type) {
+ case SENSOR_TYPE_ACCELEROMETER:
+ case SENSOR_TYPE_MAGNETIC_FIELD:
+ case SENSOR_TYPE_GYROSCOPE:
+ break;
+ default:
+ return 0;
+ }
+
+ sprintf(mm_path, MOUNTING_MATRIX_PATH, dev_num);
+
+ err = sysfs_read_str(mm_path, mm_buf, sizeof(mm_buf));
+ if (err < 0)
+ return 0;
+
+ for(i = 0; i < 9; i++) {
+ float f;
+
+ f = strtof(tmp1, &tmp2);
+ if (!f && tmp1 == tmp2)
+ return 0;
+ mm[i] = f;
+ tmp1 = tmp2 + 1;
+ }
+
+ ALOGI("%s: %f %f %f %f %f %f %f %f %f\n", __func__, mm[0], mm[1], mm[2], mm[3], mm[4], mm[5], mm[6], mm[7], mm[8]);
+ return 1;
+}
+
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:
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 */