Commit 22e244b8 authored by Philipp Zabel's avatar Philipp Zabel Committed by Mauro Carvalho Chehab

[media] coda: split format enumeration for encoder end decoder device

Let the decoder capture side and encoder output side only list
uncompressed formats, and the decoder output and encoder capture
side only list compressed formats.
Acked-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarPhilipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: default avatarKamil Debski <k.debski@samsung.com>
Signed-off-by: default avatarMauro Carvalho Chehab <m.chehab@samsung.com>
parent 121cacf4
...@@ -542,8 +542,8 @@ static int coda_querycap(struct file *file, void *priv, ...@@ -542,8 +542,8 @@ static int coda_querycap(struct file *file, void *priv,
return 0; return 0;
} }
static int enum_fmt(void *priv, struct v4l2_fmtdesc *f, static int coda_enum_fmt(struct file *file, void *priv,
enum v4l2_buf_type type, int src_fourcc) struct v4l2_fmtdesc *f)
{ {
struct coda_ctx *ctx = fh_to_ctx(priv); struct coda_ctx *ctx = fh_to_ctx(priv);
struct coda_codec *codecs = ctx->dev->devtype->codecs; struct coda_codec *codecs = ctx->dev->devtype->codecs;
...@@ -552,11 +552,19 @@ static int enum_fmt(void *priv, struct v4l2_fmtdesc *f, ...@@ -552,11 +552,19 @@ static int enum_fmt(void *priv, struct v4l2_fmtdesc *f,
int num_codecs = ctx->dev->devtype->num_codecs; int num_codecs = ctx->dev->devtype->num_codecs;
int num_formats = ARRAY_SIZE(coda_formats); int num_formats = ARRAY_SIZE(coda_formats);
int i, k, num = 0; int i, k, num = 0;
bool yuv;
if (ctx->inst_type == CODA_INST_ENCODER)
yuv = (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT);
else
yuv = (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE);
for (i = 0; i < num_formats; i++) { for (i = 0; i < num_formats; i++) {
/* Both uncompressed formats are always supported */ /* Skip either raw or compressed formats */
if (coda_format_is_yuv(formats[i].fourcc) && if (yuv != coda_format_is_yuv(formats[i].fourcc))
!coda_format_is_yuv(src_fourcc)) { continue;
/* All uncompressed formats are always supported */
if (yuv) {
if (num == f->index) if (num == f->index)
break; break;
++num; ++num;
...@@ -564,12 +572,10 @@ static int enum_fmt(void *priv, struct v4l2_fmtdesc *f, ...@@ -564,12 +572,10 @@ static int enum_fmt(void *priv, struct v4l2_fmtdesc *f,
} }
/* Compressed formats may be supported, check the codec list */ /* Compressed formats may be supported, check the codec list */
for (k = 0; k < num_codecs; k++) { for (k = 0; k < num_codecs; k++) {
/* if src_fourcc is set, only consider matching codecs */ if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE &&
if (type == V4L2_BUF_TYPE_VIDEO_CAPTURE && formats[i].fourcc == codecs[k].dst_fourcc)
formats[i].fourcc == codecs[k].dst_fourcc &&
(!src_fourcc || src_fourcc == codecs[k].src_fourcc))
break; break;
if (type == V4L2_BUF_TYPE_VIDEO_OUTPUT && if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT &&
formats[i].fourcc == codecs[k].src_fourcc) formats[i].fourcc == codecs[k].src_fourcc)
break; break;
} }
...@@ -584,7 +590,7 @@ static int enum_fmt(void *priv, struct v4l2_fmtdesc *f, ...@@ -584,7 +590,7 @@ static int enum_fmt(void *priv, struct v4l2_fmtdesc *f,
fmt = &formats[i]; fmt = &formats[i];
strlcpy(f->description, fmt->name, sizeof(f->description)); strlcpy(f->description, fmt->name, sizeof(f->description));
f->pixelformat = fmt->fourcc; f->pixelformat = fmt->fourcc;
if (!coda_format_is_yuv(fmt->fourcc)) if (!yuv)
f->flags |= V4L2_FMT_FLAG_COMPRESSED; f->flags |= V4L2_FMT_FLAG_COMPRESSED;
return 0; return 0;
} }
...@@ -593,31 +599,6 @@ static int enum_fmt(void *priv, struct v4l2_fmtdesc *f, ...@@ -593,31 +599,6 @@ static int enum_fmt(void *priv, struct v4l2_fmtdesc *f,
return -EINVAL; return -EINVAL;
} }
static int coda_enum_fmt_vid_cap(struct file *file, void *priv,
struct v4l2_fmtdesc *f)
{
struct coda_ctx *ctx = fh_to_ctx(priv);
struct vb2_queue *src_vq;
struct coda_q_data *q_data_src;
/* If the source format is already fixed, only list matching formats */
src_vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT);
if (vb2_is_streaming(src_vq)) {
q_data_src = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT);
return enum_fmt(priv, f, V4L2_BUF_TYPE_VIDEO_CAPTURE,
q_data_src->fourcc);
}
return enum_fmt(priv, f, V4L2_BUF_TYPE_VIDEO_CAPTURE, 0);
}
static int coda_enum_fmt_vid_out(struct file *file, void *priv,
struct v4l2_fmtdesc *f)
{
return enum_fmt(priv, f, V4L2_BUF_TYPE_VIDEO_OUTPUT, 0);
}
static int coda_g_fmt(struct file *file, void *priv, static int coda_g_fmt(struct file *file, void *priv,
struct v4l2_format *f) struct v4l2_format *f)
{ {
...@@ -970,12 +951,12 @@ static int coda_subscribe_event(struct v4l2_fh *fh, ...@@ -970,12 +951,12 @@ static int coda_subscribe_event(struct v4l2_fh *fh,
static const struct v4l2_ioctl_ops coda_ioctl_ops = { static const struct v4l2_ioctl_ops coda_ioctl_ops = {
.vidioc_querycap = coda_querycap, .vidioc_querycap = coda_querycap,
.vidioc_enum_fmt_vid_cap = coda_enum_fmt_vid_cap, .vidioc_enum_fmt_vid_cap = coda_enum_fmt,
.vidioc_g_fmt_vid_cap = coda_g_fmt, .vidioc_g_fmt_vid_cap = coda_g_fmt,
.vidioc_try_fmt_vid_cap = coda_try_fmt_vid_cap, .vidioc_try_fmt_vid_cap = coda_try_fmt_vid_cap,
.vidioc_s_fmt_vid_cap = coda_s_fmt_vid_cap, .vidioc_s_fmt_vid_cap = coda_s_fmt_vid_cap,
.vidioc_enum_fmt_vid_out = coda_enum_fmt_vid_out, .vidioc_enum_fmt_vid_out = coda_enum_fmt,
.vidioc_g_fmt_vid_out = coda_g_fmt, .vidioc_g_fmt_vid_out = coda_g_fmt,
.vidioc_try_fmt_vid_out = coda_try_fmt_vid_out, .vidioc_try_fmt_vid_out = coda_try_fmt_vid_out,
.vidioc_s_fmt_vid_out = coda_s_fmt_vid_out, .vidioc_s_fmt_vid_out = coda_s_fmt_vid_out,
......
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