[libcamera-devel,v4,25/31] libcamera: ipu3: Connect viewfinder's BufferReady signal

Message ID 20190320163055.22056-26-jacopo@jmondi.org
State Accepted
Headers show
Series
  • libcamera: ipu3: Add ImgU support + multiple streams
Related show

Commit Message

Jacopo Mondi March 20, 2019, 4:30 p.m. UTC
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@jmondi.org>
---
 src/libcamera/pipeline/ipu3/ipu3.cpp | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

Comments

Laurent Pinchart March 23, 2019, 1:47 p.m. UTC | #1
Hi Jacopo,

Thank you for the patch.

On Wed, Mar 20, 2019 at 05:30:49PM +0100, Jacopo Mondi wrote:
> 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@jmondi.org>
> ---
>  src/libcamera/pipeline/ipu3/ipu3.cpp | 23 +++++++++++++++--------
>  1 file changed, 15 insertions(+), 8 deletions(-)
> 
> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp
> index b2df9a4ac922..db1ec2a7c3e2 100644
> --- a/src/libcamera/pipeline/ipu3/ipu3.cpp
> +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp
> @@ -135,7 +135,7 @@ private:
>  		{
>  		}
>  
> -		void imguOutputBufferReady(Buffer *buffer);
> +		void imguCaptureBufferReady(Buffer *buffer);
>  		void imguInputBufferReady(Buffer *buffer);
>  		void cio2BufferReady(Buffer *buffer);
>  
> @@ -621,8 +621,13 @@ int PipelineHandlerIPU3::start(Camera *camera)
>  					&IPU3CameraData::cio2BufferReady);
>  	data->imgu->input->bufferReady.connect(data,
>  					&IPU3CameraData::imguInputBufferReady);
> -	data->imgu->output->bufferReady.connect(data,
> -					&IPU3CameraData::imguOutputBufferReady);
> +
> +	if (isOutputActive(data))
> +		data->imgu->output->bufferReady.connect(data,
> +					&IPU3CameraData::imguCaptureBufferReady);
> +	if (isViewfinderActive(data))
> +		data->imgu->viewfinder->bufferReady.connect(data,
> +					&IPU3CameraData::imguCaptureBufferReady);

The connections don't need to be conditional, the signal will not be
emitted for inactive outputs.

>  
>  	/*
>  	 * Enqueue all available buffers to the CIO2 unit to start frame
> @@ -1434,17 +1439,19 @@ void PipelineHandlerIPU3::IPU3CameraData::imguInputBufferReady(Buffer *buffer)
>  }
>  
>  /**
> - * \brief ImgU output BufferReady slot
> + * \brief ImgU main and secondary output BufferReady slot
>   * \param buffer The completed buffer
>   *
> - * Buffer completed from the ImgU output are directed to the applications.
> + * Buffer completed from the ImgU main and secondary outputs are directed to
> + * the applications.
>   */
> -void PipelineHandlerIPU3::IPU3CameraData::imguOutputBufferReady(Buffer *buffer)
> +void PipelineHandlerIPU3::IPU3CameraData::imguCaptureBufferReady(Buffer *buffer)
>  {
>  	Request *request = queuedRequests_.front();
>  
> -	pipe_->completeBuffer(camera_, request, buffer);
> -	pipe_->completeRequest(camera_, request);
> +	/* TODO: this will probably need locking. */

Why so ?

> +	if (pipe_->completeBuffer(camera_, request, buffer))
> +		pipe_->completeRequest(camera_, request);
>  }
>  
>  /**

Patch

diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp
index b2df9a4ac922..db1ec2a7c3e2 100644
--- a/src/libcamera/pipeline/ipu3/ipu3.cpp
+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp
@@ -135,7 +135,7 @@  private:
 		{
 		}
 
-		void imguOutputBufferReady(Buffer *buffer);
+		void imguCaptureBufferReady(Buffer *buffer);
 		void imguInputBufferReady(Buffer *buffer);
 		void cio2BufferReady(Buffer *buffer);
 
@@ -621,8 +621,13 @@  int PipelineHandlerIPU3::start(Camera *camera)
 					&IPU3CameraData::cio2BufferReady);
 	data->imgu->input->bufferReady.connect(data,
 					&IPU3CameraData::imguInputBufferReady);
-	data->imgu->output->bufferReady.connect(data,
-					&IPU3CameraData::imguOutputBufferReady);
+
+	if (isOutputActive(data))
+		data->imgu->output->bufferReady.connect(data,
+					&IPU3CameraData::imguCaptureBufferReady);
+	if (isViewfinderActive(data))
+		data->imgu->viewfinder->bufferReady.connect(data,
+					&IPU3CameraData::imguCaptureBufferReady);
 
 	/*
 	 * Enqueue all available buffers to the CIO2 unit to start frame
@@ -1434,17 +1439,19 @@  void PipelineHandlerIPU3::IPU3CameraData::imguInputBufferReady(Buffer *buffer)
 }
 
 /**
- * \brief ImgU output BufferReady slot
+ * \brief ImgU main and secondary output BufferReady slot
  * \param buffer The completed buffer
  *
- * Buffer completed from the ImgU output are directed to the applications.
+ * Buffer completed from the ImgU main and secondary outputs are directed to
+ * the applications.
  */
-void PipelineHandlerIPU3::IPU3CameraData::imguOutputBufferReady(Buffer *buffer)
+void PipelineHandlerIPU3::IPU3CameraData::imguCaptureBufferReady(Buffer *buffer)
 {
 	Request *request = queuedRequests_.front();
 
-	pipe_->completeBuffer(camera_, request, buffer);
-	pipe_->completeRequest(camera_, request);
+	/* TODO: this will probably need locking. */
+	if (pipe_->completeBuffer(camera_, request, buffer))
+		pipe_->completeRequest(camera_, request);
 }
 
 /**