mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Guoniu Zhou <guoniu.zhou@oss.nxp.com>
Cc: Frank Li <Frank.Li@nxp.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	Pengutronix Kernel Team <kernel@pengutronix.de>,
	Fabio Estevam <festevam@gmail.com>, Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Loic Poulain <loic.poulain@oss.qualcomm.com>,
	linux-media@vger.kernel.org, imx@lists.linux.dev,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v5 08/11] media: imx8-isi: Exclude RAW10/12/14 output formats on i.MX95
Date: Tue, 1 Dec 2026 00:18:16 +0900	[thread overview]
Message-ID: <20261130151816.GA70809@killaraus.ideasonboard.com> (raw)
In-Reply-To: <20261116-isi_imx952-v5-8-46de1d24efd4@oss.nxp.com>

On Mon, Nov 16, 2026 at 11:28:26AM +0800, Guoniu Zhou wrote:
> On i.MX95, the CSI formatter provides MSB-aligned RAW data to the ISI
> via the Pixel Link. The RAW16 passthrough that older platforms use to
> produce LSB-aligned output now passes through MSB-aligned data instead,
> so it no longer produces correct V4L2-compatible output. Exclude
> RAW10/12/14 from format enumeration on i.MX95.

The important part is that the hardware is not able to shift the data
right, unlike on the i.MX952. Please explain clearly here that producing
the V4L2 RAW 10/12/14 formats is not possible.

> Signed-off-by: Guoniu Zhou <guoniu.zhou@oss.nxp.com>
> ---
> Changes in v4:
> - New patch
> ---
>  .../media/platform/nxp/imx8-isi/imx8-isi-core.h    |  6 ++--
>  drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c |  2 +-
>  .../media/platform/nxp/imx8-isi/imx8-isi-regs.h    | 10 +++---
>  .../media/platform/nxp/imx8-isi/imx8-isi-video.c   | 38 ++++++++++++++++++----
>  4 files changed, 42 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h
> index a30633a7e2e9..ba0d6df98fd4 100644
> --- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h
> +++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h
> @@ -320,9 +320,11 @@ mxc_isi_bus_format_by_code(u32 code, unsigned int pad);
>  const struct mxc_isi_bus_format_info *
>  mxc_isi_bus_format_by_index(unsigned int index, unsigned int pad);
>  const struct mxc_isi_format_info *
> -mxc_isi_format_by_fourcc(u32 fourcc, enum mxc_isi_video_type type);
> +mxc_isi_format_by_fourcc(const struct mxc_isi_plat_data *pdata, u32 fourcc,

Let's pass the mxc_isi_pipe pointer to this function, to match
mxc_isi_format_try().

> +			 enum mxc_isi_video_type type);
>  const struct mxc_isi_format_info *
> -mxc_isi_format_enum(const struct v4l2_fmtdesc *f, enum mxc_isi_video_type type);
> +mxc_isi_format_enum(const struct mxc_isi_plat_data *pdata,

Same here.

> +		    const struct v4l2_fmtdesc *f, enum mxc_isi_video_type type);
>  const struct mxc_isi_format_info *
>  mxc_isi_format_try(struct mxc_isi_pipe *pipe, struct v4l2_pix_format_mplane *pix,
>  		   enum mxc_isi_video_type type);
> diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c b/drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c
> index 1178947bb548..1ad0fd1af3b1 100644
> --- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c
> +++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c
> @@ -492,7 +492,7 @@ static int mxc_isi_m2m_enum_fmt_vid(struct file *file, void *fh,
>  		MXC_ISI_VIDEO_M2M_OUT : MXC_ISI_VIDEO_M2M_CAP;
>  	const struct mxc_isi_format_info *info;
>  
> -	info = mxc_isi_format_enum(f, type);
> +	info = mxc_isi_format_enum(NULL, f, type);

I'd rather not allow passing NULL to mxc_isi_format_enum() (and down to
mxc_isi_format_is_raw_unsupported()), as that's fragile. You can access
the pipe pointer here from struct file.

If the goal is to not disallow raw formats in M2M mode on i.MX95, using
NULL as a magic value is even worse. The code should be explicit.

