return -ENOSYS;
}
+ if (sensor[s].hrtimer_trigger_name[0] != '\0') {
+ snprintf(trigger_path, PATH_MAX, "%s%s%d/", IIO_DEVICES, "trigger", sensor[s].trigger_nr);
+ snprintf(hrtimer_sampling_path, PATH_MAX, "%s%s", trigger_path, "sampling_frequency");
+ /* Enforce frequency update when software trigger
+ * frequency and current sampling rate are different */
+ if (sysfs_read_float(hrtimer_sampling_path, &sr) != -1 && sr != cur_sampling_rate)
+ cur_sampling_rate = -1;
+ }
+
/* Check if we have contraints on allowed sampling rates */
sprintf(avail_sysfs_path, DEVICE_AVAIL_FREQ_PATH, dev_num);
sr = strtod(cursor, NULL);
/* If this matches the selected rate, we're happy. Have some tolerance for rounding errors and avoid needless jumps to higher rates */
- if (fabs(arb_sampling_rate - sr) <= 0.001) {
+ if (fabs(arb_sampling_rate - sr) <= 0.01) {
arb_sampling_rate = sr;
break;
}
ALOGI("Sensor %d (%s) sampling rate set to %g\n", s, sensor[s].friendly_name, arb_sampling_rate);
- if (sensor[s].hrtimer_trigger_name[0] != '\0') {
- snprintf(trigger_path, PATH_MAX, "%s%s%d/", IIO_DEVICES, "trigger", sensor[s].trigger_nr);
- snprintf (hrtimer_sampling_path, PATH_MAX, "%s%s", trigger_path, "sampling_frequency");
+ if (sensor[s].hrtimer_trigger_name[0] != '\0')
sysfs_write_float(hrtimer_sampling_path, arb_sampling_rate);
- }
if (trig_sensors_per_dev[dev_num])
enable_buffer(dev_num, 0);
sensor[s].report_pending = DATA_TRIGGER;
sensor[s].report_initialized = 1;
- ts_offset += sr_offset;
}
/* Tentatively switch to an any-motion trigger if conditions are met */