diff mbox series

[39/50] staging: media: imx: imx7-media-csi: Define macro for default mbus code

Message ID 20220510115859.19777-40-laurent.pinchart@ideasonboard.com (mailing list archive)
State New, archived
Headers show
Series staging: media: imx: Prepare destaging of imx7-media-csi | expand

Commit Message

Laurent Pinchart May 10, 2022, 11:58 a.m. UTC
Define a macro for the default media bus code and use it through the
driver to replace a hardcoded value and a dynamic query from the
pixel_formats table.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/staging/media/imx/imx7-media-csi.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Alexander Stein May 11, 2022, 1:22 p.m. UTC | #1
Hello Laurent,

Am Dienstag, 10. Mai 2022, 13:58:48 CEST schrieb Laurent Pinchart:
> Define a macro for the default media bus code and use it through the
> driver to replace a hardcoded value and a dynamic query from the
> pixel_formats table.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  drivers/staging/media/imx/imx7-media-csi.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/media/imx/imx7-media-csi.c
> b/drivers/staging/media/imx/imx7-media-csi.c index
> bcf57aff3572..f2e85e9851e4 100644
> --- a/drivers/staging/media/imx/imx7-media-csi.c
> +++ b/drivers/staging/media/imx/imx7-media-csi.c
> @@ -167,6 +167,7 @@
>  #define IMX7_CSI_VIDEO_MEM_LIMIT	SZ_64M
>  #define IMX7_CSI_VIDEO_EOF_TIMEOUT	2000
> 
> +#define IMX7_CSI_DEF_MBUS_CODE		MEDIA_BUS_FMT_UYVY8_2X8
>  #define IMX7_CSI_DEF_PIX_WIDTH		640
>  #define IMX7_CSI_DEF_PIX_HEIGHT		480
> 
> @@ -1096,7 +1097,7 @@ static int imx7_csi_init_mbus_fmt(struct
> v4l2_mbus_framefmt *mbus, mbus->field = field;
> 
>  	if (code == 0)
> -		imx7_csi_enum_mbus_formats(&code, 0, 
IMX7_CSI_PIXFMT_SEL_YUV);
> +		code = IMX7_CSI_DEF_MBUS_CODE;
> 
>  	lcc = imx7_csi_find_mbus_format(code, IMX7_CSI_PIXFMT_SEL_ANY);
>  	if (!lcc)
> @@ -1629,7 +1630,7 @@ static int imx7_csi_video_init_format(struct imx7_csi
> *csi) .pad = IMX7_CSI_PAD_SRC,
>  		.which = V4L2_SUBDEV_FORMAT_ACTIVE,
>  	};
> -	fmt_src.format.code = MEDIA_BUS_FMT_UYVY8_2X8;
> +	fmt_src.format.code = IMX7_CSI_DEF_MBUS_CODE;
>  	fmt_src.format.width = IMX7_CSI_DEF_PIX_WIDTH;
>  	fmt_src.format.height = IMX7_CSI_DEF_PIX_HEIGHT;

This change assumes, like before, that MEDIA_BUS_FMT_UYVY8_2X8 is the 1st code 
in the 1st entry in pixel_formats. Maybe a comment is helpful to indicate 
that.

Regards,
Alexander
Laurent Pinchart May 11, 2022, 8:20 p.m. UTC | #2
Hi Alexander,