>  	if (!info)
>  		return -EINVAL;
>  
> diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-regs.h b/drivers/media/platform/nxp/imx8-isi/imx8-isi-regs.h
> index 35438abf3172..b83a25a58ebe 100644
> --- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-regs.h
> +++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-regs.h
> @@ -425,11 +425,11 @@
>  #define CHNL_IN_BUF_XTND_ADDR					0x00b8
>  
>  /*
> - * The ISI shifts the 10-bit and 12-bit RAW formats left by 6 and 4 bits when
> - * using CHNL_IMG_CTRL_FORMAT_RAW10 or CHNL_IMG_CTRL_FORMAT_RAW12 respectively,
> - * to align the bits to the left and pad with zeros in the LSBs. The
> - * corresponding V4L2 formats are however right-aligned, so
> - * CHNL_IMG_CTRL_FORMAT_RAW16 must be used to avoid the left shift.
> + * The ISI shifts the 10/12/14-bit RAW formats left to MSB-align the output.
> + * On platforms where the Pixel Link provides LSB-aligned data, the RAW16
> + * passthrough must be used instead to preserve LSB alignment. On platforms
> + * where the Pixel Link provides MSB-aligned data (i.MX95), these formats
> + * cannot produce correct V4L2-compatible output and must be excluded.
>   */
>  static inline bool isi_out_raw_shifted(u32 format)
>  {
> diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c b/drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c
> index ca8fe8782af8..708aa4c775c7 100644
> --- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c
> +++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c
> @@ -458,14 +458,32 @@ static const struct mxc_isi_format_info mxc_isi_formats[] = {
>  	}
>  };
>  
> +/*
> + * On i.MX95, the Pixel Link provides MSB-aligned RAW data, so neither the
> + * RAW16 passthrough nor the native RAW10/12/14 output formats can produce
> + * correct V4L2-compatible LSB-aligned output. Exclude these formats.
> + */
> +static bool
> +mxc_isi_format_is_raw_unsupported(const struct mxc_isi_plat_data *pdata,
> +				  const struct mxc_isi_format_info *fmt)

As explained in the review of a previous patch, the function naming
makes the code harder to understand.

