From patchwork Fri Sep 25 15:16:22 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 28378 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id DE20BBDCBD for ; Fri, 25 Sep 2026 15:16:35 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 742E6689C5; Fri, 25 Sep 2026 17:16:32 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="fXFnHjJJ"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B3BA2689AA for ; Fri, 25 Sep 2026 17:16:30 +0200 (CEST) Received: from [127.0.1.1] (chfd-03-b2-v4wan-176392-cust229.vm15.cable.virginm.net [82.19.20.230]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 93F0E12F; Fri, 25 Sep 2026 17:14:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1790349282; bh=5IPJVie1k1opuihW4m5DnGBcTjJRjx6133QzyrLGhAM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=fXFnHjJJ0e2c0rzmA5Un4ck9T2DqiMQBQ2R5mUSeP7xqhDJvTFKBvcngwXPgX1edh SSKb/WBzZNggeSbcrGuSOduWql0FoHC54XC2r+b1eT+5tJgcfTmkBNPw3bUqQ4KfwU 4YBh5lK5Rd7mjIWe2TdeDdvmDTxOgDUuDuStj3JQ= From: Daniel Scally Date: Fri, 25 Sep 2026 16:16:22 +0100 Subject: [PATCH 2/4] libcamera: v4l2_device: Make supportsFrameStartEvent() generic MIME-Version: 1.0 Message-Id: <20260925-v4l2-events-v1-2-b2ec212eb5d0@ideasonboard.com> References: <20260925-v4l2-events-v1-0-b2ec212eb5d0@ideasonboard.com> In-Reply-To: <20260925-v4l2-events-v1-0-b2ec212eb5d0@ideasonboard.com> To: libcamera-devel@lists.libcamera.org Cc: Daniel Scally X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3934; i=dan.scally@ideasonboard.com; h=from:subject:message-id; bh=5IPJVie1k1opuihW4m5DnGBcTjJRjx6133QzyrLGhAM=; b=owEBbQKS/ZANAwAKAchJV3psRXUyAcsmYgBqtpBNLAJIs4+ya5kSUsO9UYEKCEIeF9y5Q2qL4 c2EPukHwDeJAjMEAAEKAB0WIQQqyuwyDnZdb+mxmm/ISVd6bEV1MgUCaraQTQAKCRDISVd6bEV1 Mk+0D/9KEf0ZW8oEygPY7FMIFutmIMxN1PsvXjY64QIt2Yla9MrQ4q+u4aZkrTkXkUPeiC3pocx A4i1661GJ6fbaeV0utfTt0XkCWiAD+hfjof3aTTSOAWvrIm1UpJAdVNWsyjki+/2LhKUlmCbVPB 9rtJ4pW6SOFCLKmH1Ct1s0m11TD/sdeNKyJu23Z1ws0YigFuEXEQi1JZ9EAnfAmKPFyNJzH+t3c NFhbyjY7yviPq9QBz31Zby4q2fTOrWLFHY5t+7OlwErEdo7gcdzrxX74ULXCnJKVx2KNL2G+MYP sajC5Xg+so6HS+tQK8aB10c0h/5cJ7AgOrARsR3r8OtNl2NwUvw7i2gGUojGLq2A2EbX6A+y7JM 0FIE1x60XO7dd/5JtZB4HIAACqstk/WepL0RhVYXK8aqJ+Y2T7o4sudhfb9wKZt35wlKbScWHEB YPiidgSyFVkgJw2zFccsaLtFZZihA6OwU/K9Cqo0TWun97lBrQXcdjx/wP9BbqJbpgyijKhjS0b xBFtisYpjrEW1cxcPSSg4SzahjxwUAKJt9j8oSpYLE4AUoP21Pq8tyySZ7EYAKQJERTsDNo0Nib De+m1AR9n4NBe9GxspPDFOSKuKKFLOHEg8ps/CQnjAtfG1ZNxr8KUoRaVSAYnyxKSCxJuBE0h2b 0BflEFh+FKnGboQ== X-Developer-Key: i=dan.scally@ideasonboard.com; a=openpgp; fpr=EEC699ACA1B7CB5D31330C0BBD501C2A3546CCF6 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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 --- 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(-) diff --git a/include/libcamera/internal/v4l2_device.h b/include/libcamera/internal/v4l2_device.h index 1a63fc547eac579fabf50421b719d07ddb2d6639..cc8116874e9eeecac76f5c25e8b5719c07976781 100644 --- a/include/libcamera/internal/v4l2_device.h +++ b/include/libcamera/internal/v4l2_device.h @@ -24,6 +24,7 @@ #include #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 frameStart; diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index 35c29ceca1bb1f9fb09e8c547b603ee8a2b67774..4d70d50ce50bb1b94e4c30c3fecfb78af678e592 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -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) diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index 258c82b8d238156038909a4b7b7aa842c99bd677..654472286d4645ff96a404a09ff8de382a49678c 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -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)