[libcamera-devel,v10,1/3] libcamera: controls: Add frame duration control
diff mbox series

Message ID 20201218100626.205134-2-naush@raspberrypi.com
State Changes Requested
Delegated to: Laurent Pinchart
Headers show
Series
  • raspberrypi: FPS control
Related show

Commit Message

Naushir Patuck Dec. 18, 2020, 10:06 a.m. UTC
Add an int64_t array control (controls::FrameDurations) to specify the
minimum and maximum (in that order) frame duration to be used by the
camera sensor.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Tested-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
---
 src/libcamera/control_ids.yaml | 41 ++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

Comments

Kieran Bingham Dec. 18, 2020, 12:44 p.m. UTC | #1
Hi Naush,

On 18/12/2020 10:06, Naushir Patuck wrote:
> Add an int64_t array control (controls::FrameDurations) to specify the
> minimum and maximum (in that order) frame duration to be used by the
> camera sensor.
> 
> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
> Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
> Tested-by: David Plowman <david.plowman@raspberrypi.com>
> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
> ---
>  src/libcamera/control_ids.yaml | 41 ++++++++++++++++++++++++++++++++++
>  1 file changed, 41 insertions(+)
> 
> diff --git a/src/libcamera/control_ids.yaml b/src/libcamera/control_ids.yaml
> index 6d6f0fee..a58bff18 100644
> --- a/src/libcamera/control_ids.yaml
> +++ b/src/libcamera/control_ids.yaml
> @@ -306,6 +306,47 @@ controls:
>          maximum valid value is given by the properties::ScalerCropMaximum
>          property, and the two can be used to implement digital zoom.
>  
> +  - FrameDurations:
> +      type: int64_t
> +      description: |
> +          The minimum and maximum (in that order) frame duration,
> +          expressed in micro-seconds.
> +
> +          When provided by applications, the control specifies the sensor frame
> +          duration interval the pipeline has to use. This could also limit the
> +          largest exposure time the sensor can use. For example, if a maximum
> +          frame duration of 33ms is requested (corresponding to 30 frames per
> +          second), the sensor will not be able to raise the exposure time above
> +          33ms. A fixed frame duration is achieved by setting the minimum and
> +          maximum values to be the same.
> +
> +          The maximum frame duration provides the absolute limit to the shutter
> +          speed computed by the AE algorithm and it overrides any exposure mode
> +          setting specified with controls::AeExposureMode. Similarly, when a
> +          manual exposure time is set through controls::ExposureTime, it also
> +          gets clipped to the limits set by this control.
> +
> +          \sa AeExposureMode
> +          \sa ExposureTime
> +
> +          \todo Refer to the frame duration limits property to describe how
> +          application-provided values gets clipped and reset.
> +
> +          When reported by pipelines, the control expresses the minimum and
> +          maximum frame durations used after being clipped to what the current
> +          sensor mode supports, and what is achievable based on the exposure
> +          mode setting specified with controls::AeExposureMode or manual
> +          exposure time set through controls::ExposureTime. The sensor frame
> +          duration is one of the parameter that defines the capture frame rate

s/parameter/parameters/ <fixable while applying I expect>

> +          but it does not alone provide enough information to fully calculate it
> +          as it does not account for pipeline processing delays.
> +
> +          \todo Define how to calculate the capture frame rate by
> +          defining controls to report additional delays introduced by
> +          the capture pipeline or post-processing stages (ie JPEG
> +          conversion, frame scaling).

Presumably, the frame rate becomes a function of
  max(FrameDuration, OtherSteps)


Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>


> +      size: [2]
> +
>    # ----------------------------------------------------------------------------
>    # Draft controls section
>  
>
Naushir Patuck Dec. 18, 2020, 1:12 p.m. UTC | #2
Hi Kieran,

Thank you for the review.

On Fri, 18 Dec 2020 at 12:44, Kieran Bingham <
kieran.bingham@ideasonboard.com> wrote:

