From 6db776d55a88440383359910a1ec131db65692bb Mon Sep 17 00:00:00 2001 From: Jacopo Mondi Date: Mon, 29 Jun 2020 17:51:18 +0200 Subject: libcamera: ipu3: cio2: Report format and sizes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add two methods to the CIO2Device class to retrieve all the supported PixelFormats and sizes. Acked-by: Laurent Pinchart Reviewed-by: Niklas Söderlund Signed-off-by: Jacopo Mondi --- src/libcamera/pipeline/ipu3/cio2.cpp | 40 ++++++++++++++++++++++++++++++++++++ src/libcamera/pipeline/ipu3/cio2.h | 5 +++++ 2 files changed, 45 insertions(+) diff --git a/src/libcamera/pipeline/ipu3/cio2.cpp b/src/libcamera/pipeline/ipu3/cio2.cpp index 77f54da4..abe6d8a5 100644 --- a/src/libcamera/pipeline/ipu3/cio2.cpp +++ b/src/libcamera/pipeline/ipu3/cio2.cpp @@ -10,6 +10,7 @@ #include #include +#include #include #include "libcamera/internal/camera_sensor.h" @@ -43,6 +44,45 @@ CIO2Device::~CIO2Device() delete sensor_; } +/** + * \brief Retrieve the list of supported PixelFormats + * + * Retrieve the list of supported pixel formats by matching the sensor produced + * media bus codes with the formats supported by the CIO2 unit. + * + * \return The list of supported PixelFormat + */ +std::vector CIO2Device::formats() const +{ + if (!sensor_) + return {}; + + std::vector formats; + for (unsigned int code : sensor_->mbusCodes()) { + auto it = mbusCodesToPixelFormat.find(code); + if (it != mbusCodesToPixelFormat.end()) + formats.push_back(it->second); + } + + return formats; +} + +/** + * \brief Retrieve the list of supported size ranges + * \return The list of supported SizeRange + */ +std::vector CIO2Device::sizes() const +{ + if (!sensor_) + return {}; + + std::vector sizes; + for (const Size &size : sensor_->sizes()) + sizes.emplace_back(size, size); + + return sizes; +} + /** * \brief Initialize components of the CIO2 device with \a index * \param[in] media The CIO2 media device diff --git a/src/libcamera/pipeline/ipu3/cio2.h b/src/libcamera/pipeline/ipu3/cio2.h index 956355a0..221cf817 100644 --- a/src/libcamera/pipeline/ipu3/cio2.h +++ b/src/libcamera/pipeline/ipu3/cio2.h @@ -20,8 +20,10 @@ namespace libcamera { class CameraSensor; class FrameBuffer; class MediaDevice; +class PixelFormat; class Request; class Size; +class SizeRange; class V4L2Subdevice; struct StreamConfiguration; @@ -33,6 +35,9 @@ public: CIO2Device(); ~CIO2Device(); + std::vector formats() const; + std::vector sizes() const; + int init(const MediaDevice *media, unsigned int index); int configure(const Size &size, V4L2DeviceFormat *outputFormat); -- cgit v1.2.1