[{"id":24213,"web_url":"https://patchwork.libcamera.org/comment/24213/","msgid":"<CAEmqJPrgrDryobHOaJ_QiHby+6PGbEvZ2pd3m41gPDziJ2b_Ew@mail.gmail.com>","date":"2022-07-28T10:16:20","subject":"Re: [libcamera-devel] [PATCH v7 11/14] utils: raspberrypi: Add\n\ttuning file conversion script","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"content":"Hi Laurent,\n\n\nOn Wed, 27 Jul 2022 at 03:38, Laurent Pinchart <\nlaurent.pinchart@ideasonboard.com> wrote:\n\n> From: Naushir Patuck <naush@raspberrypi.com>\n>\n> Add a script to convert the Raspberry Pi camera tuning file format from\n> version\n> 1.0 to 2.0. This script also adds a root level version key set to 2.0 to\n> the\n> config file, allowing the controller to distinguish between the two\n> formats.\n>\n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> Signed-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\n>\n> diff --git a/utils/raspberrypi/ctt/convert_tuning.py\n> b/utils/raspberrypi/ctt/convert_tuning.py\n> new file mode 100755\n> index 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\n> version 2.0.\n> +#\n> +# Copyright 2022 Raspberry Pi Ltd.\n>\n\nBefore merging, can you make a quick change here:\n\ns/Raspberry Pi Ltd./Raspberry Pi Ltd/\n\nto be consistent with the reset of our codebase.\n\nThanks,\nNaush\n\n\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\n> 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 =\n> argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter,\n> description=\n> +                    'Convert the format of the Raspberry Pi camera tuning\n> 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\n> 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,\n> 'w') as f:\n> +        f.write(out_json)\n> --\n> Regards,\n>\n> Laurent Pinchart\n>\n>","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 1C1AEC3275\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 28 Jul 2022 10:16:40 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7FC8D6330E;\n\tThu, 28 Jul 2022 12:16:39 +0200 (CEST)","from mail-lj1-x22f.google.com (mail-lj1-x22f.google.com\n\t[IPv6:2a00:1450:4864:20::22f])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1A4E26330D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 28 Jul 2022 12:16:37 +0200 (CEST)","by mail-lj1-x22f.google.com with SMTP id h12so1444238ljg.7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 28 Jul 2022 03:16:37 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1659003399;\n\tbh=7kc3/oyrilDd4LopogZolkxqpzxnktsR6DYeiCeJfo0=;\n\th=References:In-Reply-To:Date:To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=XsUp1buUYMZiKdpzYpf5qjpSOXnrx9/NWnkk9Knr1PIq3PL/8zDqXkwTsuYG8nZGA\n\tJE29yQ2467VbM+o1lcWTmtu76tfutjCNR7tb3t998htI6+3nJKPDDv9cnebVQ+7t2R\n\txtpwQibb6FAyY3LKBLAWK7/9d6aQJbk+uxsuEpecsP23o9l6qMvrSnLdlqmXDCgfNK\n\t12ewGvb0R83owi6chn8fU+g+Rurn/FItTmPjOXB5zrXdQpJgTpw0oU/fYenyzIncm9\n\tjuN1JL6Z5H9OcicQlcBD+JiByajsXCGgojl4GiIlpYBvXSqJuDUdQcbYluY/NnPAuR\n\t/7FRqda7xTIaw==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=EVfRpgLyhwuoZq3xGbe9A/EntdQhevh61GzAphW6ro8=;\n\tb=jffINp5d0u4ZbeBLSJKFLoaiHRZR0r3AVJhmUnyApzpKZ/DM9GIZLl0Lue/dZ0y0lo\n\trq98kzKxQk5hPsDydV/PjcgI3wSOLD1AJtZ/1F2M2gCwvV7DSYA8HSRzizm9TKG9iu09\n\tnuyxx6HFuDEKdWs1uoSHMGvIxUjin8yKUGfJQmD7HXmt0/imeswl/Dlt7Hpnj4lKJgdO\n\tDjHmsPlfFuRIKCSmuugi8aHydddMqtLqdzXEb+o3ax1XrlqKZKe45AFtSIRmy7P+hlQJ\n\tw9lIyw7ObXszhJctD5JFEhSnWYZpkkQWgJk435iUrC5mUTCU+KvyrcntkBFwRpITF1BI\n\tDCRQ=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"jffINp5d\"; 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:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=EVfRpgLyhwuoZq3xGbe9A/EntdQhevh61GzAphW6ro8=;\n\tb=EP9U7Scokuzd7JAYPwxcp/cF6zlgEpUrFAkvQSQcOV2aMFgsCqSrS1iTdjDdT+evDN\n\tuy4r+W7t41BzFmsRw8l5TNqW24vbUGfTyBaO+v8crnjaXXv69LZ0qjw9Ml6oP5MN2GWg\n\tPT1g23TsVfFV1w87kX/SAeUkok/jHpC2/WUWuWJK/oBGhXWuKJCcZP3Hr3gXkcrA8yMg\n\taD2AUhY0VFEAM0eHzXnMQ9BEzpTOtrH3SWBqkYk4PynVOTeKo4lLxq9qIeU0UFcIz0qT\n\td95pA09soehzGN9B32TROj9apctP21RbxMZrLh5IJbPHArpHSYWNbyIqQGPt2OY3G3Zc\n\t7Tdg==","X-Gm-Message-State":"AJIora8Qwf1hkJTL7+bJwbLcDQNwdr1prJwpdn9D1UcAvFcURQ4sXy0O\n\tCz0U5iBK1PkZiD8Cp2Zgs7YxAzW/ntBUZGiWceGDlw==","X-Google-Smtp-Source":"AGRyM1u2HcjPtsKTm1moFKisfseBN6OfhZf3qPOtjqHc9NHU/4VrYdQd0nNW+P4fAcOxWaEp+HWHC3Xrfh1kbGYa38Y=","X-Received":"by 2002:a2e:6101:0:b0:25d:eb9d:4c79 with SMTP id\n\tv1-20020a2e6101000000b0025deb9d4c79mr9030601ljb.354.1659003396181;\n\tThu, 28 Jul 2022 03:16:36 -0700 (PDT)","MIME-Version":"1.0","References":"<20220727023816.30008-1-laurent.pinchart@ideasonboard.com>\n\t<20220727023816.30008-12-laurent.pinchart@ideasonboard.com>","In-Reply-To":"<20220727023816.30008-12-laurent.pinchart@ideasonboard.com>","Date":"Thu, 28 Jul 2022 11:16:20 +0100","Message-ID":"<CAEmqJPrgrDryobHOaJ_QiHby+6PGbEvZ2pd3m41gPDziJ2b_Ew@mail.gmail.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Content-Type":"multipart/alternative; boundary=\"0000000000001c664105e4dad4a1\"","Subject":"Re: [libcamera-devel] [PATCH v7 11/14] utils: raspberrypi: Add\n\ttuning file 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>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":24219,"web_url":"https://patchwork.libcamera.org/comment/24219/","msgid":"<YuJtyR2gr7Aqyotw@pendragon.ideasonboard.com>","date":"2022-07-28T11:06:49","subject":"Re: [libcamera-devel] [PATCH v7 11/14] utils: raspberrypi: Add\n\ttuning file conversion script","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Naush,\n\nOn Thu, Jul 28, 2022 at 11:16:20AM +0100, Naushir Patuck wrote:\n> On Wed, 27 Jul 2022 at 03:38, Laurent Pinchart wrote:\n> \n> > From: Naushir Patuck <naush@raspberrypi.com>\n> >\n> > Add a script to convert the Raspberry Pi camera tuning file format from version\n> > 1.0 to 2.0. This script also adds a root level version key set to 2.0 to the\n> > config file, allowing the controller to distinguish between the two\n> > formats.\n> >\n> > Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > Signed-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\n> >\n> > diff --git a/utils/raspberrypi/ctt/convert_tuning.py\n> > b/utils/raspberrypi/ctt/convert_tuning.py\n> > new file mode 100755\n> > index 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\n> > version 2.0.\n> > +#\n> > +# Copyright 2022 Raspberry Pi Ltd.\n> \n> Before merging, can you make a quick change here:\n> \n> s/Raspberry Pi Ltd./Raspberry Pi Ltd/\n> \n> to be consistent with the reset of our codebase.\n\nUpdated and pushed.\n\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)","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 0BAB8C3275\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 28 Jul 2022 11:06:54 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 573E56330D;\n\tThu, 28 Jul 2022 13:06:53 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B71FC6330D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 28 Jul 2022 13:06:51 +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 35C2656D;\n\tThu, 28 Jul 2022 13:06:51 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1659006413;\n\tbh=D5FzWuyqFGyKjmWIP9ayt64lKosNdEEYpX0EYBAPpLM=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=4J8hyrnEOxp6bv8FmaeMhAZowLPFimEJM9ct7/+X8ZMJJIgBL2w5wEOTrQAY61h8M\n\tZUWMDEn/UTLsv6PtW6drBLlRgZit2wcUVh6qB4mF27JJ3dfPejXtWxOWVV+g48WalU\n\t+5l1JbGjP6Lr2eFX/PZ6k8vlEUMHdWAYIjlLp8f+IManvaE3wWkt0Ew2rL8qhKMKL/\n\tsEGEFSGnCeswoX9NxF7Xu/vFxm9HcTC4pm6ukpx6MCI11LVcCZJuY8uDgFzuRVjUtG\n\tqmW4cqqcFa1/LFpRFDSYMqjAr/OQn7hykKIhPYQeN5FYlQk2r01/TyHzIaL87TktqS\n\t9CSGeBrt67Sow==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1659006411;\n\tbh=D5FzWuyqFGyKjmWIP9ayt64lKosNdEEYpX0EYBAPpLM=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=Bs2CgtTq6W6PStkPekOw7g9FQX6+ex/R3f3M4nZR3UN7CJMMuW004Y2DnBI9n/cCG\n\tKGw8+lXuQC9VYagp/3UsjRHWzPBP8trInIzwDCAfNOGMeM6Wze70gcNM3xHaJ6xoSR\n\tQbQSFlAs/0pYvyWFKy81Qe9L2T+yAwbHWhRp7Uds="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"Bs2CgtTq\"; dkim-atps=neutral","Date":"Thu, 28 Jul 2022 14:06:49 +0300","To":"Naushir Patuck <naush@raspberrypi.com>","Message-ID":"<YuJtyR2gr7Aqyotw@pendragon.ideasonboard.com>","References":"<20220727023816.30008-1-laurent.pinchart@ideasonboard.com>\n\t<20220727023816.30008-12-laurent.pinchart@ideasonboard.com>\n\t<CAEmqJPrgrDryobHOaJ_QiHby+6PGbEvZ2pd3m41gPDziJ2b_Ew@mail.gmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<CAEmqJPrgrDryobHOaJ_QiHby+6PGbEvZ2pd3m41gPDziJ2b_Ew@mail.gmail.com>","Subject":"Re: [libcamera-devel] [PATCH v7 11/14] utils: raspberrypi: Add\n\ttuning file 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>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]