All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/4] Fix imx7-media-csi format settings
@ 2023-04-19  7:07 ` Alexander Stein
  0 siblings, 0 replies; 16+ messages in thread
From: Alexander Stein @ 2023-04-19  7:07 UTC (permalink / raw)
  To: Rui Miguel Silva, Laurent Pinchart, Mauro Carvalho Chehab,
	Shawn Guo, Sascha Hauer, Fabio Estevam
  Cc: Alexander Stein, Pengutronix Kernel Team, NXP Linux Team,
	linux-media, linux-arm-kernel

Hi,

v4 also incorporates feedback and improves commit messages a lot.
Patch 3 is simplified now with hardware alignment constraintd being figured
out.

Thanks,
Alexander

Alexander Stein (3):
  media: imx: imx7-media-csi: Get rid of superfluous call to
    imx7_csi_mbus_fmt_to_pix_fmt
  media: imx: imx7-media-csi: Remove incorrect interlacing support
  media: imx: imx7-media-csi: Relax width constraints for non-8bpp
    formats

Laurent Pinchart (1):
  media: imx: imx7-media-csi: Init default format with
    __imx7_csi_video_try_fmt()

 drivers/media/platform/nxp/imx7-media-csi.c | 94 ++++++---------------
 1 file changed, 24 insertions(+), 70 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH v4 0/4] Fix imx7-media-csi format settings
@ 2023-04-19  7:07 ` Alexander Stein
  0 siblings, 0 replies; 16+ messages in thread
From: Alexander Stein @ 2023-04-19  7:07 UTC (permalink / raw)
  To: Rui Miguel Silva, Laurent Pinchart, Mauro Carvalho Chehab,
	Shawn Guo, Sascha Hauer, Fabio Estevam
  Cc: Alexander Stein, Pengutronix Kernel Team, NXP Linux Team,
	linux-media, linux-arm-kernel

Hi,

v4 also incorporates feedback and improves commit messages a lot.
Patch 3 is simplified now with hardware alignment constraintd being figured
out.

Thanks,
Alexander

Alexander Stein (3):
  media: imx: imx7-media-csi: Get rid of superfluous call to
    imx7_csi_mbus_fmt_to_pix_fmt
  media: imx: imx7-media-csi: Remove incorrect interlacing support
  media: imx: imx7-media-csi: Relax width constraints for non-8bpp
    formats

Laurent Pinchart (1):
  media: imx: imx7-media-csi: Init default format with
    __imx7_csi_video_try_fmt()

 drivers/media/platform/nxp/imx7-media-csi.c | 94 ++++++---------------
 1 file changed, 24 insertions(+), 70 deletions(-)

-- 
2.34.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH v4 1/4] media: imx: imx7-media-csi: Get rid of superfluous call to imx7_csi_mbus_fmt_to_pix_fmt
  2023-04-19  7:07 ` Alexander Stein
@ 2023-04-19  7:07   ` Alexander Stein
  -1 siblings, 0 replies; 16+ messages in thread
From: Alexander Stein @ 2023-04-19  7:07 UTC (permalink / raw)
  To: Rui Miguel Silva, Laurent Pinchart, Mauro Carvalho Chehab,
	Shawn Guo, Sascha Hauer, Fabio Estevam
  Cc: Alexander Stein, Pengutronix Kernel Team, NXP Linux Team,
	linux-media, linux-arm-kernel

There is no need to convert input pixformat to mbus_framefmt and back
again. Instead apply pixformat width constrains directly.
Assign compose values before adjusting pixformat height/width.

Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
Changes in v4:
* Added Laurent's r-b

 drivers/media/platform/nxp/imx7-media-csi.c | 22 ++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/drivers/media/platform/nxp/imx7-media-csi.c b/drivers/media/platform/nxp/imx7-media-csi.c
