[{"id":19545,"web_url":"https://patchwork.libcamera.org/comment/19545/","msgid":"<YTiESIte+/CVfFmo@pendragon.ideasonboard.com>","date":"2021-09-08T09:37:12","subject":"Re: [libcamera-devel] [PATCH v2 4/7] libcamera: v4l2_pixelformat:\n\tAdd helper function to get the description","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Paul,\n\nThank you for the patch.\n\nOn Wed, Sep 08, 2021 at 05:14:34PM +0900, Paul Elder wrote:\n> Add a helper function to V4L2PixelFormat for retrieving the V4L2\n> description string.\n> \n> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n> ---\n>  include/libcamera/internal/v4l2_pixelformat.h |  1 +\n>  src/libcamera/v4l2_pixelformat.cpp            | 17 +++++++++++++++++\n>  2 files changed, 18 insertions(+)\n> \n> diff --git a/include/libcamera/internal/v4l2_pixelformat.h b/include/libcamera/internal/v4l2_pixelformat.h\n> index 36c690db..3b24bc73 100644\n> --- a/include/libcamera/internal/v4l2_pixelformat.h\n> +++ b/include/libcamera/internal/v4l2_pixelformat.h\n> @@ -40,6 +40,7 @@ public:\n>  \toperator uint32_t() const { return fourcc_; }\n>  \n>  \tstd::string toString() const;\n> +\tconst char *toDescription() const;\n>  \n>  \tPixelFormat toPixelFormat() const;\n>  \tstatic V4L2PixelFormat fromPixelFormat(const PixelFormat &pixelFormat,\n> diff --git a/src/libcamera/v4l2_pixelformat.cpp b/src/libcamera/v4l2_pixelformat.cpp\n> index 0a8312c4..f5598d9d 100644\n> --- a/src/libcamera/v4l2_pixelformat.cpp\n> +++ b/src/libcamera/v4l2_pixelformat.cpp\n> @@ -250,6 +250,23 @@ std::string V4L2PixelFormat::toString() const\n>  \treturn ss;\n>  }\n>  \n> +/**\n> + * \\brief Return the V4L2 description corresponding to the V4L2 format\n\ns/Return/Retrieve/ and maybe \"Retrieve the V4L2 description for the\nformat\".\n\nLet's also add an extra paragraph here:\n\n * The description matches the value used by the kernel, as would be reported by\n * the VIDIOC_ENUM_FMT ioctl.\n\nThis should probably be copied to patch 3/7 to document the Info::name\nfield. And I'd also rename name to description in that patch.\n\n> + * \\return The V4L2 description corresponding to the V4L2 format\n> + */\n> +const char *V4L2PixelFormat::toDescription() const\n\nI'd name the function \"description\", it's not really a conversion\nfunction.\n\n> +{\n> +\tconst auto iter = vpf2pf.find(*this);\n> +\tif (iter == vpf2pf.end()) {\n> +\t\tLOG(V4L2, Warning)\n> +\t\t\t<< \"Unsupported V4L2 pixel format \"\n> +\t\t\t<< toString();\n> +\t\treturn \"\";\n\nHow about \"Unsupported\" or something similar ?\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> +\t}\n> +\n> +\treturn iter->second.name;\n> +}\n> +\n>  /**\n>   * \\brief Convert the V4L2 pixel format to the corresponding PixelFormat\n>   * \\return The PixelFormat corresponding to the V4L2 pixel format","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 46C63BDB1D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  8 Sep 2021 09:37:34 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9C3536916E;\n\tWed,  8 Sep 2021 11:37:33 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1E5716024D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  8 Sep 2021 11:37:32 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 9A3D3993;\n\tWed,  8 Sep 2021 11:37:31 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"rQbh4Iac\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1631093851;\n\tbh=4j783o0mt14o988zMp+inXOOopQ9Cd+zThj9qT/TiWA=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=rQbh4IacjjsEHGfGi4ckN6jloUcxK/MnIMGj0UI5Y3upd897JRkAPH+fUa7CxwZGZ\n\tBhyGHANGqhYXIG6VkGC9yQnk9WFgsVnpVBtpoehtZaUnpmOpincLweqASRCrSmc+j2\n\tl9UkzzE5HLOnE2S8m+iSAnauWeU/wi6F2lDnzKrg=","Date":"Wed, 8 Sep 2021 12:37:12 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Paul Elder <paul.elder@ideasonboard.com>","Message-ID":"<YTiESIte+/CVfFmo@pendragon.ideasonboard.com>","References":"<20210908081437.4022697-1-paul.elder@ideasonboard.com>\n\t<20210908081437.4022697-5-paul.elder@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20210908081437.4022697-5-paul.elder@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v2 4/7] libcamera: v4l2_pixelformat:\n\tAdd helper function to get the description","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]