/*
- * Copyright (C) 2014-2015 Intel Corporation.
- */
+// Copyright (c) 2015 Intel Corporation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+*/
#include <stdlib.h>
#include <ctype.h>
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.
}
}
-/*
+/*
* This value is defined only for continuous mode and on-change sensors. It is the delay between two sensor events corresponding to the lowest frequency that
* this sensor supports. When lower frequencies are requested through batch()/setDelay() the events will be generated at this frequency instead. It can be used
* by the framework or applications to estimate when the batch FIFO may be full. maxDelay should always fit within a 32 bit signed integer. It is declared as
*/
max_delay_t sensor_get_max_delay (int s)
{
- int dev_num = sensor[s].dev_num, i;
+ int i;
float min_supported_rate;
float rate_cap;
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;
+ int 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;