Patch Detail
Show a patch.
GET /api/patches/20124/?format=api
{ "id": 20124, "url": "https://patchwork.libcamera.org/api/patches/20124/?format=api", "web_url": "https://patchwork.libcamera.org/patch/20124/", "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": "<20240529154341.10426-7-laurent.pinchart@ideasonboard.com>", "date": "2024-05-29T15:43:41", "name": "[v2,6/6] pipeline: vimc: Don't hardcode scaling factor with recent kernels", "commit_ref": "f7d7a5e294237a50dbdc3aa3e0fa7c3200a08fa7", "pull_url": null, "state": "accepted", "archived": false, "hash": "f02f477020bcf992423c14ba9a62bb9981e785d4", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/20124/mbox/", "series": [ { "id": 4333, "url": "https://patchwork.libcamera.org/api/series/4333/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4333", "date": "2024-05-29T15:43:35", "name": "vimc scaling improvements", "version": 2, "mbox": "https://patchwork.libcamera.org/series/4333/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/20124/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/20124/checks/", "tags": {}, "headers": { "Return-Path": "<libcamera-devel-bounces@lists.libcamera.org>", "X-Original-To": "parsemail@patchwork.libcamera.org", "Delivered-To": "parsemail@patchwork.libcamera.org", "Received": [ "from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 54180BDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 29 May 2024 15:44:12 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E9F4E634BD;\n\tWed, 29 May 2024 17:44:11 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2151D634BB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 29 May 2024 17:44:01 +0200 (CEST)", "from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 6C97E4AB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 29 May 2024 17:43:57 +0200 (CEST)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"pcrICJ47\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1716997437;\n\tbh=WKZqisugEXlgk8YXogk5bjUTxJGzGMA5529Nw4L5e1A=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=pcrICJ47Q6ktq7q8cGBnZ/R6u8CVqJRujCW96M0D5vUccRrRRzO22Da/kxjeUkypK\n\tt5wxX90gwxVFibay2j1LdaC5IVcRlZKz66U5yua7CyeaDQYgCu5mGEqkBvUdPH53qD\n\tFcwra2QbCvDZaf2xyOGlG9W50d3EMwCmjznJk+9A=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Subject": "[PATCH v2 6/6] pipeline: vimc: Don't hardcode scaling factor with\n\trecent kernels", "Date": "Wed, 29 May 2024 18:43:41 +0300", "Message-ID": "<20240529154341.10426-7-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.44.1", "In-Reply-To": "<20240529154341.10426-1-laurent.pinchart@ideasonboard.com>", "References": "<20240529154341.10426-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "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>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "Starting in kernel v5.16, the vimc driver stopped hardcoding the scaler\nfactor. Use this to lift constraints on the camera configuration, and in\nparticular on the exotic output size alignment to a multiple of 6. As a\nresult, vimc-based cameras can more easily match common display\nresolutions.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n src/libcamera/pipeline/vimc/vimc.cpp | 47 +++++++++++++++++++---------\n 1 file changed, 33 insertions(+), 14 deletions(-)", "diff": "diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp\nindex c7650432ddcc..0ec9928eec23 100644\n--- a/src/libcamera/pipeline/vimc/vimc.cpp\n+++ b/src/libcamera/pipeline/vimc/vimc.cpp\n@@ -114,6 +114,9 @@ static const std::map<PixelFormat, uint32_t> pixelformats{\n \t{ formats::BGR888, MEDIA_BUS_FMT_RGB888_1X24 },\n };\n \n+static constexpr Size kMinSize{ 16, 16 };\n+static constexpr Size kMaxSize{ 4096, 2160 };\n+\n } /* namespace */\n \n VimcCameraConfiguration::VimcCameraConfiguration(VimcCameraData *data)\n@@ -153,14 +156,20 @@ CameraConfiguration::Status VimcCameraConfiguration::validate()\n \tconst Size size = cfg.size;\n \n \t/*\n-\t * The scaler hardcodes a x3 scale-up ratio, and the sensor output size\n-\t * is aligned to two pixels in both directions. The output width and\n-\t * height thus have to be multiples of 6.\n+\t * The sensor output size is aligned to two pixels in both directions.\n+\t * Additionally, prior to v5.16, the scaler hardcodes a x3 scale-up\n+\t * ratio, requiring the output width and height to be multiples of 6.\n \t */\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 % 6;\n-\tcfg.size.height -= cfg.size.height % 6;\n+\tSize minSize{ kMinSize };\n+\tunsigned int alignment = 2;\n+\n+\tif (data_->media_->version() < KERNEL_VERSION(5, 16, 0)) {\n+\t\tminSize *= 3;\n+\t\talignment *= 3;\n+\t}\n+\n+\tcfg.size.expandTo(minSize).boundTo(kMaxSize)\n+\t\t.alignDownTo(alignment, alignment);\n \n \tif (cfg.size != size) {\n \t\tLOG(VIMC, Debug)\n@@ -216,10 +225,12 @@ PipelineHandlerVimc::generateConfiguration(Camera *camera,\n \t\t\t}\n \t\t}\n \n-\t\t/* The scaler hardcodes a x3 scale-up ratio. */\n-\t\tstd::vector<SizeRange> sizes{\n-\t\t\tSizeRange{ { 48, 48 }, { 4096, 2160 } }\n-\t\t};\n+\t\t/* Prior to v5.16, the scaler hardcodes a x3 scale-up ratio. */\n+\t\tSize minSize{ kMinSize };\n+\t\tif (data->media_->version() < KERNEL_VERSION(5, 16, 0))\n+\t\t\tminSize *= 3;\n+\n+\t\tstd::vector<SizeRange> sizes{ { minSize, kMaxSize } };\n \t\tformats[pixelformat.first] = sizes;\n \t}\n \n@@ -242,10 +253,18 @@ 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+\t/*\n+\t * Prior to v5.16, the scaler hardcodes a x3 scale-up ratio. For newer\n+\t * kernels, use a sensor resolution of 1920x1080 and let the scaler\n+\t * produce the requested stream size.\n+\t */\n+\tSize sensorSize{ 1920, 1080 };\n+\tif (data->media_->version() < KERNEL_VERSION(5, 16, 0))\n+\t\tsensorSize = { cfg.size.width / 3, cfg.size.height / 3 };\n+\n \tV4L2SubdeviceFormat subformat = {};\n \tsubformat.code = MEDIA_BUS_FMT_SGRBG8_1X8;\n-\tsubformat.size = { cfg.size.width / 3, cfg.size.height / 3 };\n+\tsubformat.size = sensorSize;\n \n \tret = data->sensor_->setFormat(&subformat);\n \tif (ret)\n@@ -293,7 +312,7 @@ int PipelineHandlerVimc::configure(Camera *camera, CameraConfiguration *config)\n \t * vimc driver will fail pipeline validation.\n \t */\n \tformat.fourcc = V4L2PixelFormat(V4L2_PIX_FMT_SGRBG8);\n-\tformat.size = { cfg.size.width / 3, cfg.size.height / 3 };\n+\tformat.size = sensorSize;\n \n \tret = data->raw_->setFormat(&format);\n \tif (ret)\n", "prefixes": [ "v2", "6/6" ] }