diff mbox series

[v2,1/2] iio: cros_ec: Add sign vector in core for backward compatibility

Message ID 20190621024106.158589-2-gwendal@chromium.org (mailing list archive)
State New, archived
Headers show
Series Support accelerometers for veyron_minnie | expand

Commit Message

Gwendal Grignou June 21, 2019, 2:41 a.m. UTC
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.

On veyron minnie, check chrome detect tablet mode and rotate
screen in tablet mode.

Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
---
 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(+)

Comments

Jonathan Cameron June 22, 2019, 8:54 a.m. UTC | #1
On Thu, 20 Jun 2019 19:41:05 -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.
> 
> On veyron minnie, check chrome detect tablet mode and rotate
> screen in tablet mode.
> 
> Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
I'm guessing that you have a whole pile of code that isn't using
the mounting_matrix ABI and hence need the 'fixup' in kernel?

Otherwise this is fine, but I'd like to wait for Doug to have another
look if he wants to (and ideally give a reviewed-by)

Anyone else's input also welcome of course.

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];
>
Doug Anderson June 24, 2019, 6:05 p.m. UTC | #2
Hi,

On Thu, Jun 20, 2019 at 7:41 PM 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.
>
> On veyron minnie, check chrome detect tablet mode and rotate
> screen in tablet mode.

The above sentence is still a little strange.  You just took the
"TEST=" out but still left the testing instructions?  They sound odd
like this.  You could just drop it, or perhaps instead change to:

This change is part of a set of changes needed to let Chrome detect
tablet mode and screen rotation on rk3288-veyron-minnie.


> Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
> ---
>  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(+)

I'm decidedly a non-expert here, but since I had nitpicks on patch #1
and my nitpicks have been addressed, feel free to add:

Douglas Anderson <dianders@chromium.org>
Gwendal Grignou June 24, 2019, 10:44 p.m. UTC | #3
On Sat, Jun 22, 2019 at 1:54 AM Jonathan Cameron <jic23@kernel.org> wrote:
>
> On Thu, 20 Jun 2019 19:41:05 -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.
> >
> > On veyron minnie, check chrome detect tablet mode and rotate
> > screen in tablet mode.
> >
> > Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
> I'm guessing that you have a whole pile of code that isn't using
> the mounting_matrix ABI and hence need the 'fixup' in kernel?
That's correct: cros EC normally presents sensors information in the
proper HTML5 matrix so it does not need to export "mount_matrix"
attribute.
Except for legacy sensors where the EC firmware used a different
matrix, Given we don't want to release a new firmware for these
machines, I indeed fix it up in the kernel.
>
> Otherwise this is fine, but I'd like to wait for Doug to have another
> look if he wants to (and ideally give a reviewed-by)
>
> Anyone else's input also welcome of course.
>
> 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];
> >
>
diff mbox series

Patch

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];