From patchwork Tue Feb 18 09:19:50 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislaw Gruszka X-Patchwork-Id: 22810 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 1759FC3220 for ; Tue, 18 Feb 2025 09:20:07 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8E2626868D; Tue, 18 Feb 2025 10:20:06 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="lXkRPEqg"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1ADC86032B for ; Tue, 18 Feb 2025 10:20:01 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1739870403; x=1771406403; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bV7K+VbTYE28kWMieTanx4R2k3gXPpTQR7bgvSzb37Q=; b=lXkRPEqgWOiQUOTarhsN+hezr80SlRb5whXOhyUMAUTW9w8DuVew1XKV fBH/hBfFLZxldHYj8HXDryAEONJqySxwhc9mGdREnZditwWFrjkaa3Wh8 OhyDO3ouXJrET3nzppj+WLF6LuHq+IRqn/NDVf6CN2aiJtpLBi46OujFb GDXs9GuSPvZude5+iGMfwJ/6KsZAMqt3iXlR3YhFhty0fR6CVM8c4MD2Z zTn+McUHLjdWsbZd87GMczSNWoKQG58BjVkdCuNSPGXYZzXAF7Aa1aB90 5Fi3cJv8qAZpDU6MZWSVjPrc4zwhQ/AmuRB/wsOTGK3bu2CYRni0gRhZJ A==; X-CSE-ConnectionGUID: 1sEAZVVmRti3OSwOp6gLNQ== X-CSE-MsgGUID: 1VDMTcyCRIiACovkmbaMTA== X-IronPort-AV: E=McAfee;i="6700,10204,11348"; a="40692047" X-IronPort-AV: E=Sophos;i="6.13,295,1732608000"; d="scan'208";a="40692047" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Feb 2025 01:20:01 -0800 X-CSE-ConnectionGUID: S/abroGNRO+CVrY2xUqoOA== X-CSE-MsgGUID: WSumBM2JQf+P6M7Kis3cuA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.13,295,1732608000"; d="scan'208";a="114855859" Received: from sgruszka-mobl.ger.corp.intel.com (HELO localhost) ([10.246.8.237]) by fmviesa010-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Feb 2025 01:19:58 -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 v3 1/2] libcamera: v4l2_device: add frame start event helpers Date: Tue, 18 Feb 2025 10:19:50 +0100 Message-Id: <20250218091951.13017-2-stanislaw.gruszka@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250218091951.13017-1-stanislaw.gruszka@linux.intel.com> References: <20250218091951.13017-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. Signed-off-by: Stanislaw Gruszka Reviewed-by: Kieran Bingham --- include/libcamera/internal/v4l2_device.h | 2 ++ src/libcamera/v4l2_device.cpp | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/include/libcamera/internal/v4l2_device.h b/include/libcamera/internal/v4l2_device.h index affe52c2..0d807209 100644 --- a/include/libcamera/internal/v4l2_device.h +++ b/include/libcamera/internal/v4l2_device.h @@ -45,6 +45,8 @@ public: const std::string &deviceNode() const { return deviceNode_; } std::string devicePath() const; + bool supportsFrameStartEvent(); + bool frameStartEnabled() { return frameStartEnabled_; } int setFrameStartEnabled(bool enable); Signal frameStart; diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index 2f65a43a..219c82f6 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -449,6 +449,30 @@ 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 == 0) + ioctl(VIDIOC_UNSUBSCRIBE_EVENT, &event); + + return ret == 0; +} + +/** + * \fn V4L2Device::frameStartEnabled() + * \brief Check if frame start event is enabled + * \return True if frame start event is enabled, false otherwise + */ + /** * \brief Enable or disable frame start event notification * \param[in] enable True to enable frame start events, false to disable them