diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2021-02-15 05:26:50 +0100 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab+huawei@kernel.org> | 2021-03-11 11:59:48 +0100 |
commit | 5e14568ccbdf62955b30459f78f96195be37bf20 (patch) | |
tree | b57b4ddfa73675c32666fe18a9be2fab4b66d3c2 | |
parent | a9512b261afd1aec188d3b3a760b69115e0d1209 (diff) | |
download | linux-stable-5e14568ccbdf62955b30459f78f96195be37bf20.tar.gz linux-stable-5e14568ccbdf62955b30459f78f96195be37bf20.tar.bz2 linux-stable-5e14568ccbdf62955b30459f78f96195be37bf20.zip |
media: imx: capture: Simplify __capture_legacy_try_fmt()
The __capture_legacy_try_fmt() function returns two values through
pointer arguments. One is a compose rectangle, which duplicates
informationr returned through the subdev format argument, and can thus
be removed. The other is the imx_media_pixfmt, which can be returned
by value instead.
Simplify the implementation of __capture_legacy_try_fmt() by dropping
the retcc and compose arguments, and returning the imx_media_pixfmt by
value.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com>
Reviewed-by: Steve Longerbeam <slongerbeam@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 | 40 |
1 files changed, 17 insertions, 23 deletions
diff --git a/drivers/staging/media/imx/imx-media-capture.c b/drivers/staging/media/imx/imx-media-capture.c index ed4e51b93dc5..700e99d02523 100644 --- a/drivers/staging/media/imx/imx-media-capture.c +++ b/drivers/staging/media/imx/imx-media-capture.c @@ -251,17 +251,16 @@ static int capture_legacy_enum_fmt_vid_cap(struct file *file, void *fh, return 0; } -static int __capture_legacy_try_fmt(struct capture_priv *priv, - struct v4l2_subdev_format *fmt_src, - struct v4l2_pix_format *pixfmt, - const struct imx_media_pixfmt **retcc, - struct v4l2_rect *compose) +static const struct imx_media_pixfmt * +__capture_legacy_try_fmt(struct capture_priv *priv, + struct v4l2_subdev_format *fmt_src, + struct v4l2_pix_format *pixfmt) { const struct imx_media_pixfmt *cc; cc = capture_find_format(fmt_src->format.code, pixfmt->pixelformat); if (WARN_ON(!cc)) - return -EINVAL; + return NULL; /* allow IDMAC interweave but enforce field order from source */ if (V4L2_FIELD_IS_INTERLACED(pixfmt->field)) { @@ -279,17 +278,7 @@ static int __capture_legacy_try_fmt(struct capture_priv *priv, imx_media_mbus_fmt_to_pix_fmt(pixfmt, &fmt_src->format, cc); - if (retcc) - *retcc = cc; - - if (compose) { - compose->left = 0; - compose->top = 0; - compose->width = fmt_src->format.width; - compose->height = fmt_src->format.height; - } - - return 0; + return cc; } static int capture_legacy_try_fmt_vid_cap(struct file *file, void *fh, @@ -305,8 +294,10 @@ static int capture_legacy_try_fmt_vid_cap(struct file *file, void *fh, if (ret) return ret; - return __capture_legacy_try_fmt(priv, &fmt_src, &f->fmt.pix, NULL, - NULL); + if (!__capture_legacy_try_fmt(priv, &fmt_src, &f->fmt.pix)) + return -EINVAL; + + return 0; } static int capture_legacy_s_fmt_vid_cap(struct file *file, void *fh, @@ -314,6 +305,7 @@ static int capture_legacy_s_fmt_vid_cap(struct file *file, void *fh, { struct capture_priv *priv = video_drvdata(file); struct v4l2_subdev_format fmt_src; + const struct imx_media_pixfmt *cc; int ret; if (vb2_is_busy(&priv->q)) { @@ -327,12 +319,14 @@ static int capture_legacy_s_fmt_vid_cap(struct file *file, void *fh, if (ret) return ret; - ret = __capture_legacy_try_fmt(priv, &fmt_src, &f->fmt.pix, - &priv->vdev.cc, &priv->vdev.compose); - if (ret) - return ret; + cc = __capture_legacy_try_fmt(priv, &fmt_src, &f->fmt.pix); + if (!cc) + return -EINVAL; + priv->vdev.cc = cc; priv->vdev.fmt = f->fmt.pix; + priv->vdev.compose.width = fmt_src.format.width; + priv->vdev.compose.height = fmt_src.format.height; return 0; } |