VI drivers loosing frames when QUEUED_BUFFERS=2

Good afternoon, Nvidia! We have such a problem - when we try to receive frames from VI driver sometimes we are loosing frames. We have to work in trigger mode and to provide such a functionality we decreased QUEUED_BUFFERS to 2. When it 4 we have to generate false frames to push buffer filling and to give the frame. Now we have a problem - sometimes (very rare but occurs) there is the situation when the second frame is ready but we didn’t read previous when QUEUED_BUFFERS=2 there is only 1 entry in buffer and it dropping this frame but we strongly need to get every frame.
Then I tried to rewrite function that taking frames outside but I cannot understand what the function is in charge of this. I already restored QUEUED_BUFFERS=4 and I want to do such a feature - when we trying to get a frame from the driver - we will receive everything that is in the buffer regardless is it full (has all 3 frames inside) or not.
Please, could you tell me what function should I fix? I almost understood call stack inside VI driver but I still cannot understand where is the function that provides frames outside. Where should I see?

Hi,
By default the driver is validated with camera source in steady frame rate. It may not work properly if the source does not generate frames in steady interval. For this use-case, your solution of filling false frames looks fine. So that it looks to be steady-frame-rate camera source.

Yes, I imagine, but still it can be hard to do it on the upper lvl because of firmware was already written. Now I can recompile driver but cannot some other firmware - I haven’t have access to this software. So then could you help me to understand what function should I alter, what function is in charge of giving frames?
I think it is something in the channel.c but I cannot understand what. Please, tell me, where are frames sending after you try to read it?

Hi,
It should not be possible to do it in VI driver, since the frames are captured in hardware CSI post. Would need real frame data to be generated from source and send to CSI port. Please check if your camera source can repeat the frames in steady frame rate.

But the frames somehow end up in the user space, it turns out that some function pushes them into v4l2 - I can’t find the code that is responsible for transferring frames further to channels.с or to vi2-ops.с .
I see chan->buffers but no one read this. But data from buffers somehow going further - where is this code? Where someone read the data from the chan->buffers?