From patchwork Wed Jan 23 13:45:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 350 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0CF2060C7D for ; Wed, 23 Jan 2019 14:45:35 +0100 (CET) Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 78A6923D; Wed, 23 Jan 2019 14:45:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1548251134; bh=lPG/q21VkKRHtX71hkJpNMvUY+sKc7GZHXs+WUd4qZA=; h=From:To:Cc:Subject:Date:From; b=uDNomlnTeQZzlcsqTrzEPOj3NM9szc866pukahxOxLtzaXR3U6gUa7Xfxb80aYnCj zhDsG3l6pX26v/A9aAHjt9fm/UWBvcXDS55efWzYVSfaHLumakFvPTW2AOLQr632HP O49QsK1rxGSAnHWyWK23xztEiRPM8/O5FDD8T140= From: Kieran Bingham To: LibCamera Devel 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 Subject: [libcamera-devel] [PATCH v2] libcamera: v4l2device: Obtain device capabilities X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Jan 2019 13:45:35 -0000 The capabilities structure from the kernel can return capabilities of the driver, or potentially more specific device capabilities. Handle this with an inline function 'device_caps()' to return the device specific capabilities when available, or fall back to the driver capabilities otherwise. Signed-off-by: Kieran Bingham Reviewed-by: Niklas Söderlund --- src/libcamera/include/v4l2_device.h | 12 +++++++++--- src/libcamera/v4l2_device.cpp | 7 +++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/libcamera/include/v4l2_device.h b/src/libcamera/include/v4l2_device.h index b92e1f1c96c3..cb3601ca070c 100644 --- a/src/libcamera/include/v4l2_device.h +++ b/src/libcamera/include/v4l2_device.h @@ -26,10 +26,16 @@ struct V4L2Capability final : v4l2_capability { { return reinterpret_cast(v4l2_capability::bus_info); } + unsigned int device_caps() const + { + return capabilities & V4L2_CAP_DEVICE_CAPS + ? v4l2_capability::device_caps + : v4l2_capability::capabilities; + } - bool isCapture() const { return capabilities & V4L2_CAP_VIDEO_CAPTURE; } - bool isOutput() const { return capabilities & V4L2_CAP_VIDEO_OUTPUT; } - bool hasStreaming() const { return capabilities & V4L2_CAP_STREAMING; } + bool isCapture() const { return device_caps() & V4L2_CAP_VIDEO_CAPTURE; } + bool isOutput() const { return device_caps() & V4L2_CAP_VIDEO_OUTPUT; } + bool hasStreaming() const { return device_caps() & V4L2_CAP_STREAMING; } }; class MediaEntity; diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index 2b17fa1eb0e8..0ce2b187f2f0 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -49,6 +49,13 @@ LOG_DEFINE_CATEGORY(V4L2) * \return The string containing the device location */ +/** + * \fn unsigned int V4L2Capability::device_caps() + * \brief Retrieve the capabilities of the device + * \return The device specific capabilities if V4L2_CAP_DEVICE_CAPS is set or + * driver capabilities otherwise + */ + /** * \fn bool V4L2Capability::isCapture() * \brief Identify if the device is capable of capturing video