summaryrefslogtreecommitdiffstats
path: root/drivers/staging/media
diff options
context:
space:
mode:
authorJan Luebbe2018-05-18 15:56:38 +0200
committerMauro Carvalho Chehab2018-07-04 15:26:17 +0200
commitf6aaac7fa03e36bb43401182864a74f65a211e86 (patch)
treeef8c108e1df97b89001dd7d56fdd75db5c7cb5b5 /drivers/staging/media
parentmedia: staging/imx: fill vb2_v4l2_buffer sequence entry (diff)
downloadkernel-qcow2-linux-f6aaac7fa03e36bb43401182864a74f65a211e86.tar.gz
kernel-qcow2-linux-f6aaac7fa03e36bb43401182864a74f65a211e86.tar.xz
kernel-qcow2-linux-f6aaac7fa03e36bb43401182864a74f65a211e86.zip
media: imx: capture: refactor enum_/try_fmt
By checking and handling the internal IPU formats (ARGB or AYUV) first, we don't need to check whether it's a bayer format, as we can default to passing the input format on in all other cases. This simplifies handling the different configurations for RGB565 between parallel and MIPI CSI-2, as we don't need to check the details of the format anymore. Signed-off-by: Jan Luebbe <jlu@pengutronix.de> Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de> Reviewed-by: Steve Longerbeam <steve_longerbeam@mentor.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Diffstat (limited to 'drivers/staging/media')
-rw-r--r--drivers/staging/media/imx/imx-media-capture.c38
1 files changed, 18 insertions, 20 deletions
diff --git a/drivers/staging/media/imx/imx-media-capture.c b/drivers/staging/media/imx/imx-media-capture.c
index 4e3fdf8aeef5..256039ce561e 100644
--- a/drivers/staging/media/imx/imx-media-capture.c
+++ b/drivers/staging/media/imx/imx-media-capture.c
@@ -170,23 +170,22 @@ static int capture_enum_fmt_vid_cap(struct file *file, void *fh,
}
cc_src = imx_media_find_ipu_format(fmt_src.format.code, CS_SEL_ANY);
- if (!cc_src)
- cc_src = imx_media_find_mbus_format(fmt_src.format.code,
- CS_SEL_ANY, true);
- if (!cc_src)
- return -EINVAL;
-
- if (cc_src->bayer) {
- if (f->index != 0)
- return -EINVAL;
- fourcc = cc_src->fourcc;
- } else {
+ if (cc_src) {
u32 cs_sel = (cc_src->cs == IPUV3_COLORSPACE_YUV) ?
CS_SEL_YUV : CS_SEL_RGB;
ret = imx_media_enum_format(&fourcc, f->index, cs_sel);
if (ret)
return ret;
+ } else {
+ cc_src = imx_media_find_mbus_format(fmt_src.format.code,
+ CS_SEL_ANY, true);
+ if (WARN_ON(!cc_src))
+ return -EINVAL;
+
+ if (f->index != 0)
+ return -EINVAL;
+ fourcc = cc_src->fourcc;
}
f->pixelformat = fourcc;
@@ -219,15 +218,7 @@ static int capture_try_fmt_vid_cap(struct file *file, void *fh,
return ret;
cc_src = imx_media_find_ipu_format(fmt_src.format.code, CS_SEL_ANY);
- if (!cc_src)
- cc_src = imx_media_find_mbus_format(fmt_src.format.code,
- CS_SEL_ANY, true);
- if (!cc_src)
- return -EINVAL;
-
- if (cc_src->bayer) {
- cc = cc_src;
- } else {
+ if (cc_src) {
u32 fourcc, cs_sel;
cs_sel = (cc_src->cs == IPUV3_COLORSPACE_YUV) ?
@@ -239,6 +230,13 @@ static int capture_try_fmt_vid_cap(struct file *file, void *fh,
imx_media_enum_format(&fourcc, 0, cs_sel);
cc = imx_media_find_format(fourcc, cs_sel, false);
}
+ } else {
+ cc_src = imx_media_find_mbus_format(fmt_src.format.code,
+ CS_SEL_ANY, true);
+ if (WARN_ON(!cc_src))
+ return -EINVAL;
+
+ cc = cc_src;
}
imx_media_mbus_fmt_to_pix_fmt(&f->fmt.pix, &fmt_src.format, cc);