From patchwork Wed Mar 24 11:44:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 11692 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 3A917C32E5 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 18CE168D6A; Wed, 24 Mar 2021 12:44:22 +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="mNfJ43Ek"; dkim-atps=neutral Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 94BB86051A for ; Wed, 24 Mar 2021 12:44:19 +0100 (CET) Received: by mail-ed1-x52e.google.com with SMTP id w18so27308201edc.0 for ; Wed, 24 Mar 2021 04:44:19 -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=mrjhT2FmHfGM+ETL2c8tGFpgFd9U4oNZSbU5UloGtqs=; b=mNfJ43Eks3xUF3+HJsLeQlHFAy2AU2UcydD50SW2Fn6aE+jnr+nKSHDbeDiVdJsJwv 4kEJhIKsIR/MUFhd5nwvpqKt0PqowGs3xrmfgyGEelLJK/N6pwCYWnUNMf9n99u1OIVk 74jRUeqWrNYgMLp3sG+wjF9q+DeDHNQyV3AjdeXd5Lo4mPelHtzVrXtK0i56pyVgfzoF 1WklXfJw5oUqVyaUWUvKVp8EWxrEcwImAIidzH2tAphqCs3Oocx4j3I7g4/vUpXsCpOT zaguXKpSd+7+xQdj7I/qkZ1+BpXeNEev3wpTowtY9YWMejdDfJqglf55H4BM5IBzlqZm GqHQ== 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=mrjhT2FmHfGM+ETL2c8tGFpgFd9U4oNZSbU5UloGtqs=; b=raVvjNpJk1oWCW/DW8IZ6dTSHYEYcfpdu25oToJNTWrQ7jG3GSeiaXMs/iS5AE3E3K bbwyy0Wwj5YbW4XmEl3IZIcxfCaSuMuiK3uE5XrCG5B81KBupPZYTSaugTB0ObWHibUD B5d1m2d5h4QOYjenZgV0JB7/VqLoOZOz+9QKZu0ISw2aNnYBIx+jk+3yJN4ksO8COjTP KS0D/nAqHFK6fHWaPyQui04adn5+2T3L2X2zhIQI3/cEmvogINZHAvyDTwteNYXngRKy ZZvOuk6qE/e7j6o9wtrf7bVvetgqtvZ9eUZR3aTMZr+mNnBoGRkaS99dm5/Xmy6Xvbx8 6peQ== X-Gm-Message-State: AOAM5308eamYOhTWOxRWsqxSoyqzmV5OGPhKZKEQSuBkmmTvHPwbvgT1 CI02qcXcsxKHezBZsveEWjiQz4dFCgR/pg== X-Google-Smtp-Source: ABdhPJwipaldQ0UbHtRg5u4PoBnIWSjDhneM08wVtrrD8s+7Vhvy+B3AB7OWsRpqOB3jSUNLen6+3w== X-Received: by 2002:a05:6402:c0f:: with SMTP id co15mr2887198edb.373.1616586259043; 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.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Mar 2021 04:44:18 -0700 (PDT) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Wed, 24 Mar 2021 11:44:14 +0000 Message-Id: <20210324114415.19866-2-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 1/2] ipa: raspberrypi: Make CamHelper exposure methods virtual 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" This allows derived classes to override them if they have any special behaviours to implement. For instance if a particular camera mode produces a different signal level to other modes, you might choose to address that in the gain or exposure methods. Signed-off-by: David Plowman Reviewed-by: Naushir Patuck --- src/ipa/raspberrypi/cam_helper.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ipa/raspberrypi/cam_helper.hpp b/src/ipa/raspberrypi/cam_helper.hpp index 1b2d6eec..4053a870 100644 --- a/src/ipa/raspberrypi/cam_helper.hpp +++ b/src/ipa/raspberrypi/cam_helper.hpp @@ -66,8 +66,8 @@ public: virtual ~CamHelper(); void SetCameraMode(const CameraMode &mode); MdParser &Parser() const { return *parser_; } - uint32_t ExposureLines(double exposure_us) const; - double Exposure(uint32_t exposure_lines) const; // in us + virtual uint32_t ExposureLines(double exposure_us) const; + virtual double Exposure(uint32_t exposure_lines) const; // in us virtual uint32_t GetVBlanking(double &exposure_us, double minFrameDuration, double maxFrameDuration) const; virtual uint32_t GainCode(double gain) const = 0; 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;