index b701e823436a8..b149374b07ee1 100644
--- a/drivers/media/platform/nxp/imx7-media-csi.c
+++ b/drivers/media/platform/nxp/imx7-media-csi.c
@@ -1145,9 +1145,13 @@ static const struct imx7_csi_pixfmt *
 __imx7_csi_video_try_fmt(struct v4l2_pix_format *pixfmt,
 			 struct v4l2_rect *compose)
 {
-	struct v4l2_mbus_framefmt fmt_src;
 	const struct imx7_csi_pixfmt *cc;
 
+	if (compose) {
+		compose->width = pixfmt->width;
+		compose->height = pixfmt->height;
+	}
+
 	/*
 	 * Find the pixel format, default to the first supported format if not
 	 * found.
@@ -1172,13 +1176,17 @@ __imx7_csi_video_try_fmt(struct v4l2_pix_format *pixfmt,
 		}
 	}
 
-	v4l2_fill_mbus_format(&fmt_src, pixfmt, 0);
-	imx7_csi_mbus_fmt_to_pix_fmt(pixfmt, &fmt_src, cc);
+	/*
+	 * Round up width for minimum burst size.
+	 *
+	 * TODO: Implement configurable stride support, and check what the real
+	 * hardware alignment constraint on the width is.
+	 */
+	v4l_bound_align_image(&pixfmt->width, 1, 0xffff, 8,
+			      &pixfmt->height, 1, 0xffff, 1, 0);
 
-	if (compose) {
-		compose->width = fmt_src.width;
-		compose->height = fmt_src.height;
-	}
+	pixfmt->bytesperline = pixfmt->width * cc->bpp / 8;
+	pixfmt->sizeimage = pixfmt->bytesperline * pixfmt->height;
 
 	return cc;
 }
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v4 1/4] media: imx: imx7-media-csi: Get rid of superfluous call to imx7_csi_mbus_fmt_to_pix_fmt
@ 2023-04-19  7:07   ` Alexander Stein
  0 siblings, 0 replies; 16+ messages in thread
From: Alexander Stein @ 2023-04-19  7:07 UTC (permalink / raw)
  To: Rui Miguel Silva, Laurent Pinchart, Mauro Carvalho Chehab,
	Shawn Guo, Sascha Hauer, Fabio Estevam
  Cc: Alexander Stein, Pengutronix Kernel Team, NXP Linux Team,
	linux-media, linux-arm-kernel

There is no need to convert input pixformat to mbus_framefmt and back
again. Instead apply pixformat width constrains directly.
Assign compose values before adjusting pixformat height/width.

Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
Changes in v4:
* Added Laurent's r-b

 drivers/media/platform/nxp/imx7-media-csi.c | 22 ++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/drivers/media/platform/nxp/imx7-media-csi.c b/drivers/media/platform/nxp/imx7-media-csi.c
index b701e823436a8..b149374b07ee1 100644
--- a/drivers/media/platform/nxp/imx7-media-csi.c
+++ b/drivers/media/platform/nxp/imx7-media-csi.c
@@ -1145,9 +1145,13 @@ static const struct imx7_csi_pixfmt *
 __imx7_csi_video_try_fmt(struct v4l2_pix_format *pixfmt,
 			 struct v4l2_rect *compose)
 {
-	struct v4l2_mbus_framefmt fmt_src;
 	const struct imx7_csi_pixfmt *cc;
 
+	if (compose) {
+		compose->width = pixfmt->width;
+		compose->height = pixfmt->height;
+	}
+
 	/*
 	 * Find the pixel format, default to the first supported format if not
 	 * found.
@@ -1172,13 +1176,17 @@ __imx7_csi_video_try_fmt(struct v4l2_pix_format *pixfmt,
 		}
 	}
 
-	v4l2_fill_mbus_format(&fmt_src, pixfmt, 0);
-	imx7_csi_mbus_fmt_to_pix_fmt(pixfmt, &fmt_src, cc);
+	/*
+	 * Round up width for minimum burst size.
+	 *
+	 * TODO: Implement configurable stride support, and check what the real
+	 * hardware alignment constraint on the width is.
+	 */
+	v4l_bound_align_image(&pixfmt->width, 1, 0xffff, 8,
+			      &pixfmt->height, 1, 0xffff, 1, 0);
 
-	if (compose) {
-		compose->width = fmt_src.width;
-		compose->height = fmt_src.height;
-	}
+	pixfmt->bytesperline = pixfmt->width * cc->bpp / 8;
+	pixfmt->sizeimage = pixfmt->bytesperline * pixfmt->height;
 
 	return cc;
 }
-- 
2.34.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v4 2/4] media: imx: imx7-media-csi: Remove incorrect interlacing support
  2023-04-19  7:07 ` Alexander Stein
@ 2023-04-19  7:07   ` Alexander Stein
  -1 siblings, 0 replies; 16+ messages in thread
From: Alexander Stein @ 2023-04-19  7:07 UTC (permalink / raw)
  To: Rui Miguel Silva, Laurent Pinchart, Mauro Carvalho Chehab,
	Shawn Guo, Sascha Hauer, Fabio Estevam
  Cc: Alexander Stein, Pengutronix Kernel Team, NXP Linux Team,
	linux-media, linux-arm-kernel

The driver doesn't currently support interlacing, but due to legacy
leftovers, it accepts values for the pixel format "field" field other
than V4L2_FIELD_NONE. Fix it by hardcoding V4L2_FIELD_NONE. Proper
interlacing support can be implemented later if desired.

Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
Changes in v4:
* Improve commit message
* Added Laurent's r-b

 drivers/media/platform/nxp/imx7-media-csi.c | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/drivers/media/platform/nxp/imx7-media-csi.c b/drivers/media/platform/nxp/imx7-media-csi.c
index b149374b07ee1..1315f5743b76f 100644
--- a/drivers/media/platform/nxp/imx7-media-csi.c
+++ b/drivers/media/platform/nxp/imx7-media-csi.c
@@ -1162,20 +1162,6 @@ __imx7_csi_video_try_fmt(struct v4l2_pix_format *pixfmt,
 		cc = imx7_csi_find_pixel_format(pixfmt->pixelformat);
 	}
 
-	/* Allow IDMAC interweave but enforce field order from source. */
-	if (V4L2_FIELD_IS_INTERLACED(pixfmt->field)) {
-		switch (pixfmt->field) {
-		case V4L2_FIELD_SEQ_TB:
-			pixfmt->field = V4L2_FIELD_INTERLACED_TB;
-			break;
-		case V4L2_FIELD_SEQ_BT:
-			pixfmt->field = V4L2_FIELD_INTERLACED_BT;
-			break;
-		default:
-			break;
-		}
-	}
-
 	/*
 	 * Round up width for minimum burst size.
 	 *
@@ -1187,6 +1173,7 @@ __imx7_csi_video_try_fmt(struct v4l2_pix_format *pixfmt,
 
 	pixfmt->bytesperline = pixfmt->width * cc->bpp / 8;
 	pixfmt->sizeimage = pixfmt->bytesperline * pixfmt->height;
+	pixfmt->field = V4L2_FIELD_NONE;
 
 	return cc;
 }
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v4 2/4] media: imx: imx7-media-csi: Remove incorrect interlacing support
@ 2023-04-19  7:07   ` Alexander Stein
  0 siblings, 0 replies; 16+ messages in thread
