Skip to contentSkip to conversation

media: imx8-isi: Add i.MX952 ISI support

PATCH Superseded Guoniu Zhou 4 participants 25 messages Sep 29 – Nov 12

Subsystems (4)

v4 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v4 cover media: imx8-isi: Add i.MX952 ISI support

The series adds support for the i.MX952 Image Sensing Interface (ISI), which is a minor silicon revision of the i.MX95 ISI.

The i.MX952 ISI reuses the i.MX95 ISI core with the same 8-channel pipeline and 4 pixel link inputs. The key hardware improvement is the addition of RAW10/12/14 output LSB alignment, which allows the ISI to output right-aligned RAW data directly, matching the V4L2 format requirement without the RAW16 workaround needed on earlier platforms.

The series is organized as follows:

1. Reorder mxc_imx95_data definition to follow mxc_imx93_data, matching the order in the of_match array.
2. Extend output format mask to 7 bits unconditionally since bit 30 is unused on older platforms.
3. Support mbus_code filtering in mxc_isi_format_enum().
4. Reuse mxc_isi_format_enum() in capture format enumeration.
5. Apply RAW output format workaround at runtime, storing the actual hardware format in the format table.
6. Add RAW14 output format support (available from i.MX8ULP).
7. Select MSB-aligned RAW input from pixel link on i.MX95.
8. Exclude RAW10/12/14 output formats on i.MX95.
9. Add the i.MX952 compatible string to the DT binding.
10. Add the i.MX952 platform data and of_match entry.
11. Enable RAW10/12/14 output LSB alignment on i.MX952.

---
Changes in v4:
- Rebase to latest media/next(2dcdfb625c3b)
- Split the original patch 5/5 into multiple focused patches:
patches 3-8 are new, each addressing a specific aspect
- [3/11] New: Support mbus_code filtering in mxc_isi_format_enum()
- [4/11] New: Reuse mxc_isi_format_enum() in capture format enumeration
- [5/11] New: Apply RAW output format workaround at runtime
- [6/11] New: Add RAW14 output format support
- [7/11] New: Select MSB-aligned RAW input from pixel link on i.MX95
- [8/11] New: Exclude RAW10/12/14 output formats on i.MX95
- [11/11] Split RAW_IN_MSB_ALIGN into a separate preceding patch
- [11/11] Split RAW format table and RAW14 changes into separate preceding patches
- [11/11] Move isi_out_raw_shifted() to regs.h in the preceding workaround patch
- [11/11] Rewrite commit message
- Link to v3: https://lore.kernel.org/r/[email protected]

Changes in v3:
- [1/5] Add Reviewed-by tag from Laurent
- [2/5] Use unconditional 7-bit mask instead of per-platform approach (Laurent)
- [2/5] Drop Reviewed-by from Frank Li due to significant change and request to review again
- [3/5] Add Reviewed-by/Acked-by tag from Frank, Laurent and Dooley
- [4/5] Extend mask globally instead of per-platform (Laurent)
- [4/5] Add Reviewed-by tag from Frank
- [5/5] Use CHNL_IMG_CTRL_FORMAT_MASK instead of the removed per-platform format_mask (Laurent)
- [5/5] Derive raw_out_lsb from the model field instead of dedicated platform data (Laurent)
- [5/5] Clarify the CHNL_IMG_CTRL_FORMAT_RAW14 comment: the format is documented on i.MX{8ULP,91,93,95,952} but only used on i.MX952
- [5/5] Rewrite commit message to explain why the RAW16 workaround fails on i.MX95+ (Laurent)
- [5/5] Add Reviewed-by tag from Frank
- Drop "Remove unused model field" patch; model field is now used to derive raw_out_lsb capability (Laurent)
- Link to v2: https://lore.kernel.org/r/[email protected]

Changes in v2:
- Use fallback compatible fsl,imx95-isi for imx952 (Frank)
- Remove unused model field from platform data (Frank)
- Add Reviewed-by tag from Frank Li for patch 1/6 and 2/6
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Guoniu Zhou (11):
media: imx8-isi: Reorder mxc_imx95_data to follow mxc_imx93_data
media: imx8-isi: Extend output format mask to 7 bits
media: imx8-isi: Support mbus_code filtering in format enumeration
media: imx8-isi: Reuse mxc_isi_format_enum() in capture format enumeration
media: imx8-isi: Apply RAW output format workaround at runtime
media: imx8-isi: Add RAW14 output format support
media: imx8-isi: Select MSB-aligned RAW input from pixel link on i.MX95
media: imx8-isi: Exclude RAW10/12/14 output formats on i.MX95
media: dt-bindings: nxp,imx8-isi: Add i.MX952 ISI compatible string
media: imx8-isi: Add i.MX952 ISI support
media: imx8-isi: Enable RAW10/12/14 output LSB alignment on i.MX952

 .../devicetree/bindings/media/nxp,imx8-isi.yaml    |  18 ++--
 .../media/platform/nxp/imx8-isi/imx8-isi-core.c    |  37 ++++---
 .../media/platform/nxp/imx8-isi/imx8-isi-core.h    |   7 +-
 drivers/media/platform/nxp/imx8-isi/imx8-isi-hw.c  |  56 ++++++++++-
 drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c |   2 +-
 .../media/platform/nxp/imx8-isi/imx8-isi-regs.h    |  22 ++++-
 .../media/platform/nxp/imx8-isi/imx8-isi-video.c   | 110 ++++++++++-----------
 7 files changed, 171 insertions(+), 81 deletions(-)

---
base-commit: 2dcdfb625c3b8fe87454e19dfbc54b3e3f0ad70e
change-id: 20260817-isi_imx952-66ca65f9b638

Best regards,

Signature · 1 line
Guoniu Zhou <[email protected]>
#1 lore raw

PATCH v4 1/11 media: imx8-isi: Reorder mxc_imx95_data to follow mxc_imx93_data

Move mxc_imx95_data definition after mxc_imx93_data to match the order defined in the of_match array.

---
Changes in v3:
- Add Reviewed-by tag from Laurent

Changes in v2:
- Add Reviewed-by tag from Frank Li

---
 .../media/platform/nxp/imx8-isi/imx8-isi-core.c    | 24 +++++++++++-----------
 1 file changed, 12 insertions(+), 12 deletions(-)
drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c +12 -12
index 0ae5f35e017c..f2a8eb82fbfd 100644
@@ -314,18 +314,6 @@ static const struct mxc_isi_plat_data mxc_imx8mp_data = {
 	.has_36bit_dma		= true,
 };
 
