[libcamera-devel] libcamera: imx8-isi: Enumerate supported stream formats
diff mbox series

Message ID 20221118164035.23740-1-jacopo@jmondi.org
State Accepted
Commit f8e998a4c19e66b6a9ba5dc864ac6f6556c87937
Headers show
Series
  • [libcamera-devel] libcamera: imx8-isi: Enumerate supported stream formats
Related show

Commit Message

Jacopo Mondi Nov. 18, 2022, 4:40 p.m. UTC
Add to the formats map all the supported ISI video capture
stream formats.

This allows to populate the list of stream formats for all the non-RAW
use cases, as the ISI can perform colorspace conversion between YUV and
RGB.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
---
 src/libcamera/pipeline/imx8-isi/imx8-isi.cpp | 62 +++++++++++++++++++-
 1 file changed, 59 insertions(+), 3 deletions(-)

Comments

Laurent Pinchart Nov. 19, 2022, 12:32 a.m. UTC | #1
Hi Jacopo,

Thank you for the patch.

On Fri, Nov 18, 2022 at 05:40:35PM +0100, Jacopo Mondi via libcamera-devel wrote:
> Add to the formats map all the supported ISI video capture
> stream formats.
> 
> This allows to populate the list of stream formats for all the non-RAW
> use cases, as the ISI can perform colorspace conversion between YUV and
> RGB.
> 
> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  src/libcamera/pipeline/imx8-isi/imx8-isi.cpp | 62 +++++++++++++++++++-
>  1 file changed, 59 insertions(+), 3 deletions(-)
> 
> diff --git a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp
> index 14d699b7a42b..a3dfd3fc529c 100644
> --- a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp
> +++ b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp
> @@ -188,11 +188,51 @@ const ISICameraConfiguration::FormatMap ISICameraConfiguration::formatsMap_ = {
>  		{ MEDIA_BUS_FMT_YUV8_1X24,
>  		  MEDIA_BUS_FMT_UYVY8_1X16 },
>  	},
> +	{
> +		formats::AVUY8888,
> +		{ MEDIA_BUS_FMT_YUV8_1X24,
> +		  MEDIA_BUS_FMT_UYVY8_1X16 },
> +	},
> +	{
> +		formats::NV12,
> +		{ MEDIA_BUS_FMT_YUV8_1X24,
> +		  MEDIA_BUS_FMT_UYVY8_1X16 },
> +	},
> +	{
> +		formats::NV16,
> +		{ MEDIA_BUS_FMT_YUV8_1X24,
> +		  MEDIA_BUS_FMT_UYVY8_1X16 },
> +	},
> +	{
> +		formats::YUV444,
> +		{ MEDIA_BUS_FMT_YUV8_1X24,
> +		  MEDIA_BUS_FMT_UYVY8_1X16 },
> +	},
>  	{
>  		formats::RGB565,
>  		{ MEDIA_BUS_FMT_RGB888_1X24,
>  		  MEDIA_BUS_FMT_RGB565_1X16 },
>  	},
> +	{
> +		formats::BGR888,
> +		{ MEDIA_BUS_FMT_RGB888_1X24,
> +		  MEDIA_BUS_FMT_RGB565_1X16 },
> +	},
> +	{
> +		formats::RGB888,
> +		{ MEDIA_BUS_FMT_RGB888_1X24,
> +		  MEDIA_BUS_FMT_RGB565_1X16 },
> +	},
> +	{
> +		formats::XRGB8888,
> +		{ MEDIA_BUS_FMT_RGB888_1X24,
> +		  MEDIA_BUS_FMT_RGB565_1X16 },
> +	},
> +	{
> +		formats::ABGR8888,
> +		{ MEDIA_BUS_FMT_RGB888_1X24,
> +		  MEDIA_BUS_FMT_RGB565_1X16 },
> +	},
>  	{
>  		formats::SBGGR8,
>  		{ MEDIA_BUS_FMT_SBGGR8_1X8,
> @@ -546,6 +586,7 @@ PipelineHandlerISI::generateConfiguration(Camera *camera,
>  		return nullptr;
>  	}
>  
> +	bool isRaw = false;
>  	for (const auto &role : roles) {
>  		/*
>  		 * Prefer the following formats
> @@ -553,6 +594,7 @@ PipelineHandlerISI::generateConfiguration(Camera *camera,
>  		 * - ViewFinder/VideoRecording: 1080p YUYV
>  		 * - RAW: sensor's native format and resolution
>  		 */
> +		std::map<PixelFormat, std::vector<SizeRange>> streamFormats;
>  		PixelFormat pixelFormat;
>  		Size size;
>  
> @@ -614,6 +656,9 @@ PipelineHandlerISI::generateConfiguration(Camera *camera,
>  			size = data->sensor_->resolution();
>  			pixelFormat = rawPipeFormat->first;
>  
> +			streamFormats[pixelFormat] = { { kMinISISize, size } };
> +			isRaw = true;
> +
>  			break;
>  		}
>  
> @@ -622,9 +667,20 @@ PipelineHandlerISI::generateConfiguration(Camera *camera,
>  			return nullptr;
>  		}
>  
> -		/* \todo Add all supported formats. */
> -		std::map<PixelFormat, std::vector<SizeRange>> streamFormats;
> -		streamFormats[pixelFormat] = { { kMinISISize, size } };
> +		/*
> +		 * For non-RAW configurations the ISI can perform colorspace
> +		 * conversion. List all the supported output formats here.
> +		 */
> +		if (!isRaw) {
> +			for (const auto &[pixFmt, pipeFmt] : ISICameraConfiguration::formatsMap_) {
> +				const PixelFormatInfo &info = PixelFormatInfo::info(pixFmt);
> +				if (info.colourEncoding == PixelFormatInfo::ColourEncodingRAW)
> +					continue;
> +
> +				streamFormats[pixFmt] = { { kMinISISize, size } };
> +			}
> +		}
> +
>  		StreamFormats formats(streamFormats);
>  
>  		StreamConfiguration cfg(formats);

Patch
diff mbox series

diff --git a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp
index 14d699b7a42b..a3dfd3fc529c 100644
--- a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp
+++ b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp
@@ -188,11 +188,51 @@  const ISICameraConfiguration::FormatMap ISICameraConfiguration::formatsMap_ = {
 		{ MEDIA_BUS_FMT_YUV8_1X24,
 		  MEDIA_BUS_FMT_UYVY8_1X16 },
 	},
+	{
+		formats::AVUY8888,
+		{ MEDIA_BUS_FMT_YUV8_1X24,
+		  MEDIA_BUS_FMT_UYVY8_1X16 },
+	},
+	{
+		formats::NV12,
+		{ MEDIA_BUS_FMT_YUV8_1X24,
+		  MEDIA_BUS_FMT_UYVY8_1X16 },
+	},
+	{
+		formats::NV16,
+		{ MEDIA_BUS_FMT_YUV8_1X24,
+		  MEDIA_BUS_FMT_UYVY8_1X16 },
+	},
+	{
+		formats::YUV444,
+		{ MEDIA_BUS_FMT_YUV8_1X24,
+		  MEDIA_BUS_FMT_UYVY8_1X16 },
+	},
 	{
 		formats::RGB565,
 		{ MEDIA_BUS_FMT_RGB888_1X24,
 		  MEDIA_BUS_FMT_RGB565_1X16 },
 	},
+	{
+		formats::BGR888,
+		{ MEDIA_BUS_FMT_RGB888_1X24,
+		  MEDIA_BUS_FMT_RGB565_1X16 },
+	},
+	{
+		formats::RGB888,
+		{ MEDIA_BUS_FMT_RGB888_1X24,
+		  MEDIA_BUS_FMT_RGB565_1X16 },
+	},
+	{
+		formats::XRGB8888,
+		{ MEDIA_BUS_FMT_RGB888_1X24,
+		  MEDIA_BUS_FMT_RGB565_1X16 },
+	},
+	{
+		formats::ABGR8888,
+		{ MEDIA_BUS_FMT_RGB888_1X24,
+		  MEDIA_BUS_FMT_RGB565_1X16 },
+	},
 	{
 		formats::SBGGR8,
 		{ MEDIA_BUS_FMT_SBGGR8_1X8,
@@ -546,6 +586,7 @@  PipelineHandlerISI::generateConfiguration(Camera *camera,
 		return nullptr;
 	}
 
+	bool isRaw = false;
 	for (const auto &role : roles) {
 		/*
 		 * Prefer the following formats
@@ -553,6 +594,7 @@  PipelineHandlerISI::generateConfiguration(Camera *camera,
 		 * - ViewFinder/VideoRecording: 1080p YUYV
 		 * - RAW: sensor's native format and resolution
 		 */
+		std::map<PixelFormat, std::vector<SizeRange>> streamFormats;
 		PixelFormat pixelFormat;
 		Size size;
 
@@ -614,6 +656,9 @@  PipelineHandlerISI::generateConfiguration(Camera *camera,
 			size = data->sensor_->resolution();
 			pixelFormat = rawPipeFormat->first;
 
+			streamFormats[pixelFormat] = { { kMinISISize, size } };
+			isRaw = true;
+
 			break;
 		}
 
@@ -622,9 +667,20 @@  PipelineHandlerISI::generateConfiguration(Camera *camera,
 			return nullptr;
 		}
 
-		/* \todo Add all supported formats. */
-		std::map<PixelFormat, std::vector<SizeRange>> streamFormats;
-		streamFormats[pixelFormat] = { { kMinISISize, size } };
+		/*
+		 * For non-RAW configurations the ISI can perform colorspace
+		 * conversion. List all the supported output formats here.
+		 */
+		if (!isRaw) {
+			for (const auto &[pixFmt, pipeFmt] : ISICameraConfiguration::formatsMap_) {
+				const PixelFormatInfo &info = PixelFormatInfo::info(pixFmt);
+				if (info.colourEncoding == PixelFormatInfo::ColourEncodingRAW)
+					continue;
+
+				streamFormats[pixFmt] = { { kMinISISize, size } };
+			}
+		}
+
 		StreamFormats formats(streamFormats);
 
 		StreamConfiguration cfg(formats);