* [PATCH v2 1/2] iio: Add support for linear accel @ 2017-01-05 11:03 Song Hongyan 2017-01-05 11:03 ` [PATCH v2 2/2] iio: Add linear accel sensor hid support Song Hongyan 0 siblings, 1 reply; 3+ messages in thread From: Song Hongyan @ 2017-01-05 11:03 UTC (permalink / raw) To: linux-input-u79uwXL29TY76Z2rM5mHXA, linux-iio-u79uwXL29TY76Z2rM5mHXA Cc: jikos-DgEjT+Ai2ygdnm+yROfE0A, jic23-DgEjT+Ai2ygdnm+yROfE0A, srinivas.pandruvada-ral2JQCrhuEAvxtiuMwx3w, Song Hongyan Add new channel types support for linear accel sensor. Linear acceleration differs from a standard accelerometor, its value depends on standard accel sensor and gravity sensor. Conceptually, this three sensors have following relationship: linear acceleration = acceleration - acceleration due to gravity At rest, standard accelerometer displays 1g due to earth’s gravitational pull while a liner accelerometer will show 0g. More information can be found in: http://www.usb.org/developers/hidpage/HUTRR59_-_Usages_for_Wearables.pdf Signed-off-by: Song Hongyan <hongyan.song-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> --- changes: unify the name not use underline as separator. Documentation/ABI/testing/sysfs-bus-iio | 13 +++++++++++++ drivers/iio/industrialio-core.c | 1 + include/uapi/linux/iio/types.h | 1 + tools/iio/iio_event_monitor.c | 2 ++ 4 files changed, 17 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio index ed5bc2b..0204473 100644 --- a/Documentation/ABI/testing/sysfs-bus-iio +++ b/Documentation/ABI/testing/sysfs-bus-iio @@ -170,6 +170,19 @@ Description: Has all of the equivalent parameters as per voltageY. Units after application of scale and offset are m/s^2. +What: /sys/bus/iio/devices/iio:deviceX/in_linearaccel_x_raw +What: /sys/bus/iio/devices/iio:deviceX/in_linearaccel_y_raw +What: /sys/bus/iio/devices/iio:deviceX/in_linearaccel_z_raw +KernelVersion: 4.11 +Contact: linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org +Description: + Linear Acceleration in direction x, y or z (may be arbitrarily + assigned but should match other such assignments on device). + The sensor data is derives from standard accelerometer device + by filtering out the acceleration which is caused by the force + of Earth’s gravity.Units after application of scale and offset + are m/s^2. + What: /sys/bus/iio/devices/iio:deviceX/in_gravity_x_raw What: /sys/bus/iio/devices/iio:deviceX/in_gravity_y_raw What: /sys/bus/iio/devices/iio:deviceX/in_gravity_z_raw diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index c601698..a1fc446 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -84,6 +84,7 @@ struct bus_type iio_bus_type = { [IIO_COUNT] = "count", [IIO_INDEX] = "index", [IIO_GRAVITY] = "gravity", + [IIO_LINEARACCEL] = "linearaccel", }; static const char * const iio_modifier_names[] = { diff --git a/include/uapi/linux/iio/types.h b/include/uapi/linux/iio/types.h index ffafd6c..41d8465 100644 --- a/include/uapi/linux/iio/types.h +++ b/include/uapi/linux/iio/types.h @@ -43,6 +43,7 @@ enum iio_chan_type { IIO_COUNT, IIO_INDEX, IIO_GRAVITY, + IIO_LINEARACCEL, }; enum iio_modifier { diff --git a/tools/iio/iio_event_monitor.c b/tools/iio/iio_event_monitor.c index b61245e..a8e7896 100644 --- a/tools/iio/iio_event_monitor.c +++ b/tools/iio/iio_event_monitor.c @@ -58,6 +58,7 @@ [IIO_PH] = "ph", [IIO_UVINDEX] = "uvindex", [IIO_GRAVITY] = "gravity", + [IIO_LINEARACCEL] = "linearaccel", }; static const char * const iio_ev_type_text[] = { @@ -151,6 +152,7 @@ static bool event_is_known(struct iio_event_data *event) case IIO_PH: case IIO_UVINDEX: case IIO_GRAVITY: + case IIO_LINEARACCEL: break; default: return false; -- 1.9.1 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH v2 2/2] iio: Add linear accel sensor hid support 2017-01-05 11:03 [PATCH v2 1/2] iio: Add support for linear accel Song Hongyan @ 2017-01-05 11:03 ` Song Hongyan [not found] ` <1483614184-1038-2-git-send-email-hongyan.song-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> 0 siblings, 1 reply; 3+ messages in thread From: Song Hongyan @ 2017-01-05 11:03 UTC (permalink / raw) To: linux-input, linux-iio; +Cc: jikos, jic23, srinivas.pandruvada, Song Hongyan Linear acceleration is a soft sensor it differs from a standard accel sensor, it provides a three-dimensional vector representing acceleration along each device axis, excluding gravity. The sensor data is derives from standard accelerometer device by filtering out the acceleration which is caused by the force of Earth’s gravity. The value can be used to perform gesture detection, it can also serve as input to an inertial navigation system, which uses dead reckoning. More information can be found in: http://www.usb.org/developers/hidpage/HUTRR59_-_Usages_for_Wearables.pdf Linear accel sensor, gravity sensor and accelerometer have similar channels and share channel usage ids. So the most of the code for accel_3d can be reused. Signed-off-by: Song Hongyan <hongyan.song@intel.com> --- changes: unify name not use underline as separator. drivers/iio/accel/hid-sensor-accel-3d.c | 42 +++++++++++++++++++++++++++++++++ include/linux/hid-sensor-ids.h | 3 +++ 2 files changed, 45 insertions(+) diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c index 9edd574..8829dad 100644 --- a/drivers/iio/accel/hid-sensor-accel-3d.c +++ b/drivers/iio/accel/hid-sensor-accel-3d.c @@ -91,6 +91,41 @@ struct accel_3d_state { }; /* Channel definitions */ +static const struct iio_chan_spec linearaccel_3d_channels[] = { + { + .type = IIO_LINEARACCEL, + .modified = 1, + .channel2 = IIO_MOD_X, + .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), + .scan_index = CHANNEL_SCAN_INDEX_X, + }, { + .type = IIO_LINEARACCEL, + .modified = 1, + .channel2 = IIO_MOD_Y, + .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), + .scan_index = CHANNEL_SCAN_INDEX_Y, + }, { + .type = IIO_LINEARACCEL, + .modified = 1, + .channel2 = IIO_MOD_Z, + .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), + .scan_index = CHANNEL_SCAN_INDEX_Z, + } +}; + +/* Channel definitions */ static const struct iio_chan_spec gravity_channels[] = { { .type = IIO_GRAVITY, @@ -354,6 +389,10 @@ static int hid_accel_3d_probe(struct platform_device *pdev) name = "accel_3d"; channel_spec = accel_3d_channels; channel_size = sizeof(accel_3d_channels); + } else if (hsdev->usage == HID_USAGE_SENSOR_LINEARACCEL_3D) { + name = "linearaccel_3d"; + channel_spec = linearaccel_3d_channels; + channel_size = sizeof(linearaccel_3d_channels); } else { name = "gravity"; channel_spec = gravity_channels; @@ -452,6 +491,9 @@ static int hid_accel_3d_remove(struct platform_device *pdev) { /* gravity sensor */ .name = "HID-SENSOR-20007b", }, + { /* linear_accel sensor */ + .name = "HID-SENSOR-20007c", + }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(platform, hid_accel_3d_ids); diff --git a/include/linux/hid-sensor-ids.h b/include/linux/hid-sensor-ids.h index b6778fd2..bab8375 100644 --- a/include/linux/hid-sensor-ids.h +++ b/include/linux/hid-sensor-ids.h @@ -55,6 +55,9 @@ /* Gravity vector */ #define HID_USAGE_SENSOR_GRAVITY_VECTOR 0x20007B +/* linear accel */ +#define HID_USAGE_SENSOR_LINEARACCEL_3D 0x20007C + /* ORIENTATION: Compass 3D: (200083) */ #define HID_USAGE_SENSOR_COMPASS_3D 0x200083 #define HID_USAGE_SENSOR_DATA_ORIENTATION 0x200470 -- 1.9.1 ^ permalink raw reply related [flat|nested] 3+ messages in thread
[parent not found: <1483614184-1038-2-git-send-email-hongyan.song-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH v2 2/2] iio: Add linear accel sensor hid support [not found] ` <1483614184-1038-2-git-send-email-hongyan.song-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> @ 2017-01-05 13:08 ` Jonathan Cameron 0 siblings, 0 replies; 3+ messages in thread From: Jonathan Cameron @ 2017-01-05 13:08 UTC (permalink / raw) To: Song Hongyan, linux-input-u79uwXL29TY76Z2rM5mHXA, linux-iio-u79uwXL29TY76Z2rM5mHXA Cc: jikos-DgEjT+Ai2ygdnm+yROfE0A, srinivas.pandruvada-ral2JQCrhuEAvxtiuMwx3w On 05/01/17 11:03, Song Hongyan wrote: > Linear acceleration is a soft sensor it differs from a standard > accel sensor, it provides a three-dimensional vector representing > acceleration along each device axis, excluding gravity. > The sensor data is derives from standard accelerometer device > by filtering out the acceleration which is caused by the force > of Earth’s gravity. > > The value can be used to perform gesture detection, it can also > serve as input to an inertial navigation system, which uses > dead reckoning. > > More information can be found in: > http://www.usb.org/developers/hidpage/HUTRR59_-_Usages_for_Wearables.pdf > > Linear accel sensor, gravity sensor and accelerometer have similar > channels and share channel usage ids. So the most of the code for > accel_3d can be reused. > > Signed-off-by: Song Hongyan <hongyan.song-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> Applied to the togreg branch of iio.git - initially pushed out as testing sometime soonish. Thanks, Jonathan > --- > changes: unify name not use underline as separator. > > drivers/iio/accel/hid-sensor-accel-3d.c | 42 +++++++++++++++++++++++++++++++++ > include/linux/hid-sensor-ids.h | 3 +++ > 2 files changed, 45 insertions(+) > > diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c > index 9edd574..8829dad 100644 > --- a/drivers/iio/accel/hid-sensor-accel-3d.c > +++ b/drivers/iio/accel/hid-sensor-accel-3d.c > @@ -91,6 +91,41 @@ struct accel_3d_state { > }; > > /* Channel definitions */ > +static const struct iio_chan_spec linearaccel_3d_channels[] = { > + { > + .type = IIO_LINEARACCEL, > + .modified = 1, > + .channel2 = IIO_MOD_X, > + .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), > + .scan_index = CHANNEL_SCAN_INDEX_X, > + }, { > + .type = IIO_LINEARACCEL, > + .modified = 1, > + .channel2 = IIO_MOD_Y, > + .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), > + .scan_index = CHANNEL_SCAN_INDEX_Y, > + }, { > + .type = IIO_LINEARACCEL, > + .modified = 1, > + .channel2 = IIO_MOD_Z, > + .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), > + .scan_index = CHANNEL_SCAN_INDEX_Z, > + } > +}; > + > +/* Channel definitions */ > static const struct iio_chan_spec gravity_channels[] = { > { > .type = IIO_GRAVITY, > @@ -354,6 +389,10 @@ static int hid_accel_3d_probe(struct platform_device *pdev) > name = "accel_3d"; > channel_spec = accel_3d_channels; > channel_size = sizeof(accel_3d_channels); > + } else if (hsdev->usage == HID_USAGE_SENSOR_LINEARACCEL_3D) { > + name = "linearaccel_3d"; > + channel_spec = linearaccel_3d_channels; > + channel_size = sizeof(linearaccel_3d_channels); > } else { > name = "gravity"; > channel_spec = gravity_channels; > @@ -452,6 +491,9 @@ static int hid_accel_3d_remove(struct platform_device *pdev) > { /* gravity sensor */ > .name = "HID-SENSOR-20007b", > }, > + { /* linear_accel sensor */ > + .name = "HID-SENSOR-20007c", > + }, > { /* sentinel */ } > }; > MODULE_DEVICE_TABLE(platform, hid_accel_3d_ids); > diff --git a/include/linux/hid-sensor-ids.h b/include/linux/hid-sensor-ids.h > index b6778fd2..bab8375 100644 > --- a/include/linux/hid-sensor-ids.h > +++ b/include/linux/hid-sensor-ids.h > @@ -55,6 +55,9 @@ > /* Gravity vector */ > #define HID_USAGE_SENSOR_GRAVITY_VECTOR 0x20007B > > +/* linear accel */ > +#define HID_USAGE_SENSOR_LINEARACCEL_3D 0x20007C > + > /* ORIENTATION: Compass 3D: (200083) */ > #define HID_USAGE_SENSOR_COMPASS_3D 0x200083 > #define HID_USAGE_SENSOR_DATA_ORIENTATION 0x200470 > ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-01-05 13:08 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2017-01-05 11:03 [PATCH v2 1/2] iio: Add support for linear accel Song Hongyan 2017-01-05 11:03 ` [PATCH v2 2/2] iio: Add linear accel sensor hid support Song Hongyan [not found] ` <1483614184-1038-2-git-send-email-hongyan.song-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> 2017-01-05 13:08 ` Jonathan Cameron
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).