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

[media] vivid: add new format fields

These fields are necessary to handle the new planar formats.
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent ecb9e91b
...@@ -79,12 +79,14 @@ extern unsigned vivid_debug; ...@@ -79,12 +79,14 @@ extern unsigned vivid_debug;
struct vivid_fmt { struct vivid_fmt {
const char *name; const char *name;
u32 fourcc; /* v4l2 format id */ u32 fourcc; /* v4l2 format id */
u8 depth;
bool is_yuv; bool is_yuv;
bool can_do_overlay; bool can_do_overlay;
u8 vdownsampling[TPG_MAX_PLANES];
u32 alpha_mask; u32 alpha_mask;
u8 planes; u8 planes;
u8 buffers;
u32 data_offset[TPG_MAX_PLANES]; u32 data_offset[TPG_MAX_PLANES];
u32 bit_depth[TPG_MAX_PLANES];
}; };
extern struct vivid_fmt vivid_formats[]; extern struct vivid_fmt vivid_formats[];
......
...@@ -42,20 +42,26 @@ static const struct vivid_fmt formats_ovl[] = { ...@@ -42,20 +42,26 @@ static const struct vivid_fmt formats_ovl[] = {
{ {
.name = "RGB565 (LE)", .name = "RGB565 (LE)",
.fourcc = V4L2_PIX_FMT_RGB565, /* gggbbbbb rrrrrggg */ .fourcc = V4L2_PIX_FMT_RGB565, /* gggbbbbb rrrrrggg */
.depth = 16, .vdownsampling = { 1 },
.bit_depth = { 16 },
.planes = 1, .planes = 1,
.buffers = 1,
}, },
{ {
.name = "XRGB555 (LE)", .name = "XRGB555 (LE)",
.fourcc = V4L2_PIX_FMT_XRGB555, /* gggbbbbb arrrrrgg */ .fourcc = V4L2_PIX_FMT_XRGB555, /* gggbbbbb arrrrrgg */
.depth = 16, .vdownsampling = { 1 },
.bit_depth = { 16 },
.planes = 1, .planes = 1,
.buffers = 1,
}, },
{ {
.name = "ARGB555 (LE)", .name = "ARGB555 (LE)",
.fourcc = V4L2_PIX_FMT_ARGB555, /* gggbbbbb arrrrrgg */ .fourcc = V4L2_PIX_FMT_ARGB555, /* gggbbbbb arrrrrgg */
.depth = 16, .vdownsampling = { 1 },
.bit_depth = { 16 },
.planes = 1, .planes = 1,
.buffers = 1,
}, },
}; };
...@@ -597,9 +603,9 @@ int vivid_try_fmt_vid_cap(struct file *file, void *priv, ...@@ -597,9 +603,9 @@ int vivid_try_fmt_vid_cap(struct file *file, void *priv,
/* This driver supports custom bytesperline values */ /* This driver supports custom bytesperline values */
/* Calculate the minimum supported bytesperline value */ /* Calculate the minimum supported bytesperline value */
bytesperline = (mp->width * fmt->depth) >> 3; bytesperline = (mp->width * fmt->bit_depth[0]) >> 3;
/* Calculate the maximum supported bytesperline value */ /* Calculate the maximum supported bytesperline value */
max_bpl = (MAX_ZOOM * MAX_WIDTH * fmt->depth) >> 3; max_bpl = (MAX_ZOOM * MAX_WIDTH * fmt->bit_depth[0]) >> 3;
mp->num_planes = fmt->planes; mp->num_planes = fmt->planes;
for (p = 0; p < mp->num_planes; p++) { for (p = 0; p < mp->num_planes; p++) {
if (pfmt[p].bytesperline > max_bpl) if (pfmt[p].bytesperline > max_bpl)
...@@ -1224,7 +1230,7 @@ int vivid_vid_cap_s_fbuf(struct file *file, void *fh, ...@@ -1224,7 +1230,7 @@ int vivid_vid_cap_s_fbuf(struct file *file, void *fh,
fmt = vivid_get_format(dev, a->fmt.pixelformat); fmt = vivid_get_format(dev, a->fmt.pixelformat);
if (!fmt || !fmt->can_do_overlay) if (!fmt || !fmt->can_do_overlay)
return -EINVAL; return -EINVAL;
if (a->fmt.bytesperline < (a->fmt.width * fmt->depth) / 8) if (a->fmt.bytesperline < (a->fmt.width * fmt->bit_depth[0]) / 8)
return -EINVAL; return -EINVAL;
if (a->fmt.height * a->fmt.bytesperline < a->fmt.sizeimage) if (a->fmt.height * a->fmt.bytesperline < a->fmt.sizeimage)
return -EINVAL; return -EINVAL;
......
...@@ -46,139 +46,179 @@ struct vivid_fmt vivid_formats[] = { ...@@ -46,139 +46,179 @@ struct vivid_fmt vivid_formats[] = {
{ {
.name = "4:2:2, packed, YUYV", .name = "4:2:2, packed, YUYV",
.fourcc = V4L2_PIX_FMT_YUYV, .fourcc = V4L2_PIX_FMT_YUYV,
.depth = 16, .vdownsampling = { 1 },
.bit_depth = { 16 },
.is_yuv = true, .is_yuv = true,
.planes = 1, .planes = 1,
.buffers = 1,
.data_offset = { PLANE0_DATA_OFFSET, 0 }, .data_offset = { PLANE0_DATA_OFFSET, 0 },
}, },
{ {
.name = "4:2:2, packed, UYVY", .name = "4:2:2, packed, UYVY",
.fourcc = V4L2_PIX_FMT_UYVY, .fourcc = V4L2_PIX_FMT_UYVY,
.depth = 16, .vdownsampling = { 1 },
.bit_depth = { 16 },
.is_yuv = true, .is_yuv = true,
.planes = 1, .planes = 1,
.buffers = 1,
}, },
{ {
.name = "4:2:2, packed, YVYU", .name = "4:2:2, packed, YVYU",
.fourcc = V4L2_PIX_FMT_YVYU, .fourcc = V4L2_PIX_FMT_YVYU,
.depth = 16, .vdownsampling = { 1 },
.bit_depth = { 16 },
.is_yuv = true, .is_yuv = true,
.planes = 1, .planes = 1,
.buffers = 1,
}, },
{ {
.name = "4:2:2, packed, VYUY", .name = "4:2:2, packed, VYUY",
.fourcc = V4L2_PIX_FMT_VYUY, .fourcc = V4L2_PIX_FMT_VYUY,
.depth = 16, .vdownsampling = { 1 },
.bit_depth = { 16 },
.is_yuv = true, .is_yuv = true,
.planes = 1, .planes = 1,
.buffers = 1,
}, },
{ {
.name = "RGB565 (LE)", .name = "RGB565 (LE)",
.fourcc = V4L2_PIX_FMT_RGB565, /* gggbbbbb rrrrrggg */ .fourcc = V4L2_PIX_FMT_RGB565, /* gggbbbbb rrrrrggg */
.depth = 16, .vdownsampling = { 1 },
.bit_depth = { 16 },
.planes = 1, .planes = 1,
.buffers = 1,
.can_do_overlay = true, .can_do_overlay = true,
}, },
{ {
.name = "RGB565 (BE)", .name = "RGB565 (BE)",
.fourcc = V4L2_PIX_FMT_RGB565X, /* rrrrrggg gggbbbbb */ .fourcc = V4L2_PIX_FMT_RGB565X, /* rrrrrggg gggbbbbb */
.depth = 16, .vdownsampling = { 1 },
.bit_depth = { 16 },
.planes = 1, .planes = 1,
.buffers = 1,
.can_do_overlay = true, .can_do_overlay = true,
}, },
{ {
.name = "RGB555 (LE)", .name = "RGB555 (LE)",
.fourcc = V4L2_PIX_FMT_RGB555, /* gggbbbbb arrrrrgg */ .fourcc = V4L2_PIX_FMT_RGB555, /* gggbbbbb arrrrrgg */
.depth = 16, .vdownsampling = { 1 },
.bit_depth = { 16 },
.planes = 1, .planes = 1,
.buffers = 1,
.can_do_overlay = true, .can_do_overlay = true,
}, },
{ {
.name = "XRGB555 (LE)", .name = "XRGB555 (LE)",
.fourcc = V4L2_PIX_FMT_XRGB555, /* gggbbbbb arrrrrgg */ .fourcc = V4L2_PIX_FMT_XRGB555, /* gggbbbbb arrrrrgg */
.depth = 16, .vdownsampling = { 1 },
.bit_depth = { 16 },
.planes = 1, .planes = 1,
.buffers = 1,
.can_do_overlay = true, .can_do_overlay = true,
}, },
{ {
.name = "ARGB555 (LE)", .name = "ARGB555 (LE)",
.fourcc = V4L2_PIX_FMT_ARGB555, /* gggbbbbb arrrrrgg */ .fourcc = V4L2_PIX_FMT_ARGB555, /* gggbbbbb arrrrrgg */
.depth = 16, .vdownsampling = { 1 },
.bit_depth = { 16 },
.planes = 1, .planes = 1,
.buffers = 1,
.can_do_overlay = true, .can_do_overlay = true,
.alpha_mask = 0x8000, .alpha_mask = 0x8000,
}, },
{ {
.name = "RGB555 (BE)", .name = "RGB555 (BE)",
.fourcc = V4L2_PIX_FMT_RGB555X, /* arrrrrgg gggbbbbb */ .fourcc = V4L2_PIX_FMT_RGB555X, /* arrrrrgg gggbbbbb */
.depth = 16, .vdownsampling = { 1 },
.bit_depth = { 16 },
.planes = 1, .planes = 1,
.buffers = 1,
.can_do_overlay = true, .can_do_overlay = true,
}, },
{ {
.name = "RGB24 (LE)", .name = "RGB24 (LE)",
.fourcc = V4L2_PIX_FMT_RGB24, /* rgb */ .fourcc = V4L2_PIX_FMT_RGB24, /* rgb */
.depth = 24, .vdownsampling = { 1 },
.bit_depth = { 24 },
.planes = 1, .planes = 1,
.buffers = 1,
}, },
{ {
.name = "RGB24 (BE)", .name = "RGB24 (BE)",
.fourcc = V4L2_PIX_FMT_BGR24, /* bgr */ .fourcc = V4L2_PIX_FMT_BGR24, /* bgr */
.depth = 24, .vdownsampling = { 1 },
.bit_depth = { 24 },
.planes = 1, .planes = 1,
.buffers = 1,
}, },
{ {
.name = "RGB32 (LE)", .name = "RGB32 (LE)",
.fourcc = V4L2_PIX_FMT_RGB32, /* argb */ .fourcc = V4L2_PIX_FMT_RGB32, /* argb */
.depth = 32, .vdownsampling = { 1 },
.bit_depth = { 32 },
.planes = 1, .planes = 1,
.buffers = 1,
}, },
{ {
.name = "RGB32 (BE)", .name = "RGB32 (BE)",
.fourcc = V4L2_PIX_FMT_BGR32, /* bgra */ .fourcc = V4L2_PIX_FMT_BGR32, /* bgra */
.depth = 32, .vdownsampling = { 1 },
.bit_depth = { 32 },
.planes = 1, .planes = 1,
.buffers = 1,
}, },
{ {
.name = "XRGB32 (LE)", .name = "XRGB32 (LE)",
.fourcc = V4L2_PIX_FMT_XRGB32, /* argb */ .fourcc = V4L2_PIX_FMT_XRGB32, /* argb */
.depth = 32, .vdownsampling = { 1 },
.bit_depth = { 32 },
.planes = 1, .planes = 1,
.buffers = 1,
}, },
{ {
.name = "XRGB32 (BE)", .name = "XRGB32 (BE)",
.fourcc = V4L2_PIX_FMT_XBGR32, /* bgra */ .fourcc = V4L2_PIX_FMT_XBGR32, /* bgra */
.depth = 32, .vdownsampling = { 1 },
.bit_depth = { 32 },
.planes = 1, .planes = 1,
.buffers = 1,
}, },
{ {
.name = "ARGB32 (LE)", .name = "ARGB32 (LE)",
.fourcc = V4L2_PIX_FMT_ARGB32, /* argb */ .fourcc = V4L2_PIX_FMT_ARGB32, /* argb */
.depth = 32, .vdownsampling = { 1 },
.bit_depth = { 32 },
.planes = 1, .planes = 1,
.buffers = 1,
.alpha_mask = 0x000000ff, .alpha_mask = 0x000000ff,
}, },
{ {
.name = "ARGB32 (BE)", .name = "ARGB32 (BE)",
.fourcc = V4L2_PIX_FMT_ABGR32, /* bgra */ .fourcc = V4L2_PIX_FMT_ABGR32, /* bgra */
.depth = 32, .vdownsampling = { 1 },
.bit_depth = { 32 },
.planes = 1, .planes = 1,
.buffers = 1,
.alpha_mask = 0xff000000, .alpha_mask = 0xff000000,
}, },
{ {
.name = "4:2:2, planar, YUV", .name = "4:2:2, biplanar, YUV",
.fourcc = V4L2_PIX_FMT_NV16M, .fourcc = V4L2_PIX_FMT_NV16M,
.depth = 8, .vdownsampling = { 1, 1 },
.bit_depth = { 8, 8 },
.is_yuv = true, .is_yuv = true,
.planes = 2, .planes = 2,
.buffers = 2,
.data_offset = { PLANE0_DATA_OFFSET, 0 }, .data_offset = { PLANE0_DATA_OFFSET, 0 },
}, },
{ {
.name = "4:2:2, planar, YVU", .name = "4:2:2, biplanar, YVU",
.fourcc = V4L2_PIX_FMT_NV61M, .fourcc = V4L2_PIX_FMT_NV61M,
.depth = 8, .vdownsampling = { 1, 1 },
.bit_depth = { 8, 8 },
.is_yuv = true, .is_yuv = true,
.planes = 2, .planes = 2,
.buffers = 2,
.data_offset = { 0, PLANE0_DATA_OFFSET }, .data_offset = { 0, PLANE0_DATA_OFFSET },
}, },
}; };
......
...@@ -269,9 +269,9 @@ void vivid_update_format_out(struct vivid_dev *dev) ...@@ -269,9 +269,9 @@ void vivid_update_format_out(struct vivid_dev *dev)
if (V4L2_FIELD_HAS_T_OR_B(dev->field_out)) if (V4L2_FIELD_HAS_T_OR_B(dev->field_out))
dev->crop_out.height /= 2; dev->crop_out.height /= 2;
dev->fmt_out_rect = dev->crop_out; dev->fmt_out_rect = dev->crop_out;
dev->bytesperline_out[0] = (dev->sink_rect.width * dev->fmt_out->depth) / 8; dev->bytesperline_out[0] = (dev->sink_rect.width * dev->fmt_out->bit_depth[0]) / 8;
if (dev->fmt_out->planes == 2) if (dev->fmt_out->planes == 2)
dev->bytesperline_out[1] = (dev->sink_rect.width * dev->fmt_out->depth) / 8; dev->bytesperline_out[1] = (dev->sink_rect.width * dev->fmt_out->bit_depth[0]) / 8;
} }
/* Map the field to something that is valid for the current output */ /* Map the field to something that is valid for the current output */
...@@ -388,9 +388,9 @@ int vivid_try_fmt_vid_out(struct file *file, void *priv, ...@@ -388,9 +388,9 @@ int vivid_try_fmt_vid_out(struct file *file, void *priv,
/* This driver supports custom bytesperline values */ /* This driver supports custom bytesperline values */
/* Calculate the minimum supported bytesperline value */ /* Calculate the minimum supported bytesperline value */
bytesperline = (mp->width * fmt->depth) >> 3; bytesperline = (mp->width * fmt->bit_depth[0]) >> 3;
/* Calculate the maximum supported bytesperline value */ /* Calculate the maximum supported bytesperline value */
max_bpl = (MAX_ZOOM * MAX_WIDTH * fmt->depth) >> 3; max_bpl = (MAX_ZOOM * MAX_WIDTH * fmt->bit_depth[0]) >> 3;
mp->num_planes = fmt->planes; mp->num_planes = fmt->planes;
for (p = 0; p < mp->num_planes; p++) { for (p = 0; p < mp->num_planes; p++) {
if (pfmt[p].bytesperline > max_bpl) if (pfmt[p].bytesperline > max_bpl)
......
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