Re: [RFC PATCH v6 09/10] media: tegra-video: Add CSI MIPI pads calibration

Dmitry Osipenko
2020-07-31T11:39:08Z

31.07.2020 12:02, Sowjanya Komatineni пишет:
...
> @@ -249,13 +249,47 @@ static int tegra_csi_enable_stream(struct v4l2_subdev *subdev)
> return ret;
> }
>
> + if (csi_chan->mipi) {
> + ret = tegra_mipi_enable(csi_chan->mipi);
> + if (ret < 0) {
> + dev_err(csi->dev,
> + "failed to enable MIPI pads: %d\n", ret);
> + goto rpm_put;
> + }
> +
> + /*
> + * CSI MIPI pads PULLUP, PULLDN and TERM impedances need to
> + * be calibrated after power on.
> + * So, trigger the calibration start here and results will
> + * be latched and applied to the pads when link is in LP11
> + * state during start of sensor streaming.
> + */
> + ret = tegra_mipi_start_calibration(csi_chan->mipi);
> + if (ret < 0) {
> + dev_err(csi->dev,
> + "failed to start MIPI calibration: %d\n", ret);
> + goto disable_mipi;
> + }

What would happen if CSI stream is enabled and then immediately disabled
without enabling camera sensor?

> + }
> +
...
> static int tegra_channel_enable_stream(struct tegra_vi_channel *chan)
> {
> struct v4l2_subdev *csi_subdev, *src_subdev;
> + struct tegra_csi_channel *csi_chan;
> int ret;
>
> /*
> @@ -206,13 +207,30 @@ static int tegra_channel_enable_stream(struct tegra_vi_channel *chan)
> if (IS_ENABLED(CONFIG_VIDEO_TEGRA_TPG))
> return 0;
>
> + csi_chan = v4l2_get_subdevdata(csi_subdev);
> + /*
> + * TRM has incorrectly documented to wait for done status from
> + * calibration logic after CSI interface power on.
> + * As per the design, calibration results are latched and applied
> + * to the pads only when the link is in LP11 state which will happen
> + * during the sensor stream-on.
> + * CSI subdev stream-on triggers start of MIPI pads calibration.
> + * Wait for calibration to finish here after sensor subdev stream-on
> + * and in case of sensor stream-on failure, cancel the calibration.
> + */
> src_subdev = tegra_channel_get_remote_source_subdev(chan);

Is it possible to move the start_calibration() here?

> ret = v4l2_subdev_call(src_subdev, video, s_stream, true);
> if (ret < 0 && ret != -ENOIOCTLCMD) {
> + tegra_mipi_cancel_calibration(csi_chan->mipi);
> v4l2_subdev_call(csi_subdev, video, s_stream, false);
> return ret;
> }
>
> + ret = tegra_mipi_finish_calibration(csi_chan->mipi);
> + if (ret < 0)
> + dev_warn(csi_chan->csi->dev,
> + "MIPI calibration failed: %d\n", ret);
> +
> return 0;
> }
>
>