From patchwork Fri May 19 14:51:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Bara X-Patchwork-Id: 18639 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 4FADBC31E9 for ; Fri, 19 May 2023 15:07:30 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9D9416285F; Fri, 19 May 2023 17:07:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1684508849; bh=yUrl/VPwhm8mmItIrau3nWey9KpTOz3LrTgkww+1gv8=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=jlure8XHX1v3i6pgSE2OlIQxNWBbjGPxta/7Nk4ICfKre9syj2N4Dg5mj0p05OB4G LHuIVqsB2sagvo7hjlxM4fzytuy9EcXpU2V6hTe7+YBUQM5gyWtn8qjF5EwNu2WWRr 4865OHHq0vYwB1rBCtoMt/V8h3RykvhfRGpWRzB+sy2Yk3gGuqrrm/q8VG7fvgxvfu q3+zhfNNeBa2sMI9nZjbeX9q9Wyw2HTfLfG3QCmA6Zp+3BQoBTuvDfJArvrmg/wnvc D3RCelLyLEIIzhegIbFiv5MpSWq4sRJPz6SnDydswy5pL/O4HS/KHnzRow5vE31IR+ 1/pQ9ZSM+H+NQ== Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C13DD627CD for ; Fri, 19 May 2023 16:51:18 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="HOOKRzP2"; dkim-atps=neutral Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-96f50e26b8bso262596566b.2 for ; Fri, 19 May 2023 07:51:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684507878; x=1687099878; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Pky30XqpzLsH55nKa+2aLDaZYfSC41hnPZxl97IONeE=; b=HOOKRzP2WZvYDrwusjVxxL/4ROeiCyXmXK5EhrnMfEMzP6daMuIYWrC6z5YW1hNE/N a596XX36lDu3zCGeZjWXadv9zha8n1QzXGW0cQRaEuj5vco29WPbInVmbLg3B2Swqpbt uC9ljBX8U3OgU4/hoTc39iPUCj/Mx29N6M1gYabuCgaA1v/bSnMDU+BS5J5ZiVB74wPn 0rWtSoqpyI2TN1GG+yDUXeW63K4ICYiqzd+UPA31fffTNDIZQ4zclzwMwO9NvcWviK1m wnbiTTzZOg0FwXWJd5z8mY0wFbFmqAgOY5IpZn1xGNyfUk+z9kGSVstRm/UgHZTFS8wS KSHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684507878; x=1687099878; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Pky30XqpzLsH55nKa+2aLDaZYfSC41hnPZxl97IONeE=; b=NQSatcjLVduarf/ON/WA6iq/16YOKium2TTZO3R3HUcUcOWdyzaiHtyOIhdpmUyu72 z59IAXJcnA8Zkg7wxbJ8lgjhk2qV49HCC93NJje7XouheQyej48E/FiIJQSFulcd+eGy L4U8mj8OsfZdSL/7X4XUbvIP4Ik0SMTFYFNznEs2q7/ivn0ZjEyUI2gduTl/OVVBPcE2 fyiMmD1+VlAiTzyu6kGPnKgx0rpy0Zf2mUe5lkp3iOHPeCK1+UTOSMQsCVpKlsnTGYf5 CZxavo3mrQ1hAUetF2bYBDWo7b+SQwMhojKi5lW5BALQtOyWdoDZbFcL7sC68JnQk4YY I2aQ== X-Gm-Message-State: AC+VfDzXJIWa7YgxPJofSICZT39pkt68oSkJgSbvSDrkf4I1niqFt5ZP Wy0l7lZSNGdAbT25zJbs7L9eRdSM34U= X-Google-Smtp-Source: ACHHUZ7vXajW6iHMcVKdm8VB29sodiB5v+gMMQ/FB/g5VcZqASwCP0+DGg6oegxzfZdcfSqnmpulCw== X-Received: by 2002:a17:907:3206:b0:94e:8559:b5c5 with SMTP id xg6-20020a170907320600b0094e8559b5c5mr1623585ejb.64.1684507877774; Fri, 19 May 2023 07:51:17 -0700 (PDT) Received: from PCBABN.skidata.net ([91.230.2.244]) by smtp.gmail.com with ESMTPSA id bq6-20020a170906d0c600b0093313f4fc3csm2375636ejb.70.2023.05.19.07.51.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 May 2023 07:51:17 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 19 May 2023 16:51:09 +0200 Message-Id: <20230519145109.447590-1-bbara93@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Mailman-Approved-At: Fri, 19 May 2023 17:07:28 +0200 Subject: [libcamera-devel] [PATCH] ipa: rkisp1: agc: drop hard-coded analogue gain range 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: Benjamin Bara via libcamera-devel From: Benjamin Bara Reply-To: Benjamin Bara Cc: Benjamin Bara Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Benjamin Bara As the sensor's analogue gain range is known (read-out in IPARkISP1::configure()), drop the limiting hard-coded range. This enables better performance in low-light conditions for sensors with a higher gain (e.g. the imx327). Signed-off-by: Benjamin Bara Reviewed-by: Kieran Bingham Reviewed-by: Jacopo Mondi --- src/ipa/rkisp1/algorithms/agc.cpp | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp index 22f70aba..a4e5500e 100644 --- a/src/ipa/rkisp1/algorithms/agc.cpp +++ b/src/ipa/rkisp1/algorithms/agc.cpp @@ -36,15 +36,6 @@ namespace ipa::rkisp1::algorithms { LOG_DEFINE_CATEGORY(RkISP1Agc) -/* - * Limits for analogue gain values - * - * \todo Remove the hard-coded limits and let the sensor helper specify - * the minimum and maximum allowed gain values. - */ -static constexpr double kMinAnalogueGain = 1.0; -static constexpr double kMaxAnalogueGain = 16.0; - /* \todo Honour the FrameDurationLimits control instead of hardcoding a limit */ static constexpr utils::Duration kMaxShutterSpeed = 60ms; @@ -80,9 +71,7 @@ Agc::Agc() int Agc::configure(IPAContext &context, const IPACameraSensorInfo &configInfo) { /* Configure the default exposure and gain. */ - context.activeState.agc.automatic.gain = - std::max(context.configuration.sensor.minAnalogueGain, - kMinAnalogueGain); + context.activeState.agc.automatic.gain = context.configuration.sensor.minAnalogueGain; context.activeState.agc.automatic.exposure = 10ms / context.configuration.sensor.lineDuration; context.activeState.agc.manual.gain = context.activeState.agc.automatic.gain; @@ -265,10 +254,8 @@ void Agc::computeExposure(IPAContext &context, IPAFrameContext &frameContext, utils::Duration maxShutterSpeed = std::min(configuration.sensor.maxShutterSpeed, kMaxShutterSpeed); - double minAnalogueGain = std::max(configuration.sensor.minAnalogueGain, - kMinAnalogueGain); - double maxAnalogueGain = std::min(configuration.sensor.maxAnalogueGain, - kMaxAnalogueGain); + double minAnalogueGain = configuration.sensor.minAnalogueGain; + double maxAnalogueGain = configuration.sensor.maxAnalogueGain; /* Consider within 1% of the target as correctly exposed. */ if (utils::abs_diff(evGain, 1.0) < 0.01)