{"id":14657,"url":"https://patchwork.libcamera.org/api/1.1/patches/14657/?format=json","web_url":"https://patchwork.libcamera.org/patch/14657/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20211119111654.68445-9-jeanmichel.hautbois@ideasonboard.com>","date":"2021-11-19T11:16:54","name":"[libcamera-devel,v1,8/8] ipa: rkisp1: agc: Configure the number of cells used by HW","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"45265b88ee16e691a6e9dbb18e13d73afc44fe71","submitter":{"id":75,"url":"https://patchwork.libcamera.org/api/1.1/people/75/?format=json","name":"Jean-Michel Hautbois","email":"jeanmichel.hautbois@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/14657/mbox/","series":[{"id":2735,"url":"https://patchwork.libcamera.org/api/1.1/series/2735/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2735","date":"2021-11-19T11:16:46","name":"Introduce AGC for RkISP1","version":1,"mbox":"https://patchwork.libcamera.org/series/2735/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/14657/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/14657/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 29821C3252\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 19 Nov 2021 11:17:09 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B6202603EE;\n\tFri, 19 Nov 2021 12:17:08 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B5AB96038B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 19 Nov 2021 12:17:00 +0100 (CET)","from tatooine.ideasonboard.com (unknown\n\t[IPv6:2a01:e0a:169:7140:db30:8e54:a96:9838])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 7C8E51C19;\n\tFri, 19 Nov 2021 12:17:00 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"Q27WfM9D\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1637320620;\n\tbh=IGZf8az6dw0g/aYVeYmxTWydcvz5Ff40gQQ8ccZ6U7Y=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=Q27WfM9Dc+VDqO3NyyQ3ppkR6YsjmqBp5SlEJDzGHa3YuH5s0hRclWc1MjEzDfQV5\n\tomKdJ+BRtearPBAU3DU8i3y8C7pm5rrSWMb58dNqLSZbl+t6ct4PvsOmbABAtmaUHB\n\tzdHItKJBbe2nliLTqxrxpCx6b8TxG8lTKsmeSvoM=","From":"Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Fri, 19 Nov 2021 12:16:54 +0100","Message-Id":"<20211119111654.68445-9-jeanmichel.hautbois@ideasonboard.com>","X-Mailer":"git-send-email 2.32.0","In-Reply-To":"<20211119111654.68445-1-jeanmichel.hautbois@ideasonboard.com>","References":"<20211119111654.68445-1-jeanmichel.hautbois@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v1 8/8] ipa: rkisp1: agc: Configure the\n\tnumber of cells used by HW","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"The ISP can use 25 or 81 cells depending on its revision. Remove the\ncached value in IPARkISP1 and use IPASessionConfiguration to store it\nand pass it to AGC.\n\nSigned-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n---\n src/ipa/ipu3/ipa_context.cpp      | 3 +++\n src/ipa/rkisp1/algorithms/agc.cpp | 4 +++-\n src/ipa/rkisp1/algorithms/agc.h   | 2 ++\n src/ipa/rkisp1/ipa_context.h      | 1 +\n src/ipa/rkisp1/rkisp1.cpp         | 5 ++---\n 5 files changed, 11 insertions(+), 4 deletions(-)","diff":"diff --git a/src/ipa/ipu3/ipa_context.cpp b/src/ipa/ipu3/ipa_context.cpp\nindex 99caf9ad..71a8619b 100644\n--- a/src/ipa/ipu3/ipa_context.cpp\n+++ b/src/ipa/ipu3/ipa_context.cpp\n@@ -84,6 +84,9 @@ namespace libcamera::ipa::ipu3 {\n  *\n  * \\var IPASessionConfiguration::grid.maxAnalogueGain\n  * \\brief Maximum analogue gain supported with the configured sensor\n+ *\n+ * \\var IPASessionConfiguration::agc.numCells\n+ * \\brief Number of cells used by the ISP to store the Y means\n  */\n \n /**\ndiff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp\nindex 2b7c6fda..471cf584 100644\n--- a/src/ipa/rkisp1/algorithms/agc.cpp\n+++ b/src/ipa/rkisp1/algorithms/agc.cpp\n@@ -82,6 +82,8 @@ int Agc::configure(IPAContext &context, const IPACameraSensorInfo &configInfo)\n \tcontext.frameContext.agc.gain = minAnalogueGain_;\n \tcontext.frameContext.agc.exposure = 10ms / lineDuration_;\n \n+\tnumCells_ = context.configuration.agc.numCells;\n+\n \treturn 0;\n }\n \n@@ -195,7 +197,7 @@ double Agc::computeInitialY(const rkisp1_cif_isp_ae_stat *ae, double currentYGai\n \tdouble ySum = 0.0;\n \tunsigned int num = 0;\n \n-\tfor (unsigned int aeCell = 0; aeCell < RKISP1_CIF_ISP_AE_MEAN_MAX_V10; aeCell++) {\n+\tfor (unsigned int aeCell = 0; aeCell < numCells_; aeCell++) {\n \t\tySum += ae->exp_mean[aeCell] * currentYGain;\n \t\tnum++;\n \t}\ndiff --git a/src/ipa/rkisp1/algorithms/agc.h b/src/ipa/rkisp1/algorithms/agc.h\nindex 934a455e..f4293035 100644\n--- a/src/ipa/rkisp1/algorithms/agc.h\n+++ b/src/ipa/rkisp1/algorithms/agc.h\n@@ -45,6 +45,8 @@ private:\n \tdouble minAnalogueGain_;\n \tdouble maxAnalogueGain_;\n \n+\tuint32_t numCells_;\n+\n \tutils::Duration filteredExposure_;\n \tutils::Duration currentExposure_;\n };\ndiff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h\nindex ca48ffc5..e8e1dc47 100644\n--- a/src/ipa/rkisp1/ipa_context.h\n+++ b/src/ipa/rkisp1/ipa_context.h\n@@ -24,6 +24,7 @@ struct IPASessionConfiguration {\n \t\tutils::Duration maxShutterSpeed;\n \t\tdouble minAnalogueGain;\n \t\tdouble maxAnalogueGain;\n+\t\tuint32_t numCells;\n \t} agc;\n };\n \ndiff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp\nindex b1bfb8b6..cebf2c65 100644\n--- a/src/ipa/rkisp1/rkisp1.cpp\n+++ b/src/ipa/rkisp1/rkisp1.cpp\n@@ -75,7 +75,6 @@ private:\n \tuint32_t maxGain_;\n \n \t/* revision-specific data */\n-\tunsigned int hwAeMeanMax_;\n \tunsigned int hwHistBinNMax_;\n \tunsigned int hwGammaOutMaxSamples_;\n \tunsigned int hwHistogramWeightGridsSize_;\n@@ -98,13 +97,13 @@ int IPARkISP1::init([[maybe_unused]] const IPASettings &settings,\n \t/* \\todo Add support for other revisions */\n \tswitch (hwRevision) {\n \tcase RKISP1_V10:\n-\t\thwAeMeanMax_ = RKISP1_CIF_ISP_AE_MEAN_MAX_V10;\n+\t\tcontext_.configuration.agc.numCells = RKISP1_CIF_ISP_AE_MEAN_MAX_V10;\n \t\thwHistBinNMax_ = RKISP1_CIF_ISP_HIST_BIN_N_MAX_V10;\n \t\thwGammaOutMaxSamples_ = RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V10;\n \t\thwHistogramWeightGridsSize_ = RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V10;\n \t\tbreak;\n \tcase RKISP1_V12:\n-\t\thwAeMeanMax_ = RKISP1_CIF_ISP_AE_MEAN_MAX_V12;\n+\t\tcontext_.configuration.agc.numCells = RKISP1_CIF_ISP_AE_MEAN_MAX_V12;\n \t\thwHistBinNMax_ = RKISP1_CIF_ISP_HIST_BIN_N_MAX_V12;\n \t\thwGammaOutMaxSamples_ = RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V12;\n \t\thwHistogramWeightGridsSize_ = RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V12;\n","prefixes":["libcamera-devel","v1","8/8"]}