[libcamera-devel,1/2] libcamera: Add support for planar YVU420 format

Message ID 20200718143428.1060441-2-niklas.soderlund@ragnatech.se
State Accepted
Commit 7855dc922f789a30930f777b062d630d38391ba0
Headers show
Series
  • libcamera: Add support for YVU420 and RGB565
Related show

Commit Message

Niklas Söderlund July 18, 2020, 2:34 p.m. UTC
Add support for planar YVU420.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
---
 src/libcamera/formats.cpp          | 10 ++++++++++
 src/libcamera/formats.yaml         |  2 ++
 src/libcamera/v4l2_pixelformat.cpp |  1 +
 3 files changed, 13 insertions(+)

Comments

Jacopo Mondi July 20, 2020, 8:05 a.m. UTC | #1
Hi Niklas,

On Sat, Jul 18, 2020 at 04:34:27PM +0200, Niklas Söderlund wrote:
> Add support for planar YVU420.
>
> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>

Looks good!
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>

Thanks
  j

> ---
>  src/libcamera/formats.cpp          | 10 ++++++++++
>  src/libcamera/formats.yaml         |  2 ++
>  src/libcamera/v4l2_pixelformat.cpp |  1 +
>  3 files changed, 13 insertions(+)
>
> diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp
> index 3f895a7c2badc34a..8f9bdafe821b2e69 100644
> --- a/src/libcamera/formats.cpp
> +++ b/src/libcamera/formats.cpp
> @@ -407,6 +407,16 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{
>  		.pixelsPerGroup = 2,
>  		.planes = {{ { 2, 1 }, { 1, 2 }, { 1, 2 } }},
>  	} },
> +	{ formats::YVU420, {
> +		.name = "YVU420",
> +		.format = PixelFormat(formats::YVU420),
> +		.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_YVU420),
> +		.bitsPerPixel = 12,
> +		.colourEncoding = PixelFormatInfo::ColourEncodingYUV,
> +		.packed = false,
> +		.pixelsPerGroup = 2,
> +		.planes = {{ { 2, 1 }, { 1, 2 }, { 1, 2 } }},
> +	} },
>  	{ formats::YUV422, {
>  		.name = "YUV422",
>  		.format = PixelFormat(formats::YUV422),
> diff --git a/src/libcamera/formats.yaml b/src/libcamera/formats.yaml
> index ce06dbc41aa13f5e..6b5f084bb2e4e970 100644
> --- a/src/libcamera/formats.yaml
> +++ b/src/libcamera/formats.yaml
> @@ -55,6 +55,8 @@ formats:
>
>    - YUV420:
>        fourcc: DRM_FORMAT_YUV420
> +  - YVU420:
> +      fourcc: DRM_FORMAT_YVU420
>    - YUV422:
>        fourcc: DRM_FORMAT_YUV422
>
> diff --git a/src/libcamera/v4l2_pixelformat.cpp b/src/libcamera/v4l2_pixelformat.cpp
> index 6745d17d49269bab..1609f8bb6370fa65 100644
> --- a/src/libcamera/v4l2_pixelformat.cpp
> +++ b/src/libcamera/v4l2_pixelformat.cpp
> @@ -64,6 +64,7 @@ const std::map<V4L2PixelFormat, PixelFormat> vpf2pf{
>  	{ V4L2PixelFormat(V4L2_PIX_FMT_NV12), formats::NV12 },
>  	{ V4L2PixelFormat(V4L2_PIX_FMT_NV21), formats::NV21 },
>  	{ V4L2PixelFormat(V4L2_PIX_FMT_YUV420), formats::YUV420 },
> +	{ V4L2PixelFormat(V4L2_PIX_FMT_YVU420), formats::YVU420},
>  	{ V4L2PixelFormat(V4L2_PIX_FMT_YUV422P), formats::YUV422 },
>
>  	/* Greyscale formats. */
> --
> 2.27.0
>
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
Kieran Bingham July 20, 2020, 10:53 p.m. UTC | #2
Hi Niklas,

On 20/07/2020 09:05, Jacopo Mondi wrote:
> Hi Niklas,
> 
> On Sat, Jul 18, 2020 at 04:34:27PM +0200, Niklas Söderlund wrote:
>> Add support for planar YVU420.
>>
>> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
> 
> Looks good!
> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>

Likewise,

But see below for a single space nit...


> 
> Thanks
>   j
> 
>> ---
>>  src/libcamera/formats.cpp          | 10 ++++++++++
>>  src/libcamera/formats.yaml         |  2 ++
>>  src/libcamera/v4l2_pixelformat.cpp |  1 +
>>  3 files changed, 13 insertions(+)
>>
>> diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp
>> index 3f895a7c2badc34a..8f9bdafe821b2e69 100644
>> --- a/src/libcamera/formats.cpp
>> +++ b/src/libcamera/formats.cpp
>> @@ -407,6 +407,16 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{
>>  		.pixelsPerGroup = 2,
>>  		.planes = {{ { 2, 1 }, { 1, 2 }, { 1, 2 } }},
>>  	} },
>> +	{ formats::YVU420, {
>> +		.name = "YVU420",
>> +		.format = PixelFormat(formats::YVU420),
>> +		.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_YVU420),
>> +		.bitsPerPixel = 12,
>> +		.colourEncoding = PixelFormatInfo::ColourEncodingYUV,
>> +		.packed = false,
>> +		.pixelsPerGroup = 2,
>> +		.planes = {{ { 2, 1 }, { 1, 2 }, { 1, 2 } }},
>> +	} },
>>  	{ formats::YUV422, {
>>  		.name = "YUV422",
>>  		.format = PixelFormat(formats::YUV422),
>> diff --git a/src/libcamera/formats.yaml b/src/libcamera/formats.yaml
>> index ce06dbc41aa13f5e..6b5f084bb2e4e970 100644
>> --- a/src/libcamera/formats.yaml
>> +++ b/src/libcamera/formats.yaml
>> @@ -55,6 +55,8 @@ formats:
>>
>>    - YUV420:
>>        fourcc: DRM_FORMAT_YUV420
>> +  - YVU420:
>> +      fourcc: DRM_FORMAT_YVU420
>>    - YUV422:
>>        fourcc: DRM_FORMAT_YUV422
>>
>> diff --git a/src/libcamera/v4l2_pixelformat.cpp b/src/libcamera/v4l2_pixelformat.cpp
>> index 6745d17d49269bab..1609f8bb6370fa65 100644
>> --- a/src/libcamera/v4l2_pixelformat.cpp
>> +++ b/src/libcamera/v4l2_pixelformat.cpp
>> @@ -64,6 +64,7 @@ const std::map<V4L2PixelFormat, PixelFormat> vpf2pf{
>>  	{ V4L2PixelFormat(V4L2_PIX_FMT_NV12), formats::NV12 },
>>  	{ V4L2PixelFormat(V4L2_PIX_FMT_NV21), formats::NV21 },
>>  	{ V4L2PixelFormat(V4L2_PIX_FMT_YUV420), formats::YUV420 },
>> +	{ V4L2PixelFormat(V4L2_PIX_FMT_YVU420), formats::YVU420},

Shouldn't there be a space after YVU420 to match the other lines?

With that fixed,

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

>>  	{ V4L2PixelFormat(V4L2_PIX_FMT_YUV422P), formats::YUV422 },
>>
>>  	/* Greyscale formats. */
>> --
>> 2.27.0
>>
>> _______________________________________________
>> libcamera-devel mailing list
>> libcamera-devel@lists.libcamera.org
>> https://lists.libcamera.org/listinfo/libcamera-devel
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
>

Patch

diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp
index 3f895a7c2badc34a..8f9bdafe821b2e69 100644
--- a/src/libcamera/formats.cpp
+++ b/src/libcamera/formats.cpp
@@ -407,6 +407,16 @@  const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{
 		.pixelsPerGroup = 2,
 		.planes = {{ { 2, 1 }, { 1, 2 }, { 1, 2 } }},
 	} },
+	{ formats::YVU420, {
+		.name = "YVU420",
+		.format = PixelFormat(formats::YVU420),
+		.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_YVU420),
+		.bitsPerPixel = 12,
+		.colourEncoding = PixelFormatInfo::ColourEncodingYUV,
+		.packed = false,
+		.pixelsPerGroup = 2,
+		.planes = {{ { 2, 1 }, { 1, 2 }, { 1, 2 } }},
+	} },
 	{ formats::YUV422, {
 		.name = "YUV422",
 		.format = PixelFormat(formats::YUV422),
diff --git a/src/libcamera/formats.yaml b/src/libcamera/formats.yaml
index ce06dbc41aa13f5e..6b5f084bb2e4e970 100644
--- a/src/libcamera/formats.yaml
+++ b/src/libcamera/formats.yaml
@@ -55,6 +55,8 @@  formats:
 
   - YUV420:
       fourcc: DRM_FORMAT_YUV420
+  - YVU420:
+      fourcc: DRM_FORMAT_YVU420
   - YUV422:
       fourcc: DRM_FORMAT_YUV422
 
diff --git a/src/libcamera/v4l2_pixelformat.cpp b/src/libcamera/v4l2_pixelformat.cpp
index 6745d17d49269bab..1609f8bb6370fa65 100644
--- a/src/libcamera/v4l2_pixelformat.cpp
+++ b/src/libcamera/v4l2_pixelformat.cpp
@@ -64,6 +64,7 @@  const std::map<V4L2PixelFormat, PixelFormat> vpf2pf{
 	{ V4L2PixelFormat(V4L2_PIX_FMT_NV12), formats::NV12 },
 	{ V4L2PixelFormat(V4L2_PIX_FMT_NV21), formats::NV21 },
 	{ V4L2PixelFormat(V4L2_PIX_FMT_YUV420), formats::YUV420 },
+	{ V4L2PixelFormat(V4L2_PIX_FMT_YVU420), formats::YVU420},
 	{ V4L2PixelFormat(V4L2_PIX_FMT_YUV422P), formats::YUV422 },
 
 	/* Greyscale formats. */