[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190620185259.142133-2-gwendal@chromium.org>
Date: Thu, 20 Jun 2019 11:52:58 -0700
From: Gwendal Grignou <gwendal@...omium.org>
To: jic23@...nel.org, bleung@...omium.org,
enric.balletbo@...labora.com, groeck@...omium.org
Cc: linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org,
Gwendal Grignou <gwendal@...omium.org>
Subject: [PATCH 1/2] iio: cros_ec: Add sign vector in core for backward compatibility
To allow cros_ec iio core library to be used with legacy device, add a
vector to rotate sensor data if necessary: legacy devices are not
reporting data in HTML5/Android sensor referential.
TEST=On veyron minnie, check chrome detect tablet mode and rotate
screen in tablet mode.
Signed-off-by: Gwendal Grignou <gwendal@...omium.org>
---
drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c | 5 ++++-
include/linux/iio/common/cros_ec_sensors_core.h | 1 +
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
index 719a0df5aeeb..1b2e7a8242ad 100644
--- a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
+++ b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
@@ -66,8 +66,10 @@ int cros_ec_sensors_core_init(struct platform_device *pdev,
}
state->type = state->resp->info.type;
state->loc = state->resp->info.location;
- }
+ /* Set sign vector, only used for backward compatibility. */
+ memset(state->sign, 1, CROS_EC_SENSOR_MAX_AXIS);
+ }
return 0;
}
EXPORT_SYMBOL_GPL(cros_ec_sensors_core_init);
@@ -254,6 +256,7 @@ static int cros_ec_sensors_read_data_unsafe(struct iio_dev *indio_dev,
if (ret < 0)
return ret;
+ *data *= st->sign[i];
data++;
}
diff --git a/include/linux/iio/common/cros_ec_sensors_core.h b/include/linux/iio/common/cros_ec_sensors_core.h
index ce16445411ac..a1c85ad4df91 100644
--- a/include/linux/iio/common/cros_ec_sensors_core.h
+++ b/include/linux/iio/common/cros_ec_sensors_core.h
@@ -71,6 +71,7 @@ struct cros_ec_sensors_core_state {
enum motionsensor_location loc;
s16 calib[CROS_EC_SENSOR_MAX_AXIS];
+ s8 sign[CROS_EC_SENSOR_MAX_AXIS];
u8 samples[CROS_EC_SAMPLE_SIZE];
--
2.22.0.410.gd8fdbe21b5-goog
Powered by blists - more mailing lists