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); } From patchwork Wed Feb 17 10:08:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 11319 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 3859EBD1F1 for ; Wed, 17 Feb 2021 10:09:00 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id EA169660F9; 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="m1olAB0G"; dkim-atps=neutral Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A799B602FA for ; Wed, 17 Feb 2021 11:08:57 +0100 (CET) Received: by mail-wr1-x430.google.com with SMTP id n6so16703110wrv.8 for ; Wed, 17 Feb 2021 02:08:57 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ih66PSUudybURaOS8xx6g+qRRG+qJ22mtmV2vucmKWw=; b=m1olAB0GHA+my/XIuKirDf0TTnmwhiVOIZ2WCgsGTXy7euaipnmST5T4lGj2f2fUh6 Snhmi6nQQyOcqfGa+/dPN+nzuPGiTUecFIrCiy6TyMBaTISFf0eANWef9zm/+RWtSBF9 bGDgXsrV8mPW8m/WKMOUsTKRdavbtIEHDUH9JNGHneQsAe0TwZEVkK58VPzN1oY3LiAv jSnJAQOIRtV4Urx3V25cNr1zt5eml2K6IP9WNgdrorJaxefo8uVhL8rw8nFaRFDZcxgG cnkTRL+9kZs6fddcwZ47d2Hu2q8SzXpMKEZmZVwBTwgn1v4ouW3u0+r/O3yJUHJVsVal QJSQ== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=Ih66PSUudybURaOS8xx6g+qRRG+qJ22mtmV2vucmKWw=; b=LpzGDIk2OhynpagCdU/Xh1wK++2zI1OCKEQuUtF0jkdVrkOxFA1q3imGGe9aCNN7Ic NZBYs2obEN9QZ2aPO/RES0EOYvnkBbyHMQkhUmOQ4mPzvDTcAb0TqVCs0safJjiJT7Mg V7s+nbocZdFGd3sJRzBU9jasc6ZSYueqx274ZIN/I1KtCmKR62Ul+3B2iyrTHI7zyt/f dQHlNkQ4/JsV92+HzmfzpYrLPBjg7bhyqEyT+cG3QuP9F2EB+8IgYZx0c5i9IdfKWLK0 ZKKe80o2G0xIQfUlF7eF6YuiObtqPt1ET6rVQ9nSGxkDgY7huo6VPc901bc5Zbp92vb/ 1pgQ== X-Gm-Message-State: AOAM531IBk9GDBnR1S8rd/UDlrtAT3HYL47zjjPSvDzJhuCEUSJjHB9m vghQgr4HSUH5u4OrHzKLzVwOOf8+Y1Fp+bbY X-Google-Smtp-Source: ABdhPJyBul8cj558Vusnows5bCZo+z8awbDIiy9DTCvQUsubc/EkesHw8WPjNu5bq9x8kNNy/0BvWQ== X-Received: by 2002:a5d:5910:: with SMTP id v16mr17884311wrd.304.1613556537034; Wed, 17 Feb 2021 02:08:57 -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.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Feb 2021 02:08:56 -0800 (PST) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Wed, 17 Feb 2021 10:08:51 +0000 Message-Id: <20210217100852.1542397-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210217100852.1542397-1-naush@raspberrypi.com> References: <20210217100852.1542397-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/3] pipeline: ipa: raspberrypi: Rename IPA Interface namespace to ipa::RPi 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" Rename the IPA interface namespace to ipa::RPi for consistency with the libcamera::RPi namespace label. There is no functional change in this commit. Signed-off-by: Naushir Patuck Reviewed-by: Kieran Bingham --- include/libcamera/ipa/raspberrypi.mojom | 2 +- src/ipa/raspberrypi/raspberrypi.cpp | 38 +++++++++--------- .../pipeline/raspberrypi/raspberrypi.cpp | 40 +++++++++---------- .../pipeline/raspberrypi/rpi_stream.cpp | 4 +- .../pipeline/raspberrypi/rpi_stream.h | 4 +- 5 files changed, 42 insertions(+), 46 deletions(-) diff --git a/include/libcamera/ipa/raspberrypi.mojom b/include/libcamera/ipa/raspberrypi.mojom index 9c05cc68cceb..5a27b1e4fc2d 100644 --- a/include/libcamera/ipa/raspberrypi.mojom +++ b/include/libcamera/ipa/raspberrypi.mojom @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -module ipa.rpi; +module ipa.RPi; import "include/libcamera/ipa/core.mojom"; diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index 974f4ec63058..1226ea514521 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -63,7 +63,7 @@ constexpr double defaultMaxFrameDuration = 1e6 / 0.01; LOG_DEFINE_CATEGORY(IPARPI) -class IPARPi : public ipa::rpi::IPARPiInterface +class IPARPi : public ipa::RPi::IPARPiInterface { public: IPARPi() @@ -76,24 +76,24 @@ public: ~IPARPi() { if (lsTable_) - munmap(lsTable_, ipa::rpi::MaxLsGridSize); + munmap(lsTable_, ipa::RPi::MaxLsGridSize); } int init(const IPASettings &settings) override; - void start(const ipa::rpi::StartControls &data, - ipa::rpi::StartControls *result) override; + void start(const ipa::RPi::StartControls &data, + ipa::RPi::StartControls *result) override; void stop() override {} void configure(const CameraSensorInfo &sensorInfo, const std::map &streamConfig, const std::map &entityControls, - const ipa::rpi::ConfigInput &data, - ipa::rpi::ConfigOutput *response, int32_t *ret) override; + const ipa::RPi::ConfigInput &data, + ipa::RPi::ConfigOutput *response, int32_t *ret) override; void mapBuffers(const std::vector &buffers) override; void unmapBuffers(const std::vector &ids) override; void signalStatReady(const uint32_t bufferId) override; void signalQueueRequest(const ControlList &controls) override; - void signalIspPrepare(const ipa::rpi::ISPConfig &data) override; + void signalIspPrepare(const ipa::RPi::ISPConfig &data) override; private: void setMode(const CameraSensorInfo &sensorInfo); @@ -168,8 +168,8 @@ int IPARPi::init(const IPASettings &settings) return 0; } -void IPARPi::start(const ipa::rpi::StartControls &data, - ipa::rpi::StartControls *result) +void IPARPi::start(const ipa::RPi::StartControls &data, + ipa::RPi::StartControls *result) { RPiController::Metadata metadata; @@ -291,8 +291,8 @@ void IPARPi::setMode(const CameraSensorInfo &sensorInfo) void IPARPi::configure(const CameraSensorInfo &sensorInfo, [[maybe_unused]] const std::map &streamConfig, const std::map &entityControls, - const ipa::rpi::ConfigInput &ipaConfig, - ipa::rpi::ConfigOutput *result, int32_t *ret) + const ipa::RPi::ConfigInput &ipaConfig, + ipa::RPi::ConfigOutput *result, int32_t *ret) { if (entityControls.size() != 2) { LOG(IPARPI, Error) << "No ISP or sensor controls found."; @@ -344,7 +344,7 @@ void IPARPi::configure(const CameraSensorInfo &sensorInfo, helper_->GetDelays(exposureDelay, gainDelay); sensorMetadata = helper_->SensorEmbeddedDataPresent(); - result->params |= ipa::rpi::ConfigSensorParams; + result->params |= ipa::RPi::ConfigSensorParams; result->sensorConfig.gainDelay = gainDelay; result->sensorConfig.exposureDelay = exposureDelay; result->sensorConfig.vblank = exposureDelay; @@ -360,14 +360,14 @@ void IPARPi::configure(const CameraSensorInfo &sensorInfo, if (ipaConfig.lsTableHandle.isValid()) { /* Remove any previous table, if there was one. */ if (lsTable_) { - munmap(lsTable_, ipa::rpi::MaxLsGridSize); + munmap(lsTable_, ipa::RPi::MaxLsGridSize); lsTable_ = nullptr; } /* Map the LS table buffer into user space. */ lsTableHandle_ = std::move(ipaConfig.lsTableHandle); if (lsTableHandle_.isValid()) { - lsTable_ = mmap(nullptr, ipa::rpi::MaxLsGridSize, PROT_READ | PROT_WRITE, + lsTable_ = mmap(nullptr, ipa::RPi::MaxLsGridSize, PROT_READ | PROT_WRITE, MAP_SHARED, lsTableHandle_.fd(), 0); if (lsTable_ == MAP_FAILED) { @@ -432,7 +432,7 @@ void IPARPi::signalStatReady(uint32_t bufferId) reportMetadata(); - statsMetadataComplete.emit(bufferId & ipa::rpi::MaskID, libcameraMetadata_); + statsMetadataComplete.emit(bufferId & ipa::RPi::MaskID, libcameraMetadata_); } void IPARPi::signalQueueRequest(const ControlList &controls) @@ -440,7 +440,7 @@ void IPARPi::signalQueueRequest(const ControlList &controls) queueRequest(controls); } -void IPARPi::signalIspPrepare(const ipa::rpi::ISPConfig &data) +void IPARPi::signalIspPrepare(const ipa::RPi::ISPConfig &data) { /* * At start-up, or after a mode-switch, we may want to @@ -451,7 +451,7 @@ void IPARPi::signalIspPrepare(const ipa::rpi::ISPConfig &data) 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() @@ -906,7 +906,7 @@ void IPARPi::queueRequest(const ControlList &controls) void IPARPi::returnEmbeddedBuffer(unsigned int bufferId) { - embeddedComplete.emit(bufferId & ipa::rpi::MaskID); + embeddedComplete.emit(bufferId & ipa::RPi::MaskID); } void IPARPi::prepareISP(unsigned int bufferId) @@ -1271,7 +1271,7 @@ void IPARPi::applyLS(const struct AlscStatus *lsStatus, ControlList &ctrls) .gain_format = GAIN_FORMAT_U4P10 }; - if (!lsTable_ || w * h * 4 * sizeof(uint16_t) > ipa::rpi::MaxLsGridSize) { + if (!lsTable_ || w * h * 4 * sizeof(uint16_t) > ipa::RPi::MaxLsGridSize) { LOG(IPARPI, Error) << "Do not have a correctly allocate lens shading table!"; return; } diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 8770ae66a21a..9dd4d112a907 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -166,7 +166,7 @@ public: void handleState(); void applyScalerCrop(const ControlList &controls); - std::unique_ptr ipa_; + std::unique_ptr ipa_; std::unique_ptr sensor_; /* Array of Unicam and ISP device streams and associated buffers/streams. */ @@ -778,8 +778,8 @@ int PipelineHandlerRPi::start(Camera *camera, ControlList *controls) data->applyScalerCrop(*controls); /* Start the IPA. */ - ipa::rpi::StartControls ipaData; - ipa::rpi::StartControls result; + ipa::RPi::StartControls ipaData; + ipa::RPi::StartControls result; if (controls) ipaData.controls = *controls; data->ipa_->start(ipaData, &result); @@ -1114,8 +1114,8 @@ int PipelineHandlerRPi::prepareBuffers(Camera *camera) * Pass the stats and embedded data buffers to the IPA. No other * buffers need to be passed. */ - mapBuffers(camera, data->isp_[Isp::Stats].getBuffers(), ipa::rpi::MaskStats); - mapBuffers(camera, data->unicam_[Unicam::Embedded].getBuffers(), ipa::rpi::MaskEmbeddedData); + mapBuffers(camera, data->isp_[Isp::Stats].getBuffers(), ipa::RPi::MaskStats); + mapBuffers(camera, data->unicam_[Unicam::Embedded].getBuffers(), ipa::RPi::MaskEmbeddedData); return 0; } @@ -1164,7 +1164,7 @@ void RPiCameraData::frameStarted(uint32_t sequence) int RPiCameraData::loadIPA() { - ipa_ = IPAManager::createIPA(pipe_, 1, 1); + ipa_ = IPAManager::createIPA(pipe_, 1, 1); if (!ipa_) return -ENOENT; @@ -1188,7 +1188,7 @@ int RPiCameraData::configureIPA(const CameraConfiguration *config) std::map streamConfig; std::map entityControls; - ipa::rpi::ConfigInput ipaConfig; + ipa::RPi::ConfigInput ipaConfig; /* Get the device format to pass to the IPA. */ V4L2DeviceFormat sensorFormat; @@ -1211,7 +1211,7 @@ int RPiCameraData::configureIPA(const CameraConfiguration *config) /* Allocate the lens shading table via dmaHeap and pass to the IPA. */ if (!lsTable_.isValid()) { - lsTable_ = dmaHeap_.alloc("ls_grid", ipa::rpi::MaxLsGridSize); + lsTable_ = dmaHeap_.alloc("ls_grid", ipa::RPi::MaxLsGridSize); if (!lsTable_.isValid()) return -ENOMEM; @@ -1231,7 +1231,7 @@ int RPiCameraData::configureIPA(const CameraConfiguration *config) } /* Ready the IPA - it must know about the sensor resolution. */ - ipa::rpi::ConfigOutput result; + ipa::RPi::ConfigOutput result; ipa_->configure(sensorInfo_, streamConfig, entityControls, ipaConfig, &result, &ret); @@ -1241,7 +1241,7 @@ int RPiCameraData::configureIPA(const CameraConfiguration *config) return -EPIPE; } - if (result.params & ipa::rpi::ConfigSensorParams) { + if (result.params & ipa::RPi::ConfigSensorParams) { /* * Setup our delayed control writer with the sensor default * gain and exposure delays. @@ -1343,13 +1343,9 @@ void RPiCameraData::setIspControls(const ControlList &controls) 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); + const bcm2835_isp_lens_shading *ls = + reinterpret_cast(s.data()); + ls->dmabuf = lsTable_.fd(); } isp_[Isp::Input].dev()->setControls(&ctrls); @@ -1457,7 +1453,7 @@ void RPiCameraData::ispOutputDequeue(FrameBuffer *buffer) * application until after the IPA signals so. */ if (stream == &isp_[Isp::Stats]) { - ipa_->signalStatReady(ipa::rpi::MaskStats | static_cast(index)); + ipa_->signalStatReady(ipa::RPi::MaskStats | static_cast(index)); } else { /* Any other ISP output can be handed back to the application now. */ handleStreamBuffer(buffer, stream); @@ -1561,7 +1557,7 @@ void RPiCameraData::handleExternalBuffer(FrameBuffer *buffer, RPi::Stream *strea { unsigned int id = stream->getBufferId(buffer); - if (!(id & ipa::rpi::MaskExternalBuffer)) + if (!(id & ipa::RPi::MaskExternalBuffer)) return; /* Stop the Stream object from tracking the buffer. */ @@ -1693,9 +1689,9 @@ void RPiCameraData::tryRunPipeline() << " Bayer buffer id: " << bayerId << " Embedded buffer id: " << embeddedId; - ipa::rpi::ISPConfig ispPrepare; - ispPrepare.embeddedBufferId = ipa::rpi::MaskEmbeddedData | embeddedId; - ispPrepare.bayerBufferId = ipa::rpi::MaskBayerData | bayerId; + ipa::RPi::ISPConfig ispPrepare; + ispPrepare.embeddedBufferId = ipa::RPi::MaskEmbeddedData | embeddedId; + ispPrepare.bayerBufferId = ipa::RPi::MaskBayerData | bayerId; ipa_->signalIspPrepare(ispPrepare); } diff --git a/src/libcamera/pipeline/raspberrypi/rpi_stream.cpp b/src/libcamera/pipeline/raspberrypi/rpi_stream.cpp index 496dd36fabbc..f2430415d32d 100644 --- a/src/libcamera/pipeline/raspberrypi/rpi_stream.cpp +++ b/src/libcamera/pipeline/raspberrypi/rpi_stream.cpp @@ -72,7 +72,7 @@ int Stream::getBufferId(FrameBuffer *buffer) const void Stream::setExternalBuffer(FrameBuffer *buffer) { - bufferMap_.emplace(ipa::rpi::MaskExternalBuffer | id_.get(), buffer); + bufferMap_.emplace(ipa::RPi::MaskExternalBuffer | id_.get(), buffer); } void Stream::removeExternalBuffer(FrameBuffer *buffer) @@ -80,7 +80,7 @@ void Stream::removeExternalBuffer(FrameBuffer *buffer) int id = getBufferId(buffer); /* Ensure we have this buffer in the stream, and it is marked external. */ - ASSERT(id != -1 && (id & ipa::rpi::MaskExternalBuffer)); + ASSERT(id != -1 && (id & ipa::RPi::MaskExternalBuffer)); bufferMap_.erase(id); } diff --git a/src/libcamera/pipeline/raspberrypi/rpi_stream.h b/src/libcamera/pipeline/raspberrypi/rpi_stream.h index 701110d04bdb..f1ac715f4221 100644 --- a/src/libcamera/pipeline/raspberrypi/rpi_stream.h +++ b/src/libcamera/pipeline/raspberrypi/rpi_stream.h @@ -32,13 +32,13 @@ class Stream : public libcamera::Stream { public: Stream() - : id_(ipa::rpi::MaskID) + : id_(ipa::RPi::MaskID) { } Stream(const char *name, MediaEntity *dev, bool importOnly = false) : external_(false), importOnly_(importOnly), name_(name), - dev_(std::make_unique(dev)), id_(ipa::rpi::MaskID) + dev_(std::make_unique(dev)), id_(ipa::RPi::MaskID) { } From patchwork Wed Feb 17 10:08:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 11320 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 46474BD1F1 for ; Wed, 17 Feb 2021 10:09:02 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1222A6381F; Wed, 17 Feb 2021 11:09:02 +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="Uvly5XPo"; dkim-atps=neutral Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7DA56637F7 for ; Wed, 17 Feb 2021 11:08:58 +0100 (CET) Received: by mail-wr1-x42a.google.com with SMTP id b3so16732187wrj.5 for ; Wed, 17 Feb 2021 02:08:58 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=uuvSWvyj8WmCxY0N0GaNH8uEM5tK2g6h+wMnfKyKZG8=; b=Uvly5XPo7gjMch0Tr+071EJMcORWBXvhEs4UeHzLWKxijdmBxXgVNZ+Y0lv/icrYNp xnyO3e/xS5I792JeV0toQ7OGGxJxgJojtgUDprdB0IZi87bcek8BkL+uHbgfWn0VT5af vEfKuqihn4N0VdK4g7NAsE0E/cFhZn6aXLnJzc3SUDUvQgsRMlPpSBtaSrehZk45NvnE kSG2GNCWHIh5CzNZTNjmD5YfvHF57rR30I84RO6ttPUbHqt9GBXujojyXbWxYw30vVTP F5WlYXYlS47eF95zz5AizXMTUHBE72SCFdUZEgMAgTqWSOEMq1rJsjo29wd2ZrsKx+9g GL/Q== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=uuvSWvyj8WmCxY0N0GaNH8uEM5tK2g6h+wMnfKyKZG8=; b=Sjb2k5kkl4K6GHhUiB1SkTnbp3F0Bx9c7Atv5Jy/1pc3L68Bc2mgMbBIBpVgAhiiwl aNPUJWgvN6QddIu1z6TtVTW3bmiDmrVivHGs1JFYCHRzYmwlNYxoyMsZDZCBe4JvJCFt JLNrJNd3Bi3W77l420Y1SXfZsO8UXVPDcWeubytG35R/smAc6C20fQvPsUdc2EYjPFlS vquWA+zUlw1XwzQCbvvqcJ38rw0J+Qo1j1vmdBV6D3RKi/2LjaSIw8XWTHLkKcoscbZ+ ZEOOeOS9ctn3WLrYpTOdXLgOpdwsX0KQ8M3SCtEruSBoYCS5/IP8PXFtuMEDh03X34/f 5EDQ== X-Gm-Message-State: AOAM5315Uqeu8ccbCybgQrSrzpAHaerbUqbo2PzEoPNxeqc7FFmEuqdc MK0e1VW2tYKLHBj0ZuMLZ41pwqQx5BYctnzS X-Google-Smtp-Source: ABdhPJzUoQurMOkW1jiXstGtzDckfZCMwt5B0yLCSZ+VwKvlUuLcAIAA2wy4FZrhXICHTpu2SZTjNg== X-Received: by 2002:adf:b18e:: with SMTP id q14mr29143160wra.396.1613556537948; Wed, 17 Feb 2021 02:08:57 -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.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Feb 2021 02:08:57 -0800 (PST) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Wed, 17 Feb 2021 10:08:52 +0000 Message-Id: <20210217100852.1542397-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210217100852.1542397-1-naush@raspberrypi.com> References: <20210217100852.1542397-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/3] pipeline: raspberrypi: Update lens shading control in-place 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 the dmabuf file descriptor to the lens shading control in-place rather than taking a copy. Signed-off-by: Naushir Patuck --- src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 9dd4d112a907..a60415d93705 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1338,13 +1338,14 @@ void RPiCameraData::embeddedComplete(uint32_t bufferId) void RPiCameraData::setIspControls(const ControlList &controls) { - ControlList ctrls = controls; + ControlList ctrls = std::move(controls); if (ctrls.contains(V4L2_CID_USER_BCM2835_ISP_LENS_SHADING)) { - Span s = - ctrls.get(V4L2_CID_USER_BCM2835_ISP_LENS_SHADING).data(); - const bcm2835_isp_lens_shading *ls = - reinterpret_cast(s.data()); + ControlValue &value = + const_cast(ctrls.get(V4L2_CID_USER_BCM2835_ISP_LENS_SHADING)); + Span s = value.data(); + bcm2835_isp_lens_shading *ls = + reinterpret_cast(s.data()); ls->dmabuf = lsTable_.fd(); }