-static const struct mxc_isi_plat_data mxc_imx95_data = {
-	.model			= MXC_ISI_IMX95,
-	.num_ports		= 4,
-	.num_channels		= 8,
-	.num_vc			= 8,
-	.reg_offset		= 0x10000,
-	.ier_reg		= &mxc_imx8_isi_ier_v2,
-	.set_thd		= &mxc_imx8_isi_thd_v1,
-	.buf_active_reverse	= true,
-	.has_36bit_dma		= true,
-};
-
 static const struct mxc_isi_plat_data mxc_imx8qm_data = {
 	.model			= MXC_ISI_IMX8QM,
 	.num_ports		= 5,
@@ -384,6 +372,18 @@ static const struct mxc_isi_plat_data mxc_imx93_data = {
 	.has_36bit_dma		= false,
 };
 
+static const struct mxc_isi_plat_data mxc_imx95_data = {
+	.model			= MXC_ISI_IMX95,
+	.num_ports		= 4,
+	.num_channels		= 8,
+	.num_vc			= 8,
+	.reg_offset		= 0x10000,
+	.ier_reg		= &mxc_imx8_isi_ier_v2,
+	.set_thd		= &mxc_imx8_isi_thd_v1,
+	.buf_active_reverse	= true,
+	.has_36bit_dma		= true,
+};
+
 /* -----------------------------------------------------------------------------
  * Power management
  */
Signature · 1 line
2.34.1
#2 lore raw

PATCH v4 2/11 media: imx8-isi: Extend output format mask to 7 bits

In reply to Guoniu Zhou

The ISI output format field width differs across SoC generations:
i.MX8 series (MN/MP/QM/QXP) use a 6-bit field (bits 29:24), while from i.MX8ULP onwards (including i.MX91/93/95/952) the field is extended to 7 bits (bits 30:24) to support RAW32 and RAW14 formats.

Extend CHNL_IMG_CTRL_FORMAT_MASK to 7 bits unconditionally since bit 30 is unused on older platforms.

---
Changes in v3:
- Use unconditional 7-bit mask instead of per-platform approach (Laurent)
- Drop Reviewed-by from Frank Li due to significant change

Changes in v2:
- Add Reviewed-by tag from Frank Li

---
 drivers/media/platform/nxp/imx8-isi/imx8-isi-regs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/nxp/imx8-isi/imx8-isi-regs.h +1 -1
index e795f4daf3ff..c704be882705 100644
@@ -39,7 +39,7 @@
 /* Channel Image Control Register */
 #define CHNL_IMG_CTRL						0x0004
 #define CHNL_IMG_CTRL_FORMAT(n)					((n) << 24)
-#define CHNL_IMG_CTRL_FORMAT_MASK				GENMASK(29, 24)
+#define CHNL_IMG_CTRL_FORMAT_MASK				GENMASK(30, 24)
 #define CHNL_IMG_CTRL_FORMAT_RGBA8888				0x00
 #define CHNL_IMG_CTRL_FORMAT_ABGR8888				0x01
 #define CHNL_IMG_CTRL_FORMAT_ARGB8888				0x02
Signature · 1 line
2.34.1
Reviewed-by on v4 2/11
#3 lore raw

Re: [PATCH v4 02/11] media: imx8-isi: Extend output format mask to 7 bits

Quoted 9 lines · Guoniu Zhou

The ISI output format field width differs across SoC generations:
i.MX8 series (MN/MP/QM/QXP) use a 6-bit field (bits 29:24), while from i.MX8ULP onwards (including i.MX91/93/95/952) the field is extended to 7 bits (bits 30:24) to support RAW32 and RAW14 formats.

Extend CHNL_IMG_CTRL_FORMAT_MASK to 7 bits unconditionally since bit 30 is unused on older platforms.

Quoted 29 lines

---
Changes in v3:
- Use unconditional 7-bit mask instead of per-platform approach (Laurent)
- Drop Reviewed-by from Frank Li due to significant change

Changes in v2:
- Add Reviewed-by tag from Frank Li

---
 drivers/media/platform/nxp/imx8-isi/imx8-isi-regs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/nxp/imx8-isi/imx8-isi-regs.h +1 -2
index e795f4daf3ff..c704be882705 100644
@@ -39,7 +39,7 @@
 /* Channel Image Control Register */
 #define CHNL_IMG_CTRL						0x0004
 #define CHNL_IMG_CTRL_FORMAT(n)					((n) << 24)
-#define CHNL_IMG_CTRL_FORMAT_MASK				GENMASK(29, 24)
+#define CHNL_IMG_CTRL_FORMAT_MASK				GENMASK(30, 24)
 #define CHNL_IMG_CTRL_FORMAT_RGBA8888				0x00
 #define CHNL_IMG_CTRL_FORMAT_ABGR8888				0x01
 #define CHNL_IMG_CTRL_FORMAT_ARGB8888				0x02
 
--

2.34.1

maintainer Reviewed-by on v4 2/11
#4 lore raw

Re: [PATCH v4 02/11] media: imx8-isi: Extend output format mask to 7 bits

In reply to Guoniu Zhou

Hi Zhou,

Quoted 25 lines · Guoniu Zhou

The ISI output format field width differs across SoC generations:
i.MX8 series (MN/MP/QM/QXP) use a 6-bit field (bits 29:24), while from i.MX8ULP onwards (including i.MX91/93/95/952) the field is extended to 7 bits (bits 30:24) to support RAW32 and RAW14 formats.

Extend CHNL_IMG_CTRL_FORMAT_MASK to 7 bits unconditionally since bit 30 is unused on older platforms.

---
Changes in v3:
- Use unconditional 7-bit mask instead of per-platform approach (Laurent)
- Drop Reviewed-by from Frank Li due to significant change

Changes in v2:
- Add Reviewed-by tag from Frank Li

---
 drivers/media/platform/nxp/imx8-isi/imx8-isi-regs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/nxp/imx8-isi/imx8-isi-regs.h +0 -0
index e795f4daf3ff..c704be882705 100644

drivers/media/platform/nxp/imx8-isi/imx8-isi-regs.h line 42

Quoted 5 lines
drivers/media/platform/nxp/imx8-isi/imx8-isi-regs.h +1 -1
@@ -39,7 +39,7 @@
 /* Channel Image Control Register */
 #define CHNL_IMG_CTRL						0x0004
 #define CHNL_IMG_CTRL_FORMAT(n)					((n) << 24)
-#define CHNL_IMG_CTRL_FORMAT_MASK				GENMASK(29, 24)
+#define CHNL_IMG_CTRL_FORMAT_MASK				GENMASK(30, 24)

I've double-checked that bit 30 is reserved on all SoC versions that use a 6-bit format.

Quoted 3 lines
drivers/media/platform/nxp/imx8-isi/imx8-isi-regs.h +0 -0
 #define CHNL_IMG_CTRL_FORMAT_RGBA8888				0x00
 #define CHNL_IMG_CTRL_FORMAT_ABGR8888				0x01
 #define CHNL_IMG_CTRL_FORMAT_ARGB8888				0x02
Signature · 3 lines
Regards,

Laurent Pinchart
Reviewed-by on v4 2/11
#5 lore raw

Re: [PATCH v4 02/11] media: imx8-isi: Extend output format mask to 7 bits

In reply to Guoniu Zhou
Quoted 10 lines · Guoniu Zhou

The ISI output format field width differs across SoC generations:
i.MX8 series (MN/MP/QM/QXP) use a 6-bit field (bits 29:24), while from i.MX8ULP onwards (including i.MX91/93/95/952) the field is extended to 7 bits (bits 30:24) to support RAW32 and RAW14 formats.

Extend CHNL_IMG_CTRL_FORMAT_MASK to 7 bits unconditionally since bit 30 is unused on older platforms.

Quoted 28 lines

---
Changes in v3:
- Use unconditional 7-bit mask instead of per-platform approach (Laurent)
- Drop Reviewed-by from Frank Li due to significant change

Changes in v2:
- Add Reviewed-by tag from Frank Li

---
 drivers/media/platform/nxp/imx8-isi/imx8-isi-regs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/nxp/imx8-isi/imx8-isi-regs.h +1 -2
index e795f4daf3ff..c704be882705 100644
@@ -39,7 +39,7 @@
 /* Channel Image Control Register */
 #define CHNL_IMG_CTRL                                          0x0004
 #define CHNL_IMG_CTRL_FORMAT(n)                                        ((n) << 24)
-#define CHNL_IMG_CTRL_FORMAT_MASK                              GENMASK(29, 24)
+#define CHNL_IMG_CTRL_FORMAT_MASK                              GENMASK(30, 24)
 #define CHNL_IMG_CTRL_FORMAT_RGBA8888                          0x00
 #define CHNL_IMG_CTRL_FORMAT_ABGR8888                          0x01
 #define CHNL_IMG_CTRL_FORMAT_ARGB8888                          0x02
 
--

2.34.1

#6 lore raw

PATCH v4 3/11 media: imx8-isi: Support mbus_code filtering in format enumeration

In reply to Guoniu Zhou

Extend mxc_isi_format_enum() to accept a v4l2_fmtdesc pointer instead of a plain index, so it can filter formats by mbus_code when set. This is used by the capture path to enumerate only formats compatible with the connected subdev output.

For the M2M device, the V4L2 framework clears mbus_code to 0 for devices without V4L2_CAP_IO_MC (v4l2-ioctl.c), so this change has no effect on M2M format enumeration.

---
Changes in v4:
- New patch

---
 drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h  | 2 +-
 drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c   | 2 +-
 drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c | 6 +++++-
 3 files changed, 7 insertions(+), 3 deletions(-)
drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h +1 -1
index 58b47335afc7..a30633a7e2e9 100644
@@ -322,7 +322,7 @@ 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);
 const struct mxc_isi_format_info *
-mxc_isi_format_enum(unsigned int index, enum mxc_isi_video_type type);
+mxc_isi_format_enum(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);
drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c +1 -1
index b729eecad0fe..1178947bb548 100644
@@ -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->index, type);
+	info = mxc_isi_format_enum(f, type);
 	if (!info)
 		return -EINVAL;
 
drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c +5 -1
index f45c2aae59ce..0d87a1082727 100644
@@ -482,13 +482,17 @@ mxc_isi_format_by_fourcc(u32 fourcc, enum mxc_isi_video_type type)
 }
 
 const struct mxc_isi_format_info *
-mxc_isi_format_enum(unsigned int index, enum mxc_isi_video_type type)
+mxc_isi_format_enum(const struct v4l2_fmtdesc *f, enum mxc_isi_video_type type)
 {
+	unsigned int index = f->index;
 	unsigned int i;
 
 	for (i = 0; i < ARRAY_SIZE(mxc_isi_formats); i++) {
 		const struct mxc_isi_format_info *fmt = &mxc_isi_formats[i];
 
+		if (f->mbus_code && fmt->mbus_code != f->mbus_code)
+			continue;
+
 		if (!(fmt->type & type))
 			continue;
 
Signature · 1 line
2.34.1
Reviewed-by on v4 3/11
#7 lore raw

Re: [PATCH v4 03/11] media: imx8-isi: Support mbus_code filtering in format enumeration

Quoted 11 lines · Guoniu Zhou

Extend mxc_isi_format_enum() to accept a v4l2_fmtdesc pointer instead of a plain index, so it can filter formats by mbus_code when set. This is used by the capture path to enumerate only formats compatible with the connected subdev output.

For the M2M device, the V4L2 framework clears mbus_code to 0 for devices without V4L2_CAP_IO_MC (v4l2-ioctl.c), so this change has no effect on M2M format enumeration.

---

Quoted 62 lines

Changes in v4:
- New patch

---
 drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h  | 2 +-
 drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c   | 2 +-
 drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c | 6 +++++-
 3 files changed, 7 insertions(+), 3 deletions(-)
drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h +1 -1
index 58b47335afc7..a30633a7e2e9 100644
@@ -322,7 +322,7 @@ 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);
 const struct mxc_isi_format_info *
-mxc_isi_format_enum(unsigned int index, enum mxc_isi_video_type type);
+mxc_isi_format_enum(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);
drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c +1 -1
index b729eecad0fe..1178947bb548 100644
@@ -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->index, type);
+	info = mxc_isi_format_enum(f, type);
 	if (!info)
 		return -EINVAL;
 
drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c +5 -2
index f45c2aae59ce..0d87a1082727 100644
@@ -482,13 +482,17 @@ mxc_isi_format_by_fourcc(u32 fourcc, enum mxc_isi_video_type type)
 }
 
 const struct mxc_isi_format_info *
-mxc_isi_format_enum(unsigned int index, enum mxc_isi_video_type type)
+mxc_isi_format_enum(const struct v4l2_fmtdesc *f, enum mxc_isi_video_type type)
 {
+	unsigned int index = f->index;
 	unsigned int i;
 
 	for (i = 0; i < ARRAY_SIZE(mxc_isi_formats); i++) {
 		const struct mxc_isi_format_info *fmt = &mxc_isi_formats[i];
 
+		if (f->mbus_code && fmt->mbus_code != f->mbus_code)
+			continue;
+
 		if (!(fmt->type & type))
 			continue;
 
 
--

2.34.1

maintainer
#8 lore raw

Re: [PATCH v4 03/11] media: imx8-isi: Support mbus_code filtering in format enumeration

In reply to Guoniu Zhou
Quoted 4 lines · Guoniu Zhou

Extend mxc_isi_format_enum() to accept a v4l2_fmtdesc pointer instead of a plain index, so it can filter formats by mbus_code when set. This is used by the capture path to enumerate only formats compatible with the connected subdev output.

It's not in this patch, mxc_isi_format_enum() is used for M2M only. It will only be used in the capture path in patch 04/11.

Quoted 64 lines

For the M2M device, the V4L2 framework clears mbus_code to 0 for devices without V4L2_CAP_IO_MC (v4l2-ioctl.c), so this change has no effect on M2M format enumeration.

---
Changes in v4:
- New patch

---
 drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h  | 2 +-
 drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c   | 2 +-
 drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c | 6 +++++-
 3 files changed, 7 insertions(+), 3 deletions(-)
drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h +1 -1
index 58b47335afc7..a30633a7e2e9 100644
@@ -322,7 +322,7 @@ 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);
 const struct mxc_isi_format_info *
-mxc_isi_format_enum(unsigned int index, enum mxc_isi_video_type type);
+mxc_isi_format_enum(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);
drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c +1 -1
index b729eecad0fe..1178947bb548 100644
@@ -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->index, type);
+	info = mxc_isi_format_enum(f, type);
 	if (!info)
 		return -EINVAL;
 
drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c +5 -1
index f45c2aae59ce..0d87a1082727 100644
@@ -482,13 +482,17 @@ mxc_isi_format_by_fourcc(u32 fourcc, enum mxc_isi_video_type type)
 }
 
 const struct mxc_isi_format_info *