On Wed, May 11, 2022 at 03:22:02PM +0200, Alexander Stein wrote:
> Am Dienstag, 10. Mai 2022, 13:58:48 CEST schrieb Laurent Pinchart:
> > Define a macro for the default media bus code and use it through the
> > driver to replace a hardcoded value and a dynamic query from the
> > pixel_formats table.
> > 
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > ---
> >  drivers/staging/media/imx/imx7-media-csi.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/staging/media/imx/imx7-media-csi.c
> > b/drivers/staging/media/imx/imx7-media-csi.c index
> > bcf57aff3572..f2e85e9851e4 100644
> > --- a/drivers/staging/media/imx/imx7-media-csi.c
> > +++ b/drivers/staging/media/imx/imx7-media-csi.c
> > @@ -167,6 +167,7 @@
> >  #define IMX7_CSI_VIDEO_MEM_LIMIT	SZ_64M
> >  #define IMX7_CSI_VIDEO_EOF_TIMEOUT	2000
> > 
> > +#define IMX7_CSI_DEF_MBUS_CODE		MEDIA_BUS_FMT_UYVY8_2X8
> >  #define IMX7_CSI_DEF_PIX_WIDTH		640
> >  #define IMX7_CSI_DEF_PIX_HEIGHT		480
> > 
> > @@ -1096,7 +1097,7 @@ static int imx7_csi_init_mbus_fmt(struct
> > v4l2_mbus_framefmt *mbus, mbus->field = field;
> > 
> >  	if (code == 0)
> > -		imx7_csi_enum_mbus_formats(&code, 0, IMX7_CSI_PIXFMT_SEL_YUV);
> > +		code = IMX7_CSI_DEF_MBUS_CODE;
> > 
> >  	lcc = imx7_csi_find_mbus_format(code, IMX7_CSI_PIXFMT_SEL_ANY);
> >  	if (!lcc)
> > @@ -1629,7 +1630,7 @@ static int imx7_csi_video_init_format(struct imx7_csi
> > *csi) .pad = IMX7_CSI_PAD_SRC,
> >  		.which = V4L2_SUBDEV_FORMAT_ACTIVE,
> >  	};
> > -	fmt_src.format.code = MEDIA_BUS_FMT_UYVY8_2X8;
> > +	fmt_src.format.code = IMX7_CSI_DEF_MBUS_CODE;
> >  	fmt_src.format.width = IMX7_CSI_DEF_PIX_WIDTH;
> >  	fmt_src.format.height = IMX7_CSI_DEF_PIX_HEIGHT;
> 
> This change assumes, like before, that MEDIA_BUS_FMT_UYVY8_2X8 is the 1st code 
> in the 1st entry in pixel_formats. Maybe a comment is helpful to indicate 
> that.

I'll add a comment above the formats array that mentions this. Same for
the comment on had on patch 44/50. I'll refrain from posting a v2 until
I get more review as I don't want to spam the list too often.
diff mbox series

Patch

diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c
index bcf57aff3572..f2e85e9851e4 100644
--- a/drivers/staging/media/imx/imx7-media-csi.c
+++ b/drivers/staging/media/imx/imx7-media-csi.c
@@ -167,6 +167,7 @@ 
 #define IMX7_CSI_VIDEO_MEM_LIMIT	SZ_64M
 #define IMX7_CSI_VIDEO_EOF_TIMEOUT	2000
 
+#define IMX7_CSI_DEF_MBUS_CODE		MEDIA_BUS_FMT_UYVY8_2X8
 #define IMX7_CSI_DEF_PIX_WIDTH		640
 #define IMX7_CSI_DEF_PIX_HEIGHT		480
 
@@ -1096,7 +1097,7 @@  static int imx7_csi_init_mbus_fmt(struct v4l2_mbus_framefmt *mbus,
 	mbus->field = field;
 
 	if (code == 0)
-		imx7_csi_enum_mbus_formats(&code, 0, IMX7_CSI_PIXFMT_SEL_YUV);
+		code = IMX7_CSI_DEF_MBUS_CODE;
 
 	lcc = imx7_csi_find_mbus_format(code, IMX7_CSI_PIXFMT_SEL_ANY);
 	if (!lcc)
@@ -1629,7 +1630,7 @@  static int imx7_csi_video_init_format(struct imx7_csi *csi)
 		.pad = IMX7_CSI_PAD_SRC,
 		.which = V4L2_SUBDEV_FORMAT_ACTIVE,
 	};
-	fmt_src.format.code = MEDIA_BUS_FMT_UYVY8_2X8;
+	fmt_src.format.code = IMX7_CSI_DEF_MBUS_CODE;
 	fmt_src.format.width = IMX7_CSI_DEF_PIX_WIDTH;
 	fmt_src.format.height = IMX7_CSI_DEF_PIX_HEIGHT;