{"id":19133,"url":"https://patchwork.libcamera.org/api/patches/19133/?format=json","web_url":"https://patchwork.libcamera.org/patch/19133/","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-10-naush@raspberrypi.com>","date":"2023-10-13T07:48:30","name":"[libcamera-devel,v2,09/20] ipa: rpi: Prepare ALSC for PiSP support","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"4a6251f65b057c95eb3401970cc31b62c173a28a","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/19133/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/19133/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/19133/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 59CEEC32BC\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 13 Oct 2023 07:49:01 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8808362992;\n\tFri, 13 Oct 2023 09:49:00 +0200 (CEST)","from mail-wm1-x333.google.com (mail-wm1-x333.google.com\n\t[IPv6:2a00:1450:4864:20::333])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id BBD1462986\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 13 Oct 2023 09:48:53 +0200 (CEST)","by mail-wm1-x333.google.com with SMTP id\n\t5b1f17b1804b1-40666aa674fso18810115e9.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 13 Oct 2023 00:48:53 -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.52\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 13 Oct 2023 00:48:52 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1697183340;\n\tbh=Jjo/F25/0Dv7zcg7UHN1vZt7o6yjnm8ekVoHAswsCJA=;\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=O3ug6L9750ao9wlgp+WeSoC3NgcJPZ6vaXIM4M375UD0/iMC9p0c+SeArXtmVK4Pu\n\tvAU+bw149+sioVmj+sCuVEdD4WoUevjt/qAau5calpXp7k/BshJu/mdPrF60OJKUiy\n\tFOSTDonB2sx0uLXmaIVJ1Hh7TB91rqbdnEAbLjyepqvlvc66bA6Wc2N1KpFO5XoJau\n\tsXKQw9HnA+DtceEnqEWfvaZXAL5eZN/ggCHprsyHZDw0igkAGt54xp2I7yvqDNZQF8\n\tn145uRI+2vkONKsZ8iFWqJIrvtsUYMPbPOKI1+Nd0KVG6pKtcr855m28eKNFFSyHzZ\n\tLpStTjivlR8Ew==","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=v0nbS29QoQ7yqrDXklQ2NX32XLs3Z77SCfUCSFVZHik=;\n\tb=PmWkNhh2iRfW84fnVWud+Vq7Xi+qEAsv9i1POq6L/EREinY9vFvWxFW35gKSGTJZxf\n\tJ/mfxTu4RMspOQxsyRgToCXntqMNFak45CwFhd8kwgvFhCypkwKb13jQwXt2I0KZvoZP\n\tOYsvIwWvvfG62DM5s2iU0LJ+h3SQJMdZkQK2/pieWX6+etbK3WcsIxAfeoZMroveidQy\n\t+0F9wHVMUl4KGDqdTbjRR13Rd6xPwCeefsOFLKEeyCdh0BzpxV563IqebE/to/YCLFbp\n\t53IKOyGMW7Qv+UZ+oAnVmrnQRs6Pq2b8JdmV1/aUhAbczTHQM3OUbDmv1/6p6J1QMn3g\n\t/PwQ=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"PmWkNhh2\"; 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=v0nbS29QoQ7yqrDXklQ2NX32XLs3Z77SCfUCSFVZHik=;\n\tb=hAtaZIK4lW0KLnl0UQgcubBll2+dgwuCK380oRrDV8zvz7WdTC8BubcBjz/dDoR2Av\n\tsiBPEl1X8yloQsk7PlziYNfr+NlT30zWNVv+u1ju/kqrw2keB0ojOX/QJbb1G1LQHdt8\n\tNip/loLsudKXWDvPMLEGr+jI7CyyENciyJmM7el9d0Op8wJYYlnaRPak/Q9Y9DuBKNCn\n\tJIkWj5iQaR/WDV998fg2DU8qQPCp3sO325PbQzn5PYNVgcinCkI5Jbg/z1dTbuH66U5J\n\toKOys9+gnZBeOMoukJdwBmQdxhqP9tcvmPlEaEMNlC3EXV7ZS7dHUtPeKINRi4kQTYnI\n\tvqFA==","X-Gm-Message-State":"AOJu0YxfybKQulQCj4d5QuFCwR6bhDHbtoKkDJxB5SwkyXZ6hU18RNfb\n\tF7Vq+9Sf1GRwC7723HCGEmrIuM1nIA/MqFDiczOR9Q==","X-Google-Smtp-Source":"AGHT+IHi2pG37WGEmkyxneBt1cC3Aj5Bm3QyI+GyPBNd2Mwg+/QcOhD7ENu+leXEZsTNzpSVe7y9tw==","X-Received":"by 2002:a7b:c393:0:b0:401:bd2e:49fc with SMTP id\n\ts19-20020a7bc393000000b00401bd2e49fcmr23748595wmj.24.1697183332983; \n\tFri, 13 Oct 2023 00:48:52 -0700 (PDT)","To":"libcamera-devel@lists.libcamera.org","Date":"Fri, 13 Oct 2023 08:48:30 +0100","Message-Id":"<20231013074841.16972-10-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 09/20] ipa: rpi: Prepare ALSC 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 ALSC algorithm to support the PiSP hardware. The key change\nis to avoid factoring out the WB correction in the AWB zone statistics.\n\nAdd the ALSC correction to the global metadata so that AWB can use it to\nfactor the gains back in for the AWB calculations.\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/alsc.cpp | 16 ++++++++++++----\n 1 file changed, 12 insertions(+), 4 deletions(-)","diff":"diff --git a/src/ipa/rpi/controller/rpi/alsc.cpp b/src/ipa/rpi/controller/rpi/alsc.cpp\nindex 3a2e8fe00ca6..f1ccef87c70c 100644\n--- a/src/ipa/rpi/controller/rpi/alsc.cpp\n+++ b/src/ipa/rpi/controller/rpi/alsc.cpp\n@@ -348,9 +348,11 @@ static void copyStats(RgbyRegions &regions, StatisticsPtr &stats,\n \tconst std::vector<double> &bTable = status.b;\n \tfor (unsigned int i = 0; i < stats->awbRegions.numRegions(); i++) {\n \t\tauto r = stats->awbRegions.get(i);\n-\t\tr.val.rSum = static_cast<uint64_t>(r.val.rSum / rTable[i]);\n-\t\tr.val.gSum = static_cast<uint64_t>(r.val.gSum / gTable[i]);\n-\t\tr.val.bSum = static_cast<uint64_t>(r.val.bSum / bTable[i]);\n+\t\tif (stats->colourStatsPos == Statistics::ColourStatsPos::PostLsc) {\n+\t\t\tr.val.rSum = static_cast<uint64_t>(r.val.rSum / rTable[i]);\n+\t\t\tr.val.gSum = static_cast<uint64_t>(r.val.gSum / gTable[i]);\n+\t\t\tr.val.bSum = static_cast<uint64_t>(r.val.bSum / bTable[i]);\n+\t\t}\n \t\tregions.set(i, r);\n \t}\n }\n@@ -368,7 +370,8 @@ void Alsc::restartAsync(StatisticsPtr &stats, Metadata *imageMetadata)\n \t * the LSC table that the pipeline applied to them.\n \t */\n \tAlscStatus alscStatus;\n-\tif (imageMetadata->get(\"alsc.status\", alscStatus) != 0) {\n+\tif (stats->colourStatsPos == Statistics::ColourStatsPos::PostLsc &&\n+\t    imageMetadata->get(\"alsc.status\", alscStatus) != 0) {\n \t\tLOG(RPiAlsc, Warning)\n \t\t\t<< \"No ALSC status found for applied gains!\";\n \t\talscStatus.r.resize(config_.tableSize.width * config_.tableSize.height, 1.0);\n@@ -414,6 +417,11 @@ void Alsc::prepare(Metadata *imageMetadata)\n \tstatus.g = prevSyncResults_[1].data();\n \tstatus.b = prevSyncResults_[2].data();\n \timageMetadata->set(\"alsc.status\", status);\n+\t/*\n+\t * Put the results in the global metadata as well. This will be used by\n+\t * AWB to factor in the colour shading correction.\n+\t */\n+\tgetGlobalMetadata().set(\"alsc.status\", status);\n }\n \n void Alsc::process(StatisticsPtr &stats, Metadata *imageMetadata)\n","prefixes":["libcamera-devel","v2","09/20"]}