diff options
| author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2021-02-15 07:26:48 +0300 |
|---|---|---|
| committer | Mauro Carvalho Chehab <mchehab+huawei@kernel.org> | 2021-03-11 13:59:48 +0300 |
| commit | 7edcce6cc082f5b164382e0ca3291ade5c164fdb (patch) | |
| tree | 98b1f9fa314bec9924d3c0788a4d7d19f00217f9 | |
| parent | cc271b6754691af74d710b761eaf027e3743e243 (diff) | |
| download | linux-7edcce6cc082f5b164382e0ca3291ade5c164fdb.tar.xz | |
media: imx: capture: Extract format lookup from __capture_legacy_try_fmt
Extract the format lookup code from __capture_legacy_try_fmt() to a
separate function, it will be reused when validating the video node
format at stream start time.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
| -rw-r--r-- | drivers/staging/media/imx/imx-media-capture.c | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/drivers/staging/media/imx/imx-media-capture.c b/drivers/staging/media/imx/imx-media-capture.c index 43bf3ac9076a..6350acd0dba9 100644 --- a/drivers/staging/media/imx/imx-media-capture.c +++ b/drivers/staging/media/imx/imx-media-capture.c @@ -58,6 +58,27 @@ struct capture_priv { * Common Video IOCTLs */ +static const struct imx_media_pixfmt *capture_find_format(u32 code, u32 fourcc) +{ + const struct imx_media_pixfmt *cc; + + cc = imx_media_find_ipu_format(code, PIXFMT_SEL_YUV_RGB); + if (cc) { + enum imx_pixfmt_sel fmt_sel = cc->cs == IPUV3_COLORSPACE_YUV + ? PIXFMT_SEL_YUV : PIXFMT_SEL_RGB; + + cc = imx_media_find_pixel_format(fourcc, fmt_sel); + if (!cc) { + imx_media_enum_pixel_formats(&fourcc, 0, fmt_sel, 0); + cc = imx_media_find_pixel_format(fourcc, fmt_sel); + } + + return cc; + } + + return imx_media_find_mbus_format(code, PIXFMT_SEL_ANY); +} + static int capture_querycap(struct file *file, void *fh, struct v4l2_capability *cap) { @@ -238,27 +259,9 @@ static int __capture_legacy_try_fmt(struct capture_priv *priv, { const struct imx_media_pixfmt *cc; - cc = imx_media_find_ipu_format(fmt_src->format.code, - PIXFMT_SEL_YUV_RGB); - if (cc) { - enum imx_pixfmt_sel fmt_sel; - u32 fourcc; - - fmt_sel = (cc->cs == IPUV3_COLORSPACE_YUV) - ? PIXFMT_SEL_YUV : PIXFMT_SEL_RGB; - fourcc = pixfmt->pixelformat; - - cc = imx_media_find_pixel_format(fourcc, fmt_sel); - if (!cc) { - imx_media_enum_pixel_formats(&fourcc, 0, fmt_sel, 0); - cc = imx_media_find_pixel_format(fourcc, fmt_sel); - } - } else { - cc = imx_media_find_mbus_format(fmt_src->format.code, - PIXFMT_SEL_ANY); - if (WARN_ON(!cc)) - return -EINVAL; - } + cc = capture_find_format(fmt_src->format.code, pixfmt->pixelformat); + if (WARN_ON(!cc)) + return -EINVAL; /* allow IDMAC interweave but enforce field order from source */ if (V4L2_FIELD_IS_INTERLACED(pixfmt->field)) { |
