drivers/video: video driver supports NV12

Signed-off-by: yangsen5 <yangsen5@xiaomi.com>
This commit is contained in:
yangsen5 2023-08-01 16:34:58 +08:00 committed by Xiang Xiao
parent 775d9de30a
commit d8ca744052
4 changed files with 16 additions and 1 deletions

View File

@ -141,6 +141,10 @@ static uint32_t imgdata_fmt_to_v4l2(uint32_t pixelformat)
uint32_t fourcc;
switch (pixelformat)
{
case IMGDATA_PIX_FMT_NV12:
fourcc = V4L2_PIX_FMT_NV12;
break;
case IMGDATA_PIX_FMT_YUV420P:
fourcc = V4L2_PIX_FMT_YUV420;
break;

View File

@ -465,6 +465,10 @@ static void convert_to_imgdatafmt(FAR video_format_t *video,
data->height = video->height;
switch (video->pixelformat)
{
case V4L2_PIX_FMT_NV12:
data->pixelformat = IMGDATA_PIX_FMT_NV12;
break;
case V4L2_PIX_FMT_YUV420:
data->pixelformat = IMGDATA_PIX_FMT_YUV420P;
break;
@ -500,6 +504,10 @@ static void convert_to_imgsensorfmt(FAR video_format_t *video,
sensor->height = video->height;
switch (video->pixelformat)
{
case V4L2_PIX_FMT_NV12:
sensor->pixelformat = IMGSENSOR_PIX_FMT_NV12;
break;
case V4L2_PIX_FMT_YUV420:
sensor->pixelformat = IMGSENSOR_PIX_FMT_YUV420P;
break;
@ -1610,6 +1618,7 @@ static size_t get_bufsize(FAR video_format_t *vf)
size_t ret = vf->width * vf->height;
switch (vf->pixelformat)
{
case V4L2_PIX_FMT_NV12:
case V4L2_PIX_FMT_YUV420:
return ret * 3 / 2;
case V4L2_PIX_FMT_YUYV:
@ -1669,7 +1678,7 @@ static int video_try_fmt(FAR struct video_mng_s *priv,
v4l2->fmt.pix.pixelformat == V4L2_PIX_FMT_SUBIMG_UYVY ?
V4L2_PIX_FMT_UYVY : V4L2_PIX_FMT_RGB565;
break;
case V4L2_PIX_FMT_NV12:
case V4L2_PIX_FMT_YUV420:
case V4L2_PIX_FMT_YUYV:
case V4L2_PIX_FMT_UYVY:

View File

@ -45,6 +45,7 @@
#define IMGDATA_PIX_FMT_SUBIMG_RGB565 (5)
#define IMGDATA_PIX_FMT_YUYV (6)
#define IMGDATA_PIX_FMT_YUV420P (7)
#define IMGDATA_PIX_FMT_NV12 (8)
/* Method access helper macros */

View File

@ -121,6 +121,7 @@
#define IMGSENSOR_PIX_FMT_SUBIMG_RGB565 (5)
#define IMGSENSOR_PIX_FMT_YUYV (6)
#define IMGSENSOR_PIX_FMT_YUV420P (7)
#define IMGSENSOR_PIX_FMT_NV12 (8)
/* Method access helper macros */