@@ -24,6 +24,7 @@
#include <libcamera/controls.h>
#include "libcamera/internal/formats.h"
+#include "libcamera/internal/v4l2_event.h"
#include "libcamera/internal/v4l2_request.h"
namespace libcamera {
@@ -46,7 +47,7 @@ public:
const std::string &deviceNode() const { return deviceNode_; }
std::string devicePath() const;
- bool supportsFrameStartEvent();
+ bool supportsEvents(V4L2EventSubscription &sub);
int setFrameStartEnabled(bool enable);
Signal<uint32_t> frameStart;
@@ -45,6 +45,7 @@
#include "libcamera/internal/pipeline_handler.h"
#include "libcamera/internal/request.h"
#include "libcamera/internal/software_isp/software_isp.h"
+#include "libcamera/internal/v4l2_event.h"
#include "libcamera/internal/v4l2_subdevice.h"
#include "libcamera/internal/v4l2_videodevice.h"
@@ -668,7 +669,8 @@ int SimpleCameraData::init()
frameStartEmitter_ = nullptr;
for (const Entity &entity : entities_) {
V4L2Subdevice *sd = pipe->subdev(entity.entity);
- if (!sd || !sd->supportsFrameStartEvent())
+ V4L2EventSubscription sub(V4L2Event::Type::FrameSync);
+ if (!sd || !sd->supportsEvents(sub))
continue;
LOG(SimplePipeline, Debug)
@@ -25,6 +25,7 @@
#include "libcamera/internal/formats.h"
#include "libcamera/internal/sysfs.h"
+#include "libcamera/internal/v4l2_event.h"
/**
* \file v4l2_device.h
@@ -470,18 +471,24 @@ 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(V4L2EventSubscription &sub)
{
struct v4l2_event_subscription event{};
- event.type = V4L2_EVENT_FRAME_SYNC;
+
+ auto v4l2Type = V4L2Event::typeToV4L2(sub.type());
+ if (!v4l2Type)
+ return false;
+
+ event.type = *v4l2Type;
+ event.id = sub.id();
int ret = ioctl(VIDIOC_SUBSCRIBE_EVENT, &event);
if (ret)
Replace the existing V4l2Device::supportsFrameStartEvent() function with a generic function with a V4L2EventSubscription parameter that allows users to check whether the V4L2Device supports event subscriptions for any type. Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com> --- include/libcamera/internal/v4l2_device.h | 3 ++- src/libcamera/pipeline/simple/simple.cpp | 4 +++- src/libcamera/v4l2_device.cpp | 21 ++++++++++++++------- 3 files changed, 19 insertions(+), 9 deletions(-)