Patch Detail
Show a patch.
GET /api/patches/8907/?format=api
{ "id": 8907, "url": "https://patchwork.libcamera.org/api/patches/8907/?format=api", "web_url": "https://patchwork.libcamera.org/patch/8907/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20200721135541.2931205-4-niklas.soderlund@ragnatech.se>", "date": "2020-07-21T13:55:41", "name": "[libcamera-devel,v2,3/3] libcamera: v4l2_videodevice: Add using statement for format map", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "4b71d4416eaadcb27d3838471687cd09f57c3d0c", "submitter": { "id": 5, "url": "https://patchwork.libcamera.org/api/people/5/?format=api", "name": "Niklas Söderlund", "email": "niklas.soderlund@ragnatech.se" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/8907/mbox/", "series": [ { "id": 1123, "url": "https://patchwork.libcamera.org/api/series/1123/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1123", "date": "2020-07-21T13:55:38", "name": "libcamera: formats: Remove ImageFormat", "version": 2, "mbox": "https://patchwork.libcamera.org/series/1123/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/8907/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/8907/checks/", "tags": {}, "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 A0007C2E7B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 21 Jul 2020 13:55:59 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3BCBB60933;\n\tTue, 21 Jul 2020 15:55:59 +0200 (CEST)", "from bin-mail-out-05.binero.net (bin-mail-out-05.binero.net\n\t[195.74.38.228])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A69DA608E0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 21 Jul 2020 15:55:57 +0200 (CEST)", "from bismarck.berto.se (p4fca2eca.dip0.t-ipconnect.de\n\t[79.202.46.202]) by bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA\n\tid bedbcce0-cb59-11ea-86ee-0050569116f7;\n\tTue, 21 Jul 2020 15:54:51 +0200 (CEST)" ], "X-Halon-ID": "bedbcce0-cb59-11ea-86ee-0050569116f7", "Authorized-sender": "niklas@soderlund.pp.se", "From": "=?utf-8?q?Niklas_S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Tue, 21 Jul 2020 15:55:41 +0200", "Message-Id": "<20200721135541.2931205-4-niklas.soderlund@ragnatech.se>", "X-Mailer": "git-send-email 2.27.0", "In-Reply-To": "<20200721135541.2931205-1-niklas.soderlund@ragnatech.se>", "References": "<20200721135541.2931205-1-niklas.soderlund@ragnatech.se>", "MIME-Version": "1.0", "Subject": "[libcamera-devel] [PATCH v2 3/3] libcamera: v4l2_videodevice: Add\n\tusing statement for format map", "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>", "Content-Type": "text/plain; charset=\"utf-8\"", "Content-Transfer-Encoding": "base64", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "Define a using statement for the format maps returned by\nV4L2Device::formats() and use it in all call sites. There is no\nfunctional change in this patch.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n include/libcamera/internal/v4l2_videodevice.h | 4 +++-\n src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 13 ++++++-------\n src/libcamera/pipeline/simple/simple.cpp | 2 +-\n src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 3 +--\n src/libcamera/v4l2_videodevice.cpp | 9 +++++++--\n 5 files changed, 18 insertions(+), 13 deletions(-)", "diff": "diff --git a/include/libcamera/internal/v4l2_videodevice.h b/include/libcamera/internal/v4l2_videodevice.h\nindex fb4c0aabdd46206c..40ed87e17cfa6d3c 100644\n--- a/include/libcamera/internal/v4l2_videodevice.h\n+++ b/include/libcamera/internal/v4l2_videodevice.h\n@@ -168,6 +168,8 @@ public:\n class V4L2VideoDevice : public V4L2Device\n {\n public:\n+\tusing Formats = std::map<V4L2PixelFormat, std::vector<SizeRange>>;\n+\n \texplicit V4L2VideoDevice(const std::string &deviceNode);\n \texplicit V4L2VideoDevice(const MediaEntity *entity);\n \tV4L2VideoDevice(const V4L2VideoDevice &) = delete;\n@@ -188,7 +190,7 @@ public:\n \tint getFormat(V4L2DeviceFormat *format);\n \tint tryFormat(V4L2DeviceFormat *format);\n \tint setFormat(V4L2DeviceFormat *format);\n-\tstd::map<V4L2PixelFormat, std::vector<SizeRange>> formats(uint32_t code = 0);\n+\tFormats formats(uint32_t code = 0);\n \n \tint setSelection(unsigned int target, Rectangle *rect);\n \ndiff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex bf1c77144f855df9..82a0a4dfd6824fce 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -39,8 +39,6 @@ namespace libcamera {\n \n LOG_DEFINE_CATEGORY(RPI)\n \n-using V4L2PixFmtMap = std::map<V4L2PixelFormat, std::vector<SizeRange>>;\n-\n namespace {\n \n bool isRaw(PixelFormat &pixFmt)\n@@ -69,7 +67,8 @@ double scoreFormat(double desired, double actual)\n \treturn score;\n }\n \n-V4L2DeviceFormat findBestMode(V4L2PixFmtMap &formatsMap, const Size &req)\n+V4L2DeviceFormat findBestMode(V4L2VideoDevice::Formats &formatsMap,\n+\t\t\t const Size &req)\n {\n \tdouble bestScore = std::numeric_limits<double>::max(), score;\n \tV4L2DeviceFormat bestMode = {};\n@@ -410,7 +409,7 @@ CameraConfiguration::Status RPiCameraConfiguration::validate()\n \t\t\t * Calculate the best sensor mode we can use based on\n \t\t\t * the user request.\n \t\t\t */\n-\t\t\tV4L2PixFmtMap fmts = data_->unicam_[Unicam::Image].dev()->formats();\n+\t\t\tV4L2VideoDevice::Formats fmts = data_->unicam_[Unicam::Image].dev()->formats();\n \t\t\tV4L2DeviceFormat sensorFormat = findBestMode(fmts, cfg.size);\n \t\t\tint ret = data_->unicam_[Unicam::Image].dev()->tryFormat(&sensorFormat);\n \t\t\tif (ret)\n@@ -480,7 +479,7 @@ CameraConfiguration::Status RPiCameraConfiguration::validate()\n \t\telse\n \t\t\tdev = data_->isp_[Isp::Output1].dev();\n \n-\t\tV4L2PixFmtMap fmts = dev->formats();\n+\t\tV4L2VideoDevice::Formats fmts = dev->formats();\n \n \t\tif (fmts.find(V4L2PixelFormat::fromPixelFormat(cfgPixFmt, false)) == fmts.end()) {\n \t\t\t/* If we cannot find a native format, use a default one. */\n@@ -517,7 +516,7 @@ CameraConfiguration *PipelineHandlerRPi::generateConfiguration(Camera *camera,\n \tV4L2DeviceFormat sensorFormat;\n \tunsigned int bufferCount;\n \tPixelFormat pixelFormat;\n-\tV4L2PixFmtMap fmts;\n+\tV4L2VideoDevice::Formats fmts;\n \tSize size;\n \n \tif (roles.empty())\n@@ -633,7 +632,7 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config)\n \t}\n \n \t/* First calculate the best sensor mode we can use based on the user request. */\n-\tV4L2PixFmtMap fmts = data->unicam_[Unicam::Image].dev()->formats();\n+\tV4L2VideoDevice::Formats fmts = data->unicam_[Unicam::Image].dev()->formats();\n \tV4L2DeviceFormat sensorFormat = findBestMode(fmts, rawStream ? sensorSize : maxSize);\n \n \t/*\ndiff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp\nindex 28d367883323d855..5221ff3384923f56 100644\n--- a/src/libcamera/pipeline/simple/simple.cpp\n+++ b/src/libcamera/pipeline/simple/simple.cpp\n@@ -275,7 +275,7 @@ int SimpleCameraData::init()\n \t\t\treturn ret;\n \t\t}\n \n-\t\tstd::map<V4L2PixelFormat, std::vector<SizeRange>> videoFormats =\n+\t\tV4L2VideoDevice::Formats videoFormats =\n \t\t\tvideo_->formats(format.mbus_code);\n \n \t\tLOG(SimplePipeline, Debug)\ndiff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\nindex 47f383d1551d5193..93e3dc17e3a7105e 100644\n--- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n+++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n@@ -172,8 +172,7 @@ CameraConfiguration *PipelineHandlerUVC::generateConfiguration(Camera *camera,\n \tif (roles.empty())\n \t\treturn config;\n \n-\tstd::map<V4L2PixelFormat, std::vector<SizeRange>> v4l2Formats =\n-\t\tdata->video_->formats();\n+\tV4L2VideoDevice::Formats v4l2Formats = data->video_->formats();\n \tstd::map<PixelFormat, std::vector<SizeRange>> deviceFormats;\n \tfor (const auto &format : v4l2Formats) {\n \t\tPixelFormat pixelFormat = format.first.toPixelFormat();\ndiff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\nindex e0d2201269440795..9c4f3524af735598 100644\n--- a/src/libcamera/v4l2_videodevice.cpp\n+++ b/src/libcamera/v4l2_videodevice.cpp\n@@ -461,6 +461,11 @@ const std::string V4L2DeviceFormat::toString() const\n * \\context This class is \\threadbound.\n */\n \n+/**\n+ * \\typedef V4L2VideoDevice::Formats\n+ * \\brief A map of supported V4L2 pixel formats to frame sizes\n+ */\n+\n /**\n * \\brief Construct a V4L2VideoDevice\n * \\param[in] deviceNode The file-system path to the video device node\n@@ -951,9 +956,9 @@ int V4L2VideoDevice::trySetFormatSingleplane(V4L2DeviceFormat *format, bool set)\n *\n * \\return A list of the supported video device formats\n */\n-std::map<V4L2PixelFormat, std::vector<SizeRange>> V4L2VideoDevice::formats(uint32_t code)\n+V4L2VideoDevice::Formats V4L2VideoDevice::formats(uint32_t code)\n {\n-\tstd::map<V4L2PixelFormat, std::vector<SizeRange>> formats;\n+\tV4L2VideoDevice::Formats formats;\n \n \tfor (V4L2PixelFormat pixelFormat : enumPixelformats(code)) {\n \t\tstd::vector<SizeRange> sizes = enumSizes(pixelFormat);\n", "prefixes": [ "libcamera-devel", "v2", "3/3" ] }