[PATCH v5 1/5] libcamera: v4l2_device: add frame start event helpers
Kieran Bingham
kieran.bingham at ideasonboard.com
Sun Mar 2 00:17:32 CET 2025
Quoting Stanislaw Gruszka (2025-02-25 16:41:12)
> Add helper to check if frame start event are supported by subdevice.
> Since kernel does not have interface to query supported events
> use subscribe interface.
>
> Additionally add helper for checking if the event enabled.
> Will be needed later to proper code flow if enabling the event
> fail for some reason.
>
> Reviewed-by: Kieran Bingham <kieran.bingham at ideasonboard.com> # v3
> Signed-off-by: Stanislaw Gruszka <stanislaw.gruszka at linux.intel.com>
> ---
> include/libcamera/internal/v4l2_device.h | 1 +
> src/libcamera/v4l2_device.cpp | 19 +++++++++++++++++++
> 2 files changed, 20 insertions(+)
>
> diff --git a/include/libcamera/internal/v4l2_device.h b/include/libcamera/internal/v4l2_device.h
> index affe52c2..a647c96a 100644
> --- a/include/libcamera/internal/v4l2_device.h
> +++ b/include/libcamera/internal/v4l2_device.h
> @@ -45,6 +45,7 @@ public:
> const std::string &deviceNode() const { return deviceNode_; }
> std::string devicePath() const;
>
> + bool supportsFrameStartEvent();
> int setFrameStartEnabled(bool enable);
> Signal<uint32_t> frameStart;
>
> diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp
> index 2f65a43a..23c7d1ef 100644
> --- a/src/libcamera/v4l2_device.cpp
> +++ b/src/libcamera/v4l2_device.cpp
> @@ -449,6 +449,25 @@ std::string V4L2Device::devicePath() const
> return path;
> }
>
> +/**
> + * \brief Check if frame start event is supported
> + * \return True if frame start event is supported, false otherwise
> + */
> +
> +bool V4L2Device::supportsFrameStartEvent()
> +{
> + struct v4l2_event_subscription event {
> + };
Curiously my local clang-format is trying to make this one line, but the
CI doesn't report anything here.
So I'll leave it as it is ;-)
Aha, and I've already got a tag on here so ... to the next one.
--
Kieran
> + event.type = V4L2_EVENT_FRAME_SYNC;
> +
> + int ret = ioctl(VIDIOC_SUBSCRIBE_EVENT, &event);
> + if (ret)
> + return false;
> +
> + ioctl(VIDIOC_UNSUBSCRIBE_EVENT, &event);
> + return true;
> +}
> +
> /**
> * \brief Enable or disable frame start event notification
> * \param[in] enable True to enable frame start events, false to disable them
> --
> 2.43.0
>
More information about the libcamera-devel
mailing list