* 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 */
-
- if (!(sensor_get_quirks(s) & QUIRK_HRTIMER)) {
+ } else {
arb_sampling_rate = select_closest_available_rate(s, arb_sampling_rate);
}
-
/* Record the rate that was agreed upon with the sensor taken in isolation ; this avoid uncontrolled ripple effects between colocated sensor rates */
sensor[s].semi_arbitrated_rate = arb_sampling_rate;
if (trig_sensors_per_dev[dev_num])
enable_buffer(dev_num, 0);
- if (sensor_get_quirks(s) & QUIRK_HRTIMER) {
+ if (sensor[s].hrtimer_trigger_name[0] != '\0') {
sysfs_write_float(sysfs_path, select_closest_available_rate(s, arb_sampling_rate));
} else {
sysfs_write_float(sysfs_path, arb_sampling_rate);
return 0;
}
-static float sensor_get_min_freq (int s)
+float sensor_get_min_freq (int s)
{
/*
* Check if a low cap has been specified for this sensor sampling rate.
switch (sensor[s].mode) {
case MODE_TRIGGER:
/* For interrupt-based devices, obey the list of supported sampling rates */
- if (!(sensor_get_quirks(s) & QUIRK_HRTIMER) &&
- sensor[s].avail_freqs_count) {
+ if (sensor[s].avail_freqs_count) {
min_supported_rate = 1000;
for (i = 0; i < sensor[s].avail_freqs_count; i++) {
if (sensor[s].avail_freqs[i] < min_supported_rate)
return (max_delay_t) (1000000.0 / min_supported_rate);
}
+float sensor_get_max_static_freq(int s)
+{
+ float max_from_prop = sensor_get_max_freq(s);
+
+ /* If we have max specified via a property use it */
+ if (max_from_prop != ANDROID_MAX_FREQ) {
+ return max_from_prop;
+ } else {
+ /* The should rate */
+ return get_cdd_freq(s, 0);
+ }
+}
int32_t sensor_get_min_delay (int s)
{
int dev_num = sensor[s].dev_num, i;
float max_supported_rate = 0;
float max_from_prop = sensor_get_max_freq(s);
- int hrtimer_quirk_enabled = sensor_get_quirks(s) & QUIRK_HRTIMER;
/* continuous, on change: minimum sampling period allowed in microseconds.
* special : 0, unless otherwise noted
}
}
- if (hrtimer_quirk_enabled || !sensor[s].avail_freqs_count) {
- if (hrtimer_quirk_enabled || (sensor[s].mode == MODE_POLL)) {
+ if (!sensor[s].avail_freqs_count) {
+ if (sensor[s].mode == MODE_POLL) {
/* If we have max specified via a property use it */
if (max_from_prop != ANDROID_MAX_FREQ)
max_supported_rate = max_from_prop;
}
}
+extern float sensor_get_max_static_freq(int s);
+extern float sensor_get_min_freq (int s);
+
static int create_hrtimer_trigger(int s, int trigger)
{
struct stat dir_status;
char buf[MAX_NAME_SIZE];
char hrtimer_path[PATH_MAX];
char hrtimer_name[MAX_NAME_SIZE];
+ float min_supported_rate = 1, min_rate_cap, max_supported_rate;
snprintf(buf, MAX_NAME_SIZE, "hrtimer-%s-hr-dev%d", sensor[s].internal_name, sensor[s].dev_num);
snprintf(hrtimer_name, MAX_NAME_SIZE, "%s-hr-dev%d", sensor[s].internal_name, sensor[s].dev_num);
strncpy (sensor[s].hrtimer_trigger_name, hrtimer_name, MAX_NAME_SIZE);
sensor[s].trigger_nr = trigger;
+
+ max_supported_rate = sensor_get_max_static_freq(s);
+
+ /* set 0 for wrong values */
+ if (max_supported_rate < 0.1) {
+ max_supported_rate = 0;
+ }
+
+ sensor[s].max_supported_rate = max_supported_rate;
+ sensor_desc[s].minDelay = max_supported_rate ? (int32_t) (1000000.0 / max_supported_rate) : 0;
+
+ /* Check if a minimum rate was specified for this sensor */
+ min_rate_cap = sensor_get_min_freq(s);
+
+ if (min_supported_rate < min_rate_cap) {
+ min_supported_rate = min_rate_cap;
+ }
+
+ sensor[s].min_supported_rate = min_supported_rate;
+ sensor_desc[s].maxDelay = (max_delay_t) (1000000.0 / min_supported_rate);
+
return 0;
}