IMX219 supports configuring the Virtual Channel ID used for image and embedded data streams. Signed-off-by: Cosmin Tanislav <demonsingur@xxxxxxxxx> --- drivers/media/i2c/imx219.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/imx219.c b/drivers/media/i2c/imx219.c index 4c4ebe54f191b..ae93ac2bbe367 100644 --- a/drivers/media/i2c/imx219.c +++ b/drivers/media/i2c/imx219.c @@ -38,6 +38,8 @@ #define IMX219_MODE_STANDBY 0x00 #define IMX219_MODE_STREAMING 0x01 +#define IMX219_REG_CSI_CH_ID CCI_REG8(0x0110) + #define IMX219_REG_CSI_LANE_MODE CCI_REG8(0x0114) #define IMX219_CSI_2_LANE_MODE 0x01 #define IMX219_CSI_4_LANE_MODE 0x03 @@ -363,6 +365,9 @@ struct imx219 { /* Two or Four lanes */ u8 lanes; + + /* Virtual channel ID */ + u8 vc_id; }; static inline struct imx219 *to_imx219(struct v4l2_subdev *_sd) @@ -724,6 +729,12 @@ static int imx219_configure_lanes(struct imx219 *imx219) ARRAY_SIZE(imx219_4lane_regs), NULL); }; +static int imx219_configure_vc(struct imx219 *imx219) +{ + return cci_write(imx219->regmap, IMX219_REG_CSI_CH_ID, + imx219->vc_id, NULL); +} + static int imx219_start_streaming(struct imx219 *imx219, struct v4l2_subdev_state *state) { @@ -749,6 +760,13 @@ static int imx219_start_streaming(struct imx219 *imx219, goto err_rpm_put; } + /* Configure Virtual Channel ID */ + ret = imx219_configure_vc(imx219); + if (ret) { + dev_err(&client->dev, "%s failed to configure vc\n", __func__); + goto err_rpm_put; + } + /* Apply format and crop settings. */ ret = imx219_set_framefmt(imx219, state); if (ret) { @@ -994,6 +1012,7 @@ static int imx219_init_state(struct v4l2_subdev *sd, static int imx219_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad, struct v4l2_mbus_frame_desc *fd) { + struct imx219 *imx219 = to_imx219(sd); struct v4l2_subdev_state *state; u32 code; @@ -1006,7 +1025,7 @@ static int imx219_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad, fd->entry[0].pixelcode = code; fd->entry[0].stream = 0; - fd->entry[0].bus.csi2.vc = 0; + fd->entry[0].bus.csi2.vc = imx219->vc_id; fd->entry[0].bus.csi2.dt = imx219_get_format_bpp(code) == 8 ? MIPI_CSI2_DT_RAW8 : MIPI_CSI2_DT_RAW10; @@ -1149,6 +1168,13 @@ static int imx219_check_hwcfg(struct device *dev, struct imx219 *imx219) } imx219->lanes = ep_cfg.bus.mipi_csi2.num_data_lanes; + if (ep_cfg.bus.mipi_csi2.num_vc_ids > 1) { + dev_err_probe(dev, -EINVAL, + "only 1 virtual channel id is supported\n"); + goto error_out; + } + imx219->vc_id = ep_cfg.bus.mipi_csi2.vc_ids[0]; + /* Check the link frequency set in device tree */ switch (imx219->lanes) { case 2: -- 2.48.1