{"id":3121,"url":"https://patchwork.libcamera.org/api/patches/3121/?format=json","web_url":"https://patchwork.libcamera.org/patch/3121/","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":"<20200316214310.27665-5-laurent.pinchart@ideasonboard.com>","date":"2020-03-16T21:43:04","name":"[libcamera-devel,v2,04/10] libcamera: v4l2_videodevice: Support filtering formats by media bus code","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"c2363f6cfc924cc19dc27168c915fc974e293003","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/3121/mbox/","series":[{"id":724,"url":"https://patchwork.libcamera.org/api/series/724/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=724","date":"2020-03-16T21:43:00","name":"Simple pipeline handler","version":2,"mbox":"https://patchwork.libcamera.org/series/724/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/3121/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/3121/checks/","tags":{},"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 D5CB7629AE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 16 Mar 2020 22:43:23 +0100 (CET)","from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id ACD48AD8;\n\tMon, 16 Mar 2020 22:43:22 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1584395003;\n\tbh=sYEj5f1OrBoH6UbQEUW5Sb/y9bAOVW0zGOQKWfBWLz4=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=OiJNVgy0gdNJITqmLOfc7yu9E6w/csyE9w0AjbdXQzMStMr3TBbC/3+sfRfo8Wdz3\n\tnCzhb4z2Ccxe5RiJAlCLHYEM96fJiipC/SlyS1/hWzHL5DjbkajwLvNxW7Qw4PXyN7\n\tLBCik0y6uVIpE1JjTv+mwZh4JKaqYOD5RuXRsLqI=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Martijn Braam <martijn@brixit.nl>, Mickael GUENE <mickael.guene@st.com>, \n\tBenjamin GAIGNARD <benjamin.gaignard@st.com>,\n\tAndrey Konovalov <andrey.konovalov@linaro.org>","Date":"Mon, 16 Mar 2020 23:43:04 +0200","Message-Id":"<20200316214310.27665-5-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.24.1","In-Reply-To":"<20200316214310.27665-1-laurent.pinchart@ideasonboard.com>","References":"<20200316214310.27665-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v2 04/10] libcamera: v4l2_videodevice:\n\tSupport filtering formats by media bus code","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":"Mon, 16 Mar 2020 21:43:24 -0000"},"content":"Add support for the recent V4L2 extension to VIDIOC_ENUM_FMT that allows\nfiltering pixel formats by media bus codes.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/libcamera/include/v4l2_videodevice.h |  4 ++--\n src/libcamera/v4l2_videodevice.cpp       | 16 +++++++++++++---\n 2 files changed, 15 insertions(+), 5 deletions(-)","diff":"diff --git a/src/libcamera/include/v4l2_videodevice.h b/src/libcamera/include/v4l2_videodevice.h\nindex 2507daf23efa..7196cabd09c7 100644\n--- a/src/libcamera/include/v4l2_videodevice.h\n+++ b/src/libcamera/include/v4l2_videodevice.h\n@@ -184,7 +184,7 @@ public:\n \n \tint getFormat(V4L2DeviceFormat *format);\n \tint setFormat(V4L2DeviceFormat *format);\n-\tImageFormats formats();\n+\tImageFormats formats(uint32_t code = 0);\n \n \tint setCrop(Rectangle *rect);\n \tint setCompose(Rectangle *rect);\n@@ -222,7 +222,7 @@ private:\n \tint getFormatSingleplane(V4L2DeviceFormat *format);\n \tint setFormatSingleplane(V4L2DeviceFormat *format);\n \n-\tstd::vector<unsigned int> enumPixelformats();\n+\tstd::vector<unsigned int> enumPixelformats(uint32_t code);\n \tstd::vector<SizeRange> enumSizes(unsigned int pixelFormat);\n \n \tint setSelection(unsigned int target, Rectangle *rect);\ndiff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\nindex f17e0136b5cb..084394fa5380 100644\n--- a/src/libcamera/v4l2_videodevice.cpp\n+++ b/src/libcamera/v4l2_videodevice.cpp\n@@ -896,16 +896,19 @@ int V4L2VideoDevice::setFormatSingleplane(V4L2DeviceFormat *format)\n \n /**\n  * \\brief Enumerate all pixel formats and frame sizes\n+ * \\param[in] code Restrict formats to this media bus code.\n  *\n  * Enumerate all pixel formats and frame sizes supported by the video device.\n+ * If the \\a code argument is not zero, only formats compatible with that media\n+ * bus code will be enumerated.\n  *\n  * \\return A list of the supported video device formats\n  */\n-ImageFormats V4L2VideoDevice::formats()\n+ImageFormats V4L2VideoDevice::formats(uint32_t code)\n {\n \tImageFormats formats;\n \n-\tfor (unsigned int pixelformat : enumPixelformats()) {\n+\tfor (unsigned int pixelformat : enumPixelformats(code)) {\n \t\tstd::vector<SizeRange> sizes = enumSizes(pixelformat);\n \t\tif (sizes.empty())\n \t\t\treturn {};\n@@ -921,7 +924,7 @@ ImageFormats V4L2VideoDevice::formats()\n \treturn formats;\n }\n \n-std::vector<unsigned int> V4L2VideoDevice::enumPixelformats()\n+std::vector<unsigned int> V4L2VideoDevice::enumPixelformats(uint32_t code)\n {\n \tstd::vector<unsigned int> formats;\n \tint ret;\n@@ -930,11 +933,18 @@ std::vector<unsigned int> V4L2VideoDevice::enumPixelformats()\n \t\tstruct v4l2_fmtdesc pixelformatEnum = {};\n \t\tpixelformatEnum.index = index;\n \t\tpixelformatEnum.type = bufferType_;\n+\t\tpixelformatEnum.mbus_code = code;\n \n \t\tret = ioctl(VIDIOC_ENUM_FMT, &pixelformatEnum);\n \t\tif (ret)\n \t\t\tbreak;\n \n+\t\tif (code && !(pixelformatEnum.flags & V4L2_FMT_FLAG_MBUS_CODE)) {\n+\t\t\tLOG(V4L2, Error)\n+\t\t\t\t<< \"Media bus code filtering not supported by the device\";\n+\t\t\treturn {};\n+\t\t}\n+\n \t\tformats.push_back(pixelformatEnum.pixelformat);\n \t}\n \n","prefixes":["libcamera-devel","v2","04/10"]}