All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lorenzo Bianconi <lorenzo@kernel.org>
To: Mario Tesi <martepisa@gmail.com>
Cc: lorenzo.bianconi83@gmail.com, jic23@kernel.org, knaack.h@gmx.de,
	lars@metafoo.de, pmeerw@pmeerw.net, linux-iio@vger.kernel.org,
	linux-kernel@vger.kernel.org, mario.tesi@st.com
Subject: Re: [PATCH] iio: imu: st_lsm6dsx: Scaling factor type set to IIO_VAL_INT_PLUS_NANO
Date: Thu, 17 Sep 2020 10:06:56 +0200	[thread overview]
Message-ID: <20200917080656.GA22982@lore-desk> (raw)
In-Reply-To: <1600274660-29143-1-git-send-email-martepisa@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2882 bytes --]

> From: Mario Tesi <mario.tesi@st.com>
> 
> Scaling factor values for Acc lead to an unacceptable rounding of the
> full scale (FS) calculated by some SensorHAL on Android devices. For examples
> setting FS to 4g the in_accel_x_scale, in_accel_y_scale and in_accel_z_scale
> are 0.001196 on 6 decimal digits and the FS is
> 0.001196 × ((2^15) − 1) ~= 39.1893 m/s^2.
> 
> Android CTS R10 SensorParameterRangeTest test expects a value greater than
> 39.20 m/s^2 so this test fails (ACCELEROMETER_MAX_RANGE = 4 * 9.80).
> 
> Using 9 decimal digits the new scale factor is 0.001196411 and the FS now
> is 0.001196411 × ((2^15)−1) ~= 39.2028 m/s^2.
> 
> This patch extends to IIO_VAL_INT_PLUS_NANO type the scaling factor to all
> IMU devices where SensorParameterRangeTest CTS test fails.
> 
> Signed-off-by: Mario Tesi <mario.tesi@st.com>

Hi Mario,

just a minor comment inline. Fixing it:

Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>

> ---
>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 136 ++++++++++++++++-----------
>  1 file changed, 79 insertions(+), 57 deletions(-)
> 

[...]

>  	fs_table = &hw->settings->fs_table[sensor->id];
>  	for (i = 0; i < fs_table->fs_len; i++)
> -		len += scnprintf(buf + len, PAGE_SIZE - len, "0.%06u ",
> +		len += scnprintf(buf + len, PAGE_SIZE - len, "0.%09u ",
>  				 fs_table->fs_avl[i].gain);
>  	buf[len - 1] = '\n';
>  
>  	return len;
>  }
>  
> +static int st_lsm6dsx_write_raw_get_fmt(struct iio_dev *indio_dev,
> +					struct iio_chan_spec const *chan,
> +					long mask)
> +{
> +	switch (mask) {
> +	case IIO_CHAN_INFO_SCALE:
> +		switch (chan->type) {
> +		case IIO_ANGL_VEL:
> +		case IIO_ACCEL:
> +			return IIO_VAL_INT_PLUS_NANO;
> +		default:
> +			return IIO_VAL_INT_PLUS_MICRO;
> +		}
> +	default:
> +		return IIO_VAL_INT_PLUS_MICRO;
> +	}
> +
> +	return -EINVAL;

you can remove this

> +}
> +
>  static IIO_DEV_ATTR_SAMP_FREQ_AVAIL(st_lsm6dsx_sysfs_sampling_frequency_avail);
>  static IIO_DEVICE_ATTR(in_accel_scale_available, 0444,
>  		       st_lsm6dsx_sysfs_scale_avail, NULL, 0);
> @@ -1868,6 +1888,7 @@ static const struct iio_info st_lsm6dsx_acc_info = {
>  	.read_event_config = st_lsm6dsx_read_event_config,
>  	.write_event_config = st_lsm6dsx_write_event_config,
>  	.hwfifo_set_watermark = st_lsm6dsx_set_watermark,
> +	.write_raw_get_fmt = st_lsm6dsx_write_raw_get_fmt,
>  };
>  
>  static struct attribute *st_lsm6dsx_gyro_attributes[] = {
> @@ -1885,6 +1906,7 @@ static const struct iio_info st_lsm6dsx_gyro_info = {
>  	.read_raw = st_lsm6dsx_read_raw,
>  	.write_raw = st_lsm6dsx_write_raw,
>  	.hwfifo_set_watermark = st_lsm6dsx_set_watermark,
> +	.write_raw_get_fmt = st_lsm6dsx_write_raw_get_fmt,
>  };
>  
>  static int st_lsm6dsx_get_drdy_pin(struct st_lsm6dsx_hw *hw, int *drdy_pin)
> -- 
> 2.7.4
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

  reply	other threads:[~2020-09-17  8:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-16 16:44 [PATCH] iio: imu: st_lsm6dsx: Scaling factor type set to IIO_VAL_INT_PLUS_NANO Mario Tesi
2020-09-17  8:06 ` Lorenzo Bianconi [this message]
  -- strict thread matches above, loose matches on Subject: below --
2020-09-17 16:47 Mario Tesi
2020-09-19 13:30 ` 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=20200917080656.GA22982@lore-desk \
    --to=lorenzo@kernel.org \
    --cc=jic23@kernel.org \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lorenzo.bianconi83@gmail.com \
    --cc=mario.tesi@st.com \
    --cc=martepisa@gmail.com \
    --cc=pmeerw@pmeerw.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.