From patchwork Fri Sep 2 12:08:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17273 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 ACD5CC0DA4 for ; Fri, 2 Sep 2022 12:08:18 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id F01F361FE1; Fri, 2 Sep 2022 14:08:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1662120498; bh=sHi8aZz3YXKmLxjh3OqAnmD4nhOaI14BlruJr0I0ntY=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=ODv5zaS86IkjyAgYFEJMAvydF5vLlVKRPSzkMCAUEf1i1kp2FsjvA1QsgoHULxCcA BF/FSzDly5dBAsHZYC4+9gqTdyuH84XOa+1rSjzqZOUz+HLrftb9NPDch+D/4Yd2M1 w1bYoCFeFqGsOlMZa9l/QD0ZDpYoqfijlx6+DAv84ZreIt3os9JorCoC8hj2yK5ixi deC82VsdquHLmVb40rLJwz81Wjkqq8nj5AfeXuLVhOdQeGdk+guJlg/3t5/HYYEmRa fxeaDPcG8jB99nW9GNZHEr9ftVPJTpNng/WJiGR7XT+yrGAN3Qc50uu9ameWFCq4Uf bNO+de6S2efGQ== Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0449F603E1 for ; Fri, 2 Sep 2022 14:08:15 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="pgK7lTSW"; dkim-atps=neutral Received: by mail-wm1-x335.google.com with SMTP id bd26-20020a05600c1f1a00b003a5e82a6474so1285846wmb.4 for ; Fri, 02 Sep 2022 05:08:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date; bh=T8GPIOxc//1yT8fMqVO0yVQusAzxt1IN5nyvtIQFuA4=; b=pgK7lTSW9SB0+//Xqg8bvwVWnClrKnDlDjrwW4mJpm19U10iAsF2zA97kfgM8rg3BG 7EauLZ8lSqxDXiOiEpMCJ7XnDaCA48v1K7XNiMje3Z/8ZUfDsA4ot++440s2dsB40j/S A1egFxhdoY8xOoV0N9MSk04cbCnfCyNqn5FFclwaHpgoLSh7OojN/WSTgJpSZHKBsN+8 4qHK4G3bSZVBZo63h6eJO5AZphnvrSGTDfyWNQlV9tuClZ6w1gkEoXmDqHmM4bwM6lvO F/wwdR7k0kkRAwKmgMdqL8pgmGNvWA7M8IsaQeI72BJX+Rk4q4TpMMD7qLJVKa+WeUmf MX5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=T8GPIOxc//1yT8fMqVO0yVQusAzxt1IN5nyvtIQFuA4=; b=6JQ4DQ3q4zMl0drdQVrqWmraETp/lWKxLtIXMox7qHgF95pMKJ7GcWnXXS9c6gvbsu B08zVhpH/ly635suFLIYFRcEI1MzBN1Jt+Fe1B8zBeoXBsT5lKFN1kA7y4uUkpKOeaQe 7wPyzlhUGYEZ/OQrh0tzBS1e4OgQa6bXFGWBZdDW5tiI6tRoTLNLapt3UrbunU0tlpuv klfQ9uuR2f802CraHD/FtkUCbZ1uaJztejncbhWBuvLtwSdDJMqizIKDmMk9i7cqgNZP yDCD4RTXrngGZOnxVS41vk1T8MpIRuDay0pJN/NOK9Zl1SjSBpE4mH+qb46NEqrX38S7 LtIA== X-Gm-Message-State: ACgBeo2EQVh2SqRglQOpmAT/WVqoGrIzVkpC4N+BTdPKHkXYflzCx+0/ iL4v6ZdDBWYS4GJmFq+jEXtaAP8XzwdoRUrb X-Google-Smtp-Source: AA6agR4gqw2ue93btV4Q98OVVOuSDTB9uVgHkXcSa8wWdKgnBv2c9iB3eh9502qXxTJ8SkgfViDY9g== X-Received: by 2002:a05:600c:3d93:b0:3a6:1ac3:adf8 with SMTP id bi19-20020a05600c3d9300b003a61ac3adf8mr2525139wmb.125.1662120495234; Fri, 02 Sep 2022 05:08:15 -0700 (PDT) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id h2-20020a5d4302000000b0021e51c039c5sm1397809wrq.80.2022.09.02.05.08.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Sep 2022 05:08:14 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 2 Sep 2022 13:08:02 +0100 Message-Id: <20220902120808.842-1-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 0/6] Raspberry Pi AGC digial gain fixes 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: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Hi, This patch series fixes a long standing problem with our AGC where when using manual controls, the digital gain applied to the frame is not calculated correctly. The reason for this is that the AGC needs to know the state of the algorithm when it sent the manual shutter/gain to the sensor, and not use the state information when the frame eventually turns up. This series fixes the issue by having the IPA maintain an array of RPiController::Metadata objects that get cycled through every frame. So historical metadata objects that hold the algorithm state are available to inspect when needed. This is a bit similar to the ongoing work that is going on for IPA frame context queues. Patches 1, 2, 3 update DelayedControls to take and return a user cookie when setting a ControlList. Patches 4 and 5 pass the context index between the pipeline handler and IPA. Patch 6 uses the historical AGC state to correctly calculate the digital gain. Thanks, Naush Naushir Patuck (6): delayed_controls: Template the ControlRingBuffer class delayed_controls: Add user cookie to DelayedControls tests: delayed_controls: Add cookie value test ipa: raspberrypi: Use an array of RPiController::Metadata objects pipeline: ipa: raspberrypi: Use IPA cookies ipa: raspberrypi: agc: Fix digital gain calculation for manual mode include/libcamera/internal/delayed_controls.h | 21 +++-- include/libcamera/ipa/raspberrypi.mojom | 3 +- src/ipa/raspberrypi/controller/rpi/agc.cpp | 10 ++- src/ipa/raspberrypi/raspberrypi.cpp | 82 ++++++++++++------- src/libcamera/delayed_controls.cpp | 17 ++-- src/libcamera/pipeline/ipu3/ipu3.cpp | 3 +- .../pipeline/raspberrypi/raspberrypi.cpp | 12 +-- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 3 +- test/delayed_controls.cpp | 52 +++++++++++- 9 files changed, 144 insertions(+), 59 deletions(-)