From patchwork Fri Feb 21 11:26:09 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislaw Gruszka X-Patchwork-Id: 22819 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 8D654BEFBE for ; Fri, 21 Feb 2025 11:26:24 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3FC17686AC; Fri, 21 Feb 2025 12:26:24 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="Pl8LNmVz"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4DE3661857 for ; Fri, 21 Feb 2025 12:26:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1740137182; x=1771673182; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UW4k0FDkjeG9k7lQqLjmcgK/9CP9EV+BixgUzzq22kE=; b=Pl8LNmVzff8L6T3IXFTGRCLdAF1OVqvBLj+G6R89GuOZcBSQMh+j2Hb5 juaf9P6A0IGGwEwTrtpV+epK7R2T5ACwnn0o0zKCC2qpnGAToQWUz+HAh UDKHnf/YqnK3YDE6NRlAaJjrfupVPKXzsh+yy2NW9KYvHG27UVMxhS/CQ tz+qjsl2QS+hpLj5i5U8r+nZG2tDVLFt1Ldrvl4Ru9uBBkTPdcjeMDPXg ZhnACEkg8fILxRarZouo7LW4HQg625OXiU4qOGxS2si40O4lcey0DhDiK GSHiQeo0Srlh/gvJ37zJRLy4QOytgNX87ShNBL86VOq0avIj2ik5QZNr2 Q==; X-CSE-ConnectionGUID: YQJiRlP9QjiUPM4HtHemBg== X-CSE-MsgGUID: h6LCZ0xwQ4C6Ro0OWGmBQA== X-IronPort-AV: E=McAfee;i="6700,10204,11351"; a="51596199" X-IronPort-AV: E=Sophos;i="6.13,304,1732608000"; d="scan'208";a="51596199" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Feb 2025 03:26:19 -0800 X-CSE-ConnectionGUID: UyJi8bGUQUqOGrotsikGHA== X-CSE-MsgGUID: m2rOIAt7TBKjKzN+9soF1Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.13,304,1732608000"; d="scan'208";a="119970879" Received: from sgruszka-mobl.ger.corp.intel.com (HELO localhost) ([10.245.97.15]) by fmviesa005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Feb 2025 03:26:17 -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 v4 1/2] libcamera: v4l2_device: add frame start event helpers Date: Fri, 21 Feb 2025 12:26:09 +0100 Message-Id: <20250221112610.42402-2-stanislaw.gruszka@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250221112610.42402-1-stanislaw.gruszka@linux.intel.com> References: <20250221112610.42402-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 --- include/libcamera/internal/v4l2_device.h | 2 ++ src/libcamera/v4l2_device.cpp | 25 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/include/libcamera/internal/v4l2_device.h b/include/libcamera/internal/v4l2_device.h index affe52c2..edbd7c32 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() const { return frameStartEnabled_; } int setFrameStartEnabled(bool enable); Signal frameStart; diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index 2f65a43a..ca718897 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -449,6 +449,31 @@ 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; +} + +/** + * \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