Re: [PATCH v2 1/8] media: v4l: ctrls: add a control for flash/strobe duration

From: Richard Leitner
Date: Fri Mar 14 2025 - 06:25:29 EST


On Fri, Mar 14, 2025 at 09:20:23AM +0000, Sakari Ailus wrote:
> Hi Richard,
>
> Thanks for the set.

Hi Sakari,
thanks for the quick response!

>
> On Fri, Mar 14, 2025 at 09:49:55AM +0100, Richard Leitner wrote:
> > Add a control V4L2_CID_FLASH_DURATION to set the duration of a
> > flash/strobe pulse. This is different to the V4L2_CID_FLASH_TIMEOUT
> > control, as the timeout defines a limit after which the flash is
> > "forcefully" turned off again.
> >
> > On the other hand the new V4L2_CID_FLASH_DURATION is the desired length
> > of the flash/strobe pulse
>
> What's the actual difference between the two? To me they appear the same,
> just expressed in a different way.

According to FLASH_TIMEOUT documentation:

Hardware timeout for flash. The flash strobe is stopped after this
period of time has passed from the start of the strobe. [1]

This is a little bit unspecific, but as also discussed with Dave [2]
according to the documentation of V4L2_FLASH_FAULT_TIMEOUT it seems to
be targeted at providing a "real timeout" control, not settings the
desired duration:

The flash strobe was still on when the timeout set by the user
--- V4L2_CID_FLASH_TIMEOUT control --- has expired. Not all flash
controllers may set this in all such conditions. [1]

If I understood that wrong, I'm also happy to use FLASH_TIMEOUT for this
use-case. But tbh I think FLASH_DURATION would be more specific.

As this still seems unclear: Should the documentation be
changed/rewritten if we stick with the FLASH_DURATION approach?

[1] https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/ext-ctrls-flash.html
[2] https://lore.kernel.org/lkml/CAPY8ntB8i4OyUWAL8k899yUd5QsRifJXiOfWXKceGQ7TNZ4OUw@xxxxxxxxxxxxxx/

>
> >
> > Signed-off-by: Richard Leitner <richard.leitner@xxxxxxxxx>
> > ---
> > drivers/media/v4l2-core/v4l2-ctrls-defs.c | 1 +
> > include/uapi/linux/v4l2-controls.h | 1 +
> > 2 files changed, 2 insertions(+)
> >
> > diff --git a/drivers/media/v4l2-core/v4l2-ctrls-defs.c b/drivers/media/v4l2-core/v4l2-ctrls-defs.c
> > index 1ea52011247accc51d0261f56eab1cf13c0624a0..f9ed7273a9f3eafe01c31b638e1c8d9fcf5424af 100644
> > --- a/drivers/media/v4l2-core/v4l2-ctrls-defs.c
> > +++ b/drivers/media/v4l2-core/v4l2-ctrls-defs.c
> > @@ -1135,6 +1135,7 @@ const char *v4l2_ctrl_get_name(u32 id)
> > case V4L2_CID_FLASH_FAULT: return "Faults";
> > case V4L2_CID_FLASH_CHARGE: return "Charge";
> > case V4L2_CID_FLASH_READY: return "Ready to Strobe";
> > + case V4L2_CID_FLASH_DURATION: return "Strobe Duration";
> >
> > /* JPEG encoder controls */
> > /* Keep the order of the 'case's the same as in v4l2-controls.h! */
> > diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h
> > index 974fd254e57309e6def95b4a4f8e4de13a3972a7..80050cadb8377e3070ebbadc493fcd08b2c12c0b 100644
> > --- a/include/uapi/linux/v4l2-controls.h
> > +++ b/include/uapi/linux/v4l2-controls.h
> > @@ -1173,6 +1173,7 @@ enum v4l2_flash_strobe_source {
> >
> > #define V4L2_CID_FLASH_CHARGE (V4L2_CID_FLASH_CLASS_BASE + 11)
> > #define V4L2_CID_FLASH_READY (V4L2_CID_FLASH_CLASS_BASE + 12)
> > +#define V4L2_CID_FLASH_DURATION (V4L2_CID_FLASH_CLASS_BASE + 13)
> >
> >
> > /* JPEG-class control IDs */
> >
>
> --
> Regards,
>
> Sakari Ailus

Thanks!
Richard