{"id":16823,"url":"https://patchwork.libcamera.org/api/1.1/patches/16823/?format=json","web_url":"https://patchwork.libcamera.org/patch/16823/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20220727023816.30008-12-laurent.pinchart@ideasonboard.com>","date":"2022-07-27T02:38:13","name":"[libcamera-devel,v7,11/14] utils: raspberrypi: Add tuning file conversion script","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"325ebf5beea691df31b2eb13dbfd979d4f452be2","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/1.1/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/16823/mbox/","series":[{"id":3331,"url":"https://patchwork.libcamera.org/api/1.1/series/3331/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3331","date":"2022-07-27T02:38:02","name":"Replace boost JSON parser with libyaml in Raspberry Pi IPA","version":7,"mbox":"https://patchwork.libcamera.org/series/3331/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/16823/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/16823/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 E4409C3275\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 27 Jul 2022 02:38:37 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A149263338;\n\tWed, 27 Jul 2022 04:38:37 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0BC5C63316\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 27 Jul 2022 04:38:31 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 9A8BB56D;\n\tWed, 27 Jul 2022 04:38:30 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1658889517;\n\tbh=cZ8ZW3TILG8iG0Q7OpVXjjnpdnp8LxUDS3KQLfUofXA=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=lrzinnu7OnH7mI9D9vN6azatlTjTfNu5FdT3l1LDGPfmGND+le+/tdnvD2rWizjV5\n\tgWyJDG/Rfa9m6oBmUyvaWqTCSpVJSI3g01P6adYZ6mTQAmX77G2eiUp1fg1rhehhPZ\n\tg8uOczsCy4wwjhLtIgpZM8hlJBuHg0oUVQmEzOLbYsC7726KfWdUl2tf9EAqrnKzcp\n\tOPfVis+sN+MUGQjo5uH7lY/anX1ls4TkiHwklsiV3j4P9gaI+Tw1Pg2jAjcOtvcb2f\n\t2STH6XKSR50WgVyaGNwKmsuk8if2nGF5EZp8TWatDMkVil4be+NSPKI18PdskOq41r\n\tRf+t/okE5s7jA==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1658889510;\n\tbh=cZ8ZW3TILG8iG0Q7OpVXjjnpdnp8LxUDS3KQLfUofXA=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=lOku6J9YfCugly9Gn73vA5dpUvtAfQg4CM9kD1yMebJO9SM+tuH7s4SkIL5V1oKJR\n\t3C0mtSRuwNCBNSjKvZyff8VC+Qjk+kkmW7hSHnZzlDq6XSz/prmbcjE2Dl7xgvNmXt\n\tvSRn/zrye4Ut8brKM7vU3vjWT8B2NdrkJPzPwgQk="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"lOku6J9Y\"; dkim-atps=neutral","To":"libcamera-devel@lists.libcamera.org","Date":"Wed, 27 Jul 2022 05:38:13 +0300","Message-Id":"<20220727023816.30008-12-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.35.1","In-Reply-To":"<20220727023816.30008-1-laurent.pinchart@ideasonboard.com>","References":"<20220727023816.30008-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v7 11/14] utils: raspberrypi: Add tuning\n\tfile conversion script","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>","From":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"From: Naushir Patuck <naush@raspberrypi.com>\n\nAdd a script to convert the Raspberry Pi camera tuning file format from version\n1.0 to 2.0. This script also adds a root level version key set to 2.0 to the\nconfig file, allowing the controller to distinguish between the two formats.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n utils/raspberrypi/ctt/convert_tuning.py | 46 +++++++++++++++++++++++++\n 1 file changed, 46 insertions(+)\n create mode 100755 utils/raspberrypi/ctt/convert_tuning.py","diff":"diff --git a/utils/raspberrypi/ctt/convert_tuning.py b/utils/raspberrypi/ctt/convert_tuning.py\nnew file mode 100755\nindex 000000000000..a84dfa83b3b6\n--- /dev/null\n+++ b/utils/raspberrypi/ctt/convert_tuning.py\n@@ -0,0 +1,46 @@\n+#!/usr/bin/env python3\n+#\n+# SPDX-License-Identifier: BSD-2-Clause\n+#\n+# Script to convert version 1.0 Raspberry Pi camera tuning files to version 2.0.\n+#\n+# Copyright 2022 Raspberry Pi Ltd.\n+\n+import argparse\n+import json\n+import sys\n+\n+from ctt_pretty_print_json import pretty_print\n+\n+\n+def convert_v2(in_json: dict) -> str:\n+\n+    if 'version' in in_json.keys() and in_json['version'] != 1.0:\n+        print(f'The JSON config reports version {in_json[\"version\"]} that is incompatible with this tool.')\n+        sys.exit(-1)\n+\n+    converted = {\n+        'version': 2.0,\n+        'target': 'bcm2835',\n+        'algorithms': [{algo: config} for algo, config in in_json.items()]\n+    }\n+\n+    return pretty_print(converted)\n+\n+\n+if __name__ == \"__main__\":\n+    parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter, description=\n+                    'Convert the format of the Raspberry Pi camera tuning file from v1.0 to v2.0.\\n')\n+    parser.add_argument('input', type=str, help='Input tuning file.')\n+    parser.add_argument('output', type=str, nargs='?',\n+                        help='Output converted tuning file. If not provided, the input file will be updated in-place.',\n+                        default=None)\n+    args = parser.parse_args()\n+\n+    with open(args.input, 'r') as f:\n+        in_json = json.load(f)\n+\n+    out_json = convert_v2(in_json)\n+\n+    with open(args.output if args.output is not None else args.input, 'w') as f:\n+        f.write(out_json)\n","prefixes":["libcamera-devel","v7","11/14"]}