Show a patch.

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

{
    "id": 3138,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/3138/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/3138/",
    "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": "<20200317035239.2697679-8-niklas.soderlund@ragnatech.se>",
    "date": "2020-03-17T03:52:38",
    "name": "[libcamera-devel,v2,7/8] libcamera: PixelFormat: Make constructor explicit",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "5f6e428aafb341d34489484e50e7580b960f4b5a",
    "submitter": {
        "id": 5,
        "url": "https://patchwork.libcamera.org/api/1.1/people/5/?format=api",
        "name": "Niklas Söderlund",
        "email": "niklas.soderlund@ragnatech.se"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/3138/mbox/",
    "series": [
        {
            "id": 726,
            "url": "https://patchwork.libcamera.org/api/1.1/series/726/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=726",
            "date": "2020-03-17T03:52:31",
            "name": "libcamera: PixelFormat: Turn into a class",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/726/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/3138/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/3138/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<niklas.soderlund@ragnatech.se>",
        "Received": [
            "from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net\n\t[195.74.38.227])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 32984629A4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 17 Mar 2020 04:53:41 +0100 (CET)",
            "from bismarck.berto.se (p4fca2392.dip0.t-ipconnect.de\n\t[79.202.35.146]) by bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA\n\tid dc4e679c-6802-11ea-aa6d-005056917f90;\n\tTue, 17 Mar 2020 04:53:28 +0100 (CET)"
        ],
        "X-Halon-ID": "dc4e679c-6802-11ea-aa6d-005056917f90",
        "Authorized-sender": "niklas@soderlund.pp.se",
        "From": "=?utf-8?q?Niklas_S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Tue, 17 Mar 2020 04:52:38 +0100",
        "Message-Id": "<20200317035239.2697679-8-niklas.soderlund@ragnatech.se>",
        "X-Mailer": "git-send-email 2.25.1",
        "In-Reply-To": "<20200317035239.2697679-1-niklas.soderlund@ragnatech.se>",
        "References": "<20200317035239.2697679-1-niklas.soderlund@ragnatech.se>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=UTF-8",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v2 7/8] libcamera: PixelFormat: Make\n\tconstructor explicit",
        "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": "Tue, 17 Mar 2020 03:53:41 -0000"
    },
    "content": "From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nTo achieve the goal of preventing unwanted conversion between a DRM and\na V4L2 FourCC, make the PixelFormat constructor that takes an integer\nvalue explicit. All users of V4L2 pixel formats flagged by the compiler\nare fixed.\n\nWhile at it make the compare operations part of PixelFormat class.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n[Niklas: Make the compare operations part of PixelFormat]\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n include/libcamera/pixelformats.h         | 10 ++---\n src/gstreamer/gstlibcamera-utils.cpp     |  4 +-\n src/libcamera/pipeline/ipu3/ipu3.cpp     |  6 +--\n src/libcamera/pipeline/rkisp1/rkisp1.cpp | 20 ++++-----\n src/libcamera/pipeline/vimc.cpp          | 12 ++---\n src/libcamera/pixelformats.cpp           | 57 ++++++++++++------------\n src/libcamera/v4l2_videodevice.cpp       | 26 +++++------\n src/v4l2/v4l2_camera_proxy.cpp           | 28 ++++++------\n test/stream/stream_formats.cpp           | 24 +++++-----\n test/v4l2_videodevice/buffer_cache.cpp   |  2 +-\n 10 files changed, 94 insertions(+), 95 deletions(-)",
    "diff": "diff --git a/include/libcamera/pixelformats.h b/include/libcamera/pixelformats.h\nindex 5ba1ba1b324272b9..3285941382ccdd96 100644\n--- a/include/libcamera/pixelformats.h\n+++ b/include/libcamera/pixelformats.h\n@@ -17,7 +17,11 @@ class PixelFormat\n {\n public:\n \tPixelFormat();\n-\tPixelFormat(uint32_t fourcc, const std::set<uint64_t> &modifiers = {});\n+\texplicit PixelFormat(uint32_t fourcc, const std::set<uint64_t> &modifiers = {});\n+\n+\tbool operator==(const PixelFormat &other) const;\n+\tbool operator!=(const PixelFormat &other) const;\n+\tbool operator<(const PixelFormat &other) const;\n \n \tuint32_t fourcc() const { return fourcc_; }\n \tconst std::set<uint64_t> &modifiers() const { return modifiers_; }\n@@ -28,10 +32,6 @@ private:\n \tstd::set<uint64_t> modifiers_;\n };\n \n-bool operator==(const PixelFormat &lhs, const PixelFormat &rhs);\n-bool operator!=(const PixelFormat &lhs, const PixelFormat &rhs);\n-bool operator<(const PixelFormat &lhs, const PixelFormat &rhs);\n-\n } /* namespace libcamera */\n \n #endif /* __LIBCAMERA_PIXEL_FORMATS_H__ */\ndiff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp\nindex f21e94c3eef92737..c13b0ca245386168 100644\n--- a/src/gstreamer/gstlibcamera-utils.cpp\n+++ b/src/gstreamer/gstlibcamera-utils.cpp\n@@ -154,9 +154,9 @@ gst_libcamera_configure_stream_from_caps(StreamConfiguration &stream_cfg,\n \tif (gst_structure_has_name(s, \"video/x-raw\")) {\n \t\tconst gchar *format = gst_structure_get_string(s, \"format\");\n \t\tgst_format = gst_video_format_from_string(format);\n-\t\tstream_cfg.pixelFormat = gst_format_to_drm(gst_format);\n+\t\tstream_cfg.pixelFormat = PixelFormat(gst_format_to_drm(gst_format));\n \t} else if (gst_structure_has_name(s, \"image/jpeg\")) {\n-\t\tstream_cfg.pixelFormat = DRM_FORMAT_MJPEG;\n+\t\tstream_cfg.pixelFormat = PixelFormat(DRM_FORMAT_MJPEG);\n \t} else {\n \t\tg_critical(\"Unsupported media type: %s\", gst_structure_get_name(s));\n \t}\ndiff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nindex 0c2a217c9ea8f6ba..52b6d48aca4394c6 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -246,7 +246,7 @@ IPU3CameraConfiguration::IPU3CameraConfiguration(Camera *camera,\n void IPU3CameraConfiguration::adjustStream(StreamConfiguration &cfg, bool scale)\n {\n \t/* The only pixel format the driver supports is NV12. */\n-\tcfg.pixelFormat = DRM_FORMAT_NV12;\n+\tcfg.pixelFormat = PixelFormat(DRM_FORMAT_NV12);\n \n \tif (scale) {\n \t\t/*\n@@ -401,7 +401,7 @@ CameraConfiguration *PipelineHandlerIPU3::generateConfiguration(Camera *camera,\n \t\tStreamConfiguration cfg = {};\n \t\tIPU3Stream *stream = nullptr;\n \n-\t\tcfg.pixelFormat = DRM_FORMAT_NV12;\n+\t\tcfg.pixelFormat = PixelFormat(DRM_FORMAT_NV12);\n \n \t\tswitch (role) {\n \t\tcase StreamRole::StillCapture:\n@@ -1079,7 +1079,7 @@ int ImgUDevice::configureOutput(ImgUOutput *output,\n \t\treturn 0;\n \n \tV4L2DeviceFormat outputFormat = {};\n-\toutputFormat.fourcc = dev->toV4L2Fourcc(DRM_FORMAT_NV12);\n+\toutputFormat.fourcc = dev->toV4L2Fourcc(PixelFormat(DRM_FORMAT_NV12));\n \toutputFormat.size = cfg.size;\n \toutputFormat.planesCount = 2;\n \ndiff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\nindex 8223b82c4a9c773c..3bbe73c3abd9d75e 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n@@ -431,14 +431,14 @@ RkISP1CameraConfiguration::RkISP1CameraConfiguration(Camera *camera,\n \n CameraConfiguration::Status RkISP1CameraConfiguration::validate()\n {\n-\tstatic const std::array<unsigned int, 8> formats{\n-\t\tDRM_FORMAT_YUYV,\n-\t\tDRM_FORMAT_YVYU,\n-\t\tDRM_FORMAT_VYUY,\n-\t\tDRM_FORMAT_NV16,\n-\t\tDRM_FORMAT_NV61,\n-\t\tDRM_FORMAT_NV21,\n-\t\tDRM_FORMAT_NV12,\n+\tstatic const std::array<PixelFormat, 8> formats{\n+\t\tPixelFormat(DRM_FORMAT_YUYV),\n+\t\tPixelFormat(DRM_FORMAT_YVYU),\n+\t\tPixelFormat(DRM_FORMAT_VYUY),\n+\t\tPixelFormat(DRM_FORMAT_NV16),\n+\t\tPixelFormat(DRM_FORMAT_NV61),\n+\t\tPixelFormat(DRM_FORMAT_NV21),\n+\t\tPixelFormat(DRM_FORMAT_NV12),\n \t\t/* \\todo Add support for 8-bit greyscale to DRM formats */\n \t};\n \n@@ -460,7 +460,7 @@ CameraConfiguration::Status RkISP1CameraConfiguration::validate()\n \tif (std::find(formats.begin(), formats.end(), cfg.pixelFormat) ==\n \t    formats.end()) {\n \t\tLOG(RkISP1, Debug) << \"Adjusting format to NV12\";\n-\t\tcfg.pixelFormat = DRM_FORMAT_NV12,\n+\t\tcfg.pixelFormat = PixelFormat(DRM_FORMAT_NV12),\n \t\tstatus = Adjusted;\n \t}\n \n@@ -539,7 +539,7 @@ CameraConfiguration *PipelineHandlerRkISP1::generateConfiguration(Camera *camera\n \t\treturn config;\n \n \tStreamConfiguration cfg{};\n-\tcfg.pixelFormat = DRM_FORMAT_NV12;\n+\tcfg.pixelFormat = PixelFormat(DRM_FORMAT_NV12);\n \tcfg.size = data->sensor_->resolution();\n \n \tconfig->addConfiguration(cfg);\ndiff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp\nindex 72924bf2f55d0021..8dad2b40ed4fbb2c 100644\n--- a/src/libcamera/pipeline/vimc.cpp\n+++ b/src/libcamera/pipeline/vimc.cpp\n@@ -104,10 +104,10 @@ private:\n \n namespace {\n \n-constexpr std::array<unsigned int, 3> pixelformats{\n-\tDRM_FORMAT_RGB888,\n-\tDRM_FORMAT_BGR888,\n-\tDRM_FORMAT_BGRA8888,\n+const std::array<PixelFormat, 3> pixelformats{\n+\tPixelFormat(DRM_FORMAT_RGB888),\n+\tPixelFormat(DRM_FORMAT_BGR888),\n+\tPixelFormat(DRM_FORMAT_BGRA8888),\n };\n \n } /* namespace */\n@@ -136,7 +136,7 @@ CameraConfiguration::Status VimcCameraConfiguration::validate()\n \tif (std::find(pixelformats.begin(), pixelformats.end(), cfg.pixelFormat) ==\n \t    pixelformats.end()) {\n \t\tLOG(VIMC, Debug) << \"Adjusting format to RGB24\";\n-\t\tcfg.pixelFormat = DRM_FORMAT_BGR888;\n+\t\tcfg.pixelFormat = PixelFormat(DRM_FORMAT_BGR888);\n \t\tstatus = Adjusted;\n \t}\n \n@@ -185,7 +185,7 @@ CameraConfiguration *PipelineHandlerVimc::generateConfiguration(Camera *camera,\n \n \tStreamConfiguration cfg(formats);\n \n-\tcfg.pixelFormat = DRM_FORMAT_BGR888;\n+\tcfg.pixelFormat = PixelFormat(DRM_FORMAT_BGR888);\n \tcfg.size = { 1920, 1080 };\n \tcfg.bufferCount = 4;\n \ndiff --git a/src/libcamera/pixelformats.cpp b/src/libcamera/pixelformats.cpp\nindex fe9a6a2576978647..1c559fe46d406826 100644\n--- a/src/libcamera/pixelformats.cpp\n+++ b/src/libcamera/pixelformats.cpp\n@@ -41,6 +41,34 @@ PixelFormat::PixelFormat(uint32_t fourcc, const std::set<uint64_t> &modifiers)\n {\n }\n \n+/**\n+ * \\brief Compare pixel formats for equality\n+ * \\return True if the two pixel formats are equal, false otherwise\n+ */\n+bool PixelFormat::operator==(const PixelFormat &other) const\n+{\n+\treturn fourcc_ == other.fourcc() && modifiers_ == other.modifiers_;\n+}\n+\n+/**\n+ * \\brief Compare pixel formats for inequality\n+ * \\return True if the two pixel formats are not equal, false otherwise\n+ */\n+bool PixelFormat::operator!=(const PixelFormat &other) const\n+{\n+\treturn !(*this == other);\n+}\n+\n+/**\n+ * \\brief Compare pixel formats for smaller than order\n+ * \\todo Take modifiers into account if FourCC are equal\n+ * \\return True if \\a this is smaller than \\a other, false otherwise\n+ */\n+bool PixelFormat::operator<(const PixelFormat &other) const\n+{\n+\treturn fourcc_ < other.fourcc_;\n+}\n+\n /**\n  * \\fn PixelFormat::fourcc() const\n  * \\brief Retrieve the pixel format FourCC\n@@ -64,33 +92,4 @@ std::string PixelFormat::toString() const\n \treturn str;\n }\n \n-/**\n- * \\brief Compare pixel formats for equality\n- * \\return True if the two pixel formats are equal, false otherwise\n- */\n-bool operator==(const PixelFormat &lhs, const PixelFormat &rhs)\n-{\n-\treturn lhs.fourcc() == rhs.fourcc() &&\n-\t       lhs.modifiers() == rhs.modifiers();\n-}\n-\n-/**\n- * \\brief Compare pixel formats for inequality\n- * \\return True if the two pixel formats are not equal, false otherwise\n- */\n-bool operator!=(const PixelFormat &lhs, const PixelFormat &rhs)\n-{\n-\treturn !(lhs == rhs);\n-}\n-\n-/**\n- * \\brief Compare pixel formats for smaller than order\n- * \\todo Take modifiers into account if \\a lhs == \\a rhs.\n- * \\return True if \\a lhs is smaller than \\a rhs, false otherwise\n- */\n-bool operator<(const PixelFormat &lhs, const PixelFormat &rhs)\n-{\n-\treturn lhs.fourcc() < rhs.fourcc();\n-}\n-\n } /* namespace libcamera */\ndiff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\nindex b5762a7eabcf4e25..d8d711a951d666e9 100644\n--- a/src/libcamera/v4l2_videodevice.cpp\n+++ b/src/libcamera/v4l2_videodevice.cpp\n@@ -1563,39 +1563,39 @@ PixelFormat V4L2VideoDevice::toPixelFormat(uint32_t v4l2Fourcc)\n \tswitch (v4l2Fourcc) {\n \t/* RGB formats. */\n \tcase V4L2_PIX_FMT_RGB24:\n-\t\treturn DRM_FORMAT_BGR888;\n+\t\treturn PixelFormat(DRM_FORMAT_BGR888);\n \tcase V4L2_PIX_FMT_BGR24:\n-\t\treturn DRM_FORMAT_RGB888;\n+\t\treturn PixelFormat(DRM_FORMAT_RGB888);\n \tcase V4L2_PIX_FMT_ARGB32:\n-\t\treturn DRM_FORMAT_BGRA8888;\n+\t\treturn PixelFormat(DRM_FORMAT_BGRA8888);\n \n \t/* YUV packed formats. */\n \tcase V4L2_PIX_FMT_YUYV:\n-\t\treturn DRM_FORMAT_YUYV;\n+\t\treturn PixelFormat(DRM_FORMAT_YUYV);\n \tcase V4L2_PIX_FMT_YVYU:\n-\t\treturn DRM_FORMAT_YVYU;\n+\t\treturn PixelFormat(DRM_FORMAT_YVYU);\n \tcase V4L2_PIX_FMT_UYVY:\n-\t\treturn DRM_FORMAT_UYVY;\n+\t\treturn PixelFormat(DRM_FORMAT_UYVY);\n \tcase V4L2_PIX_FMT_VYUY:\n-\t\treturn DRM_FORMAT_VYUY;\n+\t\treturn PixelFormat(DRM_FORMAT_VYUY);\n \n \t/* YUY planar formats. */\n \tcase V4L2_PIX_FMT_NV16:\n \tcase V4L2_PIX_FMT_NV16M:\n-\t\treturn DRM_FORMAT_NV16;\n+\t\treturn PixelFormat(DRM_FORMAT_NV16);\n \tcase V4L2_PIX_FMT_NV61:\n \tcase V4L2_PIX_FMT_NV61M:\n-\t\treturn DRM_FORMAT_NV61;\n+\t\treturn PixelFormat(DRM_FORMAT_NV61);\n \tcase V4L2_PIX_FMT_NV12:\n \tcase V4L2_PIX_FMT_NV12M:\n-\t\treturn DRM_FORMAT_NV12;\n+\t\treturn PixelFormat(DRM_FORMAT_NV12);\n \tcase V4L2_PIX_FMT_NV21:\n \tcase V4L2_PIX_FMT_NV21M:\n-\t\treturn DRM_FORMAT_NV21;\n+\t\treturn PixelFormat(DRM_FORMAT_NV21);\n \n \t/* Compressed formats. */\n \tcase V4L2_PIX_FMT_MJPEG:\n-\t\treturn DRM_FORMAT_MJPEG;\n+\t\treturn PixelFormat(DRM_FORMAT_MJPEG);\n \n \t/* V4L2 formats not yet supported by DRM. */\n \tcase V4L2_PIX_FMT_GREY:\n@@ -1608,7 +1608,7 @@ PixelFormat V4L2VideoDevice::toPixelFormat(uint32_t v4l2Fourcc)\n \t\t\t\tLogError).stream()\n \t\t\t<< \"Unsupported V4L2 pixel format \"\n \t\t\t<< utils::hex(v4l2Fourcc);\n-\t\treturn 0;\n+\t\treturn PixelFormat();\n \t}\n }\n \ndiff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp\nindex 3bbbbf79cdb475db..55dd69d37bd65897 100644\n--- a/src/v4l2/v4l2_camera_proxy.cpp\n+++ b/src/v4l2/v4l2_camera_proxy.cpp\n@@ -536,21 +536,21 @@ namespace {\n \n static const std::array<PixelFormatInfo, 13> pixelFormatInfo = {{\n \t/* RGB formats. */\n-\t{ DRM_FORMAT_RGB888,\tV4L2_PIX_FMT_BGR24,\t1, {{ { 24, 1, 1 }, {  0, 0, 0 }, {  0, 0, 0 } }} },\n-\t{ DRM_FORMAT_BGR888,\tV4L2_PIX_FMT_RGB24,\t1, {{ { 24, 1, 1 }, {  0, 0, 0 }, {  0, 0, 0 } }} },\n-\t{ DRM_FORMAT_BGRA8888,\tV4L2_PIX_FMT_ARGB32,\t1, {{ { 32, 1, 1 }, {  0, 0, 0 }, {  0, 0, 0 } }} },\n+\t{ PixelFormat(DRM_FORMAT_RGB888),\tV4L2_PIX_FMT_BGR24,\t1, {{ { 24, 1, 1 }, {  0, 0, 0 }, {  0, 0, 0 } }} },\n+\t{ PixelFormat(DRM_FORMAT_BGR888),\tV4L2_PIX_FMT_RGB24,\t1, {{ { 24, 1, 1 }, {  0, 0, 0 }, {  0, 0, 0 } }} },\n+\t{ PixelFormat(DRM_FORMAT_BGRA8888),\tV4L2_PIX_FMT_ARGB32,\t1, {{ { 32, 1, 1 }, {  0, 0, 0 }, {  0, 0, 0 } }} },\n \t/* YUV packed formats. */\n-\t{ DRM_FORMAT_UYVY,\tV4L2_PIX_FMT_UYVY,\t1, {{ { 16, 1, 1 }, {  0, 0, 0 }, {  0, 0, 0 } }} },\n-\t{ DRM_FORMAT_VYUY,\tV4L2_PIX_FMT_VYUY,\t1, {{ { 16, 1, 1 }, {  0, 0, 0 }, {  0, 0, 0 } }} },\n-\t{ DRM_FORMAT_YUYV,\tV4L2_PIX_FMT_YUYV,\t1, {{ { 16, 1, 1 }, {  0, 0, 0 }, {  0, 0, 0 } }} },\n-\t{ DRM_FORMAT_YVYU,\tV4L2_PIX_FMT_YVYU,\t1, {{ { 16, 1, 1 }, {  0, 0, 0 }, {  0, 0, 0 } }} },\n+\t{ PixelFormat(DRM_FORMAT_UYVY),\t\tV4L2_PIX_FMT_UYVY,\t1, {{ { 16, 1, 1 }, {  0, 0, 0 }, {  0, 0, 0 } }} },\n+\t{ PixelFormat(DRM_FORMAT_VYUY),\t\tV4L2_PIX_FMT_VYUY,\t1, {{ { 16, 1, 1 }, {  0, 0, 0 }, {  0, 0, 0 } }} },\n+\t{ PixelFormat(DRM_FORMAT_YUYV),\t\tV4L2_PIX_FMT_YUYV,\t1, {{ { 16, 1, 1 }, {  0, 0, 0 }, {  0, 0, 0 } }} },\n+\t{ PixelFormat(DRM_FORMAT_YVYU),\t\tV4L2_PIX_FMT_YVYU,\t1, {{ { 16, 1, 1 }, {  0, 0, 0 }, {  0, 0, 0 } }} },\n \t/* YUY planar formats. */\n-\t{ DRM_FORMAT_NV12,\tV4L2_PIX_FMT_NV12,\t2, {{ {  8, 1, 1 }, { 16, 2, 2 }, {  0, 0, 0 } }} },\n-\t{ DRM_FORMAT_NV21,\tV4L2_PIX_FMT_NV21,\t2, {{ {  8, 1, 1 }, { 16, 2, 2 }, {  0, 0, 0 } }} },\n-\t{ DRM_FORMAT_NV16,\tV4L2_PIX_FMT_NV16,\t2, {{ {  8, 1, 1 }, { 16, 2, 1 }, {  0, 0, 0 } }} },\n-\t{ DRM_FORMAT_NV61,\tV4L2_PIX_FMT_NV61,\t2, {{ {  8, 1, 1 }, { 16, 2, 1 }, {  0, 0, 0 } }} },\n-\t{ DRM_FORMAT_NV24,\tV4L2_PIX_FMT_NV24,\t2, {{ {  8, 1, 1 }, { 16, 2, 1 }, {  0, 0, 0 } }} },\n-\t{ DRM_FORMAT_NV42,\tV4L2_PIX_FMT_NV42,\t2, {{ {  8, 1, 1 }, { 16, 1, 1 }, {  0, 0, 0 } }} },\n+\t{ PixelFormat(DRM_FORMAT_NV12),\t\tV4L2_PIX_FMT_NV12,\t2, {{ {  8, 1, 1 }, { 16, 2, 2 }, {  0, 0, 0 } }} },\n+\t{ PixelFormat(DRM_FORMAT_NV21),\t\tV4L2_PIX_FMT_NV21,\t2, {{ {  8, 1, 1 }, { 16, 2, 2 }, {  0, 0, 0 } }} },\n+\t{ PixelFormat(DRM_FORMAT_NV16),\t\tV4L2_PIX_FMT_NV16,\t2, {{ {  8, 1, 1 }, { 16, 2, 1 }, {  0, 0, 0 } }} },\n+\t{ PixelFormat(DRM_FORMAT_NV61),\t\tV4L2_PIX_FMT_NV61,\t2, {{ {  8, 1, 1 }, { 16, 2, 1 }, {  0, 0, 0 } }} },\n+\t{ PixelFormat(DRM_FORMAT_NV24),\t\tV4L2_PIX_FMT_NV24,\t2, {{ {  8, 1, 1 }, { 16, 2, 1 }, {  0, 0, 0 } }} },\n+\t{ PixelFormat(DRM_FORMAT_NV42),\t\tV4L2_PIX_FMT_NV42,\t2, {{ {  8, 1, 1 }, { 16, 1, 1 }, {  0, 0, 0 } }} },\n }};\n \n } /* namespace */\n@@ -594,7 +594,7 @@ PixelFormat V4L2CameraProxy::v4l2ToDrm(uint32_t format)\n \t\t\t\t\t return info.v4l2Format == format;\n \t\t\t\t });\n \tif (info == pixelFormatInfo.end())\n-\t\treturn format;\n+\t\treturn PixelFormat();\n \n \treturn info->format;\n }\ndiff --git a/test/stream/stream_formats.cpp b/test/stream/stream_formats.cpp\nindex a391f5cd087d3872..92f1574b8a0b315c 100644\n--- a/test/stream/stream_formats.cpp\n+++ b/test/stream/stream_formats.cpp\n@@ -55,40 +55,40 @@ protected:\n \t{\n \t\t/* Test discrete sizes */\n \t\tStreamFormats discrete({\n-\t\t\t{ 1, { SizeRange(100, 100), SizeRange(200, 200) } },\n-\t\t\t{ 2, { SizeRange(300, 300), SizeRange(400, 400) } },\n+\t\t\t{ PixelFormat(1), { SizeRange(100, 100), SizeRange(200, 200) } },\n+\t\t\t{ PixelFormat(2), { SizeRange(300, 300), SizeRange(400, 400) } },\n \t\t});\n \n-\t\tif (testSizes(\"discrete 1\", discrete.sizes(1),\n+\t\tif (testSizes(\"discrete 1\", discrete.sizes(PixelFormat(1)),\n \t\t\t      { Size(100, 100), Size(200, 200) }))\n \t\t\treturn TestFail;\n-\t\tif (testSizes(\"discrete 2\", discrete.sizes(2),\n+\t\tif (testSizes(\"discrete 2\", discrete.sizes(PixelFormat(2)),\n \t\t\t      { Size(300, 300), Size(400, 400) }))\n \t\t\treturn TestFail;\n \n \t\t/* Test range sizes */\n \t\tStreamFormats range({\n-\t\t\t{ 1, { SizeRange(640, 480, 640, 480) } },\n-\t\t\t{ 2, { SizeRange(640, 480, 800, 600, 8, 8) } },\n-\t\t\t{ 3, { SizeRange(640, 480, 800, 600, 16, 16) } },\n-\t\t\t{ 4, { SizeRange(128, 128, 4096, 4096, 128, 128) } },\n+\t\t\t{ PixelFormat(1), { SizeRange(640, 480, 640, 480) } },\n+\t\t\t{ PixelFormat(2), { SizeRange(640, 480, 800, 600, 8, 8) } },\n+\t\t\t{ PixelFormat(3), { SizeRange(640, 480, 800, 600, 16, 16) } },\n+\t\t\t{ PixelFormat(4), { SizeRange(128, 128, 4096, 4096, 128, 128) } },\n \t\t});\n \n-\t\tif (testSizes(\"range 1\", range.sizes(1), { Size(640, 480) }))\n+\t\tif (testSizes(\"range 1\", range.sizes(PixelFormat(1)), { Size(640, 480) }))\n \t\t\treturn TestFail;\n \n-\t\tif (testSizes(\"range 2\", range.sizes(2), {\n+\t\tif (testSizes(\"range 2\", range.sizes(PixelFormat(2)), {\n \t\t\t      Size(640, 480), Size(720, 480),\n \t\t\t      Size(720, 576), Size(768, 480),\n \t\t\t      Size(800, 600) }))\n \t\t\treturn TestFail;\n \n-\t\tif (testSizes(\"range 3\", range.sizes(3), {\n+\t\tif (testSizes(\"range 3\", range.sizes(PixelFormat(3)), {\n \t\t\t      Size(640, 480), Size(720, 480),\n \t\t\t      Size(720, 576), Size(768, 480) }))\n \t\t\treturn TestFail;\n \n-\t\tif (testSizes(\"range 4\", range.sizes(4), {\n+\t\tif (testSizes(\"range 4\", range.sizes(PixelFormat(4)), {\n \t\t\t      Size(1024, 768), Size(1280, 1024),\n \t\t\t      Size(2048, 1152), Size(2048, 1536),\n \t\t\t      Size(2560, 2048), Size(3200, 2048), }))\ndiff --git a/test/v4l2_videodevice/buffer_cache.cpp b/test/v4l2_videodevice/buffer_cache.cpp\nindex c951bc9650dc4e0e..8921605030cfdefb 100644\n--- a/test/v4l2_videodevice/buffer_cache.cpp\n+++ b/test/v4l2_videodevice/buffer_cache.cpp\n@@ -144,7 +144,7 @@ public:\n \t\tconst unsigned int numBuffers = 8;\n \n \t\tStreamConfiguration cfg;\n-\t\tcfg.pixelFormat = DRM_FORMAT_YUYV;\n+\t\tcfg.pixelFormat = PixelFormat(DRM_FORMAT_YUYV);\n \t\tcfg.size = Size(600, 800);\n \t\tcfg.bufferCount = numBuffers;\n \n",
    "prefixes": [
        "libcamera-devel",
        "v2",
        "7/8"
    ]
}