From dd4d8caef258e402e3dea20304f8b15135c2e6d9 Mon Sep 17 00:00:00 2001 From: Patrick Porlan Date: Wed, 15 Oct 2014 14:03:24 +0200 Subject: [PATCH] IRDA-2056: Refine the test we use to decide to apply gyro calibration The terse flag should only be used with drivers that a) don't expose a recognizable motion trigger (we currently look for the any-motion substring), b) are not for sensor types that Android defines as continuous, and c) are nonetheless on-change. As of today the only remaining example of this that I can think of are the XPS 12 ISH drivers, so I prefer not to use this flag to decide whether or not to apply calibration. Checking whether we're using the initial or motion trigger seems better, if not fully satisfactory. Change-Id: I24c6632497f758e1301da7927ec94bf17f6fe84d Signed-off-by: Patrick Porlan --- transform.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/transform.c b/transform.c index 7aebae8..78ec500 100644 --- a/transform.c +++ b/transform.c @@ -293,8 +293,16 @@ static int finalize_sample_default(int s, struct sensors_event_t* data) */ data->gyro.status = SENSOR_STATUS_ACCURACY_MEDIUM; - if (!(sensor_info[s].quirks & QUIRK_TERSE_DRIVER)) - calibrate_gyro(data, &sensor_info[s]); + /* + * We're only trying to calibrate data from continuously + * firing gyroscope drivers, as motion based ones use + * movement thresholds that may lead us to incorrectly + * estimate bias. + */ + if (sensor_info[s].selected_trigger != + sensor_info[s].motion_trigger_name) + calibrate_gyro(data, &sensor_info[s]); + if (sensor_info[s].quirks & QUIRK_NOISY) denoise_median(&sensor_info[s], data, 3); break; -- 2.11.0