> Hi Naush,
>
> On 18/12/2020 10:06, Naushir Patuck wrote:
> > Add an int64_t array control (controls::FrameDurations) to specify the
> > minimum and maximum (in that order) frame duration to be used by the
> > camera sensor.
> >
> > Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
> > Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
> > Tested-by: David Plowman <david.plowman@raspberrypi.com>
> > Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
> > ---
> >  src/libcamera/control_ids.yaml | 41 ++++++++++++++++++++++++++++++++++
> >  1 file changed, 41 insertions(+)
> >
> > diff --git a/src/libcamera/control_ids.yaml
> b/src/libcamera/control_ids.yaml
> > index 6d6f0fee..a58bff18 100644
> > --- a/src/libcamera/control_ids.yaml
> > +++ b/src/libcamera/control_ids.yaml
> > @@ -306,6 +306,47 @@ controls:
> >          maximum valid value is given by the
> properties::ScalerCropMaximum
> >          property, and the two can be used to implement digital zoom.
> >
> > +  - FrameDurations:
> > +      type: int64_t
> > +      description: |
> > +          The minimum and maximum (in that order) frame duration,
> > +          expressed in micro-seconds.
> > +
> > +          When provided by applications, the control specifies the
> sensor frame
> > +          duration interval the pipeline has to use. This could also
> limit the
> > +          largest exposure time the sensor can use. For example, if a
> maximum
> > +          frame duration of 33ms is requested (corresponding to 30
> frames per
> > +          second), the sensor will not be able to raise the exposure
> time above
> > +          33ms. A fixed frame duration is achieved by setting the
> minimum and
> > +          maximum values to be the same.
> > +
> > +          The maximum frame duration provides the absolute limit to the
> shutter
> > +          speed computed by the AE algorithm and it overrides any
> exposure mode
> > +          setting specified with controls::AeExposureMode. Similarly,
> when a
> > +          manual exposure time is set through controls::ExposureTime,
> it also
> > +          gets clipped to the limits set by this control.
> > +
> > +          \sa AeExposureMode
> > +          \sa ExposureTime
> > +
> > +          \todo Refer to the frame duration limits property to describe
> how
> > +          application-provided values gets clipped and reset.
> > +
> > +          When reported by pipelines, the control expresses the minimum
> and
> > +          maximum frame durations used after being clipped to what the
> current
> > +          sensor mode supports, and what is achievable based on the
> exposure
> > +          mode setting specified with controls::AeExposureMode or manual
> > +          exposure time set through controls::ExposureTime. The sensor
> frame
> > +          duration is one of the parameter that defines the capture
> frame rate
>
> s/parameter/parameters/ <fixable while applying I expect>
>
> > +          but it does not alone provide enough information to fully
> calculate it
> > +          as it does not account for pipeline processing delays.
> > +
> > +          \todo Define how to calculate the capture frame rate by
> > +          defining controls to report additional delays introduced by
> > +          the capture pipeline or post-processing stages (ie JPEG
> > +          conversion, frame scaling).
>
> Presumably, the frame rate becomes a function of
>   max(FrameDuration, OtherSteps)
>

That's right.  The tricky bit is fully defining OtherSteps :-)

Regards,
Naush



>
>
> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
>
>
> > +      size: [2]
> > +
> >    #
> ----------------------------------------------------------------------------
> >    # Draft controls section
> >
> >
>
> --
> Regards
> --
> Kieran
>
Laurent Pinchart Dec. 20, 2020, 5:38 a.m. UTC | #3
Hi Naush,

Thank you for the patch.

On Fri, Dec 18, 2020 at 10:06:25AM +0000, Naushir Patuck wrote:
> Add an int64_t array control (controls::FrameDurations) to specify the
> minimum and maximum (in that order) frame duration to be used by the
> camera sensor.
> 
> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
> Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
> Tested-by: David Plowman <david.plowman@raspberrypi.com>
> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
> ---
>  src/libcamera/control_ids.yaml | 41 ++++++++++++++++++++++++++++++++++
>  1 file changed, 41 insertions(+)
> 
> diff --git a/src/libcamera/control_ids.yaml b/src/libcamera/control_ids.yaml
> index 6d6f0fee..a58bff18 100644
> --- a/src/libcamera/control_ids.yaml
> +++ b/src/libcamera/control_ids.yaml
> @@ -306,6 +306,47 @@ controls:
>          maximum valid value is given by the properties::ScalerCropMaximum
>          property, and the two can be used to implement digital zoom.
>  
> +  - FrameDurations:
> +      type: int64_t
> +      description: |
> +          The minimum and maximum (in that order) frame duration,
> +          expressed in micro-seconds.
> +
> +          When provided by applications, the control specifies the sensor frame
> +          duration interval the pipeline has to use. This could also limit the

