From patchwork Mon Jun 8 23:28:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 3997 X-Patchwork-Delegate: jacopo@jmondi.org Return-Path: Received: from relay10.mail.gandi.net (relay10.mail.gandi.net [217.70.178.230]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 07F5D63CBF for ; Tue, 9 Jun 2020 01:25:25 +0200 (CEST) Received: from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay10.mail.gandi.net (Postfix) with ESMTPSA id 5501F240004; Mon, 8 Jun 2020 23:25:25 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Tue, 9 Jun 2020 01:28:40 +0200 Message-Id: <20200608232844.10150-3-jacopo@jmondi.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200608232844.10150-1-jacopo@jmondi.org> References: <20200608232844.10150-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 2/6] libcamera: v4l2_subdevice: Provide Formats typedef X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Jun 2020 23:25:26 -0000 Provide a type definition for ImageFormats to allow users of V4L2Subdevice to refer to it as V4L2Subdevice::Formats. Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- include/libcamera/internal/camera_sensor.h | 6 ++---- include/libcamera/internal/v4l2_subdevice.h | 4 +++- src/libcamera/v4l2_subdevice.cpp | 10 ++++++++-- test/v4l2_subdevice/list_formats.cpp | 2 +- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h index d5814a26a121..06c8292ca301 100644 --- a/include/libcamera/internal/camera_sensor.h +++ b/include/libcamera/internal/camera_sensor.h @@ -16,13 +16,11 @@ #include "libcamera/internal/formats.h" #include "libcamera/internal/log.h" +#include "libcamera/internal/v4l2_subdevice.h" namespace libcamera { class MediaEntity; -class V4L2Subdevice; - -struct V4L2SubdeviceFormat; struct CameraSensorInfo { std::string model; @@ -75,7 +73,7 @@ private: std::string model_; - ImageFormats formats_; + V4L2Subdevice::Formats formats_; Size resolution_; std::vector mbusCodes_; std::vector sizes_; diff --git a/include/libcamera/internal/v4l2_subdevice.h b/include/libcamera/internal/v4l2_subdevice.h index f811d316dada..c678fc87e80f 100644 --- a/include/libcamera/internal/v4l2_subdevice.h +++ b/include/libcamera/internal/v4l2_subdevice.h @@ -32,6 +32,8 @@ struct V4L2SubdeviceFormat { class V4L2Subdevice : public V4L2Device { public: + using Formats = ImageFormats; + enum Whence { ActiveFormat, TryFormat, @@ -51,7 +53,7 @@ public: int setSelection(unsigned int pad, unsigned int target, Rectangle *rect); - ImageFormats formats(unsigned int pad); + Formats formats(unsigned int pad); int getFormat(unsigned int pad, V4L2SubdeviceFormat *format, Whence whence = ActiveFormat); diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp index 9fa20e84a904..de7d0c0db2b6 100644 --- a/src/libcamera/v4l2_subdevice.cpp +++ b/src/libcamera/v4l2_subdevice.cpp @@ -197,6 +197,12 @@ uint8_t V4L2SubdeviceFormat::bitsPerPixel() const * any device left open will be closed, and any resources released. */ +/** + * \typedef V4L2Subdevice::Formats + * \brief Enumeration of uint32_t media bus codes associated to image + * resolutions + */ + /** * \enum V4L2Subdevice::Whence * \brief Specify the type of format for getFormat() and setFormat() operations @@ -320,9 +326,9 @@ int V4L2Subdevice::setSelection(unsigned int pad, unsigned int target, * * \return A list of the supported device formats */ -ImageFormats V4L2Subdevice::formats(unsigned int pad) +V4L2Subdevice::Formats V4L2Subdevice::formats(unsigned int pad) { - ImageFormats formats; + Formats formats; if (pad >= entity_->pads().size()) { LOG(V4L2, Error) << "Invalid pad: " << pad; diff --git a/test/v4l2_subdevice/list_formats.cpp b/test/v4l2_subdevice/list_formats.cpp index 3e8d4cdba045..7f0b3333f617 100644 --- a/test/v4l2_subdevice/list_formats.cpp +++ b/test/v4l2_subdevice/list_formats.cpp @@ -47,7 +47,7 @@ void ListFormatsTest::printFormats(unsigned int pad, int ListFormatsTest::run() { /* List all formats available on existing "Scaler" pads. */ - ImageFormats formats; + V4L2Subdevice::Formats formats; formats = scaler_->formats(0); if (formats.isEmpty()) {