{"id":11693,"url":"https://patchwork.libcamera.org/api/1.1/patches/11693/?format=json","web_url":"https://patchwork.libcamera.org/patch/11693/","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":"<20210324114415.19866-3-david.plowman@raspberrypi.com>","date":"2021-03-24T11:44:15","name":"[libcamera-devel,2/2] ipa: raspberrypi: Update sensor's RED/BLUE balance controls when present","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"57c152410a647ee480a732bd27806935cf9ce903","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/1.1/people/42/?format=json","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/11693/mbox/","series":[{"id":1827,"url":"https://patchwork.libcamera.org/api/1.1/series/1827/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1827","date":"2021-03-24T11:44:13","name":"Raspberry Pi: handle sensors more flexibly","version":1,"mbox":"https://patchwork.libcamera.org/series/1827/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/11693/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/11693/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 D427DC32E5\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 24 Mar 2021 11:44:23 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0C2FC602E3;\n\tWed, 24 Mar 2021 12:44:23 +0100 (CET)","from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com\n\t[IPv6:2a00:1450:4864:20::62e])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 32BBA6051A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 24 Mar 2021 12:44:20 +0100 (CET)","by mail-ej1-x62e.google.com with SMTP id l4so32308532ejc.10\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 24 Mar 2021 04:44:20 -0700 (PDT)","from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72])\n\tby smtp.gmail.com with ESMTPSA id\n\tc17sm1054781edw.32.2021.03.24.04.44.19\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 24 Mar 2021 04:44:19 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"Ho6AM8u/\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=96cHYUpheoCt2rXy0CqVw2fjl67ZXcqGpZeXSmABg44=;\n\tb=Ho6AM8u/AukeHSqtXoxZvtng1kJK2aUtFvikUvngRofOUEqsHReqnaZPk3F5S99/uo\n\tHRfA4H2/P+GmOhbL3kaFJsIbIhX5XZhbFhsJ4PWp6JFKi6NObAR18d3062M0UBpKY7V9\n\tXlnqRwD6yvVKP/CadPj681gyZSafu50vZDhP1YD2mJAHVWHWBCElEAUNAtZFhOY8XheE\n\txEX7jl+OQAWa6ZdJ3GFH9YUwQIKn6b9hiEBqmA2ODYfDr1qNMtFk4dJ4Al0nu9Izl6u1\n\tv01QCOOHdlCEIX8uNCldm7+8/EG5TNhFieQ6ZEGxEAyLRnuH9NNsMgPYU/p/kT9p2X9O\n\tGrfw==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=96cHYUpheoCt2rXy0CqVw2fjl67ZXcqGpZeXSmABg44=;\n\tb=LdpUG2RH89J+kCX2SzRhtETlGzGy3a/Y+owpsShH9vnrCClpr3umiLlgzGAJK9Or4P\n\tjPmMFxb81eEXoKe46OYjy/Bi1rnv8R5U+l9AVI6QgLi2CHlF8t71dL/yCGLAz5/vGRcd\n\tj5Cw4K7AgkCt+a9fEovxuD6AlrECqk1wIz3GeRiEpXIWTOw1d7QQ2J//zmBoj/8046h9\n\twhes2XKfZVkvwwZADnvrBepwmWd7nRtGfZj5gESeL3pI4ylEY2m3AQ96LAEjlTJ97iML\n\t3DVZ2Kjojp0yVIyKXw/E2ylOCz3VHSZY974BMbQEsl6gj5NI54Tgutg7jOKxDo5mVO7Z\n\tcUXw==","X-Gm-Message-State":"AOAM533CuPeoMhDFG0uLrcvlmIaB/j5GnpsPwnF8DzfqTbKZ8bH2zYLC\n\t6Lya6AlLOk1AIaBDHJYuLqDNNYxQEGD8qA==","X-Google-Smtp-Source":"ABdhPJwl7Y1AtFNOsq8t6klqfTh7NnBywuKY6GUwU/0O/83VdGDlO4eg3+quXjQ8Cz3fp1VdhPwPXg==","X-Received":"by 2002:a17:907:77d4:: with SMTP id\n\tkz20mr3229841ejc.93.1616586259646; \n\tWed, 24 Mar 2021 04:44:19 -0700 (PDT)","From":"David Plowman <david.plowman@raspberrypi.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Wed, 24 Mar 2021 11:44:15 +0000","Message-Id":"<20210324114415.19866-3-david.plowman@raspberrypi.com>","X-Mailer":"git-send-email 2.20.1","In-Reply-To":"<20210324114415.19866-1-david.plowman@raspberrypi.com>","References":"<20210324114415.19866-1-david.plowman@raspberrypi.com>","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH 2/2] ipa: raspberrypi: Update sensor's\n\tRED/BLUE balance controls when present","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>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"If the sensor exposes V4L2_CID_RED_BALANCE and V4L2_CID_BLUE_BALANCE\ncontrols, assume it wants to be told the colour gains. We will need to\nadd these to the list of delayed controls we can apply.\n\nSigned-off-by: David Plowman <david.plowman@raspberrypi.com>\n---\n src/ipa/raspberrypi/raspberrypi.cpp             | 17 ++++++++++++++---\n .../pipeline/raspberrypi/raspberrypi.cpp        |  9 +++++++++\n 2 files changed, 23 insertions(+), 3 deletions(-)","diff":"diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\nindex 1c928b72..7437a77e 100644\n--- a/src/ipa/raspberrypi/raspberrypi.cpp\n+++ b/src/ipa/raspberrypi/raspberrypi.cpp\n@@ -1030,13 +1030,24 @@ void IPARPi::processStats(unsigned int bufferId)\n \tRPiController::StatisticsPtr statistics = std::make_shared<bcm2835_isp_stats>(*stats);\n \tcontroller_.Process(statistics, &rpiMetadata_);\n \n+\tControlList ctrls(sensorCtrls_);\n+\n \tstruct AgcStatus agcStatus;\n-\tif (rpiMetadata_.Get(\"agc.status\", agcStatus) == 0) {\n-\t\tControlList ctrls(sensorCtrls_);\n+\tif (rpiMetadata_.Get(\"agc.status\", agcStatus) == 0)\n \t\tapplyAGC(&agcStatus, ctrls);\n \n-\t\tsetDelayedControls.emit(ctrls);\n+\tstruct AwbStatus awbStatus;\n+\tif (rpiMetadata_.Get(\"awb.status\", awbStatus) == 0 &&\n+\t    sensorCtrls_.find(V4L2_CID_RED_BALANCE) != sensorCtrls_.end() &&\n+\t    sensorCtrls_.find(V4L2_CID_BLUE_BALANCE) != sensorCtrls_.end()) {\n+\t\tctrls.set(V4L2_CID_RED_BALANCE,\n+\t\t\t  static_cast<int32_t>(awbStatus.gain_r * 256));\n+\t\tctrls.set(V4L2_CID_BLUE_BALANCE,\n+\t\t\t  static_cast<int32_t>(awbStatus.gain_b * 256));\n \t}\n+\n+\tif (!ctrls.empty())\n+\t\tsetDelayedControls.emit(ctrls);\n }\n \n void IPARPi::applyAWB(const struct AwbStatus *awbStatus, ControlList &ctrls)\ndiff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex 2cac802c..7bac1503 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -1027,6 +1027,15 @@ bool PipelineHandlerRPi::match(DeviceEnumerator *enumerator)\n \t\t{ V4L2_CID_EXPOSURE, { sensorConfig.exposureDelay, false } },\n \t\t{ V4L2_CID_VBLANK, { sensorConfig.vblankDelay, true } }\n \t};\n+\n+\t/* If the sensor exposes red/blue balance controls, we will update them. */\n+\tconst ControlInfoMap &sensorControls = data->unicam_[Unicam::Image].dev()->controls();\n+\tif (sensorControls.find(V4L2_CID_RED_BALANCE) != sensorControls.end() &&\n+\t    sensorControls.find(V4L2_CID_BLUE_BALANCE) != sensorControls.end()) {\n+\t\tparams[V4L2_CID_RED_BALANCE] = { sensorConfig.vblankDelay, false };\n+\t\tparams[V4L2_CID_BLUE_BALANCE] = { sensorConfig.vblankDelay, false };\n+\t}\n+\n \tdata->delayedCtrls_ = std::make_unique<DelayedControls>(data->unicam_[Unicam::Image].dev(), params);\n \tdata->sensorMetadata_ = sensorConfig.sensorMetadata;\n \n","prefixes":["libcamera-devel","2/2"]}