diff mbox series

[44/50] staging: media: imx: imx7-media-csi: Simplify default format in try_fmt

Message ID 20220510115859.19777-45-laurent.pinchart@ideasonboard.com
State New
Headers show
Series [01/50] staging: media: imx: imx7-media-csi: Initialize locks early on | expand

Commit Message

Laurent Pinchart May 10, 2022, 11:58 a.m. UTC
When trying a format on the video node, if the requested pixel format
isn't supported, fallback to the default with a simpler logic.

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

Comments

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

Am Dienstag, 10. Mai 2022, 13:58:53 CEST schrieb Laurent Pinchart:
> When trying a format on the video node, if the requested pixel format
> isn't supported, fallback to the default with a simpler logic.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  drivers/staging/media/imx/imx7-media-csi.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/media/imx/imx7-media-csi.c
> b/drivers/staging/media/imx/imx7-media-csi.c index
> bc3a87656117..0fb5e0c03396 100644
> --- a/drivers/staging/media/imx/imx7-media-csi.c
> +++ b/drivers/staging/media/imx/imx7-media-csi.c
> @@ -168,6 +168,7 @@
>  #define IMX7_CSI_VIDEO_EOF_TIMEOUT	2000
> 
>  #define IMX7_CSI_DEF_MBUS_CODE		MEDIA_BUS_FMT_UYVY8_2X8
> +#define IMX7_CSI_DEF_PIX_FORMAT		V4L2_PIX_FMT_UYVY
>  #define IMX7_CSI_DEF_PIX_WIDTH		640
>  #define IMX7_CSI_DEF_PIX_HEIGHT		480
> 
> @@ -1130,7 +1131,7 @@ __imx7_csi_video_try_fmt(struct v4l2_pix_format
> *pixfmt, */
>  	cc = imx7_csi_find_pixel_format(pixfmt->pixelformat);
>  	if (!cc) {
> -		imx7_csi_enum_pixel_formats(&pixfmt->pixelformat, 0, 0);
> +		pixfmt->pixelformat = IMX7_CSI_DEF_PIX_FORMAT;
>  		cc = imx7_csi_find_pixel_format(pixfmt->pixelformat);
>  	}

This change now expects that V4L2_PIX_FMT_UYVY is the 1st entry in 
pixel_formats. Maybe a comment is helpful to indicate 
that.

Regards,
Alexander
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 bc3a87656117..0fb5e0c03396 100644
--- a/drivers/staging/media/imx/imx7-media-csi.c
+++ b/drivers/staging/media/imx/imx7-media-csi.c
@@ -168,6 +168,7 @@ 
 #define IMX7_CSI_VIDEO_EOF_TIMEOUT	2000
 
 #define IMX7_CSI_DEF_MBUS_CODE		MEDIA_BUS_FMT_UYVY8_2X8
+#define IMX7_CSI_DEF_PIX_FORMAT		V4L2_PIX_FMT_UYVY
 #define IMX7_CSI_DEF_PIX_WIDTH		640
 #define IMX7_CSI_DEF_PIX_HEIGHT		480
 
@@ -1130,7 +1131,7 @@  __imx7_csi_video_try_fmt(struct v4l2_pix_format *pixfmt,
 	 */
 	cc = imx7_csi_find_pixel_format(pixfmt->pixelformat);
 	if (!cc) {
-		imx7_csi_enum_pixel_formats(&pixfmt->pixelformat, 0, 0);
+		pixfmt->pixelformat = IMX7_CSI_DEF_PIX_FORMAT;
 		cc = imx7_csi_find_pixel_format(pixfmt->pixelformat);
 	}