TX2 mipi csi-2 camera single shot


i have connected a camera over mipi csi-2 to my Jetson TX2 module.

I would like to run my camera in single shot mode (capturing an image every few seconds/minutes). My problem is that I’m running into timeouts if the time between two frames exceeds 1 second.

Is there a way to configure the mipi csi interface and the vi unit for single shots?

Did you capture by v4l2 API?

Yes I use the v4l2 api.

What’s the purpose/use case for this implement.
Have you try stop stream during waiting and start stream to capture?

I want to trigger my camera on external events through an external hardware trigger connected directly to the camera.

I have to achieve a low latency between the trigger event and ‘frame is ready’. I’m afraid, that if i would connect the hardware trigger also to the Jetson and start the stream on the external event, I wouldn’t be fast enough to capture the frame. Do you know what the minimum time between starting the stream (using the v4l2 api) and receiving the first MIPI CSI2 packet has to be?

The latency about 134 ms

Thank you for your fast responses.

134ms is way to long for me.

Could you tell me why there is this timeout after 1 second? Is this related to hardware limitation or just software implementation? If it is not related to the hardware, could you tell me what changes I would have to do in software?

I have tried to increase the timeout by doing small changes in the kernel file vi4_fops.c.
I simple have increased the forth parameter of the nvhost_syncpt_wait_timeout_ext call. I were able to increase the timeout to about 10s, but i got a lot of error/warning massages on the command line. Is this a proper way to increase the timeout? What side effects would the increased time out bring along. Is there a recommend maximum value?

 * Wait for PXL_SOF syncpt
 * Use the syncpt max value we just set as threshold
for (i = 0; i < chan->valid_ports; i++) {
	err = nvhost_syncpt_wait_timeout_ext(chan->vi->ndev,
			chan->syncpt[i][SOF_SYNCPT_IDX], thresh[i],

[/b], NULL, NULL);

I can confirm that the 1 second (actually 1.5 second or was it 1.5 FPS here?) timeout is quite irritating. At first I was wondering if there is something wrong with our driver when configured for low FPS (either due to lane count/high resolution/bitrate limitation) when I noticed that I could purposely trigger the timeouts with adding extra v-blank to an otherwise working system. This is one of the “features” that will haunt you one you start doing serious stuff with nvidia products.

Our use case would be to start multiple clients - prepare the streaming/processing/encoding path, with the sensors started in a later stage. It is impossible to guarantee that all the nodes will boot within 1 sec window to avoid these timeouts happening. Thus we have a workaround to start the sensors in advance, disable power management to keep them running, and the clients are started later. The drawback is, that each stream has a fixed offset from other streams and frames have to be dropped, e.g. based on a startup calibration with modifying black level on all sensors in sync or with an hardware embedded timestamp.

The reason for larger than 1 second timeout for us would be:

  • support for low FPS because some applications just want to do regular snapshots
  • support for long exposures without any special handling
  • easy synchronous multi-sensor operation

But the ultimate solution would be to have no timeout occurring at all - because once the MIPI CSI encounters a timeout, it will not recover with another frame. That is still an unsolved issue and the CSI on Tegra is rather a toy than a hardened production quality thing, resilient from random signal integrity issues.

The timeout is totally software thing. For the v4l2 vi driver is fully source release. You can modify it for your use case.

Where can this timeout value be set?

Check below driver.

../vi/vi4_fops.c:        chan->timeout = msecs_to_jiffies(200);
../vi/registers.h:#define        TEGRA_VI_SYNCPT_WAIT_TIMEOUT                    200

I still get “PXL_SOF syncpt timeout! err = -11” errors even though I changed the TEGRA_VI_SYNCPT_WAIT_TIMEOUT to a suitable value for the interval we use in our single shot mode. The system works fine in normal 30FPS mode. Is there anything else that needs to be changed in order to enable single shot mode?

Didn’t have experience for this kind of case.
But you have to make sure the sensor must output correct frame before the single shot reg been setted.

Has anyone successfully managed to capture single frames based on external events on the TX2 via MIPI CSI-2? We have not found a solution to the MIPI timeout issue yet.