From: Alexander Stein @ 2023-04-19  7:07 UTC (permalink / raw)
  To: Rui Miguel Silva, Laurent Pinchart, Mauro Carvalho Chehab,
	Shawn Guo, Sascha Hauer, Fabio Estevam
  Cc: Alexander Stein, Pengutronix Kernel Team, NXP Linux Team,
	linux-media, linux-arm-kernel

The driver doesn't currently support interlacing, but due to legacy
leftovers, it accepts values for the pixel format "field" field other
than V4L2_FIELD_NONE. Fix it by hardcoding V4L2_FIELD_NONE. Proper
interlacing support can be implemented later if desired.

Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
Changes in v4:
* Improve commit message
* Added Laurent's r-b

 drivers/media/platform/nxp/imx7-media-csi.c | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/drivers/media/platform/nxp/imx7-media-csi.c b/drivers/media/platform/nxp/imx7-media-csi.c
index b149374b07ee1..1315f5743b76f 100644
--- a/drivers/media/platform/nxp/imx7-media-csi.c
+++ b/drivers/media/platform/nxp/imx7-media-csi.c
@@ -1162,20 +1162,6 @@ __imx7_csi_video_try_fmt(struct v4l2_pix_format *pixfmt,
 		cc = imx7_csi_find_pixel_format(pixfmt->pixelformat);
 	}
 
-	/* Allow IDMAC interweave but enforce field order from source. */
-	if (V4L2_FIELD_IS_INTERLACED(pixfmt->field)) {
-		switch (pixfmt->field) {
-		case V4L2_FIELD_SEQ_TB:
-			pixfmt->field = V4L2_FIELD_INTERLACED_TB;
-			break;
-		case V4L2_FIELD_SEQ_BT:
-			pixfmt->field = V4L2_FIELD_INTERLACED_BT;
-			break;
-		default:
-			break;
-		}
-	}
-
 	/*
 	 * Round up width for minimum burst size.
 	 *
@@ -1187,6 +1173,7 @@ __imx7_csi_video_try_fmt(struct v4l2_pix_format *pixfmt,
 
 	pixfmt->bytesperline = pixfmt->width * cc->bpp / 8;
 	pixfmt->sizeimage = pixfmt->bytesperline * pixfmt->height;
+	pixfmt->field = V4L2_FIELD_NONE;
 
 	return cc;
 }
-- 
2.34.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v4 3/4] media: imx: imx7-media-csi: Relax width constraints for non-8bpp formats
  2023-04-19  7:07 ` Alexander Stein
@ 2023-04-19  7:07   ` Alexander Stein
  -1 siblings, 0 replies; 16+ messages in thread
From: Alexander Stein @ 2023-04-19  7:07 UTC (permalink / raw)
  To: Rui Miguel Silva, Laurent Pinchart, Mauro Carvalho Chehab,
	Shawn Guo, Sascha Hauer, Fabio Estevam
  Cc: Alexander Stein, Pengutronix Kernel Team, NXP Linux Team,
	linux-media, linux-arm-kernel

The driver unconditionally aligns the image width to multiples of 8
pixels. The real alignment constraint is 8 bytes, as indicated by the
CSI_IMAG_PARA.IMAGE_WIDTH documentation that calls for 8 pixel alignment
for 8bpp formats and 4 pixel alignment for other formats.

Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
---
Changes in v4:
* Improve commit message
* Simplify walign calculation
* Remove comment on hardware alignment constraints

 drivers/media/platform/nxp/imx7-media-csi.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/media/platform/nxp/imx7-media-csi.c b/drivers/media/platform/nxp/imx7-media-csi.c
index 1315f5743b76f..e6abbfbc5c129 100644
--- a/drivers/media/platform/nxp/imx7-media-csi.c
+++ b/drivers/media/platform/nxp/imx7-media-csi.c
@@ -1146,6 +1146,7 @@ __imx7_csi_video_try_fmt(struct v4l2_pix_format *pixfmt,
 			 struct v4l2_rect *compose)
 {
 	const struct imx7_csi_pixfmt *cc;
+	u32 walign;
 
 	if (compose) {
 		compose->width = pixfmt->width;
@@ -1163,12 +1164,13 @@ __imx7_csi_video_try_fmt(struct v4l2_pix_format *pixfmt,
 	}
 
 	/*
-	 * Round up width for minimum burst size.
+	 * The width alignment is 8 bytes as indicated by the
+	 * CSI_IMAG_PARA.IMAGE_WIDTH documentation. Convert it to pixels.
 	 *
-	 * TODO: Implement configurable stride support, and check what the real
-	 * hardware alignment constraint on the width is.
+	 * TODO: Implement configurable stride support.
 	 */
-	v4l_bound_align_image(&pixfmt->width, 1, 0xffff, 8,
+	walign = 8 * 8 / cc->bpp;
+	v4l_bound_align_image(&pixfmt->width, 1, 0xffff, walign,
 			      &pixfmt->height, 1, 0xffff, 1, 0);
 
 	pixfmt->bytesperline = pixfmt->width * cc->bpp / 8;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v4 3/4] media: imx: imx7-media-csi: Relax width constraints for non-8bpp formats
