From: Hans Verkuil Date: Mon, 10 Mar 2014 13:58:24 +0000 (-0300) Subject: upstream: [media] mem2mem_testdev: pick default format with try_fmt X-Git-Tag: submit/tizen/20141121.110247~1357 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e69f32b64397862e00cb6745f9098a134480828e;p=platform%2Fkernel%2Flinux-3.10.git upstream: [media] mem2mem_testdev: pick default format with try_fmt This resolves an issue raised by v4l2-compliance: if the given format does not exist, then pick a default format. While there is an exception regarding this for TV capture drivers, this m2m driver should do the right thing. Signed-off-by: Hans Verkuil Signed-off-by: Kamil Debski Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/platform/mem2mem_testdev.c b/drivers/media/platform/mem2mem_testdev.c index 5b172f6..935b314 100644 --- a/drivers/media/platform/mem2mem_testdev.c +++ b/drivers/media/platform/mem2mem_testdev.c @@ -557,7 +557,11 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, struct m2mtest_ctx *ctx = file2ctx(file); fmt = find_format(f); - if (!fmt || !(fmt->types & MEM2MEM_CAPTURE)) { + if (!fmt) { + f->fmt.pix.pixelformat = formats[0].fourcc; + fmt = find_format(f); + } + if (!(fmt->types & MEM2MEM_CAPTURE)) { v4l2_err(&ctx->dev->v4l2_dev, "Fourcc format (0x%08x) invalid.\n", f->fmt.pix.pixelformat); @@ -575,7 +579,11 @@ static int vidioc_try_fmt_vid_out(struct file *file, void *priv, struct m2mtest_ctx *ctx = file2ctx(file); fmt = find_format(f); - if (!fmt || !(fmt->types & MEM2MEM_OUTPUT)) { + if (!fmt) { + f->fmt.pix.pixelformat = formats[0].fourcc; + fmt = find_format(f); + } + if (!(fmt->types & MEM2MEM_OUTPUT)) { v4l2_err(&ctx->dev->v4l2_dev, "Fourcc format (0x%08x) invalid.\n", f->fmt.pix.pixelformat);