[v6,09/14] libcamera: bayer_format: Add 20-bit bayer formats
diff mbox series

Message ID 20241115101334.453104-10-dan.scally@ideasonboard.com
State New
Headers show
Series
  • Miscellaneous Mali-C55 Pipeline Fixes
Related show

Commit Message

Dan Scally Nov. 15, 2024, 10:13 a.m. UTC
Add support for the 20-bit bayer formats to libcamera's BayerFormat class.

Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>
---
Changes in v6:

	- New patch

 src/libcamera/bayer_format.cpp | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Kieran Bingham Nov. 15, 2024, 12:24 p.m. UTC | #1
Quoting Daniel Scally (2024-11-15 10:13:29)
> Add support for the 20-bit bayer formats to libcamera's BayerFormat class.
> 
> Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>
> ---
> Changes in v6:
> 
>         - New patch
> 
>  src/libcamera/bayer_format.cpp | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/src/libcamera/bayer_format.cpp b/src/libcamera/bayer_format.cpp
> index c2120d1c..3dab91fc 100644
> --- a/src/libcamera/bayer_format.cpp
> +++ b/src/libcamera/bayer_format.cpp
> @@ -225,6 +225,10 @@ const std::unordered_map<unsigned int, BayerFormat> mbusCodeToBayer{
>         { MEDIA_BUS_FMT_SGBRG16_1X16, { BayerFormat::GBRG, 16, BayerFormat::Packing::None } },
>         { MEDIA_BUS_FMT_SGRBG16_1X16, { BayerFormat::GRBG, 16, BayerFormat::Packing::None } },
>         { MEDIA_BUS_FMT_SRGGB16_1X16, { BayerFormat::RGGB, 16, BayerFormat::Packing::None } },
> +       { MEDIA_BUS_FMT_SBGGR20_1X20, { BayerFormat::BGGR, 20, BayerFormat::Packing::None } },
> +       { MEDIA_BUS_FMT_SGBRG20_1X20, { BayerFormat::GBRG, 20, BayerFormat::Packing::None } },
> +       { MEDIA_BUS_FMT_SGRBG20_1X20, { BayerFormat::GRBG, 20, BayerFormat::Packing::None } },
> +       { MEDIA_BUS_FMT_SRGGB20_1X20, { BayerFormat::RGGB, 20, BayerFormat::Packing::None } },

These entries are so annoyingly duplicated... (not /your/ fault).

I wonder if we should/could macro this out with the preprocessor to :

#define MBUS_BAYER_FORMAT_CODE(code, bits) \
	{ MEDIA_BUS_FMT_S#code#bits_1X#bits, { BayerFormat::GRBG, #bits, BayerFormat::Packing::None },


#define MBUS_BAYER_FORMAT(bits) \
	MBUS_BAYER_FORMAT_CODE(BGGR, bits) \
        MBUS_BAYER_FORMAT_CODE(GBRG, bits) \
        MBUS_BAYER_FORMAT_CODE(GRBG, bits) \
        MBUS_BAYER_FORMAT_CODE(RGGB, bits)


(That string join at MEDIA_BUS_FMT_S#code#bits_1X#bits, would probably
be tricky)


and then this table would have
	{
		...
		MBUS_BAYER_FORMAT(8),
		MBUS_BAYER_FORMAT(10),
		MBUS_BAYER_FORMAT(12),
		MBUS_BAYER_FORMAT(16),
		...
	}

	(names/parameters could always be changed)

The packed formats could be mapped with more specific helpers too to
produce the table perhaps...

Maybe it's overkill - but maybe it would help maintain the table and
make it more readable for the 'whole' table content/intent...

But ... that's a yak ... so if you don't think that's interesting - I
think this patch is still valid:



Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>



>         { MEDIA_BUS_FMT_Y8_1X8, { BayerFormat::MONO, 8, BayerFormat::Packing::None } },
>         { MEDIA_BUS_FMT_Y10_1X10, { BayerFormat::MONO, 10, BayerFormat::Packing::None } },
>         { MEDIA_BUS_FMT_Y12_1X12, { BayerFormat::MONO, 12, BayerFormat::Packing::None } },
> -- 
> 2.30.2
>

Patch
diff mbox series

diff --git a/src/libcamera/bayer_format.cpp b/src/libcamera/bayer_format.cpp
index c2120d1c..3dab91fc 100644
--- a/src/libcamera/bayer_format.cpp
+++ b/src/libcamera/bayer_format.cpp
@@ -225,6 +225,10 @@  const std::unordered_map<unsigned int, BayerFormat> mbusCodeToBayer{
 	{ MEDIA_BUS_FMT_SGBRG16_1X16, { BayerFormat::GBRG, 16, BayerFormat::Packing::None } },
 	{ MEDIA_BUS_FMT_SGRBG16_1X16, { BayerFormat::GRBG, 16, BayerFormat::Packing::None } },
 	{ MEDIA_BUS_FMT_SRGGB16_1X16, { BayerFormat::RGGB, 16, BayerFormat::Packing::None } },
+	{ MEDIA_BUS_FMT_SBGGR20_1X20, { BayerFormat::BGGR, 20, BayerFormat::Packing::None } },
+	{ MEDIA_BUS_FMT_SGBRG20_1X20, { BayerFormat::GBRG, 20, BayerFormat::Packing::None } },
+	{ MEDIA_BUS_FMT_SGRBG20_1X20, { BayerFormat::GRBG, 20, BayerFormat::Packing::None } },
+	{ MEDIA_BUS_FMT_SRGGB20_1X20, { BayerFormat::RGGB, 20, BayerFormat::Packing::None } },
 	{ MEDIA_BUS_FMT_Y8_1X8, { BayerFormat::MONO, 8, BayerFormat::Packing::None } },
 	{ MEDIA_BUS_FMT_Y10_1X10, { BayerFormat::MONO, 10, BayerFormat::Packing::None } },
 	{ MEDIA_BUS_FMT_Y12_1X12, { BayerFormat::MONO, 12, BayerFormat::Packing::None } },