-mxc_isi_format_enum(unsigned int index, enum mxc_isi_video_type type)
+mxc_isi_format_enum(const struct v4l2_fmtdesc *f, enum mxc_isi_video_type type)
 {
+	unsigned int index = f->index;
 	unsigned int i;
 
 	for (i = 0; i < ARRAY_SIZE(mxc_isi_formats); i++) {
 		const struct mxc_isi_format_info *fmt = &mxc_isi_formats[i];
 
+		if (f->mbus_code && fmt->mbus_code != f->mbus_code)
+			continue;
+
 		if (!(fmt->type & type))
 			continue;
 
Signature · 3 lines
Regards,

Laurent Pinchart
#9 lore raw

PATCH v4 4/11 media: imx8-isi: Reuse mxc_isi_format_enum() in capture format enumeration

In reply to Guoniu Zhou

Simplify mxc_isi_video_enum_fmt() by reusing mxc_isi_format_enum() instead of open-coding the same format table traversal.

---
Changes in v4:
- New patch

---
 .../media/platform/nxp/imx8-isi/imx8-isi-video.c   | 30 +++-------------------
 1 file changed, 3 insertions(+), 27 deletions(-)
drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c +3 -27
index 0d87a1082727..21849af3121b 100644
@@ -1231,34 +1231,10 @@ static int mxc_isi_video_enum_fmt(struct file *file, void *priv,
 				  struct v4l2_fmtdesc *f)
 {
 	const struct mxc_isi_format_info *fmt;
-	unsigned int index = f->index;
-	unsigned int i;
-
-	if (f->mbus_code) {
-		/*
-		 * If a media bus code is specified, only enumerate formats
-		 * compatible with it.
-		 */
-		for (i = 0; i < ARRAY_SIZE(mxc_isi_formats); i++) {
-			fmt = &mxc_isi_formats[i];
-			if (fmt->mbus_code != f->mbus_code)
-				continue;
-
-			if (index == 0)
-				break;
-
-			index--;
-		}
 
-		if (i == ARRAY_SIZE(mxc_isi_formats))
-			return -EINVAL;
-	} else {
-		/* Otherwise, enumerate all formatS. */
-		if (f->index >= ARRAY_SIZE(mxc_isi_formats))
-			return -EINVAL;
-
-		fmt = &mxc_isi_formats[f->index];
-	}
+	fmt = mxc_isi_format_enum(f, MXC_ISI_VIDEO_CAP);
+	if (!fmt)
+		return -EINVAL;
 
 	f->pixelformat = fmt->fourcc;
 	f->flags |= V4L2_FMT_FLAG_CSC_COLORSPACE | V4L2_FMT_FLAG_CSC_YCBCR_ENC
Signature · 1 line
2.34.1
Reviewed-by on v4 4/11
#10 lore raw

Re: [PATCH v4 04/11] media: imx8-isi: Reuse mxc_isi_format_enum() in capture format enumeration

Quoted 5 lines · Guoniu Zhou

Simplify mxc_isi_video_enum_fmt() by reusing mxc_isi_format_enum() instead of open-coding the same format table traversal.

---

Quoted 53 lines

Changes in v4:
- New patch

---
 .../media/platform/nxp/imx8-isi/imx8-isi-video.c   | 30 +++-------------------
 1 file changed, 3 insertions(+), 27 deletions(-)
drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c +3 -28
index 0d87a1082727..21849af3121b 100644
@@ -1231,34 +1231,10 @@ static int mxc_isi_video_enum_fmt(struct file *file, void *priv,
 				  struct v4l2_fmtdesc *f)
 {
 	const struct mxc_isi_format_info *fmt;
-	unsigned int index = f->index;
-	unsigned int i;
-
-	if (f->mbus_code) {
-		/*
-		 * If a media bus code is specified, only enumerate formats
-		 * compatible with it.
-		 */
-		for (i = 0; i < ARRAY_SIZE(mxc_isi_formats); i++) {
-			fmt = &mxc_isi_formats[i];
-			if (fmt->mbus_code != f->mbus_code)
-				continue;
-
-			if (index == 0)
-				break;
-
-			index--;
-		}
 
-		if (i == ARRAY_SIZE(mxc_isi_formats))
-			return -EINVAL;
-	} else {
-		/* Otherwise, enumerate all formatS. */
-		if (f->index >= ARRAY_SIZE(mxc_isi_formats))
-			return -EINVAL;
-
-		fmt = &mxc_isi_formats[f->index];
-	}
+	fmt = mxc_isi_format_enum(f, MXC_ISI_VIDEO_CAP);
+	if (!fmt)
+		return -EINVAL;
 
 	f->pixelformat = fmt->fourcc;
 	f->flags |= V4L2_FMT_FLAG_CSC_COLORSPACE | V4L2_FMT_FLAG_CSC_YCBCR_ENC
 
--

2.34.1

maintainer Reviewed-by on v4 4/11
#11 lore raw

Re: [PATCH v4 04/11] media: imx8-isi: Reuse mxc_isi_format_enum() in capture format enumeration

In reply to Guoniu Zhou
Quoted 4 lines · Guoniu Zhou

Simplify mxc_isi_video_enum_fmt() by reusing mxc_isi_format_enum() instead of open-coding the same format table traversal.

This will cause a small performance regression when enumerating formats without mbus_code being set, but it's not a hot path.

You'll need to either update the commit message of 03/11 (or possibly squash it with this patch).

Quoted 49 lines

---
Changes in v4:
- New patch

---
 .../media/platform/nxp/imx8-isi/imx8-isi-video.c   | 30 +++-------------------
 1 file changed, 3 insertions(+), 27 deletions(-)
drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c +3 -27
index 0d87a1082727..21849af3121b 100644
@@ -1231,34 +1231,10 @@ static int mxc_isi_video_enum_fmt(struct file *file, void *priv,
 				  struct v4l2_fmtdesc *f)
 {
 	const struct mxc_isi_format_info *fmt;
-	unsigned int index = f->index;
-	unsigned int i;
-
-	if (f->mbus_code) {
-		/*
-		 * If a media bus code is specified, only enumerate formats
-		 * compatible with it.
-		 */
-		for (i = 0; i < ARRAY_SIZE(mxc_isi_formats); i++) {
-			fmt = &mxc_isi_formats[i];
-			if (fmt->mbus_code != f->mbus_code)
-				continue;
-
-			if (index == 0)
-				break;
-
-			index--;
-		}
 
-		if (i == ARRAY_SIZE(mxc_isi_formats))
-			return -EINVAL;
-	} else {
-		/* Otherwise, enumerate all formatS. */
-		if (f->index >= ARRAY_SIZE(mxc_isi_formats))
-			return -EINVAL;
-
-		fmt = &mxc_isi_formats[f->index];
-	}
+	fmt = mxc_isi_format_enum(f, MXC_ISI_VIDEO_CAP);
+	if (!fmt)
+		return -EINVAL;
 
 	f->pixelformat = fmt->fourcc;
 	f->flags |= V4L2_FMT_FLAG_CSC_COLORSPACE | V4L2_FMT_FLAG_CSC_YCBCR_ENC
Signature · 3 lines
Regards,

Laurent Pinchart
#12 lore raw

PATCH v4 5/11 media: imx8-isi: Apply RAW output format workaround at runtime

In reply to Guoniu Zhou

Refactor the RAW format handling by storing the actual hardware output format (RAW10/RAW12) in the format table instead of the workaround value RAW16. The RAW16 workaround is now applied at runtime in mxc_isi_channel_set_output_format() via the new isi_out_raw_shifted() helper in imx8-isi-regs.h.

This makes the format table accurately reflect the real hardware capability.

---
Changes in v4:
- New patch

---
 drivers/media/platform/nxp/imx8-isi/imx8-isi-hw.c  |  7 ++++-
 .../media/platform/nxp/imx8-isi/imx8-isi-regs.h    | 13 ++++++++++
 .../media/platform/nxp/imx8-isi/imx8-isi-video.c   | 30 ++++++++--------------
 3 files changed, 30 insertions(+), 20 deletions(-)
drivers/media/platform/nxp/imx8-isi/imx8-isi-hw.c +6 -1
index 6aa760ce3605..cc52a90c2477 100644
@@ -411,13 +411,18 @@ void mxc_isi_channel_set_output_format(struct mxc_isi_pipe *pipe,
 				       struct v4l2_pix_format_mplane *format)
 {
 	u32 val;
+	u32 fmt;
 
 	/* set outbuf format */
 	dev_dbg(pipe->isi->dev, "output format %p4cc", &format->pixelformat);
 
+	fmt = isi_out_raw_shifted(info->isi_out_format)
+	    ? CHNL_IMG_CTRL_FORMAT_RAW16
+	    : info->isi_out_format;
+
 	val = mxc_isi_read(pipe, CHNL_IMG_CTRL);
 	val &= ~CHNL_IMG_CTRL_FORMAT_MASK;
-	val |= CHNL_IMG_CTRL_FORMAT(info->isi_out_format);
+	val |= CHNL_IMG_CTRL_FORMAT(fmt);
 	mxc_isi_write(pipe, CHNL_IMG_CTRL, val);
 
 	/* line pitch */
drivers/media/platform/nxp/imx8-isi/imx8-isi-regs.h +13 -0
index c704be882705..0f3ada30e71e 100644
@@ -421,4 +421,17 @@
 /* Channel Input Buffer Extended Address Bits */
 #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.
+ */
+static inline bool isi_out_raw_shifted(u32 format)
+{
+	return format == CHNL_IMG_CTRL_FORMAT_RAW10 ||
+	       format == CHNL_IMG_CTRL_FORMAT_RAW12;
+}
+
 #endif /* __IMX8_ISI_REGS_H__ */
drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c +11 -19
index 21849af3121b..365057db47bd 100644
@@ -218,15 +218,7 @@ static const struct mxc_isi_format_info mxc_isi_formats[] = {
 		.depth		= { 32 },
 		.encoding	= MXC_ISI_ENC_RGB,
 	},
-	/*
-	 * RAW formats
-	 *
-	 * The ISI shifts the 10-bit and 12-bit formats left by 6 and 4 bits
-	 * when using CHNL_IMG_CTRL_FORMAT_RAW10 or MXC_ISI_OUT_FMT_RAW12
-	 * respectively, to align the bits to the left and pad with zeros in
-	 * the LSBs. The corresponding V4L2 formats are however right-aligned,
-	 * we have to use CHNL_IMG_CTRL_FORMAT_RAW16 to avoid the left shift.
-	 */
+	/* RAW formats */
 	{
 		.mbus_code	= MEDIA_BUS_FMT_Y8_1X8,
 		.fourcc		= V4L2_PIX_FMT_GREY,
@@ -240,7 +232,7 @@ static const struct mxc_isi_format_info mxc_isi_formats[] = {
 		.mbus_code	= MEDIA_BUS_FMT_Y10_1X10,
 		.fourcc		= V4L2_PIX_FMT_Y10,
 		.type		= MXC_ISI_VIDEO_CAP,
-		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW16,
+		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW10,
 		.mem_planes	= 1,
 		.color_planes	= 1,
 		.depth		= { 16 },
@@ -249,7 +241,7 @@ static const struct mxc_isi_format_info mxc_isi_formats[] = {
 		.mbus_code	= MEDIA_BUS_FMT_Y12_1X12,
 		.fourcc		= V4L2_PIX_FMT_Y12,
 		.type		= MXC_ISI_VIDEO_CAP,
-		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW16,
+		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW12,
 		.mem_planes	= 1,
 		.color_planes	= 1,
 		.depth		= { 16 },
@@ -312,7 +304,7 @@ static const struct mxc_isi_format_info mxc_isi_formats[] = {
 		.mbus_code	= MEDIA_BUS_FMT_SBGGR10_1X10,
 		.fourcc		= V4L2_PIX_FMT_SBGGR10,
 		.type		= MXC_ISI_VIDEO_CAP,
-		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW16,
+		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW10,
 		.mem_planes	= 1,
 		.color_planes	= 1,
 		.depth		= { 16 },
@@ -321,7 +313,7 @@ static const struct mxc_isi_format_info mxc_isi_formats[] = {
 		.mbus_code	= MEDIA_BUS_FMT_SGBRG10_1X10,
 		.fourcc		= V4L2_PIX_FMT_SGBRG10,
 		.type		= MXC_ISI_VIDEO_CAP,
-		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW16,
+		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW10,
 		.mem_planes	= 1,
 		.color_planes	= 1,
 		.depth		= { 16 },
@@ -330,7 +322,7 @@ static const struct mxc_isi_format_info mxc_isi_formats[] = {
 		.mbus_code	= MEDIA_BUS_FMT_SGRBG10_1X10,
 		.fourcc		= V4L2_PIX_FMT_SGRBG10,
 		.type		= MXC_ISI_VIDEO_CAP,
-		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW16,
+		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW10,
 		.mem_planes	= 1,
 		.color_planes	= 1,
 		.depth		= { 16 },
@@ -339,7 +331,7 @@ static const struct mxc_isi_format_info mxc_isi_formats[] = {
 		.mbus_code	= MEDIA_BUS_FMT_SRGGB10_1X10,
 		.fourcc		= V4L2_PIX_FMT_SRGGB10,
 		.type		= MXC_ISI_VIDEO_CAP,
-		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW16,
+		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW10,
 		.mem_planes	= 1,
 		.color_planes	= 1,
 		.depth		= { 16 },
@@ -348,7 +340,7 @@ static const struct mxc_isi_format_info mxc_isi_formats[] = {
 		.mbus_code	= MEDIA_BUS_FMT_SBGGR12_1X12,
 		.fourcc		= V4L2_PIX_FMT_SBGGR12,
 		.type		= MXC_ISI_VIDEO_CAP,
-		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW16,
+		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW12,
 		.mem_planes	= 1,
 		.color_planes	= 1,
 		.depth		= { 16 },
@@ -357,7 +349,7 @@ static const struct mxc_isi_format_info mxc_isi_formats[] = {
 		.mbus_code	= MEDIA_BUS_FMT_SGBRG12_1X12,
 		.fourcc		= V4L2_PIX_FMT_SGBRG12,
 		.type		= MXC_ISI_VIDEO_CAP,
-		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW16,
+		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW12,
 		.mem_planes	= 1,
 		.color_planes	= 1,
 		.depth		= { 16 },
@@ -366,7 +358,7 @@ static const struct mxc_isi_format_info mxc_isi_formats[] = {
 		.mbus_code	= MEDIA_BUS_FMT_SGRBG12_1X12,
 		.fourcc		= V4L2_PIX_FMT_SGRBG12,
 		.type		= MXC_ISI_VIDEO_CAP,
-		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW16,
+		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW12,
 		.mem_planes	= 1,
 		.color_planes	= 1,
 		.depth		= { 16 },
@@ -375,7 +367,7 @@ static const struct mxc_isi_format_info mxc_isi_formats[] = {
 		.mbus_code	= MEDIA_BUS_FMT_SRGGB12_1X12,
 		.fourcc		= V4L2_PIX_FMT_SRGGB12,
 		.type		= MXC_ISI_VIDEO_CAP,
-		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW16,
+		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW12,
 		.mem_planes	= 1,
 		.color_planes	= 1,
 		.depth		= { 16 },
Signature · 1 line
2.34.1
Reviewed-by on v4 5/11
#13 lore raw

Re: [PATCH v4 05/11] media: imx8-isi: Apply RAW output format workaround at runtime

Quoted 11 lines · Guoniu Zhou

Refactor the RAW format handling by storing the actual hardware output format (RAW10/RAW12) in the format table instead of the workaround value RAW16. The RAW16 workaround is now applied at runtime in mxc_isi_channel_set_output_format() via the new isi_out_raw_shifted() helper in imx8-isi-regs.h.

This makes the format table accurately reflect the real hardware capability.

---

Quoted 170 lines

Changes in v4:
- New patch

---
 drivers/media/platform/nxp/imx8-isi/imx8-isi-hw.c  |  7 ++++-
 .../media/platform/nxp/imx8-isi/imx8-isi-regs.h    | 13 ++++++++++
 .../media/platform/nxp/imx8-isi/imx8-isi-video.c   | 30 ++++++++--------------
 3 files changed, 30 insertions(+), 20 deletions(-)
drivers/media/platform/nxp/imx8-isi/imx8-isi-hw.c +6 -1
index 6aa760ce3605..cc52a90c2477 100644
@@ -411,13 +411,18 @@ void mxc_isi_channel_set_output_format(struct mxc_isi_pipe *pipe,
 				       struct v4l2_pix_format_mplane *format)
 {
 	u32 val;
+	u32 fmt;
 
 	/* set outbuf format */
 	dev_dbg(pipe->isi->dev, "output format %p4cc", &format->pixelformat);
 
+	fmt = isi_out_raw_shifted(info->isi_out_format)
+	    ? CHNL_IMG_CTRL_FORMAT_RAW16
+	    : info->isi_out_format;
+
 	val = mxc_isi_read(pipe, CHNL_IMG_CTRL);
 	val &= ~CHNL_IMG_CTRL_FORMAT_MASK;
-	val |= CHNL_IMG_CTRL_FORMAT(info->isi_out_format);
+	val |= CHNL_IMG_CTRL_FORMAT(fmt);
 	mxc_isi_write(pipe, CHNL_IMG_CTRL, val);
 
 	/* line pitch */
drivers/media/platform/nxp/imx8-isi/imx8-isi-regs.h +13 -0
index c704be882705..0f3ada30e71e 100644
@@ -421,4 +421,17 @@
 /* Channel Input Buffer Extended Address Bits */
 #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.
+ */
+static inline bool isi_out_raw_shifted(u32 format)
+{
+	return format == CHNL_IMG_CTRL_FORMAT_RAW10 ||
+	       format == CHNL_IMG_CTRL_FORMAT_RAW12;
+}
+
 #endif /* __IMX8_ISI_REGS_H__ */
drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c +11 -20
index 21849af3121b..365057db47bd 100644
@@ -218,15 +218,7 @@ static const struct mxc_isi_format_info mxc_isi_formats[] = {
 		.depth		= { 32 },
 		.encoding	= MXC_ISI_ENC_RGB,
 	},
-	/*
-	 * RAW formats
-	 *
-	 * The ISI shifts the 10-bit and 12-bit formats left by 6 and 4 bits
-	 * when using CHNL_IMG_CTRL_FORMAT_RAW10 or MXC_ISI_OUT_FMT_RAW12
-	 * respectively, to align the bits to the left and pad with zeros in
-	 * the LSBs. The corresponding V4L2 formats are however right-aligned,
-	 * we have to use CHNL_IMG_CTRL_FORMAT_RAW16 to avoid the left shift.
-	 */
+	/* RAW formats */
 	{
 		.mbus_code	= MEDIA_BUS_FMT_Y8_1X8,
 		.fourcc		= V4L2_PIX_FMT_GREY,
@@ -240,7 +232,7 @@ static const struct mxc_isi_format_info mxc_isi_formats[] = {
 		.mbus_code	= MEDIA_BUS_FMT_Y10_1X10,
 		.fourcc		= V4L2_PIX_FMT_Y10,
 		.type		= MXC_ISI_VIDEO_CAP,
-		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW16,
+		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW10,
 		.mem_planes	= 1,
 		.color_planes	= 1,
 		.depth		= { 16 },
@@ -249,7 +241,7 @@ static const struct mxc_isi_format_info mxc_isi_formats[] = {
 		.mbus_code	= MEDIA_BUS_FMT_Y12_1X12,
 		.fourcc		= V4L2_PIX_FMT_Y12,
 		.type		= MXC_ISI_VIDEO_CAP,
-		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW16,
+		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW12,
 		.mem_planes	= 1,
 		.color_planes	= 1,
 		.depth		= { 16 },
@@ -312,7 +304,7 @@ static const struct mxc_isi_format_info mxc_isi_formats[] = {
 		.mbus_code	= MEDIA_BUS_FMT_SBGGR10_1X10,
 		.fourcc		= V4L2_PIX_FMT_SBGGR10,
 		.type		= MXC_ISI_VIDEO_CAP,
-		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW16,
+		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW10,
 		.mem_planes	= 1,
 		.color_planes	= 1,
 		.depth		= { 16 },
@@ -321,7 +313,7 @@ static const struct mxc_isi_format_info mxc_isi_formats[] = {
 		.mbus_code	= MEDIA_BUS_FMT_SGBRG10_1X10,
 		.fourcc		= V4L2_PIX_FMT_SGBRG10,
 		.type		= MXC_ISI_VIDEO_CAP,
-		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW16,
+		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW10,
 		.mem_planes	= 1,
 		.color_planes	= 1,
 		.depth		= { 16 },
@@ -330,7 +322,7 @@ static const struct mxc_isi_format_info mxc_isi_formats[] = {
 		.mbus_code	= MEDIA_BUS_FMT_SGRBG10_1X10,
 		.fourcc		= V4L2_PIX_FMT_SGRBG10,
 		.type		= MXC_ISI_VIDEO_CAP,
-		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW16,
+		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW10,
 		.mem_planes	= 1,
 		.color_planes	= 1,
 		.depth		= { 16 },
@@ -339,7 +331,7 @@ static const struct mxc_isi_format_info mxc_isi_formats[] = {
 		.mbus_code	= MEDIA_BUS_FMT_SRGGB10_1X10,
 		.fourcc		= V4L2_PIX_FMT_SRGGB10,
 		.type		= MXC_ISI_VIDEO_CAP,
-		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW16,
+		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW10,
 		.mem_planes	= 1,
 		.color_planes	= 1,
 		.depth		= { 16 },
@@ -348,7 +340,7 @@ static const struct mxc_isi_format_info mxc_isi_formats[] = {
 		.mbus_code	= MEDIA_BUS_FMT_SBGGR12_1X12,
 		.fourcc		= V4L2_PIX_FMT_SBGGR12,
 		.type		= MXC_ISI_VIDEO_CAP,
-		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW16,
+		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW12,
 		.mem_planes	= 1,
 		.color_planes	= 1,
 		.depth		= { 16 },
@@ -357,7 +349,7 @@ static const struct mxc_isi_format_info mxc_isi_formats[] = {
 		.mbus_code	= MEDIA_BUS_FMT_SGBRG12_1X12,
 		.fourcc		= V4L2_PIX_FMT_SGBRG12,
 		.type		= MXC_ISI_VIDEO_CAP,
-		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW16,
+		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW12,
 		.mem_planes	= 1,
 		.color_planes	= 1,
 		.depth		= { 16 },
@@ -366,7 +358,7 @@ static const struct mxc_isi_format_info mxc_isi_formats[] = {
 		.mbus_code	= MEDIA_BUS_FMT_SGRBG12_1X12,
 		.fourcc		= V4L2_PIX_FMT_SGRBG12,
 		.type		= MXC_ISI_VIDEO_CAP,
-		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW16,
+		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW12,
 		.mem_planes	= 1,
 		.color_planes	= 1,
 		.depth		= { 16 },
@@ -375,7 +367,7 @@ static const struct mxc_isi_format_info mxc_isi_formats[] = {
 		.mbus_code	= MEDIA_BUS_FMT_SRGGB12_1X12,
 		.fourcc		= V4L2_PIX_FMT_SRGGB12,
 		.type		= MXC_ISI_VIDEO_CAP,
-		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW16,
+		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW12,
 		.mem_planes	= 1,
 		.color_planes	= 1,
 		.depth		= { 16 },
 
--

2.34.1

#14 lore raw

PATCH v4 6/11 media: imx8-isi: Add RAW14 output format support

In reply to Guoniu Zhou

From i.MX8ULP onwards, the ISI added RAW14 output format. Add its register definition and use it for all 14-bit RAW formats in the format table instead of RAW16.

Include RAW14 in isi_out_raw_shifted() so the RAW16 workaround covers it on platforms that lack LSB-aligned RAW output.

---
Changes in v4:
- New patch

---
 drivers/media/platform/nxp/imx8-isi/imx8-isi-regs.h  |  5 ++++-
 drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c | 10 +++++-----
 2 files changed, 9 insertions(+), 6 deletions(-)
drivers/media/platform/nxp/imx8-isi/imx8-isi-regs.h +4 -1
index 0f3ada30e71e..5f66b7c9cd1c 100644
@@ -89,6 +89,8 @@
 #define CHNL_IMG_CTRL_FORMAT_YUV420_3P10P			0x3a
 #define CHNL_IMG_CTRL_FORMAT_YUV420_2P12			0x3d
 #define CHNL_IMG_CTRL_FORMAT_YUV420_3P12			0x3e
+#define CHNL_IMG_CTRL_FORMAT_RAW14				0x41	/* i.MX{8ULP,91,93,95} */
+
 #define CHNL_IMG_CTRL_GBL_ALPHA_VAL(n)				((n) << 16)
 #define CHNL_IMG_CTRL_GBL_ALPHA_VAL_MASK			GENMASK(23, 16)
 #define CHNL_IMG_CTRL_GBL_ALPHA_EN				BIT(15)
@@ -431,7 +433,8 @@
 static inline bool isi_out_raw_shifted(u32 format)
 {
 	return format == CHNL_IMG_CTRL_FORMAT_RAW10 ||
-	       format == CHNL_IMG_CTRL_FORMAT_RAW12;
+	       format == CHNL_IMG_CTRL_FORMAT_RAW12 ||
+	       format == CHNL_IMG_CTRL_FORMAT_RAW14;
 }
 
 #endif /* __IMX8_ISI_REGS_H__ */
drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c +5 -5
index 365057db47bd..feef79b1b718 100644
@@ -250,7 +250,7 @@ static const struct mxc_isi_format_info mxc_isi_formats[] = {
 		.mbus_code	= MEDIA_BUS_FMT_Y14_1X14,
 		.fourcc		= V4L2_PIX_FMT_Y14,
 		.type		= MXC_ISI_VIDEO_CAP,
-		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW16,
+		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW14,
 		.mem_planes	= 1,
 		.color_planes	= 1,
 		.depth		= { 16 },
@@ -376,7 +376,7 @@ static const struct mxc_isi_format_info mxc_isi_formats[] = {
 		.mbus_code	= MEDIA_BUS_FMT_SBGGR14_1X14,
 		.fourcc		= V4L2_PIX_FMT_SBGGR14,
 		.type		= MXC_ISI_VIDEO_CAP,
-		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW16,
+		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW14,
 		.mem_planes	= 1,
 		.color_planes	= 1,
 		.depth		= { 16 },
@@ -385,7 +385,7 @@ static const struct mxc_isi_format_info mxc_isi_formats[] = {
 		.mbus_code	= MEDIA_BUS_FMT_SGBRG14_1X14,
 		.fourcc		= V4L2_PIX_FMT_SGBRG14,
 		.type		= MXC_ISI_VIDEO_CAP,
-		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW16,
+		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW14,
 		.mem_planes	= 1,
 		.color_planes	= 1,
 		.depth		= { 16 },
@@ -394,7 +394,7 @@ static const struct mxc_isi_format_info mxc_isi_formats[] = {
 		.mbus_code	= MEDIA_BUS_FMT_SGRBG14_1X14,
 		.fourcc		= V4L2_PIX_FMT_SGRBG14,
 		.type		= MXC_ISI_VIDEO_CAP,
-		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW16,
+		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW14,
 		.mem_planes	= 1,
 		.color_planes	= 1,
 		.depth		= { 16 },
@@ -403,7 +403,7 @@ static const struct mxc_isi_format_info mxc_isi_formats[] = {
 		.mbus_code	= MEDIA_BUS_FMT_SRGGB14_1X14,
 		.fourcc		= V4L2_PIX_FMT_SRGGB14,
 		.type		= MXC_ISI_VIDEO_CAP,
-		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW16,
+		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW14,
 		.mem_planes	= 1,
 		.color_planes	= 1,
 		.depth		= { 16 },
Signature · 1 line
2.34.1
Reviewed-by on v4 6/11
#15 lore raw

Re: [PATCH v4 06/11] media: imx8-isi: Add RAW14 output format support

Quoted 4 lines · Guoniu Zhou

From i.MX8ULP onwards, the ISI added RAW14 output format. Add its register definition and use it for all 14-bit RAW formats in the format table instead of RAW16.

Quoted 8 lines

Include RAW14 in isi_out_raw_shifted() so the RAW16 workaround covers it on platforms that lack LSB-aligned RAW output.

---
Changes in v4:
- New patch
---

Quoted 81 lines
 drivers/media/platform/nxp/imx8-isi/imx8-isi-regs.h  |  5 ++++-
 drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c | 10 +++++-----
 2 files changed, 9 insertions(+), 6 deletions(-)
drivers/media/platform/nxp/imx8-isi/imx8-isi-regs.h +4 -1
index 0f3ada30e71e..5f66b7c9cd1c 100644
@@ -89,6 +89,8 @@
 #define CHNL_IMG_CTRL_FORMAT_YUV420_3P10P			0x3a
 #define CHNL_IMG_CTRL_FORMAT_YUV420_2P12			0x3d
 #define CHNL_IMG_CTRL_FORMAT_YUV420_3P12			0x3e
+#define CHNL_IMG_CTRL_FORMAT_RAW14				0x41	/* i.MX{8ULP,91,93,95} */
+
 #define CHNL_IMG_CTRL_GBL_ALPHA_VAL(n)				((n) << 16)
 #define CHNL_IMG_CTRL_GBL_ALPHA_VAL_MASK			GENMASK(23, 16)
 #define CHNL_IMG_CTRL_GBL_ALPHA_EN				BIT(15)
@@ -431,7 +433,8 @@
 static inline bool isi_out_raw_shifted(u32 format)
 {
 	return format == CHNL_IMG_CTRL_FORMAT_RAW10 ||
-	       format == CHNL_IMG_CTRL_FORMAT_RAW12;
+	       format == CHNL_IMG_CTRL_FORMAT_RAW12 ||
+	       format == CHNL_IMG_CTRL_FORMAT_RAW14;
 }
 
 #endif /* __IMX8_ISI_REGS_H__ */
drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c +5 -6
index 365057db47bd..feef79b1b718 100644
@@ -250,7 +250,7 @@ static const struct mxc_isi_format_info mxc_isi_formats[] = {
 		.mbus_code	= MEDIA_BUS_FMT_Y14_1X14,
 		.fourcc		= V4L2_PIX_FMT_Y14,
 		.type		= MXC_ISI_VIDEO_CAP,
-		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW16,
+		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW14,
 		.mem_planes	= 1,
 		.color_planes	= 1,
 		.depth		= { 16 },
@@ -376,7 +376,7 @@ static const struct mxc_isi_format_info mxc_isi_formats[] = {
 		.mbus_code	= MEDIA_BUS_FMT_SBGGR14_1X14,
 		.fourcc		= V4L2_PIX_FMT_SBGGR14,
 		.type		= MXC_ISI_VIDEO_CAP,
-		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW16,
+		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW14,
 		.mem_planes	= 1,
 		.color_planes	= 1,
 		.depth		= { 16 },
@@ -385,7 +385,7 @@ static const struct mxc_isi_format_info mxc_isi_formats[] = {
 		.mbus_code	= MEDIA_BUS_FMT_SGBRG14_1X14,
 		.fourcc		= V4L2_PIX_FMT_SGBRG14,
 		.type		= MXC_ISI_VIDEO_CAP,
-		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW16,
+		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW14,
 		.mem_planes	= 1,
 		.color_planes	= 1,
 		.depth		= { 16 },
@@ -394,7 +394,7 @@ static const struct mxc_isi_format_info mxc_isi_formats[] = {
 		.mbus_code	= MEDIA_BUS_FMT_SGRBG14_1X14,
 		.fourcc		= V4L2_PIX_FMT_SGRBG14,
 		.type		= MXC_ISI_VIDEO_CAP,
-		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW16,
+		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW14,
 		.mem_planes	= 1,
 		.color_planes	= 1,
 		.depth		= { 16 },
@@ -403,7 +403,7 @@ static const struct mxc_isi_format_info mxc_isi_formats[] = {
 		.mbus_code	= MEDIA_BUS_FMT_SRGGB14_1X14,
 		.fourcc		= V4L2_PIX_FMT_SRGGB14,
 		.type		= MXC_ISI_VIDEO_CAP,
-		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW16,
+		.isi_out_format	= CHNL_IMG_CTRL_FORMAT_RAW14,
 		.mem_planes	= 1,
 		.color_planes	= 1,
 		.depth		= { 16 },
 
--

2.34.1

#16 lore raw

PATCH v4 7/11 media: imx8-isi: Select MSB-aligned RAW input from pixel link on i.MX95

In reply to Guoniu Zhou

The ISI receives RAW data from the Pixel Link, whose alignment is determined by the SoC integration. Before i.MX93, the Pixel Link provides LSB-aligned RAW data to the ISI. Starting with i.MX93, both LSB and MSB alignment are supported and can be selected via CHNL_CTRL_RAW_IN_MSB_ALIGN, with the default keeping LSB alignment for backward compatibility. From i.MX95 onwards, the CSI formatter replaces the gasket and only provides MSB-aligned RAW data.

Set CHNL_CTRL_RAW_IN_MSB_ALIGN on i.MX95 so the ISI selects RAW samples from the high bits of the Pixel Link bus.

---
Changes in v4:
- New patch

---
 drivers/media/platform/nxp/imx8-isi/imx8-isi-hw.c   | 20 ++++++++++++++++++++
 drivers/media/platform/nxp/imx8-isi/imx8-isi-regs.h |  1 +
 2 files changed, 21 insertions(+)
drivers/media/platform/nxp/imx8-isi/imx8-isi-hw.c +20 -0
index cc52a90c2477..b3f32b9796d5 100644
@@ -303,6 +303,22 @@ static void mxc_isi_channel_set_panic_threshold(struct mxc_isi_pipe *pipe)
 	mxc_isi_write(pipe, CHNL_OUT_BUF_CTRL, val);
 }
 
+/*
+ * The ISI receives RAW data from the Pixel Link, whose alignment is
+ * determined by the SoC integration. It originally selected RAW samples
+ * from the low bits of the Pixel Link bus. Starting with i.MX93,
+ * CHNL_CTRL_RAW_IN_MSB_ALIGN was introduced to allow the ISI to select
+ * RAW samples from either the high or low bits, as both LSB and MSB
+ * alignment can be selected in the gasket.
+ *
+ * On i.MX95, the CSI formatter provides MSB-aligned RAW data, so the ISI
+ * must select RAW samples from the high bits of the Pixel Link bus.
+ */
+static bool isi_raw_in_msb(const struct mxc_isi_plat_data *pdata)
+{
+	return pdata->model == MXC_ISI_IMX95;
+}
+
 static void mxc_isi_channel_set_control(struct mxc_isi_pipe *pipe,
 					enum mxc_isi_input_id input,
 					unsigned int vc,
@@ -357,6 +373,10 @@ static void mxc_isi_channel_set_control(struct mxc_isi_pipe *pipe,
 			val |= CHNL_CTRL_VC_ID_1(vc >> 2);
 	}
 
+	/* Select MSB-aligned RAW data from the Pixel Link when needed. */
+	if (isi_raw_in_msb(pipe->isi->pdata))
+		val |= CHNL_CTRL_RAW_IN_MSB_ALIGN;
+
 	mxc_isi_write(pipe, CHNL_CTRL, val);
 
 	mutex_unlock(&pipe->lock);
drivers/media/platform/nxp/imx8-isi/imx8-isi-regs.h +1 -0
index 5f66b7c9cd1c..35438abf3172 100644
@@ -20,6 +20,7 @@
 #define CHNL_CTRL_CHAIN_BUF_NO_CHAIN				0
 #define CHNL_CTRL_CHAIN_BUF_2_CHAIN				1
 #define CHNL_CTRL_SW_RST					BIT(24)
+#define CHNL_CTRL_RAW_IN_MSB_ALIGN				BIT(22)	/* i.MX{91,93,95} */
 /*
  * CHNL_CTRL_BLANK_PXL: i.MX8{QM,QXP} only
  * CHNL_CTRL_VC_ID_1, CHNL_CTRL_VC_ID_1_MASK: i.MX95 only
Signature · 1 line
2.34.1
#17 lore raw

Re: [PATCH v4 07/11] media: imx8-isi: Select MSB-aligned RAW input from pixel link on i.MX95

Quoted 32 lines · Guoniu Zhou

The ISI receives RAW data from the Pixel Link, whose alignment is determined by the SoC integration. Before i.MX93, the Pixel Link provides LSB-aligned RAW data to the ISI. Starting with i.MX93, both LSB and MSB alignment are supported and can be selected via CHNL_CTRL_RAW_IN_MSB_ALIGN, with the default keeping LSB alignment for backward compatibility. From i.MX95 onwards, the CSI formatter replaces the gasket and only provides MSB-aligned RAW data.

Set CHNL_CTRL_RAW_IN_MSB_ALIGN on i.MX95 so the ISI selects RAW samples from the high bits of the Pixel Link bus.

---
Changes in v4:
- New patch

---
 drivers/media/platform/nxp/imx8-isi/imx8-isi-hw.c   | 20 ++++++++++++++++++++
 drivers/media/platform/nxp/imx8-isi/imx8-isi-regs.h |  1 +
 2 files changed, 21 insertions(+)
drivers/media/platform/nxp/imx8-isi/imx8-isi-hw.c +4 -0
index cc52a90c2477..b3f32b9796d5 100644
@@ -303,6 +303,22 @@ static void mxc_isi_channel_set_panic_threshold(struct mxc_isi_pipe *pipe)
 	mxc_isi_write(pipe, CHNL_OUT_BUF_CTRL, val);
 }
 
+/*
+ * The ISI receives RAW data from the Pixel Link, whose alignment is
+ * determined by the SoC integration. It originally selected RAW samples
+ * from the low bits of the Pixel Link bus. Starting with i.MX93,

drivers/media/platform/nxp/imx8-isi/imx8-isi-hw.c static void mxc_isi_channel_set_panic_threshold(struct mxc_isi_pipe *pipe) · line 319

Quoted 10 lines
drivers/media/platform/nxp/imx8-isi/imx8-isi-hw.c +10 -0
+ * CHNL_CTRL_RAW_IN_MSB_ALIGN was introduced to allow the ISI to select
+ * RAW samples from either the high or low bits, as both LSB and MSB
+ * alignment can be selected in the gasket.
+ *
+ * On i.MX95, the CSI formatter provides MSB-aligned RAW data, so the ISI
+ * must select RAW samples from the high bits of the Pixel Link bus.
+ */
+static bool isi_raw_in_msb(const struct mxc_isi_plat_data *pdata)
+{
+	return pdata->model == MXC_ISI_IMX95;

Can you add bool in plat_data to avoid check model? In case future other chip also use msb and complex check logic here.

Frank

Quoted 33 lines
drivers/media/platform/nxp/imx8-isi/imx8-isi-hw.c +6 -0
+}
+
 static void mxc_isi_channel_set_control(struct mxc_isi_pipe *pipe,
 					enum mxc_isi_input_id input,
 					unsigned int vc,
@@ -357,6 +373,10 @@ static void mxc_isi_channel_set_control(struct mxc_isi_pipe *pipe,
 			val |= CHNL_CTRL_VC_ID_1(vc >> 2);
 	}
 
+	/* Select MSB-aligned RAW data from the Pixel Link when needed. */
+	if (isi_raw_in_msb(pipe->isi->pdata))
+		val |= CHNL_CTRL_RAW_IN_MSB_ALIGN;
+
 	mxc_isi_write(pipe, CHNL_CTRL, val);
 
 	mutex_unlock(&pipe->lock);
drivers/media/platform/nxp/imx8-isi/imx8-isi-regs.h +1 -1
index 5f66b7c9cd1c..35438abf3172 100644
@@ -20,6 +20,7 @@
 #define CHNL_CTRL_CHAIN_BUF_NO_CHAIN				0
 #define CHNL_CTRL_CHAIN_BUF_2_CHAIN				1
 #define CHNL_CTRL_SW_RST					BIT(24)
+#define CHNL_CTRL_RAW_IN_MSB_ALIGN				BIT(22)	/* i.MX{91,93,95} */
 /*
  * CHNL_CTRL_BLANK_PXL: i.MX8{QM,QXP} only
  * CHNL_CTRL_VC_ID_1, CHNL_CTRL_VC_ID_1_MASK: i.MX95 only
 
--

2.34.1

#18 lore raw

RE: [PATCH v4 07/11] media: imx8-isi: Select MSB-aligned RAW input from pixel link on i.MX95

Hi Frank,

Thanks for your review.

NXP Confidential

Quoted 59 lines

-----Original Message-----
From: Frank Li (OSS) <[email protected]>
Sent: Tuesday, September 29, 2026 10:32 PM
To: G.N. Zhou (OSS) <[email protected]>
Cc: Laurent Pinchart <[email protected]>; Frank Li <[email protected]>; Mauro Carvalho Chehab <[email protected]>; Sascha Hauer <[email protected]>; Pengutronix Kernel Team <[email protected]>; Fabio Estevam <[email protected]>; Rob Herring <[email protected]>; Krzysztof Kozlowski <[email protected]>; Conor Dooley <[email protected]>; Loic Poulain <[email protected]>; [email protected]; [email protected]; [email protected]; linux- [email protected]; [email protected]
Subject: Re: [PATCH v4 07/11] media: imx8-isi: Select MSB-aligned RAW input from pixel link on i.MX95

Quoted 5 lines · Guoniu Zhou

The ISI receives RAW data from the Pixel Link, whose alignment is determined by the SoC integration. Before i.MX93, the Pixel Link provides LSB-aligned RAW data to the ISI. Starting with i.MX93, both LSB and MSB alignment are supported and can be selected via CHNL_CTRL_RAW_IN_MSB_ALIGN, with the default keeping LSB alignment

for

Quoted 6 lines

backward compatibility. From i.MX95 onwards, the CSI formatter replaces the gasket and only provides MSB-aligned RAW data.

Set CHNL_CTRL_RAW_IN_MSB_ALIGN on i.MX95 so the ISI selects RAW samples from the high bits of the Pixel Link bus.

Quoted 6 lines

---
Changes in v4:
- New patch

---
 drivers/media/platform/nxp/imx8-isi/imx8-isi-hw.c   | 20

++++++++++++++++++++

drivers/media/platform/nxp/imx8-isi/imx8-isi-hw.c static void

Quoted 9 lines
 drivers/media/platform/nxp/imx8-isi/imx8-isi-regs.h |  1 +
 2 files changed, 21 insertions(+)
drivers/media/platform/nxp/imx8-isi/imx8-isi-hw.c +0 -0
index cc52a90c2477..b3f32b9796d5 100644
@@ -303,6 +303,22 @@ static void

mxc_isi_channel_set_panic_threshold(struct mxc_isi_pipe *pipe)

Quoted 13 lines
drivers/media/platform/nxp/imx8-isi/imx8-isi-hw.c +11 -0
    mxc_isi_write(pipe, CHNL_OUT_BUF_CTRL, val);  }
 
+/*
+ * The ISI receives RAW data from the Pixel Link, whose alignment is
+ * determined by the SoC integration. It originally selected RAW
+samples
+ * from the low bits of the Pixel Link bus. Starting with i.MX93,
+ * CHNL_CTRL_RAW_IN_MSB_ALIGN was introduced to allow the ISI to
+select
+ * RAW samples from either the high or low bits, as both LSB and MSB
+ * alignment can be selected in the gasket.
+ *
+ * On i.MX95, the CSI formatter provides MSB-aligned RAW data, so the
Quoted 8 lines

drivers/media/platform/nxp/imx8-isi/imx8-isi-hw.c static void mxc_isi_channel_set_panic_threshold(struct mxc_isi_pipe *pipe) · line 319

Quoted 5 lines
drivers/media/platform/nxp/imx8-isi/imx8-isi-hw.c +5 -0
+ISI
+ * must select RAW samples from the high bits of the Pixel Link bus.
+ */
+static bool isi_raw_in_msb(const struct mxc_isi_plat_data *pdata) {
+   return pdata->model == MXC_ISI_IMX95;

Can you add bool in plat_data to avoid check model? In case future other chip also use msb and complex check logic here.

I used the model field here to be consistent with the approach suggested by Laurent during the v2 review.

In v2, I used a Boolean(bool raw_out_lsb) in plat_data to determine whether the ISI RAW output should be LSB-aligned, and Laurent suggested using the model field instead. Based on that feedback, I followed the same approach here for the RAW input alignment.

Please see the discussion here for more details:
https://lore.kernel.org/all/[email protected]/

Best Regards
G.N Zhou

Quoted 39 lines

Frank

drivers/media/platform/nxp/imx8-isi/imx8-isi-hw.c static void mxc_isi_channel_set_control(struct

Quoted 6 lines
drivers/media/platform/nxp/imx8-isi/imx8-isi-hw.c +2 -0
+}
+
 static void mxc_isi_channel_set_control(struct mxc_isi_pipe *pipe,
                                    enum mxc_isi_input_id input,
                                    unsigned int vc,
@@ -357,6 +373,10 @@ static void mxc_isi_channel_set_control(struct

mxc_isi_pipe *pipe,

Quoted 16 lines
drivers/media/platform/nxp/imx8-isi/imx8-isi-hw.c +4 -0
                    val |= CHNL_CTRL_VC_ID_1(vc >> 2);
    }
 
+   /* Select MSB-aligned RAW data from the Pixel Link when needed. */
+   if (isi_raw_in_msb(pipe->isi->pdata))
+           val |= CHNL_CTRL_RAW_IN_MSB_ALIGN;
+
    mxc_isi_write(pipe, CHNL_CTRL, val);
 
    mutex_unlock(&pipe->lock);
drivers/media/platform/nxp/imx8-isi/imx8-isi-regs.h +0 -0
index 5f66b7c9cd1c..35438abf3172 100644

drivers/media/platform/nxp/imx8-isi/imx8-isi-regs.h line 23

Quoted 4 lines
drivers/media/platform/nxp/imx8-isi/imx8-isi-regs.h +1 -0
@@ -20,6 +20,7 @@
 #define CHNL_CTRL_CHAIN_BUF_NO_CHAIN                               0
 #define CHNL_CTRL_CHAIN_BUF_2_CHAIN                                1
 #define CHNL_CTRL_SW_RST                                   BIT(24)
+#define CHNL_CTRL_RAW_IN_MSB_ALIGN
      BIT(22) /* i.MX{91,93,95} */
Quoted 8 lines
drivers/media/platform/nxp/imx8-isi/imx8-isi-regs.h +0 -1
 /*
  * CHNL_CTRL_BLANK_PXL: i.MX8{QM,QXP} only
  * CHNL_CTRL_VC_ID_1, CHNL_CTRL_VC_ID_1_MASK: i.MX95 only
 
--

2.34.1

#19 lore raw

Re: [PATCH v4 07/11] media: imx8-isi: Select MSB-aligned RAW input from pixel link on i.MX95

Quoted 6 lines · G.N. Zhou (OSS)

Hi Frank,

Thanks for your review.

NXP Confidential

Please remove this tags before send

...

Quoted 10 lines
Quoted 6 lines

Review

Quoted 3 lines

+ */

(quoted diff) +2 -0
+static bool isi_raw_in_msb(const struct mxc_isi_plat_data *pdata) {
+   return pdata->model == MXC_ISI_IMX95;

Can you add bool in plat_data to avoid check model? In case future other chip also use msb and complex check logic here.

I used the model field here to be consistent with the approach suggested by Laurent during the v2 review.

Quoted 6 lines

In v2, I used a Boolean(bool raw_out_lsb) in plat_data to determine whether the ISI RAW output should be LSB-aligned, and Laurent suggested using the model field instead. Based on that feedback, I followed the same approach here for the RAW input alignment.

Please see the discussion here for more details:
https://lore.kernel.org/all/[email protected]/

Laurent base on single SoC. But most likely it is not true in future. Use model field is not extentable enough. Now can't prefer use mode at most subsystem. I can reply original thread.

Frank

Quoted 43 lines

Best Regards
G.N Zhou

Quoted 39 lines

Frank

drivers/media/platform/nxp/imx8-isi/imx8-isi-hw.c static void mxc_isi_channel_set_control(struct

Quoted 6 lines
drivers/media/platform/nxp/imx8-isi/imx8-isi-hw.c +2 -0
+}
+
 static void mxc_isi_channel_set_control(struct mxc_isi_pipe *pipe,
                                    enum mxc_isi_input_id input,
                                    unsigned int vc,
@@ -357,6 +373,10 @@ static void mxc_isi_channel_set_control(struct

mxc_isi_pipe *pipe,

Quoted 16 lines
drivers/media/platform/nxp/imx8-isi/imx8-isi-hw.c +4 -0
                    val |= CHNL_CTRL_VC_ID_1(vc >> 2);
    }
 
+   /* Select MSB-aligned RAW data from the Pixel Link when needed. */
+   if (isi_raw_in_msb(pipe->isi->pdata))
+           val |= CHNL_CTRL_RAW_IN_MSB_ALIGN;
+
    mxc_isi_write(pipe, CHNL_CTRL, val);
 
    mutex_unlock(&pipe->lock);
drivers/media/platform/nxp/imx8-isi/imx8-isi-regs.h +0 -0
index 5f66b7c9cd1c..35438abf3172 100644

drivers/media/platform/nxp/imx8-isi/imx8-isi-regs.h line 23

Quoted 4 lines
drivers/media/platform/nxp/imx8-isi/imx8-isi-regs.h +1 -0
@@ -20,6 +20,7 @@
 #define CHNL_CTRL_CHAIN_BUF_NO_CHAIN                               0
 #define CHNL_CTRL_CHAIN_BUF_2_CHAIN                                1
 #define CHNL_CTRL_SW_RST                                   BIT(24)
+#define CHNL_CTRL_RAW_IN_MSB_ALIGN
      BIT(22) /* i.MX{91,93,95} */
Quoted 8 lines
drivers/media/platform/nxp/imx8-isi/imx8-isi-regs.h +0 -1
 /*
  * CHNL_CTRL_BLANK_PXL: i.MX8{QM,QXP} only
  * CHNL_CTRL_VC_ID_1, CHNL_CTRL_VC_ID_1_MASK: i.MX95 only
 
--

2.34.1

#20 lore raw

PATCH v4 8/11 media: imx8-isi: Exclude RAW10/12/14 output formats on i.MX95

In reply to Guoniu Zhou

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.

---
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(-)
drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h +4 -2
index a30633a7e2e9..ba0d6df98fd4 100644
@@ -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,
+			 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);
 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);
drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c +1 -1
index 1178947bb548..1ad0fd1af3b1 100644
@@ -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);
 	if (!info)
 		return -EINVAL;
 
drivers/media/platform/nxp/imx8-isi/imx8-isi-regs.h +5 -5
index 35438abf3172..b83a25a58ebe 100644
@@ -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)
 {
drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c +32 -6
index feef79b1b718..fac24ee3887b 100644
@@ -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)
+{
+	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;
 
Signature · 1 line
2.34.1
#21 lore raw

Re: [PATCH v4 08/11] media: imx8-isi: Exclude RAW10/12/14 output formats on i.MX95

Quoted 78 lines · Guoniu Zhou

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.

---
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(-)
drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h +4 -2
index a30633a7e2e9..ba0d6df98fd4 100644
@@ -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,
+			 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);
 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);
drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c +1 -1
index 1178947bb548..1ad0fd1af3b1 100644
@@ -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);
 	if (!info)
 		return -EINVAL;
 
drivers/media/platform/nxp/imx8-isi/imx8-isi-regs.h +5 -5
index 35438abf3172..b83a25a58ebe 100644
@@ -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)
 {
drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c +1 -0
index feef79b1b718..fac24ee3887b 100644
@@ -458,14 +458,32 @@ static const struct mxc_isi_format_info mxc_isi_formats[] = {
 	}
 };
 
+/*

drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c static const struct mxc_isi_format_info mxc_isi_formats[] = { · line 471

Quoted 10 lines
drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c +10 -0
+ * 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)
+{
+	return pdata && pdata->model == MXC_ISI_IMX95 &&
+	       isi_out_raw_shifted(fmt->isi_out_format);

The same here. don't check model.

Frank

Quoted 86 lines
drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c +21 -7
+}
+
 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;
 
 
--

2.34.1

#22 lore raw

PATCH v4 9/11 media: dt-bindings: nxp,imx8-isi: Add i.MX952 ISI compatible string

In reply to Guoniu Zhou

The i.MX952 ISI is a minor silicon revision of the i.MX95 ISI, primarily addressing RAW data alignment. The core functionality remains identical, so the i.MX952 ISI uses a fallback compatible string to fsl,imx95-isi.

---
Changes in v3:
- Add Reviewed-by/Acked-by tag from Frank, Laurent and Dooley

Changes in v2:
- Use fallback compatible fsl,imx95-isi for imx952 (Frank, Conor Dooley)

---
 .../devicetree/bindings/media/nxp,imx8-isi.yaml        | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)
Documentation/devicetree/bindings/media/nxp,imx8-isi.yaml +11 -7
index 279c9cd3034a..d0a99f00a45e 100644
@@ -18,13 +18,17 @@ description: |
 
 properties:
   compatible:
-    enum:
-      - fsl,imx8mn-isi
-      - fsl,imx8mp-isi
-      - fsl,imx8ulp-isi
-      - fsl,imx91-isi
-      - fsl,imx93-isi
-      - fsl,imx95-isi
+    oneOf:
+      - enum:
+          - fsl,imx8mn-isi
+          - fsl,imx8mp-isi
+          - fsl,imx8ulp-isi
+          - fsl,imx91-isi
+          - fsl,imx93-isi
+          - fsl,imx95-isi
+      - items:
+          - const: fsl,imx952-isi
+          - const: fsl,imx95-isi
 
   reg:
     maxItems: 1
Signature · 1 line
2.34.1
#23 lore raw

PATCH v4 10/11 media: imx8-isi: Add i.MX952 ISI support

In reply to Guoniu Zhou

The i.MX952 ISI is reused from the i.MX95 ISI with a minor silicon revision. It can process up to 8 image sources simultaneously and obtain image data from up to 4 pixel link sources.

---
Changes in v3:
- Extend mask globally instead of per-platform (Laurent)
- Add Reviewed-by tag from Frank

---
 drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c | 13 +++++++++++++
 drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h |  1 +
 drivers/media/platform/nxp/imx8-isi/imx8-isi-regs.h |  2 +-
 3 files changed, 15 insertions(+), 1 deletion(-)
drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c +13 -0
index f2a8eb82fbfd..bedf8515b1e7 100644
@@ -384,6 +384,18 @@ static const struct mxc_isi_plat_data mxc_imx95_data = {
 	.has_36bit_dma		= true,
 };
 
+static const struct mxc_isi_plat_data mxc_imx952_data = {
+	.model			= MXC_ISI_IMX952,
+	.num_ports		= 4,
+	.num_channels		= 8,
+	.num_vc			= 8,
+	.reg_offset		= 0x10000,
+	.ier_reg		= &mxc_imx8_isi_ier_v2,
+	.set_thd		= &mxc_imx8_isi_thd_v1,
+	.buf_active_reverse	= true,
+	.has_36bit_dma		= true,
+};
+
 /* -----------------------------------------------------------------------------
  * Power management
  */
@@ -574,6 +586,7 @@ static const struct of_device_id mxc_isi_of_match[] = {
 	{ .compatible = "fsl,imx91-isi", .data = &mxc_imx91_data },
 	{ .compatible = "fsl,imx93-isi", .data = &mxc_imx93_data },
 	{ .compatible = "fsl,imx95-isi", .data = &mxc_imx95_data },
+	{ .compatible = "fsl,imx952-isi", .data = &mxc_imx952_data },
 	{ /* sentinel */ },
 };
 MODULE_DEVICE_TABLE(of, mxc_isi_of_match);
drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h +1 -0
index ba0d6df98fd4..64e6961a4ea4 100644
@@ -164,6 +164,7 @@ enum model {
 	MXC_ISI_IMX91,
 	MXC_ISI_IMX93,
 	MXC_ISI_IMX95,
+	MXC_ISI_IMX952,
 };
 
 struct mxc_isi_plat_data {
drivers/media/platform/nxp/imx8-isi/imx8-isi-regs.h +1 -1
index b83a25a58ebe..d2b8a26b7c21 100644
@@ -23,7 +23,7 @@
 #define CHNL_CTRL_RAW_IN_MSB_ALIGN				BIT(22)	/* i.MX{91,93,95} */
 /*
  * CHNL_CTRL_BLANK_PXL: i.MX8{QM,QXP} only
- * CHNL_CTRL_VC_ID_1, CHNL_CTRL_VC_ID_1_MASK: i.MX95 only
+ * CHNL_CTRL_VC_ID_1, CHNL_CTRL_VC_ID_1_MASK: i.MX{95,952} only
  */
 #define CHNL_CTRL_BLANK_PXL(n)					FIELD_PREP(GENMASK(23, 16), (n))
 #define CHNL_CTRL_VC_ID_1(n)					FIELD_PREP(BIT(16), (n))
Signature · 1 line
2.34.1
#24 lore raw

PATCH v4 11/11 media: imx8-isi: Enable RAW10/12/14 output LSB alignment on i.MX952

In reply to Guoniu Zhou

Before i.MX952, the ISI RAW10/12/14 output formats are always MSB-aligned, which is not compatible with the V4L2 RAW format definition that requires LSB alignment.

From i.MX952 onwards, the ISI introduces CHNL_CTRL_RAW_OUT_LSB_ALIGN to select whether RAW10/12/14 outputs are MSB or LSB aligned. Enable it so the driver produces correct V4L2-compatible LSB-aligned output.

---
Changes in v4:
- Split RAW_IN_MSB_ALIGN into a separate preceding patch
- Split RAW format table and RAW14 changes into separate preceding patches
- Move isi_out_raw_shifted() to regs.h in the preceding workaround patch
- Rewrite commit message

Changes in v3:
- Use CHNL_IMG_CTRL_FORMAT_MASK instead of the removed per-platform format_mask (Laurent)
- Derive raw_out_lsb from the model field instead of dedicated platform data (Laurent)
- Clarify the CHNL_IMG_CTRL_FORMAT_RAW14 comment: the format is
documented on i.MX{8ULP,91,93,95,952} but only used on i.MX952
- Update the mxc_isi_channel_set_output_format() comment wording
- Rewrite commit message
- Add Reviewed-by tag from Frank

---
 drivers/media/platform/nxp/imx8-isi/imx8-isi-hw.c  | 37 +++++++++++++++++++---
 .../media/platform/nxp/imx8-isi/imx8-isi-regs.h    |  5 +--
 2 files changed, 36 insertions(+), 6 deletions(-)
drivers/media/platform/nxp/imx8-isi/imx8-isi-hw.c +33 -4
index b3f32b9796d5..6733776e72aa 100644
@@ -311,12 +311,24 @@ static void mxc_isi_channel_set_panic_threshold(struct mxc_isi_pipe *pipe)
  * RAW samples from either the high or low bits, as both LSB and MSB
  * alignment can be selected in the gasket.
  *
- * On i.MX95, the CSI formatter provides MSB-aligned RAW data, so the ISI
- * must select RAW samples from the high bits of the Pixel Link bus.
+ * Starting with i.MX95, the CSI formatter provides MSB-aligned RAW data,
+ * so the ISI must select RAW samples from the high bits of the Pixel Link
+ * bus.
  */
 static bool isi_raw_in_msb(const struct mxc_isi_plat_data *pdata)
 {
-	return pdata->model == MXC_ISI_IMX95;
+	return pdata->model == MXC_ISI_IMX95 ||
+	       pdata->model == MXC_ISI_IMX952;
+}
+
+/*
+ * Starting with i.MX952, the ISI can output RAW10/12/14 formats with LSB
+ * alignment, matching the V4L2 requirement. Older platforms lack this
+ * capability and need the RAW16 workaround.
+ */
+static bool isi_raw_out_lsb(const struct mxc_isi_plat_data *pdata)
+{
+	return pdata->model == MXC_ISI_IMX952;
 }
 
 static void mxc_isi_channel_set_control(struct mxc_isi_pipe *pipe,
@@ -377,6 +389,13 @@ static void mxc_isi_channel_set_control(struct mxc_isi_pipe *pipe,
 	if (isi_raw_in_msb(pipe->isi->pdata))
 		val |= CHNL_CTRL_RAW_IN_MSB_ALIGN;
 
+	/*
+	 * Enable RAW10/12/14 output LSB alignment to match the
+	 * V4L2 requirement that RAW formats are LSB-aligned.
+	 */
+	if (isi_raw_out_lsb(pipe->isi->pdata))
+		val |= CHNL_CTRL_RAW_OUT_LSB_ALIGN;
+
 	mxc_isi_write(pipe, CHNL_CTRL, val);
 
 	mutex_unlock(&pipe->lock);
@@ -430,13 +449,23 @@ void mxc_isi_channel_set_output_format(struct mxc_isi_pipe *pipe,
 				       const struct mxc_isi_format_info *info,
 				       struct v4l2_pix_format_mplane *format)
 {
+	const struct mxc_isi_plat_data *pdata = pipe->isi->pdata;
 	u32 val;
 	u32 fmt;
 
 	/* set outbuf format */
 	dev_dbg(pipe->isi->dev, "output format %p4cc", &format->pixelformat);
 
-	fmt = isi_out_raw_shifted(info->isi_out_format)
+	/*
+	 * Before i.MX952, the ISI shifts the 10/12/14-bit formats left
+	 * by 6, 4 and 2 bits when using CHNL_IMG_CTRL_FORMAT_RAW10/12/14
+	 * respectively, to align the bits to the left and pad with zeros in
+	 * the LSBs. The corresponding V4L2 formats are however right-aligned,
+	 * we have to use CHNL_IMG_CTRL_FORMAT_RAW16 to avoid the left shift.
+	 * Starting with i.MX952, the ISI supports RAW10/12/14 LSB output
+	 * alignment, so skip the above workaround.
+	 */
+	fmt = !isi_raw_out_lsb(pdata) && isi_out_raw_shifted(info->isi_out_format)
 	    ? CHNL_IMG_CTRL_FORMAT_RAW16
 	    : info->isi_out_format;
 
drivers/media/platform/nxp/imx8-isi/imx8-isi-regs.h +3 -2
index d2b8a26b7c21..075fc6848213 100644
@@ -20,7 +20,8 @@
 #define CHNL_CTRL_CHAIN_BUF_NO_CHAIN				0
 #define CHNL_CTRL_CHAIN_BUF_2_CHAIN				1
 #define CHNL_CTRL_SW_RST					BIT(24)
-#define CHNL_CTRL_RAW_IN_MSB_ALIGN				BIT(22)	/* i.MX{91,93,95} */
+#define CHNL_CTRL_RAW_OUT_LSB_ALIGN				BIT(23)	/* i.MX952 only */
+#define CHNL_CTRL_RAW_IN_MSB_ALIGN				BIT(22)	/* i.MX{91,93,95,952} */
 /*
  * CHNL_CTRL_BLANK_PXL: i.MX8{QM,QXP} only
  * CHNL_CTRL_VC_ID_1, CHNL_CTRL_VC_ID_1_MASK: i.MX{95,952} only
@@ -90,7 +91,7 @@
 #define CHNL_IMG_CTRL_FORMAT_YUV420_3P10P			0x3a
 #define CHNL_IMG_CTRL_FORMAT_YUV420_2P12			0x3d
 #define CHNL_IMG_CTRL_FORMAT_YUV420_3P12			0x3e
-#define CHNL_IMG_CTRL_FORMAT_RAW14				0x41	/* i.MX{8ULP,91,93,95} */
+#define CHNL_IMG_CTRL_FORMAT_RAW14				0x41	/* i.MX{8ULP,91,93,95,952}, used on i.MX952 only */
 
 #define CHNL_IMG_CTRL_GBL_ALPHA_VAL(n)				((n) << 16)
 #define CHNL_IMG_CTRL_GBL_ALPHA_VAL_MASK			GENMASK(23, 16)
Signature · 1 line
2.34.1