[libcamera-devel,v5,16/19] libcamera: ipu3: Connect CIO2 and ImgU bufferReady signals

Message ID 20190326083902.26121-17-jacopo@jmondi.org
State Superseded
Headers show
Series
  • libcamera: ipu3: Add ImgU support
Related show

Commit Message

Jacopo Mondi March 26, 2019, 8:38 a.m. UTC
Connect the CIO2 output bufferRead signal to a slot that simply
queue the received buffer to ImgU for processing, and connect the ImgU
main output bufferReady signal to the cameraData slot that notifies
to applications that a new image buffer is available.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
---
 src/libcamera/pipeline/ipu3/ipu3.cpp | 59 +++++++++++++++++++++++++---
 1 file changed, 54 insertions(+), 5 deletions(-)

Comments

Laurent Pinchart April 2, 2019, 10:52 a.m. UTC | #1
Hi Jacopo,

Thank you for the patch.

On Tue, Mar 26, 2019 at 09:38:59AM +0100, Jacopo Mondi wrote:
> Connect the CIO2 output bufferRead signal to a slot that simply
> queue the received buffer to ImgU for processing, and connect the ImgU
> main output bufferReady signal to the cameraData slot that notifies
> to applications that a new image buffer is available.
> 
> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
> ---
>  src/libcamera/pipeline/ipu3/ipu3.cpp | 59 +++++++++++++++++++++++++---
>  1 file changed, 54 insertions(+), 5 deletions(-)
> 
> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp
> index 9e8a20849ed0..7a5e715458ae 100644
> --- a/src/libcamera/pipeline/ipu3/ipu3.cpp
> +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp
> @@ -203,7 +203,9 @@ private:
>  		{
>  		}
>  
> -		void bufferReady(Buffer *buffer);
> +		void imguOutputBufferReady(Buffer *buffer);
> +		void imguInputBufferReady(Buffer *buffer);
> +		void cio2BufferReady(Buffer *buffer);
>  
>  		CIO2Device cio2_;
>  		ImgUDevice *imgu_;
> @@ -562,15 +564,28 @@ int PipelineHandlerIPU3::registerCameras()
>  		 */
>  		data->imgu_ = numCameras ? &imgu1_ : &imgu0_;
>  
> +		/*
> +		 * Connect video devices' 'bufferReady' signals to their
> +		 * slot to implement the image processing pipeline.
> +		 *
> +		 * Frames produced by the CIO2 unit are shared with the

s/shared with/passed to/

> +		 * associated ImgU input where they get processed and
> +		 * returned through the ImgU main and secondary outputs.
> +		 */
> +		data->cio2_.output_->bufferReady.connect(data.get(),
> +					&IPU3CameraData::cio2BufferReady);
> +		data->imgu_->input_->bufferReady.connect(data.get(),
> +					&IPU3CameraData::imguInputBufferReady);
> +		data->imgu_->output_->bufferReady.connect(data.get(),
> +					&IPU3CameraData::imguOutputBufferReady);
> +
> +		/* Create and register the Camera instance. */
>  		std::string cameraName = cio2->name() + " "
>  				       + std::to_string(id);
>  		std::shared_ptr<Camera> camera = Camera::create(this,
>  								cameraName,
>  								streams);
>  
> -		cio2->output_->bufferReady.connect(data.get(),
> -						   &IPU3CameraData::bufferReady);
> -
>  		registerCamera(std::move(camera), std::move(data));
>  
>  		LOG(IPU3, Info)
> @@ -584,7 +599,29 @@ int PipelineHandlerIPU3::registerCameras()
>  	return numCameras ? 0 : -ENODEV;
>  }
>  
> -void PipelineHandlerIPU3::IPU3CameraData::bufferReady(Buffer *buffer)
> +/* -----------------------------------------------------------------------------
> + * Buffer Ready slots
> + */
> +
> +/**
> + * \brief Handle buffers completion at the ImgU input
> + * \param buffer The completed buffer
> + *
> + * Buffers completed from the ImgU input are immediately queued back to the
> + * CIO2 unit to continue frame capture.
> + */
> +void PipelineHandlerIPU3::IPU3CameraData::imguInputBufferReady(Buffer *buffer)
> +{
> +	cio2_.output_->queueBuffer(buffer);
> +}
> +
> +/**
> + * \brief Handle buffers completion at the ImgU output
> + * \param buffer The completed buffer
> + *
> + * Buffers completed from the ImgU output are directed to the application.
> + */
> +void PipelineHandlerIPU3::IPU3CameraData::imguOutputBufferReady(Buffer *buffer)
>  {
>  	Request *request = queuedRequests_.front();
>  
> @@ -592,6 +629,18 @@ void PipelineHandlerIPU3::IPU3CameraData::bufferReady(Buffer *buffer)
>  	pipe_->completeRequest(camera_, request);
>  }
>  
> +/**
> + * \brief Handle buffers completion at the CIO2 output
> + * \param buffer The completed buffer
> + *
> + * Buffers completed from the CIO2 are immediately queued to the ImgU unit
> + * for further processing.
> + */
> +void PipelineHandlerIPU3::IPU3CameraData::cio2BufferReady(Buffer *buffer)
> +{
> +	imgu_->input_->queueBuffer(buffer);

I still think we'll need to keep track of requests and only queue
buffers to the ImgU input when buffers are available for its output, but
that can be done in a separate patch. With the small issue above fixed,

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> +}
> +
>  /* -----------------------------------------------------------------------------
>   * ImgU Device
>   */
Niklas Söderlund April 2, 2019, 11:39 a.m. UTC | #2
Hi Jacopo,

