From patchwork Wed Sep 8 08:14:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 13763 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 24340BDB1D for ; Wed, 8 Sep 2021 08:15:01 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DA19869173; Wed, 8 Sep 2021 10:15:00 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="YPdlrjoA"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3109E6916E for ; Wed, 8 Sep 2021 10:14:58 +0200 (CEST) Received: from pyrite.rasen.tech (unknown [IPv6:2400:4051:61:600:2c71:1b79:d06d:5032]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B8354993; Wed, 8 Sep 2021 10:14:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1631088897; bh=bfM8kBnyFpaLCAFcna3SlvvocnGZ6yCVKX+y4y4wLO4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YPdlrjoAlMmcr+l+TmMxdYF7Kg7ixZUPUekyuAIPiiAuGn1s5G4xP/uEv6C6XPNOS vpfEw2jStcIBpo3lDINWra/oaJubQy6IA4E999HLOIhxeF/Z8q4PWblwQd4TsbJjQP 3MSEO1LbUU87XluyO32SEMGWX9qLSB2uEwr7v2N4= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Wed, 8 Sep 2021 17:14:34 +0900 Message-Id: <20210908081437.4022697-5-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210908081437.4022697-1-paul.elder@ideasonboard.com> References: <20210908081437.4022697-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 4/7] libcamera: v4l2_pixelformat: Add helper function to get the description 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 a helper function to V4L2PixelFormat for retrieving the V4L2 description string. Signed-off-by: Paul Elder Reviewed-by: Laurent Pinchart --- include/libcamera/internal/v4l2_pixelformat.h | 1 + src/libcamera/v4l2_pixelformat.cpp | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/include/libcamera/internal/v4l2_pixelformat.h b/include/libcamera/internal/v4l2_pixelformat.h index 36c690db..3b24bc73 100644 --- a/include/libcamera/internal/v4l2_pixelformat.h +++ b/include/libcamera/internal/v4l2_pixelformat.h @@ -40,6 +40,7 @@ public: operator uint32_t() const { return fourcc_; } std::string toString() const; + const char *toDescription() const; PixelFormat toPixelFormat() const; static V4L2PixelFormat fromPixelFormat(const PixelFormat &pixelFormat, diff --git a/src/libcamera/v4l2_pixelformat.cpp b/src/libcamera/v4l2_pixelformat.cpp index 0a8312c4..f5598d9d 100644 --- a/src/libcamera/v4l2_pixelformat.cpp +++ b/src/libcamera/v4l2_pixelformat.cpp @@ -250,6 +250,23 @@ std::string V4L2PixelFormat::toString() const return ss; } +/** + * \brief Return the V4L2 description corresponding to the V4L2 format + * \return The V4L2 description corresponding to the V4L2 format + */ +const char *V4L2PixelFormat::toDescription() const +{ + const auto iter = vpf2pf.find(*this); + if (iter == vpf2pf.end()) { + LOG(V4L2, Warning) + << "Unsupported V4L2 pixel format " + << toString(); + return ""; + } + + return iter->second.name; +} + /** * \brief Convert the V4L2 pixel format to the corresponding PixelFormat * \return The PixelFormat corresponding to the V4L2 pixel format