[PATCH RFC 2/9] iio: consumer: Define timestamp-related structures and constants

Gyeyoung Baek posted 9 patches 7 months ago
[PATCH RFC 2/9] iio: consumer: Define timestamp-related structures and constants
Posted by Gyeyoung Baek 7 months ago
Define the required constants and structures on the consumer side.

The `timestamp_enabled` indicates whether a timestamp is grabbed or not.
This is passed to `iio_triggered_buffer_setup_new()` as an argument.

The `timestamp_type` indicates which handler grabs the timestamp.
This value is set by `iio_poll_func_register()`.

Signed-off-by: Gyeyoung Baek <gye976@gmail.com>
---
 include/linux/iio/trigger_consumer.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/include/linux/iio/trigger_consumer.h b/include/linux/iio/trigger_consumer.h
index 2c05dfad88d7..5e6ff8738386 100644
--- a/include/linux/iio/trigger_consumer.h
+++ b/include/linux/iio/trigger_consumer.h
@@ -13,6 +13,13 @@
 struct iio_dev;
 struct iio_trigger;
 
+enum iio_timestamp_type {
+	IIO_TIMESTAMP_TYPE_NONE,
+	IIO_TIMESTAMP_TYPE_CONSUMER_TOP_HALF,
+	IIO_TIMESTAMP_TYPE_CONSUMER_BOTTOM_HALF,
+	IIO_TIMESTAMP_TYPE_TRIGGER,
+};
+
 /**
  * struct iio_poll_func - poll function pair
  *
@@ -26,7 +33,10 @@ struct iio_trigger;
  * @timestamp:			some devices need a timestamp grabbed as soon
  *				as possible after the trigger - hence handler
  *				passes it via here.
+ * @timestamp_type:		indicates which handler grabs the timestamp.
+ * @timestamp_enabled:		if true, automatically grabs the timestamp.
  **/
+
 struct iio_poll_func {
 	struct iio_dev *indio_dev;
 	irqreturn_t (*h)(int irq, void *p);
@@ -35,6 +45,9 @@ struct iio_poll_func {
 	char *name;
 	int irq;
 	s64 timestamp;
+
+	enum iio_timestamp_type timestamp_type;
+	bool timestamp_enabled;
 };
 
 

-- 
2.43.0
Re: [PATCH RFC 2/9] iio: consumer: Define timestamp-related structures and constants
Posted by Jonathan Cameron 6 months, 3 weeks ago
On Mon, 19 May 2025 23:25:54 +0900
Gyeyoung Baek <gye976@gmail.com> wrote:

> Define the required constants and structures on the consumer side.
> 
> The `timestamp_enabled` indicates whether a timestamp is grabbed or not.
> This is passed to `iio_triggered_buffer_setup_new()` as an argument.
> 
> The `timestamp_type` indicates which handler grabs the timestamp.
> This value is set by `iio_poll_func_register()`.
> 
> Signed-off-by: Gyeyoung Baek <gye976@gmail.com>
> ---
>  include/linux/iio/trigger_consumer.h | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/include/linux/iio/trigger_consumer.h b/include/linux/iio/trigger_consumer.h
> index 2c05dfad88d7..5e6ff8738386 100644
> --- a/include/linux/iio/trigger_consumer.h
> +++ b/include/linux/iio/trigger_consumer.h
> @@ -13,6 +13,13 @@
>  struct iio_dev;
>  struct iio_trigger;
>  
> +enum iio_timestamp_type {
> +	IIO_TIMESTAMP_TYPE_NONE,
> +	IIO_TIMESTAMP_TYPE_CONSUMER_TOP_HALF,
> +	IIO_TIMESTAMP_TYPE_CONSUMER_BOTTOM_HALF,
> +	IIO_TIMESTAMP_TYPE_TRIGGER,
> +};

This needs documentation. I'm struggling even with the series in front of me
to understand what each of these means. The comment below helps somewhat
but we should have it alongside the enum.

> +
>  /**
>   * struct iio_poll_func - poll function pair
>   *
> @@ -26,7 +33,10 @@ struct iio_trigger;
>   * @timestamp:			some devices need a timestamp grabbed as soon
>   *				as possible after the trigger - hence handler
>   *				passes it via here.
> + * @timestamp_type:		indicates which handler grabs the timestamp.
> + * @timestamp_enabled:		if true, automatically grabs the timestamp.
>   **/
> +
>  struct iio_poll_func {
>  	struct iio_dev *indio_dev;
>  	irqreturn_t (*h)(int irq, void *p);
> @@ -35,6 +45,9 @@ struct iio_poll_func {
>  	char *name;
>  	int irq;
>  	s64 timestamp;
> +
> +	enum iio_timestamp_type timestamp_type;
> +	bool timestamp_enabled;
>  };
>  
>  
>