From patchwork Mon Jan 21 17:27:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 305 Return-Path: Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6DEDE60C96 for ; Mon, 21 Jan 2019 18:27:05 +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 relay8-d.mail.gandi.net (Postfix) with ESMTPSA id 03C7B1BF206; Mon, 21 Jan 2019 17:27:04 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Mon, 21 Jan 2019 18:27:03 +0100 Message-Id: <20190121172705.19985-5-jacopo@jmondi.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190121172705.19985-1-jacopo@jmondi.org> References: <20190121172705.19985-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 4/6] libcamera: v4l2_device: Add single/multiplane 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: Mon, 21 Jan 2019 17:27:05 -0000 Add a class hierarchy internal to V4L2Device to handle set/get format operations in the single/multi plane use case. Provide stubs only for get/setFormat methods at the moment. --- src/libcamera/include/v4l2_device.h | 34 +++++++++++++++++ src/libcamera/v4l2_device.cpp | 59 +++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+) diff --git a/src/libcamera/include/v4l2_device.h b/src/libcamera/include/v4l2_device.h index 0101a4b..81992dc 100644 --- a/src/libcamera/include/v4l2_device.h +++ b/src/libcamera/include/v4l2_device.h @@ -7,6 +7,7 @@ #ifndef __LIBCAMERA_V4L2_DEVICE_H__ #define __LIBCAMERA_V4L2_DEVICE_H__ +#include #include #include @@ -54,11 +55,44 @@ public: const char *busName() const { return caps_.bus_info(); } int setControl(unsigned int control, int value); + int getFormat(); + int setFormat(); private: + class V4L2Format + { + public: + virtual ~V4L2Format() { } + virtual int setFormat() = 0; + virtual int getFormat() = 0; + + protected: + V4L2Format() { } + V4L2Format(V4L2Format &) = delete; + }; + + class V4L2FormatSPlane : public V4L2Format + { + public: + V4L2FormatSPlane() { } + ~V4L2FormatSPlane() { } + int setFormat(); + int getFormat(); + }; + + class V4L2FormatMPlane : public V4L2Format + { + public: + V4L2FormatMPlane() { } + ~V4L2FormatMPlane() { } + int setFormat(); + int getFormat(); + }; + std::string devnode_; int fd_; V4L2Capability caps_; + std::unique_ptr format_; }; } /* namespace libcamera */ diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index 7cd89d7..126f6f2 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -5,6 +5,8 @@ * v4l2_device.cpp - V4L2 Device */ +#include + #include #include #include @@ -13,6 +15,7 @@ #include "log.h" #include "media_object.h" +#include "utils.h" #include "v4l2_device.h" /** @@ -182,6 +185,12 @@ int V4L2Device::open() return -EINVAL; } + /* Create single/multi plane format handler. */ + if (caps_.isSinglePlane()) + format_ = utils::make_unique(); + else + format_ = utils::make_unique(); + return 0; } @@ -262,4 +271,54 @@ int V4L2Device::setControl(unsigned int control, int value) return v4l2_ctrl.value; } +/** + * \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::getFormat() +{ + return format_->getFormat(); +} + +/** + * \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 format_->setFormat(); +} + +/* FIXME: this function is a stub at the moment. */ +int V4L2Device::V4L2FormatSPlane::getFormat() +{ + return 0; +} + +/* FIXME: this function is a stub at the moment. */ +int V4L2Device::V4L2FormatSPlane::setFormat() +{ + return 0; +} + +/* FIXME: this function is a stub at the moment. */ +int V4L2Device::V4L2FormatMPlane::getFormat() +{ + return 0; +} + +/* FIXME: this function is a stub at the moment. */ +int V4L2Device::V4L2FormatMPlane::setFormat() +{ + return 0; +} + } /* namespace libcamera */