{"id":748,"url":"https://patchwork.libcamera.org/api/patches/748/?format=json","web_url":"https://patchwork.libcamera.org/patch/748/","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":"<20190320163055.22056-3-jacopo@jmondi.org>","date":"2019-03-20T16:30:26","name":"[libcamera-devel,v4,02/31] libcamera: formats: Define FormatEnum type","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"0b034b5b24dad6dfe5180325f972d1addd3cba62","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/748/mbox/","series":[{"id":214,"url":"https://patchwork.libcamera.org/api/series/214/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=214","date":"2019-03-20T16:30:24","name":"libcamera: ipu3: Add ImgU support + multiple streams","version":4,"mbox":"https://patchwork.libcamera.org/series/214/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/748/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/748/checks/","tags":{},"headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay12.mail.gandi.net (relay12.mail.gandi.net\n\t[217.70.178.232])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 718876110D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 20 Mar 2019 17:30:29 +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 relay12.mail.gandi.net (Postfix) with ESMTPSA id C55C920000D;\n\tWed, 20 Mar 2019 16:30:28 +0000 (UTC)"],"From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Wed, 20 Mar 2019 17:30:26 +0100","Message-Id":"<20190320163055.22056-3-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.21.0","In-Reply-To":"<20190320163055.22056-1-jacopo@jmondi.org>","References":"<20190320163055.22056-1-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v4 02/31] libcamera: formats: Define\n\tFormatEnum type","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","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, 20 Mar 2019 16:30:30 -0000"},"content":"Add an internal format.h and format.cpp files to collect libcamera image\nformat related types, helpers and structures. Define and document the\nFormatEnum type, used to enumerate pixel image formats and associated\nimage resolutions.\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/libcamera/formats.cpp              | 27 ++++++++++++++++++++++++++\n src/libcamera/include/formats.h        | 22 +++++++++++++++++++++\n src/libcamera/include/v4l2_subdevice.h |  4 ++--\n src/libcamera/meson.build              |  1 +\n src/libcamera/v4l2_subdevice.cpp       |  5 ++---\n 5 files changed, 54 insertions(+), 5 deletions(-)\n create mode 100644 src/libcamera/formats.cpp\n create mode 100644 src/libcamera/include/formats.h","diff":"diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp\nnew file mode 100644\nindex 000000000000..a6251fe91cec\n--- /dev/null\n+++ b/src/libcamera/formats.cpp\n@@ -0,0 +1,27 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2019, Google Inc.\n+ *\n+ * formats.cpp - Libcamera image formats\n+ */\n+\n+#include \"formats.h\"\n+\n+/**\n+ * \\file formats.h\n+ * \\brief Types and helper methods to handle libcamera image formats\n+ */\n+\n+namespace libcamera {\n+\n+/**\n+ * \\typedef FormatEnum\n+ * \\brief Type definition for the map of image formats and sizes\n+ *\n+ * Type definition used to enumerate the supported pixel formats and image frame\n+ * sizes. The type associates in a map a pixel code, used to represent memory or\n+ * wire image formats, to a vector of image resolutions represented by SizeRange\n+ * items.\n+ */\n+\n+} /* namespace libcamera */\ndiff --git a/src/libcamera/include/formats.h b/src/libcamera/include/formats.h\nnew file mode 100644\nindex 000000000000..5fcfb11318e7\n--- /dev/null\n+++ b/src/libcamera/include/formats.h\n@@ -0,0 +1,22 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2019, Google Inc.\n+ *\n+ * formats.h - Libcamera image formats\n+ */\n+\n+#ifndef __LIBCAMERA_FORMATS_H__\n+#define __LIBCAMERA_FORMATS_H__\n+\n+#include <map>\n+#include <vector>\n+\n+#include \"geometry.h\"\n+\n+namespace libcamera {\n+\n+typedef std::map<unsigned int, std::vector<SizeRange>> FormatEnum;\n+\n+} /* namespace libcamera */\n+\n+#endif /* __LIBCAMERA_FORMATS_H__ */\ndiff --git a/src/libcamera/include/v4l2_subdevice.h b/src/libcamera/include/v4l2_subdevice.h\nindex 700e66bcddac..3ecf08514898 100644\n--- a/src/libcamera/include/v4l2_subdevice.h\n+++ b/src/libcamera/include/v4l2_subdevice.h\n@@ -11,6 +11,7 @@\n #include <string>\n #include <vector>\n \n+#include \"formats.h\"\n #include \"geometry.h\"\n #include \"log.h\"\n #include \"media_object.h\"\n@@ -42,8 +43,7 @@ public:\n \tint setCrop(unsigned int pad, Rectangle *rect);\n \tint setCompose(unsigned int pad, Rectangle *rect);\n \n-\tconst std::map<unsigned int, std::vector<SizeRange>>\n-\t\t\t\t\t\tformats(unsigned int pad);\n+\tFormatEnum formats(unsigned int pad);\n \n \tint getFormat(unsigned int pad, V4L2SubdeviceFormat *format);\n \tint setFormat(unsigned int pad, V4L2SubdeviceFormat *format);\ndiff --git a/src/libcamera/meson.build b/src/libcamera/meson.build\nindex 8384cd0af451..4433abfceca3 100644\n--- a/src/libcamera/meson.build\n+++ b/src/libcamera/meson.build\n@@ -6,6 +6,7 @@ libcamera_sources = files([\n     'event_dispatcher.cpp',\n     'event_dispatcher_poll.cpp',\n     'event_notifier.cpp',\n+    'formats.cpp',\n     'geometry.cpp',\n     'log.cpp',\n     'media_device.cpp',\ndiff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp\nindex 11d22da25728..7084f28c0be8 100644\n--- a/src/libcamera/v4l2_subdevice.cpp\n+++ b/src/libcamera/v4l2_subdevice.cpp\n@@ -210,10 +210,9 @@ int V4L2Subdevice::setCompose(unsigned int pad, Rectangle *rect)\n  * \\return A map of image formats associated with a list of image sizes, or\n  * an empty map on error or if the pad does not exist\n  */\n-const std::map<unsigned int, std::vector<SizeRange>>\n-V4L2Subdevice::formats(unsigned int pad)\n+FormatEnum V4L2Subdevice::formats(unsigned int pad)\n {\n-\tstd::map<unsigned int, std::vector<SizeRange>> formatMap = {};\n+\tFormatEnum formatMap = {};\n \tstruct v4l2_subdev_mbus_code_enum mbusEnum = {};\n \tint ret;\n \n","prefixes":["libcamera-devel","v4","02/31"]}