* [PATCH v4 0/2] media: nxp: imx8-isi: Add virtual channel and frame descriptor support
@ 2026-05-08 3:05 Guoniu Zhou
2026-05-08 3:05 ` [PATCH v4 1/2] media: nxp: imx8-isi: Add virtual channel support Guoniu Zhou
2026-05-08 3:05 ` [PATCH v4 2/2] media: nxp: imx8-isi: Implement get_frame_desc for crossbar subdev Guoniu Zhou
0 siblings, 2 replies; 3+ messages in thread
From: Guoniu Zhou @ 2026-05-08 3:05 UTC (permalink / raw)
To: Laurent Pinchart, Mauro Carvalho Chehab, Frank Li, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam
Cc: Aisheng Dong, linux-media, imx, linux-arm-kernel, linux-kernel,
Guoniu Zhou
This patch series enhances the i.MX ISI driver's with virtual channel
support and adds frame descriptor capabilities to the crossbar subdevice.
Signed-off-by: Guoniu Zhou <guoniu.zhou@nxp.com>
---
Changes in v4:
- Rebase to latest media/next(previous dependency now in mainline)
- Fix VC boundary check: use num_vc (virtual channels count) instead of
num_channels (ISI pipelines count)
- Set VC to 0 when frame descriptor has no entries
- Move platform-specific comments to block style to fix line length warnings
- Use %d instead of %u for ret variable in error messages
- Fix potential -ENOIOCTLCMD leak by resetting ret to 0 on continue
- See each patch's changelog for details
- Link to v3: https://lore.kernel.org/r/20260328-isi_vc-v3-0-a03b9a6fe117@oss.nxp.com
Changes in v3:
- Rebased on latest media/next
- Add num_vc field to platform data to indicate VC support
- Clear VC_ID_1 bit after reading CHNL_CTRL for proper VC switching
- Set VC_ID_1 only on platforms with num_vc > 4
- Improve mxc_isi_get_vc() error handling
- Add back CHNL_CTRL_BLANK_PXL and document platform-specific register fields
- Add xbar get_frame_desc() implementation (feedback from Laurent Pinchart)
- Link to v2: https://lore.kernel.org/r/20260310-isi_vc-v2-1-acbf77db8e6f@nxp.com
Changes in v2:
- Add Rb tag from Frank Li
- Fix typo in comment(s/support/supports/)
- Update commit log to include more details about ISI virtual channel support
on different platform
- Include bitfield.h file to fix following build error
drivers/media/platform/nxp/imx8-isi/imx8-isi-regs.h:23:65: error: implicit declaration of function ‘FIELD_PREP’ [-Wimplicit-function-declaration]
- Link to v1: https://lore.kernel.org/r/20260309-isi_vc-v1-1-fd0b8035d1cd@nxp.com
Changes in v1:
- Depends on https://lore.kernel.org/linux-media/20251105-isi_imx95-v3-2-3987533cca1c@nxp.com/
---
Guoniu Zhou (1):
media: nxp: imx8-isi: Add virtual channel support
Guoniu.zhou (1):
media: nxp: imx8-isi: Implement get_frame_desc for crossbar subdev
.../media/platform/nxp/imx8-isi/imx8-isi-core.c | 3 +
.../media/platform/nxp/imx8-isi/imx8-isi-core.h | 4 +
.../platform/nxp/imx8-isi/imx8-isi-crossbar.c | 98 ++++++++++++++++++++++
drivers/media/platform/nxp/imx8-isi/imx8-isi-hw.c | 14 +++-
.../media/platform/nxp/imx8-isi/imx8-isi-pipe.c | 59 +++++++++++++
.../media/platform/nxp/imx8-isi/imx8-isi-regs.h | 12 ++-
6 files changed, 186 insertions(+), 4 deletions(-)
---
base-commit: 2c8fe1f14240d75f2002e16b2b69c5c2d27ed41c
change-id: 20260309-isi_vc-285fd815140e
Best regards,
--
Guoniu Zhou <guoniu.zhou@oss.nxp.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v4 1/2] media: nxp: imx8-isi: Add virtual channel support
2026-05-08 3:05 [PATCH v4 0/2] media: nxp: imx8-isi: Add virtual channel and frame descriptor support Guoniu Zhou
@ 2026-05-08 3:05 ` Guoniu Zhou
2026-05-08 3:05 ` [PATCH v4 2/2] media: nxp: imx8-isi: Implement get_frame_desc for crossbar subdev Guoniu Zhou
1 sibling, 0 replies; 3+ messages in thread
From: Guoniu Zhou @ 2026-05-08 3:05 UTC (permalink / raw)
To: Laurent Pinchart, Mauro Carvalho Chehab, Frank Li, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam
Cc: Aisheng Dong, linux-media, imx, linux-arm-kernel, linux-kernel,
Guoniu Zhou
From: Guoniu Zhou <guoniu.zhou@nxp.com>
The ISI supports different numbers of virtual channels depending on the
platform. i.MX95 supports 8 virtual channels, and i.MX8QXP/QM support 4
virtual channels. They are used in multiple camera use cases, such as
surround view. Other platforms (such as i.MX8/MN/MP/ULP/91/93) don't
support virtual channels, and the VC_ID bits are marked as read-only.
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Guoniu Zhou <guoniu.zhou@nxp.com>
---
Changes in v4:
- Fix VC boundary check: use num_vc (virtual channels count) instead of
num_channels (ISI pipelines count)
- Set VC to 0 when frame descriptor has no entries
- Move platform-specific comments to block style to fix line length warnings
Changes in v3:
- Add num_vc field to platform data to indicate VC support
- Clear VC_ID_1 bit after reading CHNL_CTRL for proper VC switching
- Set VC_ID_1 only on platforms with num_vc > 4
- Improve mxc_isi_get_vc() error handling
- Add back CHNL_CTRL_BLANK_PXL and document platform-specific register fields
---
.../media/platform/nxp/imx8-isi/imx8-isi-core.c | 3 ++
.../media/platform/nxp/imx8-isi/imx8-isi-core.h | 4 ++
drivers/media/platform/nxp/imx8-isi/imx8-isi-hw.c | 14 ++++-
.../media/platform/nxp/imx8-isi/imx8-isi-pipe.c | 59 ++++++++++++++++++++++
.../media/platform/nxp/imx8-isi/imx8-isi-regs.h | 12 +++--
5 files changed, 88 insertions(+), 4 deletions(-)
diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c
index 4bf8570e1b9e..837ac7046cf2 100644
--- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c
+++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c
@@ -318,6 +318,7 @@ 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,
@@ -329,6 +330,7 @@ static const struct mxc_isi_plat_data mxc_imx8qm_data = {
.model = MXC_ISI_IMX8QM,
.num_ports = 5,
.num_channels = 8,
+ .num_vc = 4,
.reg_offset = 0x10000,
.ier_reg = &mxc_imx8_isi_ier_qm,
.set_thd = &mxc_imx8_isi_thd_v1,
@@ -340,6 +342,7 @@ static const struct mxc_isi_plat_data mxc_imx8qxp_data = {
.model = MXC_ISI_IMX8QXP,
.num_ports = 5,
.num_channels = 6,
+ .num_vc = 4,
.reg_offset = 0x10000,
.ier_reg = &mxc_imx8_isi_ier_v2,
.set_thd = &mxc_imx8_isi_thd_v1,
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 14d63ec36416..195c28dbd151 100644
--- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h
+++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.h
@@ -169,6 +169,7 @@ struct mxc_isi_plat_data {
enum model model;
unsigned int num_ports;
unsigned int num_channels;
+ unsigned int num_vc; /* Number of VCs, 0 = no VC support */
unsigned int reg_offset;
const struct mxc_isi_ier_reg *ier_reg;
const struct mxc_isi_set_thd *set_thd;
@@ -257,6 +258,9 @@ struct mxc_isi_pipe {
u8 acquired_res;
u8 chained_res;
bool chained;
+
+ /* Virtual channel ID for the ISI channel */
+ u8 vc;
};
struct mxc_isi_m2m {
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 0187d4ab97e8..ecd0c2ef28b6 100644
--- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-hw.c
+++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-hw.c
@@ -308,6 +308,11 @@ static void mxc_isi_channel_set_control(struct mxc_isi_pipe *pipe,
mutex_lock(&pipe->lock);
val = mxc_isi_read(pipe, CHNL_CTRL);
+
+ /* Clear the VC_ID_1 bit on platforms supporting more than 4 VCs. */
+ if (pipe->isi->pdata->num_vc > 4)
+ val &= ~CHNL_CTRL_VC_ID_1_MASK;
+
val &= ~(CHNL_CTRL_CHNL_BYPASS | CHNL_CTRL_CHAIN_BUF_MASK |
CHNL_CTRL_SRC_TYPE_MASK | CHNL_CTRL_MIPI_VC_ID_MASK |
CHNL_CTRL_SRC_INPUT_MASK);
@@ -338,7 +343,14 @@ static void mxc_isi_channel_set_control(struct mxc_isi_pipe *pipe,
} else {
val |= CHNL_CTRL_SRC_TYPE(CHNL_CTRL_SRC_TYPE_DEVICE);
val |= CHNL_CTRL_SRC_INPUT(input);
- val |= CHNL_CTRL_MIPI_VC_ID(0); /* FIXME: For CSI-2 only */
+ val |= CHNL_CTRL_MIPI_VC_ID(pipe->vc); /* FIXME: For CSI-2 only */
+
+ /*
+ * On platforms with more than 4 VCs (i.MX95), the VC ID is
+ * split across VC_ID_0 (bits 7:6) and VC_ID_1 (bit 16).
+ */
+ if (pipe->isi->pdata->num_vc > 4)
+ val |= CHNL_CTRL_VC_ID_1(pipe->vc >> 2);
}
mxc_isi_write(pipe, CHNL_CTRL, val);
diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-pipe.c b/drivers/media/platform/nxp/imx8-isi/imx8-isi-pipe.c
index a41c51dd9ce0..e6da254a9ef0 100644
--- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-pipe.c
+++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-pipe.c
@@ -232,6 +232,61 @@ static inline struct mxc_isi_pipe *to_isi_pipe(struct v4l2_subdev *sd)
return container_of(sd, struct mxc_isi_pipe, sd);
}
+static int mxc_isi_get_vc(struct mxc_isi_pipe *pipe)
+{
+ struct mxc_isi_crossbar *xbar = &pipe->isi->crossbar;
+ struct device *dev = pipe->isi->dev;
+ struct v4l2_mbus_frame_desc fd = { };
+ unsigned int source_pad = xbar->num_sinks + pipe->id;
+ unsigned int max_vc;
+ unsigned int i;
+ int ret;
+
+ ret = v4l2_subdev_call(&xbar->sd, pad, get_frame_desc,
+ source_pad, &fd);
+ if (ret == -ENOIOCTLCMD) {
+ /*
+ * If remote subdev doesn't implement get_frame_desc.
+ * Assume virtual channel 0.
+ */
+ pipe->vc = 0;
+ return 0;
+ }
+ if (ret < 0) {
+ dev_err(dev, "Failed to get source frame desc from pad %u\n",
+ source_pad);
+ return ret;
+ }
+
+ if (!fd.num_entries) {
+ pipe->vc = 0;
+ return 0;
+ }
+
+ /* Find stream 0 in the frame descriptor */
+ for (i = 0; i < fd.num_entries; i++) {
+ if (fd.entry[i].stream == 0)
+ break;
+ }
+
+ if (i == fd.num_entries) {
+ dev_err(dev, "Failed to find stream from source frame desc\n");
+ return -EINVAL;
+ }
+
+ max_vc = pipe->isi->pdata->num_vc ? : 1;
+
+ /* Check virtual channel range */
+ if (fd.entry[i].bus.csi2.vc >= max_vc) {
+ dev_err(dev, "Virtual channel %u exceeds maximum %u\n",
+ fd.entry[i].bus.csi2.vc, max_vc - 1);
+ return -EINVAL;
+ }
+
+ pipe->vc = fd.entry[i].bus.csi2.vc;
+ return 0;
+}
+
int mxc_isi_pipe_enable(struct mxc_isi_pipe *pipe)
{
struct mxc_isi_crossbar *xbar = &pipe->isi->crossbar;
@@ -280,6 +335,10 @@ int mxc_isi_pipe_enable(struct mxc_isi_pipe *pipe)
v4l2_subdev_unlock_state(state);
+ ret = mxc_isi_get_vc(pipe);
+ if (ret)
+ return ret;
+
/* Configure the ISI channel. */
mxc_isi_channel_config(pipe, input, &in_size, &scale, &crop,
sink_info->encoding, src_info->encoding);
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 1b65eccdf0da..e795f4daf3ff 100644
--- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-regs.h
+++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-regs.h
@@ -6,6 +6,7 @@
#ifndef __IMX8_ISI_REGS_H__
#define __IMX8_ISI_REGS_H__
+#include <linux/bitfield.h>
#include <linux/bits.h>
/* ISI Registers Define */
@@ -19,9 +20,14 @@
#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_BLANK_PXL(n) ((n) << 16)
-#define CHNL_CTRL_BLANK_PXL_MASK GENMASK(23, 16)
-#define CHNL_CTRL_MIPI_VC_ID(n) ((n) << 6)
+/*
+ * CHNL_CTRL_BLANK_PXL: i.MX8{QM,QXP} only
+ * CHNL_CTRL_VC_ID_1, CHNL_CTRL_VC_ID_1_MASK: i.MX95 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))
+#define CHNL_CTRL_VC_ID_1_MASK BIT(16)
+#define CHNL_CTRL_MIPI_VC_ID(n) FIELD_PREP(GENMASK(7, 6), (n))
#define CHNL_CTRL_MIPI_VC_ID_MASK GENMASK(7, 6)
#define CHNL_CTRL_SRC_TYPE(n) ((n) << 4)
#define CHNL_CTRL_SRC_TYPE_MASK BIT(4)
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH v4 2/2] media: nxp: imx8-isi: Implement get_frame_desc for crossbar subdev
2026-05-08 3:05 [PATCH v4 0/2] media: nxp: imx8-isi: Add virtual channel and frame descriptor support Guoniu Zhou
2026-05-08 3:05 ` [PATCH v4 1/2] media: nxp: imx8-isi: Add virtual channel support Guoniu Zhou
@ 2026-05-08 3:05 ` Guoniu Zhou
1 sibling, 0 replies; 3+ messages in thread
From: Guoniu Zhou @ 2026-05-08 3:05 UTC (permalink / raw)
To: Laurent Pinchart, Mauro Carvalho Chehab, Frank Li, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam
Cc: Aisheng Dong, linux-media, imx, linux-arm-kernel, linux-kernel,
Guoniu Zhou
From: "Guoniu.zhou" <guoniu.zhou@nxp.com>
Implement the get_frame_desc pad operation for the crossbar subdevice
to propagate frame descriptor information from the source subdevice to
downstream ISI channels.
This allows the ISI driver to retrieve virtual channel information and
other stream parameters from the connected upstream, which is required
for proper virtual channel routing on platforms supporting multiple VCs.
Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
---
Changes in v4:
- Use %d instead of %u for ret variable in error messages
- Fix potential -ENOIOCTLCMD leak by resetting ret to 0 on continue
Changes in v3:
- New patch added based on feedback from Laurent Pinchart
---
.../platform/nxp/imx8-isi/imx8-isi-crossbar.c | 98 ++++++++++++++++++++++
1 file changed, 98 insertions(+)
diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-crossbar.c b/drivers/media/platform/nxp/imx8-isi/imx8-isi-crossbar.c
index 605a45124103..b5eff191b2d5 100644
--- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-crossbar.c
+++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-crossbar.c
@@ -306,6 +306,103 @@ static int mxc_isi_crossbar_set_fmt(struct v4l2_subdev *sd,
return 0;
}
+static int mxc_isi_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad,
+ struct v4l2_mbus_frame_desc *fd)
+{
+ struct mxc_isi_crossbar *xbar = to_isi_crossbar(sd);
+ struct device *dev = xbar->isi->dev;
+ struct v4l2_subdev_route *route;
+ struct v4l2_subdev_state *state;
+ int ret = 0;
+
+ if (pad < xbar->num_sinks)
+ return -EINVAL;
+
+ memset(fd, 0, sizeof(*fd));
+
+ state = v4l2_subdev_lock_and_get_active_state(sd);
+
+ /*
+ * Iterate over all active routes. For each route going through the
+ * requested source pad, get the frame descriptor from the connected
+ * source subdev, find the corresponding stream entry, and add it to
+ * the output frame descriptor with the routed stream ID.
+ */
+ for_each_active_route(&state->routing, route) {
+ struct v4l2_mbus_frame_desc source_fd;
+ struct v4l2_subdev *remote_sd;
+ struct media_pad *remote_pad;
+ unsigned int i;
+
+ if (route->source_pad != pad)
+ continue;
+
+ /* Find the remote subdev connected to this sink pad */
+ remote_pad = media_pad_remote_pad_first(&xbar->pads[route->sink_pad]);
+ if (!remote_pad) {
+ dev_dbg(dev, "no remote pad connected to crossbar input %u\n",
+ route->sink_pad);
+ continue;
+ }
+
+ remote_sd = media_entity_to_v4l2_subdev(remote_pad->entity);
+ if (!remote_sd) {
+ dev_err(dev, "no subdev connected to crossbar input %u\n",
+ route->sink_pad);
+ ret = -EPIPE;
+ goto out_unlock;
+ }
+
+ /* Get frame descriptor from the remote subdev */
+ ret = v4l2_subdev_call(remote_sd, pad, get_frame_desc,
+ remote_pad->index, &source_fd);
+ if (ret == -ENOIOCTLCMD) {
+ dev_dbg(dev, "%s:%u does not support frame descriptors\n",
+ remote_sd->entity.name, remote_pad->index);
+ ret = 0;
+ continue;
+ }
+ if (ret < 0) {
+ dev_err(dev, "failed to get frame desc from %s:%u: %d\n",
+ remote_sd->entity.name, remote_pad->index, ret);
+ goto out_unlock;
+ }
+
+ if (fd->num_entries == 0)
+ fd->type = source_fd.type;
+
+ /* Find the source frame descriptor entry matching the sink stream */
+ for (i = 0; i < source_fd.num_entries; i++) {
+ if (source_fd.entry[i].stream == route->sink_stream)
+ break;
+ }
+
+ if (i == source_fd.num_entries) {
+ dev_err(dev, "stream %u not found in frame desc from %s:%u\n",
+ route->sink_stream, remote_sd->entity.name,
+ remote_pad->index);
+ ret = -EPIPE;
+ goto out_unlock;
+ }
+
+ if (fd->num_entries >= ARRAY_SIZE(fd->entry)) {
+ dev_err(dev, "frame descriptor is full\n");
+ ret = -ENOSPC;
+ goto out_unlock;
+ }
+
+ /* Copy the entry and update the stream ID */
+ fd->entry[fd->num_entries] = source_fd.entry[i];
+ fd->entry[fd->num_entries].stream = route->source_stream;
+ fd->num_entries++;
+ }
+
+out_unlock:
+ v4l2_subdev_unlock_state(state);
+
+ return ret;
+}
+
static int mxc_isi_crossbar_set_routing(struct v4l2_subdev *sd,
struct v4l2_subdev_state *state,
enum v4l2_subdev_format_whence which,
@@ -404,6 +501,7 @@ static const struct v4l2_subdev_pad_ops mxc_isi_crossbar_subdev_pad_ops = {
.enum_mbus_code = mxc_isi_crossbar_enum_mbus_code,
.get_fmt = v4l2_subdev_get_fmt,
.set_fmt = mxc_isi_crossbar_set_fmt,
+ .get_frame_desc = mxc_isi_get_frame_desc,
.set_routing = mxc_isi_crossbar_set_routing,
.enable_streams = mxc_isi_crossbar_enable_streams,
.disable_streams = mxc_isi_crossbar_disable_streams,
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-05-08 3:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-08 3:05 [PATCH v4 0/2] media: nxp: imx8-isi: Add virtual channel and frame descriptor support Guoniu Zhou
2026-05-08 3:05 ` [PATCH v4 1/2] media: nxp: imx8-isi: Add virtual channel support Guoniu Zhou
2026-05-08 3:05 ` [PATCH v4 2/2] media: nxp: imx8-isi: Implement get_frame_desc for crossbar subdev Guoniu Zhou
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox