{"id":19134,"url":"https://patchwork.libcamera.org/api/patches/19134/?format=json","web_url":"https://patchwork.libcamera.org/patch/19134/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20231013074841.16972-11-naush@raspberrypi.com>","date":"2023-10-13T07:48:31","name":"[libcamera-devel,v2,10/20] ipa: rpi: Prepare AWB for PiSP support","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"977d92891bc40b4c0b6826882cd8e69d83e579d6","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/?format=json","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/19134/mbox/","series":[{"id":4049,"url":"https://patchwork.libcamera.org/api/series/4049/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4049","date":"2023-10-13T07:48:21","name":"Raspberry Pi: Preliminary PiSP support","version":2,"mbox":"https://patchwork.libcamera.org/series/4049/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/19134/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/19134/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 90A9CC3274\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 13 Oct 2023 07:49:02 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 38B4B629AB;\n\tFri, 13 Oct 2023 09:49:02 +0200 (CEST)","from mail-wm1-x334.google.com (mail-wm1-x334.google.com\n\t[IPv6:2a00:1450:4864:20::334])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 304C362991\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 13 Oct 2023 09:48:54 +0200 (CEST)","by mail-wm1-x334.google.com with SMTP id\n\t5b1f17b1804b1-40666aa674fso18810165e9.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 13 Oct 2023 00:48:54 -0700 (PDT)","from localhost.localdomain ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\tm16-20020a7bca50000000b003fee6e170f9sm1791890wml.45.2023.10.13.00.48.53\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 13 Oct 2023 00:48:53 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1697183342;\n\tbh=tp/MwLhP6gZ1z/A6Ll2u9PkxFUFlzobD3MPo84nfCtg=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=cLkm0GLBt+jQwNDfZKOCqU113O37TKOFnXUQmeJUmbaucjs6yVoOQdjDPr+3bkNGt\n\tN3sHAB/q2nnL0bIkKssJUGGbO4vgvS+iaRBx5vRwcNk++az1XZDyWtF08m3MblRBiZ\n\tbXXScOb1i3SWCkjnjoaBg8WZD5ojxbAC4WbALBQoYP18qEMmARlRaMspIgrPS1Vh61\n\tYjaKbNDOZD7cUg5GtIpDMdU8PIpQJ8K1kuu2N4RTf28YcjkdWLISn8XVu8PSayXUI1\n\tBbGk1pXU+FbU6psrijCuQfxFJTnwyTGIB7rPRvjjHk4spXOuB0JPvrnI/poVil5EhB\n\t4sRaJm4g+iayw==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1697183333; x=1697788133;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=1uiXMJfgz2P+0kPDj41SLrSF7nj0Ja1wBeD8+vQd89M=;\n\tb=dQNaEGxLBNMGFmLAqGNd7wrkJQ/PnBN6nSf3O4lzs8RwrtCIyD0Re3GHK1TvFlg+5r\n\tFGcGL7OMDh2TcgA16BnvVSYjAhttz2sZWPA9MSKq2uvIHHSssZ5k98LmLVZp8zuMQKBn\n\teo2M/AmfIZti6jFshkvAGNFC5iOIaV4EQ9N7qrhYLV3ZkoTGLk3bK6uuckQcU2JXNagp\n\tEp+F5SiEM7IM/wMPRnakGV6/zwzlwAmBOvqs05LtQVi3Mj7qrOEJSM39dDNE4OJFVhDw\n\t/Uu3HYF4HlaPtS2ekLLeaF5VyC01QaThYxWkqBnzWfH+NSDTUCguuuC35MgWsxUdAeCu\n\t0Lnw=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"dQNaEGxL\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1697183333; x=1697788133;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=1uiXMJfgz2P+0kPDj41SLrSF7nj0Ja1wBeD8+vQd89M=;\n\tb=Px88crImV5Vdba70E174bqV5GxwpqCgFjwY1Y1hMKLCa+EErayZruiOMjMFpiei8J+\n\t6C6XeSj+w0DjArFdPZ2pZxcYeZPJ2ZsWxeUThFaBQ5c24s1PoUTP5JlCKqv8cPsJvAqO\n\tsbj1syx7XSqYbw7zmNhRrXeFo4rbi3npYPQJcUvPwlLI4BLdSyGu87cB1xPaBgnwxZuo\n\tXxYkoMJo/vo3EFmw/gM4wysjEInsggKO6cOWCyoqOq6iypzQTKv5btkjUNrC/nxGQMPi\n\tylDi7aCibQ8wC97Dc3gqbx0vNsMH3f1widzMPbTfzlHUQvWd0KHPtWSh5I+8cxpxtj+v\n\t81Fw==","X-Gm-Message-State":"AOJu0Ywexn0oybOCKo/WiNMWUQkBTcV/HUTuDO4kL0xwzz2+FosbbhcT\n\tc4EtLRJHUknGAs/I6HF6K3T3t3giszp39A3H1RyE1g==","X-Google-Smtp-Source":"AGHT+IEV6TSzJEQsjfX8UMMPZu0hqnM2Z763yppl3EwmdFTMwQ4AtfzoQfrcUmvkmR3cIbVFKXg9+g==","X-Received":"by 2002:a05:600c:2146:b0:401:daf2:2735 with SMTP id\n\tv6-20020a05600c214600b00401daf22735mr21997420wml.31.1697183333548; \n\tFri, 13 Oct 2023 00:48:53 -0700 (PDT)","To":"libcamera-devel@lists.libcamera.org","Date":"Fri, 13 Oct 2023 08:48:31 +0100","Message-Id":"<20231013074841.16972-11-naush@raspberrypi.com>","X-Mailer":"git-send-email 2.34.1","In-Reply-To":"<20231013074841.16972-1-naush@raspberrypi.com>","References":"<20231013074841.16972-1-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v2 10/20] ipa: rpi: Prepare AWB for PiSP\n\tsupport","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>","From":"Naushir Patuck via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Naushir Patuck <naush@raspberrypi.com>","Cc":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Prepare the AWB algorithm to support the PiSP hardware. The key change\nis to factor in the LS correction in the AWB zone statistics. This is\ndifferent from VC4 where the LS correction happens before statistics\ngathering.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\nReviewed-by: David Plowman <david.plowman@raspberrypi.com>\nReviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n---\n src/ipa/rpi/controller/rpi/awb.cpp | 29 ++++++++++++++++++++---------\n 1 file changed, 20 insertions(+), 9 deletions(-)","diff":"diff --git a/src/ipa/rpi/controller/rpi/awb.cpp b/src/ipa/rpi/controller/rpi/awb.cpp\nindex ef3435d66106..5ae0c2fad6e9 100644\n--- a/src/ipa/rpi/controller/rpi/awb.cpp\n+++ b/src/ipa/rpi/controller/rpi/awb.cpp\n@@ -12,6 +12,7 @@\n \n #include \"../lux_status.h\"\n \n+#include \"alsc_status.h\"\n #include \"awb.h\"\n \n using namespace RPiController;\n@@ -398,18 +399,28 @@ void Awb::asyncFunc()\n }\n \n static void generateStats(std::vector<Awb::RGB> &zones,\n-\t\t\t  RgbyRegions &stats, double minPixels,\n-\t\t\t  double minG)\n+\t\t\t  StatisticsPtr &stats, double minPixels,\n+\t\t\t  double minG, Metadata &globalMetadata)\n {\n-\tfor (auto const &region : stats) {\n+\tstd::scoped_lock<RPiController::Metadata> l(globalMetadata);\n+\n+\tfor (unsigned int i = 0; i < stats->awbRegions.numRegions(); i++) {\n \t\tAwb::RGB zone;\n+\t\tauto &region = stats->awbRegions.get(i);\n \t\tif (region.counted >= minPixels) {\n \t\t\tzone.G = region.val.gSum / region.counted;\n-\t\t\tif (zone.G >= minG) {\n-\t\t\t\tzone.R = region.val.rSum / region.counted;\n-\t\t\t\tzone.B = region.val.bSum / region.counted;\n-\t\t\t\tzones.push_back(zone);\n+\t\t\tif (zone.G < minG)\n+\t\t\t\tcontinue;\n+\t\t\tzone.R = region.val.rSum / region.counted;\n+\t\t\tzone.B = region.val.bSum / region.counted;\n+\t\t\t/* Factor in the ALSC applied colour shading correction if required. */\n+\t\t\tconst AlscStatus *alscStatus = globalMetadata.getLocked<AlscStatus>(\"alsc.status\");\n+\t\t\tif (stats->colourStatsPos == Statistics::ColourStatsPos::PreLsc && alscStatus) {\n+\t\t\t\tzone.R *= alscStatus->r[i];\n+\t\t\t\tzone.G *= alscStatus->g[i];\n+\t\t\t\tzone.B *= alscStatus->b[i];\n \t\t\t}\n+\t\t\tzones.push_back(zone);\n \t\t}\n \t}\n }\n@@ -421,8 +432,8 @@ void Awb::prepareStats()\n \t * LSC has already been applied to the stats in this pipeline, so stop\n \t * any LSC compensation.  We also ignore config_.fast in this version.\n \t */\n-\tgenerateStats(zones_, statistics_->awbRegions, config_.minPixels,\n-\t\t      config_.minG);\n+\tgenerateStats(zones_, statistics_, config_.minPixels,\n+\t\t      config_.minG, getGlobalMetadata());\n \t/*\n \t * apply sensitivities, so values appear to come from our \"canonical\"\n \t * sensor.\n","prefixes":["libcamera-devel","v2","10/20"]}