From patchwork Wed Mar 24 11:44:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 11693 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 D427DC32E5 for ; Wed, 24 Mar 2021 11:44:23 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0C2FC602E3; Wed, 24 Mar 2021 12:44:23 +0100 (CET) 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="Ho6AM8u/"; dkim-atps=neutral Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 32BBA6051A for ; Wed, 24 Mar 2021 12:44:20 +0100 (CET) Received: by mail-ej1-x62e.google.com with SMTP id l4so32308532ejc.10 for ; Wed, 24 Mar 2021 04:44:20 -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=96cHYUpheoCt2rXy0CqVw2fjl67ZXcqGpZeXSmABg44=; b=Ho6AM8u/AukeHSqtXoxZvtng1kJK2aUtFvikUvngRofOUEqsHReqnaZPk3F5S99/uo HRfA4H2/P+GmOhbL3kaFJsIbIhX5XZhbFhsJ4PWp6JFKi6NObAR18d3062M0UBpKY7V9 XlnqRwD6yvVKP/CadPj681gyZSafu50vZDhP1YD2mJAHVWHWBCElEAUNAtZFhOY8XheE xEX7jl+OQAWa6ZdJ3GFH9YUwQIKn6b9hiEBqmA2ODYfDr1qNMtFk4dJ4Al0nu9Izl6u1 v01QCOOHdlCEIX8uNCldm7+8/EG5TNhFieQ6ZEGxEAyLRnuH9NNsMgPYU/p/kT9p2X9O Grfw== 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=96cHYUpheoCt2rXy0CqVw2fjl67ZXcqGpZeXSmABg44=; b=LdpUG2RH89J+kCX2SzRhtETlGzGy3a/Y+owpsShH9vnrCClpr3umiLlgzGAJK9Or4P jPmMFxb81eEXoKe46OYjy/Bi1rnv8R5U+l9AVI6QgLi2CHlF8t71dL/yCGLAz5/vGRcd j5Cw4K7AgkCt+a9fEovxuD6AlrECqk1wIz3GeRiEpXIWTOw1d7QQ2J//zmBoj/8046h9 whes2XKfZVkvwwZADnvrBepwmWd7nRtGfZj5gESeL3pI4ylEY2m3AQ96LAEjlTJ97iML 3DVZ2Kjojp0yVIyKXw/E2ylOCz3VHSZY974BMbQEsl6gj5NI54Tgutg7jOKxDo5mVO7Z cUXw== X-Gm-Message-State: AOAM533CuPeoMhDFG0uLrcvlmIaB/j5GnpsPwnF8DzfqTbKZ8bH2zYLC 6Lya6AlLOk1AIaBDHJYuLqDNNYxQEGD8qA== X-Google-Smtp-Source: ABdhPJwl7Y1AtFNOsq8t6klqfTh7NnBywuKY6GUwU/0O/83VdGDlO4eg3+quXjQ8Cz3fp1VdhPwPXg== X-Received: by 2002:a17:907:77d4:: with SMTP id kz20mr3229841ejc.93.1616586259646; Wed, 24 Mar 2021 04:44:19 -0700 (PDT) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id c17sm1054781edw.32.2021.03.24.04.44.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Mar 2021 04:44:19 -0700 (PDT) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Wed, 24 Mar 2021 11:44:15 +0000 Message-Id: <20210324114415.19866-3-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210324114415.19866-1-david.plowman@raspberrypi.com> References: <20210324114415.19866-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/2] 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 will need to add these to the list of delayed controls we can apply. Signed-off-by: David Plowman --- src/ipa/raspberrypi/raspberrypi.cpp | 17 ++++++++++++++--- .../pipeline/raspberrypi/raspberrypi.cpp | 9 +++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index 1c928b72..7437a77e 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -1030,13 +1030,24 @@ void IPARPi::processStats(unsigned int bufferId) RPiController::StatisticsPtr statistics = std::make_shared(*stats); controller_.Process(statistics, &rpiMetadata_); + ControlList ctrls(sensorCtrls_); + struct AgcStatus agcStatus; - if (rpiMetadata_.Get("agc.status", agcStatus) == 0) { - ControlList ctrls(sensorCtrls_); + if (rpiMetadata_.Get("agc.status", agcStatus) == 0) applyAGC(&agcStatus, ctrls); - 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()) { + ctrls.set(V4L2_CID_RED_BALANCE, + static_cast(awbStatus.gain_r * 256)); + ctrls.set(V4L2_CID_BLUE_BALANCE, + static_cast(awbStatus.gain_b * 256)); } + + if (!ctrls.empty()) + setDelayedControls.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 2cac802c..7bac1503 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1027,6 +1027,15 @@ bool PipelineHandlerRPi::match(DeviceEnumerator *enumerator) { V4L2_CID_EXPOSURE, { sensorConfig.exposureDelay, false } }, { V4L2_CID_VBLANK, { sensorConfig.vblankDelay, true } } }; + + /* If the sensor exposes red/blue balance controls, we will update them. */ + const ControlInfoMap &sensorControls = data->unicam_[Unicam::Image].dev()->controls(); + if (sensorControls.find(V4L2_CID_RED_BALANCE) != sensorControls.end() && + sensorControls.find(V4L2_CID_BLUE_BALANCE) != sensorControls.end()) { + params[V4L2_CID_RED_BALANCE] = { sensorConfig.vblankDelay, false }; + params[V4L2_CID_BLUE_BALANCE] = { sensorConfig.vblankDelay, false }; + } + data->delayedCtrls_ = std::make_unique(data->unicam_[Unicam::Image].dev(), params); data->sensorMetadata_ = sensorConfig.sensorMetadata;