All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Alexander Stein <alexander.stein@ew.tq-group.com>
Cc: Rui Miguel Silva <rmfrfs@gmail.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Shawn Guo <shawnguo@kernel.org>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	Fabio Estevam <festevam@gmail.com>,
	Pengutronix Kernel Team <kernel@pengutronix.de>,
	NXP Linux Team <linux-imx@nxp.com>,
	linux-media@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v2 1/3] media: imx: imx7-media-csi: Get rid of superfluous call to imx7_csi_mbus_fmt_to_pix_fmt
Date: Tue, 18 Apr 2023 12:27:13 +0300	[thread overview]
Message-ID: <20230418092713.GA26319@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20230418071439.197735-2-alexander.stein@ew.tq-group.com>

Hi Alexander,

Thank you for the patch.

On Tue, Apr 18, 2023 at 09:14:37AM +0200, Alexander Stein wrote:
> There is no need to convert input pixformat to mbus_framefmt and back
> again. Instead apply pixformat width contrains directly.
> 
> Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
> ---
>  drivers/media/platform/nxp/imx7-media-csi.c | 14 +++++++++-----
>  1 file changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/media/platform/nxp/imx7-media-csi.c b/drivers/media/platform/nxp/imx7-media-csi.c
> index b701e823436a8..bd649fd9166fd 100644
> --- a/drivers/media/platform/nxp/imx7-media-csi.c
> +++ b/drivers/media/platform/nxp/imx7-media-csi.c
> @@ -1145,8 +1145,8 @@ 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;
> +	u32 stride;
>  
>  	/*
>  	 * Find the pixel format, default to the first supported format if not
> @@ -1172,12 +1172,16 @@ __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);

Could you please keep the comment from imx7_csi_mbus_fmt_to_pix_fmt()
here, to indicate where the alignment comes from ?

	/* Round up width for minimum burst size */

We should likely revisit this in the future, I don't think the alignment
is actually needed. This could be recorded already:

	/*
	 * 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);
> +
> +	stride = round_up((pixfmt->width * cc->bpp) / 8, 8);

You can drop the round_up(), as pixfmt->width is now a multiple of 8, so

	pixfmt->bytesperline = pixfmt->width * cc->bpp / 8;

> +	pixfmt->bytesperline = stride;
> +	pixfmt->sizeimage = stride * pixfmt->height;
>  
>  	if (compose) {
> -		compose->width = fmt_src.width;
> -		compose->height = fmt_src.height;
> +		compose->width = pixfmt->width;

This is a change of behaviour, compose->width used to be set to the
unaligned width.

> +		compose->height = pixfmt->height;
>  	}
>  
>  	return cc;

-- 
Regards,

Laurent Pinchart

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

WARNING: multiple messages have this Message-ID (diff)
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Alexander Stein <alexander.stein@ew.tq-group.com>
Cc: Rui Miguel Silva <rmfrfs@gmail.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Shawn Guo <shawnguo@kernel.org>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	Fabio Estevam <festevam@gmail.com>,
	Pengutronix Kernel Team <kernel@pengutronix.de>,
	NXP Linux Team <linux-imx@nxp.com>,
	linux-media@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v2 1/3] media: imx: imx7-media-csi: Get rid of superfluous call to imx7_csi_mbus_fmt_to_pix_fmt
Date: Tue, 18 Apr 2023 12:27:13 +0300	[thread overview]
Message-ID: <20230418092713.GA26319@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20230418071439.197735-2-alexander.stein@ew.tq-group.com>

Hi Alexander,

Thank you for the patch.

On Tue, Apr 18, 2023 at 09:14:37AM +0200, Alexander Stein wrote:
> There is no need to convert input pixformat to mbus_framefmt and back
> again. Instead apply pixformat width contrains directly.
> 
> Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
> ---
>  drivers/media/platform/nxp/imx7-media-csi.c | 14 +++++++++-----
>  1 file changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/media/platform/nxp/imx7-media-csi.c b/drivers/media/platform/nxp/imx7-media-csi.c
> index b701e823436a8..bd649fd9166fd 100644
> --- a/drivers/media/platform/nxp/imx7-media-csi.c
> +++ b/drivers/media/platform/nxp/imx7-media-csi.c
> @@ -1145,8 +1145,8 @@ 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;
> +	u32 stride;
>  
>  	/*
>  	 * Find the pixel format, default to the first supported format if not
> @@ -1172,12 +1172,16 @@ __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);

Could you please keep the comment from imx7_csi_mbus_fmt_to_pix_fmt()
here, to indicate where the alignment comes from ?

	/* Round up width for minimum burst size */

We should likely revisit this in the future, I don't think the alignment
is actually needed. This could be recorded already:

	/*
	 * 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);
> +
> +	stride = round_up((pixfmt->width * cc->bpp) / 8, 8);

You can drop the round_up(), as pixfmt->width is now a multiple of 8, so

	pixfmt->bytesperline = pixfmt->width * cc->bpp / 8;

> +	pixfmt->bytesperline = stride;
> +	pixfmt->sizeimage = stride * pixfmt->height;
>  
>  	if (compose) {
> -		compose->width = fmt_src.width;
> -		compose->height = fmt_src.height;
> +		compose->width = pixfmt->width;

This is a change of behaviour, compose->width used to be set to the
unaligned width.

> +		compose->height = pixfmt->height;
>  	}
>  
>  	return cc;

-- 
Regards,

Laurent Pinchart

  reply	other threads:[~2023-04-18  9:28 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-18  7:14 [PATCH v2 0/3] Fix imx7-media-csi format settings Alexander Stein
2023-04-18  7:14 ` Alexander Stein
2023-04-18  7:14 ` [PATCH v2 1/3] media: imx: imx7-media-csi: Get rid of superfluous call to imx7_csi_mbus_fmt_to_pix_fmt Alexander Stein
2023-04-18  7:14   ` Alexander Stein
2023-04-18  9:27   ` Laurent Pinchart [this message]
2023-04-18  9:27     ` Laurent Pinchart
2023-04-18 10:00     ` Alexander Stein
2023-04-18 10:00       ` Alexander Stein
2023-04-18 10:05       ` Laurent Pinchart
2023-04-18 10:05         ` Laurent Pinchart
2023-04-18 10:08         ` Alexander Stein
2023-04-18 10:08           ` Alexander Stein
2023-04-18 10:18           ` Laurent Pinchart
2023-04-18 10:18             ` Laurent Pinchart
2023-04-18  7:14 ` [PATCH v2 2/3] media: imx: imx7-media-csi: Remove interlave fields Alexander Stein
2023-04-18  7:14   ` Alexander Stein
2023-04-18  9:34   ` Laurent Pinchart
2023-04-18  9:34     ` Laurent Pinchart
2023-04-18  7:14 ` [PATCH v2 3/3] media: imx: imx7-media-csi: Lift width constraints for 8bpp formats Alexander Stein
2023-04-18  7:14   ` Alexander Stein
2023-04-18  9:37   ` Laurent Pinchart
2023-04-18  9:37     ` Laurent Pinchart
2023-04-18 10:04 ` [PATCH] media: imx: imx7-media-csi: Init default format with __imx7_csi_video_try_fmt() Laurent Pinchart
2023-04-18 10:04   ` Laurent Pinchart
2023-04-18 12:20   ` Alexander Stein
2023-04-18 12:20     ` Alexander Stein

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230418092713.GA26319@pendragon.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=alexander.stein@ew.tq-group.com \
    --cc=festevam@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=rmfrfs@gmail.com \
    --cc=s.hauer@pengutronix.de \
    --cc=shawnguo@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.