@@ -46,7 +46,7 @@ public:
const std::string &deviceNode() const { return deviceNode_; }
std::string devicePath() const;
- bool supportsFrameStartEvent();
+ bool supportsEvents(v4l2_event_subscription &sub);
int setFrameStartEnabled(bool enable);
Signal<uint32_t> frameStart;
@@ -22,6 +22,7 @@
#include <vector>
#include <linux/media-bus-format.h>
+#include <linux/videodev2.h>
#include <libcamera/base/log.h>
@@ -668,7 +669,11 @@ int SimpleCameraData::init()
frameStartEmitter_ = nullptr;
for (const Entity &entity : entities_) {
V4L2Subdevice *sd = pipe->subdev(entity.entity);
- if (!sd || !sd->supportsFrameStartEvent())
+
+ v4l2_event_subscription sub{};
+ sub.type = V4L2_EVENT_FRAME_SYNC;
+
+ if (!sd || !sd->supportsEvents(sub))
continue;
LOG(SimplePipeline, Debug)
@@ -470,24 +470,21 @@ std::string V4L2Device::devicePath() const
}
/**
- * \brief Check if frame start event is supported
+ * \brief Check if an event subscription is supported
*
- * Due to limitations in the kernel API, this function may disable the frame
- * start event as a side effect. It should only be called during initialization,
- * before enabling the frame start event with setFrameStartEnabled().
+ * Due to limitations in the kernel API, this function may disable the events as
+ * a side effect. It should only be called during initialization, before
+ * enabling the events explicitly.
*
- * \return True if frame start event is supported, false otherwise
+ * \return True if the subscription is supported, false otherwise
*/
-bool V4L2Device::supportsFrameStartEvent()
+bool V4L2Device::supportsEvents(v4l2_event_subscription &sub)
{
- struct v4l2_event_subscription event{};
- event.type = V4L2_EVENT_FRAME_SYNC;
-
- int ret = ioctl(VIDIOC_SUBSCRIBE_EVENT, &event);
+ int ret = ioctl(VIDIOC_SUBSCRIBE_EVENT, &sub);
if (ret)
return false;
- ioctl(VIDIOC_UNSUBSCRIBE_EVENT, &event);
+ ioctl(VIDIOC_UNSUBSCRIBE_EVENT, &sub);
return true;
}
Replace the existing V4l2Device::supportsFrameStartEvent() function with a generic function with a v4l2_event_subscription parameter that allows users to check whether the V4L2Device supports event subscriptions for any type. Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com> --- Changes in v2: - Use kernel uAPI types directly instead of V4L2Event and V4L2EventSubscription classes --- include/libcamera/internal/v4l2_device.h | 2 +- src/libcamera/pipeline/simple/simple.cpp | 7 ++++++- src/libcamera/v4l2_device.cpp | 19 ++++++++----------- 3 files changed, 15 insertions(+), 13 deletions(-)