Patch Detail
Show a patch.
GET /api/patches/16914/?format=api
{ "id": 16914, "url": "https://patchwork.libcamera.org/api/patches/16914/?format=api", "web_url": "https://patchwork.libcamera.org/patch/16914/", "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": "<20220802160136.63075-5-jacopo@jmondi.org>", "date": "2022-08-02T16:01:34", "name": "[libcamera-devel,v4,4/6] libcamera: v4l2_pixelformat: Return the list of V4L2 formats", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "3fa457b474da2f9707cc3666076029a7647157e8", "submitter": { "id": 3, "url": "https://patchwork.libcamera.org/api/people/3/?format=api", "name": "Jacopo Mondi", "email": "jacopo@jmondi.org" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/16914/mbox/", "series": [ { "id": 3359, "url": "https://patchwork.libcamera.org/api/series/3359/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3359", "date": "2022-08-02T16:01:30", "name": "libcamera: Map multiple V4L2 formats to a single libcamera::format", "version": 4, "mbox": "https://patchwork.libcamera.org/series/3359/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/16914/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/16914/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 9F775C3276\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 2 Aug 2022 16:01:57 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4E9DF603E7;\n\tTue, 2 Aug 2022 18:01:57 +0200 (CEST)", "from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net\n\t[217.70.183.194])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 993FD603E7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 2 Aug 2022 18:01:56 +0200 (CEST)", "(Authenticated sender: jacopo@jmondi.org)\n\tby mail.gandi.net (Postfix) with ESMTPSA id C6E274000D;\n\tTue, 2 Aug 2022 16:01:54 +0000 (UTC)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1659456117;\n\tbh=zEsN9UXvFgJQrGewj6IkWY26ydzlTpVPElPwvOy8lzg=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=KYnTK0BWGYeFFswPckd4myYCxQ2NFsqJwB2UQFt4TwmJK1aU4r71G9ft01/aMyNM/\n\tuyD+/uT38xhwpXwQc5vHElnPU5dRI1C1RGtuXSbynIee2jglbAlvxxt4RciUQC7mlv\n\t4K1PPZ3I393OjtTGtTkb89qnMtEJWSiRexAv3tjbK4GtlKqBcvnOHj5QdUp6EBGDDD\n\tg9l5Au/vXMgpYjeY+ZfimgC7oUXNahCaTk5EUYIJ3uIjHVDpYwYcwTlh31FAfFzhE/\n\tDurBUqAlkJ3RKKfg1eZ9AYjoM11hWa1yqdxKg7KmEz7t7mlG45J8ZRCJNCNODU2UCJ\n\ttcJYb5fjIFsIA==", "To": "libcamera-devel@lists.libcamera.org", "Date": "Tue, 2 Aug 2022 18:01:34 +0200", "Message-Id": "<20220802160136.63075-5-jacopo@jmondi.org>", "X-Mailer": "git-send-email 2.37.1", "In-Reply-To": "<20220802160136.63075-1-jacopo@jmondi.org>", "References": "<20220802160136.63075-1-jacopo@jmondi.org>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v4 4/6] libcamera: v4l2_pixelformat:\n\tReturn the list of V4L2 formats", "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>", "From": "Jacopo Mondi via libcamera-devel <libcamera-devel@lists.libcamera.org>", "Reply-To": "Jacopo Mondi <jacopo@jmondi.org>", "Cc": "jozef@mlich.cz, Pavel Machek <pavel@ucw.cz>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "Multiple V4L2 formats can be associated with a single PixelFormat.\nNow that users of V4L2PixelFormat::fromPixelFormat() have been converted\nto use V4L2VideoDevice::toV4L2PixelFormat(), return the full list of\nV4L2 formats in order to prepare to match them against the ones\nsupported by the video device.\n\nThe V4L2 compatibility layer, not having any video device to interact\nwith, is converted to use the first returned format unconditionally.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/internal/v4l2_pixelformat.h | 4 +++-\n src/libcamera/v4l2_pixelformat.cpp | 14 ++++++++------\n src/libcamera/v4l2_videodevice.cpp | 2 +-\n src/v4l2/v4l2_camera_proxy.cpp | 6 +++---\n 4 files changed, 15 insertions(+), 11 deletions(-)", "diff": "diff --git a/include/libcamera/internal/v4l2_pixelformat.h b/include/libcamera/internal/v4l2_pixelformat.h\nindex ed94baf92795..d5400f90a67e 100644\n--- a/include/libcamera/internal/v4l2_pixelformat.h\n+++ b/include/libcamera/internal/v4l2_pixelformat.h\n@@ -11,6 +11,7 @@\n #include <ostream>\n #include <stdint.h>\n #include <string>\n+#include <vector>\n \n #include <linux/videodev2.h>\n \n@@ -44,7 +45,8 @@ public:\n \tconst char *description() const;\n \n \tPixelFormat toPixelFormat() const;\n-\tstatic V4L2PixelFormat fromPixelFormat(const PixelFormat &pixelFormat);\n+\tstatic const std::vector<V4L2PixelFormat> &\n+\tfromPixelFormat(const PixelFormat &pixelFormat);\n \n private:\n \tuint32_t fourcc_;\ndiff --git a/src/libcamera/v4l2_pixelformat.cpp b/src/libcamera/v4l2_pixelformat.cpp\nindex 9f74bd37c5ea..90c8fa8d9aae 100644\n--- a/src/libcamera/v4l2_pixelformat.cpp\n+++ b/src/libcamera/v4l2_pixelformat.cpp\n@@ -302,22 +302,24 @@ PixelFormat V4L2PixelFormat::toPixelFormat() const\n }\n \n /**\n- * \\brief Convert \\a pixelFormat to its corresponding V4L2PixelFormat\n+ * \\brief Retrieve the list of V4L2PixelFormat associated with \\a pixelFormat\n * \\param[in] pixelFormat The PixelFormat to convert\n *\n * Multiple V4L2 formats may exist for one PixelFormat as V4L2 defines separate\n * 4CCs for contiguous and non-contiguous versions of the same image format.\n- * When that is the case, this function returns the contiguous planes format.\n *\n- * \\return The V4L2PixelFormat corresponding to \\a pixelFormat\n+ * \\return The list of V4L2PixelFormat corresponding to \\a pixelFormat\n */\n-V4L2PixelFormat V4L2PixelFormat::fromPixelFormat(const PixelFormat &pixelFormat)\n+const std::vector<V4L2PixelFormat> &\n+V4L2PixelFormat::fromPixelFormat(const PixelFormat &pixelFormat)\n {\n+\tstatic const std::vector<V4L2PixelFormat> empty;\n+\n \tconst PixelFormatInfo &info = PixelFormatInfo::info(pixelFormat);\n \tif (!info.isValid())\n-\t\treturn V4L2PixelFormat();\n+\t\treturn empty;\n \n-\treturn info.v4l2Formats[0];\n+\treturn info.v4l2Formats;\n }\n \n /**\ndiff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\nindex f41afa06f460..2ca22f485d45 100644\n--- a/src/libcamera/v4l2_videodevice.cpp\n+++ b/src/libcamera/v4l2_videodevice.cpp\n@@ -2000,7 +2000,7 @@ V4L2VideoDevice::fromEntityName(const MediaDevice *media,\n */\n V4L2PixelFormat V4L2VideoDevice::toV4L2PixelFormat(const PixelFormat &pixelFormat) const\n {\n-\treturn V4L2PixelFormat::fromPixelFormat(pixelFormat);\n+\treturn V4L2PixelFormat::fromPixelFormat(pixelFormat)[0];\n }\n \n /**\ndiff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp\nindex 26a227da6db2..55ff62cdb430 100644\n--- a/src/v4l2/v4l2_camera_proxy.cpp\n+++ b/src/v4l2/v4l2_camera_proxy.cpp\n@@ -182,7 +182,7 @@ void V4L2CameraProxy::setFmtFromConfig(const StreamConfiguration &streamConfig)\n \n \tv4l2PixFormat_.width = size.width;\n \tv4l2PixFormat_.height = size.height;\n-\tv4l2PixFormat_.pixelformat = V4L2PixelFormat::fromPixelFormat(streamConfig.pixelFormat);\n+\tv4l2PixFormat_.pixelformat = V4L2PixelFormat::fromPixelFormat(streamConfig.pixelFormat)[0];\n \tv4l2PixFormat_.field = V4L2_FIELD_NONE;\n \tv4l2PixFormat_.bytesperline = streamConfig.stride;\n \tv4l2PixFormat_.sizeimage = streamConfig.frameSize;\n@@ -290,7 +290,7 @@ int V4L2CameraProxy::vidioc_enum_fmt(V4L2CameraFile *file, struct v4l2_fmtdesc *\n \t\treturn -EINVAL;\n \n \tPixelFormat format = streamConfig_.formats().pixelformats()[arg->index];\n-\tV4L2PixelFormat v4l2Format = V4L2PixelFormat::fromPixelFormat(format);\n+\tV4L2PixelFormat v4l2Format = V4L2PixelFormat::fromPixelFormat(format)[0];\n \n \targ->flags = format == formats::MJPEG ? V4L2_FMT_FLAG_COMPRESSED : 0;\n \tutils::strlcpy(reinterpret_cast<char *>(arg->description),\n@@ -333,7 +333,7 @@ int V4L2CameraProxy::tryFormat(struct v4l2_format *arg)\n \n \targ->fmt.pix.width = config.size.width;\n \targ->fmt.pix.height = config.size.height;\n-\targ->fmt.pix.pixelformat = V4L2PixelFormat::fromPixelFormat(config.pixelFormat);\n+\targ->fmt.pix.pixelformat = V4L2PixelFormat::fromPixelFormat(config.pixelFormat)[0];\n \targ->fmt.pix.field = V4L2_FIELD_NONE;\n \targ->fmt.pix.bytesperline = config.stride;\n \targ->fmt.pix.sizeimage = config.frameSize;\n", "prefixes": [ "libcamera-devel", "v4", "4/6" ] }