[{"id":1081,"web_url":"https://patchwork.libcamera.org/comment/1081/","msgid":"<20190321084636.GE4615@pendragon.ideasonboard.com>","date":"2019-03-21T08:46:36","subject":"Re: [libcamera-devel] [PATCH v4 02/31] libcamera: formats: Define\n\tFormatEnum type","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jacopo,\n\nThank you for the patch.\n\nOn Wed, Mar 20, 2019 at 05:30:26PM +0100, Jacopo Mondi wrote:\n> Add an internal format.h and format.cpp files to collect libcamera image\n> format related types, helpers and structures. Define and document the\n> FormatEnum type, used to enumerate pixel image formats and associated\n> image resolutions.\n> \n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> Signed-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\n> \n> diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp\n> new file mode 100644\n> index 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\nThe terms used in V4L2 are either pixel format or media bus code, not\npixel code. I would write \"The type associates in a map a pixel format\n(for memory formats) or media bus code (for bus formats), ...\".\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> + * wire image formats, to a vector of image resolutions represented by SizeRange\n> + * items.\n> + */\n> +\n> +} /* namespace libcamera */\n> diff --git a/src/libcamera/include/formats.h b/src/libcamera/include/formats.h\n> new file mode 100644\n> index 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__ */\n> diff --git a/src/libcamera/include/v4l2_subdevice.h b/src/libcamera/include/v4l2_subdevice.h\n> index 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);\n> diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build\n> index 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',\n> diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp\n> index 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>","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["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 D83BB600F9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 21 Mar 2019 09:46:47 +0100 (CET)","from pendragon.ideasonboard.com (30.net042126252.t-com.ne.jp\n\t[42.126.252.30])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 6F60723A;\n\tThu, 21 Mar 2019 09:46:46 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1553158007;\n\tbh=NrmdRVXxFOswpnUrVJ3U7Caf3NVyx8Tzk0ppYut9r1I=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=LSoXXN45Du0/jVuQTSlAf+lYBWTR4bDOV4IRfAGXzUvAasQB+59YWt7Rl6zmGUAW7\n\tPpGizxY5qOBhLoqR1YGxOpqBqohr7HqFeo+fSTDAu7QUKZ3DeMBWjlpJzuTPv8C7xU\n\tSS+0cMapQ40Om8wdtuhCzmzm0TgripjMLOaoBtiU=","Date":"Thu, 21 Mar 2019 10:46:36 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190321084636.GE4615@pendragon.ideasonboard.com>","References":"<20190320163055.22056-1-jacopo@jmondi.org>\n\t<20190320163055.22056-3-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20190320163055.22056-3-jacopo@jmondi.org>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [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":"Thu, 21 Mar 2019 08:46:48 -0000"}}]