Patch Detail
Show a patch.
GET /api/1.1/patches/19857/?format=api
{ "id": 19857, "url": "https://patchwork.libcamera.org/api/1.1/patches/19857/?format=api", "web_url": "https://patchwork.libcamera.org/patch/19857/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20240405145335.3010479-2-paul.elder@ideasonboard.com>", "date": "2024-04-05T14:53:31", "name": "[1/5] utils: libtuning: modules: Add skeletal AGC module", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "8100c051879751910d15efba74b760f78b9a2c31", "submitter": { "id": 17, "url": "https://patchwork.libcamera.org/api/1.1/people/17/?format=api", "name": "Paul Elder", "email": "paul.elder@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/19857/mbox/", "series": [ { "id": 4252, "url": "https://patchwork.libcamera.org/api/1.1/series/4252/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4252", "date": "2024-04-05T14:53:30", "name": "utils: tuning: Add AGC and CCM", "version": 1, "mbox": "https://patchwork.libcamera.org/series/4252/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/19857/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/19857/checks/", "tags": {}, "headers": { "Return-Path": "<libcamera-devel-bounces@lists.libcamera.org>", "X-Original-To": "parsemail@patchwork.libcamera.org", "Delivered-To": "parsemail@patchwork.libcamera.org", "Received": [ "from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id E118DC327C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 5 Apr 2024 14:53:52 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 44D4F62CA0;\n\tFri, 5 Apr 2024 16:53:52 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4278861C29\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 5 Apr 2024 16:53:49 +0200 (CEST)", "from pyrite.hamster-moth.ts.net (h175-177-049-156.catv02.itscom.jp\n\t[175.177.49.156])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 089FF63B;\n\tFri, 5 Apr 2024 16:53:08 +0200 (CEST)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"u/hEg3kf\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1712328790;\n\tbh=wRvj0fENpOcfdEYdu2NUvHfY8LUN4SxWsF8AkRYpPxc=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=u/hEg3kfunNbAS8Xo6ffsz3g0XxmU2T7n3sEQfYAT+XVM/nEhhZrcfeijfd2sachX\n\ty7VPc2EwGdYbVUoHXhns/BLXils2ioSUPgSWZJFJeTZMNszQFMkIzilyDPKvJ7zJXu\n\tiAvFVOgeZ4jlRDEJkUFjvOo9/3xy9YWJLHvFVRJw=", "From": "Paul Elder <paul.elder@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "Paul Elder <paul.elder@ideasonboard.com>", "Subject": "[PATCH 1/5] utils: libtuning: modules: Add skeletal AGC module", "Date": "Fri, 5 Apr 2024 23:53:31 +0900", "Message-Id": "<20240405145335.3010479-2-paul.elder@ideasonboard.com>", "X-Mailer": "git-send-email 2.39.2", "In-Reply-To": "<20240405145335.3010479-1-paul.elder@ideasonboard.com>", "References": "<20240405145335.3010479-1-paul.elder@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "X-BeenThere": "libcamera-devel@lists.libcamera.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "<libcamera-devel.lists.libcamera.org>", "List-Unsubscribe": "<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>", "List-Archive": "<https://lists.libcamera.org/pipermail/libcamera-devel/>", "List-Post": "<mailto:libcamera-devel@lists.libcamera.org>", "List-Help": "<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>", "List-Subscribe": "<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "Add a skeletal AGC module just so that we can have some AGC tuning\nvalues that we can use to test during development of AGC in the IPAs. As\nrkisp1 is the main target, we only add support for rkisp1 for now.\n\nThe parameters are mostly copied from the hardcoded values in ctt,\nexcept for the metering modes.\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\n---\n .../tuning/libtuning/modules/agc/__init__.py | 6 ++\n utils/tuning/libtuning/modules/agc/agc.py | 24 +++++\n utils/tuning/libtuning/modules/agc/rkisp1.py | 95 +++++++++++++++++++\n 3 files changed, 125 insertions(+)\n create mode 100644 utils/tuning/libtuning/modules/agc/__init__.py\n create mode 100644 utils/tuning/libtuning/modules/agc/agc.py\n create mode 100644 utils/tuning/libtuning/modules/agc/rkisp1.py", "diff": "diff --git a/utils/tuning/libtuning/modules/agc/__init__.py b/utils/tuning/libtuning/modules/agc/__init__.py\nnew file mode 100644\nindex 00000000..4db9ca37\n--- /dev/null\n+++ b/utils/tuning/libtuning/modules/agc/__init__.py\n@@ -0,0 +1,6 @@\n+# SPDX-License-Identifier: GPL-2.0-or-later\n+#\n+# Copyright (C) 2024, Paul Elder <paul.elder@ideasonboard.com>\n+\n+from libtuning.modules.agc.agc import AGC\n+from libtuning.modules.agc.rkisp1 import AGCRkISP1\ndiff --git a/utils/tuning/libtuning/modules/agc/agc.py b/utils/tuning/libtuning/modules/agc/agc.py\nnew file mode 100644\nindex 00000000..5f3c4223\n--- /dev/null\n+++ b/utils/tuning/libtuning/modules/agc/agc.py\n@@ -0,0 +1,24 @@\n+# SPDX-License-Identifier: BSD-2-Clause\n+#\n+# Copyright (C) 2019, Raspberry Pi Ltd\n+# Copyright (C) 2024, Paul Elder <paul.elder@ideasonboard.com>\n+\n+from ..module import Module\n+\n+import libtuning as lt\n+import libtuning.utils as utils\n+\n+import numpy as np\n+\n+\n+class AGC(Module):\n+ type = 'agc'\n+ hr_name = 'AGC (Base)'\n+ out_name = 'GenericAGC'\n+\n+ # \\todo Add sector shapes and stuff just like lsc\n+ def __init__(self, *,\n+ debug: list):\n+ super().__init__()\n+\n+ self.debug = debug\ndiff --git a/utils/tuning/libtuning/modules/agc/rkisp1.py b/utils/tuning/libtuning/modules/agc/rkisp1.py\nnew file mode 100644\nindex 00000000..b683fecb\n--- /dev/null\n+++ b/utils/tuning/libtuning/modules/agc/rkisp1.py\n@@ -0,0 +1,95 @@\n+# SPDX-License-Identifier: BSD-2-Clause\n+#\n+# Copyright (C) 2019, Raspberry Pi Ltd\n+# Copyright (C) 2024, Paul Elder <paul.elder@ideasonboard.com>\n+#\n+# rkisp1.py - AGC module for tuning rkisp1\n+\n+from .agc import AGC\n+\n+import libtuning as lt\n+import libtuning.utils as utils\n+\n+from numbers import Number\n+import numpy as np\n+\n+\n+class AGCRkISP1(AGC):\n+ hr_name = 'AGC (RkISP1)'\n+ out_name = 'Agc'\n+ # \\todo Not sure if this is useful. Probably will remove later.\n+ compatible = ['rkisp1']\n+\n+ def __init__(self, *,\n+ hw_rev: lt.Param,\n+ **kwargs):\n+ super().__init__(**kwargs)\n+\n+ # Basically everything besides V12 uses V10 so we'll just implement it\n+ # as an exception for V12\n+ self.hist_weights_grid_size = (5, 5)\n+ if hw_rev == 'V12':\n+ self.hist_weights_grid_size = (9, 9)\n+\n+ # We don't actually need anything from the config file\n+ def validate_config(self, config: dict) -> bool:\n+ return True\n+\n+ def _generate_metering_modes(self) -> dict:\n+ # \\todo Implement support for V12\n+ centre_weighted = [\n+ 0, 0, 0, 0, 0,\n+ 0, 6, 8, 6, 0,\n+ 0, 8, 16, 8, 0,\n+ 0, 6, 8, 6, 0,\n+ 0, 0, 0, 0, 0\n+ ]\n+\n+ spot = [\n+ 0, 0, 0, 0, 0,\n+ 0, 2, 4, 2, 0,\n+ 0, 4, 16, 4, 0,\n+ 0, 2, 4, 2, 0,\n+ 0, 0, 0, 0, 0\n+ ]\n+\n+ num_cells = self.hist_weights_grid_size[0] * self.hist_weights_grid_size[1]\n+ matrix = [1 for i in range(0, num_cells)]\n+\n+ return {\n+ 'MeteringCentreWeighted': centre_weighted,\n+ 'MeteringSpot': spot,\n+ 'MeteringMatrix': matrix\n+ }\n+\n+ def _generate_exposure_modes(self) -> dict:\n+ normal = { 'shutter': [100, 10000, 30000, 60000, 120000],\n+ 'gain': [1.0, 2.0, 4.0, 6.0, 6.0] }\n+ short = { 'shutter': [100, 5000, 10000, 20000, 120000],\n+ 'gain': [1.0, 2.0, 4.0, 6.0, 6.0]}\n+\n+ return { 'ExposureNormal': normal, 'ExposureShort': short }\n+\n+ def _generate_constraint_modes(self) -> dict:\n+ normal = { 'lower': { 'qLo': 0.98, 'qHi': 1.0, 'yTarget': [ 0, 0.5, 1000, 0.5 ] } }\n+ highlight = {\n+ 'lower': { 'qLo': 0.98, 'qHi': 1.0, 'yTarget': [ 0, 0.5, 1000, 0.5 ] },\n+ 'upper': { 'qLo': 0.98, 'qHi': 1.0, 'yTarget': [ 0, 0.8, 1000, 0.5 ] }\n+ }\n+\n+ return { 'ConstraintNormal': normal, 'ConstraintHighlight': highlight }\n+\n+ def _generate_y_target(self) -> list:\n+ return [0, 0.16, 1000, 0.165, 10000, 0.17]\n+\n+ def process(self, config: dict, images: list, outputs: dict) -> dict:\n+ output = {}\n+\n+ output['AeMeteringMode'] = self._generate_metering_modes()\n+ output['AeExposureMode'] = self._generate_exposure_modes()\n+ output['AeConstraintMode'] = self._generate_constraint_modes()\n+ output['relativeLuminanceTarget'] = self._generate_y_target()\n+\n+ # \\todo Debug functionality\n+\n+ return output\n", "prefixes": [ "1/5" ] }