[libcamera-devel] [PATCH v4 10/12] libcamera: ipu3: Connect viewfinder's BufferReady signal
Jacopo Mondi
jacopo at jmondi.org
Tue Apr 9 21:25:46 CEST 2019
Connect the viewfinder buffer ready signal to the IPU3CameraData slot
that complets the buffer first, and if not waiting for other buffers
completes the request as well.
Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
---
src/libcamera/pipeline/ipu3/ipu3.cpp | 43 ++++++++++++++++++++++++----
1 file changed, 37 insertions(+), 6 deletions(-)
diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp
index bb8d4ce644ca..75ffdc56d157 100644
--- a/src/libcamera/pipeline/ipu3/ipu3.cpp
+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp
@@ -182,7 +182,7 @@ private:
{
}
- void imguOutputBufferReady(Buffer *buffer);
+ void imguCaptureBufferReady(Buffer *buffer);
void imguInputBufferReady(Buffer *buffer);
void cio2BufferReady(Buffer *buffer);
@@ -722,7 +722,9 @@ int PipelineHandlerIPU3::registerCameras()
data->imgu_->input_->bufferReady.connect(data.get(),
&IPU3CameraData::imguInputBufferReady);
data->imgu_->output_.dev->bufferReady.connect(data.get(),
- &IPU3CameraData::imguOutputBufferReady);
+ &IPU3CameraData::imguCaptureBufferReady);
+ data->imgu_->viewfinder_.dev->bufferReady.connect(data.get(),
+ &IPU3CameraData::imguCaptureBufferReady);
/* Initialize and register the Camera and its streams. */
@@ -769,12 +771,41 @@ void PipelineHandlerIPU3::IPU3CameraData::imguInputBufferReady(Buffer *buffer)
*
* Buffers completed from the ImgU output are directed to the application.
*/
-void PipelineHandlerIPU3::IPU3CameraData::imguOutputBufferReady(Buffer *buffer)
+void PipelineHandlerIPU3::IPU3CameraData::imguCaptureBufferReady(Buffer *buffer)
{
- Request *request = queuedRequests_.front();
+ Request *request = buffer->request();
+ if (!request)
+ /*
+ * Completed buffers not part of a request are ignored
+ * (they most probably come from the output stream
+ * internal pool)
+ */
+ return;
+
+ if (!pipe_->completeBuffer(camera_, request, buffer))
+ /* Request not completed yet, return here. */
+ return;
+
+ /*
+ * Complete requests in queuing order: if some other request is
+ * pending, post-pone completion.
+ */
+ Request *front = queuedRequests_.front();
+ if (front != request)
+ return;
- pipe_->completeBuffer(camera_, request, buffer);
- pipe_->completeRequest(camera_, request);
+ /*
+ * Complete the current request, and all the other pending ones,
+ * in queuing order.
+ */
+ while (1) {
+ if (front->empty())
+ pipe_->completeRequest(camera_, front);
+ else
+ break;
+
+ front = queuedRequests_.front();
+ }
}
/**
--
2.21.0
More information about the libcamera-devel
mailing list