Thanks for your work.

On 2019-03-26 09:38:59 +0100, Jacopo Mondi wrote:
> Connect the CIO2 output bufferRead signal to a slot that simply
> queue the received buffer to ImgU for processing, and connect the ImgU
> main output bufferReady signal to the cameraData slot that notifies
> to applications that a new image buffer is available.
> 
> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>

> ---
>  src/libcamera/pipeline/ipu3/ipu3.cpp | 59 +++++++++++++++++++++++++---
>  1 file changed, 54 insertions(+), 5 deletions(-)
> 
> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp
> index 9e8a20849ed0..7a5e715458ae 100644
> --- a/src/libcamera/pipeline/ipu3/ipu3.cpp
> +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp
> @@ -203,7 +203,9 @@ private:
>  		{
>  		}
>  
> -		void bufferReady(Buffer *buffer);
> +		void imguOutputBufferReady(Buffer *buffer);
> +		void imguInputBufferReady(Buffer *buffer);
> +		void cio2BufferReady(Buffer *buffer);
>  
>  		CIO2Device cio2_;
>  		ImgUDevice *imgu_;
> @@ -562,15 +564,28 @@ int PipelineHandlerIPU3::registerCameras()
>  		 */
>  		data->imgu_ = numCameras ? &imgu1_ : &imgu0_;
>  
> +		/*
> +		 * Connect video devices' 'bufferReady' signals to their
> +		 * slot to implement the image processing pipeline.
> +		 *
> +		 * Frames produced by the CIO2 unit are shared with the
> +		 * associated ImgU input where they get processed and
> +		 * returned through the ImgU main and secondary outputs.
> +		 */
> +		data->cio2_.output_->bufferReady.connect(data.get(),
> +					&IPU3CameraData::cio2BufferReady);
> +		data->imgu_->input_->bufferReady.connect(data.get(),
> +					&IPU3CameraData::imguInputBufferReady);
> +		data->imgu_->output_->bufferReady.connect(data.get(),
> +					&IPU3CameraData::imguOutputBufferReady);
> +
> +		/* Create and register the Camera instance. */
>  		std::string cameraName = cio2->name() + " "
>  				       + std::to_string(id);
>  		std::shared_ptr<Camera> camera = Camera::create(this,
>  								cameraName,
>  								streams);
>  
> -		cio2->output_->bufferReady.connect(data.get(),
> -						   &IPU3CameraData::bufferReady);
> -
>  		registerCamera(std::move(camera), std::move(data));
>  
>  		LOG(IPU3, Info)
> @@ -584,7 +599,29 @@ int PipelineHandlerIPU3::registerCameras()
>  	return numCameras ? 0 : -ENODEV;
>  }
>  
> -void PipelineHandlerIPU3::IPU3CameraData::bufferReady(Buffer *buffer)
> +/* -----------------------------------------------------------------------------
> + * Buffer Ready slots
> + */
> +
> +/**
> + * \brief Handle buffers completion at the ImgU input
> + * \param buffer The completed buffer
> + *
> + * Buffers completed from the ImgU input are immediately queued back to the
> + * CIO2 unit to continue frame capture.
> + */
> +void PipelineHandlerIPU3::IPU3CameraData::imguInputBufferReady(Buffer *buffer)
> +{
> +	cio2_.output_->queueBuffer(buffer);
> +}
> +
> +/**
> + * \brief Handle buffers completion at the ImgU output
> + * \param buffer The completed buffer
> + *
> + * Buffers completed from the ImgU output are directed to the application.
> + */
> +void PipelineHandlerIPU3::IPU3CameraData::imguOutputBufferReady(Buffer *buffer)
>  {
>  	Request *request = queuedRequests_.front();
>  
> @@ -592,6 +629,18 @@ void PipelineHandlerIPU3::IPU3CameraData::bufferReady(Buffer *buffer)
>  	pipe_->completeRequest(camera_, request);
>  }
>  
> +/**
> + * \brief Handle buffers completion at the CIO2 output
> + * \param buffer The completed buffer
> + *
> + * Buffers completed from the CIO2 are immediately queued to the ImgU unit
> + * for further processing.
> + */
> +void PipelineHandlerIPU3::IPU3CameraData::cio2BufferReady(Buffer *buffer)
> +{
> +	imgu_->input_->queueBuffer(buffer);
> +}
> +
>  /* -----------------------------------------------------------------------------
>   * ImgU Device
>   */
> -- 
> 2.21.0
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

