From patchwork Wed Mar 5 13:52:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislaw Gruszka X-Patchwork-Id: 22926 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 54037C3257 for ; Wed, 5 Mar 2025 13:53:10 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DB3096882A; Wed, 5 Mar 2025 14:53:09 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="R+t6O4OY"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1EAFA68778 for ; Wed, 5 Mar 2025 14:53:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1741182788; x=1772718788; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nPBqYe39DSbUhGu8/lTzGS3nK3uxuajGUEnAh74+aSI=; b=R+t6O4OYNGVyATXVW+d6CSzXmfwed0nJnNNAnhONjlNzlzl+xPh8STvI QKObRRvcHjBF500TimhkqSig9ApUoMSNGEyAmwsS/Cf+S3mi7DCnFn0o7 2yjmbCqiRHlErgXu5bYne5/LK715l3i+HwGAFMq7zkAtIsmp1RXuPaq+W c92OUFAE3ZEbp66tswjVjhHTURgw4koNXBhKbrSkKXCSqKBmygSss8oqY Jk/XXpGNqaqyVGQ/Vd4/V2HCVhfSe+GnngPj3MptoW4DeA7SIhh8vJ53D pPp97rOlNd/GsoTxxWkLwAHFTJa/VqxozIdglERLH2AYWVoMLARhQcubT Q==; X-CSE-ConnectionGUID: wgjlZ5l9RW2k63891m2nVw== X-CSE-MsgGUID: f1wjlfgCT/eAJLXbzMOK7g== X-IronPort-AV: E=McAfee;i="6700,10204,11363"; a="53134759" X-IronPort-AV: E=Sophos;i="6.14,223,1736841600"; d="scan'208";a="53134759" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Mar 2025 05:53:07 -0800 X-CSE-ConnectionGUID: j+ve62gPQPS1q4neK5ENYQ== X-CSE-MsgGUID: qq20bN+LRuqfnxO/i94l5w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.14,223,1736841600"; d="scan'208";a="123735769" Received: from sgruszka-mobl.ger.corp.intel.com (HELO localhost) ([10.245.112.97]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Mar 2025 05:53:04 -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 v6 1/5] libcamera: v4l2_device: add frame start event helpers Date: Wed, 5 Mar 2025 14:52:52 +0100 Message-Id: <20250305135256.801351-2-stanislaw.gruszka@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250305135256.801351-1-stanislaw.gruszka@linux.intel.com> References: <20250305135256.801351-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 | 18 ++++++++++++++++++ 2 files changed, 19 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..c3e9cd4a 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -449,6 +449,24 @@ 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 From patchwork Wed Mar 5 13:52:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislaw Gruszka X-Patchwork-Id: 22927 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 26C9EC3257 for ; Wed, 5 Mar 2025 13:53:14 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CA4CF68826; Wed, 5 Mar 2025 14:53:13 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="WQEXXZfS"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0D42C68823 for ; Wed, 5 Mar 2025 14:53:11 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1741182793; x=1772718793; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=RL+FnaRLMxhqroKIeL15KGsCJK4hX7iIspRBBAocApQ=; b=WQEXXZfS8H0JbNQd8FO36GI2TZv8/h/GtWRsMPdUKAvQbb7/s7aXG8wa zVceeI0t+MfUT6+zLyJCJozyHq/j6EyGorZdlZ+WlTIo/H2Q6q6keDLOO 07HvwqNhdzWP8yNNz3BTWv7sCwlMQ6OdMb+EbFFSaUkksYKnF5geDOS1B uQmx5qOmSEeOY0x6yrqs82jC6YIOGFNyn3Cwg8E9LGN2eAn6mjJxT2L+2 EPff64fQGPVm+t1ICnk5quwEKVKGroelvkSqcTH6yZFDta1EA62kYSY3H tq3QoRp/SeQSmQndsGRTnhPrkZllV2xknbWarAsFDuyvQTAFYMSHVEEr1 Q==; X-CSE-ConnectionGUID: Sly69FHqQzCpcHgVrzh88w== X-CSE-MsgGUID: JowmiEMsR66zUPUgQxdbZA== X-IronPort-AV: E=McAfee;i="6700,10204,11363"; a="53134769" X-IronPort-AV: E=Sophos;i="6.14,223,1736841600"; d="scan'208";a="53134769" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Mar 2025 05:53:12 -0800 X-CSE-ConnectionGUID: KInF+gRkTcivMbZqi+OXfQ== X-CSE-MsgGUID: xULXDFEeTAOeeJ71//WIzg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.14,223,1736841600"; d="scan'208";a="123735779" Received: from sgruszka-mobl.ger.corp.intel.com (HELO localhost) ([10.245.112.97]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Mar 2025 05:53:09 -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 v6 2/5] pipeline: simple: Connect/disconnect frameStart signal at start/stop time Date: Wed, 5 Mar 2025 14:52:53 +0100 Message-Id: <20250305135256.801351-3-stanislaw.gruszka@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250305135256.801351-1-stanislaw.gruszka@linux.intel.com> References: <20250305135256.801351-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" The frameStart signal from the frame start emitter is connected in the configure() function, and is never disconnected. This means that each time the camera is configured a new connection is made, causing the DelayedControls::applyControls() to be called multiple times. Fix it by connecting and disconnecting the signal when starting and stopping the camera. Co-developed-by: Hans de Goede Signed-off-by: Hans de Goede Co-developed-by: Laurent Pinchart Signed-off-by: Laurent Pinchart Signed-off-by: Stanislaw Gruszka Reviewed-by: Stefan Klug --- src/libcamera/pipeline/simple/simple.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index 6e039bf3..8345a771 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -1285,8 +1285,6 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c) data->delayedCtrls_ = std::make_unique(data->sensor_->device(), params); - data->video_->frameStart.connect(data->delayedCtrls_.get(), - &DelayedControls::applyControls); StreamConfiguration inputCfg; inputCfg.pixelFormat = pipeConfig->captureFormat; @@ -1354,6 +1352,9 @@ int SimplePipelineHandler::start(Camera *camera, [[maybe_unused]] const ControlL video->bufferReady.connect(data, &SimpleCameraData::imageBufferReady); + data->video_->frameStart.connect(data->delayedCtrls_.get(), + &DelayedControls::applyControls); + ret = video->streamOn(); if (ret < 0) { stop(camera); @@ -1386,6 +1387,9 @@ void SimplePipelineHandler::stopDevice(Camera *camera) SimpleCameraData *data = cameraData(camera); V4L2VideoDevice *video = data->video_; + data->video_->frameStart.disconnect(data->delayedCtrls_.get(), + &DelayedControls::applyControls); + if (data->useConversion_) { if (data->converter_) data->converter_->stop(); From patchwork Wed Mar 5 13:52:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislaw Gruszka X-Patchwork-Id: 22928 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 3C295C3257 for ; Wed, 5 Mar 2025 13:53:19 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E4C5B68823; Wed, 5 Mar 2025 14:53:18 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="E2wbPZ2w"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B011568823 for ; Wed, 5 Mar 2025 14:53:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1741182797; x=1772718797; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=idfQbkN/xGzKp15crcBiqWgyKpcofe1e6bWptz43C2I=; b=E2wbPZ2wG3o/Gl9RMKCbod3vLsnXQ1RV9YumfOPhim3jlrWoYWa+YWlX bUDPVS1U5Ss8TUt+CeDB3yGeLaEsGXY17PbMGpy4VjQml0K8S8ZwcgIHE OPTmq2cPmcpKWHcbNIxATvQ+cRrj7XHJRNSzwxI6eMwSCtgkfgFA3MkBh oBpoMer/5v0UpA0DrEs6tgPGrT+lhE5C7aYOXGvYBEyB6OShDyu2Oupy1 0d+IvX6d5SbGMUkDPly/dKe37d9eo9czt3edm0YwzFhrJWi8KZ2MSZJNn wM3fQQFiL4kriTzckvwG/ntEiLeC8sCZewKDebfsMrHVHDjKV/csEtjHz w==; X-CSE-ConnectionGUID: q5j2Qv4wRkmebpK97Pf1jQ== X-CSE-MsgGUID: Fw/i/xVJQtiI99fUxfzsPA== X-IronPort-AV: E=McAfee;i="6700,10204,11363"; a="53134786" X-IronPort-AV: E=Sophos;i="6.14,223,1736841600"; d="scan'208";a="53134786" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Mar 2025 05:53:17 -0800 X-CSE-ConnectionGUID: vM1BAb64SRa6mOUyyw7Qzg== X-CSE-MsgGUID: 6mjgmGQMTXuq3UTCmzgJXQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.14,223,1736841600"; d="scan'208";a="123735793" Received: from sgruszka-mobl.ger.corp.intel.com (HELO localhost) ([10.245.112.97]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Mar 2025 05:53:14 -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 v6 3/5] pipeline: simple: Enable frame start events Date: Wed, 5 Mar 2025 14:52:54 +0100 Message-Id: <20250305135256.801351-4-stanislaw.gruszka@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250305135256.801351-1-stanislaw.gruszka@linux.intel.com> References: <20250305135256.801351-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" The simple pipeline handler uses frame start events to apply sensor controls through the DelayedControls class. The setSensorControls() function applies the controls directly, which would result in controls being applied twice, if it wasn't for the fact that the pipeline handler forgot to enable the frame start events in the first place. Those two issues cancel each other, but cause controls to always be applied directly. Fix the issue by only applying controls directly in setSensorControls() if no frame start event emitter is available, and by enabling the frame start events in startDevice() otherwise. Disable them in stopDevice() for symmetry. Co-developed-by: Hans de Goede Signed-off-by: Hans de Goede Co-developed-by: Laurent Pinchart Signed-off-by: Laurent Pinchart Signed-off-by: Stanislaw Gruszka Reviewed-by: Stefan Klug --- src/libcamera/pipeline/simple/simple.cpp | 49 +++++++++++++++++++++--- 1 file changed, 43 insertions(+), 6 deletions(-) diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index 8345a771..7be49017 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -277,6 +277,7 @@ public: std::list entities_; std::unique_ptr sensor_; V4L2VideoDevice *video_; + V4L2Subdevice *frameStartEmitter_; std::vector configs_; std::map> formats_; @@ -579,6 +580,20 @@ int SimpleCameraData::init() properties_ = sensor_->properties(); + /* Find the first subdev that can generate a frame start signal, if any. */ + frameStartEmitter_ = nullptr; + for (const Entity &entity : entities_) { + V4L2Subdevice *sd = pipe->subdev(entity.entity); + if (!sd || !sd->supportsFrameStartEvent()) + continue; + + LOG(SimplePipeline, Debug) + << "Using frameStart signal from '" + << entity.entity->name() << "'"; + frameStartEmitter_ = sd; + break; + } + return 0; } @@ -897,8 +912,18 @@ void SimpleCameraData::ispStatsReady(uint32_t frame, uint32_t bufferId) void SimpleCameraData::setSensorControls(const ControlList &sensorControls) { delayedCtrls_->push(sensorControls); - ControlList ctrls(sensorControls); - sensor_->setControls(&ctrls); + /* + * Directly apply controls now if there is no frameStart signal. + * + * \todo Applying controls directly not only increases the risk of + * applying them to the wrong frame (or across a frame boundary), + * but it also bypasses delayedCtrls_, creating AGC regulation issues. + * Both problems should be fixed. + */ + if (!frameStartEmitter_) { + ControlList ctrls(sensorControls); + sensor_->setControls(&ctrls); + } } /* Retrieve all source pads connected to a sink pad through active routes. */ @@ -1323,6 +1348,7 @@ int SimplePipelineHandler::start(Camera *camera, [[maybe_unused]] const ControlL { SimpleCameraData *data = cameraData(camera); V4L2VideoDevice *video = data->video_; + V4L2Subdevice *frameStartEmitter = data->frameStartEmitter_; int ret; const MediaPad *pad = acquirePipeline(data); @@ -1352,8 +1378,15 @@ int SimplePipelineHandler::start(Camera *camera, [[maybe_unused]] const ControlL video->bufferReady.connect(data, &SimpleCameraData::imageBufferReady); - data->video_->frameStart.connect(data->delayedCtrls_.get(), - &DelayedControls::applyControls); + if (frameStartEmitter) { + ret = frameStartEmitter->setFrameStartEnabled(true); + if (ret) { + stop(camera); + return ret; + } + frameStartEmitter->frameStart.connect(data->delayedCtrls_.get(), + &DelayedControls::applyControls); + } ret = video->streamOn(); if (ret < 0) { @@ -1386,9 +1419,13 @@ void SimplePipelineHandler::stopDevice(Camera *camera) { SimpleCameraData *data = cameraData(camera); V4L2VideoDevice *video = data->video_; + V4L2Subdevice *frameStartEmitter = data->frameStartEmitter_; - data->video_->frameStart.disconnect(data->delayedCtrls_.get(), - &DelayedControls::applyControls); + if (frameStartEmitter) { + frameStartEmitter->setFrameStartEnabled(false); + frameStartEmitter->frameStart.disconnect(data->delayedCtrls_.get(), + &DelayedControls::applyControls); + } if (data->useConversion_) { if (data->converter_) From patchwork Wed Mar 5 13:52:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislaw Gruszka X-Patchwork-Id: 22929 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 792BBC3257 for ; Wed, 5 Mar 2025 13:53:24 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1FF68688AE; Wed, 5 Mar 2025 14:53:24 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="Fteimdnc"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B9D7A68823 for ; Wed, 5 Mar 2025 14:53: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=1741182802; x=1772718802; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=X3265kruYMN74Wz+fEsqq5xfOV0S2TnNFYuszevpovw=; b=FteimdncfDFNBHTNyHs1HH7N41uMB6zq2GDm4yH2uDxWyvIprHuqrLA5 RwwXjnGJtAUzDd+m4LZpQdVrL04lcF85W44LyIA2EIOdTI1nh/pgxrV6g UTXApLVBMKT0T3CzDSKPG2ZmLBJsLMPCamnUEQdCFUyy2nXSXvA3VwXsN kt8qzKLF0156ppF2PL1HqLrzKx0ZN04kOZ0j1FLVRW4O0ufxhqEhGgLSl uyKvu87eiZzYLflox5/iylVJXcyiZ2ViYvEPPtpomtGlN0YXV1eYBH/hB x8dF+OI89f9I0jKKUg8dDqJ6NppSRVrR+pbbtnRzNcWQu+MQvi0l0orWL w==; X-CSE-ConnectionGUID: GY04Xb91T8+UnhlItrp7GQ== X-CSE-MsgGUID: 2ouQMS58RPKJ3wMJnFZNZA== X-IronPort-AV: E=McAfee;i="6700,10204,11363"; a="53134794" X-IronPort-AV: E=Sophos;i="6.14,223,1736841600"; d="scan'208";a="53134794" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Mar 2025 05:53:22 -0800 X-CSE-ConnectionGUID: k97e7uQnTkK2TekvrlDA+A== X-CSE-MsgGUID: IA4UaEsOQtquPuDT4bjR/Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.14,223,1736841600"; d="scan'208";a="123735805" Received: from sgruszka-mobl.ger.corp.intel.com (HELO localhost) ([10.245.112.97]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Mar 2025 05:53:19 -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 v6 4/5] pipeline: simple: Create DelayedControls instance once only Date: Wed, 5 Mar 2025 14:52:55 +0100 Message-Id: <20250305135256.801351-5-stanislaw.gruszka@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250305135256.801351-1-stanislaw.gruszka@linux.intel.com> References: <20250305135256.801351-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" From: Laurent Pinchart The DelayedControls instance for the camera sensor is created in SimplePipelineHandler::configure(). Constant deletion and reconstruction of a new object is unnecessary, as the control delays are an intrinsic property of the sensor and are known at initialization time. Move the DelayedControls creation to the SimpleCameraData class constructor. Signed-off-by: Laurent Pinchart Signed-off-by: Stanislaw Gruszka Reviewed-by: Stefan Klug --- src/libcamera/pipeline/simple/simple.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index 7be49017..58aa3dba 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -489,6 +489,13 @@ SimpleCameraData::SimpleCameraData(SimplePipelineHandler *pipe, if (!sensor_) return; + const CameraSensorProperties::SensorDelays &delays = sensor_->sensorDelays(); + std::unordered_map params = { + { V4L2_CID_ANALOGUE_GAIN, { delays.gainDelay, false } }, + { V4L2_CID_EXPOSURE, { delays.exposureDelay, false } }, + }; + delayedCtrls_ = std::make_unique(sensor_->device(), params); + LOG(SimplePipeline, Debug) << "Found pipeline: " << utils::join(entities_, " -> ", @@ -1302,15 +1309,6 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c) if (outputCfgs.empty()) return 0; - const CameraSensorProperties::SensorDelays &delays = data->sensor_->sensorDelays(); - std::unordered_map params = { - { V4L2_CID_ANALOGUE_GAIN, { delays.gainDelay, false } }, - { V4L2_CID_EXPOSURE, { delays.exposureDelay, false } }, - }; - data->delayedCtrls_ = - std::make_unique(data->sensor_->device(), - params); - StreamConfiguration inputCfg; inputCfg.pixelFormat = pipeConfig->captureFormat; inputCfg.size = pipeConfig->captureSize; From patchwork Wed Mar 5 13:52:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislaw Gruszka X-Patchwork-Id: 22930 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 53119C3257 for ; Wed, 5 Mar 2025 13:53:29 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 09A4768920; Wed, 5 Mar 2025 14:53:29 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="gEdvvQux"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9CD3A6890C for ; Wed, 5 Mar 2025 14:53:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1741182807; x=1772718807; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=90F0usb0Gl3r9ryM8lhKN64VSuwrkfvSPBXQJEicPuk=; b=gEdvvQuxMZuKPbva1rudHPJsr+NHaQnwcs0VnhfjEMWPesYiidBWujLd Zsbmo6djax+R2D67u9qFSS8BewNbxwuUmdFBAYgFAG44khIJ+44jN+QRb vFmEt48kUTJebt1+LVjrGX29A8GZk2463BZMPDwLY+2GNm3lDQjf/QxTw Azqvy4GD1m1GcT7mX1peFe1uXDftwFPbxTJpJu8Cmj1GkLTZInkbE29qC RmLvPo2vaIyk2a3Db2UuF36tkHYoxr+1sQqyiX9RjBoJGdkh0jvGkIKpo bIA4R69BDJS41unNkilr0imasZZqMW8QadrdZcWJViu7/X9MVvIYeW+xs A==; X-CSE-ConnectionGUID: 3V0hcVEIS4Sjl7SzK+nL4g== X-CSE-MsgGUID: K+iuTSanThi9o7w3SGf2ng== X-IronPort-AV: E=McAfee;i="6700,10204,11363"; a="53134801" X-IronPort-AV: E=Sophos;i="6.14,223,1736841600"; d="scan'208";a="53134801" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Mar 2025 05:53:27 -0800 X-CSE-ConnectionGUID: T+MviJAvQ9+H42VXWGfHaA== X-CSE-MsgGUID: 5NP7lTviSFO4RpOQPtTMRw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.14,223,1736841600"; d="scan'208";a="123735829" Received: from sgruszka-mobl.ger.corp.intel.com (HELO localhost) ([10.245.112.97]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Mar 2025 05:53:24 -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 v6 5/5] pipeline: simple: Reset delayedCtrls at start. Date: Wed, 5 Mar 2025 14:52:56 +0100 Message-Id: <20250305135256.801351-6-stanislaw.gruszka@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250305135256.801351-1-stanislaw.gruszka@linux.intel.com> References: <20250305135256.801351-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" Similar like in other pipelines (IPU3, rpi) avoid using stale values of DelayedControls class when the same camera is started second time. Co-developed-by: Hans de Goede Signed-off-by: Hans de Goede Signed-off-by: Stanislaw Gruszka Reviewed-by: Stefan Klug Reviewed-by: Kieran Bingham --- src/libcamera/pipeline/simple/simple.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index 58aa3dba..659b1123 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -1376,6 +1376,7 @@ int SimplePipelineHandler::start(Camera *camera, [[maybe_unused]] const ControlL video->bufferReady.connect(data, &SimpleCameraData::imageBufferReady); + data->delayedCtrls_->reset(); if (frameStartEmitter) { ret = frameStartEmitter->setFrameStartEnabled(true); if (ret) {