From patchwork Wed Feb 17 10:08:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 11318 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 03CC5BD1F1 for ; Wed, 17 Feb 2021 10:08:59 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9352B63820; Wed, 17 Feb 2021 11:08:58 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="kI6Odv+S"; dkim-atps=neutral Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DF55E602FA for ; Wed, 17 Feb 2021 11:08:56 +0100 (CET) Received: by mail-wr1-x431.google.com with SMTP id v1so16732503wrd.6 for ; Wed, 17 Feb 2021 02:08:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=aU4UgnIZNbETazhuwhor/hEli6bslNfbqx7r7mDUkMk=; b=kI6Odv+SieJKwVzZi+5iFJpulU8NuR1Q4IKk7KfvYxNzGV+3tcL1H62FiGSQMtrCpR vslBOJk54bz/ok9EEgfguLe2p2YRNbYrJ1VszqulsKgqxcH739Ug1dd6UUbioLDNPdIK RfJbPfby4S0Vhe8gIkcvUxA7W64bHvifNtH/t7YrKN+XhKz6Re3BadT/vIkqhMFe9Z14 7EAvbiRm99BeZhGNx5Ko6d+4ql8KPnyZUMG0PXHQanV6bXdVUTtMBIEPSp+Zb2nBlyHK S+dd8NgK8son7iZfUunlnoubhiH7olGyibcUEaereZS75ZyiNMVZ4ivqYFclprG/NsPm uf7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=aU4UgnIZNbETazhuwhor/hEli6bslNfbqx7r7mDUkMk=; b=Ss9xPv++qbeC6WOJpfFszhXxvZ7BAEUiETnr/2tw2OWJfhAQYMHDo4YCj8DXRmBwOR wneSK2gbiMyXDLEgwSnsYdEi8sJQvjFcIpsGA8gqbMPRwnvzFIwqGJ9nlHNGiiuztYBA TENJdytjFiEd9gZXn3MhqVg2GwND0HGidGvAf0tUv58yRBD6qQQMCPMnSvPfc91BAOS6 3EMjkZLs6heYsbVLjQkDA7U+KAYxHUuS0O1+8pIAMH+q2pqSat9ng574RcSjnP1Y+V0Y mZ1PKIpyTcK4J9Ieaq7FKMoOOR5oNYvP2lMpD3dwDyTlhw0H3Fcwyqd/wItbf8RWzgD+ JaxQ== X-Gm-Message-State: AOAM532NHKNR4D4NrJjn+Bhlnef8b9epEGWv/qj7Pro/OORscxYuyw/S q5WjCZjJu8So1GB88PjagJzuNjuUkz2TJDWZ X-Google-Smtp-Source: ABdhPJxexHZZjzuM6GWEHwbPqKFi/sfInhhGXUU2bqrFKy3Zzi/cvQN5ZA0EnQFKWANy/hWvhdFzJA== X-Received: by 2002:a5d:698d:: with SMTP id g13mr29415045wru.30.1613556536266; Wed, 17 Feb 2021 02:08:56 -0800 (PST) Received: from naush-laptop.patuck.local ([88.97.76.4]) by smtp.gmail.com with ESMTPSA id l38sm2132481wmp.19.2021.02.17.02.08.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Feb 2021 02:08:55 -0800 (PST) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Wed, 17 Feb 2021 10:08:50 +0000 Message-Id: <20210217100852.1542397-1-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/3] pipeline: ipa: raspberrypi: Various fixups after IPAInterface changes 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" This commit addresses a few fixes and tidy-ups after the IPAInterface rework: - Rename ConfigStaggeredWrite -> ConfigSensorParams - Rename setIsp -> setIspControls - Switch to camel case for ISPConfig::embeddedbufferId and ISPConfig::bayerbufferId. - Signal handlers statsMetadataComplete(), runISP(), embeddedComplete() should only run when state != Stopped. This matches the behavior of the original code. Without this, start/stop cycles may cause errors. - In setIspControls(), only update the LS config (with the fd) when a LS control is present. Signed-off-by: Naushir Patuck Fixes: e201cb4f5450 ("libcamera: IPAInterface: Replace C API with the new C++-only API") Reviewed-by: Paul Elder Tested-by: David Plowman Reviewed-by: Kieran Bingham --- include/libcamera/ipa/raspberrypi.mojom | 8 ++--- src/ipa/raspberrypi/raspberrypi.cpp | 8 ++--- .../pipeline/raspberrypi/raspberrypi.cpp | 36 ++++++++++--------- 3 files changed, 27 insertions(+), 25 deletions(-) diff --git a/include/libcamera/ipa/raspberrypi.mojom b/include/libcamera/ipa/raspberrypi.mojom index bab19a946e18..9c05cc68cceb 100644 --- a/include/libcamera/ipa/raspberrypi.mojom +++ b/include/libcamera/ipa/raspberrypi.mojom @@ -16,7 +16,7 @@ enum BufferMask { const uint32 MaxLsGridSize = 0x8000; enum ConfigOutputParameters { - ConfigStaggeredWrite = 0x01, + ConfigSensorParams = 0x01, }; struct SensorConfig { @@ -27,8 +27,8 @@ struct SensorConfig { }; struct ISPConfig { - uint32 embeddedbufferId; - uint32 bayerbufferId; + uint32 embeddedBufferId; + uint32 bayerBufferId; }; struct ConfigInput { @@ -126,6 +126,6 @@ interface IPARPiEventInterface { statsMetadataComplete(uint32 bufferId, ControlList controls); runIsp(uint32 bufferId); embeddedComplete(uint32 bufferId); - setIsp(ControlList controls); + setIspControls(ControlList controls); setDelayedControls(ControlList controls); }; diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index 81a3195c82e9..974f4ec63058 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -344,7 +344,7 @@ void IPARPi::configure(const CameraSensorInfo &sensorInfo, helper_->GetDelays(exposureDelay, gainDelay); sensorMetadata = helper_->SensorEmbeddedDataPresent(); - result->params |= ipa::rpi::ConfigStaggeredWrite; + result->params |= ipa::rpi::ConfigSensorParams; result->sensorConfig.gainDelay = gainDelay; result->sensorConfig.exposureDelay = exposureDelay; result->sensorConfig.vblank = exposureDelay; @@ -447,11 +447,11 @@ void IPARPi::signalIspPrepare(const ipa::rpi::ISPConfig &data) * avoid running the control algos for a few frames in case * they are "unreliable". */ - prepareISP(data.embeddedbufferId); + prepareISP(data.embeddedBufferId); frameCount_++; /* Ready to push the input buffer into the ISP. */ - runIsp.emit(data.bayerbufferId & ipa::rpi::MaskID); + runIsp.emit(data.bayerBufferId & ipa::rpi::MaskID); } void IPARPi::reportMetadata() @@ -968,7 +968,7 @@ void IPARPi::prepareISP(unsigned int bufferId) applyDPC(dpcStatus, ctrls); if (!ctrls.empty()) - setIsp.emit(ctrls); + setIspControls.emit(ctrls); } } diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 15aa600ed581..8770ae66a21a 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -152,7 +152,7 @@ public: void statsMetadataComplete(uint32_t bufferId, const ControlList &controls); void runIsp(uint32_t bufferId); void embeddedComplete(uint32_t bufferId); - void setIsp(const ControlList &controls); + void setIspControls(const ControlList &controls); void setDelayedControls(const ControlList &controls); /* bufferComplete signal handlers. */ @@ -1172,7 +1172,7 @@ int RPiCameraData::loadIPA() ipa_->statsMetadataComplete.connect(this, &RPiCameraData::statsMetadataComplete); ipa_->runIsp.connect(this, &RPiCameraData::runIsp); ipa_->embeddedComplete.connect(this, &RPiCameraData::embeddedComplete); - ipa_->setIsp.connect(this, &RPiCameraData::setIsp); + ipa_->setIspControls.connect(this, &RPiCameraData::setIspControls); ipa_->setDelayedControls.connect(this, &RPiCameraData::setDelayedControls); IPASettings settings(ipa_->configurationFile(sensor_->model() + ".json")); @@ -1241,7 +1241,7 @@ int RPiCameraData::configureIPA(const CameraConfiguration *config) return -EPIPE; } - if (result.params & ipa::rpi::ConfigStaggeredWrite) { + if (result.params & ipa::rpi::ConfigSensorParams) { /* * Setup our delayed control writer with the sensor default * gain and exposure delays. @@ -1281,7 +1281,7 @@ int RPiCameraData::configureIPA(const CameraConfiguration *config) void RPiCameraData::statsMetadataComplete(uint32_t bufferId, const ControlList &controls) { if (state_ == State::Stopped) - handleState(); + return; FrameBuffer *buffer = isp_[Isp::Stats].getBuffers().at(bufferId); @@ -1314,7 +1314,7 @@ void RPiCameraData::statsMetadataComplete(uint32_t bufferId, const ControlList & void RPiCameraData::runIsp(uint32_t bufferId) { if (state_ == State::Stopped) - handleState(); + return; FrameBuffer *buffer = unicam_[Unicam::Image].getBuffers().at(bufferId); @@ -1329,26 +1329,28 @@ void RPiCameraData::runIsp(uint32_t bufferId) void RPiCameraData::embeddedComplete(uint32_t bufferId) { if (state_ == State::Stopped) - handleState(); + return; FrameBuffer *buffer = unicam_[Unicam::Embedded].getBuffers().at(bufferId); handleStreamBuffer(buffer, &unicam_[Unicam::Embedded]); handleState(); } -void RPiCameraData::setIsp(const ControlList &controls) +void RPiCameraData::setIspControls(const ControlList &controls) { ControlList ctrls = controls; - Span s = - ctrls.get(V4L2_CID_USER_BCM2835_ISP_LENS_SHADING).data(); - bcm2835_isp_lens_shading ls = - *reinterpret_cast(s.data()); - ls.dmabuf = lsTable_.fd(); + if (ctrls.contains(V4L2_CID_USER_BCM2835_ISP_LENS_SHADING)) { + Span s = + ctrls.get(V4L2_CID_USER_BCM2835_ISP_LENS_SHADING).data(); + bcm2835_isp_lens_shading ls = + *reinterpret_cast(s.data()); + ls.dmabuf = lsTable_.fd(); - ControlValue c(Span{ reinterpret_cast(&ls), - sizeof(ls) }); - ctrls.set(V4L2_CID_USER_BCM2835_ISP_LENS_SHADING, c); + ControlValue c(Span{ reinterpret_cast(&ls), + sizeof(ls) }); + ctrls.set(V4L2_CID_USER_BCM2835_ISP_LENS_SHADING, c); + } isp_[Isp::Input].dev()->setControls(&ctrls); handleState(); @@ -1692,8 +1694,8 @@ void RPiCameraData::tryRunPipeline() << " Embedded buffer id: " << embeddedId; ipa::rpi::ISPConfig ispPrepare; - ispPrepare.embeddedbufferId = ipa::rpi::MaskEmbeddedData | embeddedId; - ispPrepare.bayerbufferId = ipa::rpi::MaskBayerData | bayerId; + ispPrepare.embeddedBufferId = ipa::rpi::MaskEmbeddedData | embeddedId; + ispPrepare.bayerBufferId = ipa::rpi::MaskBayerData | bayerId; ipa_->signalIspPrepare(ispPrepare); }