drivers/video: add support for yuv420p

Add calc functions for buffer size (yuv420p is 6Byte/4px)

Signed-off-by: Peter Bee <bijunda1@xiaomi.com>
This commit is contained in:
Peter Bee 2022-11-24 23:54:32 +08:00 committed by Xiang Xiao
parent 365b1f4bb8
commit 87e16c3694
4 changed files with 15 additions and 0 deletions

View File

@ -500,6 +500,10 @@ static void convert_to_imgdatafmt(FAR video_format_t *video,
data->height = video->height;
switch (video->pixelformat)
{
case V4L2_PIX_FMT_YUV420:
data->pixelformat = IMGDATA_PIX_FMT_YUV420P;
break;
case V4L2_PIX_FMT_YUYV:
data->pixelformat = IMGDATA_PIX_FMT_YUYV;
break;
@ -531,6 +535,10 @@ static void convert_to_imgsensorfmt(FAR video_format_t *video,
sensor->height = video->height;
switch (video->pixelformat)
{
case V4L2_PIX_FMT_YUV420:
sensor->pixelformat = IMGSENSOR_PIX_FMT_YUV420P;
break;
case V4L2_PIX_FMT_YUYV:
sensor->pixelformat = IMGSENSOR_PIX_FMT_YUYV;
break;
@ -1516,6 +1524,7 @@ static int video_try_fmt(FAR struct video_mng_s *priv,
break;
case V4L2_PIX_FMT_YUV420:
case V4L2_PIX_FMT_YUYV:
case V4L2_PIX_FMT_UYVY:
case V4L2_PIX_FMT_RGB565:

View File

@ -43,6 +43,7 @@
#define IMGDATA_PIX_FMT_SUBIMG_UYVY (4)
#define IMGDATA_PIX_FMT_SUBIMG_RGB565 (5)
#define IMGDATA_PIX_FMT_YUYV (6)
#define IMGDATA_PIX_FMT_YUV420P (7)
/****************************************************************************
* Public Types

View File

@ -118,6 +118,7 @@
#define IMGSENSOR_PIX_FMT_SUBIMG_UYVY (4)
#define IMGSENSOR_PIX_FMT_SUBIMG_RGB565 (5)
#define IMGSENSOR_PIX_FMT_YUYV (6)
#define IMGSENSOR_PIX_FMT_YUV420P (7)
/****************************************************************************
* Public Types

View File

@ -219,6 +219,10 @@ extern "C"
#define V4L2_PIX_FMT_UYVY v4l2_fourcc('U', 'Y', 'V', 'Y')
#define V4L2_PIX_FMT_YUYV v4l2_fourcc('Y', 'U', 'Y', 'V')
/* YUV 4:2:0 */
#define V4L2_PIX_FMT_YUV420 v4l2_fourcc('Y', 'U', '1', '2')
/* RGB565 */
#define V4L2_PIX_FMT_RGB565 v4l2_fourcc('R', 'G', 'B', 'P')