Show a patch.

GET /api/patches/16873/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 16873,
    "url": "https://patchwork.libcamera.org/api/patches/16873/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/16873/",
    "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": "<20220729160014.101503-5-jacopo@jmondi.org>",
    "date": "2022-07-29T16:00:12",
    "name": "[libcamera-devel,v3,4/6] libcamera: v4l2_pixelformat: Return the list of V4L2 formats",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "ded2aaa8502343331f5f83605244cbfd138615a2",
    "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/16873/mbox/",
    "series": [
        {
            "id": 3350,
            "url": "https://patchwork.libcamera.org/api/series/3350/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3350",
            "date": "2022-07-29T16:00:08",
            "name": "libcamera: Map multiple V4L2 formats to a single libcamera::format",
            "version": 3,
            "mbox": "https://patchwork.libcamera.org/series/3350/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/16873/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/16873/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 2BBA0C3275\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 29 Jul 2022 16:00:31 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 10D8063324;\n\tFri, 29 Jul 2022 18:00:30 +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 34E4C63315\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 29 Jul 2022 18:00:27 +0200 (CEST)",
            "(Authenticated sender: jacopo@jmondi.org)\n\tby mail.gandi.net (Postfix) with ESMTPSA id 277FB4000F;\n\tFri, 29 Jul 2022 16:00:25 +0000 (UTC)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1659110430;\n\tbh=g9NV70bTTvX9eX2tjjp/z4kUFZAO4pTIHqKgbVSNGeU=;\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=FtUOBSsvHaC1AcY5M66CXyZNYcKjeRN9w8aGR4DT+fZxWwzvzo0WhI7ErOM8/V8tr\n\t+f0f3C+Gr72mxs0auGLpYUW5ceDxdegwI3GaTORRavTQE5t4/jxUH4AoXez2YyZ627\n\tJuM+kbf7IazTMcJYyRFzhn9Ihshxz6BxZdF/G6pQ5ZArlieEXo4e9cOILmIavakFM6\n\tQ/7SPwOFu0iSyWl4DlZZMeNnKj9PjLQeixLiGNZfZ+/6mNSQUYkcFUtqp+GNiKA9Nz\n\tnERxiICZQDakOPRwH8IeTdZqttplOro9bIlYSjBI7NZ7LVoHwYAf6avx/KYSGDrlvw\n\tcfSo3D/AiFB2w==",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Fri, 29 Jul 2022 18:00:12 +0200",
        "Message-Id": "<20220729160014.101503-5-jacopo@jmondi.org>",
        "X-Mailer": "git-send-email 2.37.1",
        "In-Reply-To": "<20220729160014.101503-1-jacopo@jmondi.org>",
        "References": "<20220729160014.101503-1-jacopo@jmondi.org>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v3 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, are converted to use the first returned format by default.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\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, 14 insertions(+), 12 deletions(-)",
    "diff": "diff --git a/include/libcamera/internal/v4l2_pixelformat.h b/include/libcamera/internal/v4l2_pixelformat.h\nindex ed94baf92795..a8aec29552e4 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+\t\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 91a882baa75b..bca97d1e3b4f 100644\n--- a/src/libcamera/v4l2_pixelformat.cpp\n+++ b/src/libcamera/v4l2_pixelformat.cpp\n@@ -302,23 +302,23 @@ 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  *\n- * Return the contiguous planes format version by default.\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> &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",
        "v3",
        "4/6"
    ]
}