{"id":2544,"url":"https://patchwork.libcamera.org/api/patches/2544/?format=json","web_url":"https://patchwork.libcamera.org/patch/2544/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20200108232509.5043-1-jacopo@jmondi.org>","date":"2020-01-08T23:25:09","name":"[libcamera-devel,v4,03/10] libcamera: properties: Generate libcamera properties","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"5c4ded8ee869c10615a0e4baf14adff756935915","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/?format=json","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/2544/mbox/","series":[{"id":612,"url":"https://patchwork.libcamera.org/api/series/612/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=612","date":"2020-01-08T23:25:09","name":null,"version":4,"mbox":"https://patchwork.libcamera.org/series/612/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/2544/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/2544/checks/","tags":{},"headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net\n\t[217.70.183.197])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C6CB26045D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  9 Jan 2020 00:22:51 +0100 (CET)","from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 4DC561C0003;\n\tWed,  8 Jan 2020 23:22:51 +0000 (UTC)"],"X-Originating-IP":"2.224.242.101","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Thu,  9 Jan 2020 00:25:09 +0100","Message-Id":"<20200108232509.5043-1-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.24.0","In-Reply-To":"<20200108163434.19530-4-jacopo@jmondi.org>","References":"<20200108163434.19530-4-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v4 03/10] libcamera: properties: Generate\n\tlibcamera properties","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":"Wed, 08 Jan 2020 23:22:51 -0000"},"content":"Re-use the Control generation infrastructure to generate libcamera properties.\n\nIntroduce three additional files:\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 properties definitions\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n\nResending a new version as in the previoud rotation could had been defined in a\nway which required to use signed values, which is not nice.\n\nI've redefined here all rotation in counterclockwise direction, removing the\nneed for a sign.\n\nPlease look at this one and ignore the previous version.\n\nThanks\n  j\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     | 336 ++++++++++++++++++++++++++++\n 5 files changed, 442 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--\n2.24.0","diff":"diff --git a/include/libcamera/meson.build b/include/libcamera/meson.build\nindex 99abf0609940..25f503660960 100644\n--- a/include/libcamera/meson.build\n+++ b/include/libcamera/meson.build\n@@ -23,15 +23,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\ndiff --git a/include/libcamera/property_ids.h.in b/include/libcamera/property_ids.h.in\nnew file mode 100644\nindex 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__\ndiff --git a/src/libcamera/meson.build b/src/libcamera/meson.build\nindex c4f965bd7413..14aff6e5fc13 100644\n--- a/src/libcamera/meson.build\n+++ b/src/libcamera/meson.build\n@@ -67,14 +67,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\ndiff --git a/src/libcamera/property_ids.cpp.in b/src/libcamera/property_ids.cpp.in\nnew file mode 100644\nindex 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 */\ndiff --git a/src/libcamera/property_ids.yaml b/src/libcamera/property_ids.yaml\nnew file mode 100644\nindex 000000000000..b1bc6fed473c\n--- /dev/null\n+++ b/src/libcamera/property_ids.yaml\n@@ -0,0 +1,336 @@\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 facing side of the device\n+        - CameraLocationExternal:\n+          value: 2\n+          description: |\n+            The camera is attached to the device in a way that allows it to\n+            move freely\n+\n+  - Rotation:\n+      type: int32_t\n+      description: |\n+        The camera rotation is expressed as the angular difference in degrees\n+        between two reference systems, one implicitly defined by the camera\n+        module intrinsics characteristics, and one artificially defined on the\n+        external world scene to be captured when projected on the image sensor\n+        pixel array.\n+\n+        A camera sensor has an implicitly defined 2-dimensional reference\n+        system 'Rc' defined by its pixel array scan-out order, with its origin\n+        posed at pixel address (0,0), the x-axis progressing from there towards\n+        the last scanned out column of the pixel array and the y-axis\n+        progressing towards the last scanned out line.\n+\n+        A typical example for a sensor with a (2592x1944) pixel array matrix\n+        observed from the front is\n+\n+                   (2592)      x-axis          0\n+                      <------------------------+ 0\n+                      .......... ... ..........!\n+                      .......... ... ..........! y-axis\n+                                 ...           !\n+                      .......... ... ..........!\n+                      .......... ... ..........! (1944)\n+                                               V\n+\n+        The external world scene reference system scene 'Rs' is defined as a\n+        2-dimensional reference system on the parallel plane posed in front\n+        of the camera module's focal plane, with its origin placed on the\n+        visible top-left corner, the x-axis progressing towards the right from\n+        there and the y-axis progressing towards the bottom of the visible\n+        scene.\n+\n+        A typical example of a (very common) picture of a shark swimming from\n+        left to right is\n+\n+                                 x-axis\n+                   (0,0)---------------------->\n+                     !\n+                     !\n+                     !       |\\____)\\___\n+                     !       ) _____  __`<\n+                     !       |/     )/\n+                     !\n+                     V\n+                   y-axis\n+\n+        With the reference plane posed in front of the camera module and\n+        parallel to its focal plane\n+\n+                                   !\n+                                 / !\n+                                /  !\n+                               /   !\n+                        _     /    !\n+                     +-/ \\-+ /     !\n+                     | (o) |       ! 'Rs' reference plane\n+                     +-----+ \\     !\n+                              \\    !\n+                               \\   !\n+                                \\  !\n+                                 \\ !\n+                                   !\n+\n+        When projected on the sensor's pixel array, the image and the associated\n+        reference system 'Rs' are typically inverted, due to the camera module's\n+        lens optical inversion effect.\n+\n+        Assuming the above represented scene of the swimming shark, the lens\n+        inversion projects on the sensor pixel array the reference plane 'Rp'\n+\n+                  y-axis\n+                     ^\n+                     !\n+                     !       |\\_____)\\__\n+                     !       ) ____  ___.<\n+                     !       |/    )/\n+                     !\n+                     !\n+                   (0,0)---------------------->\n+                                 x-axis\n+\n+        The camera rotation property is then defined as the angular difference\n+        in counterclockwise direction between the origin of the camera reference\n+        system 'Rc', defined by the camera sensor scan-out direction and its\n+        mounting position, and the origin of the projected scene reference\n+        system 'Rp', result of the optical projection of the scene reference\n+        system 'Rs' on the sensor pixel array.\n+\n+        Examples\n+\n+        0 degrees camera rotation\n+\n+                          y-Rp\n+                    y-Rc   ^\n+                     ^     !\n+                     !     !\n+                     !     !\n+                     !     !\n+                     !     !\n+                     !     !\n+                     !   (0,0)---------------------->\n+                     !                 x-Rp\n+                   0 +------------------------------------->\n+                      0            x-Rc\n+\n+\n+                                     x-Rc          0\n+                           <------------------------+ 0\n+                                x-Rp                !\n+                     <-----------------------(0,0)  !\n+                                               !    !\n+                                               !    !\n+                                               !    !\n+                                               !    V\n+                                               !  y-Rc\n+                                               V\n+                                             y-Rp\n+\n+        90 degrees camera rotation\n+\n+                      0        y-Rc\n+                   0 +----------------------->\n+                     !\n+                     !    y-Rp\n+                     !     ^\n+                     !     !\n+                     !     !\n+                     !     !\n+                     !     !\n+                     !     !\n+                     !     !\n+                     !   (0,0)---------------------->\n+                     !                 x-Rp\n+                     !\n+                     V\n+                   x-Rc\n+\n+        180 degrees camera rotation\n+\n+                                   x-Cr          0\n+                         <------------------------+ 0\n+                     y-Rp                         !\n+                      ^                           !\n+                      !                           ! y-Cr\n+                      !                           !\n+                      !                           !\n+                      !                           V\n+                      !\n+                      !\n+                    (0,0)--------------------->\n+                                   x-Rp\n+\n+        270 degrees camera rotation\n+\n+                      0        y-Rc\n+                   0 +----------------------->\n+                     !            x-Rp\n+                     ! <-----------------------(0,0\n+                     !                           !\n+                     !                           !\n+                     !                           !\n+                     !                           !\n+                     !                           !\n+                     !                           V\n+                     !                         y-Rp\n+                     !\n+                     !\n+                     V\n+                   x-Rc\n+\n+\n+\n+        Example one - Webcam\n+\n+        A camera module installed on the user facing part of a laptop screen\n+        casing used for video calls. The captured images are meant to be\n+        displayed in landscape mode (width > height) on the laptop screen.\n+\n+        The camera is typically mounted 180 degrees rotated to compensate the\n+        lens optical inversion effect.\n+\n+                          y-Rp\n+                    y-Rc   ^\n+                     ^     !\n+                     !     !       |\\_____)\\__\n+                     !     !       ) ____  ___.<\n+                     !     !       |/    )/\n+                     !     !\n+                     !     !\n+                     !   (0,0)---------------------->\n+                     !                 x-Rp\n+                   0 +------------------------------------->\n+                      0                x-Rc\n+\n+        The two reference systems are aligned, the resulting camera rotation is\n+        0 degrees, no rotation correction should be applied to the resulting\n+        image once captured to memory buffers to correctly display it to users.\n+\n+                     +--------------------------+\n+                     !       |\\____)\\___        !\n+                     !       ) _____  __`<      !\n+                     !       |/     )/          !\n+                     +--------------------------+\n+\n+        If the camera module is not mounted 180 degrees rotated to compensate\n+        the lens optical inversion, the two reference system will result not\n+        aligned, with 'Rp' plane 180 degrees rotated in respect to the 'Rc'\n+        plane.\n+\n+                                   x-Rc          0\n+                         <------------------------+ 0\n+                     y-Rp                         !\n+                      ^                           !\n+                      !                           ! y-Rc\n+                      !      |\\_____)\\__          !\n+                      !      ) ____  ___.<        !\n+                      !      |/    )/             V\n+                      !\n+                      !\n+                    (0,0)--------------------->\n+                                   x-Rp\n+\n+        The image once captured to memory will then be 180 degrees rotated\n+\n+                     +--------------------------+\n+                     !          __/(_____/|     !\n+                     !        >.___  ____ (     !\n+                     !             \\(    \\|     !\n+                     +--------------------------+\n+\n+        A software rotation correction of 180 degrees should be applied to\n+        correctly display the image.\n+\n+                     +--------------------------+\n+                     !       |\\____)\\___        !\n+                     !       ) _____  __`<      !\n+                     !       |/     )/          !\n+                     +--------------------------+\n+\n+        Example two - Phone camera\n+\n+        A camera installed on the back-side of a mobile device facing away from\n+        the user. The captured images are meant to be displayed in portrait mode\n+        (height > width) to match the device screen orientation and the device\n+        usage orientation used when taking the picture.\n+\n+        The camera is typically mounted with its pixel array longer side aligned\n+        to the device longer side, 180 degrees rotated to compensate the lens\n+        optical inversion effect.\n+\n+                      0        y-Rc\n+                   0 +----------------------->\n+                     !\n+                     !    y-Rp\n+                     !     ^\n+                     !     !\n+                     !     !       |\\_____)\\__\n+                     !     !       ) ____  ___.<\n+                     !     !       |/    )/\n+                     !     !\n+                     !     !\n+                     !   (0,0)---------------------->\n+                     !                 x-Rp\n+                     !\n+                     !\n+                     V\n+                   x-Rc\n+\n+        The two reference systems are not aligned and the 'Rp' reference\n+        system is 90 degrees rotated in counterclockwise direction in respect\n+        to the 'Rc' reference system.\n+\n+        The image, when captured to memory buffer will be rotated.\n+\n+                     +---------------------------------------+\n+                     |                  _ _                  |\n+                     |                 \\   /                 |\n+                     |                  | |                  |\n+                     |                  | |                  |\n+                     |                  |  >                 |\n+                     |                 <  |                  |\n+                     |                  | |                  |\n+                     |                    .                  |\n+                     |                   V                   |\n+                     +---------------------------------------+\n+\n+        A correction of 90 degrees in counterclockwise direction has to be\n+        applied to correctly display the image in portrait mode on the device\n+        screen.\n+\n+                                +-----------------+\n+                                |                 |\n+                                |                 |\n+                                |                 |\n+                                |                 |\n+                                |                 |\n+                                |                 |\n+                                |  |\\____)\\___    |\n+                                |  ) _____  __`<  |\n+                                |  |/     )/      |\n+                                |                 |\n+                                |                 |\n+                                |                 |\n+                                |                 |\n+                                |                 |\n+                                +-----------------+\n+...\n","prefixes":["libcamera-devel","v4","03/10"]}