diff options
author | Gwendal Grignou <gwendal@chromium.org> | 2018-11-27 12:50:42 -0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-05-30 05:56:41 +0000 |
commit | f81d843fe25267a1660d1e45c0f593fa310f79d9 (patch) | |
tree | 7410a86cd60992129c67c066fd71f5242a439516 /include | |
parent | 0aee48bdaab94faf674daa69b327d9a6675090a1 (diff) | |
download | chrome-ec-f81d843fe25267a1660d1e45c0f593fa310f79d9.tar.gz |
sensor: Adjust max_frequency based on EC performance
Put in max_frequency a value that the sensor AND the EC support.
BRANCH=none
BUG=b:118205424,b:118851581,chromium:615059
TEST=Compile. Check all max sensors frequencies have been altered with:
for i in $(grep -rh max_frequency board | cut -d '=' -f 2 | sort | \
uniq | grep FREQ | sed 's/FREQ.*//') ; do
echo -n $i ; git show | grep -q $i || break;
echo check
done
Check on nocturne accel max frequency is still correct.
(cherry picked from commit 77b306b340ca428ba6785add204ccdce82185274)
Conflicts:
driver/mag_lis2mdl.h : driver not present yet.
include/config.h : added defines.
Reviewed-on: https://chromium-review.googlesource.com/1352063
Commit-Ready: Elthan Huang <elthan_huang@compal.corp-partner.google.com>
Reviewed-by: Jesse Schettler <jschettler@chromium.org>
Reviewed-by: Jett Rink <jettrink@chromium.org>
Reviewed-by: Justin TerAvest <teravest@chromium.org>
Change-Id: I848396d9f150a2e94d430a8feeafc1087a6bf2c3
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1621506
Reviewed-by: Enrico Granata <egranata@chromium.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/config.h | 4 | ||||
-rw-r--r-- | include/motion_sense.h | 10 | ||||
-rw-r--r-- | include/util.h | 6 |
3 files changed, 16 insertions, 4 deletions
diff --git a/include/config.h b/include/config.h index fb71433a05..0d1bca56c7 100644 --- a/include/config.h +++ b/include/config.h @@ -1150,8 +1150,8 @@ /* Support EC to Internal bus bridge. */ #undef CONFIG_EC2I -/* Usually, EC capable of sensor speeds up to 200000 mHz */ -#define CONFIG_EC_MAX_SENSOR_FREQ_DEFAULT_MILLIHZ 200000 +/* Usually, EC capable of sensor speeds up to 250 Hz */ +#define CONFIG_EC_MAX_SENSOR_FREQ_DEFAULT_MILLIHZ 250000 /* Maximal EC sampling rate */ #undef CONFIG_EC_MAX_SENSOR_FREQ_MILLIHZ diff --git a/include/motion_sense.h b/include/motion_sense.h index 7b574e37f7..326c8a13b6 100644 --- a/include/motion_sense.h +++ b/include/motion_sense.h @@ -51,6 +51,16 @@ enum sensor_config { #define MAX_FIFO_EVENT_COUNT 0 #endif +/* + * Define the frequency to use in max_frequency based on the maximal frequency + * the sensor support and what the EC can provide. + * Return a frequency the sensor supports. + * Trigger a compilation error when the EC way to slow for the sensor. + */ +#define MOTION_MAX_SENSOR_FREQUENCY(_max, _step) GENERIC_MIN( \ + (_max) / (CONFIG_EC_MAX_SENSOR_FREQ_MILLIHZ >= (_step)), \ + (_step) << __fls(CONFIG_EC_MAX_SENSOR_FREQ_MILLIHZ / (_step))) + struct motion_data_t { /* * data rate the sensor will measure, in mHz: 0 suspended. diff --git a/include/util.h b/include/util.h index c8ae09db93..fe66936cf4 100644 --- a/include/util.h +++ b/include/util.h @@ -16,13 +16,15 @@ #include <stddef.h> /* Standard macros / definitions */ +#define GENERIC_MAX(x, y) ((x) > (y) ? (x) : (y)) +#define GENERIC_MIN(x, y) ((x) < (y) ? (x) : (y)) #ifndef MAX #define MAX(a, b) \ ({ \ __typeof__(a) temp_a = (a); \ __typeof__(b) temp_b = (b); \ \ - temp_a > temp_b ? temp_a : temp_b; \ + GENERIC_MAX(temp_a, temp_b); \ }) #endif #ifndef MIN @@ -31,7 +33,7 @@ __typeof__(a) temp_a = (a); \ __typeof__(b) temp_b = (b); \ \ - temp_a < temp_b ? temp_a : temp_b; \ + GENERIC_MIN(temp_a, temp_b); \ }) #endif #ifndef NULL |