Commit dde72bd7 authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

[media] vivid: add support for NV24 and NV42

Add support for the YUV 4:4:4 formats NV24 and NV42.
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent 8f1ff543
...@@ -123,7 +123,7 @@ int tpg_alloc(struct tpg_data *tpg, unsigned max_w) ...@@ -123,7 +123,7 @@ int tpg_alloc(struct tpg_data *tpg, unsigned max_w)
tpg->max_line_width = max_w; tpg->max_line_width = max_w;
for (pat = 0; pat < TPG_MAX_PAT_LINES; pat++) { for (pat = 0; pat < TPG_MAX_PAT_LINES; pat++) {
for (plane = 0; plane < TPG_MAX_PLANES; plane++) { for (plane = 0; plane < TPG_MAX_PLANES; plane++) {
unsigned pixelsz = plane ? 1 : 4; unsigned pixelsz = plane ? 2 : 4;
tpg->lines[pat][plane] = vzalloc(max_w * 2 * pixelsz); tpg->lines[pat][plane] = vzalloc(max_w * 2 * pixelsz);
if (!tpg->lines[pat][plane]) if (!tpg->lines[pat][plane])
...@@ -136,7 +136,7 @@ int tpg_alloc(struct tpg_data *tpg, unsigned max_w) ...@@ -136,7 +136,7 @@ int tpg_alloc(struct tpg_data *tpg, unsigned max_w)
} }
} }
for (plane = 0; plane < TPG_MAX_PLANES; plane++) { for (plane = 0; plane < TPG_MAX_PLANES; plane++) {
unsigned pixelsz = plane ? 1 : 4; unsigned pixelsz = plane ? 2 : 4;
tpg->contrast_line[plane] = vzalloc(max_w * pixelsz); tpg->contrast_line[plane] = vzalloc(max_w * pixelsz);
if (!tpg->contrast_line[plane]) if (!tpg->contrast_line[plane])
...@@ -255,6 +255,13 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc) ...@@ -255,6 +255,13 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc)
tpg->planes = 2; tpg->planes = 2;
tpg->is_yuv = true; tpg->is_yuv = true;
break; break;
case V4L2_PIX_FMT_NV24:
case V4L2_PIX_FMT_NV42:
tpg->vdownsampling[1] = 1;
tpg->hdownsampling[1] = 1;
tpg->planes = 2;
tpg->is_yuv = true;
break;
case V4L2_PIX_FMT_YUYV: case V4L2_PIX_FMT_YUYV:
case V4L2_PIX_FMT_UYVY: case V4L2_PIX_FMT_UYVY:
case V4L2_PIX_FMT_YVYU: case V4L2_PIX_FMT_YVYU:
...@@ -322,6 +329,11 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc) ...@@ -322,6 +329,11 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc)
tpg->twopixelsize[1] = 2; tpg->twopixelsize[1] = 2;
tpg->twopixelsize[2] = 2; tpg->twopixelsize[2] = 2;
break; break;
case V4L2_PIX_FMT_NV24:
case V4L2_PIX_FMT_NV42:
tpg->twopixelsize[0] = 2;
tpg->twopixelsize[1] = 4;
break;
} }
return true; return true;
} }
...@@ -826,6 +838,18 @@ static void gen_twopix(struct tpg_data *tpg, ...@@ -826,6 +838,18 @@ static void gen_twopix(struct tpg_data *tpg,
buf[1][1] = g_u; buf[1][1] = g_u;
break; break;
case V4L2_PIX_FMT_NV24:
buf[0][offset] = r_y;
buf[1][2 * offset] = g_u;
buf[1][2 * offset + 1] = b_v;
break;
case V4L2_PIX_FMT_NV42:
buf[0][offset] = r_y;
buf[1][2 * offset] = b_v;
buf[1][2 * offset + 1] = g_u;
break;
case V4L2_PIX_FMT_YUYV: case V4L2_PIX_FMT_YUYV:
buf[0][offset] = r_y; buf[0][offset] = r_y;
if (odd) { if (odd) {
......
...@@ -143,6 +143,24 @@ struct vivid_fmt vivid_formats[] = { ...@@ -143,6 +143,24 @@ struct vivid_fmt vivid_formats[] = {
.planes = 2, .planes = 2,
.buffers = 1, .buffers = 1,
}, },
{
.name = "YUV 4:4:4 biplanar",
.fourcc = V4L2_PIX_FMT_NV24,
.vdownsampling = { 1, 1 },
.bit_depth = { 8, 16 },
.is_yuv = true,
.planes = 2,
.buffers = 1,
},
{
.name = "YVU 4:4:4 biplanar",
.fourcc = V4L2_PIX_FMT_NV42,
.vdownsampling = { 1, 1 },
.bit_depth = { 8, 16 },
.is_yuv = true,
.planes = 2,
.buffers = 1,
},
{ {
.name = "Monochrome", .name = "Monochrome",
.fourcc = V4L2_PIX_FMT_GREY, .fourcc = V4L2_PIX_FMT_GREY,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment