drivers:iio:stm:imu:st_lsm6dsm: scaling factor type set to IIO_VAL_INT_PLUS_NANO
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> Change-Id: I4736590a4dc2d6f80fcff31950caa9d1a1e03f6c Reviewed-on: https://gerrit.st.com/c/linuxandroidopen/stm-ldd-iio/+/272680 Reviewed-by: Denis CIOCCA <denis.ciocca@st.com> Tested-by: CITOOLS <MDG-smet-aci-reviews@list.st.com>
This commit is contained in:
parent
0a2bd3a7fb
commit
23d6bdf59e
@ -130,10 +130,10 @@
|
||||
#define ST_LSM6DSM_ACCEL_FS_4G_VAL 0x02
|
||||
#define ST_LSM6DSM_ACCEL_FS_8G_VAL 0x03
|
||||
#define ST_LSM6DSM_ACCEL_FS_16G_VAL 0x01
|
||||
#define ST_LSM6DSM_ACCEL_FS_2G_GAIN IIO_G_TO_M_S_2(61)
|
||||
#define ST_LSM6DSM_ACCEL_FS_4G_GAIN IIO_G_TO_M_S_2(122)
|
||||
#define ST_LSM6DSM_ACCEL_FS_8G_GAIN IIO_G_TO_M_S_2(244)
|
||||
#define ST_LSM6DSM_ACCEL_FS_16G_GAIN IIO_G_TO_M_S_2(488)
|
||||
#define ST_LSM6DSM_ACCEL_FS_2G_GAIN IIO_G_TO_M_S_2(61000)
|
||||
#define ST_LSM6DSM_ACCEL_FS_4G_GAIN IIO_G_TO_M_S_2(122000)
|
||||
#define ST_LSM6DSM_ACCEL_FS_8G_GAIN IIO_G_TO_M_S_2(244000)
|
||||
#define ST_LSM6DSM_ACCEL_FS_16G_GAIN IIO_G_TO_M_S_2(488000)
|
||||
#define ST_LSM6DSM_ACCEL_OUT_X_L_ADDR 0x28
|
||||
#define ST_LSM6DSM_ACCEL_OUT_Y_L_ADDR 0x2a
|
||||
#define ST_LSM6DSM_ACCEL_OUT_Z_L_ADDR 0x2c
|
||||
@ -154,10 +154,10 @@
|
||||
#define ST_LSM6DSM_GYRO_FS_500_VAL 0x01
|
||||
#define ST_LSM6DSM_GYRO_FS_1000_VAL 0x02
|
||||
#define ST_LSM6DSM_GYRO_FS_2000_VAL 0x03
|
||||
#define ST_LSM6DSM_GYRO_FS_250_GAIN IIO_DEGREE_TO_RAD(8750)
|
||||
#define ST_LSM6DSM_GYRO_FS_500_GAIN IIO_DEGREE_TO_RAD(17500)
|
||||
#define ST_LSM6DSM_GYRO_FS_1000_GAIN IIO_DEGREE_TO_RAD(35000)
|
||||
#define ST_LSM6DSM_GYRO_FS_2000_GAIN IIO_DEGREE_TO_RAD(70000)
|
||||
#define ST_LSM6DSM_GYRO_FS_250_GAIN IIO_DEGREE_TO_RAD(8750000)
|
||||
#define ST_LSM6DSM_GYRO_FS_500_GAIN IIO_DEGREE_TO_RAD(17500000)
|
||||
#define ST_LSM6DSM_GYRO_FS_1000_GAIN IIO_DEGREE_TO_RAD(35000000)
|
||||
#define ST_LSM6DSM_GYRO_FS_2000_GAIN IIO_DEGREE_TO_RAD(70000000)
|
||||
#define ST_LSM6DSM_GYRO_OUT_X_L_ADDR 0x22
|
||||
#define ST_LSM6DSM_GYRO_OUT_Y_L_ADDR 0x24
|
||||
#define ST_LSM6DSM_GYRO_OUT_Z_L_ADDR 0x26
|
||||
@ -2308,7 +2308,7 @@ static ssize_t st_lsm6dsm_sysfs_scale_avail(struct device *dev,
|
||||
struct lsm6dsm_sensor_data *sdata = iio_priv(dev_get_drvdata(dev));
|
||||
|
||||
for (i = 0; i < ST_LSM6DSM_FS_LIST_NUM; i++) {
|
||||
len += scnprintf(buf + len, PAGE_SIZE - len, "0.%06u ",
|
||||
len += scnprintf(buf + len, PAGE_SIZE - len, "0.%09u ",
|
||||
st_lsm6dsm_fs_table[sdata->sindex].fs_avl[i].gain);
|
||||
}
|
||||
buf[len - 1] = '\n';
|
||||
@ -2903,6 +2903,19 @@ static IIO_DEVICE_ATTR(injection_sensors, S_IRUGO,
|
||||
NULL, 0);
|
||||
#endif /* CONFIG_ST_LSM6DSM_XL_DATA_INJECTION */
|
||||
|
||||
static int st_lsm6dsm_write_raw_get_fmt(struct iio_dev *indio_dev,
|
||||
struct iio_chan_spec const *chan,
|
||||
long mask)
|
||||
{
|
||||
if (mask == IIO_CHAN_INFO_SCALE) {
|
||||
if ((chan->type == IIO_ANGL_VEL) ||
|
||||
(chan->type == IIO_ACCEL))
|
||||
return IIO_VAL_INT_PLUS_NANO;
|
||||
}
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static struct attribute *st_lsm6dsm_accel_attributes[] = {
|
||||
&iio_dev_attr_sampling_frequency_available.dev_attr.attr,
|
||||
&iio_dev_attr_in_accel_scale_available.dev_attr.attr,
|
||||
@ -2929,6 +2942,7 @@ static const struct iio_info st_lsm6dsm_accel_info = {
|
||||
.attrs = &st_lsm6dsm_accel_attribute_group,
|
||||
.read_raw = &st_lsm6dsm_read_raw,
|
||||
.write_raw = &st_lsm6dsm_write_raw,
|
||||
.write_raw_get_fmt = st_lsm6dsm_write_raw_get_fmt,
|
||||
};
|
||||
|
||||
static struct attribute *st_lsm6dsm_gyro_attributes[] = {
|
||||
@ -2953,6 +2967,7 @@ static const struct iio_info st_lsm6dsm_gyro_info = {
|
||||
.attrs = &st_lsm6dsm_gyro_attribute_group,
|
||||
.read_raw = &st_lsm6dsm_read_raw,
|
||||
.write_raw = &st_lsm6dsm_write_raw,
|
||||
.write_raw_get_fmt = st_lsm6dsm_write_raw_get_fmt,
|
||||
};
|
||||
|
||||
static struct attribute *st_lsm6dsm_sign_motion_attributes[] = {
|
||||
|
Loading…
Reference in New Issue
Block a user