From patchwork Fri Apr 29 21:23:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 15756 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 C10FCC3256 for ; Fri, 29 Apr 2022 21:23:58 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CED0965649; Fri, 29 Apr 2022 23:23:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1651267436; bh=c/W7P84n+bFDmMYUyU2IKL/TCgna5QVZsUa6c8/xcJg=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=yjyZtLYHzXEM1qrRVnQ5LphEXOYqzH1tlvcT9zQjEuBfZ9XxC0t8X4EyJiGjJK8GT CXlR7qyNn6MtFICiV5uBCJw6UbPMIv1Tet/3LTULlYA/w8mxb337RE3kNaiSJt9sHP V2iTo0FWJLulJiqtUVwRbYhfgUL6bYCJynQ9B047Yx3XSxwJc0jzuvPFeUPoEKoa/t 2KxekzxkwETu1YMAFXXn9JtPpdNj/QmW7Svj3hGhzVQiXJI49HOaNPS8qY8eRuWBvd vQfAORDeeO5rDRGWThWW7g2S9cJJVjjFPc1DFbgouAtrVjtf3QTk0tQrEDx1qc+F0E GL2VcMdQ3wGfg== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id AEDD86042F for ; Fri, 29 Apr 2022 23:23:53 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="aFA2jJfg"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 424AD488; Fri, 29 Apr 2022 23:23:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1651267433; bh=c/W7P84n+bFDmMYUyU2IKL/TCgna5QVZsUa6c8/xcJg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aFA2jJfgIE3PPGNTVhFcZl18Hz9y+aXMVTQW9FjLnj33V5Sr/BdP+RZ4YhQtCDU5E lv5438yL1nRRw14sEG0f/TYlLX32i6/Or3H2hLKdED4c1x900bYEESvc0CbKu+T3gI zVnyMIZ2HCHkZgMGboeU0jITwRkAwdD4MU2o9raE= To: libcamera-devel@lists.libcamera.org Date: Sat, 30 Apr 2022 00:23:45 +0300 Message-Id: <20220429212348.18063-3-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220429212348.18063-1-laurent.pinchart@ideasonboard.com> References: <20220429212348.18063-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/5] libcamera: Add operator<<() for pixel format classes 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-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Implement the stream output operator<<() for the PixelFormat and V4L2PixelFormat classes to simplify printing them. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- include/libcamera/internal/v4l2_pixelformat.h | 3 +++ include/libcamera/pixel_format.h | 3 +++ src/libcamera/pixel_format.cpp | 12 ++++++++++++ src/libcamera/v4l2_pixelformat.cpp | 13 +++++++++++++ 4 files changed, 31 insertions(+) diff --git a/include/libcamera/internal/v4l2_pixelformat.h b/include/libcamera/internal/v4l2_pixelformat.h index 886d534d8c91..fb2d5d0b93df 100644 --- a/include/libcamera/internal/v4l2_pixelformat.h +++ b/include/libcamera/internal/v4l2_pixelformat.h @@ -8,6 +8,7 @@ #pragma once +#include #include #include @@ -50,4 +51,6 @@ private: uint32_t fourcc_; }; +std::ostream &operator<<(std::ostream &out, const V4L2PixelFormat &f); + } /* namespace libcamera */ diff --git a/include/libcamera/pixel_format.h b/include/libcamera/pixel_format.h index a9d7c03de851..d49c5f784118 100644 --- a/include/libcamera/pixel_format.h +++ b/include/libcamera/pixel_format.h @@ -7,6 +7,7 @@ #pragma once +#include #include #include #include @@ -45,4 +46,6 @@ private: uint64_t modifier_; }; +std::ostream &operator<<(std::ostream &out, const PixelFormat &f); + } /* namespace libcamera */ diff --git a/src/libcamera/pixel_format.cpp b/src/libcamera/pixel_format.cpp index 997aeb8a9290..80c22072b072 100644 --- a/src/libcamera/pixel_format.cpp +++ b/src/libcamera/pixel_format.cpp @@ -140,4 +140,16 @@ PixelFormat PixelFormat::fromString(const std::string &name) return PixelFormatInfo::info(name).format; } +/** + * \brief Insert a text representation of a PixelFormat into an output stream + * \param[in] out The output stream + * \param[in] f The PixelFormat + * \return The output stream \a out + */ +std::ostream &operator<<(std::ostream &out, const PixelFormat &f) +{ + out << f.toString(); + return out; +} + } /* namespace libcamera */ diff --git a/src/libcamera/v4l2_pixelformat.cpp b/src/libcamera/v4l2_pixelformat.cpp index 0e0da3f0df07..1dd93baa7a64 100644 --- a/src/libcamera/v4l2_pixelformat.cpp +++ b/src/libcamera/v4l2_pixelformat.cpp @@ -316,4 +316,17 @@ V4L2PixelFormat V4L2PixelFormat::fromPixelFormat(const PixelFormat &pixelFormat, return multiplanar ? info.v4l2Formats.multi : info.v4l2Formats.single; } +/** + * \brief Insert a text representation of a V4L2PixelFormat into an output + * stream + * \param[in] out The output stream + * \param[in] f The V4L2PixelFormat + * \return The output stream \a out + */ +std::ostream &operator<<(std::ostream &out, const V4L2PixelFormat &f) +{ + out << f.toString(); + return out; +} + } /* namespace libcamera */