mirror of https://gitee.com/openkylin/linux.git
iio: hid-sensor-magn-3d: Add support for rotation from north
Add the HID usage attribute ID's and IIO channel info for rotation from north support. Signed-off-by: Reyad Attiyat <reyad.attiyat@gmail.com> Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
This commit is contained in:
parent
2a96540a5c
commit
abea9c62c3
|
@ -35,6 +35,10 @@ enum magn_3d_channel {
|
||||||
CHANNEL_SCAN_INDEX_X,
|
CHANNEL_SCAN_INDEX_X,
|
||||||
CHANNEL_SCAN_INDEX_Y,
|
CHANNEL_SCAN_INDEX_Y,
|
||||||
CHANNEL_SCAN_INDEX_Z,
|
CHANNEL_SCAN_INDEX_Z,
|
||||||
|
CHANNEL_SCAN_INDEX_NORTH_MAGN_TILT_COMP,
|
||||||
|
CHANNEL_SCAN_INDEX_NORTH_TRUE_TILT_COMP,
|
||||||
|
CHANNEL_SCAN_INDEX_NORTH_MAGN,
|
||||||
|
CHANNEL_SCAN_INDEX_NORTH_TRUE,
|
||||||
MAGN_3D_CHANNEL_MAX,
|
MAGN_3D_CHANNEL_MAX,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -57,7 +61,11 @@ struct magn_3d_state {
|
||||||
static const u32 magn_3d_addresses[MAGN_3D_CHANNEL_MAX] = {
|
static const u32 magn_3d_addresses[MAGN_3D_CHANNEL_MAX] = {
|
||||||
HID_USAGE_SENSOR_ORIENT_MAGN_FLUX_X_AXIS,
|
HID_USAGE_SENSOR_ORIENT_MAGN_FLUX_X_AXIS,
|
||||||
HID_USAGE_SENSOR_ORIENT_MAGN_FLUX_Y_AXIS,
|
HID_USAGE_SENSOR_ORIENT_MAGN_FLUX_Y_AXIS,
|
||||||
HID_USAGE_SENSOR_ORIENT_MAGN_FLUX_Z_AXIS
|
HID_USAGE_SENSOR_ORIENT_MAGN_FLUX_Z_AXIS,
|
||||||
|
HID_USAGE_SENSOR_ORIENT_COMP_MAGN_NORTH,
|
||||||
|
HID_USAGE_SENSOR_ORIENT_COMP_TRUE_NORTH,
|
||||||
|
HID_USAGE_SENSOR_ORIENT_MAGN_NORTH,
|
||||||
|
HID_USAGE_SENSOR_ORIENT_TRUE_NORTH,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Channel definitions */
|
/* Channel definitions */
|
||||||
|
@ -89,6 +97,42 @@ static const struct iio_chan_spec magn_3d_channels[] = {
|
||||||
BIT(IIO_CHAN_INFO_SCALE) |
|
BIT(IIO_CHAN_INFO_SCALE) |
|
||||||
BIT(IIO_CHAN_INFO_SAMP_FREQ) |
|
BIT(IIO_CHAN_INFO_SAMP_FREQ) |
|
||||||
BIT(IIO_CHAN_INFO_HYSTERESIS),
|
BIT(IIO_CHAN_INFO_HYSTERESIS),
|
||||||
|
}, {
|
||||||
|
.type = IIO_ROT,
|
||||||
|
.modified = 1,
|
||||||
|
.channel2 = IIO_MOD_NORTH_MAGN_TILT_COMP,
|
||||||
|
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
|
||||||
|
.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) |
|
||||||
|
BIT(IIO_CHAN_INFO_SCALE) |
|
||||||
|
BIT(IIO_CHAN_INFO_SAMP_FREQ) |
|
||||||
|
BIT(IIO_CHAN_INFO_HYSTERESIS),
|
||||||
|
}, {
|
||||||
|
.type = IIO_ROT,
|
||||||
|
.modified = 1,
|
||||||
|
.channel2 = IIO_MOD_NORTH_TRUE_TILT_COMP,
|
||||||
|
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
|
||||||
|
.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) |
|
||||||
|
BIT(IIO_CHAN_INFO_SCALE) |
|
||||||
|
BIT(IIO_CHAN_INFO_SAMP_FREQ) |
|
||||||
|
BIT(IIO_CHAN_INFO_HYSTERESIS),
|
||||||
|
}, {
|
||||||
|
.type = IIO_ROT,
|
||||||
|
.modified = 1,
|
||||||
|
.channel2 = IIO_MOD_NORTH_MAGN,
|
||||||
|
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
|
||||||
|
.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) |
|
||||||
|
BIT(IIO_CHAN_INFO_SCALE) |
|
||||||
|
BIT(IIO_CHAN_INFO_SAMP_FREQ) |
|
||||||
|
BIT(IIO_CHAN_INFO_HYSTERESIS),
|
||||||
|
}, {
|
||||||
|
.type = IIO_ROT,
|
||||||
|
.modified = 1,
|
||||||
|
.channel2 = IIO_MOD_NORTH_TRUE,
|
||||||
|
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
|
||||||
|
.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) |
|
||||||
|
BIT(IIO_CHAN_INFO_SCALE) |
|
||||||
|
BIT(IIO_CHAN_INFO_SAMP_FREQ) |
|
||||||
|
BIT(IIO_CHAN_INFO_HYSTERESIS),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -248,6 +292,13 @@ static int magn_3d_capture_sample(struct hid_sensor_hub_device *hsdev,
|
||||||
offset = (usage_id - HID_USAGE_SENSOR_ORIENT_MAGN_FLUX_X_AXIS)
|
offset = (usage_id - HID_USAGE_SENSOR_ORIENT_MAGN_FLUX_X_AXIS)
|
||||||
+ CHANNEL_SCAN_INDEX_X;
|
+ CHANNEL_SCAN_INDEX_X;
|
||||||
break;
|
break;
|
||||||
|
case HID_USAGE_SENSOR_ORIENT_COMP_MAGN_NORTH:
|
||||||
|
case HID_USAGE_SENSOR_ORIENT_COMP_TRUE_NORTH:
|
||||||
|
case HID_USAGE_SENSOR_ORIENT_MAGN_NORTH:
|
||||||
|
case HID_USAGE_SENSOR_ORIENT_TRUE_NORTH:
|
||||||
|
offset = (usage_id - HID_USAGE_SENSOR_ORIENT_COMP_MAGN_NORTH)
|
||||||
|
+ CHANNEL_SCAN_INDEX_NORTH_MAGN_TILT_COMP;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue