{"id":328,"url":"https://patchwork.libcamera.org/api/patches/328/?format=json","web_url":"https://patchwork.libcamera.org/patch/328/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20190122192040.9719-1-kieran.bingham@ideasonboard.com>","date":"2019-01-22T19:20:40","name":"[libcamera-devel] libcamera: v4l2device: Obtain device capabilities","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"1edda5421d0f3add42ee3d9be3f21943a2eea244","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/?format=json","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/328/mbox/","series":[{"id":115,"url":"https://patchwork.libcamera.org/api/series/115/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=115","date":"2019-01-22T19:20:40","name":"[libcamera-devel] libcamera: v4l2device: Obtain device capabilities","version":1,"mbox":"https://patchwork.libcamera.org/series/115/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/328/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/328/checks/","tags":{},"headers":{"Return-Path":"<kieran.bingham@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0582560C7D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 22 Jan 2019 20:20:46 +0100 (CET)","from localhost.localdomain\n\t(cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 322FD575;\n\tTue, 22 Jan 2019 20:20:45 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1548184845;\n\tbh=5oAq2J7VaXW0LwexAat3A6HLR/zZdZHwCRTNzcGrvmI=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=G/HFMf1bkjulCHd0HNRKPWpuE1FrP7t1PfYzCtph6RpQjjB2FdMpkIF/4MNcgTQHJ\n\tUoip8rNQ1UcbjInBu34uGVdncSQfUOSJ9l3m3HjvcLt/roWxgavQ1nisFOEjXkXW75\n\tGm35rgfAeKxx3IfJI7NkXH43meaKsWf3TB7TQr2A=","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"LibCamera Devel <libcamera-devel@lists.libcamera.org>","Date":"Tue, 22 Jan 2019 19:20:40 +0000","Message-Id":"<20190122192040.9719-1-kieran.bingham@ideasonboard.com>","X-Mailer":"git-send-email 2.17.1","Subject":"[libcamera-devel] [PATCH] libcamera: v4l2device: Obtain device\n\tcapabilities","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","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>","X-List-Received-Date":"Tue, 22 Jan 2019 19:20:46 -0000"},"content":"The capabilities structure from the kernel can return capabilities of the\ndevice, or potentially more specific device capabilities.\n\nHandle this with an inline function to return the correct value.\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\nJacopo,\n\nSending this now to see what you think, as it might be useful to consider this\nwhile you're making adjustments in the area.\n\nBecause this code will be inlined, I expect the compiler to optimise sequential\nuses of this operation where the underlying capabilities is not modified.\n\nKieran \n\n\n src/libcamera/include/v4l2_device.h | 10 +++++++---\n src/libcamera/v4l2_device.cpp       |  7 +++++++\n 2 files changed, 14 insertions(+), 3 deletions(-)","diff":"diff --git a/src/libcamera/include/v4l2_device.h b/src/libcamera/include/v4l2_device.h\nindex b92e1f1c96c3..90d18b9f2260 100644\n--- a/src/libcamera/include/v4l2_device.h\n+++ b/src/libcamera/include/v4l2_device.h\n@@ -26,10 +26,14 @@ struct V4L2Capability final : v4l2_capability {\n \t{\n \t\treturn reinterpret_cast<const char *>(v4l2_capability::bus_info);\n \t}\n+\tunsigned int caps() const\n+\t{\n+\t\treturn capabilities & V4L2_CAP_DEVICE_CAPS ? device_caps : capabilities;\n+\t}\n \n-\tbool isCapture() const { return capabilities & V4L2_CAP_VIDEO_CAPTURE; }\n-\tbool isOutput() const { return capabilities & V4L2_CAP_VIDEO_OUTPUT; }\n-\tbool hasStreaming() const { return capabilities & V4L2_CAP_STREAMING; }\n+\tbool isCapture() const { return caps() & V4L2_CAP_VIDEO_CAPTURE; }\n+\tbool isOutput() const { return caps() & V4L2_CAP_VIDEO_OUTPUT; }\n+\tbool hasStreaming() const { return caps() & V4L2_CAP_STREAMING; }\n };\n \n class MediaEntity;\ndiff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\nindex 2b17fa1eb0e8..4d1cc5b6070f 100644\n--- a/src/libcamera/v4l2_device.cpp\n+++ b/src/libcamera/v4l2_device.cpp\n@@ -49,6 +49,13 @@ LOG_DEFINE_CATEGORY(V4L2)\n  * \\return The string containing the device location\n  */\n \n+/**\n+ * \\fn unsigned int V4L2Capability::caps()\n+ * \\brief Retrieve the capabilities of the device\n+ * \\return The device specific capabilities if V4L2_CAP_DEVICE_CAPS is set or\n+ * \t   driver capabilities otherwise\n+ */\n+\n /**\n  * \\fn bool V4L2Capability::isCapture()\n  * \\brief Identify if the device is capable of capturing video\n","prefixes":["libcamera-devel"]}