Patch Detail
Show a patch.
GET /api/1.1/patches/17448/?format=api
{ "id": 17448, "url": "https://patchwork.libcamera.org/api/1.1/patches/17448/?format=api", "web_url": "https://patchwork.libcamera.org/patch/17448/", "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": "<20220928102743.1484-1-laurent.pinchart@ideasonboard.com>", "date": "2022-09-28T10:27:43", "name": "[libcamera-devel,v2] cam: drm: Skip DRM devices not capable of mode setting", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "062dc555ab1911fcb4eb24500519310e761789e2", "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/17448/mbox/", "series": [ { "id": 3510, "url": "https://patchwork.libcamera.org/api/1.1/series/3510/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3510", "date": "2022-09-28T10:27:43", "name": "[libcamera-devel,v2] cam: drm: Skip DRM devices not capable of mode setting", "version": 2, "mbox": "https://patchwork.libcamera.org/series/3510/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/17448/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/17448/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 B551BC0DA4\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 28 Sep 2022 10:27:46 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 18A5E622A4;\n\tWed, 28 Sep 2022 12:27:46 +0200 (CEST)", "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 B6CD06224C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 28 Sep 2022 12:27:44 +0200 (CEST)", "from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 1C11B47C;\n\tWed, 28 Sep 2022 12:27:44 +0200 (CEST)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1664360866;\n\tbh=/KKPHWQTmRn+vXPyGwsYxhmOoZSlzoaLMmktl67GJ7U=;\n\th=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:From;\n\tb=LX6bnvGNIrhi3oKfluwb/HCIynEfUwsu9fnqRiS753k/b7U6E1FAfqVCr78XcmEZr\n\tCUC/pUF0HeEju83+UMRG7SDq2MnQJBstpDUHxiaJkwA541QtnwE+urohjMrg5NO/Bq\n\tNCeQxtSKSjsswvHZ1Vt4mgr7C9zXBSN5c62iljfrRNR9CGXnq6jm4mHi2EHhc3ZVFf\n\t8W1ZcH/IM6zdNCAeKJslBYgxNT3y1cPY6LNPrWVbjPN7R98axsH8A53LKKTqYGgJvT\n\tDNbc6lhBj0Kt6qlsQ/BsyvAkzlTOc4pH5sOlkarWgfdOU/nUUWpVmeoq+uDAaG8mKW\n\tTWsdaoPE5YZNg==", "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1664360864;\n\tbh=/KKPHWQTmRn+vXPyGwsYxhmOoZSlzoaLMmktl67GJ7U=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=nx/SamrtBgjBciovyOacDCig4PP3xZ/aYgTkk6skH6lgxSxoIEo3CCWsJ4MzvE53G\n\tgvyNdIQp6/K4hxrjwcKIUt3c1Cj++4sXuofLBFDlxEjaiMyd+g4XwAhMbpYfZzZUNO\n\tKQO08S/fdxarst709o+TrJ6hKIQouD79MgkNuUWY=" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"nx/Samrt\"; dkim-atps=neutral", "To": "libcamera-devel@lists.libcamera.org", "Date": "Wed, 28 Sep 2022 13:27:43 +0300", "Message-Id": "<20220928102743.1484-1-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.35.1", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v2] cam: drm: Skip DRM devices not capable\n\tof mode setting", "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": "Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>", "Reply-To": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "The DRM helper picks the first DRM card that it can open. On platforms\nthat have a standalone GPU, this risks selecting a device corresponding\nto the GPU instead of the display controller. Fix this by skipping\ndevices that don't support the KMS mode setting API. Some legacy display\ncontrollers would be skipped as well, but libcamera doesn't run on those\nsystems anyway.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\nChanges since v1:\n\n- Use DRM_CAP_DUMB_BUFFER instead of DRM_CLIENT_CAP_ATOMIC\n---\n src/cam/drm.cpp | 35 +++++++++++++++++++++++++++--------\n 1 file changed, 27 insertions(+), 8 deletions(-)", "diff": "diff --git a/src/cam/drm.cpp b/src/cam/drm.cpp\nindex b0602c942853..3bb950fd157a 100644\n--- a/src/cam/drm.cpp\n+++ b/src/cam/drm.cpp\n@@ -430,7 +430,8 @@ int Device::init()\n int Device::openCard()\n {\n \tconst std::string dirName = \"/dev/dri/\";\n-\tint ret = -ENOENT;\n+\tbool found = false;\n+\tint ret;\n \n \t/*\n \t * Open the first DRM/KMS device beginning with /dev/dri/card. The\n@@ -449,24 +450,42 @@ int Device::openCard()\n \t}\n \n \tfor (struct dirent *res; (res = readdir(folder));) {\n+\t\tuint64_t cap;\n+\n \t\tif (strncmp(res->d_name, \"card\", 4))\n \t\t\tcontinue;\n \n \t\tconst std::string devName = dirName + res->d_name;\n \t\tfd_ = open(devName.c_str(), O_RDWR | O_CLOEXEC);\n-\t\tif (fd_ >= 0) {\n-\t\t\tret = 0;\n-\t\t\tbreak;\n+\t\tif (fd_ < 0) {\n+\t\t\tret = -errno;\n+\t\t\tstd::cerr << \"Failed to open DRM/KMS device \" << devName << \": \"\n+\t\t\t\t << strerror(-ret) << std::endl;\n+\t\t\tcontinue;\n \t\t}\n \n-\t\tret = -errno;\n-\t\tstd::cerr << \"Failed to open DRM/KMS device \" << devName << \": \"\n-\t\t\t << strerror(-ret) << std::endl;\n+\t\t/*\n+\t\t * Skip devices that don't support the modeset API, to avoid\n+\t\t * selecting a DRM device corresponding to a GPU. There is no\n+\t\t * modeset capability, but the kernel returns an error for most\n+\t\t * caps if mode setting isn't support but the driver. The\n+\t\t * DRM_CAP_DUMB_BUFFER capability is one of those, other would\n+\t\t * do as well. The capability value itself isn't relevant.\n+\t\t */\n+\t\tret = drmGetCap(fd_, DRM_CAP_DUMB_BUFFER, &cap);\n+\t\tif (ret < 0) {\n+\t\t\tdrmClose(fd_);\n+\t\t\tfd_ = -1;\n+\t\t\tcontinue;\n+\t\t}\n+\n+\t\tfound = true;\n+\t\tbreak;\n \t}\n \n \tclosedir(folder);\n \n-\treturn ret;\n+\treturn found ? 0 : -ENOENT;\n }\n \n int Device::getResources()\n", "prefixes": [ "libcamera-devel", "v2" ] }