{"id":16674,"url":"https://patchwork.libcamera.org/api/1.1/patches/16674/?format=json","web_url":"https://patchwork.libcamera.org/patch/16674/","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":"<20220718081602.32535-8-naush@raspberrypi.com>","date":"2022-07-18T08:16:01","name":"[libcamera-devel,v6,7/8] utils: raspberrypi: Add tuning file conversion script","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"325ebf5beea691df31b2eb13dbfd979d4f452be2","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/1.1/people/34/?format=json","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/16674/mbox/","series":[{"id":3293,"url":"https://patchwork.libcamera.org/api/1.1/series/3293/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3293","date":"2022-07-18T08:15:54","name":"Replace boost JSON parser with libyaml in Raspberry Pi IPA","version":6,"mbox":"https://patchwork.libcamera.org/series/3293/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/16674/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/16674/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 5DD41BD1F1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 18 Jul 2022 08:16:16 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 209736331D;\n\tMon, 18 Jul 2022 10:16:16 +0200 (CEST)","from mail-wr1-x435.google.com (mail-wr1-x435.google.com\n\t[IPv6:2a00:1450:4864:20::435])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 49B036331F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 18 Jul 2022 10:16:12 +0200 (CEST)","by mail-wr1-x435.google.com with SMTP id r14so15920769wrg.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 18 Jul 2022 01:16:12 -0700 (PDT)","from naush-laptop.localdomain ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\ta15-20020adffb8f000000b0021dbac444a7sm10206795wrr.59.2022.07.18.01.16.10\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 18 Jul 2022 01:16:10 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1658132176;\n\tbh=IAXD9sHyO9ZNDqqutgWImcwfBQh84KpJJvIMaEvBlRk=;\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=D23VEfa0x4AArzg2CHUF1GZ+9cJW5R6vIBgkvkpbTw/DzuSkJlc6LLq7XLM6zIdFx\n\tbLnhA4XlrEZtunl5Zrgn83x5qRFUZ5cRo+y23wxo036MW5YSY9sVHFXd3pCUJm0/r3\n\tYQOkccv/DmeAYtenAqULJxkh9MpbRJUORjCK02Pvp3Czqdgbz3cq6jAJKa+RuT7QR/\n\tEWzsRavqNc2RyMQWZnyBQDvr/3tlAlF2gXmFQUYppfSu+HSGktgptirTn7MMRtXavm\n\t2FEbKK8nzxaT769EboPQ/aL3BjC6jROzWk+ikZVUg61R4ITHN/xPPOHKWNrvRu6MmE\n\tN5X8BCMEkfwUA==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=4QC2vWlF9fBEbUJSEJBWZir/FMVn4k4Vc2vCGcsByeQ=;\n\tb=pNi2bBkkBJloaG+OuAhsFxWZju3PRw0N54pr/asAg2mrzxpUFwUZ/PpF2CQrPJ5YHq\n\tzl16a7GdD6XAJx9sxn1p2prrgP+YZfa0AIlC9AY9vgxy//rQCqmByKmZsPSepiVIZ7jT\n\tIie+sFnZ/u70eixGyslvNMGx24jFtvqbKYrRztr/Z+G7tDjsPJw1cNq8E/tww33lyliQ\n\tcRA4l+ZBODsStJq2DlQt7GDVlgl+HMxTy5hHNw/y9Bp9g+eMn81fojyi/eZXQUsa+Zyz\n\tnyCntDpGCdbgd6K4QM8URSfl2Yu/r603t4cPjVwBXOCTZSblEXg/r4ce/WrWMI0Z1FXS\n\tmJZg=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"pNi2bBkk\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=4QC2vWlF9fBEbUJSEJBWZir/FMVn4k4Vc2vCGcsByeQ=;\n\tb=cU8TV0l2rqV5zcseC3Nn/mJwINKOcxD4019D6jFGs11NZg55cnX63T+lrUNhlgo87W\n\t9H2R+ClVPdz38E/rfQYx0p+kvXNamCkihYprZ5QTMzYdSfmjeWp9kuSXWRsXcp2GWwkg\n\td/r2J/cfCqv2DvdYPW1iVJwhYYsN6FdEnkAnJxLqf2TtnRmOPKhCopaWK1vMnDmAPDOa\n\tVvmSNGPx7yB48KMdN/rj0ggS+Wd2dqyKLLCbAP+pxJwE/rdjWCXN6ttXQ8detkIRBUaX\n\tnPORKYwU1BciIOoXl+Uz5RbEwG66NrQhRkdptKGUg8KqdXEBQt/KX+rQMSls3MwD3JbA\n\t7r0w==","X-Gm-Message-State":"AJIora96DH2eYNuffhnpSOlMuvqsSrfueqyJGzgAaP+5EKe3C3l2aqhh\n\tNdFraX8nLcYACHxyrT8H2kNYHOx4kL210g==","X-Google-Smtp-Source":"AGRyM1shZ6eO/6v/MS/p3OZCekUt0D/OWXTlNN44IZh7SDzULE09B6g2d/rGhsI7tn1OheZBz+kzQw==","X-Received":"by 2002:a05:6000:1e04:b0:21d:7ec3:fe5a with SMTP id\n\tbj4-20020a0560001e0400b0021d7ec3fe5amr22153639wrb.116.1658132171504; \n\tMon, 18 Jul 2022 01:16:11 -0700 (PDT)","To":"libcamera-devel@lists.libcamera.org","Date":"Mon, 18 Jul 2022 09:16:01 +0100","Message-Id":"<20220718081602.32535-8-naush@raspberrypi.com>","X-Mailer":"git-send-email 2.25.1","In-Reply-To":"<20220718081602.32535-1-naush@raspberrypi.com>","References":"<20220718081602.32535-1-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v6 7/8] 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":"Naushir Patuck via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Naushir Patuck <naush@raspberrypi.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Add 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>\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","v6","7/8"]}