[{"id":20605,"web_url":"https://patchwork.libcamera.org/comment/20605/","msgid":"<163542462183.2498920.3575668437690227570@Monstersaurus>","date":"2021-10-28T12:37:01","subject":"Re: [libcamera-devel] [PATCH v4 05/10] libcamera: bayer_format:\n\tRework BayerFormat conversion table","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Naushir Patuck (2021-10-28 09:46:41)\n> Rename the bayerToV4l2 conversion table to bayerToFormat. Update the table to\n> hold both the PixelFormat and V4L2PixelFormat conversions for a given\n> BayerFormat. This will allow converting between BayerFormat and PixelFormat\n> types in a subsequent change.\n> \n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> ---\n>  src/libcamera/bayer_format.cpp | 112 ++++++++++++++++++++++-----------\n>  1 file changed, 75 insertions(+), 37 deletions(-)\n> \n> diff --git a/src/libcamera/bayer_format.cpp b/src/libcamera/bayer_format.cpp\n> index 1c1e849a7e31..8665a025f7e0 100644\n> --- a/src/libcamera/bayer_format.cpp\n> +++ b/src/libcamera/bayer_format.cpp\n> @@ -13,6 +13,7 @@\n>  \n>  #include <linux/media-bus-format.h>\n>  \n> +#include <libcamera/formats.h>\n>  #include <libcamera/transform.h>\n>  \n>  /**\n> @@ -84,37 +85,74 @@ struct BayerFormatComparator {\n>         }\n>  };\n>  \n> -const std::map<BayerFormat, V4L2PixelFormat, BayerFormatComparator> bayerToV4l2{\n> -       { { BayerFormat::BGGR, 8, BayerFormat::Packing::None }, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR8) },\n> -       { { BayerFormat::GBRG, 8, BayerFormat::Packing::None }, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG8) },\n> -       { { BayerFormat::GRBG, 8, BayerFormat::Packing::None }, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG8) },\n> -       { { BayerFormat::RGGB, 8, BayerFormat::Packing::None }, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB8) },\n> -       { { BayerFormat::BGGR, 10, BayerFormat::Packing::None }, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR10) },\n> -       { { BayerFormat::GBRG, 10, BayerFormat::Packing::None }, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG10) },\n> -       { { BayerFormat::GRBG, 10, BayerFormat::Packing::None }, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG10) },\n> -       { { BayerFormat::RGGB, 10, BayerFormat::Packing::None }, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB10) },\n> -       { { BayerFormat::BGGR, 10, BayerFormat::Packing::CSI2 }, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR10P) },\n> -       { { BayerFormat::GBRG, 10, BayerFormat::Packing::CSI2 }, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG10P) },\n> -       { { BayerFormat::GRBG, 10, BayerFormat::Packing::CSI2 }, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG10P) },\n> -       { { BayerFormat::RGGB, 10, BayerFormat::Packing::CSI2 }, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB10P) },\n> -       { { BayerFormat::BGGR, 10, BayerFormat::Packing::IPU3 }, V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SBGGR10) },\n> -       { { BayerFormat::GBRG, 10, BayerFormat::Packing::IPU3 }, V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SGBRG10) },\n> -       { { BayerFormat::GRBG, 10, BayerFormat::Packing::IPU3 }, V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SGRBG10) },\n> -       { { BayerFormat::RGGB, 10, BayerFormat::Packing::IPU3 }, V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SRGGB10) },\n> -       { { BayerFormat::BGGR, 12, BayerFormat::Packing::None }, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR12) },\n> -       { { BayerFormat::GBRG, 12, BayerFormat::Packing::None }, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG12) },\n> -       { { BayerFormat::GRBG, 12, BayerFormat::Packing::None }, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG12) },\n> -       { { BayerFormat::RGGB, 12, BayerFormat::Packing::None }, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB12) },\n> -       { { BayerFormat::BGGR, 12, BayerFormat::Packing::CSI2 }, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR12P) },\n> -       { { BayerFormat::GBRG, 12, BayerFormat::Packing::CSI2 }, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG12P) },\n> -       { { BayerFormat::GRBG, 12, BayerFormat::Packing::CSI2 }, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG12P) },\n> -       { { BayerFormat::RGGB, 12, BayerFormat::Packing::CSI2 }, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB12P) },\n> -       { { BayerFormat::BGGR, 16, BayerFormat::Packing::None }, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR16) },\n> -       { { BayerFormat::GBRG, 16, BayerFormat::Packing::None }, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG16) },\n> -       { { BayerFormat::GRBG, 16, BayerFormat::Packing::None }, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG16) },\n> -       { { BayerFormat::RGGB, 16, BayerFormat::Packing::None }, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB16) },\n> -       { { BayerFormat::MONO, 8, BayerFormat::Packing::None }, V4L2PixelFormat(V4L2_PIX_FMT_GREY) },\n> -       { { BayerFormat::MONO, 10, BayerFormat::Packing::CSI2 }, V4L2PixelFormat(V4L2_PIX_FMT_Y10P) },\n> +struct Formats {\n> +       PixelFormat pixelFormat;\n> +       V4L2PixelFormat v4l2Format;\n> +};\n> +\n> +const std::map<BayerFormat, Formats, BayerFormatComparator> bayerToFormat{\n> +       { { BayerFormat::BGGR, 8, BayerFormat::Packing::None },\n> +               { formats::SBGGR8, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR8) } },\n> +       { { BayerFormat::GBRG, 8, BayerFormat::Packing::None },\n> +               { formats::SGBRG8, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG8) } },\n> +       { { BayerFormat::GRBG, 8, BayerFormat::Packing::None },\n> +               { formats::SGRBG8, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG8) } },\n> +       { { BayerFormat::RGGB, 8, BayerFormat::Packing::None },\n> +               { formats::SRGGB8, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB8) } },\n> +       { { BayerFormat::BGGR, 10, BayerFormat::Packing::None },\n> +               { formats::SBGGR10, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR10) } },\n> +       { { BayerFormat::GBRG, 10, BayerFormat::Packing::None },\n> +               { formats::SGBRG10, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG10) } },\n> +       { { BayerFormat::GRBG, 10, BayerFormat::Packing::None },\n> +               { formats::SGRBG10, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG10) } },\n> +       { { BayerFormat::RGGB, 10, BayerFormat::Packing::None },\n> +               { formats::SRGGB10, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB10) } },\n> +       { { BayerFormat::BGGR, 10, BayerFormat::Packing::CSI2 },\n> +               { formats::SBGGR10_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR10P) } },\n> +       { { BayerFormat::GBRG, 10, BayerFormat::Packing::CSI2 },\n> +               { formats::SGBRG10_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG10P) } },\n> +       { { BayerFormat::GRBG, 10, BayerFormat::Packing::CSI2 },\n> +               { formats::SGRBG10_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG10P) } },\n> +       { { BayerFormat::RGGB, 10, BayerFormat::Packing::CSI2 },\n> +               { formats::SRGGB10_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB10P) } },\n> +       { { BayerFormat::BGGR, 10, BayerFormat::Packing::IPU3 },\n> +               { formats::SBGGR10_IPU3, V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SBGGR10) } },\n> +       { { BayerFormat::GBRG, 10, BayerFormat::Packing::IPU3 },\n> +               { formats::SGBRG10_IPU3, V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SGBRG10) } },\n> +       { { BayerFormat::GRBG, 10, BayerFormat::Packing::IPU3 },\n> +               { formats::SGRBG10_IPU3, V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SGRBG10) } },\n> +       { { BayerFormat::RGGB, 10, BayerFormat::Packing::IPU3 },\n> +               { formats::SRGGB10_IPU3, V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SRGGB10) } },\n> +       { { BayerFormat::BGGR, 12, BayerFormat::Packing::None },\n> +               { formats::SBGGR12, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR12) } },\n> +       { { BayerFormat::GBRG, 12, BayerFormat::Packing::None },\n> +               { formats::SGBRG12, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG12) } },\n> +       { { BayerFormat::GRBG, 12, BayerFormat::Packing::None },\n> +               { formats::SGRBG12, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG12) } },\n> +       { { BayerFormat::RGGB, 12, BayerFormat::Packing::None },\n> +               { formats::SRGGB12, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB12) } },\n> +       { { BayerFormat::BGGR, 12, BayerFormat::Packing::CSI2 },\n> +               { formats::SBGGR12_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR12P) } },\n> +       { { BayerFormat::GBRG, 12, BayerFormat::Packing::CSI2 },\n> +               { formats::SGBRG12_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG12P) } },\n> +       { { BayerFormat::GRBG, 12, BayerFormat::Packing::CSI2 },\n> +               { formats::SGRBG12_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG12P) } },\n> +       { { BayerFormat::RGGB, 12, BayerFormat::Packing::CSI2 },\n> +               { formats::SRGGB12_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB12P) } },\n> +       { { BayerFormat::BGGR, 16, BayerFormat::Packing::None },\n> +               { formats::SBGGR16, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR16) } },\n> +       { { BayerFormat::GBRG, 16, BayerFormat::Packing::None },\n> +               { formats::SGBRG16, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG16) } },\n> +       { { BayerFormat::GRBG, 16, BayerFormat::Packing::None },\n> +               { formats::SGRBG16, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG16) } },\n> +       { { BayerFormat::RGGB, 16, BayerFormat::Packing::None },\n> +               { formats::SRGGB16, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB16) } },\n> +       { { BayerFormat::MONO, 8, BayerFormat::Packing::None },\n> +               { formats::R8, V4L2PixelFormat(V4L2_PIX_FMT_GREY) } },\n> +       { { BayerFormat::MONO, 10, BayerFormat::Packing::None },\n> +               { formats::R10, V4L2PixelFormat(V4L2_PIX_FMT_Y10) } },\n\nThis isn't in the original table, so this addition should be highlighted\nclearly.\n\nIdeally it would have been a patch on it's own to provide the addition,\neither before the conversion, or after. But as long as it's mentioned in\nthe commit message, I'm fine with it being here.\n\nWe could add:\n\n\"\"\"\nWhile updating the table, the unpacked V4L2_PIX_FMT_Y10 is mapped to the\nequivalent BayerFormat and formats::R10 accordingly.\n\"\"\"\n\nIf we get there in this series, that could be added while applying.\n\nSo with one of those solutions:\n\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> +       { { BayerFormat::MONO, 10, BayerFormat::Packing::CSI2 },\n> +               { formats::R10_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_Y10P) } },\n>  };\n>  \n>  const std::unordered_map<unsigned int, BayerFormat> mbusCodeToBayer{\n> @@ -245,9 +283,9 @@ bool operator==(const BayerFormat &lhs, const BayerFormat &rhs)\n>   */\n>  V4L2PixelFormat BayerFormat::toV4L2PixelFormat() const\n>  {\n> -       const auto it = bayerToV4l2.find(*this);\n> -       if (it != bayerToV4l2.end())\n> -               return it->second;\n> +       const auto it = bayerToFormat.find(*this);\n> +       if (it != bayerToFormat.end())\n> +               return it->second.v4l2Format;\n>  \n>         return V4L2PixelFormat();\n>  }\n> @@ -259,11 +297,11 @@ V4L2PixelFormat BayerFormat::toV4L2PixelFormat() const\n>   */\n>  BayerFormat BayerFormat::fromV4L2PixelFormat(V4L2PixelFormat v4l2Format)\n>  {\n> -       auto it = std::find_if(bayerToV4l2.begin(), bayerToV4l2.end(),\n> +       auto it = std::find_if(bayerToFormat.begin(), bayerToFormat.end(),\n>                                [v4l2Format](const auto &i) {\n> -                                      return i.second == v4l2Format;\n> +                                      return i.second.v4l2Format == v4l2Format;\n>                                });\n> -       if (it != bayerToV4l2.end())\n> +       if (it != bayerToFormat.end())\n>                 return it->first;\n>  \n>         return BayerFormat();\n> -- \n> 2.25.1\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 C9C5EBDB1C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 28 Oct 2021 12:37:05 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 48664600BA;\n\tThu, 28 Oct 2021 14:37:05 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 99A91600B5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 28 Oct 2021 14:37:04 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 39AA1513;\n\tThu, 28 Oct 2021 14:37:04 +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=\"mQQtM0lP\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1635424624;\n\tbh=NKCiYWmjZwWRTvLq6FhGZ9r0VPr8Wc8rjbdcuav6HIQ=;\n\th=In-Reply-To:References:Subject:From:To:Date:From;\n\tb=mQQtM0lPV92wPOkaIHKyDwlssMuvrnXuknqojQFqgPieegDXrmWxw9eRvj4AZosKG\n\tJUh6kqKbevqr61TIMwoz6BAQRw/1cOwobt8t6FtJn00/B5mvBzNERMd6vyRKk8NPG0\n\ttUrUEGmpTmZjfSWTmxwilceubYoM/B3o81y5QQKI=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20211028084646.453775-6-naush@raspberrypi.com>","References":"<20211028084646.453775-1-naush@raspberrypi.com>\n\t<20211028084646.453775-6-naush@raspberrypi.com>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"Naushir Patuck <naush@raspberrypi.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Thu, 28 Oct 2021 13:37:01 +0100","Message-ID":"<163542462183.2498920.3575668437690227570@Monstersaurus>","User-Agent":"alot/0.9.1","Subject":"Re: [libcamera-devel] [PATCH v4 05/10] libcamera: bayer_format:\n\tRework BayerFormat conversion table","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>"}},{"id":20606,"web_url":"https://patchwork.libcamera.org/comment/20606/","msgid":"<CAEmqJPrrkSiqwacek9a1jtw5wS5SYWVLv8O9fb1jnD5KVSsmsg@mail.gmail.com>","date":"2021-10-28T12:40:38","subject":"Re: [libcamera-devel] [PATCH v4 05/10] libcamera: bayer_format:\n\tRework BayerFormat conversion table","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"content":"Hi Kieran,\n\nThank you for your feedback.\n\nOn Thu, 28 Oct 2021 at 13:37, Kieran Bingham <\nkieran.bingham@ideasonboard.com> wrote:\n\n> Quoting Naushir Patuck (2021-10-28 09:46:41)\n> > Rename the bayerToV4l2 conversion table to bayerToFormat. Update the\n> table to\n> > hold both the PixelFormat and V4L2PixelFormat conversions for a given\n> > BayerFormat. This will allow converting between BayerFormat and\n> PixelFormat\n> > types in a subsequent change.\n> >\n> > Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> > ---\n> >  src/libcamera/bayer_format.cpp | 112 ++++++++++++++++++++++-----------\n> >  1 file changed, 75 insertions(+), 37 deletions(-)\n> >\n> > diff --git a/src/libcamera/bayer_format.cpp\n> b/src/libcamera/bayer_format.cpp\n> > index 1c1e849a7e31..8665a025f7e0 100644\n> > --- a/src/libcamera/bayer_format.cpp\n> > +++ b/src/libcamera/bayer_format.cpp\n> > @@ -13,6 +13,7 @@\n> >\n> >  #include <linux/media-bus-format.h>\n> >\n> > +#include <libcamera/formats.h>\n> >  #include <libcamera/transform.h>\n> >\n> >  /**\n> > @@ -84,37 +85,74 @@ struct BayerFormatComparator {\n> >         }\n> >  };\n> >\n> > -const std::map<BayerFormat, V4L2PixelFormat, BayerFormatComparator>\n> bayerToV4l2{\n> > -       { { BayerFormat::BGGR, 8, BayerFormat::Packing::None },\n> V4L2PixelFormat(V4L2_PIX_FMT_SBGGR8) },\n> > -       { { BayerFormat::GBRG, 8, BayerFormat::Packing::None },\n> V4L2PixelFormat(V4L2_PIX_FMT_SGBRG8) },\n> > -       { { BayerFormat::GRBG, 8, BayerFormat::Packing::None },\n> V4L2PixelFormat(V4L2_PIX_FMT_SGRBG8) },\n> > -       { { BayerFormat::RGGB, 8, BayerFormat::Packing::None },\n> V4L2PixelFormat(V4L2_PIX_FMT_SRGGB8) },\n> > -       { { BayerFormat::BGGR, 10, BayerFormat::Packing::None },\n> V4L2PixelFormat(V4L2_PIX_FMT_SBGGR10) },\n> > -       { { BayerFormat::GBRG, 10, BayerFormat::Packing::None },\n> V4L2PixelFormat(V4L2_PIX_FMT_SGBRG10) },\n> > -       { { BayerFormat::GRBG, 10, BayerFormat::Packing::None },\n> V4L2PixelFormat(V4L2_PIX_FMT_SGRBG10) },\n> > -       { { BayerFormat::RGGB, 10, BayerFormat::Packing::None },\n> V4L2PixelFormat(V4L2_PIX_FMT_SRGGB10) },\n> > -       { { BayerFormat::BGGR, 10, BayerFormat::Packing::CSI2 },\n> V4L2PixelFormat(V4L2_PIX_FMT_SBGGR10P) },\n> > -       { { BayerFormat::GBRG, 10, BayerFormat::Packing::CSI2 },\n> V4L2PixelFormat(V4L2_PIX_FMT_SGBRG10P) },\n> > -       { { BayerFormat::GRBG, 10, BayerFormat::Packing::CSI2 },\n> V4L2PixelFormat(V4L2_PIX_FMT_SGRBG10P) },\n> > -       { { BayerFormat::RGGB, 10, BayerFormat::Packing::CSI2 },\n> V4L2PixelFormat(V4L2_PIX_FMT_SRGGB10P) },\n> > -       { { BayerFormat::BGGR, 10, BayerFormat::Packing::IPU3 },\n> V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SBGGR10) },\n> > -       { { BayerFormat::GBRG, 10, BayerFormat::Packing::IPU3 },\n> V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SGBRG10) },\n> > -       { { BayerFormat::GRBG, 10, BayerFormat::Packing::IPU3 },\n> V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SGRBG10) },\n> > -       { { BayerFormat::RGGB, 10, BayerFormat::Packing::IPU3 },\n> V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SRGGB10) },\n> > -       { { BayerFormat::BGGR, 12, BayerFormat::Packing::None },\n> V4L2PixelFormat(V4L2_PIX_FMT_SBGGR12) },\n> > -       { { BayerFormat::GBRG, 12, BayerFormat::Packing::None },\n> V4L2PixelFormat(V4L2_PIX_FMT_SGBRG12) },\n> > -       { { BayerFormat::GRBG, 12, BayerFormat::Packing::None },\n> V4L2PixelFormat(V4L2_PIX_FMT_SGRBG12) },\n> > -       { { BayerFormat::RGGB, 12, BayerFormat::Packing::None },\n> V4L2PixelFormat(V4L2_PIX_FMT_SRGGB12) },\n> > -       { { BayerFormat::BGGR, 12, BayerFormat::Packing::CSI2 },\n> V4L2PixelFormat(V4L2_PIX_FMT_SBGGR12P) },\n> > -       { { BayerFormat::GBRG, 12, BayerFormat::Packing::CSI2 },\n> V4L2PixelFormat(V4L2_PIX_FMT_SGBRG12P) },\n> > -       { { BayerFormat::GRBG, 12, BayerFormat::Packing::CSI2 },\n> V4L2PixelFormat(V4L2_PIX_FMT_SGRBG12P) },\n> > -       { { BayerFormat::RGGB, 12, BayerFormat::Packing::CSI2 },\n> V4L2PixelFormat(V4L2_PIX_FMT_SRGGB12P) },\n> > -       { { BayerFormat::BGGR, 16, BayerFormat::Packing::None },\n> V4L2PixelFormat(V4L2_PIX_FMT_SBGGR16) },\n> > -       { { BayerFormat::GBRG, 16, BayerFormat::Packing::None },\n> V4L2PixelFormat(V4L2_PIX_FMT_SGBRG16) },\n> > -       { { BayerFormat::GRBG, 16, BayerFormat::Packing::None },\n> V4L2PixelFormat(V4L2_PIX_FMT_SGRBG16) },\n> > -       { { BayerFormat::RGGB, 16, BayerFormat::Packing::None },\n> V4L2PixelFormat(V4L2_PIX_FMT_SRGGB16) },\n> > -       { { BayerFormat::MONO, 8, BayerFormat::Packing::None },\n> V4L2PixelFormat(V4L2_PIX_FMT_GREY) },\n> > -       { { BayerFormat::MONO, 10, BayerFormat::Packing::CSI2 },\n> V4L2PixelFormat(V4L2_PIX_FMT_Y10P) },\n> > +struct Formats {\n> > +       PixelFormat pixelFormat;\n> > +       V4L2PixelFormat v4l2Format;\n> > +};\n> > +\n> > +const std::map<BayerFormat, Formats, BayerFormatComparator>\n> bayerToFormat{\n> > +       { { BayerFormat::BGGR, 8, BayerFormat::Packing::None },\n> > +               { formats::SBGGR8, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR8)\n> } },\n> > +       { { BayerFormat::GBRG, 8, BayerFormat::Packing::None },\n> > +               { formats::SGBRG8, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG8)\n> } },\n> > +       { { BayerFormat::GRBG, 8, BayerFormat::Packing::None },\n> > +               { formats::SGRBG8, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG8)\n> } },\n> > +       { { BayerFormat::RGGB, 8, BayerFormat::Packing::None },\n> > +               { formats::SRGGB8, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB8)\n> } },\n> > +       { { BayerFormat::BGGR, 10, BayerFormat::Packing::None },\n> > +               { formats::SBGGR10,\n> V4L2PixelFormat(V4L2_PIX_FMT_SBGGR10) } },\n> > +       { { BayerFormat::GBRG, 10, BayerFormat::Packing::None },\n> > +               { formats::SGBRG10,\n> V4L2PixelFormat(V4L2_PIX_FMT_SGBRG10) } },\n> > +       { { BayerFormat::GRBG, 10, BayerFormat::Packing::None },\n> > +               { formats::SGRBG10,\n> V4L2PixelFormat(V4L2_PIX_FMT_SGRBG10) } },\n> > +       { { BayerFormat::RGGB, 10, BayerFormat::Packing::None },\n> > +               { formats::SRGGB10,\n> V4L2PixelFormat(V4L2_PIX_FMT_SRGGB10) } },\n> > +       { { BayerFormat::BGGR, 10, BayerFormat::Packing::CSI2 },\n> > +               { formats::SBGGR10_CSI2P,\n> V4L2PixelFormat(V4L2_PIX_FMT_SBGGR10P) } },\n> > +       { { BayerFormat::GBRG, 10, BayerFormat::Packing::CSI2 },\n> > +               { formats::SGBRG10_CSI2P,\n> V4L2PixelFormat(V4L2_PIX_FMT_SGBRG10P) } },\n> > +       { { BayerFormat::GRBG, 10, BayerFormat::Packing::CSI2 },\n> > +               { formats::SGRBG10_CSI2P,\n> V4L2PixelFormat(V4L2_PIX_FMT_SGRBG10P) } },\n> > +       { { BayerFormat::RGGB, 10, BayerFormat::Packing::CSI2 },\n> > +               { formats::SRGGB10_CSI2P,\n> V4L2PixelFormat(V4L2_PIX_FMT_SRGGB10P) } },\n> > +       { { BayerFormat::BGGR, 10, BayerFormat::Packing::IPU3 },\n> > +               { formats::SBGGR10_IPU3,\n> V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SBGGR10) } },\n> > +       { { BayerFormat::GBRG, 10, BayerFormat::Packing::IPU3 },\n> > +               { formats::SGBRG10_IPU3,\n> V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SGBRG10) } },\n> > +       { { BayerFormat::GRBG, 10, BayerFormat::Packing::IPU3 },\n> > +               { formats::SGRBG10_IPU3,\n> V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SGRBG10) } },\n> > +       { { BayerFormat::RGGB, 10, BayerFormat::Packing::IPU3 },\n> > +               { formats::SRGGB10_IPU3,\n> V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SRGGB10) } },\n> > +       { { BayerFormat::BGGR, 12, BayerFormat::Packing::None },\n> > +               { formats::SBGGR12,\n> V4L2PixelFormat(V4L2_PIX_FMT_SBGGR12) } },\n> > +       { { BayerFormat::GBRG, 12, BayerFormat::Packing::None },\n> > +               { formats::SGBRG12,\n> V4L2PixelFormat(V4L2_PIX_FMT_SGBRG12) } },\n> > +       { { BayerFormat::GRBG, 12, BayerFormat::Packing::None },\n> > +               { formats::SGRBG12,\n> V4L2PixelFormat(V4L2_PIX_FMT_SGRBG12) } },\n> > +       { { BayerFormat::RGGB, 12, BayerFormat::Packing::None },\n> > +               { formats::SRGGB12,\n> V4L2PixelFormat(V4L2_PIX_FMT_SRGGB12) } },\n> > +       { { BayerFormat::BGGR, 12, BayerFormat::Packing::CSI2 },\n> > +               { formats::SBGGR12_CSI2P,\n> V4L2PixelFormat(V4L2_PIX_FMT_SBGGR12P) } },\n> > +       { { BayerFormat::GBRG, 12, BayerFormat::Packing::CSI2 },\n> > +               { formats::SGBRG12_CSI2P,\n> V4L2PixelFormat(V4L2_PIX_FMT_SGBRG12P) } },\n> > +       { { BayerFormat::GRBG, 12, BayerFormat::Packing::CSI2 },\n> > +               { formats::SGRBG12_CSI2P,\n> V4L2PixelFormat(V4L2_PIX_FMT_SGRBG12P) } },\n> > +       { { BayerFormat::RGGB, 12, BayerFormat::Packing::CSI2 },\n> > +               { formats::SRGGB12_CSI2P,\n> V4L2PixelFormat(V4L2_PIX_FMT_SRGGB12P) } },\n> > +       { { BayerFormat::BGGR, 16, BayerFormat::Packing::None },\n> > +               { formats::SBGGR16,\n> V4L2PixelFormat(V4L2_PIX_FMT_SBGGR16) } },\n> > +       { { BayerFormat::GBRG, 16, BayerFormat::Packing::None },\n> > +               { formats::SGBRG16,\n> V4L2PixelFormat(V4L2_PIX_FMT_SGBRG16) } },\n> > +       { { BayerFormat::GRBG, 16, BayerFormat::Packing::None },\n> > +               { formats::SGRBG16,\n> V4L2PixelFormat(V4L2_PIX_FMT_SGRBG16) } },\n> > +       { { BayerFormat::RGGB, 16, BayerFormat::Packing::None },\n> > +               { formats::SRGGB16,\n> V4L2PixelFormat(V4L2_PIX_FMT_SRGGB16) } },\n> > +       { { BayerFormat::MONO, 8, BayerFormat::Packing::None },\n> > +               { formats::R8, V4L2PixelFormat(V4L2_PIX_FMT_GREY) } },\n> > +       { { BayerFormat::MONO, 10, BayerFormat::Packing::None },\n> > +               { formats::R10, V4L2PixelFormat(V4L2_PIX_FMT_Y10) } },\n>\n> This isn't in the original table, so this addition should be highlighted\n> clearly.\n>\n> Ideally it would have been a patch on it's own to provide the addition,\n> either before the conversion, or after. But as long as it's mentioned in\n> the commit message, I'm fine with it being here.\n>\n> We could add:\n>\n> \"\"\"\n> While updating the table, the unpacked V4L2_PIX_FMT_Y10 is mapped to the\n> equivalent BayerFormat and formats::R10 accordingly.\n> \"\"\"\n>\n> If we get there in this series, that could be added while applying.\n>\n> So with one of those solutions:\n>\n\nI'll split this into 2 changes to be clearer.\n\nRegards,\nNaush\n\n\n>\n>\n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n>\n> > +       { { BayerFormat::MONO, 10, BayerFormat::Packing::CSI2 },\n> > +               { formats::R10_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_Y10P)\n> } },\n> >  };\n> >\n> >  const std::unordered_map<unsigned int, BayerFormat> mbusCodeToBayer{\n> > @@ -245,9 +283,9 @@ bool operator==(const BayerFormat &lhs, const\n> BayerFormat &rhs)\n> >   */\n> >  V4L2PixelFormat BayerFormat::toV4L2PixelFormat() const\n> >  {\n> > -       const auto it = bayerToV4l2.find(*this);\n> > -       if (it != bayerToV4l2.end())\n> > -               return it->second;\n> > +       const auto it = bayerToFormat.find(*this);\n> > +       if (it != bayerToFormat.end())\n> > +               return it->second.v4l2Format;\n> >\n> >         return V4L2PixelFormat();\n> >  }\n> > @@ -259,11 +297,11 @@ V4L2PixelFormat BayerFormat::toV4L2PixelFormat()\n> const\n> >   */\n> >  BayerFormat BayerFormat::fromV4L2PixelFormat(V4L2PixelFormat v4l2Format)\n> >  {\n> > -       auto it = std::find_if(bayerToV4l2.begin(), bayerToV4l2.end(),\n> > +       auto it = std::find_if(bayerToFormat.begin(),\n> bayerToFormat.end(),\n> >                                [v4l2Format](const auto &i) {\n> > -                                      return i.second == v4l2Format;\n> > +                                      return i.second.v4l2Format ==\n> v4l2Format;\n> >                                });\n> > -       if (it != bayerToV4l2.end())\n> > +       if (it != bayerToFormat.end())\n> >                 return it->first;\n> >\n> >         return BayerFormat();\n> > --\n> > 2.25.1\n> >\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 88C24BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 28 Oct 2021 12:40:57 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id EEA6C600B7;\n\tThu, 28 Oct 2021 14:40:56 +0200 (CEST)","from mail-lf1-x132.google.com (mail-lf1-x132.google.com\n\t[IPv6:2a00:1450:4864:20::132])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5A53C600B5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 28 Oct 2021 14:40:55 +0200 (CEST)","by mail-lf1-x132.google.com with SMTP id b32so10086553lfv.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 28 Oct 2021 05:40:55 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"R29Y1muN\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=r11x8QxPAmH0Ou6x8u2nZgNpODOqTrdkGkz0QAHiYx8=;\n\tb=R29Y1muNw+e4mCkWxwgBXTbpq7UOfgwMFIcQ+R5nC1gAWB17UlZeulZ4I+zpA0iuCI\n\tdWd6ZNTbQUkIs+XqBMnraExoTCrM/j1JjbWLm7WHCnBtoIIVmHsbhN47/LwIzqCecQVb\n\tJaw+UIyLuIquhkpT+FXkzBDhjobBOawSKFRgHf4qDFZtioPIrPXXr1DvSjQCH/E5IFfX\n\tfRwTG4WbqAVVzUHE2IF9FKKPeyAluAYwcHHu800vS5Vys9U7t5ar/v2OYUGAG/zyycS1\n\tDwoTgk9ULhxk276L90WdBz4sgjPB2v9deGAqMaGLVnDB1r6r5MaJgroNdwMlHP7U18/h\n\tMQGA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=r11x8QxPAmH0Ou6x8u2nZgNpODOqTrdkGkz0QAHiYx8=;\n\tb=HLbljCHzoWuh6taPX+NyrxKU2kjz58nWanh7UVdsVPthJXPjfpLeeaxvwSa5uLP5f0\n\tc1DlrPh31RXT7OwTuxY9PALCXm9O13ijiF8D7PHGDB6IUVctA5dncfVpncx6o7v0/83f\n\tQ1Agm9qKmGlQQmUjVpal8Ug4DGOS+vcFNrEAda+OFykqn1OsRwhwee7WdOIZ8MFHBYTE\n\tWEGgqI8+x9SAHgrnQjQZi8WG8tQmy+Rddho8WlpDbRQX79wNYUBpjAhAM0ln+Qo91dil\n\tuILRGEBumYpldC1HYttb9LCi4zWEINz66ZrpddOaHrtmZMDH8u+HvTWk8AkDUIaTyr88\n\tEL6w==","X-Gm-Message-State":"AOAM533XrBfOX2DOoRkaL3yZxyGqUwvLyemJ602WymaMxIUhWrKkUKCH\n\tn7G2eyzUyLE73PpTw1GakPQANRZRkk4tVgcPrNSlug==","X-Google-Smtp-Source":"ABdhPJzxhB1cXLqn6XgoL7HDp+bAmDV+5t8s5KqsompNGkmJCMAks6GH/hb+adzM66NflzSMhUZUbObWfWOzYZGjYi0=","X-Received":"by 2002:a05:6512:2118:: with SMTP id\n\tq24mr3842047lfr.315.1635424854459; \n\tThu, 28 Oct 2021 05:40:54 -0700 (PDT)","MIME-Version":"1.0","References":"<20211028084646.453775-1-naush@raspberrypi.com>\n\t<20211028084646.453775-6-naush@raspberrypi.com>\n\t<163542462183.2498920.3575668437690227570@Monstersaurus>","In-Reply-To":"<163542462183.2498920.3575668437690227570@Monstersaurus>","From":"Naushir Patuck <naush@raspberrypi.com>","Date":"Thu, 28 Oct 2021 13:40:38 +0100","Message-ID":"<CAEmqJPrrkSiqwacek9a1jtw5wS5SYWVLv8O9fb1jnD5KVSsmsg@mail.gmail.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Content-Type":"multipart/alternative; boundary=\"00000000000081d8d705cf69052e\"","Subject":"Re: [libcamera-devel] [PATCH v4 05/10] libcamera: bayer_format:\n\tRework BayerFormat conversion table","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 <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]