Show a patch.

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

{
    "id": 2290,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/2290/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/2290/",
    "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": "<20191028110208.15751-8-laurent.pinchart@ideasonboard.com>",
    "date": "2019-10-28T11:02:08",
    "name": "[libcamera-devel,v2,7/7] libcamera: Switch PixelFormat to DRM FourCC values",
    "commit_ref": "448716d8f75185795d9b01164440d0753850a80a",
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "b6ee05c573c7232c1699d4683f00d340b14dd9ea",
    "submitter": {
        "id": 2,
        "url": "https://patchwork.libcamera.org/api/1.1/people/2/?format=api",
        "name": "Laurent Pinchart",
        "email": "laurent.pinchart@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/2290/mbox/",
    "series": [
        {
            "id": 564,
            "url": "https://patchwork.libcamera.org/api/1.1/series/564/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=564",
            "date": "2019-10-28T11:02:01",
            "name": "libcamera: Introduce a PixelFormat type",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/564/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/2290/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/2290/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<laurent.pinchart@ideasonboard.com>",
        "Received": [
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3944861509\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 28 Oct 2019 12:02:21 +0100 (CET)",
            "from pendragon.ideasonboard.com (unknown [91.217.168.176])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id AC23CA4C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 28 Oct 2019 12:02:20 +0100 (CET)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1572260540;\n\tbh=21F6mr1Cn9vP4FCmLzCiqwEe6z9VM7OPm500yXprAEE=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=FGn5/tIqBhrz8tUig5a/fWezBdKVVSyAOAmy5ca+0G3COhqVpnUUVvLr6z6l5khuq\n\t4EfX7vsTAxVkVyH9pIrtY5f+lLuY5fQXvdIqPgy7J0LE71yy0oEjU/06+dS8/klarp\n\tvTBgYYFh4Rrn7jhaOM3Loe1MXpoDRE337KwzBo20=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Mon, 28 Oct 2019 13:02:08 +0200",
        "Message-Id": "<20191028110208.15751-8-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.23.0",
        "In-Reply-To": "<20191028110208.15751-1-laurent.pinchart@ideasonboard.com>",
        "References": "<20191028110208.15751-1-laurent.pinchart@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v2 7/7] libcamera: Switch PixelFormat to\n\tDRM FourCC values",
        "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, 28 Oct 2019 11:02:22 -0000"
    },
    "content": "From: Jacopo Mondi <jacopo@jmondi.org>\n\nUse DRM FourCC values for the newly defined PixelFormat.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/libcamera/pipeline/ipu3/ipu3.cpp     |  7 +++---\n src/libcamera/pipeline/rkisp1/rkisp1.cpp | 25 ++++++++++----------\n src/libcamera/pipeline/uvcvideo.cpp      |  4 ++--\n src/libcamera/pipeline/vimc.cpp          | 15 ++++++------\n src/libcamera/pixelformats.cpp           |  6 +++--\n src/qcam/format_converter.cpp            | 30 ++++++++++++------------\n test/camera/buffer_import.cpp            | 17 ++++++++++----\n 7 files changed, 58 insertions(+), 46 deletions(-)",
    "diff": "diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nindex 8d3ad568d16e..1c5fccf69428 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -10,6 +10,7 @@\n #include <memory>\n #include <vector>\n \n+#include <linux/drm_fourcc.h>\n #include <linux/media-bus-format.h>\n \n #include <libcamera/camera.h>\n@@ -249,7 +250,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 = V4L2_PIX_FMT_NV12;\n+\tcfg.pixelFormat = DRM_FORMAT_NV12;\n \n \tif (scale) {\n \t\t/*\n@@ -404,7 +405,7 @@ CameraConfiguration *PipelineHandlerIPU3::generateConfiguration(Camera *camera,\n \t\tStreamConfiguration cfg = {};\n \t\tIPU3Stream *stream = nullptr;\n \n-\t\tcfg.pixelFormat = V4L2_PIX_FMT_NV12;\n+\t\tcfg.pixelFormat = DRM_FORMAT_NV12;\n \n \t\tswitch (role) {\n \t\tcase StreamRole::StillCapture:\n@@ -1121,7 +1122,7 @@ int ImgUDevice::configureOutput(ImgUOutput *output,\n \t\treturn 0;\n \n \tV4L2DeviceFormat outputFormat = {};\n-\toutputFormat.fourcc = V4L2_PIX_FMT_NV12;\n+\toutputFormat.fourcc = dev->toV4L2Fourcc(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 7a28b03b8d38..b21cf92435e7 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n@@ -11,6 +11,7 @@\n #include <memory>\n #include <queue>\n \n+#include <linux/drm_fourcc.h>\n #include <linux/media-bus-format.h>\n \n #include <ipa/rkisp1.h>\n@@ -434,14 +435,14 @@ RkISP1CameraConfiguration::RkISP1CameraConfiguration(Camera *camera,\n CameraConfiguration::Status RkISP1CameraConfiguration::validate()\n {\n \tstatic const std::array<unsigned int, 8> formats{\n-\t\tV4L2_PIX_FMT_YUYV,\n-\t\tV4L2_PIX_FMT_YVYU,\n-\t\tV4L2_PIX_FMT_VYUY,\n-\t\tV4L2_PIX_FMT_NV16,\n-\t\tV4L2_PIX_FMT_NV61,\n-\t\tV4L2_PIX_FMT_NV21,\n-\t\tV4L2_PIX_FMT_NV12,\n-\t\tV4L2_PIX_FMT_GREY,\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+\t\t/* \\todo Add support for 8-bit greyscale to DRM formats */\n \t};\n \n \tconst CameraSensor *sensor = data_->sensor_;\n@@ -462,7 +463,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 = V4L2_PIX_FMT_NV12;\n+\t\tcfg.pixelFormat = DRM_FORMAT_NV12,\n \t\tstatus = Adjusted;\n \t}\n \n@@ -541,7 +542,7 @@ CameraConfiguration *PipelineHandlerRkISP1::generateConfiguration(Camera *camera\n \t\treturn config;\n \n \tStreamConfiguration cfg{};\n-\tcfg.pixelFormat = V4L2_PIX_FMT_NV12;\n+\tcfg.pixelFormat = DRM_FORMAT_NV12;\n \tcfg.size = data->sensor_->resolution();\n \n \tconfig->addConfiguration(cfg);\n@@ -623,7 +624,7 @@ int PipelineHandlerRkISP1::configure(Camera *camera, CameraConfiguration *c)\n \tLOG(RkISP1, Debug) << \"ISP output pad configured with \" << format.toString();\n \n \tV4L2DeviceFormat outputFormat = {};\n-\toutputFormat.fourcc = cfg.pixelFormat;\n+\toutputFormat.fourcc = video_->toV4L2Fourcc(cfg.pixelFormat);\n \toutputFormat.size = cfg.size;\n \toutputFormat.planesCount = 2;\n \n@@ -632,7 +633,7 @@ int PipelineHandlerRkISP1::configure(Camera *camera, CameraConfiguration *c)\n \t\treturn ret;\n \n \tif (outputFormat.size != cfg.size ||\n-\t    outputFormat.fourcc != cfg.pixelFormat) {\n+\t    outputFormat.fourcc != video_->toV4L2Fourcc(cfg.pixelFormat)) {\n \t\tLOG(RkISP1, Error)\n \t\t\t<< \"Unable to configure capture in \" << cfg.toString();\n \t\treturn -EINVAL;\ndiff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp\nindex fae0ffc4de30..45448d6f8c05 100644\n--- a/src/libcamera/pipeline/uvcvideo.cpp\n+++ b/src/libcamera/pipeline/uvcvideo.cpp\n@@ -176,7 +176,7 @@ int PipelineHandlerUVC::configure(Camera *camera, CameraConfiguration *config)\n \tint ret;\n \n \tV4L2DeviceFormat format = {};\n-\tformat.fourcc = cfg.pixelFormat;\n+\tformat.fourcc = data->video_->toV4L2Fourcc(cfg.pixelFormat);\n \tformat.size = cfg.size;\n \n \tret = data->video_->setFormat(&format);\n@@ -184,7 +184,7 @@ int PipelineHandlerUVC::configure(Camera *camera, CameraConfiguration *config)\n \t\treturn ret;\n \n \tif (format.size != cfg.size ||\n-\t    format.fourcc != cfg.pixelFormat)\n+\t    format.fourcc != data->video_->toV4L2Fourcc(cfg.pixelFormat))\n \t\treturn -EINVAL;\n \n \tcfg.setStream(&data->stream_);\ndiff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp\nindex c16ae4cb76b5..e6ab6a085824 100644\n--- a/src/libcamera/pipeline/vimc.cpp\n+++ b/src/libcamera/pipeline/vimc.cpp\n@@ -10,6 +10,7 @@\n #include <iomanip>\n #include <tuple>\n \n+#include <linux/drm_fourcc.h>\n #include <linux/media-bus-format.h>\n \n #include <ipa/ipa_interface.h>\n@@ -106,9 +107,9 @@ private:\n namespace {\n \n constexpr std::array<unsigned int, 3> pixelformats{\n-\tV4L2_PIX_FMT_BGR24,\n-\tV4L2_PIX_FMT_RGB24,\n-\tV4L2_PIX_FMT_ARGB32,\n+\tDRM_FORMAT_RGB888,\n+\tDRM_FORMAT_BGR888,\n+\tDRM_FORMAT_BGRA8888,\n };\n \n } /* namespace */\n@@ -137,7 +138,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 = V4L2_PIX_FMT_RGB24;\n+\t\tcfg.pixelFormat = DRM_FORMAT_BGR888;\n \t\tstatus = Adjusted;\n \t}\n \n@@ -186,7 +187,7 @@ CameraConfiguration *PipelineHandlerVimc::generateConfiguration(Camera *camera,\n \n \tStreamConfiguration cfg(formats.data());\n \n-\tcfg.pixelFormat = V4L2_PIX_FMT_RGB24;\n+\tcfg.pixelFormat = DRM_FORMAT_BGR888;\n \tcfg.size = { 1920, 1080 };\n \tcfg.bufferCount = 4;\n \n@@ -231,7 +232,7 @@ int PipelineHandlerVimc::configure(Camera *camera, CameraConfiguration *config)\n \t\treturn ret;\n \n \tV4L2DeviceFormat format = {};\n-\tformat.fourcc = cfg.pixelFormat;\n+\tformat.fourcc = data->video_->toV4L2Fourcc(cfg.pixelFormat);\n \tformat.size = cfg.size;\n \n \tret = data->video_->setFormat(&format);\n@@ -239,7 +240,7 @@ int PipelineHandlerVimc::configure(Camera *camera, CameraConfiguration *config)\n \t\treturn ret;\n \n \tif (format.size != cfg.size ||\n-\t    format.fourcc != cfg.pixelFormat)\n+\t    format.fourcc != data->video_->toV4L2Fourcc(cfg.pixelFormat))\n \t\treturn -EINVAL;\n \n \t/*\ndiff --git a/src/libcamera/pixelformats.cpp b/src/libcamera/pixelformats.cpp\nindex 9377fb5e0749..c03335400b70 100644\n--- a/src/libcamera/pixelformats.cpp\n+++ b/src/libcamera/pixelformats.cpp\n@@ -19,8 +19,10 @@ namespace libcamera {\n  * \\brief libcamera image pixel format\n  *\n  * The PixelFormat type describes the format of images in the public libcamera\n- * API. It stores a FourCC value in a 32-bit unsigned integer. The values are\n- * defined in the Linux kernel V4L2 API (see linux/videodev2.h).\n+ * API. It stores a FourCC value as a 32-bit unsigned integer. The values are\n+ * defined in the Linux kernel DRM/KMS API (see linux/drm_fourcc.h).\n+ *\n+ * \\todo Add support for format modifiers\n  */\n \n } /* namespace libcamera */\ndiff --git a/src/qcam/format_converter.cpp b/src/qcam/format_converter.cpp\nindex 86b03b2cd84d..383d48223140 100644\n--- a/src/qcam/format_converter.cpp\n+++ b/src/qcam/format_converter.cpp\n@@ -7,7 +7,7 @@\n \n #include <errno.h>\n \n-#include <linux/videodev2.h>\n+#include <linux/drm_fourcc.h>\n \n #include <QImage>\n \n@@ -31,84 +31,84 @@ int FormatConverter::configure(unsigned int format, unsigned int width,\n \t\t\t       unsigned int height)\n {\n \tswitch (format) {\n-\tcase V4L2_PIX_FMT_NV12:\n+\tcase DRM_FORMAT_NV12:\n \t\tformatFamily_ = NV;\n \t\thorzSubSample_ = 2;\n \t\tvertSubSample_ = 2;\n \t\tnvSwap_ = false;\n \t\tbreak;\n-\tcase V4L2_PIX_FMT_NV21:\n+\tcase DRM_FORMAT_NV21:\n \t\tformatFamily_ = NV;\n \t\thorzSubSample_ = 2;\n \t\tvertSubSample_ = 2;\n \t\tnvSwap_ = true;\n \t\tbreak;\n-\tcase V4L2_PIX_FMT_NV16:\n+\tcase DRM_FORMAT_NV16:\n \t\tformatFamily_ = NV;\n \t\thorzSubSample_ = 2;\n \t\tvertSubSample_ = 1;\n \t\tnvSwap_ = false;\n \t\tbreak;\n-\tcase V4L2_PIX_FMT_NV61:\n+\tcase DRM_FORMAT_NV61:\n \t\tformatFamily_ = NV;\n \t\thorzSubSample_ = 2;\n \t\tvertSubSample_ = 1;\n \t\tnvSwap_ = true;\n \t\tbreak;\n-\tcase V4L2_PIX_FMT_NV24:\n+\tcase DRM_FORMAT_NV24:\n \t\tformatFamily_ = NV;\n \t\thorzSubSample_ = 1;\n \t\tvertSubSample_ = 1;\n \t\tnvSwap_ = false;\n \t\tbreak;\n-\tcase V4L2_PIX_FMT_NV42:\n+\tcase DRM_FORMAT_NV42:\n \t\tformatFamily_ = NV;\n \t\thorzSubSample_ = 1;\n \t\tvertSubSample_ = 1;\n \t\tnvSwap_ = true;\n \t\tbreak;\n-\tcase V4L2_PIX_FMT_BGR24:\n+\tcase DRM_FORMAT_RGB888:\n \t\tformatFamily_ = RGB;\n \t\tr_pos_ = 2;\n \t\tg_pos_ = 1;\n \t\tb_pos_ = 0;\n \t\tbpp_ = 3;\n \t\tbreak;\n-\tcase V4L2_PIX_FMT_RGB24:\n+\tcase DRM_FORMAT_BGR888:\n \t\tformatFamily_ = RGB;\n \t\tr_pos_ = 0;\n \t\tg_pos_ = 1;\n \t\tb_pos_ = 2;\n \t\tbpp_ = 3;\n \t\tbreak;\n-\tcase V4L2_PIX_FMT_ARGB32:\n+\tcase DRM_FORMAT_BGRA8888:\n \t\tformatFamily_ = RGB;\n \t\tr_pos_ = 1;\n \t\tg_pos_ = 2;\n \t\tb_pos_ = 3;\n \t\tbpp_ = 4;\n \t\tbreak;\n-\tcase V4L2_PIX_FMT_VYUY:\n+\tcase DRM_FORMAT_VYUY:\n \t\tformatFamily_ = YUV;\n \t\ty_pos_ = 1;\n \t\tcb_pos_ = 2;\n \t\tbreak;\n-\tcase V4L2_PIX_FMT_YVYU:\n+\tcase DRM_FORMAT_YVYU:\n \t\tformatFamily_ = YUV;\n \t\ty_pos_ = 0;\n \t\tcb_pos_ = 3;\n \t\tbreak;\n-\tcase V4L2_PIX_FMT_UYVY:\n+\tcase DRM_FORMAT_UYVY:\n \t\tformatFamily_ = YUV;\n \t\ty_pos_ = 1;\n \t\tcb_pos_ = 0;\n \t\tbreak;\n-\tcase V4L2_PIX_FMT_YUYV:\n+\tcase DRM_FORMAT_YUYV:\n \t\tformatFamily_ = YUV;\n \t\ty_pos_ = 0;\n \t\tcb_pos_ = 1;\n \t\tbreak;\n-\tcase V4L2_PIX_FMT_MJPEG:\n+\tcase DRM_FORMAT_MJPEG:\n \t\tformatFamily_ = MJPEG;\n \t\tbreak;\n \tdefault:\ndiff --git a/test/camera/buffer_import.cpp b/test/camera/buffer_import.cpp\nindex 9cac19d8ce81..bbc5a25c4019 100644\n--- a/test/camera/buffer_import.cpp\n+++ b/test/camera/buffer_import.cpp\n@@ -155,7 +155,16 @@ public:\n \t}\n \n \tbool done() const { return done_; }\n-\tconst V4L2DeviceFormat &format() const { return format_; }\n+\n+\tPixelFormat format() const\n+\t{\n+\t\treturn video_->toPixelFormat(format_.fourcc);\n+\t}\n+\n+\tconst Size &size() const\n+\t{\n+\t\treturn format_.size;\n+\t}\n \n \tSignal<uint64_t, int> requestReady;\n \n@@ -314,11 +323,9 @@ protected:\n \t\t\treturn TestFail;\n \t\t}\n \n-\t\tconst V4L2DeviceFormat &format = sink_.format();\n-\n \t\tStreamConfiguration &cfg = config->at(0);\n-\t\tcfg.size = format.size;\n-\t\tcfg.pixelFormat = format.fourcc;\n+\t\tcfg.size = sink_.size();\n+\t\tcfg.pixelFormat = sink_.format();\n \t\tcfg.bufferCount = CAMERA_BUFFER_COUNT;\n \t\tcfg.memoryType = ExternalMemory;\n \n",
    "prefixes": [
        "libcamera-devel",
        "v2",
        "7/7"
    ]
}