[libcamera-devel,v2,04/11] libcamera: ipu3: cio2: Return the FrameBuffer pointer used
diff mbox series

Message ID 20201229160318.77536-5-niklas.soderlund@ragnatech.se
State Superseded
Delegated to: Niklas Söderlund
Headers show
Series
  • libcamera: ipu3: Attach to an skeleton IPA
Related show

Commit Message

Niklas Söderlund Dec. 29, 2020, 4:03 p.m. UTC
When adding IPA plumbing to the IPU3 pipeline handler it will be needed
to track which raw buffer was queued to the CIO2 for a specific request.
Currently if using an internally allocated raw buffer the FrameBuffer is
not exposed outside the CIO2Device as it was not needed. Prepare for the
IPA by exposing which internal raw buffer is picked for each request,
later changes will associate this with a Request.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
---
* Changes since v1
- Update commit message.
---
 src/libcamera/pipeline/ipu3/cio2.cpp | 10 +++++++---
 src/libcamera/pipeline/ipu3/cio2.h   |  2 +-
 src/libcamera/pipeline/ipu3/ipu3.cpp |  8 ++++----
 3 files changed, 12 insertions(+), 8 deletions(-)

Comments

Laurent Pinchart Jan. 7, 2021, 3:22 a.m. UTC | #1
Hi Niklas,

Thank you for the patch.

On Tue, Dec 29, 2020 at 05:03:11PM +0100, Niklas Söderlund wrote:
> When adding IPA plumbing to the IPU3 pipeline handler it will be needed
> to track which raw buffer was queued to the CIO2 for a specific request.
> Currently if using an internally allocated raw buffer the FrameBuffer is
> not exposed outside the CIO2Device as it was not needed. Prepare for the
> IPA by exposing which internal raw buffer is picked for each request,
> later changes will associate this with a Request.
> 
> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>

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