s/could also limit/limits/ ?

> +          largest exposure time the sensor can use. For example, if a maximum
> +          frame duration of 33ms is requested (corresponding to 30 frames per
> +          second), the sensor will not be able to raise the exposure time above
> +          33ms. A fixed frame duration is achieved by setting the minimum and
> +          maximum values to be the same.
> +
> +          The maximum frame duration provides the absolute limit to the shutter
> +          speed computed by the AE algorithm and it overrides any exposure mode

I think we should talk about exposure time instead of shutter speed, but
we'll need to go through the whole documentation and code base to ensure
consistency, so this can be done later.

> +          setting specified with controls::AeExposureMode. Similarly, when a
> +          manual exposure time is set through controls::ExposureTime, it also
> +          gets clipped to the limits set by this control.
> +
> +          \sa AeExposureMode
> +          \sa ExposureTime
> +
> +          \todo Refer to the frame duration limits property to describe how
> +          application-provided values gets clipped and reset.
> +
> +          When reported by pipelines, the control expresses the minimum and

Is this about Request::metadata(), or Camera::properties() ? I assume
the former as it's defined in control_ids.yaml.

> +          maximum frame durations used after being clipped to what the current
> +          sensor mode supports, and what is achievable based on the exposure
> +          mode setting specified with controls::AeExposureMode or manual
> +          exposure time set through controls::ExposureTime. The sensor frame

I have a hard time parsing this, and a hard time seeing how it should be
used by applications :-S Do you need this for your use cases ?

> +          duration is one of the parameter that defines the capture frame rate
> +          but it does not alone provide enough information to fully calculate it
> +          as it does not account for pipeline processing delays.

Delays in the pipeline don't affect the frame duration, do they ? We
could drop frames when processing streams in software (for instance for
JPEG compression), but that's out of scope as libcamera doesn't support
that.

> +
> +          \todo Define how to calculate the capture frame rate by
> +          defining controls to report additional delays introduced by
> +          the capture pipeline or post-processing stages (ie JPEG
> +          conversion, frame scaling).
> +      size: [2]
> +
>    # ----------------------------------------------------------------------------
>    # Draft controls section
>
Naushir Patuck Dec. 21, 2020, 11:11 a.m. UTC | #4
Hi Laurent,

Thank you for the review feedback.

On Sun, 20 Dec 2020 at 05:38, Laurent Pinchart <
laurent.pinchart@ideasonboard.com> wrote:

> Hi Naush,
>
> Thank you for the patch.
>
> On Fri, Dec 18, 2020 at 10:06:25AM +0000, Naushir Patuck wrote:
> > Add an int64_t array control (controls::FrameDurations) to specify the
> > minimum and maximum (in that order) frame duration to be used by the
> > camera sensor.
> >
> > Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
> > Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
> > Tested-by: David Plowman <david.plowman@raspberrypi.com>
> > Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
> > ---
> >  src/libcamera/control_ids.yaml | 41 ++++++++++++++++++++++++++++++++++
> >  1 file changed, 41 insertions(+)
> >
> > diff --git a/src/libcamera/control_ids.yaml
> b/src/libcamera/control_ids.yaml
> > index 6d6f0fee..a58bff18 100644
> > --- a/src/libcamera/control_ids.yaml
> > +++ b/src/libcamera/control_ids.yaml
> > @@ -306,6 +306,47 @@ controls:
> >          maximum valid value is given by the
> properties::ScalerCropMaximum
> >          property, and the two can be used to implement digital zoom.
> >
> > +  - FrameDurations:
> > +      type: int64_t
> > +      description: |
> > +          The minimum and maximum (in that order) frame duration,
> > +          expressed in micro-seconds.
> > +
> > +          When provided by applications, the control specifies the
> sensor frame
> > +          duration interval the pipeline has to use. This could also
> limit the
>
> s/could also limit/limits/ ?
>

Ack


