{"id":1227,"url":"https://patchwork.libcamera.org/api/1.1/patches/1227/?format=json","web_url":"https://patchwork.libcamera.org/patch/1227/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/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":"<20190517230621.24668-11-laurent.pinchart@ideasonboard.com>","date":"2019-05-17T23:06:19","name":"[libcamera-devel,PATCH/RFC,10/12] libcamera: v4l2_device: Add method to enumerate all discrete frame sizes","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"240c73d2e0e594feb7b56387deea880cb956be87","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/1.1/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/1227/mbox/","series":[{"id":307,"url":"https://patchwork.libcamera.org/api/1.1/series/307/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=307","date":"2019-05-17T23:06:09","name":"Rework camera configuration to introduce negotiation of parameters","version":1,"mbox":"https://patchwork.libcamera.org/series/307/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/1227/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/1227/checks/","tags":{},"headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1A22D60E53\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 18 May 2019 01:06:46 +0200 (CEST)","from pendragon.bb.dnainternet.fi\n\t(dfj612yhrgyx302h3jwwy-3.rev.dnainternet.fi\n\t[IPv6:2001:14ba:21f5:5b00:ce28:277f:58d7:3ca4])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id BE4D8336\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 18 May 2019 01:06:45 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1558134405;\n\tbh=zvXB96Id6V1CoVvFd/HvN+v+pntl7HD3pxKx2o01h7M=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=lMcJlXzP2Ton5tkI4LPogFyN8LSVEsCgbfwC+iS/wBWLJhV9dGbojbtc2xkLTk27q\n\tml61tpYmnIf6oj1wRJROcZajeEe7hSWjp2EpE8g5XwVTW4GAGTq+/E6uekA0g6ut7o\n\tYwrnU4Zd6OPRxrFQfqiFkcHVkv78KtD2drJPwpiw=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Sat, 18 May 2019 02:06:19 +0300","Message-Id":"<20190517230621.24668-11-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.21.0","In-Reply-To":"<20190517230621.24668-1-laurent.pinchart@ideasonboard.com>","References":"<20190517230621.24668-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH/RFC 10/12] libcamera: v4l2_device: Add\n\tmethod to enumerate all discrete frame sizes","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":"Fri, 17 May 2019 23:06:49 -0000"},"content":"From: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\nAllow the video device to be interrogated about which discrete frame\nsizes it supports.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n src/libcamera/include/v4l2_device.h |  4 +++\n src/libcamera/v4l2_device.cpp       | 51 +++++++++++++++++++++++++++++\n 2 files changed, 55 insertions(+)","diff":"diff --git a/src/libcamera/include/v4l2_device.h b/src/libcamera/include/v4l2_device.h\nindex 2e7bd1e7f4cc..481d63d9cc4c 100644\n--- a/src/libcamera/include/v4l2_device.h\n+++ b/src/libcamera/include/v4l2_device.h\n@@ -8,6 +8,8 @@\n #define __LIBCAMERA_V4L2_DEVICE_H__\n \n #include <atomic>\n+#include <map>\n+#include <set>\n #include <string>\n #include <vector>\n \n@@ -126,6 +128,8 @@ public:\n \n \tint getFormat(V4L2DeviceFormat *format);\n \tint setFormat(V4L2DeviceFormat *format);\n+\tstd::map<unsigned int, std::vector<Size>>\n+\tenumerateFrameSizes(std::set<unsigned int> pixelformats);\n \n \tint exportBuffers(BufferPool *pool);\n \tint importBuffers(BufferPool *pool);\ndiff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\nindex 8366ffc4db55..d26a89f4a27d 100644\n--- a/src/libcamera/v4l2_device.cpp\n+++ b/src/libcamera/v4l2_device.cpp\n@@ -564,6 +564,57 @@ int V4L2Device::setFormatMultiplane(V4L2DeviceFormat *format)\n \treturn 0;\n }\n \n+/**\n+ * \\brief Enumerate all discrete frame sizes for a set of pixel formats\n+ * \\param[in] pixelformats A set of pixel formats to enumerate sizes for\n+ *\n+ * Enumerate all discrete frame sizes reported by the video device.\n+ *\n+ * \\return A map of pixel format to frame sizes\n+ */\n+std::map<unsigned int, std::vector<Size>>\n+V4L2Device::enumerateFrameSizes(std::set<unsigned int> pixelformats)\n+{\n+\tstd::map<unsigned int, std::vector<Size>> sizes;\n+\tint ret;\n+\n+\tfor (unsigned int pixelformat : pixelformats) {\n+\t\tstruct v4l2_frmsizeenum frameSize = {};\n+\t\tunsigned int index = 0;\n+\n+\t\tframeSize.pixel_format = pixelformat;\n+\n+\t\twhile (true) {\n+\t\t\tframeSize.index = index;\n+\n+\t\t\tret = ioctl(fd_, VIDIOC_ENUM_FRAMESIZES, &frameSize);\n+\t\t\tif (ret) {\n+\t\t\t\tret = -errno;\n+\n+\t\t\t\tif (ret == -EINVAL)\n+\t\t\t\t\tbreak;\n+\n+\t\t\t\tif (ret != -ENOTTY)\n+\t\t\t\t\tLOG(V4L2, Error)\n+\t\t\t\t\t\t<< \"Unable to enumerate frame size\"\n+\t\t\t\t\t\t<< strerror(-ret);\n+\n+\t\t\t\treturn {};\n+\t\t\t}\n+\n+\t\t\tif (frameSize.type != V4L2_FRMSIZE_TYPE_DISCRETE)\n+\t\t\t\treturn {};\n+\n+\t\t\tsizes[pixelformat].push_back(Size(frameSize.discrete.width,\n+\t\t\t\t\t\t\t  frameSize.discrete.height));\n+\n+\t\t\tindex++;\n+\t\t}\n+\t}\n+\n+\treturn sizes;\n+}\n+\n int V4L2Device::requestBuffers(unsigned int count)\n {\n \tstruct v4l2_requestbuffers rb = {};\n","prefixes":["libcamera-devel","PATCH/RFC","10/12"]}