Show a patch.

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

{
    "id": 17445,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/17445/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/17445/",
    "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": "<20220927232628.7544-1-laurent.pinchart@ideasonboard.com>",
    "date": "2022-09-27T23:26:28",
    "name": "[libcamera-devel] cam: drm: Skip DRM devices not capable of supporting the atomic API",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "bf40e28a59e0c40bdd275d922ae7a3282e0e949c",
    "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/17445/mbox/",
    "series": [
        {
            "id": 3507,
            "url": "https://patchwork.libcamera.org/api/1.1/series/3507/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3507",
            "date": "2022-09-27T23:26:28",
            "name": "[libcamera-devel] cam: drm: Skip DRM devices not capable of supporting the atomic API",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/3507/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/17445/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/17445/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 575C4C0DA4\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 27 Sep 2022 23:26:33 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5D0D262277;\n\tWed, 28 Sep 2022 01:26:32 +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 604BF61F78\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 28 Sep 2022 01:26:30 +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 B058D47C;\n\tWed, 28 Sep 2022 01:26:29 +0200 (CEST)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1664321192;\n\tbh=oj3cZdMTPHw9yU7SRK5wjOpJ87eaJ6nHxR+d8lh95k0=;\n\th=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:From;\n\tb=OETHC4jUJAD6+GiPox7VpASIk3e/RQrsYEaO5+b8j8ejEk/32LMc36mkC7eA0zrOO\n\tnp3uBcLnmvqAccNsRSOy2457VIZfEHCuvl2o3w3CK9mC/7azoSMWBRrNTcjKvoPKI8\n\tY9fQPaHIEEpg3Zf9yDxClyQYHgDdMZwNVwZHAAEWV7m3XbCs8wkKqICs7WK6lNRfEX\n\tVbyJ108bNfXfRxxUQpQ3VAQukxrCdkbB3flO3KqzCYDsUsxsslmFW2Iry+hVZXxxPN\n\tYIj+wA7EYodTIRvSID/xRsXBsJcSS7ZkDRj7SqH3jE3x2c07JhiWKb2Izu937qwRtO\n\tQFHbFn0cHuoYw==",
            "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1664321189;\n\tbh=oj3cZdMTPHw9yU7SRK5wjOpJ87eaJ6nHxR+d8lh95k0=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=Tf2B2x7CVAo72OdoLHMYg97Gc6SEtrLV/gXgFs6TogqnMgwdjy5jlsSEWte4K5Igt\n\tOfLY1NjnT92LTDBTdF7zUFpTHCw7IPsJ2wsAE1GGIhzZ4HbozfG6oVFP0pP9RxPRYu\n\totdS9jO5cpm9liQsVcyiVQWyVqvbBDxiEKHvJ5IQ="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"Tf2B2x7C\"; dkim-atps=neutral",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Wed, 28 Sep 2022 02:26:28 +0300",
        "Message-Id": "<20220927232628.7544-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] cam: drm: Skip DRM devices not capable of\n\tsupporting the atomic API",
        "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 atomic API. Some legacy display\ncontrollers would be skipped as well, but libcamera doesn't run on those\nsystems anyway, and the DRM helper doesn't support the legacy KMS\nmodeset API in any case.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/cam/drm.cpp | 31 +++++++++++++++++++++++--------\n 1 file changed, 23 insertions(+), 8 deletions(-)",
    "diff": "diff --git a/src/cam/drm.cpp b/src/cam/drm.cpp\nindex b0602c942853..b2a6b0bba9e8 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,38 @@ 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 atomic API, to avoid\n+\t\t * selecting a DRM device corresponding to a GPU.\n+\t\t */\n+\t\tret = drmGetCap(fd_, DRM_CLIENT_CAP_ATOMIC, &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"
    ]
}