From patchwork Mon Jul 31 09:46:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 18904 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 D2E2EBDB13 for ; Mon, 31 Jul 2023 09:46:47 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A25BB627E8; Mon, 31 Jul 2023 11:46:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1690796806; bh=NoN0ho+Ywmc6vgWzPoPbK8wyDVmRzI+9p10pwvXmdfQ=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=VedjYM6+DDc8J1A9QIpPEPp9MZM7Ur7qUutZRMXMvEKDN0fusOn4ns4LWEARtCdsH L8ky1CV+3OBUC9U3cCf1VTCn8qI3nCxdVE86qwtRCtCPMr6k1GxceMzCBqf1TIrbFd lYP0Td++lWyZiaqoLNYbZFBO2BO52CBO9yK/VJcjc304QZgMe9hWAemxtI0JSUtvED 866hdtOqvc5jI7SAo7I48rUiGbTrLlkvQeyyP4oi4snyZtHxyD6iHWfHHNJca2EMPu NU5xyI3e+vsmtu5kcFThsVf8Mik5bj2YI/j5V4WVj6rR3RVzVLJiNJPFuh+caysyBG Gbb31ihGt1f4w== Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 11DD36037D for ; Mon, 31 Jul 2023 11:46:45 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="BL352t15"; dkim-atps=neutral Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-3fbf1b82d9cso39673925e9.2 for ; Mon, 31 Jul 2023 02:46:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1690796804; x=1691401604; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=HKCWqZVi/sSP3gjL3skd6CV6Q/ckTQR7IbUgKxVx/s0=; b=BL352t15lsMGpLzB3lMCmHk4EkG7h+vhgUem6608iwjMMRqkqbm1RKuLeAB7k7Sh6l OejzPYsWWIbN74x2OKZA/fB/AEMMc8KsmVg895rvodb1Nh1dtVrunnU2ASw45o0aXuTI zUVPZzq0T0a15HR7rbUHXou3JuKFInnF0xumGUCmNIWjaoRk+x3Dz+KelWuqoSdZF5HW ULg8Mi6fCMn25IpaImnQ2zC0NEIYdHYRssXPmq9tecOdpyNbK94/z0+ICdlhbfDNsCzG dgozSlcLuKKX9QVCs1y5iSYDFbEBmemdP6nSQi4pBCyyn6oVjhMgn7yFwmmHs9iVsWCL EZog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690796804; x=1691401604; 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=HKCWqZVi/sSP3gjL3skd6CV6Q/ckTQR7IbUgKxVx/s0=; b=KE9bDxC3NoXFdEa8kuVhBkxhF4sOd9bcnyO3UqhfcEgK8ozSXaROt4vGiaAMwPGui9 UGktFu5Dck/QB+dtW9iS3TkP95+jvhWy8m9M6l812H7WLJWcR/Pgjd/owLfx5XljFu+j D2C4Esi34kt0+/GD/DDAs8/e+9AFMgBmPlLDMbkdQLjfZc/mqaPIGwH5UAbsqAJH1kee Pokztv/t9savWVvnDdPU0MO13qRo7NlywSYOqHWpjcJm+BEiQJmbgHEPrNdrktAwttaS klQmF5I9fwdI9joAvLaPBKfjWYy9zVVxQ42ygNezCVXjWp3iqVN5z1Ew4CfUz/0oyR6P a2cg== X-Gm-Message-State: ABy/qLa3K0XxjHRzWA+X22wNfeY9dHJhMVihzI1528mK0rjyHs+0aFW+ Ws76qMATthyb3H6BpU0Qc6pqNfb3uCKw49azgvg= X-Google-Smtp-Source: APBJJlFIEqi5LIPX0n3oDP6ll1QfQ8V31xtay881rxRMJU94jInvtGd3ZcjlMf5Rbxv91P2zRbyxgw== X-Received: by 2002:a05:600c:230b:b0:3fc:e00:5282 with SMTP id 11-20020a05600c230b00b003fc0e005282mr6425988wmo.0.1690796804243; Mon, 31 Jul 2023 02:46:44 -0700 (PDT) Received: from pi4-davidp.pitowers.org ([2a00:1098:3142:14:2bce:64d6:1a5c:49a2]) by smtp.gmail.com with ESMTPSA id 9-20020a05600c240900b003fa98908014sm13612838wmp.8.2023.07.31.02.46.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jul 2023 02:46:43 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Mon, 31 Jul 2023 10:46:36 +0100 Message-Id: <20230731094641.73646-1-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 0/5] Multi-channel AGC 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" Hi everyone This set of patches implements multi-channel AGC for the Raspberry Pi. This allows an application to run independent instances of AGC on successive frames with independent settings, and switching between the exposures gets handled for the application. It's a building block for HDR type of applications (though not limited to that). We have 5 patches: 1. I seem to have built on top of some future work that Naush has been doing, so I've included a small histogram patch of his that is required. 2. This moves essentially all of the Agc class into an AgcChannel class, and adds a new Agc class that is a thin wrapper around multiple AgcChannels. The wrapper is sufficient only to make the AGC work as before, and does not yet add anything new. 3. Now we add real multi-channel functionality to the Agc class. For now there are no libcamera controls to drive it, but a future commit will add an HDR algorithm that will use it. 4. Adds an AgcChannelConstraint class. Now that we have multiple channels, we might want to constrain the exposures of one channel to lie within certain limits of another. Here we add only the class; the next commit will make use of them. 5. Make use of the AgcChannelConstraints. As implied above, this work is all preparatory to some HDR features in a future commit. The Pi, of course, has no facility to combine images automatically, so "HDR" on the Pi will be all about driving the multi-channel AGC and letting the application handle the images itself. Thanks! David David Plowman (4): ipa: rpi: agc: Reorganise code for multi-channel AGC ipa: rpi: agc: Implementation of multi-channel AGC ipa: rpi: agc: Add AgcChannelConstraint class ipa: rpi: agc: Use channel constraints in the AGC algorithm Naushir Patuck (1): ipa: rpi: histogram: Add interBinMean() src/ipa/rpi/common/ipa_base.cpp | 14 +- src/ipa/rpi/controller/agc_algorithm.h | 19 +- src/ipa/rpi/controller/agc_status.h | 1 + src/ipa/rpi/controller/histogram.cpp | 22 +- src/ipa/rpi/controller/histogram.h | 2 + src/ipa/rpi/controller/meson.build | 1 + src/ipa/rpi/controller/rpi/agc.cpp | 969 ++++--------------- src/ipa/rpi/controller/rpi/agc.h | 124 +-- src/ipa/rpi/controller/rpi/agc_channel.cpp | 1018 ++++++++++++++++++++ src/ipa/rpi/controller/rpi/agc_channel.h | 149 +++ src/ipa/rpi/vc4/data/imx477.json | 3 +- 11 files changed, 1424 insertions(+), 898 deletions(-) create mode 100644 src/ipa/rpi/controller/rpi/agc_channel.cpp create mode 100644 src/ipa/rpi/controller/rpi/agc_channel.h