[{"id":3448,"web_url":"https://patchwork.libcamera.org/comment/3448/","msgid":"<20200114230154.GB942549@oden.dyn.berto.se>","date":"2020-01-14T23:01:54","subject":"Re: [libcamera-devel] [PATCH 03/23] libcamera: properties: Add\n\tlocation property","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Jacopo,\n\nThanks for your work.\n\nOn 2020-01-13 17:42:25 +0100, Jacopo Mondi wrote:\n> Re-use the Control generation infrastructure to generate libcamera properties\n> and define the first 'Location' property.\n> \n> Introduce three additional files:\n> \n> - include/libcamera/property_ids.h\n>   Defines the properties ids\n> \n> - src/libcamera/property_ids.cpp\n>   Defines the properties Control<> instances\n> \n> - src/libcamera/property_ids.yaml\n>   Provide the first 'Location' property definition.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\n> ---\n>  include/libcamera/meson.build       | 26 +++++++++++------\n>  include/libcamera/property_ids.h.in | 33 ++++++++++++++++++++++\n>  src/libcamera/meson.build           | 21 ++++++++------\n>  src/libcamera/property_ids.cpp.in   | 43 +++++++++++++++++++++++++++++\n>  src/libcamera/property_ids.yaml     | 28 +++++++++++++++++++\n>  5 files changed, 134 insertions(+), 17 deletions(-)\n>  create mode 100644 include/libcamera/property_ids.h.in\n>  create mode 100644 src/libcamera/property_ids.cpp.in\n>  create mode 100644 src/libcamera/property_ids.yaml\n> \n> diff --git a/include/libcamera/meson.build b/include/libcamera/meson.build\n> index 8db217bb782c..f58c02d2cf35 100644\n> --- a/include/libcamera/meson.build\n> +++ b/include/libcamera/meson.build\n> @@ -25,15 +25,23 @@ install_headers(libcamera_api,\n>  \n>  gen_controls = files('../../src/libcamera/gen-controls.py')\n>  \n> -control_ids_h = custom_target('control_ids_h',\n> -                              input : files('../../src/libcamera/control_ids.yaml', 'control_ids.h.in'),\n> -                              output : 'control_ids.h',\n> -                              depend_files : gen_controls,\n> -                              command : [gen_controls, '-o', '@OUTPUT@', '@INPUT@'],\n> -                              install : true,\n> -                              install_dir : join_paths('include', include_dir))\n> -\n> -libcamera_api += control_ids_h\n> +control_source_files = [\n> +    'control_ids',\n> +    'property_ids',\n> +]\n> +\n> +control_headers = []\n> +\n> +foreach header : control_source_files\n> +    input_files = files('../../src/libcamera/' + header +'.yaml', header + '.h.in')\n> +    control_headers += custom_target(header + '_h',\n> +                                     input : input_files,\n> +                                     output : header + '.h',\n> +                                     depend_files : gen_controls,\n> +                                     command : [gen_controls, '-o', '@OUTPUT@', '@INPUT@'],\n> +                                     install : true,\n> +                                     install_dir : join_paths('include', include_dir))\n> +endforeach\n>  \n>  gen_header = files('gen-header.sh')\n>  \n> diff --git a/include/libcamera/property_ids.h.in b/include/libcamera/property_ids.h.in\n> new file mode 100644\n> index 000000000000..62799b3e8c54\n> --- /dev/null\n> +++ b/include/libcamera/property_ids.h.in\n> @@ -0,0 +1,33 @@\n> +/* SPDX-License-Identifier: LGPL-2.1-or-later */\n> +/*\n> + * Copyright (C) 2019, Google Inc.\n> + *\n> + * property_ids.h : Property ID list\n> + *\n> + * This file is auto-generated. Do not edit.\n> + */\n> +\n> +#ifndef __LIBCAMERA_PROPERTY_IDS_H__\n> +#define __LIBCAMERA_PROPERTY_IDS_H__\n> +\n> +#include <stdint.h>\n> +\n> +#include <libcamera/controls.h>\n> +\n> +namespace libcamera {\n> +\n> +namespace properties {\n> +\n> +enum {\n> +${ids}\n> +};\n> +\n> +${controls}\n> +\n> +extern const ControlIdMap properties;\n> +\n> +} /* namespace propertiess */\n> +\n> +} /* namespace libcamera */\n> +\n> +#endif // __LIBCAMERA_PROPERTY_IDS_H__\n> diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build\n> index 68d89559b290..1e5b54b34078 100644\n> --- a/src/libcamera/meson.build\n> +++ b/src/libcamera/meson.build\n> @@ -69,14 +69,19 @@ endif\n>  \n>  gen_controls = files('gen-controls.py')\n>  \n> -control_ids_cpp = custom_target('control_ids_cpp',\n> -                                input : files('control_ids.yaml', 'control_ids.cpp.in'),\n> -                                output : 'control_ids.cpp',\n> -                                depend_files : gen_controls,\n> -                                command : [gen_controls, '-o', '@OUTPUT@', '@INPUT@'])\n> -\n> -libcamera_sources += control_ids_cpp\n> -libcamera_sources += control_ids_h\n> +control_sources = []\n> +\n> +foreach source : control_source_files\n> +    input_files = files(source +'.yaml', source + '.cpp.in')\n> +    control_sources += custom_target(source + '_cpp',\n> +                                     input : input_files,\n> +                                     output : source + '.cpp',\n> +                                     depend_files : gen_controls,\n> +                                     command : [gen_controls, '-o', '@OUTPUT@', '@INPUT@'])\n> +endforeach\n> +\n> +libcamera_sources += control_headers\n> +libcamera_sources += control_sources\n>  \n>  gen_version = join_paths(meson.source_root(), 'utils', 'gen-version.sh')\n>  \n> diff --git a/src/libcamera/property_ids.cpp.in b/src/libcamera/property_ids.cpp.in\n> new file mode 100644\n> index 000000000000..bfdd823f63b0\n> --- /dev/null\n> +++ b/src/libcamera/property_ids.cpp.in\n> @@ -0,0 +1,43 @@\n> +/* SPDX-License-Identifier: LGPL-2.1-or-later */\n> +/*\n> + * Copyright (C) 2019, Google Inc.\n> + *\n> + * property_ids.cpp : Property ID list\n> + *\n> + * This file is auto-generated. Do not edit.\n> + */\n> +\n> +#include <libcamera/property_ids.h>\n> +\n> +/**\n> + * \\file property_ids.h\n> + * \\brief Camera property identifiers\n> + */\n> +\n> +namespace libcamera {\n> +\n> +/**\n> + * \\brief Namespace for libcamera properties\n> + */\n> +namespace properties {\n> +\n> +${controls_doc}\n> +\n> +#ifndef __DOXYGEN__\n> +/*\n> + * Keep the properties definitions hidden from doxygen as it incorrectly parses\n> + * them as functions.\n> + */\n> +${controls_def}\n> +#endif\n> +\n> +/**\n> + * \\brief List of all supported libcamera properties\n> + */\n> +extern const ControlIdMap properties {\n> +${controls_map}\n> +};\n> +\n> +} /* namespace properties */\n> +\n> +} /* namespace libcamera */\n> diff --git a/src/libcamera/property_ids.yaml b/src/libcamera/property_ids.yaml\n> new file mode 100644\n> index 000000000000..aaadcbd3e52b\n> --- /dev/null\n> +++ b/src/libcamera/property_ids.yaml\n> @@ -0,0 +1,28 @@\n> +# SPDX-License-Identifier: LGPL-2.1-or-later\n> +#\n> +# Copyright (C) 2019, Google Inc.\n> +#\n> +%YAML 1.2\n> +---\n> +controls:\n> +  - Location:\n> +      type: int32_t\n> +      description: |\n> +        Camera mounting location\n> +      enum:\n> +        - CameraLocationFront:\n> +          value: 0\n> +          description: |\n> +            The camera is mounted on the front side of the device, facing the\n> +            user\n> +        - CameraLocationBack:\n> +          value: 1\n> +          description: |\n> +            The camera is mounted on the back side of the device, facing away\n> +            from the user\n> +        - CameraLocationExternal:\n> +          value: 2\n> +          description: |\n> +            The camera is attached to the device in a way that allows it to\n> +            be moved freely\n> +...\n> -- \n> 2.24.0\n> \n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","headers":{"Return-Path":"<niklas.soderlund@ragnatech.se>","Received":["from mail-lf1-x144.google.com (mail-lf1-x144.google.com\n\t[IPv6:2a00:1450:4864:20::144])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B330360705\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 15 Jan 2020 00:01:56 +0100 (CET)","by mail-lf1-x144.google.com with SMTP id v201so11161979lfa.11\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 14 Jan 2020 15:01:56 -0800 (PST)","from localhost (h-93-159.A463.priv.bahnhof.se. [46.59.93.159])\n\tby smtp.gmail.com with ESMTPSA id\n\td20sm8139010ljg.95.2020.01.14.15.01.54\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 14 Jan 2020 15:01:55 -0800 (PST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to;\n\tbh=ZQpWZdsvHAlvYBz/ryMn0snn2TJgP9DoY/unJVeA67Y=;\n\tb=oTytAyihiqtRuLPlS6tCZoluNX/fwTmHDtkRowIT0BL613e57mW0FeA+G5mdQ72TX/\n\tTy61wb9K6kMGuEpO41nx6K4sAQV0AgE/sbIfQRG8kST3nKoj7Mkhjn46hOQZD2Bqcnkj\n\tG3y/DGdBK26bvi1aamx3wxaMH5SJx9/4d4EhTu46L8HcKn8REtAlJC9DLBJGa8T/WlJA\n\tH96EhiIFfO56mTikyqJlpzzpqJTCIYQ/nU2pICvS7/Z5C/b7wU4ecfCHRbiHGBGTumsj\n\tuzC+bpu/R9LONflueGTH8qROoEFomJKWYy57A9HVNf8y9+CPbWrjP4RCTgDT+HHsxN9/\n\tzm/A==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to;\n\tbh=ZQpWZdsvHAlvYBz/ryMn0snn2TJgP9DoY/unJVeA67Y=;\n\tb=efPKCg8KC55Zb6f4zeyywgbdpqMhw5YBFYHDcpdSfLwGVAEQRSSHA26IHqmkQoYId+\n\tWbwCnZdGHcynFCBP7hmoCD43ang7YMX5lcOHC0eYJ2+maXQdHzisATHXQQS/JW3Uu0ya\n\tpQyywLsQSqR4O4YExKf93kgod4aZL2BKcNSkOrFdewPJ1gxq3oktFm1yqzlLRT30gkqg\n\tBHms60knZFMtmhfnL/s3zsew4lZJFWXUvgmCqNwnEsFrYT+/RHuxkitRsMhz9hyKHFPG\n\tkByCKwJ9gU4tjrKkTyr7GPYmE7jCC+M/Da5n4r1ZuGhD4/QQdCH4jiDJ8G6qyRzLEjcE\n\t55nQ==","X-Gm-Message-State":"APjAAAVgqJ6l+InbfZ4dswge+w/cXcasndHzai3Qiir7wALUPWH+a/he\n\tJAp8Ds44G+zwvEWbEnTqJtanjbUpHF4=","X-Google-Smtp-Source":"APXvYqwHgtMdMkBo52neYtyzfUPKvlEQFKrUZR/+TRwttICrnDJiHYF0I4UaTRuwkovbTR60F7+vFw==","X-Received":"by 2002:a05:6512:307:: with SMTP id\n\tt7mr3087060lfp.201.1579042915876; \n\tTue, 14 Jan 2020 15:01:55 -0800 (PST)","Date":"Wed, 15 Jan 2020 00:01:54 +0100","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20200114230154.GB942549@oden.dyn.berto.se>","References":"<20200113164245.52535-1-jacopo@jmondi.org>\n\t<20200113164245.52535-4-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=iso-8859-1","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20200113164245.52535-4-jacopo@jmondi.org>","Subject":"Re: [libcamera-devel] [PATCH 03/23] libcamera: properties: Add\n\tlocation property","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>","X-List-Received-Date":"Tue, 14 Jan 2020 23:01:56 -0000"}}]