Show a patch.

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

{
    "id": 16125,
    "url": "https://patchwork.libcamera.org/api/patches/16125/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/16125/",
    "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": "<20220601152345.37753-1-ecurtin@redhat.com>",
    "date": "2022-06-01T15:23:45",
    "name": "[libcamera-devel] cam: drm: Support /dev/dri cards other than 0",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "b0248dadc6a6b4ebf8758665111d4df7cc79556b",
    "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/16125/mbox/",
    "series": [
        {
            "id": 3151,
            "url": "https://patchwork.libcamera.org/api/series/3151/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3151",
            "date": "2022-06-01T15:23:45",
            "name": "[libcamera-devel] cam: drm: Support /dev/dri cards other than 0",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/3151/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/16125/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/16125/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 3AFA0BD160\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  1 Jun 2022 15:24:07 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 45AA665631;\n\tWed,  1 Jun 2022 17:24:06 +0200 (CEST)",
            "from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.129.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6262260413\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  1 Jun 2022 17:24:04 +0200 (CEST)",
            "from mail-wm1-f72.google.com (mail-wm1-f72.google.com\n\t[209.85.128.72]) 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-595-d8n_Fh_qOnip1C4wYEDqQg-1; Wed, 01 Jun 2022 11:24:02 -0400",
            "by mail-wm1-f72.google.com with SMTP id\n\tl34-20020a05600c1d2200b003973a50c1e4so1303706wms.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 01 Jun 2022 08:24:01 -0700 (PDT)",
            "from p1.Home ([2001:8a0:6724:4500:a69c:e66f:828e:b340])\n\tby smtp.gmail.com with ESMTPSA id\n\tj26-20020a05600c1c1a00b003973e27b789sm7730487wms.27.2022.06.01.08.23.59\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 01 Jun 2022 08:23:59 -0700 (PDT)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1654097046;\n\tbh=+nqydM/I3LJFyuwAsgvXcD4TJ38CwGqMQO06dQ3NNek=;\n\th=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:Cc:From;\n\tb=zT9qwF1ckK4CmyXZAwjzxcExX2ctD6PPcKl9PXzpKsFzNGSsfkmDqFYKXbDwtculc\n\tiLRrkeh+cXDCHzF+QoImsExP6aMOMuNG+9RkoqaBvzCuJP5HO4wAKbyqjallhEJovN\n\tFUS5XBFXjInbVJ3iWUCu9XvpSUVdk8Jz201AUaWxIOn509WZMamlBwgHd+1hNC1eUS\n\tU5/S1P6R12jdDwR38Go7lv595/CNI2xpPzIcsKLT55fKzZL8VVXUq3owB3pMETxot6\n\tgtlKj0jW/LcubdfFKwUZhkn6X3GsM0ZHwldTWK7gWYRGVQpMNc+Opaz7rk419k9Mny\n\tmTaV3CBfqqyZw==",
            "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1654097043;\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=S+2Wo+NuuCWLNXxzZOOcYeGSU7isVTl4gCUJThsNYcM=;\n\tb=jNEMPi8otviL3EJVXmaLotVF7VKH0xlRVohWCis5KjovTiwo33/8u3/kVJW2X1XDd30Zjh\n\tUFHu+BcxpFCiEfkOdJalpoE6Ib60WYtEUCqa89nf370EZF5Ptk0Px5IZMBpusO8h/iNl06\n\t030GFqufAyT8Gue1oYnHr22Fvd/sFng="
        ],
        "Authentication-Results": [
            "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=redhat.com\n\theader.i=@redhat.com header.b=\"jNEMPi8o\"; \n\tdkim-atps=neutral",
            "relay.mimecast.com;\n\tauth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ecurtin@redhat.com"
        ],
        "X-MC-Unique": "d8n_Fh_qOnip1C4wYEDqQg-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=S+2Wo+NuuCWLNXxzZOOcYeGSU7isVTl4gCUJThsNYcM=;\n\tb=IqY6Usk0/gcxBJhpjkec4wiRfpUySGa2bsSAvzH8URaztg1bQuuF2hl09bieadUl5Z\n\tAgK1Do2p1Drohiph6UHX74gVrh8e/YCBOHFPLU/u1UU7FPQeC8aqjnkFvZBN7f42hzcH\n\tXwa6SOoeWGeDEmMMcUH9ztv6bv7TW6VkyX7pdwLr9av2raOajScAuKI0KmuonHkXw5cC\n\ts7ZmNd91JnZwMuRZkqieQ7CeTMQJ9/cVcUYmgsMlVqFaqg84S26/D32y1L+NnkEtVBYy\n\tKQVvaUcB+eN1NKgbMDi0ttMMgGjVKx0Wk1z62NeeKHRKOf6j2cHUDUjr8FCB0WM+Kp4k\n\taTJQ==",
        "X-Gm-Message-State": "AOAM533Q+pHxCE10oRAUOyS9rYPTiKB0kfyiD/AsEOyttnskXY4SOXaq\n\tezkwvNe4+UM+4VkmP5h5YfwtPoH9wtjcxhM4xrp47rUGvmay+itWuxNmucX7lxD5L7tQ9q+eItM\n\tjSRPCB8BaGiWobc194aAj8gITyz4RX4PKunjkG2ifp8lWBXy8ppMcTX8jCbhhfqJyzWXnV4qu9y\n\tD8GSVXoKaX",
        "X-Received": [
            "by 2002:a7b:ce94:0:b0:397:82a5:dd05 with SMTP id\n\tq20-20020a7bce94000000b0039782a5dd05mr27477474wmj.161.1654097040405; \n\tWed, 01 Jun 2022 08:24:00 -0700 (PDT)",
            "by 2002:a7b:ce94:0:b0:397:82a5:dd05 with SMTP id\n\tq20-20020a7bce94000000b0039782a5dd05mr27477455wmj.161.1654097040177; \n\tWed, 01 Jun 2022 08:24:00 -0700 (PDT)"
        ],
        "X-Google-Smtp-Source": "ABdhPJwXhzm5GWUYv1JWYVgFsZipRCQVESFu2WtCiTNoI3JbuGAQcsN5oZ1ETaHSNbQWMpKxTdO3BA==",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Wed,  1 Jun 2022 16:23:45 +0100",
        "Message-Id": "<20220601152345.37753-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] cam: drm: Support /dev/dri cards other\n\tthan 0",
        "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>",
        "Cc": "Ian Mullins <imullins@redhat.com>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Existing code is hardcoded to card0. Since recent fedora upgrades, we\nhave noticed on more than one machine that card1 is present as the\nlowest numbered device, could theoretically be higher. This technique\ntries every file starting with card and continue only when we have\nsuccessfully opened one. These devices with card1 as the lowest device\nwere simply failing when they do not see a /dev/dri/card0 file present.\n\nReported-by: Ian Mullins <imullins@redhat.com>\nSigned-off-by: Eric Curtin <ecurtin@redhat.com>\n---\n src/cam/drm.cpp | 37 +++++++++++++++++++++++++++----------\n 1 file changed, 27 insertions(+), 10 deletions(-)",
    "diff": "diff --git a/src/cam/drm.cpp b/src/cam/drm.cpp\nindex 42c5a3b1..5a322819 100644\n--- a/src/cam/drm.cpp\n+++ b/src/cam/drm.cpp\n@@ -8,6 +8,7 @@\n #include \"drm.h\"\n \n #include <algorithm>\n+#include <dirent.h>\n #include <errno.h>\n #include <fcntl.h>\n #include <iostream>\n@@ -393,8 +394,10 @@ Device::~Device()\n \n int Device::init()\n {\n-\tconstexpr size_t NODE_NAME_MAX = sizeof(\"/dev/dri/card255\");\n-\tchar name[NODE_NAME_MAX];\n+\tconstexpr size_t DIR_NAME_MAX = sizeof(\"/dev/dri/\");\n+\tconstexpr size_t BASE_NAME_MAX = sizeof(\"card255\");\n+\tconstexpr size_t NODE_NAME_MAX = DIR_NAME_MAX + BASE_NAME_MAX - 1;\n+\tchar name[NODE_NAME_MAX] = \"/dev/dri/\";\n \tint ret;\n \n \t/*\n@@ -404,14 +407,28 @@ int Device::init()\n \t * from drmOpen() is of no practical use as any modern system will\n \t * handle that through udev or an equivalent component.\n \t */\n-\tsnprintf(name, sizeof(name), \"/dev/dri/card%u\", 0);\n-\tfd_ = open(name, O_RDWR | O_CLOEXEC);\n-\tif (fd_ < 0) {\n-\t\tret = -errno;\n-\t\tstd::cerr\n-\t\t\t<< \"Failed to open DRM/KMS device \" << name << \": \"\n-\t\t\t<< strerror(-ret) << std::endl;\n-\t\treturn ret;\n+\tDIR *folder = opendir(name);\n+\tif (folder) {\n+\t\tfor (struct dirent *res; (res = readdir(folder));) {\n+\t\t\tif (strlen(res->d_name) > 4 &&\n+\t\t\t    !strncmp(res->d_name, \"card\", 4)) {\n+\t\t\t\tmemcpy(name + DIR_NAME_MAX - 1, res->d_name,\n+\t\t\t\t       BASE_NAME_MAX);\n+\t\t\t\tfd_ = open(name, O_RDWR | O_CLOEXEC);\n+\t\t\t\tif (fd_ < 0) {\n+\t\t\t\t\tret = -errno;\n+\t\t\t\t\tstd::cerr\n+\t\t\t\t\t\t<< \"Failed to open DRM/KMS device \"\n+\t\t\t\t\t\t<< name << \": \"\n+\t\t\t\t\t\t<< strerror(-ret) << std::endl;\n+\t\t\t\t\tcontinue;\n+\t\t\t\t}\n+\n+\t\t\t\tbreak;\n+\t\t\t}\n+\t\t}\n+\n+\t\tclosedir(folder);\n \t}\n \n \t/*\n",
    "prefixes": [
        "libcamera-devel"
    ]
}