OSDN Git Service

Ignore avail freqs when the hrtimer trigger is selected
authorConstantin Musca <constantin.musca@intel.com>
Fri, 7 Aug 2015 16:55:35 +0000 (19:55 +0300)
committerbuildslave <sys_buildbot@intel.com>
Mon, 10 Aug 2015 11:23:22 +0000 (11:23 +0000)
Setting the hrtimer quirk doesn't mean that the hrtimer
trigger will be selected.
Remove the hrtimer quirk checks and reset the freqs
without considering avail freqs in the create_hrtimer_trigger
function.

Change-Id: I0c45b024664768fe2a7f4d7d6ca57859f44c028d
Tracked-On: https://jira01.devtools.intel.com/browse/GMINL-15776
Signed-off-by: Constantin Musca <constantin.musca@intel.com>
Reviewed-on: https://android.intel.com:443/398640

control.c
description.c
enumeration.c

index da228ee..1a5cd4d 100644 (file)
--- a/control.c
+++ b/control.c
@@ -859,15 +859,10 @@ static int sensor_set_rate (int s, float requested_rate)
                 * 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;
 
@@ -901,7 +896,7 @@ static int sensor_set_rate (int s, float requested_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);
index b5a72f0..28a3533 100644 (file)
@@ -294,7 +294,7 @@ float sensor_get_max_range (int s)
        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.
@@ -681,8 +681,7 @@ max_delay_t sensor_get_max_delay (int s)
        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)
@@ -712,13 +711,24 @@ max_delay_t sensor_get_max_delay (int s)
        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
@@ -748,8 +758,8 @@ int32_t sensor_get_min_delay (int s)
                }
        }
 
-       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;
index d5c8b5a..5aec685 100644 (file)
@@ -882,12 +882,16 @@ static void update_sensor_matching_trigger_name (char name[MAX_NAME_SIZE], int*
                }
 }
 
+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);
@@ -904,6 +908,27 @@ static int create_hrtimer_trigger(int s, int trigger)
 
        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;
 }