From patchwork Thu Apr 3 07:45:47 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislaw Gruszka X-Patchwork-Id: 23110 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 D8944C3213 for ; Thu, 3 Apr 2025 07:46:04 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8A82C6899C; Thu, 3 Apr 2025 09:46:04 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="iYHlwgKr"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6F8AD6899A for ; Thu, 3 Apr 2025 09:46:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1743666362; x=1775202362; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7gNkBCS+9eOAC6ByJMdpQJ24EewFwjpekuV8RTbAeDQ=; b=iYHlwgKrOOcdvQaX4by+kqxdO3XW6OShS4qa2Mo4TIe4ySzXTxxFNdgN b/Ilsx7q3MoYI/XPZekRoppqF8mdyLKbwkWRXRreiqGhPBrxyH3o0ZDPC G6ImQ+/ortwNqqLtLRKePAWKm/iD2kbMfMPJoEzs/gOcJc+H5RrezQ9LR RaUdZCbQVfWW9j0RAKvDK6YrJbpFbQYeq2Dvw7NxvXFfSK5AxCT/GFk+R caBEkSHGS5wq2xR3PllL/QSu2OlnHentEZcVtKml59VA0EnpMU75OqyIf WBOy+02qwxoWZJ19VWhjqBSZZMGVpp1f69Q32BHzRNx1pOVRXQtux3wHi A==; X-CSE-ConnectionGUID: XFA+Es8NSuGZ35o/ptJuXA== X-CSE-MsgGUID: xCKVpkEwQUqLylnrE+UDmw== X-IronPort-AV: E=McAfee;i="6700,10204,11392"; a="70425135" X-IronPort-AV: E=Sophos;i="6.15,184,1739865600"; d="scan'208";a="70425135" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Apr 2025 00:46:01 -0700 X-CSE-ConnectionGUID: LjaaaMbSS6O/4MdG+QSv6Q== X-CSE-MsgGUID: vSoDpjDVSS+Qcx1gAssPUg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,184,1739865600"; d="scan'208";a="131785136" Received: from sgruszka-mobl.ger.corp.intel.com (HELO localhost) ([10.246.8.237]) by ORVIESA003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Apr 2025 00:45:59 -0700 From: Stanislaw Gruszka To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal , Hans de Goede , Laurent Pinchart , Kieran Bingham , Sakari Ailus Subject: [PATCH v7 1/5] libcamera: v4l2_device: add frame start event helpers Date: Thu, 3 Apr 2025 09:45:47 +0200 Message-Id: <20250403074551.263496-2-stanislaw.gruszka@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250403074551.263496-1-stanislaw.gruszka@linux.intel.com> References: <20250403074551.263496-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. Reviewed-by: Kieran Bingham # v3 Reviewed-by: Laurent Pinchart # v5 Signed-off-by: Stanislaw Gruszka --- include/libcamera/internal/v4l2_device.h | 1 + src/libcamera/v4l2_device.cpp | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/include/libcamera/internal/v4l2_device.h b/include/libcamera/internal/v4l2_device.h index affe52c2ad3f..a647c96a5eb7 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 2f65a43a0547..0db92c19ca4a 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -449,6 +449,28 @@ std::string V4L2Device::devicePath() const return path; } +/** + * \brief Check if frame start event 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(). + * + * \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