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 From patchwork Tue Feb 25 16:41:13 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislaw Gruszka X-Patchwork-Id: 22866 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 433DFBDB1C for ; Tue, 25 Feb 2025 16:41:43 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id EF9676872A; Tue, 25 Feb 2025 17:41:42 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="X0FqoEmv"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EE9016871E for ; Tue, 25 Feb 2025 17:41:39 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1740501700; x=1772037700; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=e6Z2+Xw95ppyYevHMwKDI4aOyvzg2uhgO40wxVD/efM=; b=X0FqoEmv1BSlzN83EE8F5ezhUipw7OoluIZxXA6pu8yX60rIPNkeVKTD tcgqcI+uAh/KUeGycd2G9gO+6NCoD/AGQcTqp/3QZvYExgNOp1BaUMKU2 VdjQyyigIasoQSCxVC9eB2kvVmDm8QMhVzw1VAGeOpEt8/U0nf5zrJHiB QNzk/Un17FkplBWEyDNh9j1LsCc8IZrzvwT8Ps5L86ZHL3jsxvRVkBA8Q ieH+vKOwSspZi0CLAuFQPQ3cAhmaQZL6Z5kukHPr3WsKbZdPGu4FEPKrM Q/TZ99Dk9Ng/VRygHFvHtiCv0dt94Qmd+MDMRgENnFZn+WmNWJb87L1VB Q==; X-CSE-ConnectionGUID: 7QwR7bjORpmGA1g92mr5kg== X-CSE-MsgGUID: i88yItXDTPqwBsV41s8ClQ== X-IronPort-AV: E=McAfee;i="6700,10204,11314"; a="52740852" X-IronPort-AV: E=Sophos;i="6.12,310,1728975600"; d="scan'208";a="52740852" 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:39 -0800 X-CSE-ConnectionGUID: xIF2eVbPT2C64fnYUfQmZg== X-CSE-MsgGUID: QpFCfi4uToGi+BJPOD3zTA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,224,1728975600"; d="scan'208";a="121689794" 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:37 -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 2/5] pipeline: simple: Use proper device for frame start events Date: Tue, 25 Feb 2025 17:41:13 +0100 Message-Id: <20250225164116.414301-3-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" Currently we use frame start event from video capture device to apply controls. But the capture device might not generate the events. Usually CSI-2 receiver is proper device to subscribe for start frame events. To fix, loop over devices in the pipeline to find the one that supports events and use it as start frame emitter. Co-developed-by: Hans de Goede Signed-off-by: Hans de Goede Signed-off-by: Stanislaw Gruszka Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- src/libcamera/pipeline/simple/simple.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index 6e039bf3..063a098f 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,19 @@ int SimpleCameraData::init() properties_ = sensor_->properties(); + frameStartEmitter_ = nullptr; + for (const Entity &entity : entities_) { + V4L2Subdevice *sd = pipe->subdev(entity.entity); + if (!sd || !sd->supportsFrameStartEvent()) + continue; + + LOG(SimplePipeline, Debug) + << "Using " << entity.entity->name() << " frameStart signal"; + + frameStartEmitter_ = sd; + break; + } + return 0; } @@ -1215,6 +1229,7 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c) static_cast(c); SimpleCameraData *data = cameraData(camera); V4L2VideoDevice *video = data->video_; + V4L2Subdevice *frameStartEmitter = data->frameStartEmitter_; int ret; /* @@ -1285,8 +1300,9 @@ 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); + if (frameStartEmitter) + frameStartEmitter->frameStart.connect(data->delayedCtrls_.get(), + &DelayedControls::applyControls); StreamConfiguration inputCfg; inputCfg.pixelFormat = pipeConfig->captureFormat; From patchwork Tue Feb 25 16:41:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislaw Gruszka X-Patchwork-Id: 22867 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 D48EBBDB1C for ; Tue, 25 Feb 2025 16:41:48 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 92F3D6872D; Tue, 25 Feb 2025 17:41:48 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="ClkalRXy"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 567D06871F for ; Tue, 25 Feb 2025 17:41:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1740501707; x=1772037707; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nS0he6M5+OnKyzidaXn9nLdjZWwtir6ALzW2zaXi0yQ=; b=ClkalRXyLENlLRliCsQrnXNc7YbLU9ClxG4fOHFTxtaEP6Q46aJBLW/B Z4LIWmbK+kLx9geuLab4QBuVJysKHeyvZDN0X0XmTwIViAHjjmYW4U7vd tmEqo9LTgkS400YS1u5OiC9hmwfSvF0BLLH98D83ufbJ6oa3Jjf5oig/X ewCGxCaOwZSNJQ1TDqHiBeJ3Li9EEtD9K47QB3VmPFgBcjIJYghMSj+3t xzcB71vxGBoodYtYOtLole5wBgyQAVpTUA436S1SaSOWYwWyESyHs3eto CZMoOrHROfDZzKNGFbocnj84HZYgZtRgm8kO9iFYu+u/KpMUHNB4rpB72 Q==; X-CSE-ConnectionGUID: gdOkO2jQTjKTK138JBipjw== X-CSE-MsgGUID: cl6RS+4URfGegkRfR2ZNHA== X-IronPort-AV: E=McAfee;i="6700,10204,11356"; a="51948277" X-IronPort-AV: E=Sophos;i="6.13,314,1732608000"; d="scan'208";a="51948277" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Feb 2025 08:41:45 -0800 X-CSE-ConnectionGUID: sp+c/Qg9SVWuZM571qW0Xg== X-CSE-MsgGUID: UtSGXvnRQkSvuO6USAR7Bw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.13,314,1732608000"; d="scan'208";a="116426747" Received: from sgruszka-mobl.ger.corp.intel.com (HELO localhost) ([10.245.115.185]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Feb 2025 08:41:42 -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 3/5] pipeline: simple: Connect and disconnect start frame events Date: Tue, 25 Feb 2025 17:41:14 +0100 Message-Id: <20250225164116.414301-4-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" Enable frame events on the emitter device during SimplePipelineHandler::start(), move signal connection there from SimplePipelineHandler::configure(). Also reset delayed controls on start() to prevent using stale values. Accordingly disable/disconnect on SimplePipelineHandler::stopDevice(). This fixes the assertion like below: ../src/libcamera/delayed_controls.cpp:227: libcamera::ControlList libcamera::DelayedControls::get(uint32_t): Assertion `info.type() != ControlTypeNone' failed which can happen rarely at the beginning of streaming when ControlRingBuffer is not yet filled and there are errors on CSI-2. In such rare scenario we can have call to DelayedControls::get() with frame number that exceed number of saved entries. Handing frame start signal assure we do DelayedConntrols::applyControls() with (possibly out of sequence) frame number and later call to DelayedControls::get() will get proper not-empty control entry. Bug: https://bugs.libcamera.org/show_bug.cgi?id=241 Co-developed-by: Hans de Goede Signed-off-by: Hans de Goede Signed-off-by: Stanislaw Gruszka --- src/libcamera/pipeline/simple/simple.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) -- 2.43.0 diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index 063a098f..774c7824 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -1229,7 +1229,6 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c) static_cast(c); SimpleCameraData *data = cameraData(camera); V4L2VideoDevice *video = data->video_; - V4L2Subdevice *frameStartEmitter = data->frameStartEmitter_; int ret; /* @@ -1300,9 +1299,6 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c) data->delayedCtrls_ = std::make_unique(data->sensor_->device(), params); - if (frameStartEmitter) - frameStartEmitter->frameStart.connect(data->delayedCtrls_.get(), - &DelayedControls::applyControls); StreamConfiguration inputCfg; inputCfg.pixelFormat = pipeConfig->captureFormat; @@ -1341,6 +1337,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); @@ -1370,6 +1367,17 @@ 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) { + stop(camera); + return ret; + } + frameStartEmitter->frameStart.connect(data->delayedCtrls_.get(), + &DelayedControls::applyControls); + } + ret = video->streamOn(); if (ret < 0) { stop(camera); @@ -1401,6 +1409,13 @@ void SimplePipelineHandler::stopDevice(Camera *camera) { SimpleCameraData *data = cameraData(camera); V4L2VideoDevice *video = data->video_; + V4L2Subdevice *frameStartEmitter = data->frameStartEmitter_; + + if (frameStartEmitter) { + frameStartEmitter->setFrameStartEnabled(false); + frameStartEmitter->frameStart.disconnect(data->delayedCtrls_.get(), + &DelayedControls::applyControls); + } if (data->useConversion_) { if (data->converter_) From patchwork Tue Feb 25 16:41:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislaw Gruszka X-Patchwork-Id: 22868 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 DE032BDB1C for ; Tue, 25 Feb 2025 16:41:51 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8A61268732; Tue, 25 Feb 2025 17:41:51 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="UlqsvkGj"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id AFD5E6871F for ; Tue, 25 Feb 2025 17:41:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1740501710; x=1772037710; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Y5wdfFYDBMNLyP2m5ayrPxIgyqj/crVleZ3xSB+6TJs=; b=UlqsvkGjLNlpplORm7TLTTFz0Vz+YHvIP9jJMAa3Lr4c5LRdmALhHRHJ uuz+sMT0nO2E0FFjYN75y/T05lWwaC2h0juFTIAVPt1vjXcZALbdnhBTh jRJJitUWO6sdIQ1jOCAga1GvwZHuzcuyonPwpVkms2wTuF9AeYcgithyl Z2mE1c1zrXEtz1w0drtrVsugk8QwmG71RR8ORABVfh0SRwNjxUVsUsFNH NyCVijt1yGKhgOc832X35s42zCoaI21OPX/RLTNPtt6+WE5sixLpXk/P7 o9b3tTGEbXxvE8c9cExk7dPLkyS15OCYT7cQjdehG1UaW7c4oBH9Q/P3y g==; X-CSE-ConnectionGUID: 5GfbR0Z2RKevaNtI0aGAxQ== X-CSE-MsgGUID: +V8ganN5R/e8OGbMyrUkzg== X-IronPort-AV: E=McAfee;i="6700,10204,11356"; a="51948295" X-IronPort-AV: E=Sophos;i="6.13,314,1732608000"; d="scan'208";a="51948295" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Feb 2025 08:41:49 -0800 X-CSE-ConnectionGUID: XKvuQk59THOMGtVeZR2Wsg== X-CSE-MsgGUID: JxRgiii0Rtm116MdVUFwHg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.13,314,1732608000"; d="scan'208";a="116426802" Received: from sgruszka-mobl.ger.corp.intel.com (HELO localhost) ([10.245.115.185]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Feb 2025 08:41:47 -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 4/5] pipeline: simple: Do not apply controls twice Date: Tue, 25 Feb 2025 17:41:15 +0100 Message-Id: <20250225164116.414301-5-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" Apply controls directly only when there is no start frame emitter device. Co-developed-by: Hans de Goede Signed-off-by: Hans de Goede Signed-off-by: Stanislaw Gruszka Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- src/libcamera/pipeline/simple/simple.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index 774c7824..b92b738b 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -911,8 +911,11 @@ 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 */ + if (!frameStartEmitter_) { + ControlList ctrls(sensorControls); + sensor_->setControls(&ctrls); + } } /* Retrieve all source pads connected to a sink pad through active routes. */ From patchwork Tue Feb 25 16:41:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislaw Gruszka X-Patchwork-Id: 22869 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 EBAE0BDB1C for ; Tue, 25 Feb 2025 16:41:57 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A1EFA68733; Tue, 25 Feb 2025 17:41:57 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="Phd9DzaU"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 01D5D6872D for ; Tue, 25 Feb 2025 17:41:55 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1740501716; x=1772037716; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5TUsit5KkBSqkcFHmQvWJf8nR/TKdJIJxtM4z//UWEI=; b=Phd9DzaU7UhxK3lMFekkE5gTX3cjkw+45ca+Bd3s1Hi6FXZb0nRqYVXe CrwkN/8cydEtzXEhGuhRo0mpJgc//ZRhygzCYyhVQPTOz/tVlqNGG7WeL XrEB/SU8ubiTM5eKULyqX6Q9dp1bZmED6OLl9kMtpmT77vWQJ2hllBeT5 gVugpVxSURsZIaJP62GzrzOL9tWDTOlh23McBR7HrnZoI7PwTHYqQRz5r M1tmOwt4dN8KI/UiUzBynzAURPYAWM/eOLr6H2fKo/aC8qHhWnatbvyJs l5s8+unJT9Em14s1+DadIGdf+mVCHlN72l4ZMIxAL0ON7imUyw6upJCWZ A==; X-CSE-ConnectionGUID: rQovXHqiQDuTZzPtDby4Qw== X-CSE-MsgGUID: 9K1jAHTqROygJrRvzLMpdw== X-IronPort-AV: E=McAfee;i="6700,10204,11314"; a="52740869" X-IronPort-AV: E=Sophos;i="6.12,310,1728975600"; d="scan'208";a="52740869" 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:54 -0800 X-CSE-ConnectionGUID: wdjBb0SNSpiofxhDolBgVg== X-CSE-MsgGUID: WbwzeAJzQj6R/X+S42lwdw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,224,1728975600"; d="scan'208";a="121689887" 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:51 -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 5/5] pipeline: simple: Create DelayedControls instance once only Date: Tue, 25 Feb 2025 17:41:16 +0100 Message-Id: <20250225164116.414301-6-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" 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: Kieran Bingham --- 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 b92b738b..73a4138e 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_, " -> ", @@ -1294,15 +1301,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;