@ 2023-04-19  7:07   ` Alexander Stein
  0 siblings, 0 replies; 16+ messages in thread
From: Alexander Stein @ 2023-04-19  7:07 UTC (permalink / raw)
  To: Rui Miguel Silva, Laurent Pinchart, Mauro Carvalho Chehab,
	Shawn Guo, Sascha Hauer, Fabio Estevam
  Cc: Alexander Stein, Pengutronix Kernel Team, NXP Linux Team,
	linux-media, linux-arm-kernel

The driver unconditionally aligns the image width to multiples of 8
pixels. The real alignment constraint is 8 bytes, as indicated by the
CSI_IMAG_PARA.IMAGE_WIDTH documentation that calls for 8 pixel alignment
for 8bpp formats and 4 pixel alignment for other formats.

Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
---
Changes in v4:
* Improve commit message
* Simplify walign calculation
* Remove comment on hardware alignment constraints

 drivers/media/platform/nxp/imx7-media-csi.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/media/platform/nxp/imx7-media-csi.c b/drivers/media/platform/nxp/imx7-media-csi.c
index 1315f5743b76f..e6abbfbc5c129 100644
--- a/drivers/media/platform/nxp/imx7-media-csi.c
+++ b/drivers/media/platform/nxp/imx7-media-csi.c
@@ -1146,6 +1146,7 @@ __imx7_csi_video_try_fmt(struct v4l2_pix_format *pixfmt,
 			 struct v4l2_rect *compose)
 {
 	const struct imx7_csi_pixfmt *cc;
+	u32 walign;
 
 	if (compose) {
 		compose->width = pixfmt->width;
@@ -1163,12 +1164,13 @@ __imx7_csi_video_try_fmt(struct v4l2_pix_format *pixfmt,
 	}
 
 	/*
-	 * Round up width for minimum burst size.
+	 * The width alignment is 8 bytes as indicated by the
+	 * CSI_IMAG_PARA.IMAGE_WIDTH documentation. Convert it to pixels.
 	 *
-	 * TODO: Implement configurable stride support, and check what the real
-	 * hardware alignment constraint on the width is.
+	 * TODO: Implement configurable stride support.
 	 */
-	v4l_bound_align_image(&pixfmt->width, 1, 0xffff, 8,
+	walign = 8 * 8 / cc->bpp;
+	v4l_bound_align_image(&pixfmt->width, 1, 0xffff, walign,
 			      &pixfmt->height, 1, 0xffff, 1, 0);
 
 	pixfmt->bytesperline = pixfmt->width * cc->bpp / 8;
-- 
2.34.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v4 4/4] media: imx: imx7-media-csi: Init default format with __imx7_csi_video_try_fmt()
  2023-04-19  7:07 ` Alexander Stein
@ 2023-04-19  7:07   ` Alexander Stein
  -1 siblings, 0 replies; 16+ messages in thread
From: Alexander Stein @ 2023-04-19  7:07 UTC (permalink / raw)
  To: Rui Miguel Silva, Laurent Pinchart, Mauro Carvalho Chehab,
	Shawn Guo, Sascha Hauer, Fabio Estevam
  Cc: Pengutronix Kernel Team, NXP Linux Team, linux-media,
	linux-arm-kernel, Alexander Stein

From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Use the __imx7_csi_video_try_fmt() helper function to initialize the
default format at probe time. This improves consistency by using the
same code path for both default initialization and validation at
runtime, and allows dropping the now unused imx7_csi_find_pixel_format()
function.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
---
Changes in v4:
* None

 drivers/media/platform/nxp/imx7-media-csi.c | 55 +++------------------
 1 file changed, 6 insertions(+), 49 deletions(-)

diff --git a/drivers/media/platform/nxp/imx7-media-csi.c b/drivers/media/platform/nxp/imx7-media-csi.c
index e6abbfbc5c129..0bd2613b9320f 100644
--- a/drivers/media/platform/nxp/imx7-media-csi.c
+++ b/drivers/media/platform/nxp/imx7-media-csi.c
@@ -1014,39 +1014,6 @@ static int imx7_csi_enum_mbus_formats(u32 *code, u32 index)
 	return -EINVAL;
 }
 
-static int imx7_csi_mbus_fmt_to_pix_fmt(struct v4l2_pix_format *pix,
-					const struct v4l2_mbus_framefmt *mbus,
-					const struct imx7_csi_pixfmt *cc)
-{
-	u32 width;
-	u32 stride;
-
-	if (!cc) {
-		cc = imx7_csi_find_mbus_format(mbus->code);
-		if (!cc)
-			return -EINVAL;
-	}
-
-	/* Round up width for minimum burst size */
-	width = round_up(mbus->width, 8);
-
-	/* Round up stride for IDMAC line start address alignment */
-	stride = round_up((width * cc->bpp) >> 3, 8);
-
-	pix->width = width;
-	pix->height = mbus->height;
-	pix->pixelformat = cc->fourcc;
-	pix->colorspace = mbus->colorspace;
-	pix->xfer_func = mbus->xfer_func;
-	pix->ycbcr_enc = mbus->ycbcr_enc;
-	pix->quantization = mbus->quantization;
-	pix->field = mbus->field;
-	pix->bytesperline = stride;
-	pix->sizeimage = stride * pix->height;
-
-	return 0;
-}
-
 /* -----------------------------------------------------------------------------
  * Video Capture Device - IOCTLs
  */
@@ -1603,22 +1570,14 @@ static struct imx7_csi_vb2_buffer *imx7_csi_video_next_buf(struct imx7_csi *csi)
 	return buf;
 }
 
-static int imx7_csi_video_init_format(struct imx7_csi *csi)
+static void imx7_csi_video_init_format(struct imx7_csi *csi)
 {
-	struct v4l2_mbus_framefmt format = { };
-
-	format.code = IMX7_CSI_DEF_MBUS_CODE;
-	format.width = IMX7_CSI_DEF_PIX_WIDTH;
-	format.height = IMX7_CSI_DEF_PIX_HEIGHT;
-	format.field = V4L2_FIELD_NONE;
+	struct v4l2_pix_format *pixfmt = &csi->vdev_fmt;
 
-	imx7_csi_mbus_fmt_to_pix_fmt(&csi->vdev_fmt, &format, NULL);
-	csi->vdev_compose.width = format.width;
-	csi->vdev_compose.height = format.height;
+	pixfmt->width = IMX7_CSI_DEF_PIX_WIDTH;
+	pixfmt->height = IMX7_CSI_DEF_PIX_HEIGHT;
 
-	csi->vdev_cc = imx7_csi_find_pixel_format(csi->vdev_fmt.pixelformat);
-
-	return 0;
+	csi->vdev_cc = __imx7_csi_video_try_fmt(pixfmt, &csi->vdev_compose);
 }
 
 static int imx7_csi_video_register(struct imx7_csi *csi)
@@ -1631,9 +1590,7 @@ static int imx7_csi_video_register(struct imx7_csi *csi)
 	vdev->v4l2_dev = v4l2_dev;
 
 	/* Initialize the default format and compose rectangle. */
-	ret = imx7_csi_video_init_format(csi);
-	if (ret < 0)
-		return ret;
+	imx7_csi_video_init_format(csi);
 
 	/* Register the video device. */
 	ret = video_register_device(vdev, VFL_TYPE_VIDEO, -1);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v4 4/4] media: imx: imx7-media-csi: Init default format with __imx7_csi_video_try_fmt()
@ 2023-04-19  7:07   ` Alexander Stein
  0 siblings, 0 replies; 16+ messages in thread
