{"id":15218,"url":"https://patchwork.libcamera.org/api/patches/15218/?format=json","web_url":"https://patchwork.libcamera.org/patch/15218/","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":"<20211223080110.9766-4-david.plowman@raspberrypi.com>","date":"2021-12-23T08:01:10","name":"[libcamera-devel,3/3] ipa: raspberrypi: Update sensor's V4L2_CID_NOTIFY_GAINS control when present","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"4ceeccd3b7d5bd288a27e58c5aeb8ff596d4570e","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/people/42/?format=json","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/15218/mbox/","series":[{"id":2864,"url":"https://patchwork.libcamera.org/api/series/2864/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2864","date":"2021-12-23T08:01:07","name":"Make use of V4L2_CID_NOTIFY_GAINS","version":1,"mbox":"https://patchwork.libcamera.org/series/2864/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/15218/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/15218/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 435B4BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 23 Dec 2021 08:01:55 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7E65D60909;\n\tThu, 23 Dec 2021 09:01:55 +0100 (CET)","from mail-wm1-x335.google.com (mail-wm1-x335.google.com\n\t[IPv6:2a00:1450:4864:20::335])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 595AA60908\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 23 Dec 2021 09:01:51 +0100 (CET)","by mail-wm1-x335.google.com with SMTP id g132so3097458wmg.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 23 Dec 2021 00:01:51 -0800 (PST)","from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72])\n\tby smtp.gmail.com with ESMTPSA id\n\ta3sm4692730wri.98.2021.12.23.00.01.50\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 23 Dec 2021 00:01:50 -0800 (PST)"],"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=\"V2dr61pd\"; 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=1xgOi85a1Kf11O4bZiB4HzBhTUoQ8d1X9czgP0d1Soc=;\n\tb=V2dr61pdNkmcA4lKvpZQ0B1STFsYrJ3gmbzqn2i3bOo9/MC7PuqUicgwW6zJuso9Cm\n\tJ9wbFBv5Ws7GQkhCY2YlOs6VvdiWnk+qS3dKurV6ocm2u57EqC7UyCm60kdGuNMOI5R1\n\tjU0JCPhgebWiXMG4xQl5Ssspn84ie3VVC93bh0hazjgsCd8M/vskymEnr9Ai0fhUcK+h\n\tRRiXkXdC7jEWO8YMvq2QiOUUUxx7WWJEU3shF1FbRuCAreXS33q/S9haSGxinKIMikIc\n\tHQSjyoM0LMkVJ6gY1hc0ED7ncQefUtnx0jP5MChRDm00bCJAuDfr+5vQdz3xK/ziAfsI\n\tFoxA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\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=1xgOi85a1Kf11O4bZiB4HzBhTUoQ8d1X9czgP0d1Soc=;\n\tb=3gapPzRJvxYXBfv88FOJVeGOlMZaoDgC77JiosGBetiwsDjr2sgut2oeDonh1bxT5h\n\tNgmObXCSS9TAMFdt/cnmzZgVDWabrg9UC9tVRz7j+kwxZJzOxAWEavIUQngXysjGUPMS\n\tCnWLajUzQbmiVWIktTAoex+OINT1sWbC8S2zJoupgf7Y/xe0tn+Uu4cEsxWC8/c9GUKm\n\tibZffDlvT/poHZRrKg7bT65MNYeW+79XI1Fw5azMpUMLQHZhhUhT42oQ6SFrk2e5OKV5\n\tPrssopGCwyxotKx+5cT7o/MvQ8cAazGuDnDozoCmGX4E6osOJDys1sxCoUzVsd0/J0/d\n\tZvOw==","X-Gm-Message-State":"AOAM530VzS5J6u8Zj9RZggwQo04GGpojKC3TntS8NF686TLQc5l/PpCX\n\twNXICxUE5y9tB8ScrbeKXIh1jf4BUCAHZw==","X-Google-Smtp-Source":"ABdhPJzwYIatLBPU1aVT0B5xP/8SwF8iplS+KWl4vQ0y9OZJ1HwdXmi0xavSsMaioTsezvJ2vyXlZA==","X-Received":"by 2002:a05:600c:5009:: with SMTP id\n\tn9mr907038wmr.162.1640246510594; \n\tThu, 23 Dec 2021 00:01:50 -0800 (PST)","From":"David Plowman <david.plowman@raspberrypi.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Thu, 23 Dec 2021 08:01:10 +0000","Message-Id":"<20211223080110.9766-4-david.plowman@raspberrypi.com>","X-Mailer":"git-send-email 2.30.2","In-Reply-To":"<20211223080110.9766-1-david.plowman@raspberrypi.com>","References":"<20211223080110.9766-1-david.plowman@raspberrypi.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 3/3] ipa: raspberrypi: Update sensor's\n\tV4L2_CID_NOTIFY_GAINS control 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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"If the sensor exposes the V4L2_CID_NOTIFY_GAINS controls, assume it\nwants to be told the colour gains.\n\nWe want these to be applied as soon as possible so we add a new\nsetSensorControls signal to the IPA which passes these back to the\npipeline handler without using the DelayedControls mechanism.\n\nSigned-off-by: David Plowman <david.plowman@raspberrypi.com>\n---\n include/libcamera/ipa/raspberrypi.mojom       |  1 +\n src/ipa/raspberrypi/raspberrypi.cpp           | 22 +++++++++++++++++++\n .../pipeline/raspberrypi/raspberrypi.cpp      | 10 +++++++++\n 3 files changed, 33 insertions(+)","diff":"diff --git a/include/libcamera/ipa/raspberrypi.mojom b/include/libcamera/ipa/raspberrypi.mojom\nindex acd3cafe..e7647724 100644\n--- a/include/libcamera/ipa/raspberrypi.mojom\n+++ b/include/libcamera/ipa/raspberrypi.mojom\n@@ -123,6 +123,7 @@ interface IPARPiEventInterface {\n \tstatsMetadataComplete(uint32 bufferId, libcamera.ControlList controls);\n \trunIsp(uint32 bufferId);\n \tembeddedComplete(uint32 bufferId);\n+\tsetSensorControls(libcamera.ControlList controls);\n \tsetIspControls(libcamera.ControlList controls);\n \tsetDelayedControls(libcamera.ControlList controls);\n };\ndiff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\nindex 0ed41385..8c20c066 100644\n--- a/src/ipa/raspberrypi/raspberrypi.cpp\n+++ b/src/ipa/raspberrypi/raspberrypi.cpp\n@@ -1061,6 +1061,28 @@ void IPARPi::processStats(unsigned int bufferId)\n \n \t\tsetDelayedControls.emit(ctrls);\n \t}\n+\n+\tauto itCtrl = sensorCtrls_.find(V4L2_CID_NOTIFY_GAINS);\n+\tif (itCtrl != sensorCtrls_.end()) {\n+\t\tstruct AwbStatus awbStatus;\n+\t\tif (rpiMetadata_.Get(\"awb.status\", awbStatus) == 0) {\n+\t\t\t/*\n+\t\t\t * This control is a linear gain value where the default is\n+\t\t\t * defined to correspond to a gain of 1. The order of the gains\n+\t\t\t * is always B, Gb, Gr, R.\n+\t\t\t */\n+\t\t\tint unity = itCtrl->second.def().get<int32_t>();\n+\t\t\tControlList ctrls(sensorCtrls_);\n+\t\t\tint32_t gains[4] = { static_cast<int32_t>(awbStatus.gain_b * unity),\n+\t\t\t\t\t     unity, unity,\n+\t\t\t\t\t     static_cast<int32_t>(awbStatus.gain_r * unity) };\n+\t\t\tControlValue c(Span<const uint8_t>{ reinterpret_cast<uint8_t *>(gains),\n+\t\t\t\t\t\t\t    sizeof(gains) });\n+\t\t\tctrls.set(V4L2_CID_NOTIFY_GAINS, c);\n+\n+\t\t\tsetSensorControls.emit(ctrls);\n+\t\t}\n+\t}\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 b5c687da..59d3bbd8 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -196,6 +196,7 @@ public:\n \tvoid statsMetadataComplete(uint32_t bufferId, const ControlList &controls);\n \tvoid runIsp(uint32_t bufferId);\n \tvoid embeddedComplete(uint32_t bufferId);\n+\tvoid setSensorControls(const ControlList &controls);\n \tvoid setIspControls(const ControlList &controls);\n \tvoid setDelayedControls(const ControlList &controls);\n \tvoid setSensorControls(ControlList &controls);\n@@ -1405,6 +1406,7 @@ int RPiCameraData::loadIPA(ipa::RPi::SensorConfig *sensorConfig)\n \tipa_->statsMetadataComplete.connect(this, &RPiCameraData::statsMetadataComplete);\n \tipa_->runIsp.connect(this, &RPiCameraData::runIsp);\n \tipa_->embeddedComplete.connect(this, &RPiCameraData::embeddedComplete);\n+\tipa_->setSensorControls.connect(this, &RPiCameraData::setSensorControls);\n \tipa_->setIspControls.connect(this, &RPiCameraData::setIspControls);\n \tipa_->setDelayedControls.connect(this, &RPiCameraData::setDelayedControls);\n \n@@ -1524,6 +1526,14 @@ void RPiCameraData::embeddedComplete(uint32_t bufferId)\n \thandleState();\n }\n \n+void RPiCameraData::setSensorControls(const ControlList &controls)\n+{\n+\tControlList ctrls = controls;\n+\n+\tsensor_->setControls(&ctrls);\n+\thandleState();\n+}\n+\n void RPiCameraData::setIspControls(const ControlList &controls)\n {\n \tControlList ctrls = controls;\n","prefixes":["libcamera-devel","3/3"]}