From patchwork Mon Jul 20 10:47:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 8878 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 6199FC0109 for ; Mon, 20 Jul 2020 10:44:22 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3A9CB605BF; Mon, 20 Jul 2020 12:44:22 +0200 (CEST) Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DFE9E60537 for ; Mon, 20 Jul 2020 12:44:17 +0200 (CEST) X-Originating-IP: 93.34.118.233 Received: from uno.lan (93-34-118-233.ip49.fastwebnet.it [93.34.118.233]) (Authenticated sender: jacopo@jmondi.org) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 52D6F6000B; Mon, 20 Jul 2020 10:44:17 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Mon, 20 Jul 2020 12:47:23 +0200 Message-Id: <20200720104736.19986-7-jacopo@jmondi.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200720104736.19986-1-jacopo@jmondi.org> References: <20200720104736.19986-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 06/19] libcamera: ipu3: cio2: Report format and sizes 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add two methods to the CIO2Device class to retrieve all the supported PixelFormats and sizes. Reviewed-by: Niklas Söderlund Signed-off-by: Jacopo Mondi Acked-by: Laurent Pinchart --- 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 77f54da47e28..abe6d8a592d6 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 956355a0aa58..221cf817eee9 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);