> ---
> * Changes since v1
> - Update commit message.
> ---
>  src/libcamera/pipeline/ipu3/cio2.cpp | 10 +++++++---
>  src/libcamera/pipeline/ipu3/cio2.h   |  2 +-
>  src/libcamera/pipeline/ipu3/ipu3.cpp |  8 ++++----
>  3 files changed, 12 insertions(+), 8 deletions(-)
> 
> diff --git a/src/libcamera/pipeline/ipu3/cio2.cpp b/src/libcamera/pipeline/ipu3/cio2.cpp
> index bd5260d5b28893e8..f76c6675b0f448fe 100644
> --- a/src/libcamera/pipeline/ipu3/cio2.cpp
> +++ b/src/libcamera/pipeline/ipu3/cio2.cpp
> @@ -254,7 +254,7 @@ int CIO2Device::stop()
>  	return ret;
>  }
>  
> -int CIO2Device::queueBuffer(Request *request, FrameBuffer *rawBuffer)
> +FrameBuffer *CIO2Device::queueBuffer(Request *request, FrameBuffer *rawBuffer)
>  {
>  	FrameBuffer *buffer = rawBuffer;
>  
> @@ -262,7 +262,7 @@ int CIO2Device::queueBuffer(Request *request, FrameBuffer *rawBuffer)
>  	if (!buffer) {
>  		if (availableBuffers_.empty()) {
>  			LOG(IPU3, Error) << "CIO2 buffer underrun";
> -			return -EINVAL;
> +			return nullptr;
>  		}
>  
>  		buffer = availableBuffers_.front();
> @@ -271,7 +271,11 @@ int CIO2Device::queueBuffer(Request *request, FrameBuffer *rawBuffer)
>  
>  	buffer->setRequest(request);
>  
> -	return output_->queueBuffer(buffer);
> +	int ret = output_->queueBuffer(buffer);
> +	if (ret)
> +		return nullptr;
> +
> +	return buffer;
>  }
>  
>  void CIO2Device::tryReturnBuffer(FrameBuffer *buffer)
> diff --git a/src/libcamera/pipeline/ipu3/cio2.h b/src/libcamera/pipeline/ipu3/cio2.h
> index 236ad287354a0bf6..dca4d40e4c32e8b2 100644
> --- a/src/libcamera/pipeline/ipu3/cio2.h
> +++ b/src/libcamera/pipeline/ipu3/cio2.h
> @@ -51,7 +51,7 @@ public:
>  	CameraSensor *sensor() { return sensor_.get(); }
>  	const CameraSensor *sensor() const { return sensor_.get(); }
>  
> -	int queueBuffer(Request *request, FrameBuffer *rawBuffer);
> +	FrameBuffer *queueBuffer(Request *request, FrameBuffer *rawBuffer);
>  	void tryReturnBuffer(FrameBuffer *buffer);
>  	Signal<FrameBuffer *> &bufferReady() { return output_->bufferReady; }
>  
> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp
> index 3e0e88fa63c4f1fb..a87ce8f3378ba2fe 100644
> --- a/src/libcamera/pipeline/ipu3/ipu3.cpp
> +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp
> @@ -643,10 +643,10 @@ int PipelineHandlerIPU3::queueRequestDevice(Camera *camera, Request *request)
>  	 * Queue a buffer on the CIO2, using the raw stream buffer provided in
>  	 * the request, if any, or a CIO2 internal buffer otherwise.
>  	 */
> -	FrameBuffer *rawBuffer = request->findBuffer(&data->rawStream_);
> -	error = data->cio2_.queueBuffer(request, rawBuffer);
> -	if (error)
> -		return error;
> +	FrameBuffer *reqRawBuffer = request->findBuffer(&data->rawStream_);
> +	FrameBuffer *rawBuffer = data->cio2_.queueBuffer(request, reqRawBuffer);
> +	if (!rawBuffer)
> +		return -ENOMEM;
>  
>  	/* Queue all buffers from the request aimed for the ImgU. */
>  	for (auto it : request->buffers()) {

Patch
diff mbox series

diff --git a/src/libcamera/pipeline/ipu3/cio2.cpp b/src/libcamera/pipeline/ipu3/cio2.cpp
index bd5260d5b28893e8..f76c6675b0f448fe 100644
--- a/src/libcamera/pipeline/ipu3/cio2.cpp
+++ b/src/libcamera/pipeline/ipu3/cio2.cpp
@@ -254,7 +254,7 @@  int CIO2Device::stop()
 	return ret;
 }
 
-int CIO2Device::queueBuffer(Request *request, FrameBuffer *rawBuffer)
+FrameBuffer *CIO2Device::queueBuffer(Request *request, FrameBuffer *rawBuffer)
 {
 	FrameBuffer *buffer = rawBuffer;
 
@@ -262,7 +262,7 @@  int CIO2Device::queueBuffer(Request *request, FrameBuffer *rawBuffer)
 	if (!buffer) {
 		if (availableBuffers_.empty()) {
 			LOG(IPU3, Error) << "CIO2 buffer underrun";
-			return -EINVAL;
+			return nullptr;
 		}
 
 		buffer = availableBuffers_.front();
@@ -271,7 +271,11 @@  int CIO2Device::queueBuffer(Request *request, FrameBuffer *rawBuffer)
 
 	buffer->setRequest(request);
 
-	return output_->queueBuffer(buffer);
+	int ret = output_->queueBuffer(buffer);
+	if (ret)
+		return nullptr;
+
+	return buffer;
 }
 
 void CIO2Device::tryReturnBuffer(FrameBuffer *buffer)
diff --git a/src/libcamera/pipeline/ipu3/cio2.h b/src/libcamera/pipeline/ipu3/cio2.h
index 236ad287354a0bf6..dca4d40e4c32e8b2 100644
--- a/src/libcamera/pipeline/ipu3/cio2.h
+++ b/src/libcamera/pipeline/ipu3/cio2.h
@@ -51,7 +51,7 @@  public:
 	CameraSensor *sensor() { return sensor_.get(); }
 	const CameraSensor *sensor() const { return sensor_.get(); }
 
-	int queueBuffer(Request *request, FrameBuffer *rawBuffer);
+	FrameBuffer *queueBuffer(Request *request, FrameBuffer *rawBuffer);
 	void tryReturnBuffer(FrameBuffer *buffer);
 	Signal<FrameBuffer *> &bufferReady() { return output_->bufferReady; }
 
diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp
index 3e0e88fa63c4f1fb..a87ce8f3378ba2fe 100644
--- a/src/libcamera/pipeline/ipu3/ipu3.cpp
+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp
@@ -643,10 +643,10 @@  int PipelineHandlerIPU3::queueRequestDevice(Camera *camera, Request *request)
 	 * Queue a buffer on the CIO2, using the raw stream buffer provided in
 	 * the request, if any, or a CIO2 internal buffer otherwise.
 	 */
-	FrameBuffer *rawBuffer = request->findBuffer(&data->rawStream_);
-	error = data->cio2_.queueBuffer(request, rawBuffer);
-	if (error)
-		return error;
+	FrameBuffer *reqRawBuffer = request->findBuffer(&data->rawStream_);
+	FrameBuffer *rawBuffer = data->cio2_.queueBuffer(request, reqRawBuffer);
+	if (!rawBuffer)
+		return -ENOMEM;
 
 	/* Queue all buffers from the request aimed for the ImgU. */
 	for (auto it : request->buffers()) {