{"id":350,"url":"https://patchwork.libcamera.org/api/patches/350/?format=json","web_url":"https://patchwork.libcamera.org/patch/350/","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":"<20190123134530.26993-1-kieran.bingham@ideasonboard.com>","date":"2019-01-23T13:45:30","name":"[libcamera-devel,v2] libcamera: v4l2device: Obtain device capabilities","commit_ref":"e5163f54d47c4f2c167eba5e40f8df62229e8ad5","pull_url":null,"state":"accepted","archived":false,"hash":"52998f6073716194e231da41b08d4fcbe0f23f67","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/350/mbox/","series":[{"id":122,"url":"https://patchwork.libcamera.org/api/series/122/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=122","date":"2019-01-23T13:45:30","name":"[libcamera-devel,v2] libcamera: v4l2device: Obtain device capabilities","version":2,"mbox":"https://patchwork.libcamera.org/series/122/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/350/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/350/checks/","tags":{},"headers":{"Return-Path":"<kieran.bingham@ideasonboard.com>","Received":["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 0CF2060C7D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 23 Jan 2019 14:45:35 +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 78A6923D;\n\tWed, 23 Jan 2019 14:45:34 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1548251134;\n\tbh=lPG/q21VkKRHtX71hkJpNMvUY+sKc7GZHXs+WUd4qZA=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=uDNomlnTeQZzlcsqTrzEPOj3NM9szc866pukahxOxLtzaXR3U6gUa7Xfxb80aYnCj\n\tzhDsG3l6pX26v/A9aAHjt9fm/UWBvcXDS55efWzYVSfaHLumakFvPTW2AOLQr632HP\n\tO49QsK1rxGSAnHWyWK23xztEiRPM8/O5FDD8T140=","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"LibCamera Devel <libcamera-devel@lists.libcamera.org>","Date":"Wed, 23 Jan 2019 13:45:30 +0000","Message-Id":"<20190123134530.26993-1-kieran.bingham@ideasonboard.com>","X-Mailer":"git-send-email 2.19.1","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v2] 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":"Wed, 23 Jan 2019 13:45:35 -0000"},"content":"The capabilities structure from the kernel can return capabilities of the\ndriver, or potentially more specific device capabilities.\n\nHandle this with an inline function 'device_caps()' to return the device\nspecific capabilities when available, or fall back to the driver capabilities\notherwise.\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n src/libcamera/include/v4l2_device.h | 12 +++++++++---\n src/libcamera/v4l2_device.cpp       |  7 +++++++\n 2 files changed, 16 insertions(+), 3 deletions(-)","diff":"diff --git a/src/libcamera/include/v4l2_device.h b/src/libcamera/include/v4l2_device.h\nindex b92e1f1c96c3..cb3601ca070c 100644\n--- a/src/libcamera/include/v4l2_device.h\n+++ b/src/libcamera/include/v4l2_device.h\n@@ -26,10 +26,16 @@ struct V4L2Capability final : v4l2_capability {\n \t{\n \t\treturn reinterpret_cast<const char *>(v4l2_capability::bus_info);\n \t}\n+\tunsigned int device_caps() const\n+\t{\n+\t\treturn capabilities & V4L2_CAP_DEVICE_CAPS\n+\t\t\t\t    ? v4l2_capability::device_caps\n+\t\t\t\t    : v4l2_capability::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 device_caps() & V4L2_CAP_VIDEO_CAPTURE; }\n+\tbool isOutput() const { return device_caps() & V4L2_CAP_VIDEO_OUTPUT; }\n+\tbool hasStreaming() const { return device_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..0ce2b187f2f0 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::device_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","v2"]}