Patch Detail
Show a patch.
GET /api/1.1/patches/16950/?format=api
{ "id": 16950, "url": "https://patchwork.libcamera.org/api/1.1/patches/16950/?format=api", "web_url": "https://patchwork.libcamera.org/patch/16950/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/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": "<20220803112640.30402-6-jacopo@jmondi.org>", "date": "2022-08-03T11:26:37", "name": "[libcamera-devel,v6,5/8] libcamera: v4l2_pixelformat: Return the list of V4L2 formats", "commit_ref": "b7ca378b65e8ba936bf3c5631e16534a3376aec9", "pull_url": null, "state": "accepted", "archived": false, "hash": "3fa457b474da2f9707cc3666076029a7647157e8", "submitter": { "id": 3, "url": "https://patchwork.libcamera.org/api/1.1/people/3/?format=api", "name": "Jacopo Mondi", "email": "jacopo@jmondi.org" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/16950/mbox/", "series": [ { "id": 3368, "url": "https://patchwork.libcamera.org/api/1.1/series/3368/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3368", "date": "2022-08-03T11:26:32", "name": "libcamera: Map multiple V4L2 formats to a single libcamera::format", "version": 6, "mbox": "https://patchwork.libcamera.org/series/3368/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/16950/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/16950/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 6F1C5C3272\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 3 Aug 2022 11:27:05 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2D6CE63310;\n\tWed, 3 Aug 2022 13:27:05 +0200 (CEST)", "from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net\n\t[IPv6:2001:4b98:dc4:8::228])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 30CA46330F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 3 Aug 2022 13:27:04 +0200 (CEST)", "(Authenticated sender: jacopo@jmondi.org)\n\tby mail.gandi.net (Postfix) with ESMTPSA id 23D761BF207;\n\tWed, 3 Aug 2022 11:27:01 +0000 (UTC)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1659526025;\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=1LEOnfhESlLy9XRzD66vv/RsTC1hJgfV1jy//dUy8U34MdrMM9ld/t5IZfLMS0H9e\n\tWT2AhiutPx2t/7Wpn+7qQ5DDmOLg9KE+yX8NZga13BvTnLZYzNibRB3VHGNCXSWZB5\n\tqpgDdVJSCQb9lY+6vs40tiEWw0j0GC/ZjrI8URbc+nvBRLjZs+R71KFcA2OjVsTSTn\n\tFQ6N+RwDl/vlGSR/LxY0VXZbD+pFt541mL92iuAsHRFjNoreQ2S8IbeOdPynUbzrE0\n\tuT5k8FK7rWbTK9F3KgmZ3HKUkodxoisy4caxJJQtciCzh6fS+jvxVg8ava+8nWJgeQ\n\tfwyM9ejyuevew==", "To": "libcamera-devel@lists.libcamera.org", "Date": "Wed, 3 Aug 2022 13:26:37 +0200", "Message-Id": "<20220803112640.30402-6-jacopo@jmondi.org>", "X-Mailer": "git-send-email 2.37.1", "In-Reply-To": "<20220803112640.30402-1-jacopo@jmondi.org>", "References": "<20220803112640.30402-1-jacopo@jmondi.org>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v6 5/8] 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", "v6", "5/8" ] }