From patchwork Tue Apr 27 13:08:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 12122 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 17FAABDE3B for ; Tue, 27 Apr 2021 13:08:58 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C582B688BC; Tue, 27 Apr 2021 15:08:57 +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="iKk8ke3W"; dkim-atps=neutral Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 52B89688B9 for ; Tue, 27 Apr 2021 15:08:52 +0200 (CEST) Received: by mail-wm1-x329.google.com with SMTP id i129so4829548wma.3 for ; Tue, 27 Apr 2021 06:08:52 -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=SRcCNs41XyRBojY2uLGpAnfWWyGX6MGdxtj3SoKY7bA=; b=iKk8ke3W+gjuSdq7H1CVyIfROkXOgLIddT5vKbJI/V3lCg8a4s+FdX7O7aBCdXeqRc /3WfXAk7kHb61tzXjnvYT/h5e4oTfG6DjJjAHb8Kiag9y4PtYIAjOiDoRQ5/FCorHje7 82R94jWVskviwGqxkAN1osg+9IgftrbKgakb1kr0k+8yVvHs/WCwJoMIjqBVfJCu4DFD ZCY7TdkFeHMon9ytzdi/a8sP9Q/I7BgIGXthFohkzJ74o3tweNecDdDBkyRY8dSybADt ZdM77JD/Ev4wffuTVIUVeppTyC2v4Qefa/BuHgXnD+YsPx86lhvaB4dp4Vvv5K39SiFg QgKQ== 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=SRcCNs41XyRBojY2uLGpAnfWWyGX6MGdxtj3SoKY7bA=; b=GSlYSnSJyPOusYAR3+WL4MZp0Lr+1qbUIuYsJmBWeEzDC2fCm1fjkQAmXXRbggOzk9 CQzKWHN69jGCP6YMQVZxZu7GJyQ54yXcNzldGqq05V6iKpCy+JtOdOJdTE2HakeLwMD3 sU3v0OWzT3NTn+5LiMbRSUCyCUKexaFy7BGBkB/LFdSx2e6Ze5rfZqd7Em6JAh/uK7Oj hY4wx+dLMqtQ7riWoIIjndDSzh8Jb3/S5I2q0GDGqKYHJ1/hqf5tAo3WLE/rlukx7+Rw lRdw0LGHI7dGyL1yf1aGJ1D1s1dee0gUs3fU8Xj2ocMAMg/HJvNqtYhPPFIyjbDY3ka0 z1ag== X-Gm-Message-State: AOAM530Ud2jG5/Ky3N6t/93VQvyBzS9NOyTortd07YhVirhJ3PNPaRUE tgqlt6dvvw0/WCf5uXgcOeF4ipC8dHwALg== X-Google-Smtp-Source: ABdhPJy7DuZivxA2vMi8SNqnuqT8YrSLM3YU4YkP9FYXJpQoXNd2NGpUCoRnYrgQb4BCF9r500OWmA== X-Received: by 2002:a05:600c:4148:: with SMTP id h8mr4252934wmm.19.1619528931901; Tue, 27 Apr 2021 06:08:51 -0700 (PDT) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id r11sm3899327wrx.22.2021.04.27.06.08.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Apr 2021 06:08:51 -0700 (PDT) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Tue, 27 Apr 2021 14:08:44 +0100 Message-Id: <20210427130844.11357-5-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210427130844.11357-1-david.plowman@raspberrypi.com> References: <20210427130844.11357-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 4/4] ipa: raspberrypi: Update sensor's V4L2_CID_NOTIFY_GAIN_RED/BLUE 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_NOTIFY_GAIN_RED and V4L2_CID_NOTIFY_GAIN_BLUE controls, we pass it 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 42321bee..24015263 100644 --- a/include/libcamera/ipa/raspberrypi.mojom +++ b/include/libcamera/ipa/raspberrypi.mojom @@ -118,6 +118,7 @@ interface IPARPiEventInterface { statsMetadataComplete(uint32 bufferId, libcamera.ControlList controls); runIsp(uint32 bufferId); embeddedComplete(uint32 bufferId); + setSensorControls(libcamera.ControlList controls); setIspControls(libcamera.ControlList controls); setDelayedControls(libcamera.ControlList controls); }; diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index dad6395f..f7d1aa0a 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_NOTIFY_GAIN_RED) != sensorCtrls_.end() && + sensorCtrls_.find(V4L2_CID_NOTIFY_GAIN_BLUE) != sensorCtrls_.end()) { + ControlList ctrls(sensorCtrls_); + ctrls.set(V4L2_CID_NOTIFY_GAIN_RED, + static_cast(helper_->ColourGainCode(awbStatus.gain_r))); + ctrls.set(V4L2_CID_NOTIFY_GAIN_BLUE, + 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 2a917455..054171d8 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;