[v3,2/3] iio: Add IIO_DELTA_VELOCITY channel type

Message ID 20230804064559.47192-3-ramona.bolboaca@analog.com
State New
Headers
Series Add new channels for adis16475 |

Commit Message

Ramona Bolboaca Aug. 4, 2023, 6:45 a.m. UTC
  The delta velocity is defined as a piece-wise integration of
acceleration data. The delta velocity represents the linear velocity
change between two consecutive measurements and it
is measured in m / s (meters per second).

In order to track the total linear velocity change during a desired
period of time, simply sum-up the delta velocity samples acquired
during that time.

IIO currently does not offer a suitable channel type for this
type of measurements hence this patch adds it.

Signed-off-by: Ramona Bolboaca <ramona.bolboaca@analog.com>
---
 Documentation/ABI/testing/sysfs-bus-iio | 15 +++++++++++++++
 drivers/iio/industrialio-core.c         |  1 +
 include/uapi/linux/iio/types.h          |  1 +
 tools/iio/iio_event_monitor.c           |  2 ++
 4 files changed, 19 insertions(+)
  

Comments

Jonathan Cameron Aug. 5, 2023, 6:37 p.m. UTC | #1
On Fri, 4 Aug 2023 09:45:58 +0300
Ramona Bolboaca <ramona.bolboaca@analog.com> wrote:

> The delta velocity is defined as a piece-wise integration of
> acceleration data. The delta velocity represents the linear velocity
> change between two consecutive measurements and it
> is measured in m / s (meters per second).
> 
> In order to track the total linear velocity change during a desired
> period of time, simply sum-up the delta velocity samples acquired
> during that time.
> 
> IIO currently does not offer a suitable channel type for this
> type of measurements hence this patch adds it.
> 
> Signed-off-by: Ramona Bolboaca <ramona.bolboaca@analog.com>
This one looks good to me - I'll pick it up once we reach agreement on
the rest of the series.

Jonathan
  

Patch

diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio
index 1561c33b05a1..dab53d5d7dcf 100644
--- a/Documentation/ABI/testing/sysfs-bus-iio
+++ b/Documentation/ABI/testing/sysfs-bus-iio
@@ -293,6 +293,21 @@  Description:
 		angle samples acquired during that time.
 		Units after application of scale and offset are angles.
 
+What:		/sys/bus/iio/devices/iio:deviceX/in_deltavelocity_x_raw
+What:		/sys/bus/iio/devices/iio:deviceX/in_deltavelocity_y_raw
+What:		/sys/bus/iio/devices/iio:deviceX/in_deltavelocity_z_raw
+KernelVersion:	6.5
+Contact:	linux-iio@vger.kernel.org
+Description:
+		The linear velocity change between two consecutive samples on x,
+		y or z (may be arbitrarily assigned but should match other such
+		assignments on device).
+		In order to compute the total linear velocity change during a
+		desired period of time, the application should sum-up the delta
+		velocity samples acquired during that time.
+		Units after application of scale and offset are meters per
+		second.
+
 What:		/sys/bus/iio/devices/iio:deviceX/in_angl_raw
 What:		/sys/bus/iio/devices/iio:deviceX/in_anglY_raw
 KernelVersion:	4.17
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index 2e2fd0be2504..ba694b049629 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -90,6 +90,7 @@  static const char * const iio_chan_type_name_spec[] = {
 	[IIO_PHASE] = "phase",
 	[IIO_MASSCONCENTRATION] = "massconcentration",
 	[IIO_DELTA_ANGL] = "deltaangl",
+	[IIO_DELTA_VELOCITY] = "deltavelocity",
 };
 
 static const char * const iio_modifier_names[] = {
diff --git a/include/uapi/linux/iio/types.h b/include/uapi/linux/iio/types.h
index 55666a17d311..9a341bd07702 100644
--- a/include/uapi/linux/iio/types.h
+++ b/include/uapi/linux/iio/types.h
@@ -48,6 +48,7 @@  enum iio_chan_type {
 	IIO_PHASE,
 	IIO_MASSCONCENTRATION,
 	IIO_DELTA_ANGL,
+	IIO_DELTA_VELOCITY,
 };
 
 enum iio_modifier {
diff --git a/tools/iio/iio_event_monitor.c b/tools/iio/iio_event_monitor.c
index 3505450060e6..7e6761612246 100644
--- a/tools/iio/iio_event_monitor.c
+++ b/tools/iio/iio_event_monitor.c
@@ -60,6 +60,7 @@  static const char * const iio_chan_type_name_spec[] = {
 	[IIO_PHASE] = "phase",
 	[IIO_MASSCONCENTRATION] = "massconcentration",
 	[IIO_DELTA_ANGL] = "deltaangl",
+	[IIO_DELTA_VELOCITY] = "deltavelocity",
 };
 
 static const char * const iio_ev_type_text[] = {
@@ -175,6 +176,7 @@  static bool event_is_known(struct iio_event_data *event)
 	case IIO_PHASE:
 	case IIO_MASSCONCENTRATION:
 	case IIO_DELTA_ANGL:
+	case IIO_DELTA_VELOCITY:
 		break;
 	default:
 		return false;