<div dir="ltr"><div dir="ltr">Hi Laurent,</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, 2 Dec 2022 at 13:53, Laurent Pinchart <<a href="mailto:laurent.pinchart@ideasonboard.com">laurent.pinchart@ideasonboard.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Naush,<br>
<br>
Thank you for the patch.<br>
<br>
On Tue, Nov 29, 2022 at 01:45:30PM +0000, Naushir Patuck via libcamera-devel wrote:<br>
> Reorder the code such that the IPA requested startup drop frames count is<br>
> available before the pipeline handler allocates any stream buffers.<br>
> <br>
> This will be used in a subsequent change to stop Unicam buffer allocations if<br>
> there are no startup drop frames required.<br>
<br>
Do you mean "if there are no startup drop frames required and the<br>
application has configured a raw stream and always provides buffers for<br>
it" ?<br></blockquote><div><br></div><div>Yes!</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Why is that related ? Can't you avoid allocating internal raw buffers<br>
even without startup frames being dropped ? Can't you use the raw buffer<br>
from the first request to capture all the dropped frames and the first<br>
useful frame ?<br></blockquote><div><br></div><div>There are a couple of reasons for this:</div><div><br></div><div>1) I'm working under the assumption that I cannot enqueue the same buffer<br></div><div>multiple times in v4l2 Because of this, I can only ever queue 1 buffer, have it</div><div>dequeued, processed by the ISP, and requeue it back to Unicam. This</div><div>effectively halves my overall framerate because of the added latency of running</div><div>the ISP.</div><div><br></div><div>2) Even if V4L2 does allow enquing the same framebuffer multiple times, there is</div><div>a possible (probable?) HW race condition where the ISP could be processing the</div><div>buffer for frame N, while Unicam is writing out to the buffer for frame N + 1.</div><div><br></div><div> It would be interesting to know if (1) is actually possible. I don't recall exactly, but</div><div>I think I did try it, and might have got complaints from the v4l2 framework.</div><div><br></div><div>Regards,</div><div>Naush</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
> Signed-off-by: Naushir Patuck <<a href="mailto:naush@raspberrypi.com" target="_blank">naush@raspberrypi.com</a>><br>
> Reviewed-by: David Plowman <<a href="mailto:david.plowman@raspberrypi.com" target="_blank">david.plowman@raspberrypi.com</a>><br>
> ---<br>
> .../pipeline/raspberrypi/raspberrypi.cpp | 30 +++++++++----------<br>
> 1 file changed, 15 insertions(+), 15 deletions(-)<br>
> <br>
> diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp<br>
> index 86eb43a3a3c5..742521927780 100644<br>
> --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp<br>
> +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp<br>
> @@ -1044,21 +1044,6 @@ int PipelineHandlerRPi::start(Camera *camera, const ControlList *controls)<br>
> RPiCameraData *data = cameraData(camera);<br>
> int ret;<br>
> <br>
> - for (auto const stream : data->streams_)<br>
> - stream->resetBuffers();<br>
> -<br>
> - if (!data->buffersAllocated_) {<br>
> - /* Allocate buffers for internal pipeline usage. */<br>
> - ret = prepareBuffers(camera);<br>
> - if (ret) {<br>
> - LOG(RPI, Error) << "Failed to allocate buffers";<br>
> - data->freeBuffers();<br>
> - stop(camera);<br>
> - return ret;<br>
> - }<br>
> - data->buffersAllocated_ = true;<br>
> - }<br>
> -<br>
> /* Check if a ScalerCrop control was specified. */<br>
> if (controls)<br>
> data->applyScalerCrop(*controls);<br>
> @@ -1075,6 +1060,21 @@ int PipelineHandlerRPi::start(Camera *camera, const ControlList *controls)<br>
> /* Configure the number of dropped frames required on startup. */<br>
> data->dropFrameCount_ = startConfig.dropFrameCount;<br>
> <br>
> + for (auto const stream : data->streams_)<br>
> + stream->resetBuffers();<br>
> +<br>
> + if (!data->buffersAllocated_) {<br>
> + /* Allocate buffers for internal pipeline usage. */<br>
> + ret = prepareBuffers(camera);<br>
> + if (ret) {<br>
> + LOG(RPI, Error) << "Failed to allocate buffers";<br>
> + data->freeBuffers();<br>
> + stop(camera);<br>
> + return ret;<br>
> + }<br>
> + data->buffersAllocated_ = true;<br>
> + }<br>
> +<br>
> /* We need to set the dropFrameCount_ before queueing buffers. */<br>
> ret = queueAllBuffers(camera);<br>
> if (ret) {<br>
<br>
-- <br>
Regards,<br>
<br>
Laurent Pinchart<br>
</blockquote></div></div>