Show a patch.

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

{
    "id": 4106,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/4106/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/4106/",
    "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": "<20200622110351.GA14836@kaaira-HP-Pavilion-Notebook>",
    "date": "2020-06-22T11:03:51",
    "name": "[libcamera-devel,v6] libcamera:PixelFormat: Replace hex with format names",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "4328ef4dff526bf0019f1d9bf4e196224cac7abd",
    "submitter": {
        "id": 39,
        "url": "https://patchwork.libcamera.org/api/1.1/people/39/?format=api",
        "name": "Kaaira Gupta",
        "email": "kgupta@es.iitr.ac.in"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/4106/mbox/",
    "series": [
        {
            "id": 1022,
            "url": "https://patchwork.libcamera.org/api/1.1/series/1022/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1022",
            "date": "2020-06-22T11:03:51",
            "name": "[libcamera-devel,v6] libcamera:PixelFormat: Replace hex with format names",
            "version": 6,
            "mbox": "https://patchwork.libcamera.org/series/1022/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/4106/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/4106/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<kgupta@es.iitr.ac.in>",
        "Received": [
            "from mail-pf1-x433.google.com (mail-pf1-x433.google.com\n\t[IPv6:2607:f8b0:4864:20::433])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3E189603BD\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 22 Jun 2020 13:04:01 +0200 (CEST)",
            "by mail-pf1-x433.google.com with SMTP id a127so8241102pfa.12\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 22 Jun 2020 04:04:01 -0700 (PDT)",
            "from kaaira-HP-Pavilion-Notebook ([103.113.213.178])\n\tby smtp.gmail.com with ESMTPSA id\n\tk140sm8668885pfd.185.2020.06.22.04.03.56\n\t(version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256);\n\tMon, 22 Jun 2020 04:03:58 -0700 (PDT)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected)\n\theader.d=es-iitr-ac-in.20150623.gappssmtp.com\n\theader.i=@es-iitr-ac-in.20150623.gappssmtp.com header.b=\"tWT/Syrq\"; \n\tdkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=es-iitr-ac-in.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:subject:message-id:mime-version:content-disposition\n\t:user-agent; bh=mRC84SzwDzGBoK+a6lpFuDRXH+nonLVyY/+p27rUxHc=;\n\tb=tWT/SyrqYpyJ9aoKB5n5XdH9sz2XL/lCg0bIYdGMoi85bd5DYkIpp7nKqA9y558o4V\n\tPCZi7AeKe/b5uqnPS53pYtRn2PGde+Rz5AMumgpV0uP349mdyzwgzyyQhxChMyPHuqtv\n\tO/wXloFSxJnQFyhvZJ5hax2ycjCEtL3cZAWewDcMEEIWt96URXo5yyigM8DRQjJ3kGA0\n\t7K67Cdayl6UN9mZAnJB1dnU/vFEjDAE7uADbC8zHfcvHbZsJeix2T07DfMBcyfPuqlqh\n\ttXmVKlyszbXnr0Ylp6Yw/CO7a915CoffG1waHOsWKIVHtHzH75kdhhatsKR8KSrNwB0E\n\tuigg==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:subject:message-id:mime-version\n\t:content-disposition:user-agent;\n\tbh=mRC84SzwDzGBoK+a6lpFuDRXH+nonLVyY/+p27rUxHc=;\n\tb=YwsNaNbe4mFWInYAD5YflUbAkDks/xecQgQMUXCudxc84z5DwWK+I3vHwJTgRHDKbf\n\tPKJtK6+JthbPz73lIM6SIkqYuupMPmik9YhBQbw5UeswUlHbm7nGJgOBMgcOj5aQv0Uc\n\tyOpcWsbhh+9kqbsQbtQmt2NXveasaPGsweE7AHHTDLE+FiF8Iffd8NxBN4FQyaZh0xav\n\tRu8SiFgYq0on1TDDGJVKt5iMM4J3r8xri1eehqA8OD4fQ4G1Xp51U4okBXcGAHQVn4vC\n\tWZWt8JZtA9/EYI6xAWv0nWIaWgfAwB/rqXF5wpRKjmCuS/3cCWjWqaeNoiqBckyWjqZU\n\tKsyw==",
        "X-Gm-Message-State": "AOAM533kBmyDu8s4bb5HIHHgRG4Z7WJsRt0+fWcecQA2gC8Gmng8KlDI\n\td1N4Ov6LS8stJosYiXOCjawucW0YoTKpHQ==",
        "X-Google-Smtp-Source": "ABdhPJyPVbhTAZZlV5BvJNJWaez/Wp2HxuWndCLYgBPs5giggegjFxITVDZBt/ZCjKwYdfMUXYm1WA==",
        "X-Received": "by 2002:a62:8342:: with SMTP id\n\th63mr19173439pfe.183.1592823839042; \n\tMon, 22 Jun 2020 04:03:59 -0700 (PDT)",
        "Date": "Mon, 22 Jun 2020 16:33:51 +0530",
        "From": "Kaaira Gupta <kgupta@es.iitr.ac.in>",
        "To": "libcamera-devel@lists.libcamera.org,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "Message-ID": "<20200622110351.GA14836@kaaira-HP-Pavilion-Notebook>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=us-ascii",
        "Content-Disposition": "inline",
        "User-Agent": "Mutt/1.9.4 (2018-02-28)",
        "Subject": "[libcamera-devel] [PATCH v6] libcamera:PixelFormat: Replace hex\n\twith format names",
        "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, 22 Jun 2020 11:04:01 -0000"
    },
    "content": "Print format names defined in formats namespace instead of the hex\nvalues in toString() as they are easier to comprehend. For this add\na property of 'name' in PixelFormatInfo' so as to map the formats\nwith their names. Print fourcc for formats which are not used in\nlibcamera.\n\nSigned-off-by: Kaaira Gupta <kgupta@es.iitr.ac.in>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\nResending due to typo in mailing list address.\n\nChanges since v5:\n\t- formatting changes.\n\t- based on top of [PATCH v2] libcamera: add support\n\t for planar YUV422 and YUV420 formats\n\nChanges since v4:\n        -Print libcamera defined names instead of fourcc.\n\nChanges since v3:\n        -shortened the texts.\n        -Removed default case as well.\n        -changed commit message and tests to reflect the changes.\n\nChanges since v2:\n        - Remove description for all vendors except for MIPI\n        - Change commit message to reflect this change.\n        - Change tests accordingly.\n\nChanges since v1:\n        - Replaced magic numbers with expressive values.\n        - Re-wrote ARM vendor's modifiers\n        - Re-wrote the vendors' map with a macro.\n        - Changed the copyrights in test file.\n        - Changed the tests.\n\n include/libcamera/internal/formats.h |  1 +\n src/libcamera/formats.cpp            | 42 +++++++++++++++++++++--\n src/libcamera/pixel_format.cpp       | 27 +++++++++++++--\n test/meson.build                     |  1 +\n test/pixel-format.cpp                | 51 ++++++++++++++++++++++++++++\n 5 files changed, 117 insertions(+), 5 deletions(-)\n create mode 100644 test/pixel-format.cpp",
    "diff": "diff --git a/include/libcamera/internal/formats.h b/include/libcamera/internal/formats.h\nindex 4b172ef..f59ac8f 100644\n--- a/include/libcamera/internal/formats.h\n+++ b/include/libcamera/internal/formats.h\n@@ -46,6 +46,7 @@ public:\n \tstatic const PixelFormatInfo &info(const PixelFormat &format);\n \n \t/* \\todo Add support for non-contiguous memory planes */\n+\tconst char *name;\n \tPixelFormat format;\n \tV4L2PixelFormat v4l2Format;\n \tunsigned int bitsPerPixel;\ndiff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp\nindex c0b53ce..9de1434 100644\n--- a/src/libcamera/formats.cpp\n+++ b/src/libcamera/formats.cpp\n@@ -169,6 +169,7 @@ namespace {\n const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n \t/* RGB formats. */\n \t{ formats::BGR888, {\n+\t\t.name = \"BGR888\",\n \t\t.format = formats::BGR888,\n \t\t.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_RGB24),\n \t\t.bitsPerPixel = 24,\n@@ -176,6 +177,7 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n \t\t.packed = false,\n \t} },\n \t{ formats::RGB888, {\n+\t\t.name = \"RGB888\",\n \t\t.format = formats::RGB888,\n \t\t.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_BGR24),\n \t\t.bitsPerPixel = 24,\n@@ -183,6 +185,7 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n \t\t.packed = false,\n \t} },\n \t{ formats::ABGR8888, {\n+\t\t.name = \"ABGR8888\",\n \t\t.format = formats::ABGR8888,\n \t\t.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_RGBA32),\n \t\t.bitsPerPixel = 32,\n@@ -190,6 +193,7 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n \t\t.packed = false,\n \t} },\n \t{ formats::ARGB8888, {\n+\t\t.name = \"ARGB8888\",\n \t\t.format = formats::ARGB8888,\n \t\t.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_ABGR32),\n \t\t.bitsPerPixel = 32,\n@@ -197,6 +201,7 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n \t\t.packed = false,\n \t} },\n \t{ formats::BGRA8888, {\n+\t\t.name = \"BGRA8888\",\n \t\t.format = formats::BGRA8888,\n \t\t.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_ARGB32),\n \t\t.bitsPerPixel = 32,\n@@ -204,6 +209,7 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n \t\t.packed = false,\n \t} },\n \t{ formats::RGBA8888, {\n+\t\t.name = \"RGBA8888\",\n \t\t.format = formats::RGBA8888,\n \t\t.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_BGRA32),\n \t\t.bitsPerPixel = 32,\n@@ -213,6 +219,7 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n \n \t/* YUV packed formats. */\n \t{ formats::YUYV, {\n+\t\t.name = \"YUYV\",\n \t\t.format = formats::YUYV,\n \t\t.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_YUYV),\n \t\t.bitsPerPixel = 16,\n@@ -220,6 +227,7 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n \t\t.packed = false,\n \t} },\n \t{ formats::YVYU, {\n+\t\t.name = \"YVYU\",\n \t\t.format = formats::YVYU,\n \t\t.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_YVYU),\n \t\t.bitsPerPixel = 16,\n@@ -227,6 +235,7 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n \t\t.packed = false,\n \t} },\n \t{ formats::UYVY, {\n+\t\t.name = \"UYVY\",\n \t\t.format = formats::UYVY,\n \t\t.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_UYVY),\n \t\t.bitsPerPixel = 16,\n@@ -234,6 +243,7 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n \t\t.packed = false,\n \t} },\n \t{ formats::VYUY, {\n+\t\t.name = \"VYUY\",\n \t\t.format = formats::VYUY,\n \t\t.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_VYUY),\n \t\t.bitsPerPixel = 16,\n@@ -243,6 +253,7 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n \n \t/* YUV planar formats. */\n \t{ formats::NV16, {\n+\t\t.name = \"NV16\",\n \t\t.format = formats::NV16,\n \t\t.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_NV16),\n \t\t.bitsPerPixel = 16,\n@@ -250,6 +261,7 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n \t\t.packed = false,\n \t} },\n \t{ formats::NV61, {\n+\t\t.name = \"NV61\",\n \t\t.format = formats::NV61,\n \t\t.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_NV61),\n \t\t.bitsPerPixel = 16,\n@@ -257,6 +269,7 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n \t\t.packed = false,\n \t} },\n \t{ formats::NV12, {\n+\t\t.name = \"NV12\",\n \t\t.format = formats::NV12,\n \t\t.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_NV12),\n \t\t.bitsPerPixel = 12,\n@@ -264,6 +277,7 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n \t\t.packed = false,\n \t} },\n \t{ formats::NV21, {\n+\t\t.name = \"NV21\",\n \t\t.format = formats::NV21,\n \t\t.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_NV21),\n \t\t.bitsPerPixel = 12,\n@@ -271,6 +285,7 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n \t\t.packed = false,\n \t} },\n \t{ formats::YUV420, {\n+\t\t.name = \"YUV420\",\n \t\t.format = PixelFormat(formats::YUV420),\n \t\t.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_YUV420),\n \t\t.bitsPerPixel = 12,\n@@ -278,6 +293,7 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n \t\t.packed = false,\n \t} },\n \t{ formats::YUV422, {\n+\t\t.name = \"YUV422\",\n \t\t.format = PixelFormat(formats::YUV422),\n \t\t.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_YUV422P),\n \t\t.bitsPerPixel = 16,\n@@ -287,6 +303,7 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n \n \t/* Greyscale formats. */\n \t{ formats::R8, {\n+\t\t.name = \"R8\",\n \t\t.format = formats::R8,\n \t\t.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_GREY),\n \t\t.bitsPerPixel = 8,\n@@ -296,6 +313,7 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n \n \t/* Bayer formats. */\n \t{ formats::SBGGR8, {\n+\t\t.name = \"SBGGR8\",\n \t\t.format = formats::SBGGR8,\n \t\t.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SBGGR8),\n \t\t.bitsPerPixel = 8,\n@@ -303,6 +321,7 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n \t\t.packed = false,\n \t} },\n \t{ formats::SGBRG8, {\n+\t\t.name = \"SGBRG8\",\n \t\t.format = formats::SGBRG8,\n \t\t.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SGBRG8),\n \t\t.bitsPerPixel = 8,\n@@ -310,6 +329,7 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n \t\t.packed = false,\n \t} },\n \t{ formats::SGRBG8, {\n+\t\t.name = \"SGRBG8\",\n \t\t.format = formats::SGRBG8,\n \t\t.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SGRBG8),\n \t\t.bitsPerPixel = 8,\n@@ -317,6 +337,7 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n \t\t.packed = false,\n \t} },\n \t{ formats::SRGGB8, {\n+\t\t.name = \"SRGGB8\",\n \t\t.format = formats::SRGGB8,\n \t\t.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SRGGB8),\n \t\t.bitsPerPixel = 8,\n@@ -324,6 +345,7 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n \t\t.packed = false,\n \t} },\n \t{ formats::SBGGR10, {\n+\t\t.name = \"SBGGR10\",\n \t\t.format = formats::SBGGR10,\n \t\t.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SBGGR10),\n \t\t.bitsPerPixel = 10,\n@@ -331,6 +353,7 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n \t\t.packed = false,\n \t} },\n \t{ formats::SGBRG10, {\n+\t\t.name = \"SGBRG10\",\n \t\t.format = formats::SGBRG10,\n \t\t.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SGBRG10),\n \t\t.bitsPerPixel = 10,\n@@ -338,6 +361,7 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n \t\t.packed = false,\n \t} },\n \t{ formats::SGRBG10, {\n+\t\t.name = \"SGRBG10\",\n \t\t.format = formats::SGRBG10,\n \t\t.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SGRBG10),\n \t\t.bitsPerPixel = 10,\n@@ -345,6 +369,7 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n \t\t.packed = false,\n \t} },\n \t{ formats::SRGGB10, {\n+\t\t.name = \"SRGGB10\",\n \t\t.format = formats::SRGGB10,\n \t\t.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SRGGB10),\n \t\t.bitsPerPixel = 10,\n@@ -352,6 +377,7 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n \t\t.packed = false,\n \t} },\n \t{ formats::SBGGR10_CSI2P, {\n+\t\t.name = \"SBGGR10_CSI2P\",\n \t\t.format = formats::SBGGR10_CSI2P,\n \t\t.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SBGGR10P),\n \t\t.bitsPerPixel = 10,\n@@ -359,6 +385,7 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n \t\t.packed = true,\n \t} },\n \t{ formats::SGBRG10_CSI2P, {\n+\t\t.name = \"SGBRG10_CSI2P\",\n \t\t.format = formats::SGBRG10_CSI2P,\n \t\t.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SGBRG10P),\n \t\t.bitsPerPixel = 10,\n@@ -366,6 +393,7 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n \t\t.packed = true,\n \t} },\n \t{ formats::SGRBG10_CSI2P, {\n+\t\t.name = \"SGRBG10_CSI2P\",\n \t\t.format = formats::SGRBG10_CSI2P,\n \t\t.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SGRBG10P),\n \t\t.bitsPerPixel = 10,\n@@ -373,6 +401,7 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n \t\t.packed = true,\n \t} },\n \t{ formats::SRGGB10_CSI2P, {\n+\t\t.name = \"SRGGB10_CSI2P\",\n \t\t.format = formats::SRGGB10_CSI2P,\n \t\t.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SRGGB10P),\n \t\t.bitsPerPixel = 10,\n@@ -380,6 +409,7 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n \t\t.packed = true,\n \t} },\n \t{ formats::SBGGR12, {\n+\t\t.name = \"SBGGR12\",\n \t\t.format = formats::SBGGR12,\n \t\t.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SBGGR12),\n \t\t.bitsPerPixel = 12,\n@@ -387,6 +417,7 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n \t\t.packed = false,\n \t} },\n \t{ formats::SGBRG12, {\n+\t\t.name = \"SGBRG12\",\n \t\t.format = formats::SGBRG12,\n \t\t.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SGBRG12),\n \t\t.bitsPerPixel = 12,\n@@ -394,6 +425,7 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n \t\t.packed = false,\n \t} },\n \t{ formats::SGRBG12, {\n+\t\t.name = \"SGRBG12\",\n \t\t.format = formats::SGRBG12,\n \t\t.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SGRBG12),\n \t\t.bitsPerPixel = 12,\n@@ -401,6 +433,7 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n \t\t.packed = false,\n \t} },\n \t{ formats::SRGGB12, {\n+\t\t.name = \"SRGGB12\",\n \t\t.format = formats::SRGGB12,\n \t\t.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SRGGB12),\n \t\t.bitsPerPixel = 12,\n@@ -408,6 +441,7 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n \t\t.packed = false,\n \t} },\n \t{ formats::SBGGR12_CSI2P, {\n+\t\t.name = \"SBGGR12_CSI2P\",\n \t\t.format = formats::SBGGR12_CSI2P,\n \t\t.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SBGGR12P),\n \t\t.bitsPerPixel = 12,\n@@ -415,6 +449,7 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n \t\t.packed = true,\n \t} },\n \t{ formats::SGBRG12_CSI2P, {\n+\t\t.name = \"SGBRG12_CSI2P\",\n \t\t.format = formats::SGBRG12_CSI2P,\n \t\t.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SGBRG12P),\n \t\t.bitsPerPixel = 12,\n@@ -422,6 +457,7 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n \t\t.packed = true,\n \t} },\n \t{ formats::SGRBG12_CSI2P, {\n+\t\t.name = \"SGRBG12_CSI2P\",\n \t\t.format = formats::SGRBG12_CSI2P,\n \t\t.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SGRBG12P),\n \t\t.bitsPerPixel = 12,\n@@ -429,6 +465,7 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n \t\t.packed = true,\n \t} },\n \t{ formats::SRGGB12_CSI2P, {\n+\t\t.name = \"SRGGB12_CSI2P\",\n \t\t.format = formats::SRGGB12_CSI2P,\n \t\t.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_SRGGB12P),\n \t\t.bitsPerPixel = 12,\n@@ -438,6 +475,7 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n \n \t/* Compressed formats. */\n \t{ formats::MJPEG, {\n+\t\t.name = \"MJPEG\",\n \t\t.format = formats::MJPEG,\n \t\t.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_MJPEG),\n \t\t.bitsPerPixel = 0,\n@@ -467,8 +505,8 @@ const PixelFormatInfo &PixelFormatInfo::info(const PixelFormat &format)\n \tconst auto iter = pixelFormatInfo.find(format);\n \tif (iter == pixelFormatInfo.end()) {\n \t\tLOG(Formats, Warning)\n-\t\t\t<< \"Unsupported pixel format \"\n-\t\t\t<< format.toString();\n+\t\t\t<< \"Unsupported pixel format 0x\"\n+\t\t\t<< utils::hex(format.fourcc());\n \t\treturn invalid;\n \t}\n \ndiff --git a/src/libcamera/pixel_format.cpp b/src/libcamera/pixel_format.cpp\nindex f191851..14addb5 100644\n--- a/src/libcamera/pixel_format.cpp\n+++ b/src/libcamera/pixel_format.cpp\n@@ -8,6 +8,8 @@\n #include <libcamera/formats.h>\n #include <libcamera/pixel_format.h>\n \n+#include \"libcamera/internal/formats.h\"\n+\n /**\n  * \\file pixel_format.h\n  * \\brief libcamera pixel format\n@@ -104,9 +106,28 @@ bool PixelFormat::operator<(const PixelFormat &other) const\n  */\n std::string PixelFormat::toString() const\n {\n-\tchar str[11];\n-\tsnprintf(str, 11, \"0x%08x\", fourcc_);\n-\treturn str;\n+\tconst PixelFormatInfo &info = PixelFormatInfo::info(*this);\n+\n+\tif (!info.isValid()) {\n+\t\tif (*this == PixelFormat())\n+\t\t\treturn \"<INVALID>\";\n+\n+\t\tchar fourcc[7] = { '<',\n+\t\t\t\t   static_cast<char>(fourcc_),\n+\t\t\t\t   static_cast<char>(fourcc_ >> 8),\n+\t\t\t\t   static_cast<char>(fourcc_ >> 16),\n+\t\t\t\t   static_cast<char>(fourcc_ >> 24),\n+\t\t\t\t   '>' };\n+\n+\t\tfor (unsigned int i = 1; i < 5; i++) {\n+\t\t\tif (!isprint(fourcc[i]))\n+\t\t\t\tfourcc[i] = '.';\n+\t\t}\n+\n+\t\treturn fourcc;\n+\t}\n+\n+\treturn info.name;\n }\n \n } /* namespace libcamera */\ndiff --git a/test/meson.build b/test/meson.build\nindex a868813..7808a26 100644\n--- a/test/meson.build\n+++ b/test/meson.build\n@@ -34,6 +34,7 @@ internal_tests = [\n     ['message',                         'message.cpp'],\n     ['object',                          'object.cpp'],\n     ['object-invoke',                   'object-invoke.cpp'],\n+    ['pixel-format',                    'pixel-format.cpp'],\n     ['signal-threads',                  'signal-threads.cpp'],\n     ['threads',                         'threads.cpp'],\n     ['timer',                           'timer.cpp'],\ndiff --git a/test/pixel-format.cpp b/test/pixel-format.cpp\nnew file mode 100644\nindex 0000000..c4a08f4\n--- /dev/null\n+++ b/test/pixel-format.cpp\n@@ -0,0 +1,51 @@\n+/* SPDX-License-Identifier: GPL-2.0-or-later */\n+/*\n+ * Copyright (C) 2020, Kaaira Gupta\n+ * libcamera pixel format handling test\n+ */\n+\n+#include <iostream>\n+#include <vector>\n+\n+#include <libcamera/formats.h>\n+#include <libcamera/pixel_format.h>\n+\n+#include \"libcamera/internal/utils.h\"\n+\n+#include \"test.h\"\n+\n+using namespace std;\n+using namespace libcamera;\n+\n+class PixelFormatTest : public Test\n+{\n+protected:\n+\tint run()\n+\t{\n+\t\tstd::vector<std::pair<PixelFormat, const char *>> formatsMap{\n+\t\t\t{ formats::R8, \"R8\" },\n+\t\t\t{ formats::SRGGB10_CSI2P, \"SRGGB10_CSI2P\" },\n+\t\t\t{ PixelFormat(0, 0), \"<INVALID>\" },\n+\t\t\t{ PixelFormat(0x20203843), \"<C8  >\" }\n+\t\t};\n+\n+\t\tfor (const auto &format : formatsMap) {\n+\t\t\tif ((format.first).toString() != format.second) {\n+\t\t\t\tcerr << \"Failed to convert PixelFormat \"\n+\t\t\t\t     << utils::hex(format.first.fourcc()) << \" to string\"\n+\t\t\t\t     << endl;\n+\t\t\t\treturn TestFail;\n+\t\t\t}\n+\t\t}\n+\n+\t\tif (PixelFormat().toString() != \"<INVALID>\") {\n+\t\t\tcerr << \"Failed to convert default PixelFormat to string\"\n+\t\t\t     << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\treturn TestPass;\n+\t}\n+};\n+\n+TEST_REGISTER(PixelFormatTest)\n",
    "prefixes": [
        "libcamera-devel",
        "v6"
    ]
}