From patchwork Mon Jan 24 10:31:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 15293 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 260C4BF415 for ; Mon, 24 Jan 2022 10:31:13 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7E9CB60987; Mon, 24 Jan 2022 11:31:12 +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="BYPFnPwK"; dkim-atps=neutral Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A477E60215 for ; Mon, 24 Jan 2022 11:31:10 +0100 (CET) Received: by mail-wm1-x334.google.com with SMTP id o30-20020a05600c511e00b0034f4c3186f4so2758072wms.3 for ; Mon, 24 Jan 2022 02:31:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=lUd6MuJ460zqOHLslCR49u36QMbLyzBHDCNTLUdvVHI=; b=BYPFnPwKVb6HGczlyYU9Jawy3UFyKFAg6XnVONMyG3S5PuxILSbRAkkHQpJGYF+79f KO1Wss4iM0I+AUtTRZ98tD84BIyuACQEIkKtlvQ5zh93zmSHRlGVfs6xVNlS9RVG59eb lciRs+B1cMmkBoT01OInAfkMgfg08bAYdIpCbTaduglioTgDvYI28R4/lzvku91cIEbu N8o1ZjBP/0GOKL6b7mjd6FaF18bH7C92e0+9LX06tQ7iPFefzndtyeL0ybF0pxKGL/7D OcNJ/BLf5Rb8x8gCygChn/L3ejDPr0gjt9DFNO8tqxc3gFFwo81M5F291FhmRZlk+X9R 2HXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=lUd6MuJ460zqOHLslCR49u36QMbLyzBHDCNTLUdvVHI=; b=IcU7vOOYjlESaZanY/sZWm07IBfkvLXfqgdoQJ6CcaIa94YZP0xvmuFW2pYpEYq13y 2MOkCt7M1p8xUIlNnxFI89oiOvyXx0rfIiFLrXKZJ5mqbOsotj02MZutIwW/gyW95uxh wtYKLAWq8VFGPrVEvPsi+faLwMfiLhAopT8pBkUs2IkK0DycGDbUaY5qAgGNCB2Sh9Q6 FGB3gCcdoIw1kPuhj8EcUjBZ9tui6u1eeRb2oOiwLJrcypsj//It6oP+09g9s0HXQgre EPd4Uj6IrCOzA08Ep8ekzqxKFEOCR8IuAW5LOWNboEGZYtwX40xQJ+vExLzWfVSIrU+y ncDA== X-Gm-Message-State: AOAM531VYrSNYkiWdD8vs15WHnRe9hkD0mE1pPVsdd4vBsMUYPZvq6v5 DaSQJTx2pIoauQ3fYqYG8yXjzwZkUHRX+A== X-Google-Smtp-Source: ABdhPJyCTl3EVdeqyQru6Ea2BSbBAlnmgzEsQqvEqMbyQcJmBFkTwlvmJJFiFWSy2JmunIsvURc25w== X-Received: by 2002:a05:600c:3391:: with SMTP id o17mr1206309wmp.156.1643020270048; Mon, 24 Jan 2022 02:31:10 -0800 (PST) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:d877:8ca4:c9e0:6bb7]) by smtp.gmail.com with ESMTPSA id x6sm16285480wrn.18.2022.01.24.02.31.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 02:31:09 -0800 (PST) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Mon, 24 Jan 2022 10:31:06 +0000 Message-Id: <20220124103107.1799464-1-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 1/2] ipa: raspberrypi: Limit the maximum sensor gain used 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" Limit the gain code to the maximum value reported by the sensor controls when sending to DelayedControls. The AGC algorithm will handle a lower gain used by the sensor, provided provided it knows the actual gain used. This change ensures that DelayedControls will never report an unclipped gain used. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman Reviewed-by: Kieran Bingham --- src/ipa/raspberrypi/raspberrypi.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index 0ed41385018a..a72d516f84ee 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -173,6 +173,9 @@ private: /* Frame duration (1/fps) limits. */ Duration minFrameDuration_; Duration maxFrameDuration_; + + /* Maximum gain code for the sensor. */ + uint32_t maxSensorGainCode_; }; int IPARPi::init(const IPASettings &settings, ipa::RPi::SensorConfig *sensorConfig) @@ -357,6 +360,8 @@ int IPARPi::configure(const IPACameraSensorInfo &sensorInfo, return -1; } + maxSensorGainCode_ = sensorCtrls_.at(V4L2_CID_ANALOGUE_GAIN).max().get(); + /* Setup a metadata ControlList to output metadata. */ libcameraMetadata_ = ControlList(controls::controls); @@ -1113,6 +1118,13 @@ void IPARPi::applyAGC(const struct AgcStatus *agcStatus, ControlList &ctrls) { int32_t gainCode = helper_->GainCode(agcStatus->analogue_gain); + /* + * Ensure anything larger than the max gain code will not be passed to + * DelayedControls. The AGC will correctly handle a lower gain returned + * by the sensor, provided it knows the actual gain used. + */ + gainCode = std::min(gainCode, maxSensorGainCode_); + /* GetVBlanking might clip exposure time to the fps limits. */ Duration exposure = agcStatus->shutter_time; int32_t vblanking = helper_->GetVBlanking(exposure, minFrameDuration_, maxFrameDuration_); From patchwork Mon Jan 24 10:31:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 15294 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 57848BF415 for ; Mon, 24 Jan 2022 10:31:14 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 01F2160215; Mon, 24 Jan 2022 11:31:13 +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="MgqEVPQ3"; dkim-atps=neutral Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 982F460215 for ; Mon, 24 Jan 2022 11:31:11 +0100 (CET) Received: by mail-wm1-x330.google.com with SMTP id f202-20020a1c1fd3000000b0034dd403f4fbso23968146wmf.1 for ; Mon, 24 Jan 2022 02:31:11 -0800 (PST) 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=VuvwQc+xnjO1R8Rc2f7WGY1FuJD6++xIIZDUxkQmoJU=; b=MgqEVPQ3NX3SSWuov2Mn+bCf2xpzXKET5YSVed1Dz12aSoTl7UR2GJioU0ETS2Xppv qIceWGo6lMie/hSMryYrTF72dCMYYorxXWjeGDVGcVs0w+7QG3jkurvis0xlVbx1TrkF CAGgLiOtwzG274JxKygpQzZS8uVScctdjjgi8bnKltjxUJltjjQGuQiwDHi+YhIVbV2C kKa6D0QsgIQCwqh5fEW7ZIRpU7otCWYPj1j7npgR0pbbi8P1uKh0QA29Q/DX140joAe7 E43540Rbe0JHCIMzBqw7XGJrPu5CA4WDf0soWpcXFOcN+8hgeY+3pyR+COncjxBL4LHr /gkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VuvwQc+xnjO1R8Rc2f7WGY1FuJD6++xIIZDUxkQmoJU=; b=zfjfGOw7+IjRVItE/CYwY3+L6wt2dEgAPsybi3kP+BOnDz4enLSXsZmo9az5S+BWW3 KVOONq472p+HfYOembjX0gQ6QMbPtioezOG1pXoxiWlNNFr01rrio99QBfnbFPiwQLEI B90UN8t6nZO1UYOhbXzCZEWyzx8p2HGHje3g9IToeeO5lMM9YIHP7Pgz+7EHFeVh3eDo 7UmdvLEP2qe/sVpP9R5sTcmtye5xWyHR9xy+Wo8kuOtFfVDG9qae2fvjIA40otOLCqv0 +YNE3kS4c9b+U5/WfvfTzVy2AljnH1Ui31thEaFYXseb8nFkud8rYPslhH1xH/EqRxiX REgg== X-Gm-Message-State: AOAM531ZbfKZQlaVcl7ib7CwwEkEVaGdLbclaNxflx1nJ+Y+Ui66+LYT 8rI217bGjsBPAPOrm1L933oVZ0TkRZ0HbQ== X-Google-Smtp-Source: ABdhPJxL07fo9VzpbjQC6RPdQjqV4oRTqKMdMeydVno0GTs63NogLs3yDAWum1kjJgbrRFNc9kA8sA== X-Received: by 2002:a05:600c:601f:: with SMTP id az31mr1225908wmb.35.1643020270873; Mon, 24 Jan 2022 02:31:10 -0800 (PST) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:d877:8ca4:c9e0:6bb7]) by smtp.gmail.com with ESMTPSA id x6sm16285480wrn.18.2022.01.24.02.31.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 02:31:10 -0800 (PST) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Mon, 24 Jan 2022 10:31:07 +0000 Message-Id: <20220124103107.1799464-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220124103107.1799464-1-naush@raspberrypi.com> References: <20220124103107.1799464-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 2/2] ipa: raspberrypi: config: Increase the max gain in the exposure profiles 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" Increase the maximum allowable gain from 6.0 to 8.0 in the normal and short exposure profiles for all camera sensors. Increase this limit to 12.0 for the long exposure profiles for sensors where this has been defined. The 6.0x value was somewhat arbitrarily chosen, and does limit the total exposure in dark conditions. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman Reviewed-by: Kieran Bingham --- src/ipa/raspberrypi/data/imx219.json | 6 +++--- src/ipa/raspberrypi/data/imx219_noir.json | 6 +++--- src/ipa/raspberrypi/data/imx290.json | 2 +- src/ipa/raspberrypi/data/imx378.json | 4 ++-- src/ipa/raspberrypi/data/imx477.json | 6 +++--- src/ipa/raspberrypi/data/imx477_noir.json | 6 +++--- src/ipa/raspberrypi/data/imx519.json | 4 ++-- src/ipa/raspberrypi/data/ov5647.json | 6 +++--- src/ipa/raspberrypi/data/ov5647_noir.json | 6 +++--- src/ipa/raspberrypi/data/ov9281.json | 2 +- src/ipa/raspberrypi/data/se327m12.json | 4 ++-- 11 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/ipa/raspberrypi/data/imx219.json b/src/ipa/raspberrypi/data/imx219.json index 1ec338be2ccb..de59d9363be4 100644 --- a/src/ipa/raspberrypi/data/imx219.json +++ b/src/ipa/raspberrypi/data/imx219.json @@ -137,7 +137,7 @@ ], "gain": [ - 1.0, 2.0, 4.0, 6.0, 6.0 + 1.0, 2.0, 4.0, 6.0, 8.0 ] }, "short": @@ -148,7 +148,7 @@ ], "gain": [ - 1.0, 2.0, 4.0, 6.0, 6.0 + 1.0, 2.0, 4.0, 6.0, 8.0 ] }, "long": @@ -159,7 +159,7 @@ ], "gain": [ - 1.0, 2.0, 4.0, 6.0, 6.0 + 1.0, 2.0, 4.0, 6.0, 12.0 ] } }, diff --git a/src/ipa/raspberrypi/data/imx219_noir.json b/src/ipa/raspberrypi/data/imx219_noir.json index 1d48ef53d33b..9a3f03ec86f4 100644 --- a/src/ipa/raspberrypi/data/imx219_noir.json +++ b/src/ipa/raspberrypi/data/imx219_noir.json @@ -69,7 +69,7 @@ ], "gain": [ - 1.0, 2.0, 4.0, 6.0, 6.0 + 1.0, 2.0, 4.0, 6.0, 8.0 ] }, "short": @@ -80,7 +80,7 @@ ], "gain": [ - 1.0, 2.0, 4.0, 6.0, 6.0 + 1.0, 2.0, 4.0, 6.0, 8.0 ] }, "long": @@ -91,7 +91,7 @@ ], "gain": [ - 1.0, 2.0, 4.0, 6.0, 6.0 + 1.0, 2.0, 4.0, 6.0, 12.0 ] } }, diff --git a/src/ipa/raspberrypi/data/imx290.json b/src/ipa/raspberrypi/data/imx290.json index 6fb92cc41593..20b45c1684c2 100644 --- a/src/ipa/raspberrypi/data/imx290.json +++ b/src/ipa/raspberrypi/data/imx290.json @@ -79,7 +79,7 @@ ], "gain": [ - 1.0, 2.0, 4.0, 6.0, 6.0 + 1.0, 2.0, 4.0, 6.0, 8.0 ] } }, diff --git a/src/ipa/raspberrypi/data/imx378.json b/src/ipa/raspberrypi/data/imx378.json index 3c2164e2ec63..6620034513f0 100644 --- a/src/ipa/raspberrypi/data/imx378.json +++ b/src/ipa/raspberrypi/data/imx378.json @@ -134,7 +134,7 @@ ], "gain": [ - 1.0, 2.0, 4.0, 6.0, 6.0 + 1.0, 2.0, 4.0, 6.0, 8.0 ] }, "short": @@ -145,7 +145,7 @@ ], "gain": [ - 1.0, 2.0, 4.0, 6.0, 6.0 + 1.0, 2.0, 4.0, 6.0, 8.0 ] } }, diff --git a/src/ipa/raspberrypi/data/imx477.json b/src/ipa/raspberrypi/data/imx477.json index 9bee3f16e108..d07febd283ed 100644 --- a/src/ipa/raspberrypi/data/imx477.json +++ b/src/ipa/raspberrypi/data/imx477.json @@ -137,7 +137,7 @@ ], "gain": [ - 1.0, 2.0, 4.0, 6.0, 6.0 + 1.0, 2.0, 4.0, 6.0, 8.0 ] }, "short": @@ -148,7 +148,7 @@ ], "gain": [ - 1.0, 2.0, 4.0, 6.0, 6.0 + 1.0, 2.0, 4.0, 6.0, 8.0 ] }, "long": @@ -159,7 +159,7 @@ ], "gain": [ - 1.0, 2.0, 4.0, 6.0, 6.0 + 1.0, 2.0, 4.0, 6.0, 12.0 ] } }, diff --git a/src/ipa/raspberrypi/data/imx477_noir.json b/src/ipa/raspberrypi/data/imx477_noir.json index 290e8264bba9..7d4fc7dab9fd 100644 --- a/src/ipa/raspberrypi/data/imx477_noir.json +++ b/src/ipa/raspberrypi/data/imx477_noir.json @@ -69,7 +69,7 @@ ], "gain": [ - 1.0, 2.0, 4.0, 6.0, 6.0 + 1.0, 2.0, 4.0, 6.0, 8.0 ] }, "short": @@ -80,7 +80,7 @@ ], "gain": [ - 1.0, 2.0, 4.0, 6.0, 6.0 + 1.0, 2.0, 4.0, 6.0, 8.0 ] }, "long": @@ -91,7 +91,7 @@ ], "gain": [ - 1.0, 2.0, 4.0, 6.0, 6.0 + 1.0, 2.0, 4.0, 6.0, 12.0 ] } }, diff --git a/src/ipa/raspberrypi/data/imx519.json b/src/ipa/raspberrypi/data/imx519.json index 164d0d9d1b79..2ce6a08c029d 100644 --- a/src/ipa/raspberrypi/data/imx519.json +++ b/src/ipa/raspberrypi/data/imx519.json @@ -134,7 +134,7 @@ ], "gain": [ - 1.0, 2.0, 4.0, 6.0, 6.0 + 1.0, 2.0, 4.0, 6.0, 8.0 ] }, "short": @@ -145,7 +145,7 @@ ], "gain": [ - 1.0, 2.0, 4.0, 6.0, 6.0 + 1.0, 2.0, 4.0, 6.0, 8.0 ] } }, diff --git a/src/ipa/raspberrypi/data/ov5647.json b/src/ipa/raspberrypi/data/ov5647.json index 1a354f7cb036..24bc06fb6114 100644 --- a/src/ipa/raspberrypi/data/ov5647.json +++ b/src/ipa/raspberrypi/data/ov5647.json @@ -137,7 +137,7 @@ ], "gain": [ - 1.0, 2.0, 4.0, 6.0, 6.0 + 1.0, 2.0, 4.0, 6.0, 8.0 ] }, "short": @@ -148,7 +148,7 @@ ], "gain": [ - 1.0, 2.0, 4.0, 6.0, 6.0 + 1.0, 2.0, 4.0, 6.0, 8.0 ] }, "long": @@ -159,7 +159,7 @@ ], "gain": [ - 1.0, 2.0, 4.0, 6.0, 6.0 + 1.0, 2.0, 4.0, 6.0, 12.0 ] } }, diff --git a/src/ipa/raspberrypi/data/ov5647_noir.json b/src/ipa/raspberrypi/data/ov5647_noir.json index c4bb21a0f34e..1c628ed13f19 100644 --- a/src/ipa/raspberrypi/data/ov5647_noir.json +++ b/src/ipa/raspberrypi/data/ov5647_noir.json @@ -69,7 +69,7 @@ ], "gain": [ - 1.0, 2.0, 4.0, 6.0, 6.0 + 1.0, 2.0, 4.0, 6.0, 8.0 ] }, "short": @@ -80,7 +80,7 @@ ], "gain": [ - 1.0, 2.0, 4.0, 6.0, 6.0 + 1.0, 2.0, 4.0, 6.0, 8.0 ] }, "long": @@ -91,7 +91,7 @@ ], "gain": [ - 1.0, 2.0, 4.0, 6.0, 6.0 + 1.0, 2.0, 4.0, 6.0, 12.0 ] } }, diff --git a/src/ipa/raspberrypi/data/ov9281.json b/src/ipa/raspberrypi/data/ov9281.json index ecd262be12ad..2319448b1593 100644 --- a/src/ipa/raspberrypi/data/ov9281.json +++ b/src/ipa/raspberrypi/data/ov9281.json @@ -32,7 +32,7 @@ "normal": { "shutter": [ 100, 15000, 30000, 60000, 120000 ], - "gain": [ 1.0, 2.0, 3.0, 4.0, 6.0 ] + "gain": [ 1.0, 2.0, 3.0, 4.0, 8.0 ] } }, "constraint_modes": diff --git a/src/ipa/raspberrypi/data/se327m12.json b/src/ipa/raspberrypi/data/se327m12.json index 3245ed98c1b1..94af2239f700 100644 --- a/src/ipa/raspberrypi/data/se327m12.json +++ b/src/ipa/raspberrypi/data/se327m12.json @@ -134,7 +134,7 @@ ], "gain": [ - 1.0, 2.0, 4.0, 6.0, 6.0 + 1.0, 2.0, 4.0, 6.0, 8.0 ] }, "short": @@ -145,7 +145,7 @@ ], "gain": [ - 1.0, 2.0, 4.0, 6.0, 6.0 + 1.0, 2.0, 4.0, 6.0, 8.0 ] } },