From patchwork Wed Apr 26 13:10:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18555 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 1C7BFBDCBD for ; Wed, 26 Apr 2023 13:13:22 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C164E627E0; Wed, 26 Apr 2023 15:13:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1682514801; bh=8ZJirGtzoI1nfzxKgVonMTAI0BmoM7sKCOo0NC5txqc=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=AMdt2VUhu4e3biif0MibKJzdnAWTK61Ud3C3yfFcxiHNnVlK1d1E6Wo1+/dOjyAzf aVNZ1XxvwtMJOBIsYKsO4BhHikMDtK4JKWselFvDGYQ/3NkKSbc3tjUiMwgZDLES0R PGLTt6IjNfWBpWIX74ohDG3zsqhfTAg3ZmoiOmbUAp+wsUj475oAszMdI14qgbTZ8s JbJ6vbyg1M+cNN1MOSbUGuutwC+Tg+mz0qUHdq9EJDd9sGgMUv4AIBALOD9tvDw2tb 4QkeFvPUTmkXgLRJXYAR3bfDz5UY/HwBVkr0ckx2pbuicP5pn0vNZi9gvMWmdSVw8z ++Jb6zWlu/h0Q== Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 824DC627ED for ; Wed, 26 Apr 2023 15:13:17 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="mgbXOhEh"; dkim-atps=neutral Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-3f1763ee8f8so48872745e9.1 for ; Wed, 26 Apr 2023 06:13:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1682514797; x=1685106797; 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=sxkrJNOXybpoweaw5C2D3mxs0OIHpZEwdQMHkFUZTyc=; b=mgbXOhEhxPVlgomonpV54g6wP5Cp7iFkCpoELnnuDqWseE/yVvVolm63grPIU2YG6B rOeFS3a8Nf5ArYJCk9nedOPvcxGpLDlfHoTb7XOPw+efGPePwCL9RIr26u4IDEuwucCi zjlrWwE/eBwe/hxvWiUB0/Ve/6Qu6etRw3VGxKBZnYXLxcC0V29O/KFod3itSv/DladZ z+C7HLnm8CdyR5G2t+preNDqn6MNDobQp/VoeAg/nJRhWK4QfJvNwp40N+++Z6JiXU0J xpP+ZQrcdL9YFeiztAVcfQaZjOq46MTISRL0DFK52Hl8aEQffZSmlCyhxQYX+bqTp5s/ Vqlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682514797; x=1685106797; 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=sxkrJNOXybpoweaw5C2D3mxs0OIHpZEwdQMHkFUZTyc=; b=KJ7SwXD4Ypkq78oIhlnRPlHbBwcb6NuJTSnyKIUtCeHwCmyCVoEYZ/DFpDd1k+5fNy PwYdVPbxzt4hnIcxJ0yLvjjMPMzfuAP/p+uer6ZxOh1iYy/IxOSE2MymcNBHluHbei+K C/S/2cumuqI44K5ePSGsBXotavt6U63UEOrtrOl61+h/tu6+59nDWoZl+ipqvZV2L1my asRksYP7/6gFwewqakopEIq3SBKumiDiP/Vx3ZOgnudUBWxy1LNUKV2ZUHqQiyv/AEY9 J7KVFqdXyR/Ra1CyQK5kFA57Fsl0xx+spJmWDE2lb9ElrppTJMR+LC5NylpG5K6cLees kAZQ== X-Gm-Message-State: AAQBX9foWcUUc/+lONHpaoy6WHeh/LbywfTi7aq5P3uFtLGrZsljKmCc 4dergyRpL+K9RNRk8wrbYo+RrILwi5b1VBHAh4lFRg== X-Google-Smtp-Source: AKy350Z/CyVuWjIBxK3eVEoZgrAaX/4XRnDzy2bSvBYGhqPidEJkq4dME3ApJUwiBDGZnuqJ8g1uVg== X-Received: by 2002:adf:fe49:0:b0:2fa:631a:9f38 with SMTP id m9-20020adffe49000000b002fa631a9f38mr14906924wrs.2.1682514796652; Wed, 26 Apr 2023 06:13:16 -0700 (PDT) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id k5-20020adff5c5000000b002f103ca90cdsm15780949wrp.101.2023.04.26.06.13.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Apr 2023 06:13:16 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Wed, 26 Apr 2023 14:10:51 +0100 Message-Id: <20230426131057.21550-8-naush@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230426131057.21550-1-naush@raspberrypi.com> References: <20230426131057.21550-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 07/13] pipeline: ipa: raspberrypi: Replace IPA metadataReady() call 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 Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Remove the IPA -> pipeline metadataReady() call to signify the return Request metdata is ready to be consumed. Instead, replace this with a new pipeline -> IPA reportMetadata() call that explicitly ask the IPA to fill in the Request metdata at an appropriate time. This change allows the pipeline handler to dictate when it receives the metadata from the IPA if the structure of the pipeline were to ever change. Signed-off-by: Naushir Patuck Reviewed-by: Jacopo Mondi --- include/libcamera/ipa/raspberrypi.mojom | 2 ++ src/ipa/rpi/vc4/raspberrypi.cpp | 9 ++++----- src/libcamera/pipeline/rpi/vc4/raspberrypi.cpp | 18 +++++++----------- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/include/libcamera/ipa/raspberrypi.mojom b/include/libcamera/ipa/raspberrypi.mojom index 7d56248f4ab3..620f13ba9717 100644 --- a/include/libcamera/ipa/raspberrypi.mojom +++ b/include/libcamera/ipa/raspberrypi.mojom @@ -82,6 +82,8 @@ interface IPARPiInterface { [async] prepareIsp(PrepareParams params); [async] processStats(ProcessParams params); + + reportMetadata(uint32 ipaContext) => (libcamera.ControlList controls); }; interface IPARPiEventInterface { diff --git a/src/ipa/rpi/vc4/raspberrypi.cpp b/src/ipa/rpi/vc4/raspberrypi.cpp index d737f1d662a0..e3ca8e2f7cbe 100644 --- a/src/ipa/rpi/vc4/raspberrypi.cpp +++ b/src/ipa/rpi/vc4/raspberrypi.cpp @@ -154,7 +154,7 @@ private: bool validateLensControls(); void applyControls(const ControlList &controls); void prepare(const PrepareParams ¶ms); - void reportMetadata(unsigned int ipaContext); + void reportMetadata(unsigned int ipaContext, ControlList *controls) override; void fillDeviceStatus(const ControlList &sensorControls, unsigned int ipaContext); RPiController::StatisticsPtr fillStatistics(bcm2835_isp_stats *stats) const; void process(unsigned int bufferId, unsigned int ipaContext); @@ -565,7 +565,6 @@ void IPARPi::processStats(const ProcessParams ¶ms) if (processPending_ && frameCount_ > mistrustCount_) process(params.buffers.stats, context); - reportMetadata(context); processStatsComplete.emit(params.buffers); } @@ -586,9 +585,9 @@ void IPARPi::prepareIsp(const PrepareParams ¶ms) prepareIspComplete.emit(params.buffers); } -void IPARPi::reportMetadata(unsigned int ipaContext) +void IPARPi::reportMetadata(unsigned int ipaContext, ControlList *controls) { - RPiController::Metadata &rpiMetadata = rpiMetadata_[ipaContext]; + RPiController::Metadata &rpiMetadata = rpiMetadata_[ipaContext % rpiMetadata_.size()]; std::unique_lock lock(rpiMetadata); /* @@ -697,7 +696,7 @@ void IPARPi::reportMetadata(unsigned int ipaContext) libcameraMetadata_.set(controls::AfPauseState, p); } - metadataReady.emit(libcameraMetadata_); + *controls = std::move(libcameraMetadata_); } bool IPARPi::validateSensorControls() diff --git a/src/libcamera/pipeline/rpi/vc4/raspberrypi.cpp b/src/libcamera/pipeline/rpi/vc4/raspberrypi.cpp index 30ce6feab0d1..bd66468683df 100644 --- a/src/libcamera/pipeline/rpi/vc4/raspberrypi.cpp +++ b/src/libcamera/pipeline/rpi/vc4/raspberrypi.cpp @@ -207,7 +207,6 @@ public: void enumerateVideoDevices(MediaLink *link); void processStatsComplete(const ipa::RPi::BufferIds &buffers); - void metadataReady(const ControlList &metadata); void prepareIspComplete(const ipa::RPi::BufferIds &buffers); void setIspControls(const ControlList &controls); void setDelayedControls(const ControlList &controls, uint32_t delayContext); @@ -1652,7 +1651,6 @@ int RPiCameraData::loadIPA(ipa::RPi::InitResult *result) ipa_->processStatsComplete.connect(this, &RPiCameraData::processStatsComplete); ipa_->prepareIspComplete.connect(this, &RPiCameraData::prepareIspComplete); - ipa_->metadataReady.connect(this, &RPiCameraData::metadataReady); ipa_->setIspControls.connect(this, &RPiCameraData::setIspControls); ipa_->setDelayedControls.connect(this, &RPiCameraData::setDelayedControls); ipa_->setLensControls.connect(this, &RPiCameraData::setLensControls); @@ -1892,17 +1890,12 @@ void RPiCameraData::processStatsComplete(const ipa::RPi::BufferIds &buffers) FrameBuffer *buffer = isp_[Isp::Stats].getBuffers().at(buffers.stats & RPi::MaskID); handleStreamBuffer(buffer, &isp_[Isp::Stats]); - state_ = State::IpaComplete; - handleState(); -} -void RPiCameraData::metadataReady(const ControlList &metadata) -{ - if (!isRunning()) - return; - - /* Add to the Request metadata buffer what the IPA has provided. */ + /* Last thing to do is to fill up the request metadata. */ Request *request = requestQueue_.front(); + ControlList metadata; + + ipa_->reportMetadata(request->sequence(), &metadata); request->metadata().merge(metadata); /* @@ -1923,6 +1916,9 @@ void RPiCameraData::metadataReady(const ControlList &metadata) sensor_->setControls(&ctrls); } + + state_ = State::IpaComplete; + handleState(); } void RPiCameraData::prepareIspComplete(const ipa::RPi::BufferIds &buffers)