Show a patch.

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

{
    "id": 16063,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/16063/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/16063/",
    "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": "<20220526133025.18746-1-laurent.pinchart@ideasonboard.com>",
    "date": "2022-05-26T13:30:25",
    "name": "[libcamera-devel] libcamera: pipeline: uvcvideo: Infer camera location from removable attribute",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "07aa875ebd4f15a57a0b35463a03685016e4203f",
    "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/16063/mbox/",
    "series": [
        {
            "id": 3143,
            "url": "https://patchwork.libcamera.org/api/1.1/series/3143/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3143",
            "date": "2022-05-26T13:30:25",
            "name": "[libcamera-devel] libcamera: pipeline: uvcvideo: Infer camera location from removable attribute",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/3143/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/16063/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/16063/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 66B6EBD160\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 26 May 2022 13:30:38 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7A8AC611BF;\n\tThu, 26 May 2022 15:30:37 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8DC8060DB0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 26 May 2022 15:30:35 +0200 (CEST)",
            "from pendragon.lan (unknown [37.120.212.14])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id C9CA56D4;\n\tThu, 26 May 2022 15:30:34 +0200 (CEST)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1653571837;\n\tbh=cuC721V7+su2w+pfJvMWBlbx9mL910pdlbQCvaiCREg=;\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=uM2QUrUlZo2pmRm5/AU3tWgt4rA/XZvo2k42KHQy43EytNUG41huFHe40M5rC9VD7\n\toTZvp/ClGem+aLStCaPsAY7kfB+VOML78GQLSgDeAiwGjD4YCB61Xuq62tCwu+Z6rg\n\tzTR0rCvRwk1rcBp/OYlC9j1McnzebpCuU6PLoqKD1fmJZ6tX2E+ll0hZvT9CV2K1o5\n\ta0/P4vPqc9wKQ6kv+m6RrNfPPzoo44KSVUYx4ahZa//p2spJvlHDqszu8lsMQuO0D2\n\tYwQ6fmu6ThuZ6bSh19e1nUdfLs0ZuQsmqEmfDeXa3br5aAUUiyuusnrhjgM7iglgKq\n\tw1tlwLYV5TzGw==",
            "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1653571835;\n\tbh=cuC721V7+su2w+pfJvMWBlbx9mL910pdlbQCvaiCREg=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=uEpT+XlnVfX46heWj3CmLWtRjmzaKEiyfpwbdgoc3gHDOQxyzwHYpJrVkPoh2qZqL\n\tyt9VEPjcpGIYEusmVxqy/20KSOr2eWSXavgvWL833hnlq4MnRONl6DS7Iit6djmVL3\n\tkSylkIq6GHcVJcE8LHnbsJKyulLV1MpsIkgkEp5I="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"uEpT+Xln\"; dkim-atps=neutral",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Thu, 26 May 2022 16:30:25 +0300",
        "Message-Id": "<20220526133025.18746-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] libcamera: pipeline: uvcvideo: Infer\n\tcamera location from removable attribute",
        "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>",
        "Cc": "George Kiagiadakis <george.kiagiadakis@collabora.com>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Use the removable attribute exposed by the USB device in sysfs to infer\nif the camera is an external (when removable) or front (when\nnon-removable) camera. This is likely not perfect as the removable\nattribute is derived from ACPI data which may not always be accurate,\nand non-ACPI platforms likely report all devices as removable. Still,\nthis is a first step upon which a better method could be built.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 33 +++++++++++++++++---\n 1 file changed, 28 insertions(+), 5 deletions(-)\n\n\nbase-commit: f8e4649680303ce9b7dace5ad1344fcb450013ac\nprerequisite-patch-id: edbf31ed9d7f5374e17b34936fe1aa8dea2eac44",
    "diff": "diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\nindex 2ebf2788c3b4..53b2f23ab029 100644\n--- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n+++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n@@ -501,13 +501,36 @@ int UVCCameraData::init(MediaDevice *media)\n \n \tvideo_->bufferReady.connect(this, &UVCCameraData::bufferReady);\n \n-\t/*\n-\t * \\todo Find a way to tell internal and external UVC cameras apart.\n-\t * Until then, treat all UVC cameras as external.\n-\t */\n-\tproperties_.set(properties::Location, properties::CameraLocationExternal);\n \tproperties_.set(properties::Model, utils::toAscii(media->model()));\n \n+\t/*\n+\t * Derive the location from the device removable attribute in sysfs.\n+\t * Non-removable devices are assumed to be front as we lack detailed\n+\t * location information, and removable device are considered external.\n+\t *\n+\t * The sysfs removable attribute is derived from the ACPI _UPC attribute\n+\t * if available, or from the USB hub descriptors otherwise. ACPI data\n+\t * may not be very reliable, and the USB hub descriptors may not be\n+\t * accurate on DT-based platforms. A heuristic may need to be\n+\t * implemented later if too many devices end up being miscategorized.\n+\t *\n+\t * \\todo Find a way to tell front and back devices apart. This could\n+\t * come from the ACPI _PLD, but that may be even more unreliable than\n+\t * the _UPC.\n+\t */\n+\tproperties::LocationEnum location = properties::CameraLocationExternal;\n+\tstd::ifstream file(video_->devicePath() + \"/../removable\");\n+\tif (file.is_open()) {\n+\t\tstd::string value;\n+\t\tstd::getline(file, value);\n+\t\tfile.close();\n+\n+\t\tif (value == \"fixed\")\n+\t\t\tlocation = properties::CameraLocationFront;\n+\t}\n+\n+\tproperties_.set(properties::Location, location);\n+\n \t/*\n \t * Get the current format in order to initialize the sensor array\n \t * properties.\n",
    "prefixes": [
        "libcamera-devel"
    ]
}