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 529928b94a193e02177f8773a0e68375b59b0a08..a28ccdeef8521c0e00d13b1860eadef5f2118651 100644
--- a/drivers/media/platform/nxp/imx8mq-mipi-csi2.c
+++ b/drivers/media/platform/nxp/imx8mq-mipi-csi2.c
@@ -648,6 +648,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 = media_bus_fmt_to_csi2_dt(csi2_fmt->code);
+
+ return 0;
+}
+
static const struct v4l2_subdev_video_ops imx8mq_mipi_csi_video_ops = {
.s_stream = imx8mq_mipi_csi_s_stream,
};
@@ -656,6 +687,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
On Wed, Aug 20, 2025 at 07:04:59PM +0800, Guoniu Zhou wrote: > Implement .get_frame_desc subdev callback since downstream subdev > need to get frame description. > > Signed-off-by: Guoniu Zhou <guoniu.zhou@nxp.com> Reviewed-by: Frank Li <Frank.Li@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 529928b94a193e02177f8773a0e68375b59b0a08..a28ccdeef8521c0e00d13b1860eadef5f2118651 100644 > --- a/drivers/media/platform/nxp/imx8mq-mipi-csi2.c > +++ b/drivers/media/platform/nxp/imx8mq-mipi-csi2.c > @@ -648,6 +648,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 = media_bus_fmt_to_csi2_dt(csi2_fmt->code); > + > + return 0; > +} > + > static const struct v4l2_subdev_video_ops imx8mq_mipi_csi_video_ops = { > .s_stream = imx8mq_mipi_csi_s_stream, > }; > @@ -656,6 +687,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 >
© 2016 - 2025 Red Hat, Inc.