Skip to content

Commit be8e48d

Browse files
spandruvadajic23
authored andcommitted
iio: hid-sensors: Inclinometer 3D: adjust scale and offset
Using units and unit exponent to calculate scale which is compliant to IIO ABI. Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
1 parent 92463fd commit be8e48d

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

‎drivers/iio/orientation/hid-sensor-incl-3d.c‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ struct incl_3d_state {
4242
struct hid_sensor_common common_attributes;
4343
struct hid_sensor_hub_attribute_info incl[INCLI_3D_CHANNEL_MAX];
4444
u32 incl_val[INCLI_3D_CHANNEL_MAX];
45+
int scale_pre_decml;
46+
int scale_post_decml;
47+
int scale_precision;
48+
int value_offset;
4549
};
4650

4751
static const u32 incl_3d_addresses[INCLI_3D_CHANNEL_MAX] = {
@@ -125,12 +129,12 @@ static int incl_3d_read_raw(struct iio_dev *indio_dev,
125129
ret_type = IIO_VAL_INT;
126130
break;
127131
case IIO_CHAN_INFO_SCALE:
128-
*val = incl_state->incl[CHANNEL_SCAN_INDEX_X].units;
129-
ret_type = IIO_VAL_INT;
132+
*val = incl_state->scale_pre_decml;
133+
*val2 = incl_state->scale_post_decml;
134+
ret_type = incl_state->scale_precision;
130135
break;
131136
case IIO_CHAN_INFO_OFFSET:
132-
*val = hid_sensor_convert_exponent(
133-
incl_state->incl[CHANNEL_SCAN_INDEX_X].unit_expo);
137+
*val = incl_state->value_offset;
134138
ret_type = IIO_VAL_INT;
135139
break;
136140
case IIO_CHAN_INFO_SAMP_FREQ:
@@ -279,6 +283,11 @@ static int incl_3d_parse_report(struct platform_device *pdev,
279283
st->incl[1].index, st->incl[1].report_id,
280284
st->incl[2].index, st->incl[2].report_id);
281285

286+
st->scale_precision = hid_sensor_format_scale(
287+
HID_USAGE_SENSOR_INCLINOMETER_3D,
288+
&st->incl[CHANNEL_SCAN_INDEX_X],
289+
&st->scale_pre_decml, &st->scale_post_decml);
290+
282291
/* Set Sensitivity field ids, when there is no individual modifier */
283292
if (st->common_attributes.sensitivity.index < 0) {
284293
sensor_hub_input_get_attribute_info(hsdev,

0 commit comments

Comments
 (0)