[libcamera-devel,6/7] libcamera: pipeline: vimc: Queue the buffers

Message ID 20200722133009.26528-7-kgupta@es.iitr.ac.in
State New
Delegated to: Kieran Bingham
Headers show
Series
  • vimc: Introduce multiple streaming
Related show

Commit Message

Kaaira Gupta July 22, 2020, 1:30 p.m. UTC
Queue the buffers correctly according to the streams requested.

Signed-off-by: Kaaira Gupta <kgupta@es.iitr.ac.in>
---
 src/libcamera/pipeline/vimc/vimc.cpp | 31 +++++++++++++++++++---------
 1 file changed, 21 insertions(+), 10 deletions(-)

Comments

Kaaira Gupta July 24, 2020, 3:16 p.m. UTC | #1
On Wed, Jul 22, 2020 at 07:00:08PM +0530, Kaaira Gupta wrote:
> Queue the buffers correctly according to the streams requested.
> 
> Signed-off-by: Kaaira Gupta <kgupta@es.iitr.ac.in>
> ---
>  src/libcamera/pipeline/vimc/vimc.cpp | 31 +++++++++++++++++++---------
>  1 file changed, 21 insertions(+), 10 deletions(-)
> 
> diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp
> index 6010e1e..7e8d355 100644
> --- a/src/libcamera/pipeline/vimc/vimc.cpp
> +++ b/src/libcamera/pipeline/vimc/vimc.cpp
> @@ -536,19 +536,30 @@ int PipelineHandlerVimc::processControls(VimcCameraData *data, Request *request)
>  int PipelineHandlerVimc::queueRequestDevice(Camera *camera, Request *request)
>  {
>  	VimcCameraData *data = cameraData(camera);
> -	FrameBuffer *buffer = request->findBuffer(&data->rgbStream_);
> -	if (!buffer) {
> -		LOG(VIMC, Error)
> -			<< "Attempt to queue request with invalid stream";
> +	for (auto it : request->buffers()) {
> +		Stream *stream = static_cast<Stream *>(it.first);
> +		FrameBuffer *buffer = it.second;
> +		if (!buffer) {
> +			LOG(VIMC, Error)
> +				<< "Attempt to queue request with invalid stream";
> +
> +			return -ENOENT;
> +		}
>  
> -		return -ENOENT;
> -	}
> +		int ret;
>  
> -	int ret = processControls(data, request);
> -	if (ret < 0)
> -		return ret;
> +		if (stream == &data->rgbStream_)
> +			ret = data->video_->queueBuffer(buffer);
> +		if (stream == &data->rawStream_)
> +			ret = data->raw_->queueBuffer(buffer);
> +		else
> +			continue;
>  
> -	ret = data->video_->queueBuffer(buffer);
> +		if (ret < 0)
> +			return ret;
> +		return ret;

This return statement prevents control from moving out of the loop.
It should be removed.

> +	}
> +	int ret = processControls(data, request);
>  	if (ret < 0)
>  		return ret;

Since there is a 'return 0' after this, it could simply be

	ret = processControls(data, request);
	return ret;

by declaring ret outside of the loop ofcourse.

>  
> -- 
> 2.17.1
>

Patch

diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp
index 6010e1e..7e8d355 100644
--- a/src/libcamera/pipeline/vimc/vimc.cpp
+++ b/src/libcamera/pipeline/vimc/vimc.cpp
@@ -536,19 +536,30 @@  int PipelineHandlerVimc::processControls(VimcCameraData *data, Request *request)
 int PipelineHandlerVimc::queueRequestDevice(Camera *camera, Request *request)
 {
 	VimcCameraData *data = cameraData(camera);
-	FrameBuffer *buffer = request->findBuffer(&data->rgbStream_);
-	if (!buffer) {
-		LOG(VIMC, Error)
-			<< "Attempt to queue request with invalid stream";
+	for (auto it : request->buffers()) {
+		Stream *stream = static_cast<Stream *>(it.first);
+		FrameBuffer *buffer = it.second;
+		if (!buffer) {
+			LOG(VIMC, Error)
+				<< "Attempt to queue request with invalid stream";
+
+			return -ENOENT;
+		}
 
-		return -ENOENT;
-	}
+		int ret;
 
-	int ret = processControls(data, request);
-	if (ret < 0)
-		return ret;
+		if (stream == &data->rgbStream_)
+			ret = data->video_->queueBuffer(buffer);
+		if (stream == &data->rawStream_)
+			ret = data->raw_->queueBuffer(buffer);
+		else
+			continue;
 
-	ret = data->video_->queueBuffer(buffer);
+		if (ret < 0)
+			return ret;
+		return ret;
+	}
+	int ret = processControls(data, request);
 	if (ret < 0)
 		return ret;