Patch

diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp
index 9e8a20849ed0..7a5e715458ae 100644
--- a/src/libcamera/pipeline/ipu3/ipu3.cpp
+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp
@@ -203,7 +203,9 @@  private:
 		{
 		}
 
-		void bufferReady(Buffer *buffer);
+		void imguOutputBufferReady(Buffer *buffer);
+		void imguInputBufferReady(Buffer *buffer);
+		void cio2BufferReady(Buffer *buffer);
 
 		CIO2Device cio2_;
 		ImgUDevice *imgu_;
@@ -562,15 +564,28 @@  int PipelineHandlerIPU3::registerCameras()
 		 */
 		data->imgu_ = numCameras ? &imgu1_ : &imgu0_;
 
+		/*
+		 * Connect video devices' 'bufferReady' signals to their
+		 * slot to implement the image processing pipeline.
+		 *
+		 * Frames produced by the CIO2 unit are shared with the
+		 * associated ImgU input where they get processed and
+		 * returned through the ImgU main and secondary outputs.
+		 */
+		data->cio2_.output_->bufferReady.connect(data.get(),
+					&IPU3CameraData::cio2BufferReady);
+		data->imgu_->input_->bufferReady.connect(data.get(),
+					&IPU3CameraData::imguInputBufferReady);
+		data->imgu_->output_->bufferReady.connect(data.get(),
+					&IPU3CameraData::imguOutputBufferReady);
+
+		/* Create and register the Camera instance. */
 		std::string cameraName = cio2->name() + " "
 				       + std::to_string(id);
 		std::shared_ptr<Camera> camera = Camera::create(this,
 								cameraName,
 								streams);
 
-		cio2->output_->bufferReady.connect(data.get(),
-						   &IPU3CameraData::bufferReady);
-
 		registerCamera(std::move(camera), std::move(data));
 
 		LOG(IPU3, Info)
@@ -584,7 +599,29 @@  int PipelineHandlerIPU3::registerCameras()
 	return numCameras ? 0 : -ENODEV;
 }
 
-void PipelineHandlerIPU3::IPU3CameraData::bufferReady(Buffer *buffer)
+/* -----------------------------------------------------------------------------
+ * Buffer Ready slots
+ */
+
+/**
+ * \brief Handle buffers completion at the ImgU input
+ * \param buffer The completed buffer
+ *
+ * Buffers completed from the ImgU input are immediately queued back to the
+ * CIO2 unit to continue frame capture.
+ */
+void PipelineHandlerIPU3::IPU3CameraData::imguInputBufferReady(Buffer *buffer)
+{
+	cio2_.output_->queueBuffer(buffer);
+}
+
+/**
+ * \brief Handle buffers completion at the ImgU output
+ * \param buffer The completed buffer
+ *
+ * Buffers completed from the ImgU output are directed to the application.
+ */
+void PipelineHandlerIPU3::IPU3CameraData::imguOutputBufferReady(Buffer *buffer)
 {
 	Request *request = queuedRequests_.front();
 
@@ -592,6 +629,18 @@  void PipelineHandlerIPU3::IPU3CameraData::bufferReady(Buffer *buffer)
 	pipe_->completeRequest(camera_, request);
 }
 
+/**
+ * \brief Handle buffers completion at the CIO2 output
+ * \param buffer The completed buffer
+ *
+ * Buffers completed from the CIO2 are immediately queued to the ImgU unit
+ * for further processing.
+ */
+void PipelineHandlerIPU3::IPU3CameraData::cio2BufferReady(Buffer *buffer)
+{
+	imgu_->input_->queueBuffer(buffer);
+}
+
 /* -----------------------------------------------------------------------------
  * ImgU Device
  */