From patchwork Mon Oct 5 15:40:29 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 28404 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 706C1C3305 for ; Mon, 5 Oct 2026 15:40:40 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 590E668DE1; Mon, 5 Oct 2026 17:40:39 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="FnEM2s7H"; 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 6705C68A44 for ; Mon, 5 Oct 2026 17:40:36 +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 C1177227; Mon, 5 Oct 2026 17:38:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1791214720; bh=ah/soejvY7XsVw6SPnRITDAf5dZY4nYc0kcnXFjzFgM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=FnEM2s7H2LjIQKLjxD2CmBOL1Pn3wt1WD9+CS8el8LsxKuDvB7SSPwImRV6NgLQUJ 6FD4K9Ww5W/sBt/A8wpevJUp75Iuy2cEznAjOkJzC63K+uCifDfY1+N7CetSP6hMic tljJGYhLk2D7QSIzEIYwpJFUH5ae/I294U+W3n5k= From: Daniel Scally Date: Mon, 05 Oct 2026 16:40:29 +0100 Subject: [PATCH v2 1/3] libcamera: v4l2_device: Make supportsFrameStartEvent() generic MIME-Version: 1.0 Message-Id: <20261005-v4l2-events-v2-1-e4883190489d@ideasonboard.com> References: <20261005-v4l2-events-v2-0-e4883190489d@ideasonboard.com> In-Reply-To: <20261005-v4l2-events-v2-0-e4883190489d@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=3543; i=dan.scally@ideasonboard.com; h=from:subject:message-id; bh=ah/soejvY7XsVw6SPnRITDAf5dZY4nYc0kcnXFjzFgM=; b=owEBbQKS/ZANAwAKAchJV3psRXUyAcsmYgBqw8TzQO/CghOt11UX5i3dKaof3rCQYgP3ZUekk oRDsZ8tuSGJAjMEAAEKAB0WIQQqyuwyDnZdb+mxmm/ISVd6bEV1MgUCasPE8wAKCRDISVd6bEV1 MgiaD/9Xec13n2Uz1YfqY963TvcqXJGQYCyWxiEWW0Qty6OHTOgOXU2gFOiZjGmvClyrCgVngUa Ddj9DvkpdhbHDdZeWdMZ1+5YcMdjw3GG1Pol9acBh5Ki2nApfTS/Q2eZAKtwHv1pWN6qfS1gkuJ e/JR9aXtRbJaswng8ukXUDVbvtsfsYVYyit7IUgQoHER+Zo5UPv1duksLOs4gIFyCg95M51fwwh qcbnpo56/uER8CKAfV1XNTzGsf8yqIYCFvI6ae7BKEM7UDio+4Blt40y6v5br9OeCYoOo2XIzKf 1HTW2gSivGAaEy1Kixs/GMG4XFXjy2Bo46jcIpmv6AQnik9S+G478S7TRTeR1cGEyDb/ht3rbFp pwdbbzEq8cAYtKmPLTjOJtVpK+BBrZ563gt+4rPXyZ85lv5pIRRss9GlpSYFyzLp6c4TWKozFbf wPyunvP6oqGkBrotMUnXrN0/jN2cgPx56BaER4NmQbjBR0VOcaJ8IfmnZAhT7+b1mPbp+VqGZa1 bkskclpF0sWP/cTR4n8qe8SPO+LzRic1/fJCOkFvCnw0CqwwYyprBbC9mgDLDt7gG5hYQScnQ8M v7CMZS2tl6kAddjkVarLs8/IkQ1paSdRVzvslYXrknS89sL8V8u2mzlgQAfEbw/ai3A4mA9NbBp +e1mpC+IZePC+HA== 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 v4l2_event_subscription parameter that allows users to check whether the V4L2Device supports event subscriptions for any type. Signed-off-by: Daniel Scally --- 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(-) diff --git a/include/libcamera/internal/v4l2_device.h b/include/libcamera/internal/v4l2_device.h index 1a63fc547eac579fabf50421b719d07ddb2d6639..03e4d3dbb480557de98a5fa16fd41d4f2e7431c5 100644 --- a/include/libcamera/internal/v4l2_device.h +++ b/include/libcamera/internal/v4l2_device.h @@ -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 frameStart; diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index 35c29ceca1bb1f9fb09e8c547b603ee8a2b67774..4631d5450b4ac4c47a78a631917d8b226a5269b0 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -22,6 +22,7 @@ #include #include +#include #include @@ -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) diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index 258c82b8d238156038909a4b7b7aa842c99bd677..225b938649dcfe86f5528c3a82ed1b5ca0c94a5a 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -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; }