Commit 4ec319eb authored by Philipp Zabel's avatar Philipp Zabel Committed by Mauro Carvalho Chehab

[media] coda: correctly set capture compose rectangle

Correctly store the rectangle of valid video data in the destination
q_data before rounding up to macroblock size. This fixes the output
of VIDIOC_G_SELECTION for the capture side compose rectangle.
Signed-off-by: default avatarPhilipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: default avatarMichael Tretter <m.tretter@pengutronix.de>
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent 126f52b0
...@@ -566,7 +566,8 @@ static int coda_try_fmt_vid_out(struct file *file, void *priv, ...@@ -566,7 +566,8 @@ static int coda_try_fmt_vid_out(struct file *file, void *priv,
return coda_try_fmt(ctx, codec, f); return coda_try_fmt(ctx, codec, f);
} }
static int coda_s_fmt(struct coda_ctx *ctx, struct v4l2_format *f) static int coda_s_fmt(struct coda_ctx *ctx, struct v4l2_format *f,
struct v4l2_rect *r)
{ {
struct coda_q_data *q_data; struct coda_q_data *q_data;
struct vb2_queue *vq; struct vb2_queue *vq;
...@@ -589,10 +590,14 @@ static int coda_s_fmt(struct coda_ctx *ctx, struct v4l2_format *f) ...@@ -589,10 +590,14 @@ static int coda_s_fmt(struct coda_ctx *ctx, struct v4l2_format *f)
q_data->height = f->fmt.pix.height; q_data->height = f->fmt.pix.height;
q_data->bytesperline = f->fmt.pix.bytesperline; q_data->bytesperline = f->fmt.pix.bytesperline;
q_data->sizeimage = f->fmt.pix.sizeimage; q_data->sizeimage = f->fmt.pix.sizeimage;
if (r) {
q_data->rect = *r;
} else {
q_data->rect.left = 0; q_data->rect.left = 0;
q_data->rect.top = 0; q_data->rect.top = 0;
q_data->rect.width = f->fmt.pix.width; q_data->rect.width = f->fmt.pix.width;
q_data->rect.height = f->fmt.pix.height; q_data->rect.height = f->fmt.pix.height;
}
switch (f->fmt.pix.pixelformat) { switch (f->fmt.pix.pixelformat) {
case V4L2_PIX_FMT_NV12: case V4L2_PIX_FMT_NV12:
...@@ -621,27 +626,37 @@ static int coda_s_fmt_vid_cap(struct file *file, void *priv, ...@@ -621,27 +626,37 @@ static int coda_s_fmt_vid_cap(struct file *file, void *priv,
struct v4l2_format *f) struct v4l2_format *f)
{ {
struct coda_ctx *ctx = fh_to_ctx(priv); struct coda_ctx *ctx = fh_to_ctx(priv);
struct coda_q_data *q_data_src;
struct v4l2_rect r;
int ret; int ret;
ret = coda_try_fmt_vid_cap(file, priv, f); ret = coda_try_fmt_vid_cap(file, priv, f);
if (ret) if (ret)
return ret; return ret;
return coda_s_fmt(ctx, f); q_data_src = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT);
r.left = 0;
r.top = 0;
r.width = q_data_src->width;
r.height = q_data_src->height;
return coda_s_fmt(ctx, f, &r);
} }
static int coda_s_fmt_vid_out(struct file *file, void *priv, static int coda_s_fmt_vid_out(struct file *file, void *priv,
struct v4l2_format *f) struct v4l2_format *f)
{ {
struct coda_ctx *ctx = fh_to_ctx(priv); struct coda_ctx *ctx = fh_to_ctx(priv);
struct coda_q_data *q_data_src;
struct v4l2_format f_cap; struct v4l2_format f_cap;
struct v4l2_rect r;
int ret; int ret;
ret = coda_try_fmt_vid_out(file, priv, f); ret = coda_try_fmt_vid_out(file, priv, f);
if (ret) if (ret)
return ret; return ret;
ret = coda_s_fmt(ctx, f); ret = coda_s_fmt(ctx, f, NULL);
if (ret) if (ret)
return ret; return ret;
...@@ -657,7 +672,13 @@ static int coda_s_fmt_vid_out(struct file *file, void *priv, ...@@ -657,7 +672,13 @@ static int coda_s_fmt_vid_out(struct file *file, void *priv,
if (ret) if (ret)
return ret; return ret;
return coda_s_fmt(ctx, &f_cap); q_data_src = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT);
r.left = 0;
r.top = 0;
r.width = q_data_src->width;
r.height = q_data_src->height;
return coda_s_fmt(ctx, &f_cap, &r);
} }
static int coda_reqbufs(struct file *file, void *priv, static int coda_reqbufs(struct file *file, void *priv,
......
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