Show a patch.

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

{
    "id": 16931,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/16931/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/16931/",
    "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": "<20220803103849.26144-6-jacopo@jmondi.org>",
    "date": "2022-08-03T10:38:47",
    "name": "[libcamera-devel,v5,5/7] 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/1.1/people/3/?format=api",
        "name": "Jacopo Mondi",
        "email": "jacopo@jmondi.org"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/16931/mbox/",
    "series": [
        {
            "id": 3365,
            "url": "https://patchwork.libcamera.org/api/1.1/series/3365/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3365",
            "date": "2022-08-03T10:38:42",
            "name": "libcamera: Map multiple V4L2 formats to a single libcamera::format",
            "version": 5,
            "mbox": "https://patchwork.libcamera.org/series/3365/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/16931/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/16931/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 BBE1ABE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  3 Aug 2022 10:39:07 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 877D16331C;\n\tWed,  3 Aug 2022 12:39:07 +0200 (CEST)",
            "from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net\n\t[IPv6:2001:4b98:dc4:8::225])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 965A1603E6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  3 Aug 2022 12:39:05 +0200 (CEST)",
            "(Authenticated sender: jacopo@jmondi.org)\n\tby mail.gandi.net (Postfix) with ESMTPSA id 613DA1C0003;\n\tWed,  3 Aug 2022 10:39:04 +0000 (UTC)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1659523147;\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:\n\tFrom;\n\tb=oIAFa6Rrvdo/YeaAl7ZsPU+68Uy8qLLHX4kKWCdRuGO+4WlHfNzUW/DeB2qPVgYB7\n\tNldmwKaUxNcngauMp4CnaDpabbNf+CYP/VSUoaoXix+xBwt/UvHslJM3UgI6XfGyuV\n\tIW7Wp990vozR8/Djq0A5YbbXe7iYPzh5RrmftyVEZXphFNn+50N2gHqYvzpFeYbZv0\n\t62D4w80fCObcdoAUbmvGZmcUlIx/thtPL69RmlLUTzU6dh5/PifQ3WZguCiQzzgML2\n\tzL3+NONrB5pHgTRwiB7qs5tyKRYotcy2lEdcniSMP0o9rz/g1IBUtQnzjYXApMRlpN\n\tzdCtcm4UnXxvA==",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Wed,  3 Aug 2022 12:38:47 +0200",
        "Message-Id": "<20220803103849.26144-6-jacopo@jmondi.org>",
        "X-Mailer": "git-send-email 2.37.1",
        "In-Reply-To": "<20220803103849.26144-1-jacopo@jmondi.org>",
        "References": "<20220803103849.26144-1-jacopo@jmondi.org>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v5 5/7] 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>",
        "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",
        "v5",
        "5/7"
    ]
}