From: Alexander Stein @ 2023-04-19  7:07 UTC (permalink / raw)
  To: Rui Miguel Silva, Laurent Pinchart, Mauro Carvalho Chehab,
	Shawn Guo, Sascha Hauer, Fabio Estevam
  Cc: Pengutronix Kernel Team, NXP Linux Team, linux-media,
	linux-arm-kernel, Alexander Stein

From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Use the __imx7_csi_video_try_fmt() helper function to initialize the
default format at probe time. This improves consistency by using the
same code path for both default initialization and validation at
runtime, and allows dropping the now unused imx7_csi_find_pixel_format()
function.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
---
Changes in v4:
* None

 drivers/media/platform/nxp/imx7-media-csi.c | 55 +++------------------
 1 file changed, 6 insertions(+), 49 deletions(-)

diff --git a/drivers/media/platform/nxp/imx7-media-csi.c b/drivers/media/platform/nxp/imx7-media-csi.c
index e6abbfbc5c129..0bd2613b9320f 100644
--- a/drivers/media/platform/nxp/imx7-media-csi.c
+++ b/drivers/media/platform/nxp/imx7-media-csi.c
@@ -1014,39 +1014,6 @@ static int imx7_csi_enum_mbus_formats(u32 *code, u32 index)
 	return -EINVAL;
 }
 
-static int imx7_csi_mbus_fmt_to_pix_fmt(struct v4l2_pix_format *pix,
-					const struct v4l2_mbus_framefmt *mbus,
-					const struct imx7_csi_pixfmt *cc)
-{
-	u32 width;
-	u32 stride;
-
-	if (!cc) {
-		cc = imx7_csi_find_mbus_format(mbus->code);
-		if (!cc)
-			return -EINVAL;
-	}
-
-	/* Round up width for minimum burst size */
-	width = round_up(mbus->width, 8);
-
-	/* Round up stride for IDMAC line start address alignment */
-	stride = round_up((width * cc->bpp) >> 3, 8);
-
-	pix->width = width;
-	pix->height = mbus->height;
-	pix->pixelformat = cc->fourcc;
-	pix->colorspace = mbus->colorspace;
-	pix->xfer_func = mbus->xfer_func;
-	pix->ycbcr_enc = mbus->ycbcr_enc;
-	pix->quantization = mbus->quantization;
-	pix->field = mbus->field;
-	pix->bytesperline = stride;
-	pix->sizeimage = stride * pix->height;
-
-	return 0;
-}
-
 /* -----------------------------------------------------------------------------
  * Video Capture Device - IOCTLs
  */
@@ -1603,22 +1570,14 @@ static struct imx7_csi_vb2_buffer *imx7_csi_video_next_buf(struct imx7_csi *csi)
 	return buf;
 }
 
