From patchwork Wed Apr 14 10:29:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 11929 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 647D3BD224 for ; Wed, 14 Apr 2021 10:30:05 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 57E7868813; Wed, 14 Apr 2021 12:30:04 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="lDw8iNr+"; dkim-atps=neutral Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A63A968819 for ; Wed, 14 Apr 2021 12:30:02 +0200 (CEST) Received: by mail-ed1-x532.google.com with SMTP id f8so23038646edd.11 for ; Wed, 14 Apr 2021 03:30:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EK0KpznhWxelp9GWrSl8L18Zfi0E+M59ms30V470TNM=; b=lDw8iNr+MhgOtSfelvrxqRuDZsoKAekzcRvkiI2h7TzC0nDCGeBJrM+ag8uw3TJoZi oBrcEcogt3ZKcR71YzkcwKNy8rJ8WtGSDPons6wdaixmA493uftCDZDsHbOOW1cMFFJK YdvCVXk/x1fHUbVV1V5ZjBzeyN7n7Kpg8GShQ4OzuOwTRx8lDUrqm1GF0UoteoP4dd8+ y3PzISU8jw5Eg/V/7K1DFd6n7HdcVcrEAhfkPFLusj+GLsHLAsJfOU3zbod7LxUOEPbL 8QJQrYesHHFiDLNSnB/hrJ1BrgHSd8NulMffkyX3vQyxukKla3v6sP/nyTbggpby014L m4Ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EK0KpznhWxelp9GWrSl8L18Zfi0E+M59ms30V470TNM=; b=IIuYO657PjGq37PFOhr46hPcp+hfNRQwhLNzKxBOJ3Jk/UIoHmdNLUK5Q7RqaDVqrW iPAm/jUB3smkQjgZy/+hZVr9ThGL8SS1mjZ6qAn+hjMvk+88Q9zUGaZ1tlBxmmMhkzHe s1qJpXwO6z0LEzOTELpw9m8xZl7TPytk1O9P/x+t7m9qIsoxCWr+Qmfj4ECirZIYUq+C 3i3ipP4qIASMIcM1rIKcM9H/5trxMhoklQp+md/VohnpvwFNgH/Ceb8DRhYP90IO6zRM gNtLaYuOtu9E3PybhEYoih5up/pCFNimaTNXt4+eRwWbfiBzFr9wgRtK/hkabzMlSVdA yUXQ== X-Gm-Message-State: AOAM5306bQbrXDzEE6slEZ/PMmnyIP/Q4haFNWI9/l4O3RVhoMYh9ALg BZ4Pau9txMnNDGnzqKm53ix0s4WEJo3xFQ== X-Google-Smtp-Source: ABdhPJzLzu2mA/ASiBKybAr6SD0KGFjzJQ5MJasuS9AABu4BH20RixYuX5I4ibpTjEzdHE1cG5tp3A== X-Received: by 2002:a05:6402:c:: with SMTP id d12mr39746082edu.100.1618396202001; Wed, 14 Apr 2021 03:30:02 -0700 (PDT) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id h8sm11369137ede.25.2021.04.14.03.30.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Apr 2021 03:30:01 -0700 (PDT) From: David Plowman 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 RED/BLUE balance controls when present X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" If the sensor exposes V4L2_CID_RED_BALANCE and V4L2_CID_BLUE_BALANCE controls, assume it wants to be told the colour gains. We want these to be applied as soon as possible so we add a new setSensorControls signal to the IPA which passes these back to the pipeline handler without using the DelayedControls mechanism. Signed-off-by: David Plowman Reviewed-by: Kieran Bingham Reviewed-by: Naushir Patuck --- include/libcamera/ipa/raspberrypi.mojom | 1 + src/ipa/raspberrypi/raspberrypi.cpp | 13 +++++++++++++ src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 10 ++++++++++ 3 files changed, 24 insertions(+) diff --git a/include/libcamera/ipa/raspberrypi.mojom b/include/libcamera/ipa/raspberrypi.mojom index f38c2261..ebaf0a04 100644 --- a/include/libcamera/ipa/raspberrypi.mojom +++ b/include/libcamera/ipa/raspberrypi.mojom @@ -117,6 +117,7 @@ interface IPARPiEventInterface { statsMetadataComplete(uint32 bufferId, ControlList controls); runIsp(uint32 bufferId); embeddedComplete(uint32 bufferId); + setSensorControls(ControlList controls); setIspControls(ControlList controls); setDelayedControls(ControlList controls); }; diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index dad6395f..f95896d2 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -1036,6 +1036,19 @@ void IPARPi::processStats(unsigned int bufferId) setDelayedControls.emit(ctrls); } + + struct AwbStatus awbStatus; + if (rpiMetadata_.Get("awb.status", awbStatus) == 0 && + sensorCtrls_.find(V4L2_CID_RED_BALANCE) != sensorCtrls_.end() && + sensorCtrls_.find(V4L2_CID_BLUE_BALANCE) != sensorCtrls_.end()) { + ControlList ctrls(sensorCtrls_); + ctrls.set(V4L2_CID_RED_BALANCE, + static_cast(helper_->ColourGainCode(awbStatus.gain_r))); + ctrls.set(V4L2_CID_BLUE_BALANCE, + static_cast(helper_->ColourGainCode(awbStatus.gain_b))); + + setSensorControls.emit(ctrls); + } } void IPARPi::applyAWB(const struct AwbStatus *awbStatus, ControlList &ctrls) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index f22e286e..8dae4912 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -152,6 +152,7 @@ public: void statsMetadataComplete(uint32_t bufferId, const ControlList &controls); void runIsp(uint32_t bufferId); void embeddedComplete(uint32_t bufferId); + void setSensorControls(const ControlList &controls); void setIspControls(const ControlList &controls); void setDelayedControls(const ControlList &controls); @@ -1219,6 +1220,7 @@ int RPiCameraData::loadIPA(ipa::RPi::SensorConfig *sensorConfig) ipa_->statsMetadataComplete.connect(this, &RPiCameraData::statsMetadataComplete); ipa_->runIsp.connect(this, &RPiCameraData::runIsp); ipa_->embeddedComplete.connect(this, &RPiCameraData::embeddedComplete); + ipa_->setSensorControls.connect(this, &RPiCameraData::setSensorControls); ipa_->setIspControls.connect(this, &RPiCameraData::setIspControls); ipa_->setDelayedControls.connect(this, &RPiCameraData::setDelayedControls); @@ -1361,6 +1363,14 @@ void RPiCameraData::embeddedComplete(uint32_t bufferId) handleState(); } +void RPiCameraData::setSensorControls(const ControlList &controls) +{ + ControlList ctrls = controls; + + unicam_[Unicam::Image].dev()->setControls(&ctrls); + handleState(); +} + void RPiCameraData::setIspControls(const ControlList &controls) { ControlList ctrls = controls;