lkml.org 
[lkml]   [2019]   [Jul]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v6 1/4] iio: cros_ec: Add sign vector in core for backward compatibility
On Mon, 15 Jul 2019 16:14:51 -0700
Gwendal Grignou <gwendal@chromium.org> wrote:

> 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.
>
> Check the data is not rotated on recent chromebooks that use the HTML5
> standard to present sensor data.
>
> Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
> Reviewed-by: Douglas Anderson <dianders@chromium.org>
Applied to the togreg branch of iio.git and pushed out as testing for the
autobuilders to play with it.

Thanks,

Jonathan

> ---
> drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c | 4 ++++
> include/linux/iio/common/cros_ec_sensors_core.h | 1 +
> 2 files changed, 5 insertions(+)
>
> 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..e8a4d78659c8 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,6 +66,9 @@ 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;
> @@ -254,6 +257,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];
>

\
 
 \ /
  Last update: 2019-07-28 00:14    [W:0.064 / U:36.496 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site