Patch Detail
Show a patch.
GET /api/patches/16285/?format=api
{ "id": 16285, "url": "https://patchwork.libcamera.org/api/patches/16285/?format=api", "web_url": "https://patchwork.libcamera.org/patch/16285/", "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": "<20220620115238.16138-1-ecurtin@redhat.com>", "date": "2022-06-20T11:52:39", "name": "[libcamera-devel,v5] cam: kms_sink: Remove limitation that camera and display must match", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "967b63cd9f053637b12941a538156021d75f6123", "submitter": { "id": 101, "url": "https://patchwork.libcamera.org/api/people/101/?format=api", "name": "Eric Curtin", "email": "ecurtin@redhat.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/16285/mbox/", "series": [ { "id": 3194, "url": "https://patchwork.libcamera.org/api/series/3194/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3194", "date": "2022-06-20T11:52:39", "name": "[libcamera-devel,v5] cam: kms_sink: Remove limitation that camera and display must match", "version": 5, "mbox": "https://patchwork.libcamera.org/series/3194/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/16285/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/16285/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 94A9EBD808\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 20 Jun 2022 11:55:37 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id CDAA165635;\n\tMon, 20 Jun 2022 13:55:36 +0200 (CEST)", "from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.133.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 876DF60498\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 20 Jun 2022 13:55:34 +0200 (CEST)", "from mail-wm1-f71.google.com (mail-wm1-f71.google.com\n\t[209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS\n\t(version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id\n\tus-mta-628-P4UJTk5pPA--tfYahWYWyw-1; Mon, 20 Jun 2022 07:55:32 -0400", "by mail-wm1-f71.google.com with SMTP id\n\tl3-20020a05600c1d0300b0039c7efa2526so4942305wms.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 20 Jun 2022 04:55:32 -0700 (PDT)", "from p1.Home ([2001:8a0:6724:4500:a69c:e66f:828e:b340])\n\tby smtp.gmail.com with ESMTPSA id\n\ty14-20020a1c4b0e000000b0039c95b31812sm14627485wma.31.2022.06.20.04.55.29\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 20 Jun 2022 04:55:29 -0700 (PDT)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1655726136;\n\tbh=t4ubaAXKxvm8akX5y/yD/ZJX0ifX/V18g8LpvReRfbo=;\n\th=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:From;\n\tb=AGiaxDiPBBXYzArdVbrrM82eFA1S0WkfI+ZKcumBNBJyj8aXldYgyBczpbEOCWf9p\n\t29UrDF1+5F3+JkUPVvzN6ND+EJJqkD7j3ofWXi4mvOhSnWo5P0WpV/F2ZEZzwqfSzq\n\tf56vIx6XwM/3Vlx7jr5zxR/X4dlOLWOn3PRV4fw0TvLo7oQIl3CQXh9q/iCkSjmdxu\n\tPQ33zDbwLlydscyZyazbabyi/WPzeXKVlc+DFPJzgqWEDsu3u+tsaOS+A9DXdVnEtw\n\tNjitIqOyoCbUlWTXn8cT98IUNyQqB044xHGsqL3xeUA2b0Kb78K/Cxr5tk5/RVaopc\n\tDqDC299/zIHuw==", "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1655726133;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tcontent-transfer-encoding:content-transfer-encoding;\n\tbh=MX7dKoczXP2emmVnHyN75QkZbiirMKKNuz4mDMjFj7E=;\n\tb=bCYlWtChkDEPThQqT0+NDfk+e6ePuUiDpeYbIY4CJ7mW39Tkv3o3UeehKmK6xcOYq5xthM\n\tHp537gTB9vpxsTiKgncrX4bm8Et++g04Ggd7R1LfThryDb3T69gTTsHXtS0n0/QUvIdGD1\n\tS7xD4UJoml8Wn65XKM0VEFzO3LPRqgs=" ], "Authentication-Results": [ "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=redhat.com\n\theader.i=@redhat.com header.b=\"bCYlWtCh\"; \n\tdkim-atps=neutral", "relay.mimecast.com;\n\tauth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ecurtin@redhat.com" ], "X-MC-Unique": "P4UJTk5pPA--tfYahWYWyw-1", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding;\n\tbh=MX7dKoczXP2emmVnHyN75QkZbiirMKKNuz4mDMjFj7E=;\n\tb=Mum4Nw2hNrGJ7HjNiL4lQaM2MobZDnwlbK619hoWBHOsO0dBnfvur3ir4C9LL93sYi\n\tUApGOwIZadVU9i3vp/exTpsg8iNn2/CVq+EWd7sb3x5UtgmmvTBGSMRyKl5l7IzXH8pU\n\tnVZfCRVpxqK/AcD7cRpb4Cez+OIg6AjQUCoJDClFcICul8TwFL6VBvZhud0qnXrXoq3x\n\tFxvZ7M3yDhVqLYzfG3PHnZ/ZqiuVZiXOJSi+LYezow/5xGoJgumeWl/6zQEgHhUvN0DO\n\tIcXFiVe/2AfhhOAh3CnRBdtNwpWuSvd5lFE9HfBXNTshH8lRfguzHQ2GEoJJ12FAz8aN\n\tnEOw==", "X-Gm-Message-State": "AJIora+EZdxB5nYPSO+00fhWxMkExsAsMgjRa+yLYwvpOVfZePqEW7TE\n\tkmOXF7bDJG7FbV7bY/KlloStfQJTTJspOyh3SovU115bMfMsHjF67vBJMmW0mVpK7IjCkUyh5lO\n\twoTbysXxtD8WCZmi7K7W4yq4Xz6ShIsIgAjfL8QPtlPfavDJ0NwyGKnFHkLhIiaDmyx/EPYoEln\n\t3Xf7ISK6Bi", "X-Received": [ "by 2002:adf:e9cd:0:b0:21b:94a2:572f with SMTP id\n\tl13-20020adfe9cd000000b0021b94a2572fmr396707wrn.647.1655726130849; \n\tMon, 20 Jun 2022 04:55:30 -0700 (PDT)", "by 2002:adf:e9cd:0:b0:21b:94a2:572f with SMTP id\n\tl13-20020adfe9cd000000b0021b94a2572fmr396674wrn.647.1655726130485; \n\tMon, 20 Jun 2022 04:55:30 -0700 (PDT)" ], "X-Google-Smtp-Source": "AGRyM1uIHsufV3Ok8PAa2FtuyH1jx9Q6lZlkA/H97g9w1WhycM14R287zJMNpSZtsEWjRZIYDWZMZg==", "To": "libcamera-devel@lists.libcamera.org", "Date": "Mon, 20 Jun 2022 12:52:39 +0100", "Message-Id": "<20220620115238.16138-1-ecurtin@redhat.com>", "X-Mailer": "git-send-email 2.35.3", "MIME-Version": "1.0", "X-Mimecast-Spam-Score": "0", "X-Mimecast-Originator": "redhat.com", "Content-Transfer-Encoding": "8bit", "Content-Type": "text/plain; charset=\"US-ASCII\"; x-default=true", "Subject": "[libcamera-devel] [PATCH v5] cam: kms_sink: Remove limitation that\n\tcamera and display must match", "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>", "From": "Eric Curtin via libcamera-devel <libcamera-devel@lists.libcamera.org>", "Reply-To": "Eric Curtin <ecurtin@redhat.com>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "There is a limitation that requires input and output to be pixel\nfor pixel identical in terms of height and width. Remove this\nlimitation to enable more hardware that doesn't match. Just start\ndrawing from top left 0, 0 corner. Try and pick the mode closest to the\nstream size.\n\nSuggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nSigned-off-by: Eric Curtin <ecurtin@redhat.com>\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nTested-by: Eric Curtin <ecurtin@redhat.com>\n---\nChanges in v5:\n- Tested Laurents suggested change successfully\n- Added to commit message about trying to pick closest\n\nChanges in v4:\n- Change commit message to say top left\n- Spaces to tabs\n\nChanges in v3:\n- Much simplified version of the patch where we just attempt to\n draw from point 0, 0. Only in the case where we do not find a\n matching mode. Can expand to do centralization, scaling, etc.\n in further patches if needs be.\n\nChanges in v2:\n- Tested and support drawing from negative pixel range\n kernel parameter (video=960x540@60) was useful here\n---\n src/cam/kms_sink.cpp | 45 +++++++++++++++++++++++++++++++++++---------\n 1 file changed, 36 insertions(+), 9 deletions(-)", "diff": "diff --git a/src/cam/kms_sink.cpp b/src/cam/kms_sink.cpp\nindex 7add81a6..7904bca8 100644\n--- a/src/cam/kms_sink.cpp\n+++ b/src/cam/kms_sink.cpp\n@@ -11,6 +11,7 @@\n #include <algorithm>\n #include <assert.h>\n #include <iostream>\n+#include <limits.h>\n #include <memory>\n #include <stdint.h>\n #include <string.h>\n@@ -112,6 +113,7 @@ int KMSSink::configure(const libcamera::CameraConfiguration &config)\n \n \tconst libcamera::StreamConfiguration &cfg = config.at(0);\n \n+\t/* Find the best mode for the stream size. */\n \tconst std::vector<DRM::Mode> &modes = connector_->modes();\n \tconst auto iter = std::find_if(modes.begin(), modes.end(),\n \t\t\t\t [&](const DRM::Mode &mode) {\n@@ -120,6 +122,32 @@ int KMSSink::configure(const libcamera::CameraConfiguration &config)\n \t\t\t\t });\n \tif (iter == modes.end()) {\n \t\tstd::cerr << \"No mode matching \" << cfg.size << std::endl;\n+\n+\t\tunsigned int cfgArea = cfg.size.width * cfg.size.height;\n+\t\tunsigned int bestDistance = UINT_MAX;\n+\n+\t\tfor (const DRM::Mode &mode : modes) {\n+\t\t\tunsigned int modeArea = mode.hdisplay * mode.vdisplay;\n+\t\t\tunsigned int distance = modeArea > cfgArea\n+\t\t\t\t\t\t\t? modeArea - cfgArea\n+\t\t\t\t\t\t\t: cfgArea - modeArea;\n+\n+\t\t\tif (distance < bestDistance) {\n+\t\t\t\tmode_ = &mode;\n+\t\t\t\tbestDistance = distance;\n+\n+\t\t\t\t/*\n+\t\t\t\t * If the sizes match exactly, there will be no better\n+\t\t\t\t * match.\n+\t\t\t\t */\n+\t\t\t\tif (distance == 0)\n+\t\t\t\t\tbreak;\n+\t\t\t}\n+\t\t}\n+\t}\n+\n+\tif (!mode_) {\n+\t\tstd::cerr << \"No modes\\n\";\n \t\treturn -EINVAL;\n \t}\n \n@@ -127,7 +155,6 @@ int KMSSink::configure(const libcamera::CameraConfiguration &config)\n \tif (ret < 0)\n \t\treturn ret;\n \n-\tmode_ = &*iter;\n \tsize_ = cfg.size;\n \tstride_ = cfg.stride;\n \n@@ -199,10 +226,10 @@ int KMSSink::configurePipeline(const libcamera::PixelFormat &format)\n \t\treturn ret;\n \t}\n \n-\tstd::cout\n-\t\t<< \"Using KMS plane \" << plane_->id() << \", CRTC \" << crtc_->id()\n-\t\t<< \", connector \" << connector_->name()\n-\t\t<< \" (\" << connector_->id() << \")\" << std::endl;\n+\tstd::cout << \"Using KMS plane \" << plane_->id() << \", CRTC \"\n+\t\t << crtc_->id() << \", connector \" << connector_->name() << \" (\"\n+\t\t << connector_->id() << \"), mode \" << mode_->hdisplay << \"x\"\n+\t\t << mode_->vdisplay << \"@\" << mode_->vrefresh << std::endl;\n \n \treturn 0;\n }\n@@ -295,12 +322,12 @@ bool KMSSink::processRequest(libcamera::Request *camRequest)\n \t\tdrmRequest->addProperty(plane_, \"CRTC_ID\", crtc_->id());\n \t\tdrmRequest->addProperty(plane_, \"SRC_X\", 0 << 16);\n \t\tdrmRequest->addProperty(plane_, \"SRC_Y\", 0 << 16);\n-\t\tdrmRequest->addProperty(plane_, \"SRC_W\", mode_->hdisplay << 16);\n-\t\tdrmRequest->addProperty(plane_, \"SRC_H\", mode_->vdisplay << 16);\n+\t\tdrmRequest->addProperty(plane_, \"SRC_W\", size_.width << 16);\n+\t\tdrmRequest->addProperty(plane_, \"SRC_H\", size_.height << 16);\n \t\tdrmRequest->addProperty(plane_, \"CRTC_X\", 0);\n \t\tdrmRequest->addProperty(plane_, \"CRTC_Y\", 0);\n-\t\tdrmRequest->addProperty(plane_, \"CRTC_W\", mode_->hdisplay);\n-\t\tdrmRequest->addProperty(plane_, \"CRTC_H\", mode_->vdisplay);\n+\t\tdrmRequest->addProperty(plane_, \"CRTC_W\", size_.width);\n+\t\tdrmRequest->addProperty(plane_, \"CRTC_H\", size_.height);\n \n \t\tflags |= DRM::AtomicRequest::FlagAllowModeset;\n \t}\n", "prefixes": [ "libcamera-devel", "v5" ] }