Show a patch.

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

{
    "id": 1739,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/1739/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/1739/",
    "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": "<20190807204915.23942-3-niklas.soderlund@ragnatech.se>",
    "date": "2019-08-07T20:49:13",
    "name": "[libcamera-devel,v2,2/4] libcamera: pipeline: vimc: Set media bus formats for sensor and debayer",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "772d378c5ed3bbc2d6629334fe67e486a89d1ad9",
    "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/1739/mbox/",
    "series": [
        {
            "id": 447,
            "url": "https://patchwork.libcamera.org/api/1.1/series/447/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=447",
            "date": "2019-08-07T20:49:13",
            "name": "libcamera: Fix issues with vimc and Linux v5.2",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/447/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/1739/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/1739/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<niklas.soderlund@ragnatech.se>",
        "Received": [
            "from bin-mail-out-06.binero.net (bin-mail-out-06.binero.net\n\t[195.74.38.229])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id BA61161623\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  7 Aug 2019 22:49:22 +0200 (CEST)",
            "from bismarck.berto.se (unknown [145.14.112.32])\n\tby bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA\n\tid d069b579-b954-11e9-bdc3-005056917a89;\n\tWed, 07 Aug 2019 22:49:13 +0200 (CEST)"
        ],
        "X-Halon-ID": "d069b579-b954-11e9-bdc3-005056917a89",
        "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": "Wed,  7 Aug 2019 22:49:13 +0200",
        "Message-Id": "<20190807204915.23942-3-niklas.soderlund@ragnatech.se>",
        "X-Mailer": "git-send-email 2.22.0",
        "In-Reply-To": "<20190807204915.23942-1-niklas.soderlund@ragnatech.se>",
        "References": "<20190807204915.23942-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 2/4] libcamera: pipeline: vimc: Set\n\tmedia bus formats for sensor and debayer",
        "X-BeenThere": "libcamera-devel@lists.libcamera.org",
        "X-Mailman-Version": "2.1.23",
        "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": "Wed, 07 Aug 2019 20:49:30 -0000"
    },
    "content": "Linux commit 85ab1aa1fac17bcd (\"media: vimc: deb: fix default sink bayer\nformat\") which is part of v5.2 changes the default media bus format for\nthe debayer subdevices. This leads to a -EPIPE error when trying to use\nthe raw capture video device nodes.\n\nFix this by modifying the camera exposed by vimc to only support bayer\nformarts. This allows the pipeline to function both before and after the\nupstream change. As a consequence of this change the media bus format of\nthe subdevices involved needs to be set to avoid a misconfigured media\npipeline. Once upstream is sorted out none bayer formats should be\nre-enabled on the vimc pipeline.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n src/libcamera/pipeline/vimc.cpp | 54 ++++++++++++++++++++++++++++-----\n test/camera/buffer_import.cpp   |  6 ++--\n 2 files changed, 49 insertions(+), 11 deletions(-)",
    "diff": "diff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp\nindex 3d6808222a8a2c5d..4dc514638da3746d 100644\n--- a/src/libcamera/pipeline/vimc.cpp\n+++ b/src/libcamera/pipeline/vimc.cpp\n@@ -10,6 +10,8 @@\n #include <iomanip>\n #include <tuple>\n \n+#include <linux/media-bus-format.h>\n+\n #include <libcamera/camera.h>\n #include <libcamera/controls.h>\n #include <libcamera/ipa/ipa_interface.h>\n@@ -25,6 +27,7 @@\n #include \"pipeline_handler.h\"\n #include \"utils.h\"\n #include \"v4l2_controls.h\"\n+#include \"v4l2_subdevice.h\"\n #include \"v4l2_videodevice.h\"\n \n namespace libcamera {\n@@ -35,13 +38,15 @@ class VimcCameraData : public CameraData\n {\n public:\n \tVimcCameraData(PipelineHandler *pipe)\n-\t\t: CameraData(pipe), video_(nullptr), sensor_(nullptr)\n+\t\t: CameraData(pipe), video_(nullptr), debayer_(nullptr),\n+\t\t  sensor_(nullptr)\n \t{\n \t}\n \n \t~VimcCameraData()\n \t{\n \t\tdelete sensor_;\n+\t\tdelete debayer_;\n \t\tdelete video_;\n \t}\n \n@@ -49,6 +54,7 @@ public:\n \tvoid bufferReady(Buffer *buffer);\n \n \tV4L2VideoDevice *video_;\n+\tV4L2Subdevice *debayer_;\n \tCameraSensor *sensor_;\n \tStream stream_;\n };\n@@ -101,10 +107,11 @@ VimcCameraConfiguration::VimcCameraConfiguration()\n \n CameraConfiguration::Status VimcCameraConfiguration::validate()\n {\n-\tstatic const std::array<unsigned int, 3> formats{\n-\t\tV4L2_PIX_FMT_BGR24,\n-\t\tV4L2_PIX_FMT_RGB24,\n-\t\tV4L2_PIX_FMT_ARGB32,\n+\tstatic const std::array<unsigned int, 4> formats{\n+\t\tV4L2_PIX_FMT_SBGGR8,\n+\t\tV4L2_PIX_FMT_SGBRG8,\n+\t\tV4L2_PIX_FMT_SGRBG8,\n+\t\tV4L2_PIX_FMT_SRGGB8,\n \t};\n \n \tStatus status = Valid;\n@@ -123,8 +130,8 @@ CameraConfiguration::Status VimcCameraConfiguration::validate()\n \t/* Adjust the pixel format. */\n \tif (std::find(formats.begin(), formats.end(), cfg.pixelFormat) ==\n \t    formats.end()) {\n-\t\tLOG(VIMC, Debug) << \"Adjusting format to RGB24\";\n-\t\tcfg.pixelFormat = V4L2_PIX_FMT_RGB24;\n+\t\tLOG(VIMC, Debug) << \"Adjusting format to SBGGR8\";\n+\t\tcfg.pixelFormat = V4L2_PIX_FMT_SBGGR8;\n \t\tstatus = Adjusted;\n \t}\n \n@@ -159,7 +166,7 @@ CameraConfiguration *PipelineHandlerVimc::generateConfiguration(Camera *camera,\n \t\treturn config;\n \n \tStreamConfiguration cfg{};\n-\tcfg.pixelFormat = V4L2_PIX_FMT_RGB24;\n+\tcfg.pixelFormat = V4L2_PIX_FMT_SBGGR8;\n \tcfg.size = { 640, 480 };\n \tcfg.bufferCount = 4;\n \n@@ -176,6 +183,33 @@ int PipelineHandlerVimc::configure(Camera *camera, CameraConfiguration *config)\n \tStreamConfiguration &cfg = config->at(0);\n \tint ret;\n \n+\tV4L2SubdeviceFormat subformat = {};\n+\tsubformat.size = cfg.size;\n+\tswitch (cfg.pixelFormat) {\n+\tcase V4L2_PIX_FMT_SBGGR8:\n+\t\tsubformat.mbus_code = MEDIA_BUS_FMT_SBGGR8_1X8;\n+\t\tbreak;\n+\tcase V4L2_PIX_FMT_SGBRG8:\n+\t\tsubformat.mbus_code = MEDIA_BUS_FMT_SGBRG8_1X8;\n+\t\tbreak;\n+\tcase V4L2_PIX_FMT_SGRBG8:\n+\t\tsubformat.mbus_code = MEDIA_BUS_FMT_SGRBG8_1X8;\n+\t\tbreak;\n+\tcase V4L2_PIX_FMT_SRGGB8:\n+\t\tsubformat.mbus_code = MEDIA_BUS_FMT_SRGGB8_1X8;\n+\t\tbreak;\n+\tdefault:\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tret = data->sensor_->setFormat(&subformat);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tret = data->debayer_->setFormat(0, &subformat);\n+\tif (ret)\n+\t\treturn ret;\n+\n \tV4L2DeviceFormat format = {};\n \tformat.fourcc = cfg.pixelFormat;\n \tformat.size = cfg.size;\n@@ -340,6 +374,10 @@ int VimcCameraData::init(MediaDevice *media)\n \tif (video_->open())\n \t\treturn -ENODEV;\n \n+\tdebayer_ = new V4L2Subdevice(media->getEntityByName(\"Debayer B\"));\n+\tif (debayer_->open())\n+\t\treturn -ENODEV;\n+\n \tvideo_->bufferReady.connect(this, &VimcCameraData::bufferReady);\n \n \tsensor_ = new CameraSensor(media->getEntityByName(\"Sensor B\"));\ndiff --git a/test/camera/buffer_import.cpp b/test/camera/buffer_import.cpp\nindex 400d02b350c1aa8f..2c29267f22d1ba27 100644\n--- a/test/camera/buffer_import.cpp\n+++ b/test/camera/buffer_import.cpp\n@@ -74,10 +74,10 @@ public:\n \n \t\tformat_.size.width = 640;\n \t\tformat_.size.height = 480;\n-\t\tformat_.fourcc = V4L2_PIX_FMT_RGB24;\n+\t\tformat_.fourcc = V4L2_PIX_FMT_SBGGR8;\n \t\tformat_.planesCount = 1;\n-\t\tformat_.planes[0].size = 640 * 480 * 3;\n-\t\tformat_.planes[0].bpl = 640 * 3;\n+\t\tformat_.planes[0].size = 640 * 480;\n+\t\tformat_.planes[0].bpl = 640;\n \n \t\tif (video_->setFormat(&format_)) {\n \t\t\tcleanup();\n",
    "prefixes": [
        "libcamera-devel",
        "v2",
        "2/4"
    ]
}