Patch Detail
Show a patch.
GET /api/1.1/patches/1772/?format=api
{ "id": 1772, "url": "https://patchwork.libcamera.org/api/1.1/patches/1772/?format=api", "web_url": "https://patchwork.libcamera.org/patch/1772/", "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": "<20190810011333.8731-3-niklas.soderlund@ragnatech.se>", "date": "2019-08-10T01:13:31", "name": "[libcamera-devel,v4,2/4] libcamera: pipeline: vimc: Switch to using the RGB/YUV Capture video node", "commit_ref": "4debc71ffa7ffe92d23189c9157855ba89fccfea", "pull_url": null, "state": "accepted", "archived": false, "hash": "15b215497659fb5b6f1573bc1ffc3e4018707c1d", "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/1772/mbox/", "series": [ { "id": 452, "url": "https://patchwork.libcamera.org/api/1.1/series/452/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=452", "date": "2019-08-10T01:13:30", "name": "libcamera: Fix issues with vimc and Linux v5.2", "version": 4, "mbox": "https://patchwork.libcamera.org/series/452/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/1772/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/1772/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 887FB61582\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 10 Aug 2019 03:13:56 +0200 (CEST)", "from wyvern.dyn.berto.se (unknown [155.4.79.45])\n\tby bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA\n\tid 1a294aee-bb0c-11e9-bdc3-005056917a89;\n\tSat, 10 Aug 2019 03:13:47 +0200 (CEST)" ], "X-Halon-ID": "1a294aee-bb0c-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": "Sat, 10 Aug 2019 03:13:31 +0200", "Message-Id": "<20190810011333.8731-3-niklas.soderlund@ragnatech.se>", "X-Mailer": "git-send-email 2.22.0", "In-Reply-To": "<20190810011333.8731-1-niklas.soderlund@ragnatech.se>", "References": "<20190810011333.8731-1-niklas.soderlund@ragnatech.se>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v4 2/4] libcamera: pipeline: vimc: Switch\n\tto using the RGB/YUV Capture video node", "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": "Sat, 10 Aug 2019 01:13:56 -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 moving the vimc pipeline to use the RGB/YUV Capture capture\nvideo node. As a consequence of this change the scaler in the vimc\npipeline is used and a hard coded upscale of 3 is present in the video\npipeline. This limits the sizes exposed and accepted by libcamera to\nmultiples of 3.\n\nUpdate the buffer import test case to match this new format constraint\nby setting the resolution to 1920x1080, a resolution which works with\nboth vimc and vivid. With this new resolution the buffer import test\ntakes a bit more time to complete 60 buffers and it's runtime also needs\nto be increased.\n\nThe raw capture video node still needs to be handled by the pipeline as\nits format needs to be updated to allow the pipeline format validation\nto pass.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/libcamera/pipeline/vimc.cpp | 93 +++++++++++++++++++++++++++++----\n test/camera/buffer_import.cpp | 10 ++--\n 2 files changed, 89 insertions(+), 14 deletions(-)", "diff": "diff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp\nindex 3d6808222a8a2c5d..f8f91d6219b1aee4 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,21 +38,28 @@ 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), sensor_(nullptr), debayer_(nullptr),\n+\t\t scaler_(nullptr), video_(nullptr), raw_(nullptr)\n \t{\n \t}\n \n \t~VimcCameraData()\n \t{\n \t\tdelete sensor_;\n+\t\tdelete debayer_;\n+\t\tdelete scaler_;\n \t\tdelete video_;\n+\t\tdelete raw_;\n \t}\n \n \tint init(MediaDevice *media);\n \tvoid bufferReady(Buffer *buffer);\n \n-\tV4L2VideoDevice *video_;\n \tCameraSensor *sensor_;\n+\tV4L2Subdevice *debayer_;\n+\tV4L2Subdevice *scaler_;\n+\tV4L2VideoDevice *video_;\n+\tV4L2VideoDevice *raw_;\n \tStream stream_;\n };\n \n@@ -131,8 +141,11 @@ CameraConfiguration::Status VimcCameraConfiguration::validate()\n \t/* Clamp the size based on the device limits. */\n \tconst Size size = cfg.size;\n \n-\tcfg.size.width = std::max(16U, std::min(4096U, cfg.size.width));\n-\tcfg.size.height = std::max(16U, std::min(2160U, cfg.size.height));\n+\t/* The scaler hardcodes a x3 scale-up ratio. */\n+\tcfg.size.width = std::max(48U, std::min(4096U, cfg.size.width));\n+\tcfg.size.height = std::max(48U, std::min(2160U, cfg.size.height));\n+\tcfg.size.width -= cfg.size.width % 3;\n+\tcfg.size.height -= cfg.size.height % 3;\n \n \tif (cfg.size != size) {\n \t\tLOG(VIMC, Debug)\n@@ -160,7 +173,7 @@ CameraConfiguration *PipelineHandlerVimc::generateConfiguration(Camera *camera,\n \n \tStreamConfiguration cfg{};\n \tcfg.pixelFormat = V4L2_PIX_FMT_RGB24;\n-\tcfg.size = { 640, 480 };\n+\tcfg.size = { 1920, 1080 };\n \tcfg.bufferCount = 4;\n \n \tconfig->addConfiguration(cfg);\n@@ -176,6 +189,33 @@ int PipelineHandlerVimc::configure(Camera *camera, CameraConfiguration *config)\n \tStreamConfiguration &cfg = config->at(0);\n \tint ret;\n \n+\t/* The scaler hardcodes a x3 scale-up ratio. */\n+\tV4L2SubdeviceFormat subformat = {};\n+\tsubformat.mbus_code = MEDIA_BUS_FMT_SGRBG8_1X8;\n+\tsubformat.size = { cfg.size.width / 3, cfg.size.height / 3 };\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+\tsubformat.mbus_code = MEDIA_BUS_FMT_RGB888_1X24;\n+\tret = data->debayer_->setFormat(1, &subformat);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tret = data->scaler_->setFormat(0, &subformat);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tsubformat.size = cfg.size;\n+\tret = data->scaler_->setFormat(1, &subformat);\n+\tif (ret)\n+\t\treturn ret;\n+\n \tV4L2DeviceFormat format = {};\n \tformat.fourcc = cfg.pixelFormat;\n \tformat.size = cfg.size;\n@@ -188,6 +228,17 @@ int PipelineHandlerVimc::configure(Camera *camera, CameraConfiguration *config)\n \t format.fourcc != cfg.pixelFormat)\n \t\treturn -EINVAL;\n \n+\t/*\n+\t * Format has to be set on the raw capture video node, otherwise the\n+\t * vimc driver will fail pipeline validation.\n+\t */\n+\tformat.fourcc = V4L2_PIX_FMT_SGRBG8;\n+\tformat.size = { cfg.size.width / 3, cfg.size.height / 3 };\n+\n+\tret = data->raw_->setFormat(&format);\n+\tif (ret)\n+\t\treturn ret;\n+\n \tcfg.setStream(&data->stream_);\n \n \treturn 0;\n@@ -335,18 +386,42 @@ int VimcCameraData::init(MediaDevice *media)\n {\n \tint ret;\n \n-\t/* Create and open the video device and the camera sensor. */\n-\tvideo_ = new V4L2VideoDevice(media->getEntityByName(\"Raw Capture 1\"));\n-\tif (video_->open())\n+\tret = media->disableLinks();\n+\tif (ret < 0)\n+\t\treturn ret;\n+\n+\tMediaLink *link = media->link(\"Debayer B\", 1, \"Scaler\", 0);\n+\tif (!link)\n \t\treturn -ENODEV;\n \n-\tvideo_->bufferReady.connect(this, &VimcCameraData::bufferReady);\n+\tret = link->setEnabled(true);\n+\tif (ret < 0)\n+\t\treturn ret;\n \n+\t/* Create and open the camera sensor, debayer, scaler and video device. */\n \tsensor_ = new CameraSensor(media->getEntityByName(\"Sensor B\"));\n \tret = sensor_->init();\n \tif (ret)\n \t\treturn ret;\n \n+\tdebayer_ = new V4L2Subdevice(media->getEntityByName(\"Debayer B\"));\n+\tif (debayer_->open())\n+\t\treturn -ENODEV;\n+\n+\tscaler_ = new V4L2Subdevice(media->getEntityByName(\"Scaler\"));\n+\tif (scaler_->open())\n+\t\treturn -ENODEV;\n+\n+\tvideo_ = new V4L2VideoDevice(media->getEntityByName(\"RGB/YUV Capture\"));\n+\tif (video_->open())\n+\t\treturn -ENODEV;\n+\n+\tvideo_->bufferReady.connect(this, &VimcCameraData::bufferReady);\n+\n+\traw_ = new V4L2VideoDevice(media->getEntityByName(\"Raw Capture 1\"));\n+\tif (raw_->open())\n+\t\treturn -ENODEV;\n+\n \t/* Initialise the supported controls. */\n \tconst V4L2ControlInfoMap &controls = sensor_->controls();\n \tfor (const auto &ctrl : controls) {\ndiff --git a/test/camera/buffer_import.cpp b/test/camera/buffer_import.cpp\nindex 400d02b350c1aa8f..98786469428f7f39 100644\n--- a/test/camera/buffer_import.cpp\n+++ b/test/camera/buffer_import.cpp\n@@ -72,12 +72,12 @@ public:\n \t\t\treturn ret;\n \t\t}\n \n-\t\tformat_.size.width = 640;\n-\t\tformat_.size.height = 480;\n+\t\tformat_.size.width = 1920;\n+\t\tformat_.size.height = 1080;\n \t\tformat_.fourcc = V4L2_PIX_FMT_RGB24;\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 = 1920 * 1080 * 3;\n+\t\tformat_.planes[0].bpl = 1920 * 3;\n \n \t\tif (video_->setFormat(&format_)) {\n \t\t\tcleanup();\n@@ -378,7 +378,7 @@ protected:\n \t\tEventDispatcher *dispatcher = CameraManager::instance()->eventDispatcher();\n \n \t\tTimer timer;\n-\t\ttimer.start(3000);\n+\t\ttimer.start(5000);\n \t\twhile (timer.isRunning() && !sink_.done())\n \t\t\tdispatcher->processEvents();\n \n", "prefixes": [ "libcamera-devel", "v4", "2/4" ] }