-static int imx7_csi_video_init_format(struct imx7_csi *csi)
+static void imx7_csi_video_init_format(struct imx7_csi *csi)
 {
-	struct v4l2_mbus_framefmt format = { };
-
-	format.code = IMX7_CSI_DEF_MBUS_CODE;
-	format.width = IMX7_CSI_DEF_PIX_WIDTH;
-	format.height = IMX7_CSI_DEF_PIX_HEIGHT;
-	format.field = V4L2_FIELD_NONE;
+	struct v4l2_pix_format *pixfmt = &csi->vdev_fmt;
 
-	imx7_csi_mbus_fmt_to_pix_fmt(&csi->vdev_fmt, &format, NULL);
-	csi->vdev_compose.width = format.width;
-	csi->vdev_compose.height = format.height;
+	pixfmt->width = IMX7_CSI_DEF_PIX_WIDTH;
+	pixfmt->height = IMX7_CSI_DEF_PIX_HEIGHT;
 
-	csi->vdev_cc = imx7_csi_find_pixel_format(csi->vdev_fmt.pixelformat);
-
-	return 0;
+	csi->vdev_cc = __imx7_csi_video_try_fmt(pixfmt, &csi->vdev_compose);
 }
 
 static int imx7_csi_video_register(struct imx7_csi *csi)
@@ -1631,9 +1590,7 @@ static int imx7_csi_video_register(struct imx7_csi *csi)
 	vdev->v4l2_dev = v4l2_dev;
 
 	/* Initialize the default format and compose rectangle. */
-	ret = imx7_csi_video_init_format(csi);
-	if (ret < 0)
-		return ret;
+	imx7_csi_video_init_format(csi);
 
 	/* Register the video device. */
 	ret = video_register_device(vdev, VFL_TYPE_VIDEO, -1);
-- 
2.34.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH v4 3/4] media: imx: imx7-media-csi: Relax width constraints for non-8bpp formats
  2023-04-19  7:07   ` Alexander Stein
@ 2023-04-20 10:33     ` Laurent Pinchart
  -1 siblings, 0 replies; 16+ messages in thread
From: Laurent Pinchart @ 2023-04-20 10:33 UTC (permalink / raw)
  To: Alexander Stein
  Cc: Rui Miguel Silva, Mauro Carvalho Chehab, Shawn Guo, Sascha Hauer,
	Fabio Estevam, Pengutronix Kernel Team, NXP Linux Team,
	linux-media, linux-arm-kernel

Hi Alexander,

Thank you for the patch.

