{"id":11929,"url":"https://patchwork.libcamera.org/api/patches/11929/?format=json","web_url":"https://patchwork.libcamera.org/patch/11929/","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":"<20210414102955.9503-4-david.plowman@raspberrypi.com>","date":"2021-04-14T10:29:55","name":"[libcamera-devel,v3,3/3] ipa: raspberrypi: Update sensor's RED/BLUE balance controls when present","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"b7d37a098e57505cde26f855d946747ed1a6f415","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/11929/mbox/","series":[{"id":1927,"url":"https://patchwork.libcamera.org/api/series/1927/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1927","date":"2021-04-14T10:29:52","name":"Raspberry Pi: handle sensors more flexibly","version":3,"mbox":"https://patchwork.libcamera.org/series/1927/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/11929/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/11929/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 647D3BD224\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 14 Apr 2021 10:30:05 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 57E7868813;\n\tWed, 14 Apr 2021 12:30:04 +0200 (CEST)","from mail-ed1-x532.google.com (mail-ed1-x532.google.com\n\t[IPv6:2a00:1450:4864:20::532])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A63A968819\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 14 Apr 2021 12:30:02 +0200 (CEST)","by mail-ed1-x532.google.com with SMTP id f8so23038646edd.11\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 14 Apr 2021 03:30:02 -0700 (PDT)","from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72])\n\tby smtp.gmail.com with ESMTPSA id\n\th8sm11369137ede.25.2021.04.14.03.30.01\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 14 Apr 2021 03:30:01 -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=\"lDw8iNr+\"; 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=EK0KpznhWxelp9GWrSl8L18Zfi0E+M59ms30V470TNM=;\n\tb=lDw8iNr+MhgOtSfelvrxqRuDZsoKAekzcRvkiI2h7TzC0nDCGeBJrM+ag8uw3TJoZi\n\toBrcEcogt3ZKcR71YzkcwKNy8rJ8WtGSDPons6wdaixmA493uftCDZDsHbOOW1cMFFJK\n\tYdvCVXk/x1fHUbVV1V5ZjBzeyN7n7Kpg8GShQ4OzuOwTRx8lDUrqm1GF0UoteoP4dd8+\n\ty3PzISU8jw5Eg/V/7K1DFd6n7HdcVcrEAhfkPFLusj+GLsHLAsJfOU3zbod7LxUOEPbL\n\t8QJQrYesHHFiDLNSnB/hrJ1BrgHSd8NulMffkyX3vQyxukKla3v6sP/nyTbggpby014L\n\tm4Ig==","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=EK0KpznhWxelp9GWrSl8L18Zfi0E+M59ms30V470TNM=;\n\tb=IIuYO657PjGq37PFOhr46hPcp+hfNRQwhLNzKxBOJ3Jk/UIoHmdNLUK5Q7RqaDVqrW\n\tiPAm/jUB3smkQjgZy/+hZVr9ThGL8SS1mjZ6qAn+hjMvk+88Q9zUGaZ1tlBxmmMhkzHe\n\ts1qJpXwO6z0LEzOTELpw9m8xZl7TPytk1O9P/x+t7m9qIsoxCWr+Qmfj4ECirZIYUq+C\n\t3i3ipP4qIASMIcM1rIKcM9H/5trxMhoklQp+md/VohnpvwFNgH/Ceb8DRhYP90IO6zRM\n\tgNtLaYuOtu9E3PybhEYoih5up/pCFNimaTNXt4+eRwWbfiBzFr9wgRtK/hkabzMlSVdA\n\tyUXQ==","X-Gm-Message-State":"AOAM5306bQbrXDzEE6slEZ/PMmnyIP/Q4haFNWI9/l4O3RVhoMYh9ALg\n\tBZ4Pau9txMnNDGnzqKm53ix0s4WEJo3xFQ==","X-Google-Smtp-Source":"ABdhPJzLzu2mA/ASiBKybAr6SD0KGFjzJQ5MJasuS9AABu4BH20RixYuX5I4ibpTjEzdHE1cG5tp3A==","X-Received":"by 2002:a05:6402:c:: with SMTP id\n\td12mr39746082edu.100.1618396202001; \n\tWed, 14 Apr 2021 03:30:02 -0700 (PDT)","From":"David Plowman <david.plowman@raspberrypi.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Wed, 14 Apr 2021 11:29:55 +0100","Message-Id":"<20210414102955.9503-4-david.plowman@raspberrypi.com>","X-Mailer":"git-send-email 2.20.1","In-Reply-To":"<20210414102955.9503-1-david.plowman@raspberrypi.com>","References":"<20210414102955.9503-1-david.plowman@raspberrypi.com>","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH v3 3/3] 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.\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>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n include/libcamera/ipa/raspberrypi.mojom            |  1 +\n src/ipa/raspberrypi/raspberrypi.cpp                | 13 +++++++++++++\n src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 10 ++++++++++\n 3 files changed, 24 insertions(+)","diff":"diff --git a/include/libcamera/ipa/raspberrypi.mojom b/include/libcamera/ipa/raspberrypi.mojom\nindex f38c2261..ebaf0a04 100644\n--- a/include/libcamera/ipa/raspberrypi.mojom\n+++ b/include/libcamera/ipa/raspberrypi.mojom\n@@ -117,6 +117,7 @@ interface IPARPiEventInterface {\n \tstatsMetadataComplete(uint32 bufferId, ControlList controls);\n \trunIsp(uint32 bufferId);\n \tembeddedComplete(uint32 bufferId);\n+\tsetSensorControls(ControlList controls);\n \tsetIspControls(ControlList controls);\n \tsetDelayedControls(ControlList controls);\n };\ndiff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\nindex dad6395f..f95896d2 100644\n--- a/src/ipa/raspberrypi/raspberrypi.cpp\n+++ b/src/ipa/raspberrypi/raspberrypi.cpp\n@@ -1036,6 +1036,19 @@ void IPARPi::processStats(unsigned int bufferId)\n \n \t\tsetDelayedControls.emit(ctrls);\n \t}\n+\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\tControlList ctrls(sensorCtrls_);\n+\t\tctrls.set(V4L2_CID_RED_BALANCE,\n+\t\t\t  static_cast<int32_t>(helper_->ColourGainCode(awbStatus.gain_r)));\n+\t\tctrls.set(V4L2_CID_BLUE_BALANCE,\n+\t\t\t  static_cast<int32_t>(helper_->ColourGainCode(awbStatus.gain_b)));\n+\n+\t\tsetSensorControls.emit(ctrls);\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 f22e286e..8dae4912 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -152,6 +152,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 \n@@ -1219,6 +1220,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@@ -1361,6 +1363,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+\tunicam_[Unicam::Image].dev()->setControls(&ctrls);\n+\thandleState();\n+}\n+\n void RPiCameraData::setIspControls(const ControlList &controls)\n {\n \tControlList ctrls = controls;\n","prefixes":["libcamera-devel","v3","3/3"]}