Patch Detail
Show a patch.
GET /api/patches/4103/?format=api
{ "id": 4103, "url": "https://patchwork.libcamera.org/api/patches/4103/?format=api", "web_url": "https://patchwork.libcamera.org/patch/4103/", "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": "<20200619190631.GA13950@kaaira-HP-Pavilion-Notebook>", "date": "2020-06-19T19:06:31", "name": "[libcamera-devel,v5] libcamera:PixelFormat: Replace hex with format names", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "d242ac87bd55bd9d32ea910f05686c84e172a796", "submitter": { "id": 39, "url": "https://patchwork.libcamera.org/api/people/39/?format=api", "name": "Kaaira Gupta", "email": "kgupta@es.iitr.ac.in" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/4103/mbox/", "series": [ { "id": 1020, "url": "https://patchwork.libcamera.org/api/series/1020/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1020", "date": "2020-06-19T19:06:31", "name": "[libcamera-devel,v5] libcamera:PixelFormat: Replace hex with format names", "version": 5, "mbox": "https://patchwork.libcamera.org/series/1020/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/4103/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/4103/checks/", "tags": {}, "headers": { "Return-Path": "<kgupta@es.iitr.ac.in>", "Received": [ "from mail-pg1-x535.google.com (mail-pg1-x535.google.com\n\t[IPv6:2607:f8b0:4864:20::535])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 08C77600FE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 19 Jun 2020 21:06:39 +0200 (CEST)", "by mail-pg1-x535.google.com with SMTP id s10so4899037pgm.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 19 Jun 2020 12:06:39 -0700 (PDT)", "from kaaira-HP-Pavilion-Notebook ([103.113.213.178])\n\tby smtp.gmail.com with ESMTPSA id\n\tx126sm6657750pfc.36.2020.06.19.12.06.35\n\t(version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256);\n\tFri, 19 Jun 2020 12:06:37 -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=\"GVsGQhHk\"; \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=xXWxUHRlwLR0ExHZPIY7IGmpEErELaLAeLli60Fznw8=;\n\tb=GVsGQhHka7MJJOpgnlWcFsK9Tuy6FcV2W1YRSYdk4LvmGyk3gMpLSaCGgGO86NxnL7\n\tZJgq1UTqeJC2oQ1IFhSgPkE9h+rwvRMy7LlZd9Yd61MCF3W++hkbSLtaw6UorW3r/anS\n\tkJxecYVBvMhNMN4sL6kQXptWRjfke7mftOWBldIja8OX+3DxmE40Q8Prx4N1II27QScA\n\ttT5h6yh9NFkbxuYGLmmu8Y8CyO0d41Ts/4kUCzTHHZxVO6prLK8yWpTSFpEeya+mZBwE\n\ttRQz4h0D7H2xCfbI/ck2RcZnPdMnC3gme8KY7c7LxqJX0cfeezOz82NNknzp0UnYYEgZ\n\tJ6Pg==", "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=xXWxUHRlwLR0ExHZPIY7IGmpEErELaLAeLli60Fznw8=;\n\tb=ijrcBRW8nTFF5TZENRmYGiAS/MeVugUaHpIEWI3VWXUN3IzAZYjgdFsEsbwUxmpTV+\n\tTWLeSysdyJlHWUsmkJj628vv6lFck/+He/lrK1w+Mrhx3yiTWEjo+SQN8578Fbjqv+es\n\tIN62ZSMmqI4hKCrCklSYe11GszLk7rK8JSCQHSg10yY4tQqupsZ+3uxxTd88bs8gkdER\n\tp1z1vthG+yEw5iXmc/oZDHfnxQnTOclgoxpHdRe5dumDvaIPi0zNN2s8kUJUqnk/u36q\n\tWoIAZ8eK8gIspk8T/lr89wG56v6VpVqxH9+uEyEaaUvveplzJf4sGP057YP1peTHjGFV\n\tRozw==", "X-Gm-Message-State": "AOAM53095ZhqqnqTSir31UzvRhBpiq4M7/NoRceukUAfIAP4OanRHo9B\n\tSIA2AcCJJerSon0XQHzsTT9iHjDCUv/p7g==", "X-Google-Smtp-Source": "ABdhPJxGOJDYnxa+FrnDPQTbD2aSOA4i4KQ3OouOjnTnkD8qIGbwP20MFbE7KIaAQyKSgvSbrkek3g==", "X-Received": "by 2002:a63:5d19:: with SMTP id\n\tr25mr4144062pgb.360.1592593597555; \n\tFri, 19 Jun 2020 12:06:37 -0700 (PDT)", "Date": "Sat, 20 Jun 2020 00:36:31 +0530", "From": "Kaaira Gupta <kgupta@es.iitr.ac.in>", "To": "libcamera-devel@lists.libcamera.org,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>, Laurent Pinchart\n\t<laurent.pinchartatideasonboard.com@kaaira-HP-Pavilion-Notebook>", "Message-ID": "<20200619190631.GA13950@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 v5] 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": "Fri, 19 Jun 2020 19:06:41 -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>\n---\n\nChanges since v4:\n\t-Print libcamera defined names instead of fourcc.\n\nChanges since v3:\n\t-shortened the texts.\n\t-Removed default case as well.\n\t-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 | 40 +++++++++++++++++++++--\n src/libcamera/pixel_format.cpp | 27 +++++++++++++--\n test/meson.build | 1 +\n test/pixel-format.cpp | 49 ++++++++++++++++++++++++++++\n 5 files changed, 113 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..8012721 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+\tstd::string name;\n \tPixelFormat format;\n \tV4L2PixelFormat v4l2Format;\n \tunsigned int bitsPerPixel;\ndiff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp\nindex 97e9867..2908409 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@@ -273,6 +287,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@@ -282,6 +297,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@@ -289,6 +305,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@@ -296,6 +313,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@@ -303,6 +321,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@@ -310,6 +329,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@@ -317,6 +337,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@@ -324,6 +345,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@@ -331,6 +353,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@@ -338,6 +361,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@@ -345,6 +369,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@@ -352,6 +377,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@@ -359,6 +385,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@@ -366,6 +393,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@@ -373,6 +401,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@@ -380,6 +409,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@@ -387,6 +417,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@@ -394,6 +425,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@@ -401,6 +433,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@@ -408,6 +441,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@@ -415,6 +449,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@@ -424,6 +459,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@@ -453,8 +489,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<< std::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..07e7af0 100644\n--- a/src/libcamera/pixel_format.cpp\n+++ b/src/libcamera/pixel_format.cpp\n@@ -6,6 +6,7 @@\n */\n \n #include <libcamera/formats.h>\n+#include \"libcamera/internal/formats.h\"\n #include <libcamera/pixel_format.h>\n \n /**\n@@ -104,9 +105,29 @@ 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+\tPixelFormat format = PixelFormat(fourcc_, modifier_);\n+\tconst PixelFormatInfo &info = PixelFormatInfo::info(format);\n+\n+\tif (!info.isValid()) {\n+\t\tif (format == PixelFormat())\n+\t\t\treturn \"<INVALID>\";\n+\n+\t\tchar fourcc[7] = { '<',\n+\t\t\t\t static_cast<char>(fourcc_ & 0x7f),\n+\t\t\t\t static_cast<char>((fourcc_ >> 8) & 0x7f),\n+\t\t\t\t static_cast<char>((fourcc_ >> 16) & 0x7f),\n+\t\t\t\t static_cast<char>((fourcc_ >> 24) & 0x7f),\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..5b9cdc9\n--- /dev/null\n+++ b/test/pixel-format.cpp\n@@ -0,0 +1,49 @@\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 \"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 << 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", "v5" ] }