From patchwork Tue Feb 25 16:41:12 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislaw Gruszka X-Patchwork-Id: 22865 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 6DB38BDB1C for ; Tue, 25 Feb 2025 16:41:38 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 336546871F; Tue, 25 Feb 2025 17:41:38 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="mgO0N9e5"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 57AC06871C for ; Tue, 25 Feb 2025 17:41:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1740501697; x=1772037697; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wASek0M/LPWvI1PuzDpxmNo4n7PrnAoMj42iArPH8hM=; b=mgO0N9e5KVAq66kz1mU4886ERgwYK+1NHzAd4OfIvUWPyIuXq5L+3dcu Q3AsfKErx7gAAV5z2dZgtM10RFrt4Sh1oEDsd3XA4oyd1Lr1eYLmTb0T7 ohAqhAmGPN43MdAxYlOQJHv6P6/KIGc0xtQid0/Gr/SUbqoRt+2/1RFTU QMkJUDtOxXWPnSyiR0id5TkGo82kNrfo601bwRe7JyhOeBnK0+LQlWvw6 lYSq85WR/fit197UiCvy7Kjkks4V9J9MYCyL1u0UVNnnbMhyElJ1DWauL hW3uGaLwwppcLoy5kbBiHSUl4CpJT1H8wLCGTzbl0tcDt2D0ATz9nC00B w==; X-CSE-ConnectionGUID: dC94/yHQQ7+8E7XvYD4hxw== X-CSE-MsgGUID: wtm+nmFtQNWQYrd3QeUXww== X-IronPort-AV: E=McAfee;i="6700,10204,11314"; a="52740838" X-IronPort-AV: E=Sophos;i="6.12,310,1728975600"; d="scan'208";a="52740838" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Feb 2025 08:41:35 -0800 X-CSE-ConnectionGUID: uhwbX5HaQdCAXQsziibfbQ== X-CSE-MsgGUID: smGPowgFQgaOzjJjtSOucw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,224,1728975600"; d="scan'208";a="121689780" Received: from sgruszka-mobl.ger.corp.intel.com (HELO localhost) ([10.245.115.185]) by orviesa005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Feb 2025 08:41:32 -0800 From: Stanislaw Gruszka To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal , Laurent Pinchart , Kieran Bingham , Naushir Patuck , Sakari Ailus , Hans de Goede Subject: [PATCH v5 1/5] libcamera: v4l2_device: add frame start event helpers Date: Tue, 25 Feb 2025 17:41:12 +0100 Message-Id: <20250225164116.414301-2-stanislaw.gruszka@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250225164116.414301-1-stanislaw.gruszka@linux.intel.com> References: <20250225164116.414301-1-stanislaw.gruszka@linux.intel.com> MIME-Version: 1.0 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" 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 # v3 Signed-off-by: Stanislaw Gruszka Reviewed-by: Laurent Pinchart --- 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 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 { + }; + 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