[libcamera-devel,v2,05/10] libcamera: ipu3: Calculate number of buffers for ImgU

Message ID 20200606150436.1851700-6-niklas.soderlund@ragnatech.se
State Superseded
Headers show
Series
  • libcamera: ipu3: Allow zero-copy RAW stream
Related show

Commit Message

Niklas Söderlund June 6, 2020, 3:04 p.m. UTC
Decouple the number of buffers to allocate for the ImgU from the number
of buffers allocated for the CIO2. Instead of blindly following the CIO2
pick the maximum number of buffers requested for any stream facing
applications.

This is potentially wasteful, as each stream could allocate just as many
buffers as requested by the application instead of the maximum from the
set. But this is not more wasteful than what is already used by the
pipeline and should be fixed on top after the decoupling of the two
processing units.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
---
* Changes since v1
- Use std::max({ ... })
---
 src/libcamera/pipeline/ipu3/ipu3.cpp | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Laurent Pinchart June 6, 2020, 9:20 p.m. UTC | #1
Hi Niklas,

Thank you for the patch.

On Sat, Jun 06, 2020 at 05:04:31PM +0200, Niklas Söderlund wrote:
> Decouple the number of buffers to allocate for the ImgU from the number
> of buffers allocated for the CIO2. Instead of blindly following the CIO2
> pick the maximum number of buffers requested for any stream facing
> applications.
> 
> This is potentially wasteful, as each stream could allocate just as many
> buffers as requested by the application instead of the maximum from the
> set. But this is not more wasteful than what is already used by the
> pipeline and should be fixed on top after the decoupling of the two
> processing units.
> 
> 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
> - Use std::max({ ... })
> ---
>  src/libcamera/pipeline/ipu3/ipu3.cpp | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp
> index 6df93eedb365b904..d143a425817b5f03 100644
> --- a/src/libcamera/pipeline/ipu3/ipu3.cpp
> +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp
> @@ -726,7 +726,11 @@ int PipelineHandlerIPU3::allocateBuffers(Camera *camera)
>  	if (ret < 0)
>  		return ret;
>  
> -	bufferCount = ret;
> +	bufferCount = std::max({
> +		data->outStream_.configuration().bufferCount,
> +		data->vfStream_.configuration().bufferCount,
> +		data->rawStream_.configuration().bufferCount,
> +	});
>  
>  	ret = imgu->allocateBuffers(data, bufferCount);
>  	if (ret < 0) {

Patch

diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp
index 6df93eedb365b904..d143a425817b5f03 100644
--- a/src/libcamera/pipeline/ipu3/ipu3.cpp
+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp
@@ -726,7 +726,11 @@  int PipelineHandlerIPU3::allocateBuffers(Camera *camera)
 	if (ret < 0)
 		return ret;
 
-	bufferCount = ret;
+	bufferCount = std::max({
+		data->outStream_.configuration().bufferCount,
+		data->vfStream_.configuration().bufferCount,
+		data->rawStream_.configuration().bufferCount,
+	});
 
 	ret = imgu->allocateBuffers(data, bufferCount);
 	if (ret < 0) {