{"id":11873,"url":"https://patchwork.libcamera.org/api/patches/11873/?format=json","web_url":"https://patchwork.libcamera.org/patch/11873/","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":"<20210408133634.16815-4-david.plowman@raspberrypi.com>","date":"2021-04-08T13:36:34","name":"[libcamera-devel,v2,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/11873/mbox/","series":[{"id":1905,"url":"https://patchwork.libcamera.org/api/series/1905/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1905","date":"2021-04-08T13:36:31","name":"Raspberry Pi: handle sensors more flexibly","version":2,"mbox":"https://patchwork.libcamera.org/series/1905/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/11873/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/11873/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 56EFCBD16B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  8 Apr 2021 13:36:44 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 90EA768800;\n\tThu,  8 Apr 2021 15:36:43 +0200 (CEST)","from mail-wr1-x431.google.com (mail-wr1-x431.google.com\n\t[IPv6:2a00:1450:4864:20::431])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id CD4EB602CC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  8 Apr 2021 15:36:41 +0200 (CEST)","by mail-wr1-x431.google.com with SMTP id a4so2191288wrr.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 08 Apr 2021 06:36:41 -0700 (PDT)","from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72])\n\tby smtp.gmail.com with ESMTPSA id\n\tz18sm13132522wmc.27.2021.04.08.06.36.40\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 08 Apr 2021 06:36:40 -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=\"CaoJTeD+\"; 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=AQav4R2q5Pmtad2u5QffIsZ0yQgPDaIh0eB6DfyPay8=;\n\tb=CaoJTeD+yxDhoek3PfysPemkHVQIhRagg0YzDC4J+gRDJD1fZQflj6QT7dTS7Vrkz+\n\tAM5qxmCp+elFhsSR57/D6gDaTe7PWFIQK6UV8NQPspmxf3YTTGM4IPoEld4BExLMXs+k\n\tVUP3AhdlFNciRaWxOKtPqTzHwiB/B7ErVZLHPhrXIUgSdNsKaITZU+QW0NKiSANKDPH+\n\t2FFE7z0/UC/klvUa05oki9ngqQjoTmULhKuoVOSe3oq/jkfleIUbyCSkwnddh8FM+6C5\n\tFvstviJ0jNw0CdGQS7RlcmC1PVO5SAU+gas34BOAevvm2bXsOVZjL/0+Fg3wEePJ0azx\n\tLoZw==","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=AQav4R2q5Pmtad2u5QffIsZ0yQgPDaIh0eB6DfyPay8=;\n\tb=IAF8wlKOdqDnjkWenwyXJTWMnD/IP3ydhV1Mc0jWAbE2njvudd5LduRK4I89MtZVn7\n\tHtuewXlNM651/ixSouK81/7aVg8/sq1pqmN1yD0zaFUoY6XTCtiwvbcRcolk7teGA1bK\n\t6Fb15PGgY/gc9WGOk7QiXS14zOsWENP6y83Nno0CTS/FSl9WOLydzgkqVd4MpOQHTGAc\n\txGAQF1h6W/8dPbimuIXNqv94jZSGUUnwWjchA/dJUXxyx6TF1qA8Ry2TY3kKyRxWdeYe\n\tId2dZma2iEqwVQk7WwTzbuW6DuFG7Nwp7/iwPQNAseduLDjqXL4OnA5OrEU9dUiNKZjr\n\tXONA==","X-Gm-Message-State":"AOAM530hmDiK6Z4q1r1ktgsnRiHZ1CtgaslRC5rV8fU/P/Q3On8nfso9\n\tyuQCa0xMOzYbdH8o2HUYDukf4DvKBuFsmw==","X-Google-Smtp-Source":"ABdhPJyLpZUgqJq7EiIKMiufH6xY18MWfh+PPKuVRcZQb4ZW8UNVL40d0am5HtUhDPtU9cl14H/y5A==","X-Received":"by 2002:adf:fb0b:: with SMTP id\n\tc11mr11491354wrr.425.1617889001378; \n\tThu, 08 Apr 2021 06:36:41 -0700 (PDT)","From":"David Plowman <david.plowman@raspberrypi.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Thu,  8 Apr 2021 14:36:34 +0100","Message-Id":"<20210408133634.16815-4-david.plowman@raspberrypi.com>","X-Mailer":"git-send-email 2.20.1","In-Reply-To":"<20210408133634.16815-1-david.plowman@raspberrypi.com>","References":"<20210408133634.16815-1-david.plowman@raspberrypi.com>","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH v2 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>\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","v2","3/3"]}