[PATCH v6 1/5] media: imx8-isi: Apply RAW output configuration at runtime
From: Guoniu Zhou
Date: Wed Dec 02 2026 - 22:25:39 EST
The format table currently stores RAW10 and RAW12 formats as
CHNL_IMG_CTRL_FORMAT_RAW16.
This matches the behaviour required by older ISI implementations, where
selecting RAW10 or RAW12 output causes samples to be shifted to MSB
alignment, while V4L2 RAW formats are expected to be stored right-aligned
in a 16-bit container. Programming RAW16 therefore produces the desired
output format.
However, this RAW16 selection is a hardware-specific configuration detail
rather than a property of the format itself.
Starting with i.MX95, the assumptions that make RAW16 suitable no longer
universally apply. The ISI may receive MSB-aligned RAW data from the pixel
link path, making RAW16 unsuitable as a generic solution for representing
V4L2 RAW formats.
Furthermore, i.MX952 introduces native RAW10/12/14 output modes with
selectable output alignment, allowing V4L2 RAW formats to be represented
directly through the corresponding hardware RAW formats.
Move the RAW output format selection to the hardware configuration path.
This allows platform-specific RAW output requirements to be handled at
runtime, while the format table describes the native RAW formats
supported by the hardware. This separation prepares the driver for newer
ISI generations with different RAW alignment capabilities.
No functional change intended.
Reviewed-by: Frank Li <Frank.Li@xxxxxxx>
Signed-off-by: Guoniu Zhou <guoniu.zhou@xxxxxxxxxxx>
---
Changes in v6:
- Update commit message to explain that RAW16 is no longer suitable for
newer ISI generations, where RAW alignment requirements differ from older platforms (Laurent).
- Squash the former v5 06/11 RAW14 format definition patch into this patch (Laurent).
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 | 16 +++++++++
.../media/platform/nxp/imx8-isi/imx8-isi-video.c | 40 +++++++++-------------
3 files changed, 38 insertions(+), 25 deletions(-)
diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-hw.c b/drivers/media/platform/nxp/imx8-isi/imx8-isi-hw.c
index 6aa760ce3605..cc52a90c2477 100644
--- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-hw.c
+++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-hw.c
@@ -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 */
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 c704be882705..5f66b7c9cd1c 100644
--- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-regs.h
+++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-regs.h
@@ -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)
@@ -421,4 +423,18 @@
/* 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 ||
+ format == CHNL_IMG_CTRL_FORMAT_RAW14;
+}
+
#endif /* __IMX8_ISI_REGS_H__ */
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 af91bd65b2c1..ca8fe8782af8 100644
--- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c
+++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-video.c
@@ -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 },
@@ -258,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 },
@@ -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 },
@@ -384,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 },
@@ -393,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 },
@@ -402,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 },
@@ -411,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