From a80f4c9fdecfa1c44ae12dfd2f7abf19e974ec57 Mon Sep 17 00:00:00 2001 From: Patrick Porlan Date: Wed, 11 Feb 2015 10:40:36 +0100 Subject: [PATCH] IRDA-3621: Fix a bug where accel and gyro get stuck at 200 Hz This is happening on Malata because the MPU-6050 driver exposes both the accel and gyro on the same iio device, with a single frequency knob for both. With the current code the accel would be bumped up to 200 Hz if the gyro was configured at 200 Hz, but would not go back when a lower sampling rate was selected because the accel would appear to require 200 Hz. Change-Id: Ied0c1c94c278be180a22fd537f8e82f0e8f7adbd Signed-off-by: Patrick Porlan --- common.h | 1 + control.c | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/common.h b/common.h index 156edac..98aa4c9 100644 --- a/common.h +++ b/common.h @@ -274,6 +274,7 @@ typedef struct */ int needs_enable; + int semi_arbitrated_rate; /* Arbitrated sampling rate before we considered other sensors co-located on the same iio device */ } sensor_info_t; diff --git a/control.c b/control.c index dfd9292..c527a55 100644 --- a/control.c +++ b/control.c @@ -843,13 +843,17 @@ static int sensor_set_rate (int s, float requested_rate) arb_sampling_rate = sensor[s].max_supported_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; + /* Coordinate with others active sensors on the same device, if any */ if (per_device_sampling_rate) for (n=0; n arb_sampling_rate) { + if (n != s && sensor[n].dev_num == dev_num && sensor[n].num_channels && is_enabled(n) && + sensor[n].semi_arbitrated_rate > arb_sampling_rate) { ALOGV("Sampling rate shared between %s and %s, using %g instead of %g\n", sensor[s].friendly_name, sensor[n].friendly_name, - sensor[n].sampling_rate, arb_sampling_rate); - arb_sampling_rate = sensor[n].sampling_rate; + sensor[n].semi_arbitrated_rate, arb_sampling_rate); + arb_sampling_rate = sensor[n].semi_arbitrated_rate; } sensor[s].sampling_rate = arb_sampling_rate; -- 2.11.0