[PATCH v2 2/9] media: imx: Forward type of hardware implementation

Alexander Stein
2022-02-11T14:28:17Z

From: Dorota Czaplejewicz <dorota.czaplejewicz@puri.sm>

Pass down the hardware type so imx_media_mbus_fmt_to_pix_fmt can do
the actual switch.

Signed-off-by: Dorota Czaplejewicz <dorota.czaplejewicz@puri.sm>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
---
Changes in v2:
* Switch back to using enum
* Added Reviewed-by: Laurent Pinchart

drivers/staging/media/imx/imx-media-capture.c | 15 +++++++++------
drivers/staging/media/imx/imx-media-utils.c | 3 ++-
drivers/staging/media/imx/imx-media.h | 3 ++-
3 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/media/imx/imx-media-capture.c b/drivers/staging/media/imx/imx-media-capture.c
index 65dc95a48ecc..7a6384b3e5e6 100644
--- a/drivers/staging/media/imx/imx-media-capture.c
+++ b/drivers/staging/media/imx/imx-media-capture.c
@@ -139,7 +139,8 @@ static int capture_g_fmt_vid_cap(struct file *file, void *fh,
}

static const struct imx_media_pixfmt *
-__capture_try_fmt(struct v4l2_pix_format *pixfmt, struct v4l2_rect *compose)
+__capture_try_fmt(struct v4l2_pix_format *pixfmt, struct v4l2_rect *compose,
+ enum imx_media_device_type type)
{
struct v4l2_mbus_framefmt fmt_src;
const struct imx_media_pixfmt *cc;
@@ -171,7 +172,7 @@ __capture_try_fmt(struct v4l2_pix_format *pixfmt, struct v4l2_rect *compose)
}

v4l2_fill_mbus_format(&fmt_src, pixfmt, 0);
- imx_media_mbus_fmt_to_pix_fmt(pixfmt, &fmt_src, cc);
+ imx_media_mbus_fmt_to_pix_fmt(pixfmt, &fmt_src, cc, type);

if (compose) {
compose->width = fmt_src.width;
@@ -184,7 +185,9 @@ __capture_try_fmt(struct v4l2_pix_format *pixfmt, struct v4l2_rect *compose)
static int capture_try_fmt_vid_cap(struct file *file, void *fh,
struct v4l2_format *f)
{
- __capture_try_fmt(&f->fmt.pix, NULL);
+ struct capture_priv *priv = video_drvdata(file);
+
+ __capture_try_fmt(&f->fmt.pix, NULL, priv->type);
return 0;
}

@@ -199,7 +202,7 @@ static int capture_s_fmt_vid_cap(struct file *file, void *fh,
return -EBUSY;
}

- cc = __capture_try_fmt(&f->fmt.pix, &priv->vdev.compose);
+ cc = __capture_try_fmt(&f->fmt.pix, &priv->vdev.compose, priv->type);

priv->vdev.cc = cc;
priv->vdev.fmt = f->fmt.pix;
@@ -418,7 +421,7 @@ __capture_legacy_try_fmt(struct capture_priv *priv,
}
}

- imx_media_mbus_fmt_to_pix_fmt(pixfmt, &fmt_src->format, cc);
+ imx_media_mbus_fmt_to_pix_fmt(pixfmt, &fmt_src->format, cc, priv->type);

return cc;
}
@@ -889,7 +892,7 @@ static int capture_init_format(struct capture_priv *priv)
fmt_src.format.height = IMX_MEDIA_DEF_PIX_HEIGHT;
}

- imx_media_mbus_fmt_to_pix_fmt(&vdev->fmt, &fmt_src.format, NULL);
+ imx_media_mbus_fmt_to_pix_fmt(&vdev->fmt, &fmt_src.format, NULL, priv->type);
vdev->compose.width = fmt_src.format.width;
vdev->compose.height = fmt_src.format.height;

diff --git a/drivers/staging/media/imx/imx-media-utils.c b/drivers/staging/media/imx/imx-media-utils.c
index 94bc866ca28c..c42f3da8e3a8 100644
--- a/drivers/staging/media/imx/imx-media-utils.c
+++ b/drivers/staging/media/imx/imx-media-utils.c
@@ -518,7 +518,8 @@ EXPORT_SYMBOL_GPL(imx_media_try_colorimetry);

int imx_media_mbus_fmt_to_pix_fmt(struct v4l2_pix_format *pix,
const struct v4l2_mbus_framefmt *mbus,
- const struct imx_media_pixfmt *cc)
+ const struct imx_media_pixfmt *cc,
+ enum imx_media_device_type type)
{
u32 width;
u32 stride;
diff --git a/drivers/staging/media/imx/imx-media.h b/drivers/staging/media/imx/imx-media.h
index e4c22b3ccd57..f59feccb26bf 100644
--- a/drivers/staging/media/imx/imx-media.h
+++ b/drivers/staging/media/imx/imx-media.h
@@ -203,7 +203,8 @@ void imx_media_try_colorimetry(struct v4l2_mbus_framefmt *tryfmt,
bool ic_route);
int imx_media_mbus_fmt_to_pix_fmt(struct v4l2_pix_format *pix,
const struct v4l2_mbus_framefmt *mbus,
- const struct imx_media_pixfmt *cc);
+ const struct imx_media_pixfmt *cc,
+ enum imx_media_device_type type);
void imx_media_grp_id_to_sd_name(char *sd_name, int sz,
u32 grp_id, int ipu_id);
struct v4l2_subdev *
--
2.25.1