>
> > +          largest exposure time the sensor can use. For example, if a
> maximum
> > +          frame duration of 33ms is requested (corresponding to 30
> frames per
> > +          second), the sensor will not be able to raise the exposure
> time above
> > +          33ms. A fixed frame duration is achieved by setting the
> minimum and
> > +          maximum values to be the same.
> > +
> > +          The maximum frame duration provides the absolute limit to the
> shutter
> > +          speed computed by the AE algorithm and it overrides any
> exposure mode
>
> I think we should talk about exposure time instead of shutter speed, but
> we'll need to go through the whole documentation and code base to ensure
> consistency, so this can be done later.
>
> > +          setting specified with controls::AeExposureMode. Similarly,
> when a
> > +          manual exposure time is set through controls::ExposureTime,
> it also
> > +          gets clipped to the limits set by this control.
> > +
> > +          \sa AeExposureMode
> > +          \sa ExposureTime
> > +
> > +          \todo Refer to the frame duration limits property to describe
> how
> > +          application-provided values gets clipped and reset.
> > +
> > +          When reported by pipelines, the control expresses the minimum
> and
>
> Is this about Request::metadata(), or Camera::properties() ? I assume
> the former as it's defined in control_ids.yaml.
>

This is through Request::metadata().  Should I perhaps reword to make this
more explicit?

"When reported by pipelines through metadata, the control expresses...." ?


>
> > +          maximum frame durations used after being clipped to what the
> current
> > +          sensor mode supports, and what is achievable based on the
> exposure
> > +          mode setting specified with controls::AeExposureMode or manual
> > +          exposure time set through controls::ExposureTime. The sensor
> frame
>
> I have a hard time parsing this, and a hard time seeing how it should be
> used by applications :-S Do you need this for your use cases ?
>

Yes, this was also a point of confusion between Jacopo and me :-)

What I was trying to convey is that the values returned through the
metadata is the actual limits that will be used (after being constrained by
the exposure mode and/or shutter speed), and may not be the same as what
the application requested.  I thought this might be useful for the
application to know the actual limits used.  If you think this may not be
needed, I could remove this control from the metadata?


>
> > +          duration is one of the parameter that defines the capture
> frame rate
> > +          but it does not alone provide enough information to fully
> calculate it
> > +          as it does not account for pipeline processing delays.
>
> Delays in the pipeline don't affect the frame duration, do they ? We
> could drop frames when processing streams in software (for instance for
> JPEG compression), but that's out of scope as libcamera doesn't support
> that.
>

If you have, e.g. a slow software denoise running in the IPA whose
processing time limits your frame throughput, it could be limiting the
overall pipeline framerate (increasing frame duration).  Do you think
perhaps this should not be mentioned here to avoid complicating things for
now?


>
> > +
> > +          \todo Define how to calculate the capture frame rate by
> > +          defining controls to report additional delays introduced by
> > +          the capture pipeline or post-processing stages (ie JPEG
> > +          conversion, frame scaling).
> > +      size: [2]
> > +
> >    #
> ----------------------------------------------------------------------------
> >    # Draft controls section
> >
>
> --
> Regards,
>
> Laurent Pinchart
>
Andrey Konovalov Dec. 21, 2020, 11:35 a.m. UTC | #5
Hi Naushir,

On 21.12.2020 14:11, Naushir Patuck wrote:
> Hi Laurent,
> 
> Thank you for the review feedback.
> 
> On Sun, 20 Dec 2020 at 05:38, Laurent Pinchart <laurent.pinchart@ideasonboard.com <mailto:laurent.pinchart@ideasonboard.com>> wrote:
> 
>     Hi Naush,
> 
>     Thank you for the patch.
> 
>     On Fri, Dec 18, 2020 at 10:06:25AM +0000, Naushir Patuck wrote:
>      > Add an int64_t array control (controls::FrameDurations) to specify the
>      > minimum and maximum (in that order) frame duration to be used by the
>      > camera sensor.
>      >
>      > Signed-off-by: Naushir Patuck <naush@raspberrypi.com <mailto:naush@raspberrypi.com>>
>      > Reviewed-by: David Plowman <david.plowman@raspberrypi.com <mailto:david.plowman@raspberrypi.com>>
>      > Tested-by: David Plowman <david.plowman@raspberrypi.com <mailto:david.plowman@raspberrypi.com>>
>      > Reviewed-by: Jacopo Mondi <jacopo@jmondi.org <mailto:jacopo@jmondi.org>>
>      > ---
>      >  src/libcamera/control_ids.yaml | 41 ++++++++++++++++++++++++++++++++++
>      >  1 file changed, 41 insertions(+)
>      >
>      > diff --git a/src/libcamera/control_ids.yaml b/src/libcamera/control_ids.yaml
>      > index 6d6f0fee..a58bff18 100644
>      > --- a/src/libcamera/control_ids.yaml
>      > +++ b/src/libcamera/control_ids.yaml
>      > @@ -306,6 +306,47 @@ controls:
>      >          maximum valid value is given by the properties::ScalerCropMaximum
>      >          property, and the two can be used to implement digital zoom.
>      >
>      > +  - FrameDurations:
>      > +      type: int64_t
>      > +      description: |
>      > +          The minimum and maximum (in that order) frame duration,
>      > +          expressed in micro-seconds.
>      > +
>      > +          When provided by applications, the control specifies the sensor frame
>      > +          duration interval the pipeline has to use. This could also limit the
> 
>     s/could also limit/limits/ ?
> 
> 
> Ack
> 
> 
>      > +          largest exposure time the sensor can use. For example, if a maximum
>      > +          frame duration of 33ms is requested (corresponding to 30 frames per
>      > +          second), the sensor will not be able to raise the exposure time above
>      > +          33ms. A fixed frame duration is achieved by setting the minimum and
>      > +          maximum values to be the same.
>      > +
>      > +          The maximum frame duration provides the absolute limit to the shutter
>      > +          speed computed by the AE algorithm and it overrides any exposure mode
> 
>     I think we should talk about exposure time instead of shutter speed, but
>     we'll need to go through the whole documentation and code base to ensure
>     consistency, so this can be done later.
> 
>      > +          setting specified with controls::AeExposureMode. Similarly, when a
>      > +          manual exposure time is set through controls::ExposureTime, it also
>      > +          gets clipped to the limits set by this control.
>      > +
>      > +          \sa AeExposureMode
>      > +          \sa ExposureTime
>      > +
>      > +          \todo Refer to the frame duration limits property to describe how
>      > +          application-provided values gets clipped and reset.
>      > +
>      > +          When reported by pipelines, the control expresses the minimum and
> 
>     Is this about Request::metadata(), or Camera::properties() ? I assume
>     the former as it's defined in control_ids.yaml.
> 
> 
> This is through Request::metadata().  Should I perhaps reword to make this more explicit?
> 
> "When reported by pipelines through metadata, the control expresses...." ?
> 
> 
>      > +          maximum frame durations used after being clipped to what the current
>      > +          sensor mode supports, and what is achievable based on the exposure
>      > +          mode setting specified with controls::AeExposureMode or manual
>      > +          exposure time set through controls::ExposureTime. The sensor frame
> 
>     I have a hard time parsing this, and a hard time seeing how it should be
>     used by applications :-S Do you need this for your use cases ?
> 
> 
> Yes, this was also a point of confusion between Jacopo and me :-)
> 
> What I was trying to convey is that the values returned through the metadata is the actual limits that will be used (after being 
> constrained by the exposure mode and/or shutter speed), and may not be the same as what the application requested.  I thought 
> this might be useful for the application to know the actual limits used.  If you think this may not be needed, I could remove 
> this control from the metadata?
> 
> 
>      > +          duration is one of the parameter that defines the capture frame rate
>      > +          but it does not alone provide enough information to fully calculate it
>      > +          as it does not account for pipeline processing delays.
> 
>     Delays in the pipeline don't affect the frame duration, do they ? We
>     could drop frames when processing streams in software (for instance for
>     JPEG compression), but that's out of scope as libcamera doesn't support
>     that.
> 
> 
> If you have, e.g. a slow software denoise running in the IPA whose processing time limits your frame throughput, it could be 
> limiting the overall pipeline framerate (increasing frame duration).  Do you think perhaps this should not be mentioned here to 
> avoid complicating things for now?

The "capture frame rate" (vs sensor frame rate or sensor frame duration) is just fine.
"overall pipeline frame rate" is also clear.
But "pipeline frame duration" (as the control is "frame duration", not "frame interval" or "frame rate") does
sound confusing to me.

Thanks,
Andrey

