From: Jonathan Cameron <jic23@jic23.retrosnub.co.uk>
To: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Cc: linux-iio@vger.kernel.org
Subject: Re: [PATCH 3/4] iio: imu: inv_mpu6050: skip first sample when gyro is on
Date: Sun, 6 May 2018 18:00:15 +0100 [thread overview]
Message-ID: <20180506180015.52902895@archlinux> (raw)
In-Reply-To: <1525083251-8368-3-git-send-email-jmaneyrol@invensense.com>
On Mon, 30 Apr 2018 12:14:10 +0200
Jean-Baptiste Maneyrol <jmaneyrol@invensense.com> wrote:
> Implement generic skip first samples mechanism and use it to
> filter out first sample when gyro is on.
>
> The problem for these chips is that the first sample of the gyro
> is out of specs, because gyro is not completely stabilized. To
> ensure all data are within sensor specs, we just skip the first
> sample when turning gyro on.
>
> Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Neat and tidy solution so good.
Is there a similar issue in the read_raw path which seems to just
flick the gyro on then read from it immediately?
I may be missing a delay there which is preventing the data being
bad though.
Jonathan
> ---
> drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h | 1 +
> drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c | 7 ++++++-
> drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c | 3 +++
> 3 files changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
> index 142a835..dfb9e4e 100644
> --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
> @@ -148,6 +148,7 @@ struct inv_mpu6050_state {
> struct regmap *map;
> int irq;
> u8 irq_mask;
> + unsigned skip_samples;
> };
>
> /*register and associated bit definition*/
> diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c
> index e51404f..1b57354 100644
> --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c
> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c
> @@ -185,7 +185,12 @@ irqreturn_t inv_mpu6050_read_fifo(int irq, void *p)
> if (result == 0)
> timestamp = 0;
>
> - iio_push_to_buffers_with_timestamp(indio_dev, data, timestamp);
> + /* skip first samples if needed */
> + if (st->skip_samples)
> + st->skip_samples--;
> + else
> + iio_push_to_buffers_with_timestamp(indio_dev, data,
> + timestamp);
>
> fifo_count -= bytes_per_datum;
> }
> diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c
> index 8a9f869..0d7db27 100644
> --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c
> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c
> @@ -49,11 +49,14 @@ static int inv_mpu6050_set_enable(struct iio_dev *indio_dev, bool enable)
> if (result)
> return result;
> inv_scan_query(indio_dev);
> + st->skip_samples = 0;
> if (st->chip_config.gyro_fifo_enable) {
> result = inv_mpu6050_switch_engine(st, true,
> INV_MPU6050_BIT_PWR_GYRO_STBY);
> if (result)
> goto error_power_off;
> + /* gyro first sample is out of specs, skip it */
> + st->skip_samples = 1;
> }
> if (st->chip_config.accl_fifo_enable) {
> result = inv_mpu6050_switch_engine(st, true,
next prev parent reply other threads:[~2018-05-06 17:00 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-30 10:14 [PATCH 1/4] iio: imu: inv_mpu6050: use i2c mux only for chip with i2c aux bus Jean-Baptiste Maneyrol
2018-04-30 10:14 ` [PATCH 2/4] iio: imu: inv_mpu6050: fix possible deadlock between mutex and iio Jean-Baptiste Maneyrol
2018-05-06 16:55 ` Jonathan Cameron
2018-04-30 10:14 ` [PATCH 3/4] iio: imu: inv_mpu6050: skip first sample when gyro is on Jean-Baptiste Maneyrol
2018-05-06 17:00 ` Jonathan Cameron [this message]
2018-05-08 14:40 ` Jean-Baptiste Maneyrol
2018-05-12 9:38 ` Jonathan Cameron
2018-04-30 10:14 ` [PATCH 4/4] iio: imu: inv_mpu6050: fix user_ctrl register overwritten Jean-Baptiste Maneyrol
2018-05-06 17:01 ` Jonathan Cameron
2018-05-06 16:49 ` [PATCH 1/4] iio: imu: inv_mpu6050: use i2c mux only for chip with i2c aux bus Jonathan Cameron
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180506180015.52902895@archlinux \
--to=jic23@jic23.retrosnub.co.uk \
--cc=jmaneyrol@invensense.com \
--cc=linux-iio@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).