From patchwork Thu Jan 24 11:29:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 367 Return-Path: Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2E8DB60C81 for ; Thu, 24 Jan 2019 12:29:52 +0100 (CET) X-Originating-IP: 2.224.242.101 Received: from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id B9E83E0015; Thu, 24 Jan 2019 11:29:51 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Thu, 24 Jan 2019 12:29:59 +0100 Message-Id: <20190124113000.7142-2-jacopo@jmondi.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190124113000.7142-1-jacopo@jmondi.org> References: <20190124113000.7142-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 1/2] libcamera: v4l2_device: Identify multiplanar formats 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: Thu, 24 Jan 2019 11:29:52 -0000 Add functions to V4L2Capability to identify if a V4L2 device supports multiplanar V4L2 APIs. Signed-off-by: Jacopo Mondi Reviewed-by: Niklas Söderlund --- src/libcamera/include/v4l2_device.h | 23 +++++++++++++++++++---- src/libcamera/v4l2_device.cpp | 6 ++++++ 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/libcamera/include/v4l2_device.h b/src/libcamera/include/v4l2_device.h index cb3601c..413bb7f 100644 --- a/src/libcamera/include/v4l2_device.h +++ b/src/libcamera/include/v4l2_device.h @@ -32,10 +32,25 @@ struct V4L2Capability final : v4l2_capability { ? v4l2_capability::device_caps : v4l2_capability::capabilities; } - - 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; } + bool isMultiplanar() const + { + return device_caps() & (V4L2_CAP_VIDEO_CAPTURE_MPLANE | + V4L2_CAP_VIDEO_OUTPUT_MPLANE); + } + bool isCapture() const + { + return device_caps() & (V4L2_CAP_VIDEO_CAPTURE | + V4L2_CAP_VIDEO_CAPTURE_MPLANE); + } + bool isOutput() const + { + return device_caps() & (V4L2_CAP_VIDEO_OUTPUT | + V4L2_CAP_VIDEO_OUTPUT_MPLANE); + } + 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 0ce2b18..9cb504d 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -56,6 +56,12 @@ LOG_DEFINE_CATEGORY(V4L2) * driver capabilities otherwise */ +/** + * \fn bool V4L2Capability::isMultiplanar() + * \brief Identify if the device implement V4L2 multiplanar APIs + * \return True if the device supports multiplanar APIs + */ + /** * \fn bool V4L2Capability::isCapture() * \brief Identify if the device is capable of capturing video From patchwork Thu Jan 24 11:30:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 368 X-Patchwork-Delegate: jacopo@jmondi.org Return-Path: Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id BCD4560C80 for ; Thu, 24 Jan 2019 12:29:52 +0100 (CET) X-Originating-IP: 2.224.242.101 Received: from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 5593FE0007; Thu, 24 Jan 2019 11:29:52 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Thu, 24 Jan 2019 12:30:00 +0100 Message-Id: <20190124113000.7142-3-jacopo@jmondi.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190124113000.7142-1-jacopo@jmondi.org> References: <20190124113000.7142-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 2/2] libcamera: v4l2_device: Add stubs to set/get format 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: Thu, 24 Jan 2019 11:29:53 -0000 Add function stubs for set/get format to V4L2Device. Signed-off-by: Jacopo Mondi --- src/libcamera/include/v4l2_device.h | 9 ++++++ src/libcamera/v4l2_device.cpp | 49 +++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/src/libcamera/include/v4l2_device.h b/src/libcamera/include/v4l2_device.h index 413bb7f..2da30d1 100644 --- a/src/libcamera/include/v4l2_device.h +++ b/src/libcamera/include/v4l2_device.h @@ -72,10 +72,19 @@ public: const char *deviceName() const { return caps_.card(); } const char *busName() const { return caps_.bus_info(); } + int format(); + int setFormat(); + private: std::string deviceNode_; int fd_; V4L2Capability caps_; + + int getFormatSingleplane(); + int setFormatSingleplane(); + + int getFormatMultiplane(); + int setFormatMultiplane(); }; } /* namespace libcamera */ diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index 9cb504d..2ddb800 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -213,4 +213,53 @@ void V4L2Device::close() * \return The string containing the device location */ +/** + * \brief Retrieve the image format set on the V4L2 device + * + * TODO: define how the image format is encoded + * FIXME: this function is a stub at the moment + * + * \return 0 for success, a negative error code otherwise + */ +int V4L2Device::format() +{ + return caps_.isMultiplanar() ? getFormatMultiplane() : + getFormatSingleplane(); +} + +/** + * \brief Program an image format on the V4L2 device + * + * TODO: define how the image format is encoded + * FIXME: this function is a stub at the moment + * + * \return 0 for success, a negative error code otherwise + */ +int V4L2Device::setFormat() +{ + return caps_.isMultiplanar() ? setFormatMultiplane() : + setFormatSingleplane(); +} + +/* FIXME: these functions are stubs at the moment. */ +int V4L2Device::getFormatSingleplane() +{ + return 0; +} + +int V4L2Device::setFormatSingleplane() +{ + return 0; +} + +int V4L2Device::getFormatMultiplane() +{ + return 0; +} + +int V4L2Device::setFormatMultiplane() +{ + return 0; +} + } /* namespace libcamera */