From patchwork Tue Mar 7 10:30:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18347 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 CA8D0C3262 for ; Tue, 7 Mar 2023 10:30:23 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 193DD626C2; Tue, 7 Mar 2023 11:30:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1678185022; bh=p4NX4NT6AUG8DZqOr71i/qWbOUcv1IEEHvyDAOhZ0kA=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=KByPWuoyqr0CNdsOQznUURdiwC6h9O4S0dE1MkPbxwrT9+Q1DCFeF8aJPDv23eAcX ED7/ONKINIeHUKbF74/LzmsnM00wUMbV28/vbsmEygvGkDxYGmYJ47jMgD9QFZIM0Q EJWTKG/cN++Et+fuvjXlsoVAGYJIdUVATYSn87RZoE1Oux6bTBkBQGfLeR1k2bo/eR 2w5j46UhbEqYHwPafz2fxkpAktiJib9YEqsnyIAYC4S0a7spwfPP+KsjmM3n7GuPIx HijZGcyM35C7FWyX50zLqSj+eksF0LR82Ah+FRaPAtEg6oCtxQH9s9I6//Xit0CMAk NZh4IoxnRETjA== Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 168DA6266A for ; Tue, 7 Mar 2023 11:30:20 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="AkzSOT96"; dkim-atps=neutral Received: by mail-wr1-x434.google.com with SMTP id e13so11571925wro.10 for ; Tue, 07 Mar 2023 02:30:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1678185019; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3gAHJm9NpiQ1zfRhg6VO2npvj+v9NiZ4ZFdagsdSiow=; b=AkzSOT96rKWukUYg3zPM0BQ+M8cNo+rXXEJvFx7XGajh+1a1JJi0ZMExN3J/L8t7xI /UXdMP1GySR72QN/HCuVri3emMQ1wJ30az1XR449fLBiBHTObtMe0vWaVaHiBqLbzvFj p8GMX96YnAr5Jmd+TzGI1qY805rwaXhL3ANxbtQHDue83zFV8hUArC2u3kw5OcqO61ON 54t3IueRoqp66SsDMml9jbQKsKgEsKSouqoXdt7XBPoI6TanTRlUjXDl8ChSAOb4wLPA aW/6TcoYbdnX6oc+UUe9uvFe/IbM9+KGQTsxHbs3Wep8aGT765EfOgAvB8c03WnDlYv/ HVqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678185019; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3gAHJm9NpiQ1zfRhg6VO2npvj+v9NiZ4ZFdagsdSiow=; b=V545Sz2cWfz/kMUbV2xz2RrHzK39RdoIWnT1idaqbmFNRBycZcp30vne43Zw1D+wh/ 9O5gOkaqBg4ItCqKQESmSnVPSRgM38bDj8jiCmfml/9A1BKedPVY18oF1sQehiAHG2e3 2MPT7RhFzz2fpkIM1syEOclLvl222c4LnIR27ICUnhPJtb8+kxuLWgeTXazRibn7MXer /zZVdYsV3qvDntWvK51G+A67zMCa/bEzHJ+p34IXLyPboeJ6WZ/OfrR3vKYnuHQwbvfN FRsq0Si9XgNxpnQMM1vDPIbIIeOiewkE7/yNz0BzTVc6a+jbRQOAT3kgehR4zpeXoMDY CduQ== X-Gm-Message-State: AO0yUKVZySZYwGQgdaMKaJP+fFa27RGJPhl5HvuMnRZW64EC3RQVz/Iw XbDsfePIPxwxM+QpDT1sVF1ShD2qY7h9R0aMDFE7kw== X-Google-Smtp-Source: AK7set87XyUyvkxCES5pFuLDcwv2Ft+fgoFZBvwDzfTPA56BBe96wXfzk0udQ53wAeZStTEchX8yaA== X-Received: by 2002:a5d:558e:0:b0:2c9:e5f0:bd4f with SMTP id i14-20020a5d558e000000b002c9e5f0bd4fmr9082931wrv.18.1678185019472; Tue, 07 Mar 2023 02:30:19 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id r1-20020a056000014100b002c5534db60bsm12523621wrx.71.2023.03.07.02.30.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Mar 2023 02:30:19 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Tue, 7 Mar 2023 10:30:21 +0000 Message-Id: <20230307103023.3932-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230307103023.3932-1-naush@raspberrypi.com> References: <20230307103023.3932-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 1/3] pipeline: ipa: raspberrypi: Change Unicam timeout handling 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: , X-Patchwork-Original-From: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Cc: Jacopo Mondi Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add an explicit helper function setCameraTimeout() in the pipeline handler to set the Unicam timeout value. This function is signalled from the IPA to set up an appropriate timeout. This replaces the maxSensorFrameLengthMs value parameter returned back from IPARPi::start(). Adjust the timeout to be 5x the maximum frame duration reported by the IPA. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- include/libcamera/ipa/raspberrypi.mojom | 2 +- src/ipa/raspberrypi/raspberrypi.cpp | 2 +- .../pipeline/raspberrypi/raspberrypi.cpp | 24 ++++++++++++------- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/include/libcamera/ipa/raspberrypi.mojom b/include/libcamera/ipa/raspberrypi.mojom index 8e78f167f179..80e0126618c8 100644 --- a/include/libcamera/ipa/raspberrypi.mojom +++ b/include/libcamera/ipa/raspberrypi.mojom @@ -49,7 +49,6 @@ struct IPAConfigResult { struct StartConfig { libcamera.ControlList controls; int32 dropFrameCount; - uint32 maxSensorFrameLengthMs; }; interface IPARPiInterface { @@ -132,4 +131,5 @@ interface IPARPiEventInterface { setIspControls(libcamera.ControlList controls); setDelayedControls(libcamera.ControlList controls, uint32 delayContext); setLensControls(libcamera.ControlList controls); + setCameraTimeout(uint32 maxFrameLengthMs); }; diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index 9b08ae4ca622..f6826bf27fe1 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -341,7 +341,7 @@ void IPARPi::start(const ControlList &controls, StartConfig *startConfig) startConfig->dropFrameCount = dropFrameCount_; const Duration maxSensorFrameDuration = mode_.maxFrameLength * mode_.maxLineLength; - startConfig->maxSensorFrameLengthMs = maxSensorFrameDuration.get(); + setCameraTimeout.emit(maxSensorFrameDuration.get()); firstStart_ = false; lastRunTimestamp_ = 0; diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 841209548350..3d04842a2440 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -212,6 +212,7 @@ public: void setIspControls(const ControlList &controls); void setDelayedControls(const ControlList &controls, uint32_t delayContext); void setLensControls(const ControlList &controls); + void setCameraTimeout(uint32_t maxExposureTimeMs); void setSensorControls(ControlList &controls); void unicamTimeout(); @@ -1166,14 +1167,6 @@ int PipelineHandlerRPi::start(Camera *camera, const ControlList *controls) } } - /* - * Set the dequeue timeout to the larger of 2x the maximum possible - * frame duration or 1 second. - */ - utils::Duration timeout = - std::max(1s, 2 * startConfig.maxSensorFrameLengthMs * 1ms); - data->unicam_[Unicam::Image].dev()->setDequeueTimeout(timeout); - return 0; } @@ -1645,6 +1638,7 @@ int RPiCameraData::loadIPA(ipa::RPi::IPAInitResult *result) ipa_->setIspControls.connect(this, &RPiCameraData::setIspControls); ipa_->setDelayedControls.connect(this, &RPiCameraData::setDelayedControls); ipa_->setLensControls.connect(this, &RPiCameraData::setLensControls); + ipa_->setCameraTimeout.connect(this, &RPiCameraData::setCameraTimeout); /* * The configuration (tuning file) is made from the sensor name unless @@ -1957,6 +1951,20 @@ void RPiCameraData::setLensControls(const ControlList &controls) } } +void RPiCameraData::setCameraTimeout(uint32_t maxFrameLengthMs) +{ + /* + * Set the dequeue timeout to the larger of 5x the maximum reported + * frame length advertised by the IPA over a number of frames. Allow + * a minimum timeout value of 1s. + */ + utils::Duration timeout = + std::max(1s, 5 * maxFrameLengthMs * 1ms); + + LOG(RPI, Debug) << "Setting Unicam timeout to " << timeout; + unicam_[Unicam::Image].dev()->setDequeueTimeout(timeout); +} + void RPiCameraData::setSensorControls(ControlList &controls) { /*