From patchwork Wed Dec 6 10:38:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 19285 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 26352C32BC for ; Wed, 6 Dec 2023 10:38:48 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id AFC0E629E1; Wed, 6 Dec 2023 11:38:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1701859126; bh=VHu1D8QcGt3QTtWrGB09AuC+u5A4cHlLLdus5GFWFhc=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=V6xF+rQEvIFzAZvGli+/e5ttX6ShB3RrZTQWQc9jksyJ1p+sPMTKcfMpJeAsMVYgM n321AOVNx9OKujq0WrvcwhV+AJYKeM6JaNCwzwG4HMo9UQiwYdvzMqOL0uaqWrX77P UXoBPe9p44BBk3Gcl2QWnkXq58eUP4TmcAkx8wsKEGRW6S5vjrMpR/mu6+YlB65gCO dNE5GSKvzi9Wh5k+saho1wK7QoXWM/0Is/ZSB0FHw0NGB0180SBwGi9x4QqyyxZTAD puSodCmp89NLPSlkx+6Xzy2OpVu5pqptiwX+TuMDHmzbn81KAT0BAUXcLUe7kgo+NQ kz5fesKoqAByA== Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 50D2361D9D for ; Wed, 6 Dec 2023 11:38:44 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="Z6bGHpfJ"; dkim-atps=neutral Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-33340c50af9so612263f8f.3 for ; Wed, 06 Dec 2023 02:38:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1701859123; x=1702463923; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KfdxpVw/nqOtJSbSlLwQZUu9ot11A/cqlOXqcakgcC0=; b=Z6bGHpfJaXh5ND1jJu+4iHAbyOS/MigiwweKtTD/4H5RN7m49sfdVErmT37+iMeB2R 6IpjFaxOPFCn7HkOrkGU1TWCnvJMK5NHLJxAq34tWtGNvhVjYoWZ4fORD+W1c8OGiOdx T7KJ65FMgWVRo0OfGSuGDrLr3zLF9iAvo/0hk35oxjJXCyvi6aiCYUNIOs9q1Ixq5/ev pcBhqMH3WQV6DpIfV3Im66XwhDaI9Z4k04p21MGhjB6HDmwz/f3DfOB7OQQg2v24ATwt S0OcOa7srHaK24ntc2h1MOqC/4GqST68HjlDuhlnuIMEL/kq2JJTBvbKi++slD0FcAUJ vIoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701859123; x=1702463923; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KfdxpVw/nqOtJSbSlLwQZUu9ot11A/cqlOXqcakgcC0=; b=UoGEmZ0NNNu2K0uyQi2Gpqh3ojwmolt7DnzS/leJNrrsIWP945sUF5ac8t6Vc2ATIB 7I9ksHYHXwPft3CVtQQlmsAwsUn9aPEneuE/3DR+P6Wlgdsku7TsnlO5Nr1KT5V46U8Y BiKbJ6sDq5uYtELVDHXIMvHV07Ce3R1dGPz1LGoUs20Qjv/XcE3MAXTmKAIRZlnaSsYX PXgh8ypdKjtCTcyRwA+HlbjNKc7u+TMSMiHAIbOiNhauALWu7rpPutnQAiitBB5OppMg Ad3yizYNXr9QtwrbMWcku2HeNzgO09hitt9qn1Z6ymDGCZikGEkl40h9jpC4WTydBOLt rGlA== X-Gm-Message-State: AOJu0Ywxd0YU9NKF2fEjIGuYUq6OK55jUWCkyeJlnxomViZ9vpnI71bZ lfSx7HsdQEHgQ/uazwJZiMSqs+gfAoMtScwwKmU= X-Google-Smtp-Source: AGHT+IFDd1R6CByowznNthXLw1sqWQevBn76xueZKdHwnGytaTAddTFI3aXljUHSiMGgP9115RiluQ== X-Received: by 2002:adf:f652:0:b0:333:3cf1:baaa with SMTP id x18-20020adff652000000b003333cf1baaamr255662wrp.60.1701859123434; Wed, 06 Dec 2023 02:38:43 -0800 (PST) Received: from localhost.localdomain ([194.233.231.115]) by smtp.gmail.com with ESMTPSA id w7-20020a5d6087000000b0033340937da6sm9733697wrt.95.2023.12.06.02.38.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 02:38:43 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Wed, 6 Dec 2023 10:38:38 +0000 Message-Id: <20231206103839.16607-2-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231206103839.16607-1-david.plowman@raspberrypi.com> References: <20231206103839.16607-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/2] ipa: rpi: black_level: Add an initialValues method 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: , X-Patchwork-Original-From: David Plowman via libcamera-devel From: David Plowman Reply-To: David Plowman Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" This allows the IPA to discover the correct black level values even before any frames have been processed. This is important on the PiSP platform where the front end black level blocks must be programmed in advance. Signed-off-by: David Plowman Reviewed-by: Naushir Patuck --- .../rpi/controller/black_level_algorithm.h | 23 +++++++++++++++++++ src/ipa/rpi/controller/rpi/black_level.cpp | 10 +++++++- src/ipa/rpi/controller/rpi/black_level.h | 6 +++-- 3 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 src/ipa/rpi/controller/black_level_algorithm.h diff --git a/src/ipa/rpi/controller/black_level_algorithm.h b/src/ipa/rpi/controller/black_level_algorithm.h new file mode 100644 index 00000000..c2cff2f5 --- /dev/null +++ b/src/ipa/rpi/controller/black_level_algorithm.h @@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ +/* + * Copyright (C) 2023, Raspberry Pi Ltd + * + * black_level_algorithm.h - black level control algorithm interface + */ +#pragma once + +#include "algorithm.h" + +namespace RPiController { + +class BlackLevelAlgorithm : public Algorithm +{ +public: + BlackLevelAlgorithm(Controller *controller) + : Algorithm(controller) {} + /* A black level algorithm must provide the following: */ + virtual void initialValues(uint16_t &blackLevelR, uint16_t &blackLevelG, + uint16_t &blackLevelB) = 0; +}; + +} /* namespace RPiController */ diff --git a/src/ipa/rpi/controller/rpi/black_level.cpp b/src/ipa/rpi/controller/rpi/black_level.cpp index 85baec3f..2e3db51f 100644 --- a/src/ipa/rpi/controller/rpi/black_level.cpp +++ b/src/ipa/rpi/controller/rpi/black_level.cpp @@ -22,7 +22,7 @@ LOG_DEFINE_CATEGORY(RPiBlackLevel) #define NAME "rpi.black_level" BlackLevel::BlackLevel(Controller *controller) - : Algorithm(controller) + : BlackLevelAlgorithm(controller) { } @@ -45,6 +45,14 @@ int BlackLevel::read(const libcamera::YamlObject ¶ms) return 0; } +void BlackLevel::initialValues(uint16_t &blackLevelR, uint16_t &blackLevelG, + uint16_t &blackLevelB) +{ + blackLevelR = blackLevelR_; + blackLevelG = blackLevelG_; + blackLevelB = blackLevelB_; +} + void BlackLevel::prepare(Metadata *imageMetadata) { /* diff --git a/src/ipa/rpi/controller/rpi/black_level.h b/src/ipa/rpi/controller/rpi/black_level.h index 2403f7f7..d8c41c62 100644 --- a/src/ipa/rpi/controller/rpi/black_level.h +++ b/src/ipa/rpi/controller/rpi/black_level.h @@ -6,19 +6,21 @@ */ #pragma once -#include "../algorithm.h" +#include "../black_level_algorithm.h" #include "../black_level_status.h" /* This is our implementation of the "black level algorithm". */ namespace RPiController { -class BlackLevel : public Algorithm +class BlackLevel : public BlackLevelAlgorithm { public: BlackLevel(Controller *controller); char const *name() const override; int read(const libcamera::YamlObject ¶ms) override; + void initialValues(uint16_t &blackLevelR, uint16_t &blackLevelG, + uint16_t &blackLevelB) override; void prepare(Metadata *imageMetadata) override; private: From patchwork Wed Dec 6 10:38:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 19286 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 13D0CC32BD for ; Wed, 6 Dec 2023 10:38:49 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 645E062B2C; Wed, 6 Dec 2023 11:38:47 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1701859127; bh=ni2QX6pma5m3c0EiLshQSYkCMzf2cqIxtSOG4x8MMt4=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=zAFXLhN2HS9rZzz3vv5TM5pd3m34/E4ojhzX6yk385ph3imvA6X8bEInI6/qPU0su efFbT/G4UNOaGO2fRD2D+OSLmd00rzLuAh+lrntkvCyJs44PtuNdI43oqMYR5e8nH8 PQ1v72OpVH/8dzMDylvmxS2NC0KbxSLB7F/eBOYXGG6JzKfyJSCLn355cy7A6Su1bT 5juhyzNKPivsmohY5OIkFMNOwbTLMHbLZKNQnOgbSS1yF8dbdztI0Oz4k+P2nDcPfo E2CI0rwDexfzVE6fX1C2FQjXKLLQKIP91sY3iMCL0l19TJMcSCin2LffVGklSHDWrO H/MzVZz0lU7Aw== Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C6C8661D9D for ; Wed, 6 Dec 2023 11:38:44 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="IvlxspLF"; dkim-atps=neutral Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-334af3b3ddfso122150f8f.3 for ; Wed, 06 Dec 2023 02:38:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1701859124; x=1702463924; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SH1bgtabT2/Y07DB0FvYUY/ZLjVIDck7Ae1kliUNlaY=; b=IvlxspLF6GO7y9nEIf4e9jWV4ui/IohuXUucXa2suZLxlrva7oCaCzkSKgjfp1eOK/ 4iEKHVLWN2GGucOnvdcmFHHUqBHgqzrJNeD1KoDBaHYTmkx4zLfltD0k4wNiaYoE1wAx SST8lJ7Ie/4+zJDG14ZfUMJbibKAe1xfMkI1kyB84R2K6+9DQ71oUCfhl8gD0m7N/oUf 4awkFeWVJuR+gijJfyBXVSvVzEp4USwR7MA2b60xOyWm1f/PLbTe8rOcT/P39Wxy46ra NvcoA38n7/ooi2RjoTp7M7/aTrDl5UJvh1b2tLRI6tFw7gOi/DYvihAzrqmZE3igBPQ0 ZPMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701859124; x=1702463924; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SH1bgtabT2/Y07DB0FvYUY/ZLjVIDck7Ae1kliUNlaY=; b=Hklqb8F13TKb0BAdgGTJsat2EjTTVkg7V0cB+PAnl/s9tNJ850hE72n/lOo0i7uh4R p2b5gfveIWgcn2PPY2n5R2f5CqcqHrvI6pdOeDj/Zxd977+0OOIvEWvD93s9MRRrfCC7 N2mshYqSHPqThs7DeQAztFu0lYG7FPBP6hARbjOo2UgRwmDIVy0XfzNjwyiLcQw+WYW+ mMMEbCMvOQL2cB77ywobxy79YkW/dfS7tVM/LotY+5v2NCmA9byOxAyXe/oO2OGuoILJ Iol3SwD7l/8zXvtkLSGMDr2ahZFYjLLY9N3dkYCU1OPuMq62yz1e/xHBY0LvHk7uEJwf hf2A== X-Gm-Message-State: AOJu0YzerXe2OdEceiDuIVASbGZuBd0IizobGSS1yp19MK/ZeQk/N2Yo vfLlw10fT5ekwGwoP12s8WQG+iiYTNlr5iVBLlo= X-Google-Smtp-Source: AGHT+IE94/A2Q/NdH8+cWw8q4Yly/6Kyf8/yi2x53oXC0ZNiQT+7x+xrwlW46X3yl60f4MvhEyXxgg== X-Received: by 2002:a5d:5002:0:b0:333:4bd9:78 with SMTP id e2-20020a5d5002000000b003334bd90078mr320759wrt.15.1701859124027; Wed, 06 Dec 2023 02:38:44 -0800 (PST) Received: from localhost.localdomain ([194.233.231.115]) by smtp.gmail.com with ESMTPSA id w7-20020a5d6087000000b0033340937da6sm9733697wrt.95.2023.12.06.02.38.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 02:38:43 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Wed, 6 Dec 2023 10:38:39 +0000 Message-Id: <20231206103839.16607-3-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231206103839.16607-1-david.plowman@raspberrypi.com> References: <20231206103839.16607-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/2] ipa: rpi: awb: Add an initialValues method 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: , X-Patchwork-Original-From: David Plowman via libcamera-devel From: David Plowman Reply-To: David Plowman Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" This allows the IPA to get reasonable default colour gains before AWB has run. This is particularly important on the PiSP platform where these numbers are helpful in programming the Front End statistics block in advance. Signed-off-by: David Plowman Reviewed-by: Naushir Patuck --- src/ipa/rpi/controller/awb_algorithm.h | 1 + src/ipa/rpi/controller/rpi/awb.cpp | 6 ++++++ src/ipa/rpi/controller/rpi/awb.h | 1 + 3 files changed, 8 insertions(+) diff --git a/src/ipa/rpi/controller/awb_algorithm.h b/src/ipa/rpi/controller/awb_algorithm.h index 8462c4db..6009bdac 100644 --- a/src/ipa/rpi/controller/awb_algorithm.h +++ b/src/ipa/rpi/controller/awb_algorithm.h @@ -16,6 +16,7 @@ public: AwbAlgorithm(Controller *controller) : Algorithm(controller) {} /* An AWB algorithm must provide the following: */ virtual unsigned int getConvergenceFrames() const = 0; + virtual void initialValues(double &gainR, double &gainB) = 0; virtual void setMode(std::string const &modeName) = 0; virtual void setManualGains(double manualR, double manualB) = 0; virtual void enableAuto() = 0; diff --git a/src/ipa/rpi/controller/rpi/awb.cpp b/src/ipa/rpi/controller/rpi/awb.cpp index 5ae0c2fa..dde5785a 100644 --- a/src/ipa/rpi/controller/rpi/awb.cpp +++ b/src/ipa/rpi/controller/rpi/awb.cpp @@ -220,6 +220,12 @@ void Awb::initialise() asyncResults_ = syncResults_; } +void Awb::initialValues(double &gainR, double &gainB) +{ + gainR = syncResults_.gainR; + gainB = syncResults_.gainB; +} + void Awb::disableAuto() { /* Freeze the most recent values, and treat them as manual gains */ diff --git a/src/ipa/rpi/controller/rpi/awb.h b/src/ipa/rpi/controller/rpi/awb.h index e7d49cd8..cde6a62f 100644 --- a/src/ipa/rpi/controller/rpi/awb.h +++ b/src/ipa/rpi/controller/rpi/awb.h @@ -95,6 +95,7 @@ public: void initialise() override; int read(const libcamera::YamlObject ¶ms) override; unsigned int getConvergenceFrames() const override; + void initialValues(double &gainR, double &gainB) override; void setMode(std::string const &name) override; void setManualGains(double manualR, double manualB) override; void enableAuto() override;