[libcamera-devel] [PATCH 6/8] android: camera_device: Allocate buffer pool

Niklas Söderlund niklas.soderlund at ragnatech.se
Thu Sep 10 13:31:16 CEST 2020


Hi Jacopo,

Thanks for your patch.

On 2020-09-09 17:54:55 +0200, Jacopo Mondi wrote:
> CameraStream instances that are not directly mapped to application
> facing Android streams need memory to be reserved in libcamera on their
> behalf.
> 
> After the libcamera::Camera has been configured, reserve memory for the
> CameraStream isntances that need a pool of libcamera allocated buffers.
> 
> Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>

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

> ---
>  src/android/camera_device.cpp | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
> 
> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
> index d35c6b93b654..a7cb1be03b9a 100644
> --- a/src/android/camera_device.cpp
> +++ b/src/android/camera_device.cpp
> @@ -1329,6 +1329,26 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)
>  		return ret;
>  	}
>  
> +	/*
> +	 * Allocate buffers in libcamera for stream not directly mapped to
> +	 * Android streams.
> +	 */
> +	for (unsigned int i = 0; i < stream_list->num_streams; ++i) {
> +		camera3_stream_t *camera3Stream = stream_list->streams[i];
> +		CameraStream *cameraStream = static_cast<CameraStream *>(camera3Stream->priv);
> +		StreamConfiguration &cfg = config_->at(cameraStream->index());
> +
> +		if (cameraStream->type() != CameraStream::Type::Internal)
> +			continue;
> +
> +		int ret = allocator_.allocate(cfg.stream());
> +		if (ret < 0) {
> +			LOG(HAL, Error)
> +				<< "Failed to allocate buffers for stream " << i;
> +			return ret;
> +		}
> +	}
> +
>  	return 0;
>  }
>  
> -- 
> 2.28.0
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel at lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

-- 
Regards,
Niklas Söderlund


More information about the libcamera-devel mailing list