aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2012-07-18 10:33:22 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-07-30 18:20:21 -0400
commit47556ffaf212273ca65ce2d3177d4ff2f116db4d (patch)
treee93e51e6ecca90d30e9dd95b0f45f6e7ec15f1cf /drivers/media
parent97a3c902e98d772f4310e81d44a27db0d1cf4ddd (diff)
[media] mem2mem_testdev: set default size and fix colorspace
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/video/mem2mem_testdev.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/drivers/media/video/mem2mem_testdev.c b/drivers/media/video/mem2mem_testdev.c
index f7a2a2d635f5..7fdee8fcf3f7 100644
--- a/drivers/media/video/mem2mem_testdev.c
+++ b/drivers/media/video/mem2mem_testdev.c
@@ -171,6 +171,8 @@ struct m2mtest_ctx {
171 /* Processing mode */ 171 /* Processing mode */
172 int mode; 172 int mode;
173 173
174 enum v4l2_colorspace colorspace;
175
174 struct v4l2_m2m_ctx *m2m_ctx; 176 struct v4l2_m2m_ctx *m2m_ctx;
175 177
176 /* Source and destination queue data */ 178 /* Source and destination queue data */
@@ -494,6 +496,7 @@ static int vidioc_g_fmt(struct m2mtest_ctx *ctx, struct v4l2_format *f)
494 f->fmt.pix.pixelformat = q_data->fmt->fourcc; 496 f->fmt.pix.pixelformat = q_data->fmt->fourcc;
495 f->fmt.pix.bytesperline = (q_data->width * q_data->fmt->depth) >> 3; 497 f->fmt.pix.bytesperline = (q_data->width * q_data->fmt->depth) >> 3;
496 f->fmt.pix.sizeimage = q_data->sizeimage; 498 f->fmt.pix.sizeimage = q_data->sizeimage;
499 f->fmt.pix.colorspace = ctx->colorspace;
497 500
498 return 0; 501 return 0;
499} 502}
@@ -555,6 +558,7 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
555 f->fmt.pix.pixelformat); 558 f->fmt.pix.pixelformat);
556 return -EINVAL; 559 return -EINVAL;
557 } 560 }
561 f->fmt.pix.colorspace = ctx->colorspace;
558 562
559 return vidioc_try_fmt(f, fmt); 563 return vidioc_try_fmt(f, fmt);
560} 564}
@@ -572,6 +576,8 @@ static int vidioc_try_fmt_vid_out(struct file *file, void *priv,
572 f->fmt.pix.pixelformat); 576 f->fmt.pix.pixelformat);
573 return -EINVAL; 577 return -EINVAL;
574 } 578 }
579 if (!f->fmt.pix.colorspace)
580 f->fmt.pix.colorspace = V4L2_COLORSPACE_REC709;
575 581
576 return vidioc_try_fmt(f, fmt); 582 return vidioc_try_fmt(f, fmt);
577} 583}
@@ -622,13 +628,17 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
622static int vidioc_s_fmt_vid_out(struct file *file, void *priv, 628static int vidioc_s_fmt_vid_out(struct file *file, void *priv,
623 struct v4l2_format *f) 629 struct v4l2_format *f)
624{ 630{
631 struct m2mtest_ctx *ctx = file2ctx(file);
625 int ret; 632 int ret;
626 633
627 ret = vidioc_try_fmt_vid_out(file, priv, f); 634 ret = vidioc_try_fmt_vid_out(file, priv, f);
628 if (ret) 635 if (ret)
629 return ret; 636 return ret;
630 637
631 return vidioc_s_fmt(file2ctx(file), f); 638 ret = vidioc_s_fmt(file2ctx(file), f);
639 if (!ret)
640 ctx->colorspace = f->fmt.pix.colorspace;
641 return ret;
632} 642}
633 643
634static int vidioc_reqbufs(struct file *file, void *priv, 644static int vidioc_reqbufs(struct file *file, void *priv,
@@ -906,7 +916,14 @@ static int m2mtest_open(struct file *file)
906 v4l2_ctrl_handler_setup(hdl); 916 v4l2_ctrl_handler_setup(hdl);
907 917
908 ctx->q_data[V4L2_M2M_SRC].fmt = &formats[0]; 918 ctx->q_data[V4L2_M2M_SRC].fmt = &formats[0];
909 ctx->q_data[V4L2_M2M_DST].fmt = &formats[0]; 919 ctx->q_data[V4L2_M2M_SRC].width = 640;
920 ctx->q_data[V4L2_M2M_SRC].height = 480;
921 ctx->q_data[V4L2_M2M_SRC].sizeimage =
922 ctx->q_data[V4L2_M2M_SRC].width *
923 ctx->q_data[V4L2_M2M_SRC].height *
924 (ctx->q_data[V4L2_M2M_SRC].fmt->depth >> 3);
925 ctx->q_data[V4L2_M2M_DST] = ctx->q_data[V4L2_M2M_SRC];
926 ctx->colorspace = V4L2_COLORSPACE_REC709;
910 927
911 ctx->m2m_ctx = v4l2_m2m_ctx_init(dev->m2m_dev, ctx, &queue_init); 928 ctx->m2m_ctx = v4l2_m2m_ctx_init(dev->m2m_dev, ctx, &queue_init);
912 929