Commit 6cc20944 authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Mauro Carvalho Chehab

media: imx: capture: Pass v4l2_pix_format to __capture_legacy_try_fmt()

The __capture_legacy_try_fmt() function only needs the v4l2_pix_format
embedded in the v4l2_format argument it receives. Pass it the
v4l2_pix_format directly, allowing on caller to allocate a smaller
structure on the stack.
Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: default avatarRui Miguel Silva <rmfrfs@gmail.com>
Reviewed-by: default avatarSteve Longerbeam <slongerbeam@gmail.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 96fe421e
...@@ -232,7 +232,7 @@ static int capture_legacy_enum_fmt_vid_cap(struct file *file, void *fh, ...@@ -232,7 +232,7 @@ static int capture_legacy_enum_fmt_vid_cap(struct file *file, void *fh,
static int __capture_legacy_try_fmt(struct capture_priv *priv, static int __capture_legacy_try_fmt(struct capture_priv *priv,
struct v4l2_subdev_format *fmt_src, struct v4l2_subdev_format *fmt_src,
struct v4l2_format *f, struct v4l2_pix_format *pixfmt,
const struct imx_media_pixfmt **retcc, const struct imx_media_pixfmt **retcc,
struct v4l2_rect *compose) struct v4l2_rect *compose)
{ {
...@@ -246,7 +246,7 @@ static int __capture_legacy_try_fmt(struct capture_priv *priv, ...@@ -246,7 +246,7 @@ static int __capture_legacy_try_fmt(struct capture_priv *priv,
fmt_sel = (cc->cs == IPUV3_COLORSPACE_YUV) fmt_sel = (cc->cs == IPUV3_COLORSPACE_YUV)
? PIXFMT_SEL_YUV : PIXFMT_SEL_RGB; ? PIXFMT_SEL_YUV : PIXFMT_SEL_RGB;
fourcc = f->fmt.pix.pixelformat; fourcc = pixfmt->pixelformat;
cc = imx_media_find_pixel_format(fourcc, fmt_sel); cc = imx_media_find_pixel_format(fourcc, fmt_sel);
if (!cc) { if (!cc) {
...@@ -261,7 +261,7 @@ static int __capture_legacy_try_fmt(struct capture_priv *priv, ...@@ -261,7 +261,7 @@ static int __capture_legacy_try_fmt(struct capture_priv *priv,
} }
/* allow IDMAC interweave but enforce field order from source */ /* allow IDMAC interweave but enforce field order from source */
if (V4L2_FIELD_IS_INTERLACED(f->fmt.pix.field)) { if (V4L2_FIELD_IS_INTERLACED(pixfmt->field)) {
switch (fmt_src->format.field) { switch (fmt_src->format.field) {
case V4L2_FIELD_SEQ_TB: case V4L2_FIELD_SEQ_TB:
fmt_src->format.field = V4L2_FIELD_INTERLACED_TB; fmt_src->format.field = V4L2_FIELD_INTERLACED_TB;
...@@ -274,7 +274,7 @@ static int __capture_legacy_try_fmt(struct capture_priv *priv, ...@@ -274,7 +274,7 @@ static int __capture_legacy_try_fmt(struct capture_priv *priv,
} }
} }
imx_media_mbus_fmt_to_pix_fmt(&f->fmt.pix, &fmt_src->format, cc); imx_media_mbus_fmt_to_pix_fmt(pixfmt, &fmt_src->format, cc);
if (retcc) if (retcc)
*retcc = cc; *retcc = cc;
...@@ -302,7 +302,8 @@ static int capture_legacy_try_fmt_vid_cap(struct file *file, void *fh, ...@@ -302,7 +302,8 @@ static int capture_legacy_try_fmt_vid_cap(struct file *file, void *fh,
if (ret) if (ret)
return ret; return ret;
return __capture_legacy_try_fmt(priv, &fmt_src, f, NULL, NULL); return __capture_legacy_try_fmt(priv, &fmt_src, &f->fmt.pix, NULL,
NULL);
} }
static int capture_legacy_s_fmt_vid_cap(struct file *file, void *fh, static int capture_legacy_s_fmt_vid_cap(struct file *file, void *fh,
...@@ -323,8 +324,8 @@ static int capture_legacy_s_fmt_vid_cap(struct file *file, void *fh, ...@@ -323,8 +324,8 @@ static int capture_legacy_s_fmt_vid_cap(struct file *file, void *fh,
if (ret) if (ret)
return ret; return ret;
ret = __capture_legacy_try_fmt(priv, &fmt_src, f, &priv->vdev.cc, ret = __capture_legacy_try_fmt(priv, &fmt_src, &f->fmt.pix,
&priv->vdev.compose); &priv->vdev.cc, &priv->vdev.compose);
if (ret) if (ret)
return ret; return ret;
...@@ -534,7 +535,7 @@ static int capture_validate_fmt(struct capture_priv *priv) ...@@ -534,7 +535,7 @@ static int capture_validate_fmt(struct capture_priv *priv)
struct v4l2_subdev_format fmt_src; struct v4l2_subdev_format fmt_src;
const struct imx_media_pixfmt *cc; const struct imx_media_pixfmt *cc;
struct v4l2_rect compose; struct v4l2_rect compose;
struct v4l2_format f; struct v4l2_pix_format pixfmt;
int ret; int ret;
fmt_src.pad = priv->src_sd_pad; fmt_src.pad = priv->src_sd_pad;
...@@ -543,14 +544,14 @@ static int capture_validate_fmt(struct capture_priv *priv) ...@@ -543,14 +544,14 @@ static int capture_validate_fmt(struct capture_priv *priv)
if (ret) if (ret)
return ret; return ret;
v4l2_fill_pix_format(&f.fmt.pix, &fmt_src.format); v4l2_fill_pix_format(&pixfmt, &fmt_src.format);
ret = __capture_legacy_try_fmt(priv, &fmt_src, &f, &cc, &compose); ret = __capture_legacy_try_fmt(priv, &fmt_src, &pixfmt, &cc, &compose);
if (ret) if (ret)
return ret; return ret;
return (priv->vdev.fmt.width != f.fmt.pix.width || return (priv->vdev.fmt.width != pixfmt.width ||
priv->vdev.fmt.height != f.fmt.pix.height || priv->vdev.fmt.height != pixfmt.height ||
priv->vdev.cc->cs != cc->cs || priv->vdev.cc->cs != cc->cs ||
priv->vdev.compose.width != compose.width || priv->vdev.compose.width != compose.width ||
priv->vdev.compose.height != compose.height) ? -EINVAL : 0; priv->vdev.compose.height != compose.height) ? -EINVAL : 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment