[RFC,1/3] controls: Add FrameWallClock and FrameWallClockRaw controls
diff mbox series

Message ID 20241126121706.4350-2-david.plowman@raspberrypi.com
State New
Headers show
Series
  • Frame wallclock timestamps and metadata
Related show

Commit Message

David Plowman Nov. 26, 2024, 12:17 p.m. UTC
We add FrameWallClockRaw, a direct "raw" measurement of the wall clock
timestamp for the frame, and FrameWallClock, for a smoothed
(de-jittered) version of the same number.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
---
 src/libcamera/control_ids_core.yaml | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

Comments

Laurent Pinchart Dec. 5, 2024, 9:46 a.m. UTC | #1
Hi David,

Thank you for the patch.

On Tue, Nov 26, 2024 at 12:17:04PM +0000, David Plowman wrote:
> We add FrameWallClockRaw, a direct "raw" measurement of the wall clock
> timestamp for the frame, and FrameWallClock, for a smoothed
> (de-jittered) version of the same number.

Will the two values always be returned together ? If so we could
possibly combine them into a single array control of size 2. I don't
mind too much either way, but it could make it slightly simpler for
applications if they always (or often) need to process both values in
conjunction.

> Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
> ---
>  src/libcamera/control_ids_core.yaml | 29 +++++++++++++++++++++++++++++
>  1 file changed, 29 insertions(+)
> 
> diff --git a/src/libcamera/control_ids_core.yaml b/src/libcamera/control_ids_core.yaml
> index d34a2d06..7cf0f481 100644
> --- a/src/libcamera/control_ids_core.yaml
> +++ b/src/libcamera/control_ids_core.yaml
> @@ -973,4 +973,33 @@ controls:
>        description: |
>          Enable or disable the debug metadata.
>  
> +  - FrameWallClockRaw:
> +      type: int64_t
> +      description: |
> +        The time in microseconds since the system clock's epoch.

The time of what ? Is it a start of frame, end of DMA or another time ?
My understanding is that it should correlate with the SensorTimestamp
control, so should be sampled at the same time, "just" with a different
clock.

Linux has four wall clocks: CLOCK_REALTIME, CLOCK_REALTIME_ALARM,
CLOCK_REALTIME_COARSE and CLOCK_TAI. Would an application need to know
which clock is used ?

> +
> +        This is a direct measurement of the number of microseconds since the
> +        system clock's epoch. Because of the way it is sampled, this value is

It sounds like the control should define how this is sampled.

> +        likely to be subject to significant amounts of system and system
> +        load-dependent jitter, typically of many milliseconds in duration.
> +
> +        For a smoothed version of this timestamp, use the FramwWallClock
> +        control.
> +
> +        \sa FrameWallClock
> +
> +        The FrameWallClockRaw control can only be returned in metadata.
> +
> +  - FrameWallClock:
> +      type: int64_t
> +      description: |
> +        The time in microseconds since the system clock's epoch.
> +
> +        This is a smoothed version of the FrameWallClockRaw timestamp, which
> +        should show much reduced amounts of jitter.

Reading the documentation only I can't really tell what this is meant
for. I suppose the next patches will shed some more light, but the
control documentation should be expanded. Possible areas for improvement
are how the clock is smoothed (at least the parts of the smoothing
process that matter from a usage point of view), and why.

> +
> +        \sa FrameWallClockRaw
> +
> +        The FrameWallClock control can only be returned in metadata.
> +
>  ...

Patch
diff mbox series

diff --git a/src/libcamera/control_ids_core.yaml b/src/libcamera/control_ids_core.yaml
index d34a2d06..7cf0f481 100644
--- a/src/libcamera/control_ids_core.yaml
+++ b/src/libcamera/control_ids_core.yaml
@@ -973,4 +973,33 @@  controls:
       description: |
         Enable or disable the debug metadata.
 
+  - FrameWallClockRaw:
+      type: int64_t
+      description: |
+        The time in microseconds since the system clock's epoch.
+
+        This is a direct measurement of the number of microseconds since the
+        system clock's epoch. Because of the way it is sampled, this value is
+        likely to be subject to significant amounts of system and system
+        load-dependent jitter, typically of many milliseconds in duration.
+
+        For a smoothed version of this timestamp, use the FramwWallClock
+        control.
+
+        \sa FrameWallClock
+
+        The FrameWallClockRaw control can only be returned in metadata.
+
+  - FrameWallClock:
+      type: int64_t
+      description: |
+        The time in microseconds since the system clock's epoch.
+
+        This is a smoothed version of the FrameWallClockRaw timestamp, which
+        should show much reduced amounts of jitter.
+
+        \sa FrameWallClockRaw
+
+        The FrameWallClock control can only be returned in metadata.
+
 ...