> +{
> +	return pdata && pdata->model == MXC_ISI_IMX95 &&
> +	       isi_out_raw_shifted(fmt->isi_out_format);
> +}
> +
>  const struct mxc_isi_format_info *
> -mxc_isi_format_by_fourcc(u32 fourcc, enum mxc_isi_video_type type)
> +mxc_isi_format_by_fourcc(const struct mxc_isi_plat_data *pdata, u32 fourcc,
> +			 enum mxc_isi_video_type type)
>  {
>  	unsigned int i;
>  
>  	for (i = 0; i < ARRAY_SIZE(mxc_isi_formats); i++) {
>  		const struct mxc_isi_format_info *fmt = &mxc_isi_formats[i];
>  
> +		/* Skip formats unsupported by the platform. */
> +		if (mxc_isi_format_is_raw_unsupported(pdata, fmt))
> +			continue;
> +
>  		if (fmt->fourcc == fourcc && fmt->type & type)
>  			return fmt;
>  	}
> @@ -474,7 +492,8 @@ mxc_isi_format_by_fourcc(u32 fourcc, enum mxc_isi_video_type type)
>  }
>  
>  const struct mxc_isi_format_info *
> -mxc_isi_format_enum(const struct v4l2_fmtdesc *f, enum mxc_isi_video_type type)
> +mxc_isi_format_enum(const struct mxc_isi_plat_data *pdata,
> +		    const struct v4l2_fmtdesc *f, enum mxc_isi_video_type type)
>  {
>  	unsigned int index = f->index;
>  	unsigned int i;
> @@ -482,6 +501,10 @@ mxc_isi_format_enum(const struct v4l2_fmtdesc *f, enum mxc_isi_video_type type)
>  	for (i = 0; i < ARRAY_SIZE(mxc_isi_formats); i++) {
>  		const struct mxc_isi_format_info *fmt = &mxc_isi_formats[i];
>  
> +		/* Skip formats unsupported by the platform. */
> +		if (mxc_isi_format_is_raw_unsupported(pdata, fmt))
> +			continue;
> +
>  		if (f->mbus_code && fmt->mbus_code != f->mbus_code)
>  			continue;
>  
> @@ -509,7 +532,7 @@ mxc_isi_format_try(struct mxc_isi_pipe *pipe, struct v4l2_pix_format_mplane *pix
>  		  ? MXC_ISI_MAX_WIDTH_UNCHAINED
>  		  : MXC_ISI_MAX_WIDTH_CHAINED;
>  
> -	fmt = mxc_isi_format_by_fourcc(pix->pixelformat, type);
> +	fmt = mxc_isi_format_by_fourcc(pipe->isi->pdata, pix->pixelformat, type);
>  	if (!fmt)
>  		fmt = &mxc_isi_formats[0];
>  
> @@ -803,7 +826,8 @@ static int mxc_isi_video_validate_format(struct mxc_isi_video *video)
>  
>  	state = v4l2_subdev_lock_and_get_active_state(sd);
>  
> -	info = mxc_isi_format_by_fourcc(video->pix.pixelformat,
> +	info = mxc_isi_format_by_fourcc(video->pipe->isi->pdata,
> +					video->pix.pixelformat,
>  					MXC_ISI_VIDEO_CAP);
>  	format = v4l2_subdev_state_get_format(state, MXC_ISI_PIPE_PAD_SOURCE);
>  
> @@ -1222,9 +1246,10 @@ static int mxc_isi_video_querycap(struct file *file, void *priv,
>  static int mxc_isi_video_enum_fmt(struct file *file, void *priv,
>  				  struct v4l2_fmtdesc *f)
>  {
> +	struct mxc_isi_video *video = video_drvdata(file);
>  	const struct mxc_isi_format_info *fmt;
>  
> -	fmt = mxc_isi_format_enum(f, MXC_ISI_VIDEO_CAP);
> +	fmt = mxc_isi_format_enum(video->pipe->isi->pdata, f, MXC_ISI_VIDEO_CAP);
>  	if (!fmt)
>  		return -EINVAL;
>  
> @@ -1281,7 +1306,8 @@ static int mxc_isi_video_enum_framesizes(struct file *file, void *priv,
>  	if (fsize->index)
>  		return -EINVAL;
>  
> -	info = mxc_isi_format_by_fourcc(fsize->pixel_format, MXC_ISI_VIDEO_CAP);
> +	info = mxc_isi_format_by_fourcc(video->pipe->isi->pdata,
> +					fsize->pixel_format, MXC_ISI_VIDEO_CAP);
>  	if (!info)
>  		return -EINVAL;
>  

-- 
Regards,

Laurent Pinchart

  parent reply	other threads:[~2026-11-30 15:18 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16  3:28 [PATCH v5 00/11] media: imx8-isi: Add i.MX952 ISI support Guoniu Zhou
2026-11-16  3:28 ` [PATCH v5 01/11] media: imx8-isi: Reorder mxc_imx95_data to follow mxc_imx93_data Guoniu Zhou
2026-11-16  3:28 ` [PATCH v5 02/11] media: imx8-isi: Extend output format mask to 7 bits Guoniu Zhou
2026-11-16  3:28 ` [PATCH v5 03/11] media: imx8-isi: Support mbus_code filtering in format enumeration Guoniu Zhou
2026-11-30  8:22   ` Laurent Pinchart
2026-11-16  3:28 ` [PATCH v5 04/11] media: imx8-isi: Reuse mxc_isi_format_enum() in capture " Guoniu Zhou
2026-11-16  3:28 ` [PATCH v5 05/11] media: imx8-isi: Apply RAW output format workaround at runtime Guoniu Zhou
2026-11-30 13:43   ` Laurent Pinchart
2026-11-16  3:28 ` [PATCH v5 06/11] media: imx8-isi: Add RAW14 output format support Guoniu Zhou
2026-11-30 13:57   ` Laurent Pinchart
2026-11-16  3:28 ` [PATCH v5 07/11] media: imx8-isi: Select MSB-aligned RAW input from pixel link on i.MX95 Guoniu Zhou
2026-11-16 16:48   ` Frank Li
2026-11-30 15:12   ` Laurent Pinchart
2026-11-16  3:28 ` [PATCH v5 08/11] media: imx8-isi: Exclude RAW10/12/14 output formats " Guoniu Zhou
2026-11-16 16:53   ` Frank Li
2026-11-30 15:18   ` Laurent Pinchart [this message]
2026-11-16  3:28 ` [PATCH v5 09/11] media: dt-bindings: nxp,imx8-isi: Add i.MX952 ISI compatible string Guoniu Zhou
2026-11-16  3:28 ` [PATCH v5 10/11] media: imx8-isi: Add i.MX952 ISI support Guoniu Zhou
2026-11-30 15:32   ` Laurent Pinchart
2026-11-16  3:28 ` [PATCH v5 11/11] media: imx8-isi: Enable RAW10/12/14 output LSB alignment on i.MX952 Guoniu Zhou

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=20261130151816.GA70809@killaraus.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=Frank.Li@nxp.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=festevam@gmail.com \
    --cc=guoniu.zhou@oss.nxp.com \
    --cc=imx@lists.linux.dev \
    --cc=kernel@pengutronix.de \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=loic.poulain@oss.qualcomm.com \
    --cc=mchehab@kernel.org \
    --cc=robh@kernel.org \
    --cc=s.hauer@pengutronix.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®