[{"id":28182,"web_url":"https://patchwork.libcamera.org/comment/28182/","msgid":"<mwcgscav6yhxirrpfuqzgjaa6jlmntdd7iklrx7sgixgjf7epl@vplpbk2w5ytm>","date":"2023-11-27T16:54:25","subject":"Re: [libcamera-devel] [PATCH v3 4/7] libcamera: control: Add vendor\n\tcontrol id range reservation","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/people/143/","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"content":"I wonder if it's worth passing this as param, as I suspect the\nenumeration of controls will be something that user won't change..\n\nOn Fri, Nov 24, 2023 at 12:37:10PM +0000, Naushir Patuck via libcamera-devel wrote:\n> Add a new control_ranges.yaml file that is used to reserve control id\n> ranges/offsets for libcamera and vendor specific controls. This file is\n> used by the gen-controls.py script to generate control id values for\n> each control.\n>\n> Draft controls now have a separate range from core libcamera controls,\n> breaking the existing numbering behaviour.\n>\n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n>  include/libcamera/meson.build     |  3 ++-\n>  src/libcamera/control_ranges.yaml | 18 ++++++++++++++++++\n>  src/libcamera/meson.build         |  4 +++-\n>  utils/gen-controls.py             | 14 ++++++++++----\n>  4 files changed, 33 insertions(+), 6 deletions(-)\n>  create mode 100644 src/libcamera/control_ranges.yaml\n>\n> diff --git a/include/libcamera/meson.build b/include/libcamera/meson.build\n> index a763c8ff4344..79187d3fdfc9 100644\n> --- a/include/libcamera/meson.build\n> +++ b/include/libcamera/meson.build\n> @@ -76,12 +76,13 @@ foreach mode, entry : controls_map\n>      endif\n>\n>      template_file = files(outfile + '.in')\n> +    ranges_file = files('../../src/libcamera/control_ranges.yaml')\n>      control_headers += custom_target(header + '_h',\n>                                       input : input_files,\n>                                       output : outfile,\n>                                       command : [gen_controls, '-o', '@OUTPUT@',\n>                                                  '--mode', mode, '-t', template_file,\n> -                                                '@INPUT@'],\n> +                                                '-r', ranges_file, '@INPUT@'],\n>                                       install : true,\n>                                       install_dir : libcamera_headers_install_dir)\n>  endforeach\n> diff --git a/src/libcamera/control_ranges.yaml b/src/libcamera/control_ranges.yaml\n> new file mode 100644\n> index 000000000000..d42447d04647\n> --- /dev/null\n> +++ b/src/libcamera/control_ranges.yaml\n> @@ -0,0 +1,18 @@\n> +# SPDX-License-Identifier: LGPL-2.1-or-later\n> +#\n> +# Copyright (C) 2023, Raspberry Pi Ltd\n> +#\n> +%YAML 1.1\n> +---\n> +# Specifies the control id ranges/offsets for core/draft libcamera and vendor\n> +# controls and properties.\n> +ranges:\n> +  # Core libcamera controls\n> +  libcamera: 0\n> +  # Draft designated libcamera controls\n> +  draft: 10000\n> +  # Raspberry Pi vendor controls\n> +  rpi: 20000\n> +  # Next range starts at 30000\n> +\n> +...\n> diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build\n> index 6d9902e6ffd1..45f63e932e4f 100644\n> --- a/src/libcamera/meson.build\n> +++ b/src/libcamera/meson.build\n> @@ -141,11 +141,13 @@ foreach mode, input_files : controls_mode_files\n>          template_file = files('property_ids.cpp.in')\n>      endif\n>\n> +    ranges_file = files('control_ranges.yaml')\n>      control_sources += custom_target(mode + '_cpp',\n>                                       input : input_files,\n>                                       output : mode + '_ids.cpp',\n>                                       command : [gen_controls, '-o', '@OUTPUT@',\n> -                                                '--mode', mode, '-t', template_file, '@INPUT@'])\n> +                                                '--mode', mode, '-t', template_file,\n> +                                                '-r', ranges_file, '@INPUT@'])\n>  endforeach\n>\n>  libcamera_sources += control_sources\n> diff --git a/utils/gen-controls.py b/utils/gen-controls.py\n> index 30c58f35473c..04c63098b19b 100755\n> --- a/utils/gen-controls.py\n> +++ b/utils/gen-controls.py\n> @@ -236,7 +236,7 @@ ${vendor_controls_str}\n>      }\n>\n>\n> -def generate_h(controls, mode):\n> +def generate_h(controls, mode, ranges):\n>      enum_template_start = string.Template('''enum ${name}Enum {''')\n>      enum_value_template = string.Template('''\\t${name} = ${value},''')\n>      enum_values_template = string.Template('''extern const std::array<const ControlValue, ${size}> ${name}Values;''')\n> @@ -251,8 +251,10 @@ def generate_h(controls, mode):\n>\n>          vendor = 'draft' if ctrl.is_draft else ctrl.vendor\n>          if vendor not in ctrls:\n> +            if vendor not in ranges.keys():\n> +                raise RuntimeError(f'Control id range is not defined for vendor {vendor}')\n> +            id_value[vendor] = ranges[vendor] + 1\n>              ids[vendor] = []\n> -            id_value[vendor] = 1\n>              ctrls[vendor] = []\n>\n>          # Core and draft controls use the same ID value\n> @@ -338,13 +340,17 @@ def main(argv):\n>                          help='Mode of operation')\n>      parser.add_argument('--output', '-o', metavar='file', type=str,\n>                          help='Output file name. Defaults to standard output if not specified.')\n> +    parser.add_argument('--ranges', '-r', type=str, required=True,\n> +                        help='Control id range reservation file.')\n>      parser.add_argument('--template', '-t', dest='template', type=str, required=True,\n>                          help='Template file name.')\n>      parser.add_argument('input', type=str, nargs='+',\n>                          help='Input file name.')\n> -\n>      args = parser.parse_args(argv[1:])\n>\n> +    data = open(args.ranges, 'rb').read()\n> +    ranges = yaml.safe_load(data)['ranges']\n> +\n>      controls = []\n>      for input in args.input:\n>          data = open(input, 'rb').read()\n> @@ -355,7 +361,7 @@ def main(argv):\n>      if args.template.endswith('.cpp.in'):\n>          data = generate_cpp(controls)\n>      elif args.template.endswith('.h.in'):\n> -        data = generate_h(controls, args.mode)\n> +        data = generate_h(controls, args.mode, ranges)\n>      else:\n>          raise RuntimeError('Unknown template type')\n>\n> --\n> 2.34.1\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 4AA8BBDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 27 Nov 2023 16:54:30 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A98C3629BD;\n\tMon, 27 Nov 2023 17:54:29 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 84D6C629B6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 27 Nov 2023 17:54:28 +0100 (CET)","from ideasonboard.com (93-61-96-190.ip145.fastwebnet.it\n\t[93.61.96.190])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D20F025A;\n\tMon, 27 Nov 2023 17:53:53 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1701104069;\n\tbh=3VVcPwEzT5Gmvg+hmePujFg6279lc8jlg8dqQaKg9gY=;\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=stLRveIKiX8ERVAUaDC0kKmFjROhU/+IdbPXBuzWcbJ9w4WwCfRXYK/Q6qT/M6F+8\n\tm1+sXm6KA12uPVU5nWg7GO/NajoeWWbZNPOt6ZNqhu2Kr6tVxwWxsQqLr4/Q7JBOUl\n\tVRZOao1Q/vseiL+cuDiuBCvA3HgucGLrNiCsCSGP3lG3dmm5GuTpzBo575wGez0fbs\n\ttnRunb3ZsHBBT2h++IycFIOjVl4ulCcjm+q4ztqvph6CIgqEiS/RuEBNT6pT5jCm+R\n\tGETTOAjahNqvt2NGm/pIu1F91bz7pnE00yRZSR6e/nGdh3AbJgmGQ792pXOTPHq1Y7\n\tHT2h1ETGULpFQ==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1701104033;\n\tbh=3VVcPwEzT5Gmvg+hmePujFg6279lc8jlg8dqQaKg9gY=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=wfKiETtfzRqY+iA9IzpG7HMea5PZXEbnBRMiY1TYCJg7OdPt4BtORU7iZd0P1h22p\n\tybKj6NzY8HaenlsqyvlxozxBNR29Voigp6fShnqx5foxV8IE5BnI2cl+XtckPIoCFE\n\t7fD0v9/k8cxi1LzMD4fv7pC9r/KPcOhlCS3DPai8="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"wfKiETtf\"; dkim-atps=neutral","Date":"Mon, 27 Nov 2023 17:54:25 +0100","To":"Naushir Patuck <naush@raspberrypi.com>","Message-ID":"<mwcgscav6yhxirrpfuqzgjaa6jlmntdd7iklrx7sgixgjf7epl@vplpbk2w5ytm>","References":"<20231124123713.22519-1-naush@raspberrypi.com>\n\t<20231124123713.22519-5-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20231124123713.22519-5-naush@raspberrypi.com>","Subject":"Re: [libcamera-devel] [PATCH v3 4/7] libcamera: control: Add vendor\n\tcontrol id range reservation","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":"Jacopo Mondi via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":28187,"web_url":"https://patchwork.libcamera.org/comment/28187/","msgid":"<CAEmqJPpTP5gj62=9=PbGD7zrT=NnmsJG-AAOn56Q9FOKX=4Hbg@mail.gmail.com>","date":"2023-11-28T09:21:05","subject":"Re: [libcamera-devel] [PATCH v3 4/7] libcamera: control: Add vendor\n\tcontrol id range reservation","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"content":"Hi Jacopo,\n\nOn Mon, 27 Nov 2023 at 16:54, Jacopo Mondi\n<jacopo.mondi@ideasonboard.com> wrote:\n>\n> I wonder if it's worth passing this as param, as I suspect the\n> enumeration of controls will be something that user won't change..\n\nI could do that, but that involves setting the vendor ranges in the\nmeson.build file somewhere and fetching it when calling the script.\nPersonally I prefer this living in a YAML file as this patch does, but\nif folks want, I can move it into the build scripts.\n\nRegards,\nNaush\n\n>\n> On Fri, Nov 24, 2023 at 12:37:10PM +0000, Naushir Patuck via libcamera-devel wrote:\n> > Add a new control_ranges.yaml file that is used to reserve control id\n> > ranges/offsets for libcamera and vendor specific controls. This file is\n> > used by the gen-controls.py script to generate control id values for\n> > each control.\n> >\n> > Draft controls now have a separate range from core libcamera controls,\n> > breaking the existing numbering behaviour.\n> >\n> > Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > ---\n> >  include/libcamera/meson.build     |  3 ++-\n> >  src/libcamera/control_ranges.yaml | 18 ++++++++++++++++++\n> >  src/libcamera/meson.build         |  4 +++-\n> >  utils/gen-controls.py             | 14 ++++++++++----\n> >  4 files changed, 33 insertions(+), 6 deletions(-)\n> >  create mode 100644 src/libcamera/control_ranges.yaml\n> >\n> > diff --git a/include/libcamera/meson.build b/include/libcamera/meson.build\n> > index a763c8ff4344..79187d3fdfc9 100644\n> > --- a/include/libcamera/meson.build\n> > +++ b/include/libcamera/meson.build\n> > @@ -76,12 +76,13 @@ foreach mode, entry : controls_map\n> >      endif\n> >\n> >      template_file = files(outfile + '.in')\n> > +    ranges_file = files('../../src/libcamera/control_ranges.yaml')\n> >      control_headers += custom_target(header + '_h',\n> >                                       input : input_files,\n> >                                       output : outfile,\n> >                                       command : [gen_controls, '-o', '@OUTPUT@',\n> >                                                  '--mode', mode, '-t', template_file,\n> > -                                                '@INPUT@'],\n> > +                                                '-r', ranges_file, '@INPUT@'],\n> >                                       install : true,\n> >                                       install_dir : libcamera_headers_install_dir)\n> >  endforeach\n> > diff --git a/src/libcamera/control_ranges.yaml b/src/libcamera/control_ranges.yaml\n> > new file mode 100644\n> > index 000000000000..d42447d04647\n> > --- /dev/null\n> > +++ b/src/libcamera/control_ranges.yaml\n> > @@ -0,0 +1,18 @@\n> > +# SPDX-License-Identifier: LGPL-2.1-or-later\n> > +#\n> > +# Copyright (C) 2023, Raspberry Pi Ltd\n> > +#\n> > +%YAML 1.1\n> > +---\n> > +# Specifies the control id ranges/offsets for core/draft libcamera and vendor\n> > +# controls and properties.\n> > +ranges:\n> > +  # Core libcamera controls\n> > +  libcamera: 0\n> > +  # Draft designated libcamera controls\n> > +  draft: 10000\n> > +  # Raspberry Pi vendor controls\n> > +  rpi: 20000\n> > +  # Next range starts at 30000\n> > +\n> > +...\n> > diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build\n> > index 6d9902e6ffd1..45f63e932e4f 100644\n> > --- a/src/libcamera/meson.build\n> > +++ b/src/libcamera/meson.build\n> > @@ -141,11 +141,13 @@ foreach mode, input_files : controls_mode_files\n> >          template_file = files('property_ids.cpp.in')\n> >      endif\n> >\n> > +    ranges_file = files('control_ranges.yaml')\n> >      control_sources += custom_target(mode + '_cpp',\n> >                                       input : input_files,\n> >                                       output : mode + '_ids.cpp',\n> >                                       command : [gen_controls, '-o', '@OUTPUT@',\n> > -                                                '--mode', mode, '-t', template_file, '@INPUT@'])\n> > +                                                '--mode', mode, '-t', template_file,\n> > +                                                '-r', ranges_file, '@INPUT@'])\n> >  endforeach\n> >\n> >  libcamera_sources += control_sources\n> > diff --git a/utils/gen-controls.py b/utils/gen-controls.py\n> > index 30c58f35473c..04c63098b19b 100755\n> > --- a/utils/gen-controls.py\n> > +++ b/utils/gen-controls.py\n> > @@ -236,7 +236,7 @@ ${vendor_controls_str}\n> >      }\n> >\n> >\n> > -def generate_h(controls, mode):\n> > +def generate_h(controls, mode, ranges):\n> >      enum_template_start = string.Template('''enum ${name}Enum {''')\n> >      enum_value_template = string.Template('''\\t${name} = ${value},''')\n> >      enum_values_template = string.Template('''extern const std::array<const ControlValue, ${size}> ${name}Values;''')\n> > @@ -251,8 +251,10 @@ def generate_h(controls, mode):\n> >\n> >          vendor = 'draft' if ctrl.is_draft else ctrl.vendor\n> >          if vendor not in ctrls:\n> > +            if vendor not in ranges.keys():\n> > +                raise RuntimeError(f'Control id range is not defined for vendor {vendor}')\n> > +            id_value[vendor] = ranges[vendor] + 1\n> >              ids[vendor] = []\n> > -            id_value[vendor] = 1\n> >              ctrls[vendor] = []\n> >\n> >          # Core and draft controls use the same ID value\n> > @@ -338,13 +340,17 @@ def main(argv):\n> >                          help='Mode of operation')\n> >      parser.add_argument('--output', '-o', metavar='file', type=str,\n> >                          help='Output file name. Defaults to standard output if not specified.')\n> > +    parser.add_argument('--ranges', '-r', type=str, required=True,\n> > +                        help='Control id range reservation file.')\n> >      parser.add_argument('--template', '-t', dest='template', type=str, required=True,\n> >                          help='Template file name.')\n> >      parser.add_argument('input', type=str, nargs='+',\n> >                          help='Input file name.')\n> > -\n> >      args = parser.parse_args(argv[1:])\n> >\n> > +    data = open(args.ranges, 'rb').read()\n> > +    ranges = yaml.safe_load(data)['ranges']\n> > +\n> >      controls = []\n> >      for input in args.input:\n> >          data = open(input, 'rb').read()\n> > @@ -355,7 +361,7 @@ def main(argv):\n> >      if args.template.endswith('.cpp.in'):\n> >          data = generate_cpp(controls)\n> >      elif args.template.endswith('.h.in'):\n> > -        data = generate_h(controls, args.mode)\n> > +        data = generate_h(controls, args.mode, ranges)\n> >      else:\n> >          raise RuntimeError('Unknown template type')\n> >\n> > --\n> > 2.34.1\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 4829DBDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 28 Nov 2023 09:21:37 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A3828629BC;\n\tTue, 28 Nov 2023 10:21:36 +0100 (CET)","from mail-yw1-x1135.google.com (mail-yw1-x1135.google.com\n\t[IPv6:2607:f8b0:4864:20::1135])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id F1ABB61DA5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 28 Nov 2023 10:21:33 +0100 (CET)","by mail-yw1-x1135.google.com with SMTP id\n\t00721157ae682-5cc77e23218so53057917b3.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 28 Nov 2023 01:21:33 -0800 (PST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1701163296;\n\tbh=O1AZKQSnfRj0pr28CxvWshkUtebfANZp5mbllPZEjjE=;\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=wt1zGjhsEPH44mVkxMwqy0DzvbfunZbcQbSZUXJkFHhSrDfoV0XFnh4JWoe7OIk3f\n\tBhejBI+2UdSTfZ4isV1US9rVCQbv+pTe+6tTD48pw4YJWcaDltJy0m1MU5zPL4v7KU\n\tk2rV75p2ttD5FGnKbzli9nMNYMX5ar+B+FIj5uYnhz80xdshYrXqU0nZW9Xfsdc8+p\n\ta51Cnci+hFkNzG5g8aOlb9VTrNbhUfY5WpmsMIxHDKcNrWBO/NHgtfNM5s+wXtLfvt\n\t6K19F9jygbDZpPoB7/LTZYDoL751jRf4qzIGF4qQg4kdYHuovURFn9meGrC+43JBbF\n\tQcgnG380XMvwg==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1701163292; x=1701768092;\n\tdarn=lists.libcamera.org; \n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:from:to:cc:subject:date:message-id:reply-to;\n\tbh=prMP1bZLH8aehuoucoEVQNRodK/k7jJ5VQMXb+pAZe0=;\n\tb=YxOhHi/gbfnBrmOu39C9PQzn4zGUyrPW1okwbWmGJXJWOySDZHwZz0Rgmks3EeFTUY\n\tNpY2brqqrR8F5QJV2aQEZRhkmrmwtHMVIOPhSaJVtFs5rHioLScNUXkla52ESI0QXj7c\n\tMLy4PAkISjEddqebYPPsbUSuxOAtNKKw06NNjKK/DOD8/V8b/hYtewZcPUAeVAAqa3MH\n\tDGtCT3+SHeaMznRyqt1Va0JzHYczeHCYQmSmYTHn7efoMFw7oS3c8mpEfsnH599PdktP\n\tV2OvaX/hUTIlomRKj31HHHzQjuMB7veHYtXy/Q2AMjp17PtIzYEeTOOg+uKkm9KBlVG3\n\tidHw=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"YxOhHi/g\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1701163292; x=1701768092;\n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:x-gm-message-state:from:to:cc:subject:date:message-id\n\t:reply-to;\n\tbh=prMP1bZLH8aehuoucoEVQNRodK/k7jJ5VQMXb+pAZe0=;\n\tb=Uy+OX8FP5X7g9Rb2LiX2AF8nTaAzrMGotSLrNsUdIuOxqzKtP9Iy6mooUmQyEJQpHM\n\tlhTmPEiiYGUy7s57gmLmusHOVWvjJUdFAn4PZa9NFxg3ojOAXL+mCra1eFd9AzETvtgJ\n\tdYWEeu9xikhX4MLkst0fkNwKmqQi+/HkCnEpsVjB2Mh8qWmyYu/T5whDmegpq0S0TNXJ\n\toS2MX+uKUwwMLEC4AAQMOmiIqYNUSyZsYGIKVVV0gfAczNuuqKJcIksoVQT2nY6ILbmV\n\tY8p/NTJJJlCvqzgPfu9L0hZuFiFY7fBdPT6nv+wr1HyVeoI1WW4p4eZN3V096iIhc+XB\n\tfzbw==","X-Gm-Message-State":"AOJu0YxnS+Rrr1/+dcQYIV/X9CPEGaKuOUjJm5xRRc/aStVpXGm6N1G4\n\tHTQQQop+7EZtuySzN1xYaUA/e+bAuxGKY6iXZh3RRF4XmAZYXCA3Mdg=","X-Google-Smtp-Source":"AGHT+IHrmOK6weXUjjfGm1GwU22o4OR4lL78DyC4Y9Z4nQdW+UACZIBrtq+L1eMJwMbMHLJMJkb2YqAwplI4X9oohhI=","X-Received":"by 2002:a0d:d692:0:b0:5a0:ae01:803c with SMTP id\n\ty140-20020a0dd692000000b005a0ae01803cmr14618088ywd.38.1701163292687;\n\tTue, 28 Nov 2023 01:21:32 -0800 (PST)","MIME-Version":"1.0","References":"<20231124123713.22519-1-naush@raspberrypi.com>\n\t<20231124123713.22519-5-naush@raspberrypi.com>\n\t<mwcgscav6yhxirrpfuqzgjaa6jlmntdd7iklrx7sgixgjf7epl@vplpbk2w5ytm>","In-Reply-To":"<mwcgscav6yhxirrpfuqzgjaa6jlmntdd7iklrx7sgixgjf7epl@vplpbk2w5ytm>","Date":"Tue, 28 Nov 2023 09:21:05 +0000","Message-ID":"<CAEmqJPpTP5gj62=9=PbGD7zrT=NnmsJG-AAOn56Q9FOKX=4Hbg@mail.gmail.com>","To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Subject":"Re: [libcamera-devel] [PATCH v3 4/7] libcamera: control: Add vendor\n\tcontrol id range reservation","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@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":28188,"web_url":"https://patchwork.libcamera.org/comment/28188/","msgid":"<kodmfzm25ty4vc7xowoesbxuufsr34sajgggie5hwwjnfgk2lk@wzt24y4vmg2s>","date":"2023-11-28T09:24:33","subject":"Re: [libcamera-devel] [PATCH v3 4/7] libcamera: control: Add vendor\n\tcontrol id range reservation","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/people/143/","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"content":"Hi Naush\n\nOn Tue, Nov 28, 2023 at 09:21:05AM +0000, Naushir Patuck wrote:\n> Hi Jacopo,\n>\n> On Mon, 27 Nov 2023 at 16:54, Jacopo Mondi\n> <jacopo.mondi@ideasonboard.com> wrote:\n> >\n> > I wonder if it's worth passing this as param, as I suspect the\n> > enumeration of controls will be something that user won't change..\n>\n> I could do that, but that involves setting the vendor ranges in the\n> meson.build file somewhere and fetching it when calling the script.\n> Personally I prefer this living in a YAML file as this patch does, but\n> if folks want, I can move it into the build scripts.\n>\n\nI was not questioning the usage of the yaml file, that's fine.\nI was wondering if it's worth passing the ranges file name and\nlocation as parameter, or gen-controls.py can assume it knows where it\nlives..\n\n> Regards,\n> Naush\n>\n> >\n> > On Fri, Nov 24, 2023 at 12:37:10PM +0000, Naushir Patuck via libcamera-devel wrote:\n> > > Add a new control_ranges.yaml file that is used to reserve control id\n> > > ranges/offsets for libcamera and vendor specific controls. This file is\n> > > used by the gen-controls.py script to generate control id values for\n> > > each control.\n> > >\n> > > Draft controls now have a separate range from core libcamera controls,\n> > > breaking the existing numbering behaviour.\n> > >\n> > > Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> > > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > > ---\n> > >  include/libcamera/meson.build     |  3 ++-\n> > >  src/libcamera/control_ranges.yaml | 18 ++++++++++++++++++\n> > >  src/libcamera/meson.build         |  4 +++-\n> > >  utils/gen-controls.py             | 14 ++++++++++----\n> > >  4 files changed, 33 insertions(+), 6 deletions(-)\n> > >  create mode 100644 src/libcamera/control_ranges.yaml\n> > >\n> > > diff --git a/include/libcamera/meson.build b/include/libcamera/meson.build\n> > > index a763c8ff4344..79187d3fdfc9 100644\n> > > --- a/include/libcamera/meson.build\n> > > +++ b/include/libcamera/meson.build\n> > > @@ -76,12 +76,13 @@ foreach mode, entry : controls_map\n> > >      endif\n> > >\n> > >      template_file = files(outfile + '.in')\n> > > +    ranges_file = files('../../src/libcamera/control_ranges.yaml')\n> > >      control_headers += custom_target(header + '_h',\n> > >                                       input : input_files,\n> > >                                       output : outfile,\n> > >                                       command : [gen_controls, '-o', '@OUTPUT@',\n> > >                                                  '--mode', mode, '-t', template_file,\n> > > -                                                '@INPUT@'],\n> > > +                                                '-r', ranges_file, '@INPUT@'],\n> > >                                       install : true,\n> > >                                       install_dir : libcamera_headers_install_dir)\n> > >  endforeach\n> > > diff --git a/src/libcamera/control_ranges.yaml b/src/libcamera/control_ranges.yaml\n> > > new file mode 100644\n> > > index 000000000000..d42447d04647\n> > > --- /dev/null\n> > > +++ b/src/libcamera/control_ranges.yaml\n> > > @@ -0,0 +1,18 @@\n> > > +# SPDX-License-Identifier: LGPL-2.1-or-later\n> > > +#\n> > > +# Copyright (C) 2023, Raspberry Pi Ltd\n> > > +#\n> > > +%YAML 1.1\n> > > +---\n> > > +# Specifies the control id ranges/offsets for core/draft libcamera and vendor\n> > > +# controls and properties.\n> > > +ranges:\n> > > +  # Core libcamera controls\n> > > +  libcamera: 0\n> > > +  # Draft designated libcamera controls\n> > > +  draft: 10000\n> > > +  # Raspberry Pi vendor controls\n> > > +  rpi: 20000\n> > > +  # Next range starts at 30000\n> > > +\n> > > +...\n> > > diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build\n> > > index 6d9902e6ffd1..45f63e932e4f 100644\n> > > --- a/src/libcamera/meson.build\n> > > +++ b/src/libcamera/meson.build\n> > > @@ -141,11 +141,13 @@ foreach mode, input_files : controls_mode_files\n> > >          template_file = files('property_ids.cpp.in')\n> > >      endif\n> > >\n> > > +    ranges_file = files('control_ranges.yaml')\n> > >      control_sources += custom_target(mode + '_cpp',\n> > >                                       input : input_files,\n> > >                                       output : mode + '_ids.cpp',\n> > >                                       command : [gen_controls, '-o', '@OUTPUT@',\n> > > -                                                '--mode', mode, '-t', template_file, '@INPUT@'])\n> > > +                                                '--mode', mode, '-t', template_file,\n> > > +                                                '-r', ranges_file, '@INPUT@'])\n> > >  endforeach\n> > >\n> > >  libcamera_sources += control_sources\n> > > diff --git a/utils/gen-controls.py b/utils/gen-controls.py\n> > > index 30c58f35473c..04c63098b19b 100755\n> > > --- a/utils/gen-controls.py\n> > > +++ b/utils/gen-controls.py\n> > > @@ -236,7 +236,7 @@ ${vendor_controls_str}\n> > >      }\n> > >\n> > >\n> > > -def generate_h(controls, mode):\n> > > +def generate_h(controls, mode, ranges):\n> > >      enum_template_start = string.Template('''enum ${name}Enum {''')\n> > >      enum_value_template = string.Template('''\\t${name} = ${value},''')\n> > >      enum_values_template = string.Template('''extern const std::array<const ControlValue, ${size}> ${name}Values;''')\n> > > @@ -251,8 +251,10 @@ def generate_h(controls, mode):\n> > >\n> > >          vendor = 'draft' if ctrl.is_draft else ctrl.vendor\n> > >          if vendor not in ctrls:\n> > > +            if vendor not in ranges.keys():\n> > > +                raise RuntimeError(f'Control id range is not defined for vendor {vendor}')\n> > > +            id_value[vendor] = ranges[vendor] + 1\n> > >              ids[vendor] = []\n> > > -            id_value[vendor] = 1\n> > >              ctrls[vendor] = []\n> > >\n> > >          # Core and draft controls use the same ID value\n> > > @@ -338,13 +340,17 @@ def main(argv):\n> > >                          help='Mode of operation')\n> > >      parser.add_argument('--output', '-o', metavar='file', type=str,\n> > >                          help='Output file name. Defaults to standard output if not specified.')\n> > > +    parser.add_argument('--ranges', '-r', type=str, required=True,\n> > > +                        help='Control id range reservation file.')\n> > >      parser.add_argument('--template', '-t', dest='template', type=str, required=True,\n> > >                          help='Template file name.')\n> > >      parser.add_argument('input', type=str, nargs='+',\n> > >                          help='Input file name.')\n> > > -\n> > >      args = parser.parse_args(argv[1:])\n> > >\n> > > +    data = open(args.ranges, 'rb').read()\n> > > +    ranges = yaml.safe_load(data)['ranges']\n> > > +\n> > >      controls = []\n> > >      for input in args.input:\n> > >          data = open(input, 'rb').read()\n> > > @@ -355,7 +361,7 @@ def main(argv):\n> > >      if args.template.endswith('.cpp.in'):\n> > >          data = generate_cpp(controls)\n> > >      elif args.template.endswith('.h.in'):\n> > > -        data = generate_h(controls, args.mode)\n> > > +        data = generate_h(controls, args.mode, ranges)\n> > >      else:\n> > >          raise RuntimeError('Unknown template type')\n> > >\n> > > --\n> > > 2.34.1\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 27F8FC31E9\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 28 Nov 2023 09:24:38 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7937B629C3;\n\tTue, 28 Nov 2023 10:24:37 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DA54F629BC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 28 Nov 2023 10:24:35 +0100 (CET)","from ideasonboard.com (93-61-96-190.ip145.fastwebnet.it\n\t[93.61.96.190])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id BA751289;\n\tTue, 28 Nov 2023 10:24:00 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1701163477;\n\tbh=N46G4kuNVskKiisrLv2uFbf1uH+RlDUDKqeE8eqbrFA=;\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=FdDBYqxiHOEK3AB0RIT98JmiBfr2otBlcLQqKwqSBC269KU1bSzBnnqEXUf4vSNLN\n\t6uSPyDVh7PT+H0WFUGQQ9Qph0IFJSaqOXU8X0c3B6RU4/iNsZJXyaHwooevtwaQcRD\n\tkbs2ptLJGxNlbXmQYrdMrnpBxxOb3bRgBh1UTlTWPjE4vHuc/bWjEiF7UohZOtEYpT\n\t4AeZOfmHrQjNI8DMINur6DWRvW5uxrrLqEVTFFwqdkwsIABqT7semS8mMeqwrOT7fr\n\tU0mqNX7CM2IAkJncMLNdmUze2NUpfC+e91Zerd1MRk6I3jJF4KpUBibPfVIeEL508B\n\tQJdLmQ2ohBMCA==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1701163440;\n\tbh=N46G4kuNVskKiisrLv2uFbf1uH+RlDUDKqeE8eqbrFA=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=bW0niO6LWYOtVIxAokQ/bXDZVtrSOBSk7FV4stz2xUalNhBjpXE1jmn7joRaKnGlJ\n\tvorBbfytJ8rQd6WFBeshTyvYV5LgASBqssx9M1c2+1gd7PwiQGBGGlkegVUPlk9z9w\n\tfXUZC85tvARRS16xkkyzYjMJo82VKwxD+L+13yp0="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"bW0niO6L\"; dkim-atps=neutral","Date":"Tue, 28 Nov 2023 10:24:33 +0100","To":"Naushir Patuck <naush@raspberrypi.com>","Message-ID":"<kodmfzm25ty4vc7xowoesbxuufsr34sajgggie5hwwjnfgk2lk@wzt24y4vmg2s>","References":"<20231124123713.22519-1-naush@raspberrypi.com>\n\t<20231124123713.22519-5-naush@raspberrypi.com>\n\t<mwcgscav6yhxirrpfuqzgjaa6jlmntdd7iklrx7sgixgjf7epl@vplpbk2w5ytm>\n\t<CAEmqJPpTP5gj62=9=PbGD7zrT=NnmsJG-AAOn56Q9FOKX=4Hbg@mail.gmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<CAEmqJPpTP5gj62=9=PbGD7zrT=NnmsJG-AAOn56Q9FOKX=4Hbg@mail.gmail.com>","Subject":"Re: [libcamera-devel] [PATCH v3 4/7] libcamera: control: Add vendor\n\tcontrol id range reservation","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":"Jacopo Mondi via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","Cc":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":28189,"web_url":"https://patchwork.libcamera.org/comment/28189/","msgid":"<CAEmqJPphV57vKgHyEM=0c+f4c-7DWoe5Q9MdQ3kWLkg=jt_rgg@mail.gmail.com>","date":"2023-11-28T09:28:08","subject":"Re: [libcamera-devel] [PATCH v3 4/7] libcamera: control: Add vendor\n\tcontrol id range reservation","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"content":"On Tue, 28 Nov 2023 at 09:24, Jacopo Mondi\n<jacopo.mondi@ideasonboard.com> wrote:\n>\n> Hi Naush\n>\n> On Tue, Nov 28, 2023 at 09:21:05AM +0000, Naushir Patuck wrote:\n> > Hi Jacopo,\n> >\n> > On Mon, 27 Nov 2023 at 16:54, Jacopo Mondi\n> > <jacopo.mondi@ideasonboard.com> wrote:\n> > >\n> > > I wonder if it's worth passing this as param, as I suspect the\n> > > enumeration of controls will be something that user won't change..\n> >\n> > I could do that, but that involves setting the vendor ranges in the\n> > meson.build file somewhere and fetching it when calling the script.\n> > Personally I prefer this living in a YAML file as this patch does, but\n> > if folks want, I can move it into the build scripts.\n> >\n>\n> I was not questioning the usage of the yaml file, that's fine.\n> I was wondering if it's worth passing the ranges file name and\n> location as parameter, or gen-controls.py can assume it knows where it\n> lives..\n\nAh, sorry I misunderstood! I did it as a parameter as all the inputs\nseem to go through parameters, but again, I am happy to keep the\nranges file hardcoded in the script if folks think that's better.\n\nNaush\n\n\n>\n> > Regards,\n> > Naush\n> >\n> > >\n> > > On Fri, Nov 24, 2023 at 12:37:10PM +0000, Naushir Patuck via libcamera-devel wrote:\n> > > > Add a new control_ranges.yaml file that is used to reserve control id\n> > > > ranges/offsets for libcamera and vendor specific controls. This file is\n> > > > used by the gen-controls.py script to generate control id values for\n> > > > each control.\n> > > >\n> > > > Draft controls now have a separate range from core libcamera controls,\n> > > > breaking the existing numbering behaviour.\n> > > >\n> > > > Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> > > > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > > > ---\n> > > >  include/libcamera/meson.build     |  3 ++-\n> > > >  src/libcamera/control_ranges.yaml | 18 ++++++++++++++++++\n> > > >  src/libcamera/meson.build         |  4 +++-\n> > > >  utils/gen-controls.py             | 14 ++++++++++----\n> > > >  4 files changed, 33 insertions(+), 6 deletions(-)\n> > > >  create mode 100644 src/libcamera/control_ranges.yaml\n> > > >\n> > > > diff --git a/include/libcamera/meson.build b/include/libcamera/meson.build\n> > > > index a763c8ff4344..79187d3fdfc9 100644\n> > > > --- a/include/libcamera/meson.build\n> > > > +++ b/include/libcamera/meson.build\n> > > > @@ -76,12 +76,13 @@ foreach mode, entry : controls_map\n> > > >      endif\n> > > >\n> > > >      template_file = files(outfile + '.in')\n> > > > +    ranges_file = files('../../src/libcamera/control_ranges.yaml')\n> > > >      control_headers += custom_target(header + '_h',\n> > > >                                       input : input_files,\n> > > >                                       output : outfile,\n> > > >                                       command : [gen_controls, '-o', '@OUTPUT@',\n> > > >                                                  '--mode', mode, '-t', template_file,\n> > > > -                                                '@INPUT@'],\n> > > > +                                                '-r', ranges_file, '@INPUT@'],\n> > > >                                       install : true,\n> > > >                                       install_dir : libcamera_headers_install_dir)\n> > > >  endforeach\n> > > > diff --git a/src/libcamera/control_ranges.yaml b/src/libcamera/control_ranges.yaml\n> > > > new file mode 100644\n> > > > index 000000000000..d42447d04647\n> > > > --- /dev/null\n> > > > +++ b/src/libcamera/control_ranges.yaml\n> > > > @@ -0,0 +1,18 @@\n> > > > +# SPDX-License-Identifier: LGPL-2.1-or-later\n> > > > +#\n> > > > +# Copyright (C) 2023, Raspberry Pi Ltd\n> > > > +#\n> > > > +%YAML 1.1\n> > > > +---\n> > > > +# Specifies the control id ranges/offsets for core/draft libcamera and vendor\n> > > > +# controls and properties.\n> > > > +ranges:\n> > > > +  # Core libcamera controls\n> > > > +  libcamera: 0\n> > > > +  # Draft designated libcamera controls\n> > > > +  draft: 10000\n> > > > +  # Raspberry Pi vendor controls\n> > > > +  rpi: 20000\n> > > > +  # Next range starts at 30000\n> > > > +\n> > > > +...\n> > > > diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build\n> > > > index 6d9902e6ffd1..45f63e932e4f 100644\n> > > > --- a/src/libcamera/meson.build\n> > > > +++ b/src/libcamera/meson.build\n> > > > @@ -141,11 +141,13 @@ foreach mode, input_files : controls_mode_files\n> > > >          template_file = files('property_ids.cpp.in')\n> > > >      endif\n> > > >\n> > > > +    ranges_file = files('control_ranges.yaml')\n> > > >      control_sources += custom_target(mode + '_cpp',\n> > > >                                       input : input_files,\n> > > >                                       output : mode + '_ids.cpp',\n> > > >                                       command : [gen_controls, '-o', '@OUTPUT@',\n> > > > -                                                '--mode', mode, '-t', template_file, '@INPUT@'])\n> > > > +                                                '--mode', mode, '-t', template_file,\n> > > > +                                                '-r', ranges_file, '@INPUT@'])\n> > > >  endforeach\n> > > >\n> > > >  libcamera_sources += control_sources\n> > > > diff --git a/utils/gen-controls.py b/utils/gen-controls.py\n> > > > index 30c58f35473c..04c63098b19b 100755\n> > > > --- a/utils/gen-controls.py\n> > > > +++ b/utils/gen-controls.py\n> > > > @@ -236,7 +236,7 @@ ${vendor_controls_str}\n> > > >      }\n> > > >\n> > > >\n> > > > -def generate_h(controls, mode):\n> > > > +def generate_h(controls, mode, ranges):\n> > > >      enum_template_start = string.Template('''enum ${name}Enum {''')\n> > > >      enum_value_template = string.Template('''\\t${name} = ${value},''')\n> > > >      enum_values_template = string.Template('''extern const std::array<const ControlValue, ${size}> ${name}Values;''')\n> > > > @@ -251,8 +251,10 @@ def generate_h(controls, mode):\n> > > >\n> > > >          vendor = 'draft' if ctrl.is_draft else ctrl.vendor\n> > > >          if vendor not in ctrls:\n> > > > +            if vendor not in ranges.keys():\n> > > > +                raise RuntimeError(f'Control id range is not defined for vendor {vendor}')\n> > > > +            id_value[vendor] = ranges[vendor] + 1\n> > > >              ids[vendor] = []\n> > > > -            id_value[vendor] = 1\n> > > >              ctrls[vendor] = []\n> > > >\n> > > >          # Core and draft controls use the same ID value\n> > > > @@ -338,13 +340,17 @@ def main(argv):\n> > > >                          help='Mode of operation')\n> > > >      parser.add_argument('--output', '-o', metavar='file', type=str,\n> > > >                          help='Output file name. Defaults to standard output if not specified.')\n> > > > +    parser.add_argument('--ranges', '-r', type=str, required=True,\n> > > > +                        help='Control id range reservation file.')\n> > > >      parser.add_argument('--template', '-t', dest='template', type=str, required=True,\n> > > >                          help='Template file name.')\n> > > >      parser.add_argument('input', type=str, nargs='+',\n> > > >                          help='Input file name.')\n> > > > -\n> > > >      args = parser.parse_args(argv[1:])\n> > > >\n> > > > +    data = open(args.ranges, 'rb').read()\n> > > > +    ranges = yaml.safe_load(data)['ranges']\n> > > > +\n> > > >      controls = []\n> > > >      for input in args.input:\n> > > >          data = open(input, 'rb').read()\n> > > > @@ -355,7 +361,7 @@ def main(argv):\n> > > >      if args.template.endswith('.cpp.in'):\n> > > >          data = generate_cpp(controls)\n> > > >      elif args.template.endswith('.h.in'):\n> > > > -        data = generate_h(controls, args.mode)\n> > > > +        data = generate_h(controls, args.mode, ranges)\n> > > >      else:\n> > > >          raise RuntimeError('Unknown template type')\n> > > >\n> > > > --\n> > > > 2.34.1\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 5E7FFBDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 28 Nov 2023 09:28:39 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 80C6D629C3;\n\tTue, 28 Nov 2023 10:28:38 +0100 (CET)","from mail-yw1-x1132.google.com (mail-yw1-x1132.google.com\n\t[IPv6:2607:f8b0:4864:20::1132])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5FE19629BC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 28 Nov 2023 10:28:36 +0100 (CET)","by mail-yw1-x1132.google.com with SMTP id\n\t00721157ae682-5cca68f6e01so51806587b3.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 28 Nov 2023 01:28:36 -0800 (PST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1701163718;\n\tbh=ZzLU5Hr7YHvylh7zGjqQHhBlLKtuLag1QAF+DjbN5EE=;\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=J425XWmUZfxwOzpeVlZNPVZz57mkFYCfBv2Ev1x3by1BoL9lTHsqpBh074G3W2bS0\n\t6O9NpVK693alIvJ8GrF9FH7ezJc5oP0dJD7Ja+N+rFwS7b4IuBEhIv+7Uty//FAZHw\n\tzwKIb4dlyUzUVsLZlLk21KKn4YnYYgcP3f3jR3C9e6p//fOPGgoIskOCE3cfvzihoZ\n\tGMaGJTRmuktErrnQQIeGpFYv8Vsk4Hc6rnf/ElcJoLC895gnD4IZ5/GUubY2gHE5NK\n\taDjdrDrO2WtzC/3fe5Es/r/sI7dKUIvTeal/o4MEAZ2RjGlYbA0rBkOw3bpibNmezL\n\tkYd+DkH9wwsag==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1701163715; x=1701768515;\n\tdarn=lists.libcamera.org; \n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:from:to:cc:subject:date:message-id:reply-to;\n\tbh=BpNzRpefPgOn4uNWNIUZA+e9KnjCI9wFELc5Ll0f1Ew=;\n\tb=h6oMp/kh9fwHG7FiDef6isxKb4TazwWEP3YV/t6Ebslpy6s2qZ2m94VWmNCTZNVe4U\n\t2Zzpscoz5IDapAqqWFSNF8edPELb1yTNY0eJstjtbMhU3tvnMfk/p8BcVryGyLQiOkWo\n\t2qSBqhduN9QSGWJSRqNKMXTl7RrvX3nr+t0ZSQivr8iChwK2kvLNydgUXtDgWzHxmysO\n\tzLcwAVetPBVTPeUpsc9C1KbZ60IsoIL+xaZhuVcAIh5HJxYVO47pUUwdEeOmdfkj20vw\n\tAU7UvX4BpViqfFlRNENlgy935G+zRKPGuJaSw1m6sMRFBa96tn+KS1N9owANT/uf6Ezp\n\tQGyw=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"h6oMp/kh\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1701163715; x=1701768515;\n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:x-gm-message-state:from:to:cc:subject:date:message-id\n\t:reply-to;\n\tbh=BpNzRpefPgOn4uNWNIUZA+e9KnjCI9wFELc5Ll0f1Ew=;\n\tb=csiWw+U4kWKT+V7PAnCPpLPoQ/h32h+ojmWS+/KA8KudW58QqpZGZvJoivIYdBWE9H\n\tW4UpOpfAgMyU7ZS8J7sHgSAbur6MHVBWlgY15iNoQwbApjT6xlOIp1DOEN6DjSw0Ev3S\n\tJu2wYoVG+Mk27nhbC82dASFIh3ws4bZ9fOV1c2CrmB12MYRQo5k1MATw+mzYaHSUghqt\n\tYL0GWPea4KUU7k/TVd0q7bO/0yfHEbCPPLi9oYCglglV4TuqNlknxZkwOp0myVkHQTyo\n\tt5yQ4yx2qmCUYA8ptdFpLxaP/iRrV0Dx6FTHH5C10ma1230lxox3eaQw6D47F0THpAat\n\tOBGg==","X-Gm-Message-State":"AOJu0YyQfCTHyme4MwBwtfcPqMbyD7rbzsyXMWsmkGizGoSvL70Ib1M7\n\t0z30g/zcyEtcVR3FzTa20jYpV2Yap5LRrgkRFz6FwZIIULWGmaeIb3M=","X-Google-Smtp-Source":"AGHT+IHinFnQBJROdzPAB22+Sc4rEpAjE/aaYIQzUD2e62/ShGnl9/YHQOL7owbCwGGq1C9cpxh8yopuaomrHCDUins=","X-Received":"by 2002:a81:6246:0:b0:5cc:c00:8d73 with SMTP id\n\tw67-20020a816246000000b005cc0c008d73mr15806142ywb.45.1701163715133;\n\tTue, 28 Nov 2023 01:28:35 -0800 (PST)","MIME-Version":"1.0","References":"<20231124123713.22519-1-naush@raspberrypi.com>\n\t<20231124123713.22519-5-naush@raspberrypi.com>\n\t<mwcgscav6yhxirrpfuqzgjaa6jlmntdd7iklrx7sgixgjf7epl@vplpbk2w5ytm>\n\t<CAEmqJPpTP5gj62=9=PbGD7zrT=NnmsJG-AAOn56Q9FOKX=4Hbg@mail.gmail.com>\n\t<kodmfzm25ty4vc7xowoesbxuufsr34sajgggie5hwwjnfgk2lk@wzt24y4vmg2s>","In-Reply-To":"<kodmfzm25ty4vc7xowoesbxuufsr34sajgggie5hwwjnfgk2lk@wzt24y4vmg2s>","Date":"Tue, 28 Nov 2023 09:28:08 +0000","Message-ID":"<CAEmqJPphV57vKgHyEM=0c+f4c-7DWoe5Q9MdQ3kWLkg=jt_rgg@mail.gmail.com>","To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Subject":"Re: [libcamera-devel] [PATCH v3 4/7] libcamera: control: Add vendor\n\tcontrol id range reservation","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@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":28190,"web_url":"https://patchwork.libcamera.org/comment/28190/","msgid":"<170116551912.630990.8467646397438655317@ping.linuxembedded.co.uk>","date":"2023-11-28T09:58:39","subject":"Re: [libcamera-devel] [PATCH v3 4/7] libcamera: control: Add vendor\n\tcontrol id range reservation","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Naushir Patuck via libcamera-devel (2023-11-28 09:28:08)\n> On Tue, 28 Nov 2023 at 09:24, Jacopo Mondi\n> <jacopo.mondi@ideasonboard.com> wrote:\n> >\n> > Hi Naush\n> >\n> > On Tue, Nov 28, 2023 at 09:21:05AM +0000, Naushir Patuck wrote:\n> > > Hi Jacopo,\n> > >\n> > > On Mon, 27 Nov 2023 at 16:54, Jacopo Mondi\n> > > <jacopo.mondi@ideasonboard.com> wrote:\n> > > >\n> > > > I wonder if it's worth passing this as param, as I suspect the\n> > > > enumeration of controls will be something that user won't change..\n> > >\n> > > I could do that, but that involves setting the vendor ranges in the\n> > > meson.build file somewhere and fetching it when calling the script.\n> > > Personally I prefer this living in a YAML file as this patch does, but\n> > > if folks want, I can move it into the build scripts.\n> > >\n> >\n> > I was not questioning the usage of the yaml file, that's fine.\n> > I was wondering if it's worth passing the ranges file name and\n> > location as parameter, or gen-controls.py can assume it knows where it\n> > lives..\n> \n> Ah, sorry I misunderstood! I did it as a parameter as all the inputs\n> seem to go through parameters, but again, I am happy to keep the\n> ranges file hardcoded in the script if folks think that's better.\n\nI likely wouldn't have asked to change it to be a parameter specified\nexternally, but as it's already there I think it's ok as is.\n\nThis script is specifically custom anyway, it doesn't have to be\ngeneric.\n\nHaving it specified in the meson build means we can likely handle things\neasier if we move the files around too.\n\nI anticipate once this lands we'll want to move and collate all\ncontrols into a subdir to group the likely expansions here, but we don't\nneed to do that as part of this series.\n\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> \n> Naush\n> \n> \n> >\n> > > Regards,\n> > > Naush\n> > >\n> > > >\n> > > > On Fri, Nov 24, 2023 at 12:37:10PM +0000, Naushir Patuck via libcamera-devel wrote:\n> > > > > Add a new control_ranges.yaml file that is used to reserve control id\n> > > > > ranges/offsets for libcamera and vendor specific controls. This file is\n> > > > > used by the gen-controls.py script to generate control id values for\n> > > > > each control.\n> > > > >\n> > > > > Draft controls now have a separate range from core libcamera controls,\n> > > > > breaking the existing numbering behaviour.\n> > > > >\n> > > > > Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> > > > > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > > > > ---\n> > > > >  include/libcamera/meson.build     |  3 ++-\n> > > > >  src/libcamera/control_ranges.yaml | 18 ++++++++++++++++++\n> > > > >  src/libcamera/meson.build         |  4 +++-\n> > > > >  utils/gen-controls.py             | 14 ++++++++++----\n> > > > >  4 files changed, 33 insertions(+), 6 deletions(-)\n> > > > >  create mode 100644 src/libcamera/control_ranges.yaml\n> > > > >\n> > > > > diff --git a/include/libcamera/meson.build b/include/libcamera/meson.build\n> > > > > index a763c8ff4344..79187d3fdfc9 100644\n> > > > > --- a/include/libcamera/meson.build\n> > > > > +++ b/include/libcamera/meson.build\n> > > > > @@ -76,12 +76,13 @@ foreach mode, entry : controls_map\n> > > > >      endif\n> > > > >\n> > > > >      template_file = files(outfile + '.in')\n> > > > > +    ranges_file = files('../../src/libcamera/control_ranges.yaml')\n> > > > >      control_headers += custom_target(header + '_h',\n> > > > >                                       input : input_files,\n> > > > >                                       output : outfile,\n> > > > >                                       command : [gen_controls, '-o', '@OUTPUT@',\n> > > > >                                                  '--mode', mode, '-t', template_file,\n> > > > > -                                                '@INPUT@'],\n> > > > > +                                                '-r', ranges_file, '@INPUT@'],\n> > > > >                                       install : true,\n> > > > >                                       install_dir : libcamera_headers_install_dir)\n> > > > >  endforeach\n> > > > > diff --git a/src/libcamera/control_ranges.yaml b/src/libcamera/control_ranges.yaml\n> > > > > new file mode 100644\n> > > > > index 000000000000..d42447d04647\n> > > > > --- /dev/null\n> > > > > +++ b/src/libcamera/control_ranges.yaml\n> > > > > @@ -0,0 +1,18 @@\n> > > > > +# SPDX-License-Identifier: LGPL-2.1-or-later\n> > > > > +#\n> > > > > +# Copyright (C) 2023, Raspberry Pi Ltd\n> > > > > +#\n> > > > > +%YAML 1.1\n> > > > > +---\n> > > > > +# Specifies the control id ranges/offsets for core/draft libcamera and vendor\n> > > > > +# controls and properties.\n> > > > > +ranges:\n> > > > > +  # Core libcamera controls\n> > > > > +  libcamera: 0\n> > > > > +  # Draft designated libcamera controls\n> > > > > +  draft: 10000\n> > > > > +  # Raspberry Pi vendor controls\n> > > > > +  rpi: 20000\n> > > > > +  # Next range starts at 30000\n> > > > > +\n> > > > > +...\n> > > > > diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build\n> > > > > index 6d9902e6ffd1..45f63e932e4f 100644\n> > > > > --- a/src/libcamera/meson.build\n> > > > > +++ b/src/libcamera/meson.build\n> > > > > @@ -141,11 +141,13 @@ foreach mode, input_files : controls_mode_files\n> > > > >          template_file = files('property_ids.cpp.in')\n> > > > >      endif\n> > > > >\n> > > > > +    ranges_file = files('control_ranges.yaml')\n> > > > >      control_sources += custom_target(mode + '_cpp',\n> > > > >                                       input : input_files,\n> > > > >                                       output : mode + '_ids.cpp',\n> > > > >                                       command : [gen_controls, '-o', '@OUTPUT@',\n> > > > > -                                                '--mode', mode, '-t', template_file, '@INPUT@'])\n> > > > > +                                                '--mode', mode, '-t', template_file,\n> > > > > +                                                '-r', ranges_file, '@INPUT@'])\n> > > > >  endforeach\n> > > > >\n> > > > >  libcamera_sources += control_sources\n> > > > > diff --git a/utils/gen-controls.py b/utils/gen-controls.py\n> > > > > index 30c58f35473c..04c63098b19b 100755\n> > > > > --- a/utils/gen-controls.py\n> > > > > +++ b/utils/gen-controls.py\n> > > > > @@ -236,7 +236,7 @@ ${vendor_controls_str}\n> > > > >      }\n> > > > >\n> > > > >\n> > > > > -def generate_h(controls, mode):\n> > > > > +def generate_h(controls, mode, ranges):\n> > > > >      enum_template_start = string.Template('''enum ${name}Enum {''')\n> > > > >      enum_value_template = string.Template('''\\t${name} = ${value},''')\n> > > > >      enum_values_template = string.Template('''extern const std::array<const ControlValue, ${size}> ${name}Values;''')\n> > > > > @@ -251,8 +251,10 @@ def generate_h(controls, mode):\n> > > > >\n> > > > >          vendor = 'draft' if ctrl.is_draft else ctrl.vendor\n> > > > >          if vendor not in ctrls:\n> > > > > +            if vendor not in ranges.keys():\n> > > > > +                raise RuntimeError(f'Control id range is not defined for vendor {vendor}')\n> > > > > +            id_value[vendor] = ranges[vendor] + 1\n> > > > >              ids[vendor] = []\n> > > > > -            id_value[vendor] = 1\n> > > > >              ctrls[vendor] = []\n> > > > >\n> > > > >          # Core and draft controls use the same ID value\n> > > > > @@ -338,13 +340,17 @@ def main(argv):\n> > > > >                          help='Mode of operation')\n> > > > >      parser.add_argument('--output', '-o', metavar='file', type=str,\n> > > > >                          help='Output file name. Defaults to standard output if not specified.')\n> > > > > +    parser.add_argument('--ranges', '-r', type=str, required=True,\n> > > > > +                        help='Control id range reservation file.')\n> > > > >      parser.add_argument('--template', '-t', dest='template', type=str, required=True,\n> > > > >                          help='Template file name.')\n> > > > >      parser.add_argument('input', type=str, nargs='+',\n> > > > >                          help='Input file name.')\n> > > > > -\n> > > > >      args = parser.parse_args(argv[1:])\n> > > > >\n> > > > > +    data = open(args.ranges, 'rb').read()\n> > > > > +    ranges = yaml.safe_load(data)['ranges']\n> > > > > +\n> > > > >      controls = []\n> > > > >      for input in args.input:\n> > > > >          data = open(input, 'rb').read()\n> > > > > @@ -355,7 +361,7 @@ def main(argv):\n> > > > >      if args.template.endswith('.cpp.in'):\n> > > > >          data = generate_cpp(controls)\n> > > > >      elif args.template.endswith('.h.in'):\n> > > > > -        data = generate_h(controls, args.mode)\n> > > > > +        data = generate_h(controls, args.mode, ranges)\n> > > > >      else:\n> > > > >          raise RuntimeError('Unknown template type')\n> > > > >\n> > > > > --\n> > > > > 2.34.1\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 17297C31E9\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 28 Nov 2023 09:58:44 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 70938629BC;\n\tTue, 28 Nov 2023 10:58:43 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B58D261DA5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 28 Nov 2023 10:58:41 +0100 (CET)","from pendragon.ideasonboard.com\n\t(aztw-30-b2-v4wan-166917-cust845.vm26.cable.virginm.net\n\t[82.37.23.78])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 7097F289;\n\tTue, 28 Nov 2023 10:58:06 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1701165523;\n\tbh=1svDVfk2SJKwTlqiwXk4txcGFJ1JjFuf6oPIgZsbx6U=;\n\th=In-Reply-To:References:To:Date:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=sLUMlZ0ns2J6dqAty/DRO5sYgcZ52cEnFRLINdx1sE0UcA8ErXKT5QD63VKL2pKg8\n\twqzlfHuleK7KDVCOLMNK8ZsFBAqXqmJr4UV0Mwt0FlSNTqirzUJScO/4NweUOQPaO3\n\tqsjf2ivJwrZyPtdRevvDM/M0Ze4PQxm5pfuEHSjTzyOh95rFV9vsnBrLLEWwzoy0jd\n\tbANrYwhIFEaKi+jeMA3N0hmPqQM20csnT8hNcYqGMrtkjPCMUB01hAzxYJ/YzYQPgv\n\tqOWn+y61PRzhBgppHOYqdEB/OAhOLcnHXLkP3Fl9fTLQDBghSJN2HebRvEEZrTJhgr\n\t6VR6MJawM/YaQ==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1701165486;\n\tbh=1svDVfk2SJKwTlqiwXk4txcGFJ1JjFuf6oPIgZsbx6U=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=gDFvrN01Yycr013GSPA0z9qA8wyuqKX6L4dvPUL/wfW1P2XwjGFGv4dFAFUPV0MU1\n\tbO7rd3mwPIIxp+YgbNF+Hrd0RRLSm4bPsRMpSIYHN3xWTJEwBtsogTQlvnFhjKjR0v\n\tXbDXBVVJDoH5iQTKYFGK5k34vH1iBCLtVGeoep4A="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"gDFvrN01\"; dkim-atps=neutral","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<CAEmqJPphV57vKgHyEM=0c+f4c-7DWoe5Q9MdQ3kWLkg=jt_rgg@mail.gmail.com>","References":"<20231124123713.22519-1-naush@raspberrypi.com>\n\t<20231124123713.22519-5-naush@raspberrypi.com>\n\t<mwcgscav6yhxirrpfuqzgjaa6jlmntdd7iklrx7sgixgjf7epl@vplpbk2w5ytm>\n\t<CAEmqJPpTP5gj62=9=PbGD7zrT=NnmsJG-AAOn56Q9FOKX=4Hbg@mail.gmail.com>\n\t<kodmfzm25ty4vc7xowoesbxuufsr34sajgggie5hwwjnfgk2lk@wzt24y4vmg2s>\n\t<CAEmqJPphV57vKgHyEM=0c+f4c-7DWoe5Q9MdQ3kWLkg=jt_rgg@mail.gmail.com>","To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>,\n\tNaushir Patuck <naush@raspberrypi.com>,\n\tNaushir Patuck via libcamera-devel <libcamera-devel@lists.libcamera.org>","Date":"Tue, 28 Nov 2023 09:58:39 +0000","Message-ID":"<170116551912.630990.8467646397438655317@ping.linuxembedded.co.uk>","User-Agent":"alot/0.10","Subject":"Re: [libcamera-devel] [PATCH v3 4/7] libcamera: control: Add vendor\n\tcontrol id range reservation","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":"Kieran Bingham via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":28192,"web_url":"https://patchwork.libcamera.org/comment/28192/","msgid":"<3njl4cln6csyndybjwjconsw3j4xz2y6pbndynu65lefwboigq@e66ikouzjoec>","date":"2023-11-28T10:03:30","subject":"Re: [libcamera-devel] [PATCH v3 4/7] libcamera: control: Add vendor\n\tcontrol id range reservation","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/people/143/","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"content":"Hi\n\nOn Tue, Nov 28, 2023 at 09:58:39AM +0000, Kieran Bingham via libcamera-devel wrote:\n> Quoting Naushir Patuck via libcamera-devel (2023-11-28 09:28:08)\n> > On Tue, 28 Nov 2023 at 09:24, Jacopo Mondi\n> > <jacopo.mondi@ideasonboard.com> wrote:\n> > >\n> > > Hi Naush\n> > >\n> > > On Tue, Nov 28, 2023 at 09:21:05AM +0000, Naushir Patuck wrote:\n> > > > Hi Jacopo,\n> > > >\n> > > > On Mon, 27 Nov 2023 at 16:54, Jacopo Mondi\n> > > > <jacopo.mondi@ideasonboard.com> wrote:\n> > > > >\n> > > > > I wonder if it's worth passing this as param, as I suspect the\n> > > > > enumeration of controls will be something that user won't change..\n> > > >\n> > > > I could do that, but that involves setting the vendor ranges in the\n> > > > meson.build file somewhere and fetching it when calling the script.\n> > > > Personally I prefer this living in a YAML file as this patch does, but\n> > > > if folks want, I can move it into the build scripts.\n> > > >\n> > >\n> > > I was not questioning the usage of the yaml file, that's fine.\n> > > I was wondering if it's worth passing the ranges file name and\n> > > location as parameter, or gen-controls.py can assume it knows where it\n> > > lives..\n> >\n> > Ah, sorry I misunderstood! I did it as a parameter as all the inputs\n> > seem to go through parameters, but again, I am happy to keep the\n> > ranges file hardcoded in the script if folks think that's better.\n>\n> I likely wouldn't have asked to change it to be a parameter specified\n> externally, but as it's already there I think it's ok as is.\n>\n> This script is specifically custom anyway, it doesn't have to be\n> generic.\n>\n> Having it specified in the meson build means we can likely handle things\n> easier if we move the files around too.\n>\n\nYeah, mine was defintely more a question more than a requirement, I\nthink it's fine too\n\n> I anticipate once this lands we'll want to move and collate all\n> controls into a subdir to group the likely expansions here, but we don't\n> need to do that as part of this series.\n>\n>\n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n>\n\nAnd seems I forgot my tag\nReviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n\nThanks\n  j\n\n> >\n> > Naush\n> >\n> >\n> > >\n> > > > Regards,\n> > > > Naush\n> > > >\n> > > > >\n> > > > > On Fri, Nov 24, 2023 at 12:37:10PM +0000, Naushir Patuck via libcamera-devel wrote:\n> > > > > > Add a new control_ranges.yaml file that is used to reserve control id\n> > > > > > ranges/offsets for libcamera and vendor specific controls. This file is\n> > > > > > used by the gen-controls.py script to generate control id values for\n> > > > > > each control.\n> > > > > >\n> > > > > > Draft controls now have a separate range from core libcamera controls,\n> > > > > > breaking the existing numbering behaviour.\n> > > > > >\n> > > > > > Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> > > > > > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > > > > > ---\n> > > > > >  include/libcamera/meson.build     |  3 ++-\n> > > > > >  src/libcamera/control_ranges.yaml | 18 ++++++++++++++++++\n> > > > > >  src/libcamera/meson.build         |  4 +++-\n> > > > > >  utils/gen-controls.py             | 14 ++++++++++----\n> > > > > >  4 files changed, 33 insertions(+), 6 deletions(-)\n> > > > > >  create mode 100644 src/libcamera/control_ranges.yaml\n> > > > > >\n> > > > > > diff --git a/include/libcamera/meson.build b/include/libcamera/meson.build\n> > > > > > index a763c8ff4344..79187d3fdfc9 100644\n> > > > > > --- a/include/libcamera/meson.build\n> > > > > > +++ b/include/libcamera/meson.build\n> > > > > > @@ -76,12 +76,13 @@ foreach mode, entry : controls_map\n> > > > > >      endif\n> > > > > >\n> > > > > >      template_file = files(outfile + '.in')\n> > > > > > +    ranges_file = files('../../src/libcamera/control_ranges.yaml')\n> > > > > >      control_headers += custom_target(header + '_h',\n> > > > > >                                       input : input_files,\n> > > > > >                                       output : outfile,\n> > > > > >                                       command : [gen_controls, '-o', '@OUTPUT@',\n> > > > > >                                                  '--mode', mode, '-t', template_file,\n> > > > > > -                                                '@INPUT@'],\n> > > > > > +                                                '-r', ranges_file, '@INPUT@'],\n> > > > > >                                       install : true,\n> > > > > >                                       install_dir : libcamera_headers_install_dir)\n> > > > > >  endforeach\n> > > > > > diff --git a/src/libcamera/control_ranges.yaml b/src/libcamera/control_ranges.yaml\n> > > > > > new file mode 100644\n> > > > > > index 000000000000..d42447d04647\n> > > > > > --- /dev/null\n> > > > > > +++ b/src/libcamera/control_ranges.yaml\n> > > > > > @@ -0,0 +1,18 @@\n> > > > > > +# SPDX-License-Identifier: LGPL-2.1-or-later\n> > > > > > +#\n> > > > > > +# Copyright (C) 2023, Raspberry Pi Ltd\n> > > > > > +#\n> > > > > > +%YAML 1.1\n> > > > > > +---\n> > > > > > +# Specifies the control id ranges/offsets for core/draft libcamera and vendor\n> > > > > > +# controls and properties.\n> > > > > > +ranges:\n> > > > > > +  # Core libcamera controls\n> > > > > > +  libcamera: 0\n> > > > > > +  # Draft designated libcamera controls\n> > > > > > +  draft: 10000\n> > > > > > +  # Raspberry Pi vendor controls\n> > > > > > +  rpi: 20000\n> > > > > > +  # Next range starts at 30000\n> > > > > > +\n> > > > > > +...\n> > > > > > diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build\n> > > > > > index 6d9902e6ffd1..45f63e932e4f 100644\n> > > > > > --- a/src/libcamera/meson.build\n> > > > > > +++ b/src/libcamera/meson.build\n> > > > > > @@ -141,11 +141,13 @@ foreach mode, input_files : controls_mode_files\n> > > > > >          template_file = files('property_ids.cpp.in')\n> > > > > >      endif\n> > > > > >\n> > > > > > +    ranges_file = files('control_ranges.yaml')\n> > > > > >      control_sources += custom_target(mode + '_cpp',\n> > > > > >                                       input : input_files,\n> > > > > >                                       output : mode + '_ids.cpp',\n> > > > > >                                       command : [gen_controls, '-o', '@OUTPUT@',\n> > > > > > -                                                '--mode', mode, '-t', template_file, '@INPUT@'])\n> > > > > > +                                                '--mode', mode, '-t', template_file,\n> > > > > > +                                                '-r', ranges_file, '@INPUT@'])\n> > > > > >  endforeach\n> > > > > >\n> > > > > >  libcamera_sources += control_sources\n> > > > > > diff --git a/utils/gen-controls.py b/utils/gen-controls.py\n> > > > > > index 30c58f35473c..04c63098b19b 100755\n> > > > > > --- a/utils/gen-controls.py\n> > > > > > +++ b/utils/gen-controls.py\n> > > > > > @@ -236,7 +236,7 @@ ${vendor_controls_str}\n> > > > > >      }\n> > > > > >\n> > > > > >\n> > > > > > -def generate_h(controls, mode):\n> > > > > > +def generate_h(controls, mode, ranges):\n> > > > > >      enum_template_start = string.Template('''enum ${name}Enum {''')\n> > > > > >      enum_value_template = string.Template('''\\t${name} = ${value},''')\n> > > > > >      enum_values_template = string.Template('''extern const std::array<const ControlValue, ${size}> ${name}Values;''')\n> > > > > > @@ -251,8 +251,10 @@ def generate_h(controls, mode):\n> > > > > >\n> > > > > >          vendor = 'draft' if ctrl.is_draft else ctrl.vendor\n> > > > > >          if vendor not in ctrls:\n> > > > > > +            if vendor not in ranges.keys():\n> > > > > > +                raise RuntimeError(f'Control id range is not defined for vendor {vendor}')\n> > > > > > +            id_value[vendor] = ranges[vendor] + 1\n> > > > > >              ids[vendor] = []\n> > > > > > -            id_value[vendor] = 1\n> > > > > >              ctrls[vendor] = []\n> > > > > >\n> > > > > >          # Core and draft controls use the same ID value\n> > > > > > @@ -338,13 +340,17 @@ def main(argv):\n> > > > > >                          help='Mode of operation')\n> > > > > >      parser.add_argument('--output', '-o', metavar='file', type=str,\n> > > > > >                          help='Output file name. Defaults to standard output if not specified.')\n> > > > > > +    parser.add_argument('--ranges', '-r', type=str, required=True,\n> > > > > > +                        help='Control id range reservation file.')\n> > > > > >      parser.add_argument('--template', '-t', dest='template', type=str, required=True,\n> > > > > >                          help='Template file name.')\n> > > > > >      parser.add_argument('input', type=str, nargs='+',\n> > > > > >                          help='Input file name.')\n> > > > > > -\n> > > > > >      args = parser.parse_args(argv[1:])\n> > > > > >\n> > > > > > +    data = open(args.ranges, 'rb').read()\n> > > > > > +    ranges = yaml.safe_load(data)['ranges']\n> > > > > > +\n> > > > > >      controls = []\n> > > > > >      for input in args.input:\n> > > > > >          data = open(input, 'rb').read()\n> > > > > > @@ -355,7 +361,7 @@ def main(argv):\n> > > > > >      if args.template.endswith('.cpp.in'):\n> > > > > >          data = generate_cpp(controls)\n> > > > > >      elif args.template.endswith('.h.in'):\n> > > > > > -        data = generate_h(controls, args.mode)\n> > > > > > +        data = generate_h(controls, args.mode, ranges)\n> > > > > >      else:\n> > > > > >          raise RuntimeError('Unknown template type')\n> > > > > >\n> > > > > > --\n> > > > > > 2.34.1\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 ED809BDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 28 Nov 2023 10:03:33 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A2592629BD;\n\tTue, 28 Nov 2023 11:03:33 +0100 (CET)","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 B014361DA5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 28 Nov 2023 11:03:32 +0100 (CET)","from ideasonboard.com (93-61-96-190.ip145.fastwebnet.it\n\t[93.61.96.190])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 8CE36BB2;\n\tTue, 28 Nov 2023 11:02:57 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1701165813;\n\tbh=hKVoxxwIGwG18C8h5Lx6OCxgJunSI8wfJuJyjrNZN4M=;\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=0+FI/1MCnWYjZmNMQMCbrym3QCM8xuUJaRkjBwO/lqy3EyggNnYPoNG0O9GQy7gt5\n\tkQLhMvLXztbtz6dTNIteZf4HzQnQ79RmpJ3hL8CgkFruRyHZSzy7phD+3HdVTx3uMp\n\t4pX36fBGkZUEKXmvyAPhYE7X7Z5YaWfCXxfOiuoq2PpJ4jxcFLGajB4RtBrmgWDKXM\n\tvnkvPzfIri/f7KORWdOATs3NVZRjWZt/fqmMnbHlVS+GGAI3M20qSOXF32BEnAjIxE\n\tUdVVSVQpPU0tXCOf+nM/00xHOIFFFAeG6SGa/RZ17htx0ayiIImUsKQ0BRByV0GWKN\n\tzXJTHJNmHD7ew==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1701165777;\n\tbh=hKVoxxwIGwG18C8h5Lx6OCxgJunSI8wfJuJyjrNZN4M=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=ozlJTIu1emy/g8K8l/5WE6xkzKOojkPysyWhCOZ1NIRVpr6muUYiriAnbC4tdGp3q\n\tpeKwEFamiG+mgRYxqKT8bRiHTNxmqpjVqo4jFZiPiNcJgGZqEa0bUgQFbfxuCb89+4\n\tWLwGbTwX4YNzYQEz1VGrPs1PAVEi8chcdZ2aW8W0="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"ozlJTIu1\"; dkim-atps=neutral","Date":"Tue, 28 Nov 2023 11:03:30 +0100","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Message-ID":"<3njl4cln6csyndybjwjconsw3j4xz2y6pbndynu65lefwboigq@e66ikouzjoec>","References":"<20231124123713.22519-1-naush@raspberrypi.com>\n\t<20231124123713.22519-5-naush@raspberrypi.com>\n\t<mwcgscav6yhxirrpfuqzgjaa6jlmntdd7iklrx7sgixgjf7epl@vplpbk2w5ytm>\n\t<CAEmqJPpTP5gj62=9=PbGD7zrT=NnmsJG-AAOn56Q9FOKX=4Hbg@mail.gmail.com>\n\t<kodmfzm25ty4vc7xowoesbxuufsr34sajgggie5hwwjnfgk2lk@wzt24y4vmg2s>\n\t<CAEmqJPphV57vKgHyEM=0c+f4c-7DWoe5Q9MdQ3kWLkg=jt_rgg@mail.gmail.com>\n\t<170116551912.630990.8467646397438655317@ping.linuxembedded.co.uk>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<170116551912.630990.8467646397438655317@ping.linuxembedded.co.uk>","Subject":"Re: [libcamera-devel] [PATCH v3 4/7] libcamera: control: Add vendor\n\tcontrol id range reservation","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":"Jacopo Mondi via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","Cc":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>,\n\tNaushir Patuck via libcamera-devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]