[{"id":19569,"web_url":"https://patchwork.libcamera.org/comment/19569/","msgid":"<c2e59d3a-1c7c-5ce9-5d59-2cef7025fe6b@ideasonboard.com>","date":"2021-09-09T08:34:38","subject":"Re: [libcamera-devel] [PATCH v3 4/7] libcamera: v4l2_pixelformat:\n\tAdd helper function to get the description","submitter":{"id":75,"url":"https://patchwork.libcamera.org/api/people/75/","name":"Jean-Michel Hautbois","email":"jeanmichel.hautbois@ideasonboard.com"},"content":"Hi Paul,\n\nOn 09/09/2021 10:08, 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> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n>  include/libcamera/internal/v4l2_pixelformat.h |  1 +\n>  src/libcamera/v4l2_pixelformat.cpp            | 21 +++++++++++++++++++\n>  2 files changed, 22 insertions(+)\n> \n> diff --git a/include/libcamera/internal/v4l2_pixelformat.h b/include/libcamera/internal/v4l2_pixelformat.h\n> index 87872542..e3cda699 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 *description() 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 2c8167a7..fed31238 100644\n> --- a/src/libcamera/v4l2_pixelformat.cpp\n> +++ b/src/libcamera/v4l2_pixelformat.cpp\n> @@ -250,6 +250,27 @@ std::string V4L2PixelFormat::toString() const\n>  \treturn ss;\n>  }\n>  \n> +/**\n> + * \\brief Retrieve the V4L2 description for the format\n> + *\n> + * The description matches the value used by the kernel, as would be reported\n> + * by the VIDIOC_ENUM_FMT ioctl.\n> + *\n> + * \\return The V4L2 description corresponding to the V4L2 format\nOr an error message if not found ?\n\nReviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n> + */\n> +const char *V4L2PixelFormat::description() const\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 \"Unsupported format\";\n> +\t}\n> +\n> +\treturn iter->second.description;\n> +}\n> +\n>  /**\n>   * \\brief Convert the V4L2 pixel format to the corresponding PixelFormat\n>   * \\return The PixelFormat corresponding to the V4L2 pixel format\n>","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 A8AC0BDB1D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  9 Sep 2021 08:34:42 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 78AA16916E;\n\tThu,  9 Sep 2021 10:34:42 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2E1DF6024E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  9 Sep 2021 10:34:41 +0200 (CEST)","from tatooine.ideasonboard.com (unknown\n\t[IPv6:2a01:e0a:169:7140:ab35:be36:579e:39cf])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id E371D466;\n\tThu,  9 Sep 2021 10:34:40 +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=\"HZiQgDn3\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1631176480;\n\tbh=mgw2LerCmm9UfFTInz8t5fCJZe0jrwAHfmYriFaJqZ0=;\n\th=Subject:To:References:From:Date:In-Reply-To:From;\n\tb=HZiQgDn39oPbTH4TTakjQYOJXI0Gr68MupIGLfb/Sc3NXET8PqCwmBw3GHxfCczRQ\n\tk+rLt0XbKEhnTMnLwzMK9P35nZ9efk2TgR3L5M3LCFD/J9KN2OGSYZjw1dspnvbzrP\n\tDrpLhg3fDPgzMp2S18kQnKPp/q8aaoYgt+G1PNiM=","To":"Paul Elder <paul.elder@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20210909080902.239533-1-paul.elder@ideasonboard.com>\n\t<20210909080902.239533-5-paul.elder@ideasonboard.com>","From":"Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>","Message-ID":"<c2e59d3a-1c7c-5ce9-5d59-2cef7025fe6b@ideasonboard.com>","Date":"Thu, 9 Sep 2021 10:34:38 +0200","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101\n\tThunderbird/78.13.0","MIME-Version":"1.0","In-Reply-To":"<20210909080902.239533-5-paul.elder@ideasonboard.com>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-US","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [PATCH v3 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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]