[PATCH RFC 03/10] media: i2c: imx678: Add .get_frame_desc() hook

From: Jai Luthra

Date: Fri Jul 03 2026 - 05:59:06 EST


Downstream elements, like CSI bridge drivers, need to know the MIPI CSI
virtual channel and data type to filter and route the incoming streams.

Add the required .get_frame_desc() hook they can call.

Signed-off-by: Jai Luthra <jai.luthra@xxxxxxxxxxxxxxxx>
---
drivers/media/i2c/imx678.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)

diff --git a/drivers/media/i2c/imx678.c b/drivers/media/i2c/imx678.c
index fb260ce6f5d9..51c5487fa1af 100644
--- a/drivers/media/i2c/imx678.c
+++ b/drivers/media/i2c/imx678.c
@@ -17,6 +17,7 @@
#include <linux/property.h>
#include <linux/pm_runtime.h>
#include <linux/regulator/consumer.h>
+#include <media/mipi-csi2.h>
#include <media/v4l2-cci.h>
#include <media/v4l2-ctrls.h>
#include <media/v4l2-device.h>
@@ -820,6 +821,29 @@ static const struct v4l2_ctrl_ops imx678_ctrl_ops = {
.s_ctrl = imx678_set_ctrl,
};

+static int imx678_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad,
+ struct v4l2_mbus_frame_desc *fd)
+{
+ const struct v4l2_mbus_framefmt *fmt;
+ struct v4l2_subdev_state *state;
+
+ if (pad != IMX678_SOURCE_PAD)
+ return -EINVAL;
+
+ fd->type = V4L2_MBUS_FRAME_DESC_TYPE_CSI2;
+ fd->num_entries = 1;
+ fd->entry[0].stream = IMX678_STREAM_IMAGE;
+ fd->entry[0].bus.csi2.vc = 0;
+ fd->entry[0].bus.csi2.dt = MIPI_CSI2_DT_RAW12;
+
+ state = v4l2_subdev_lock_and_get_active_state(sd);
+ fmt = v4l2_subdev_state_get_format(state, pad, IMX678_STREAM_IMAGE);
+ fd->entry[0].pixelcode = fmt->code;
+ v4l2_subdev_unlock_state(state);
+
+ return 0;
+}
+
static int imx678_enum_mbus_code(struct v4l2_subdev *sd,
struct v4l2_subdev_state *sd_state,
struct v4l2_subdev_mbus_code_enum *code)
@@ -1213,6 +1237,7 @@ static const struct v4l2_subdev_pad_ops imx678_pad_ops = {
.set_fmt = v4l2_subdev_get_fmt_ci,
.get_selection = imx678_get_selection,
.enum_frame_size = imx678_enum_frame_size,
+ .get_frame_desc = imx678_get_frame_desc,
.enable_streams = imx678_enable_streams,
.disable_streams = imx678_disable_streams,
};

--
2.54.0