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

From: Dmitry Osipenko
Date: Fri Jul 31 2020 - 16:42:35 EST


31.07.2020 19:29, Sowjanya Komatineni ÐÐÑÐÑ:
>
> On 7/31/20 9:14 AM, Dmitry Osipenko wrote:
>> 31.07.2020 18:46, Sowjanya Komatineni ÐÐÑÐÑ:
>>> On 7/31/20 4:39 AM, Dmitry Osipenko wrote:
>>>> 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?
>>> Nothing will happen as during stream enable csi receiver is kept ready.
>>>
>>> But actual capture will not happen during that point.
>> Could you please show how the full call chain looks like? It's not clear
>> to me what keeps CSI stream "ready".
>
> VI is the main video input (video device) and on streaming it starts
> stream of CSI subdev prior to stream of Sensor.
>
> HW path, sensor stream (CSI TX) -> CSI stream (RX)
>
> During CSI stream on, CSI PHY receiver is enabled to start receiving the
> data but internally capture assembled to active state will happen only
> when Tegra VI single shot is issues where VI thru pixel parser gets
> captures data into the memory

Alright, I see now.

Will be great if you could change this hunk:

{
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;
}
}

to look like this:

{
err = v4l2_subdev_call(src_subdev, video, s_stream, true);
if (err < 0 && err != -ENOIOCTLCMD)
goto err_disable_csi_stream;
...
return 0;

err_disable_csi_stream:
tegra_mipi_cancel_calibration(csi_chan->mipi);

v4l2_subdev_call(csi_subdev, video, s_stream, false);

return err;
}


It should make code a bit easier to read and follow.

Otherwise this patch looks good to me, thanks.