On Wed, Apr 19, 2023 at 09:07:11AM +0200, Alexander Stein wrote:
> The driver unconditionally aligns the image width to multiples of 8
> pixels. The real alignment constraint is 8 bytes, as indicated by the
> CSI_IMAG_PARA.IMAGE_WIDTH documentation that calls for 8 pixel alignment
> for 8bpp formats and 4 pixel alignment for other formats.
> 
> Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
> Changes in v4:
> * Improve commit message
> * Simplify walign calculation
> * Remove comment on hardware alignment constraints
> 
>  drivers/media/platform/nxp/imx7-media-csi.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/media/platform/nxp/imx7-media-csi.c b/drivers/media/platform/nxp/imx7-media-csi.c
> index 1315f5743b76f..e6abbfbc5c129 100644
> --- a/drivers/media/platform/nxp/imx7-media-csi.c
> +++ b/drivers/media/platform/nxp/imx7-media-csi.c
> @@ -1146,6 +1146,7 @@ __imx7_csi_video_try_fmt(struct v4l2_pix_format *pixfmt,
>  			 struct v4l2_rect *compose)
>  {
>  	const struct imx7_csi_pixfmt *cc;
> +	u32 walign;
>  
>  	if (compose) {
>  		compose->width = pixfmt->width;
> @@ -1163,12 +1164,13 @@ __imx7_csi_video_try_fmt(struct v4l2_pix_format *pixfmt,
>  	}
>  
>  	/*
> -	 * Round up width for minimum burst size.
> +	 * The width alignment is 8 bytes as indicated by the
> +	 * CSI_IMAG_PARA.IMAGE_WIDTH documentation. Convert it to pixels.
>  	 *
> -	 * TODO: Implement configurable stride support, and check what the real
> -	 * hardware alignment constraint on the width is.
> +	 * TODO: Implement configurable stride support.
>  	 */
> -	v4l_bound_align_image(&pixfmt->width, 1, 0xffff, 8,
> +	walign = 8 * 8 / cc->bpp;
> +	v4l_bound_align_image(&pixfmt->width, 1, 0xffff, walign,
>  			      &pixfmt->height, 1, 0xffff, 1, 0);
>  
>  	pixfmt->bytesperline = pixfmt->width * cc->bpp / 8;

-- 
Regards,

Laurent Pinchart

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v4 3/4] media: imx: imx7-media-csi: Relax width constraints for non-8bpp formats
@ 2023-04-20 10:33     ` Laurent Pinchart
  0 siblings, 0 replies; 16+ messages in thread
From: Laurent Pinchart @ 2023-04-20 10:33 UTC (permalink / raw)
  To: Alexander Stein
  Cc: Rui Miguel Silva, Mauro Carvalho Chehab, Shawn Guo, Sascha Hauer,
	Fabio Estevam, Pengutronix Kernel Team, NXP Linux Team,
	linux-media, linux-arm-kernel

Hi Alexander,

Thank you for the patch.

On Wed, Apr 19, 2023 at 09:07:11AM +0200, Alexander Stein wrote:
> The driver unconditionally aligns the image width to multiples of 8
> pixels. The real alignment constraint is 8 bytes, as indicated by the
> CSI_IMAG_PARA.IMAGE_WIDTH documentation that calls for 8 pixel alignment
> for 8bpp formats and 4 pixel alignment for other formats.
> 
> Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
> Changes in v4:
> * Improve commit message
> * Simplify walign calculation
> * Remove comment on hardware alignment constraints
> 
>  drivers/media/platform/nxp/imx7-media-csi.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/media/platform/nxp/imx7-media-csi.c b/drivers/media/platform/nxp/imx7-media-csi.c
> index 1315f5743b76f..e6abbfbc5c129 100644
> --- a/drivers/media/platform/nxp/imx7-media-csi.c
> +++ b/drivers/media/platform/nxp/imx7-media-csi.c
> @@ -1146,6 +1146,7 @@ __imx7_csi_video_try_fmt(struct v4l2_pix_format *pixfmt,
>  			 struct v4l2_rect *compose)
>  {
>  	const struct imx7_csi_pixfmt *cc;
> +	u32 walign;
>  
>  	if (compose) {
>  		compose->width = pixfmt->width;
> @@ -1163,12 +1164,13 @@ __imx7_csi_video_try_fmt(struct v4l2_pix_format *pixfmt,
>  	}
>  
>  	/*
> -	 * Round up width for minimum burst size.
> +	 * The width alignment is 8 bytes as indicated by the
> +	 * CSI_IMAG_PARA.IMAGE_WIDTH documentation. Convert it to pixels.
>  	 *
> -	 * TODO: Implement configurable stride support, and check what the real
> -	 * hardware alignment constraint on the width is.
> +	 * TODO: Implement configurable stride support.
>  	 */
> -	v4l_bound_align_image(&pixfmt->width, 1, 0xffff, 8,
> +	walign = 8 * 8 / cc->bpp;
> +	v4l_bound_align_image(&pixfmt->width, 1, 0xffff, walign,
>  			      &pixfmt->height, 1, 0xffff, 1, 0);
>  
>  	pixfmt->bytesperline = pixfmt->width * cc->bpp / 8;

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v4 0/4] Fix imx7-media-csi format settings
  2023-04-19  7:07 ` Alexander Stein
@ 2023-05-24 13:02   ` Alexander Stein
  -1 siblings, 0 replies; 16+ messages in thread
From: Alexander Stein @ 2023-05-24 13:02 UTC (permalink / raw)
  To: Rui Miguel Silva, Laurent Pinchart, Mauro Carvalho Chehab,
	Shawn Guo, Sascha Hauer, Fabio Estevam
  Cc: Pengutronix Kernel Team, NXP Linux Team, linux-media, linux-arm-kernel

Hello,

Am Mittwoch, 19. April 2023, 09:07:08 CEST schrieb Alexander Stein:
> Hi,
> 
> v4 also incorporates feedback and improves commit messages a lot.
> Patch 3 is simplified now with hardware alignment constraintd being figured
> out.

Ping, any more reviews?

Thanks
Alexander

> Thanks,
> Alexander
> 
> Alexander Stein (3):
>   media: imx: imx7-media-csi: Get rid of superfluous call to
>     imx7_csi_mbus_fmt_to_pix_fmt
>   media: imx: imx7-media-csi: Remove incorrect interlacing support
>   media: imx: imx7-media-csi: Relax width constraints for non-8bpp
>     formats
> 
> Laurent Pinchart (1):
>   media: imx: imx7-media-csi: Init default format with
>     __imx7_csi_video_try_fmt()
> 
>  drivers/media/platform/nxp/imx7-media-csi.c | 94 ++++++---------------
>  1 file changed, 24 insertions(+), 70 deletions(-)


-- 
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
http://www.tq-group.com/



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v4 0/4] Fix imx7-media-csi format settings
@ 2023-05-24 13:02   ` Alexander Stein
  0 siblings, 0 replies; 16+ messages in thread
From: Alexander Stein @ 2023-05-24 13:02 UTC (permalink / raw)
  To: Rui Miguel Silva, Laurent Pinchart, Mauro Carvalho Chehab,
	Shawn Guo, Sascha Hauer, Fabio Estevam
  Cc: Pengutronix Kernel Team, NXP Linux Team, linux-media, linux-arm-kernel

Hello,

Am Mittwoch, 19. April 2023, 09:07:08 CEST schrieb Alexander Stein:
> Hi,
> 
> v4 also incorporates feedback and improves commit messages a lot.
> Patch 3 is simplified now with hardware alignment constraintd being figured
> out.

Ping, any more reviews?

Thanks
Alexander

> Thanks,
> Alexander
> 
> Alexander Stein (3):
>   media: imx: imx7-media-csi: Get rid of superfluous call to
>     imx7_csi_mbus_fmt_to_pix_fmt
>   media: imx: imx7-media-csi: Remove incorrect interlacing support
>   media: imx: imx7-media-csi: Relax width constraints for non-8bpp
>     formats
> 
> Laurent Pinchart (1):
>   media: imx: imx7-media-csi: Init default format with
>     __imx7_csi_video_try_fmt()
> 
>  drivers/media/platform/nxp/imx7-media-csi.c | 94 ++++++---------------
>  1 file changed, 24 insertions(+), 70 deletions(-)


-- 
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
http://www.tq-group.com/



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v4 0/4] Fix imx7-media-csi format settings
  2023-05-24 13:02   ` Alexander Stein
@ 2023-05-24 15:39     ` Rui Miguel Silva
  -1 siblings, 0 replies; 16+ messages in thread
From: Rui Miguel Silva @ 2023-05-24 15:39 UTC (permalink / raw)
  To: Alexander Stein, Laurent Pinchart, Mauro Carvalho Chehab,
	Shawn Guo, Sascha Hauer, Fabio Estevam
  Cc: Pengutronix Kernel Team, NXP Linux Team, linux-media, linux-arm-kernel

Hi Alexander,

Alexander Stein <alexander.stein@ew.tq-group.com> writes:

> Hello,
>
> Am Mittwoch, 19. April 2023, 09:07:08 CEST schrieb Alexander Stein:
>> Hi,
>> 
>> v4 also incorporates feedback and improves commit messages a lot.
>> Patch 3 is simplified now with hardware alignment constraintd being figured
>> out.
>
> Ping, any more reviews?

The all series LGTM, FWIW:
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>

I think Laurent can pull request this on his tree.

Cheers,
  Rui
>
> Thanks
> Alexander
>
>> Thanks,
>> Alexander
>> 
>> Alexander Stein (3):
>>   media: imx: imx7-media-csi: Get rid of superfluous call to
>>     imx7_csi_mbus_fmt_to_pix_fmt
>>   media: imx: imx7-media-csi: Remove incorrect interlacing support
>>   media: imx: imx7-media-csi: Relax width constraints for non-8bpp
>>     formats
>> 
>> Laurent Pinchart (1):
>>   media: imx: imx7-media-csi: Init default format with
>>     __imx7_csi_video_try_fmt()
>> 
>>  drivers/media/platform/nxp/imx7-media-csi.c | 94 ++++++---------------
>>  1 file changed, 24 insertions(+), 70 deletions(-)
>
>
> -- 
> TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
> Amtsgericht München, HRB 105018
> Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
> http://www.tq-group.com/

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v4 0/4] Fix imx7-media-csi format settings
@ 2023-05-24 15:39     ` Rui Miguel Silva
  0 siblings, 0 replies; 16+ messages in thread
From: Rui Miguel Silva @ 2023-05-24 15:39 UTC (permalink / raw)
  To: Alexander Stein, Laurent Pinchart, Mauro Carvalho Chehab,
	Shawn Guo, Sascha Hauer, Fabio Estevam
  Cc: Pengutronix Kernel Team, NXP Linux Team, linux-media, linux-arm-kernel

Hi Alexander,

Alexander Stein <alexander.stein@ew.tq-group.com> writes:

> Hello,
>
> Am Mittwoch, 19. April 2023, 09:07:08 CEST schrieb Alexander Stein:
>> Hi,
>> 
>> v4 also incorporates feedback and improves commit messages a lot.
>> Patch 3 is simplified now with hardware alignment constraintd being figured
>> out.
>
> Ping, any more reviews?

The all series LGTM, FWIW:
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>

I think Laurent can pull request this on his tree.

Cheers,
  Rui
>
> Thanks
> Alexander
>
>> Thanks,
>> Alexander
>> 
>> Alexander Stein (3):
>>   media: imx: imx7-media-csi: Get rid of superfluous call to
>>     imx7_csi_mbus_fmt_to_pix_fmt
>>   media: imx: imx7-media-csi: Remove incorrect interlacing support
>>   media: imx: imx7-media-csi: Relax width constraints for non-8bpp
>>     formats
>> 
>> Laurent Pinchart (1):
>>   media: imx: imx7-media-csi: Init default format with
>>     __imx7_csi_video_try_fmt()
>> 
>>  drivers/media/platform/nxp/imx7-media-csi.c | 94 ++++++---------------
>>  1 file changed, 24 insertions(+), 70 deletions(-)
>
>
> -- 
> TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
> Amtsgericht München, HRB 105018
> Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
> http://www.tq-group.com/

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2023-05-24 16:50 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-19  7:07 [PATCH v4 0/4] Fix imx7-media-csi format settings Alexander Stein
2023-04-19  7:07 ` Alexander Stein
2023-04-19  7:07 ` [PATCH v4 1/4] media: imx: imx7-media-csi: Get rid of superfluous call to imx7_csi_mbus_fmt_to_pix_fmt Alexander Stein
2023-04-19  7:07   ` Alexander Stein
2023-04-19  7:07 ` [PATCH v4 2/4] media: imx: imx7-media-csi: Remove incorrect interlacing support Alexander Stein
2023-04-19  7:07   ` Alexander Stein
2023-04-19  7:07 ` [PATCH v4 3/4] media: imx: imx7-media-csi: Relax width constraints for non-8bpp formats Alexander Stein
2023-04-19  7:07   ` Alexander Stein
2023-04-20 10:33   ` Laurent Pinchart
2023-04-20 10:33     ` Laurent Pinchart
2023-04-19  7:07 ` [PATCH v4 4/4] media: imx: imx7-media-csi: Init default format with __imx7_csi_video_try_fmt() Alexander Stein
2023-04-19  7:07   ` Alexander Stein
2023-05-24 13:02 ` [PATCH v4 0/4] Fix imx7-media-csi format settings Alexander Stein
2023-05-24 13:02   ` Alexander Stein
2023-05-24 15:39   ` Rui Miguel Silva
2023-05-24 15:39     ` Rui Miguel Silva

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.