[PATCH v3 3/3] media: imx8mq-mipi-csi2: Implement .get_frame_desc subdev callback

guoniu.zhou
2025-08-12T09:20:00Z

Implement .get_frame_desc subdev callback since downstream subdev
need to get frame description.

Signed-off-by: Guoniu Zhou <guoniu.zhou@nxp.com>
---
drivers/media/platform/nxp/imx8mq-mipi-csi2.c | 32 +++++++++++++++++++
1 file changed, 32 insertions(+)

diff --git a/drivers/media/platform/nxp/imx8mq-mipi-csi2.c b/drivers/media/platform/nxp/imx8mq-mipi-csi2.c
index 3de9007ad122..ed6578f7f0f9 100644
--- a/drivers/media/platform/nxp/imx8mq-mipi-csi2.c
+++ b/drivers/media/platform/nxp/imx8mq-mipi-csi2.c
@@ -689,6 +689,37 @@ static int imx8mq_mipi_csi_set_fmt(struct v4l2_subdev *sd,
return 0;
}

+static int imx8mq_mipi_csi_get_frame_desc(struct v4l2_subdev *sd,
+ unsigned int pad,
+ struct v4l2_mbus_frame_desc *fd)
+{
+ struct v4l2_mbus_frame_desc_entry *entry = &fd->entry[0];
+ const struct csi2_pix_format *csi2_fmt;
+ const struct v4l2_mbus_framefmt *fmt;
+ struct v4l2_subdev_state *state;
+
+ if (pad != MIPI_CSI2_PAD_SOURCE)
+ return -EINVAL;
+
+ state = v4l2_subdev_lock_and_get_active_state(sd);
+ fmt = v4l2_subdev_state_get_format(state, MIPI_CSI2_PAD_SOURCE);
+ csi2_fmt = find_csi2_format(fmt->code);
+ v4l2_subdev_unlock_state(state);
+
+ if (!csi2_fmt)
+ return -EPIPE;
+
+ fd->type = V4L2_MBUS_FRAME_DESC_TYPE_CSI2;
+ fd->num_entries = 1;
+
+ entry->flags = 0;
+ entry->pixelcode = csi2_fmt->code;
+ entry->bus.csi2.vc = 0;
+ entry->bus.csi2.dt = csi2_fmt->data_type;
+
+ return 0;
+}
+
static const struct v4l2_subdev_video_ops imx8mq_mipi_csi_video_ops = {
.s_stream = imx8mq_mipi_csi_s_stream,
};
@@ -697,6 +728,7 @@ static const struct v4l2_subdev_pad_ops imx8mq_mipi_csi_pad_ops = {
.enum_mbus_code = imx8mq_mipi_csi_enum_mbus_code,
.get_fmt = v4l2_subdev_get_fmt,
.set_fmt = imx8mq_mipi_csi_set_fmt,
+ .get_frame_desc = imx8mq_mipi_csi_get_frame_desc,
};

static const struct v4l2_subdev_ops imx8mq_mipi_csi_subdev_ops = {
--
2.34.1