>      > +
>      > +          \todo Define how to calculate the capture frame rate by
>      > +          defining controls to report additional delays introduced by
>      > +          the capture pipeline or post-processing stages (ie JPEG
>      > +          conversion, frame scaling).
>      > +      size: [2]
>      > +
>      >    # ----------------------------------------------------------------------------
>      >    # Draft controls section
>      >
> 
>     -- 
>     Regards,
> 
>     Laurent Pinchart
> 
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
>
Laurent Pinchart Jan. 5, 2021, 12:49 p.m. UTC | #6
Hi Naush,

On Mon, Dec 21, 2020 at 11:11:59AM +0000, Naushir Patuck wrote:
> On Sun, 20 Dec 2020 at 05:38, Laurent Pinchart wrote:
> > On Fri, Dec 18, 2020 at 10:06:25AM +0000, Naushir Patuck wrote:
> > > Add an int64_t array control (controls::FrameDurations) to specify the
> > > minimum and maximum (in that order) frame duration to be used by the
> > > camera sensor.
> > >
> > > Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
> > > Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
> > > Tested-by: David Plowman <david.plowman@raspberrypi.com>
> > > Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
> > > ---
> > >  src/libcamera/control_ids.yaml | 41 ++++++++++++++++++++++++++++++++++
> > >  1 file changed, 41 insertions(+)
> > >
> > > diff --git a/src/libcamera/control_ids.yaml b/src/libcamera/control_ids.yaml
> > > index 6d6f0fee..a58bff18 100644
> > > --- a/src/libcamera/control_ids.yaml
> > > +++ b/src/libcamera/control_ids.yaml
> > > @@ -306,6 +306,47 @@ controls:
> > >          maximum valid value is given by the properties::ScalerCropMaximum
> > >          property, and the two can be used to implement digital zoom.
> > >
> > > +  - FrameDurations:
> > > +      type: int64_t
> > > +      description: |
> > > +          The minimum and maximum (in that order) frame duration,
> > > +          expressed in micro-seconds.
> > > +
> > > +          When provided by applications, the control specifies the sensor frame
> > > +          duration interval the pipeline has to use. This could also limit the
> >
> > s/could also limit/limits/ ?
> 
> Ack
> 
> > > +          largest exposure time the sensor can use. For example, if a maximum
> > > +          frame duration of 33ms is requested (corresponding to 30 frames per
> > > +          second), the sensor will not be able to raise the exposure time above
> > > +          33ms. A fixed frame duration is achieved by setting the minimum and
> > > +          maximum values to be the same.
> > > +
> > > +          The maximum frame duration provides the absolute limit to the shutter
> > > +          speed computed by the AE algorithm and it overrides any exposure mode
> >
> > I think we should talk about exposure time instead of shutter speed, but
> > we'll need to go through the whole documentation and code base to ensure
> > consistency, so this can be done later.
> >
> > > +          setting specified with controls::AeExposureMode. Similarly, when a
> > > +          manual exposure time is set through controls::ExposureTime, it also
> > > +          gets clipped to the limits set by this control.
> > > +
> > > +          \sa AeExposureMode
> > > +          \sa ExposureTime
> > > +
> > > +          \todo Refer to the frame duration limits property to describe how
> > > +          application-provided values gets clipped and reset.
> > > +
> > > +          When reported by pipelines, the control expresses the minimum and
> >
> > Is this about Request::metadata(), or Camera::properties() ? I assume
> > the former as it's defined in control_ids.yaml.
> 
> This is through Request::metadata().  Should I perhaps reword to make this
> more explicit?
> 
> "When reported by pipelines through metadata, the control expresses...." ?

You could just say "When reported in metadata, ...".

> > > +          maximum frame durations used after being clipped to what the current
> > > +          sensor mode supports, and what is achievable based on the exposure
> > > +          mode setting specified with controls::AeExposureMode or manual
> > > +          exposure time set through controls::ExposureTime. The sensor frame
> >
> > I have a hard time parsing this, and a hard time seeing how it should be
> > used by applications :-S Do you need this for your use cases ?
> 
> Yes, this was also a point of confusion between Jacopo and me :-)
> 
> What I was trying to convey is that the values returned through the
> metadata is the actual limits that will be used (after being constrained by
> the exposure mode and/or shutter speed), and may not be the same as what
> the application requested.  I thought this might be useful for the
> application to know the actual limits used.  If you think this may not be
> needed, I could remove this control from the metadata?

Now I understand. Sorry for being slow :-)

One thing we should report in metadata for sure (but not necessarily as
part of this series) is the actual frame duration. I've so far thought
it could be done with this control, with the minimum and maximum values
set to the actual frame duration. That would however preclude from using
the control to report clamped values. We could introduce a new
FrameDuration control used in metadata only for this purpose, but it
could be a bit confusing when setting a particular frame duration to set
it through FrameDurations and read it back through FrameDuration.

I see pros and cons in both cases, even if I don't see at the moment use
cases for reporting the constrained limits. If you think it would be
useful, I'm fine keeping this usage, if possible with a slightly
clarified documentation. Maybe this paragraph could be reworked to first
explain that the current configuration of the camera sensor and of the
algorithms restrict possible frame durations, followed by the sentence
stating that, when used in metadata, the control reports the limits used
by the camera after those constraints are taken into account ?

> > > +          duration is one of the parameter that defines the capture frame rate
> > > +          but it does not alone provide enough information to fully calculate it
> > > +          as it does not account for pipeline processing delays.
> >
> > Delays in the pipeline don't affect the frame duration, do they ? We
> > could drop frames when processing streams in software (for instance for
> > JPEG compression), but that's out of scope as libcamera doesn't support
> > that.
> 
> If you have, e.g. a slow software denoise running in the IPA whose
> processing time limits your frame throughput, it could be limiting the
> overall pipeline framerate (increasing frame duration).  Do you think
> perhaps this should not be mentioned here to avoid complicating things for
> now?

While you're right, I'd drop it for now. We'll need to document how
certain processing blocks may not have any bandwidth to process all
frames at the sensor frame rate, but before we do so, I think partial
documentation would be confusing. The todo comment should be enough for
now.

> > > +
> > > +          \todo Define how to calculate the capture frame rate by
> > > +          defining controls to report additional delays introduced by
> > > +          the capture pipeline or post-processing stages (ie JPEG
> > > +          conversion, frame scaling).
> > > +      size: [2]
> > > +
> > >    # ----------------------------------------------------------------------------
> > >    # Draft controls section
> > >

Patch
diff mbox series

diff --git a/src/libcamera/control_ids.yaml b/src/libcamera/control_ids.yaml
index 6d6f0fee..a58bff18 100644
--- a/src/libcamera/control_ids.yaml
+++ b/src/libcamera/control_ids.yaml
@@ -306,6 +306,47 @@  controls:
         maximum valid value is given by the properties::ScalerCropMaximum
         property, and the two can be used to implement digital zoom.
 
+  - FrameDurations:
+      type: int64_t
+      description: |
+          The minimum and maximum (in that order) frame duration,
+          expressed in micro-seconds.
+
+          When provided by applications, the control specifies the sensor frame
+          duration interval the pipeline has to use. This could also limit the
+          largest exposure time the sensor can use. For example, if a maximum
+          frame duration of 33ms is requested (corresponding to 30 frames per
+          second), the sensor will not be able to raise the exposure time above
+          33ms. A fixed frame duration is achieved by setting the minimum and
+          maximum values to be the same.
+
+          The maximum frame duration provides the absolute limit to the shutter
+          speed computed by the AE algorithm and it overrides any exposure mode
+          setting specified with controls::AeExposureMode. Similarly, when a
+          manual exposure time is set through controls::ExposureTime, it also
+          gets clipped to the limits set by this control.
+
+          \sa AeExposureMode
+          \sa ExposureTime
+
+          \todo Refer to the frame duration limits property to describe how
+          application-provided values gets clipped and reset.
+
+          When reported by pipelines, the control expresses the minimum and
+          maximum frame durations used after being clipped to what the current
+          sensor mode supports, and what is achievable based on the exposure
+          mode setting specified with controls::AeExposureMode or manual
+          exposure time set through controls::ExposureTime. The sensor frame
+          duration is one of the parameter that defines the capture frame rate
+          but it does not alone provide enough information to fully calculate it
+          as it does not account for pipeline processing delays.
+
+          \todo Define how to calculate the capture frame rate by
+          defining controls to report additional delays introduced by
+          the capture pipeline or post-processing stages (ie JPEG
+          conversion, frame scaling).
+      size: [2]
+
   # ----------------------------------------------------------------------------
   # Draft controls section