[libcamera-devel,v4,04/12] pipeline: raspberrypi: Reorder startup drop frame initialisation
diff mbox series

Message ID 20221209090050.19441-5-naush@raspberrypi.com
State Superseded
Headers show
Series
  • Raspberry Pi: Platform configuration and buffer allocation improvements
Related show

Commit Message

Naushir Patuck Dec. 9, 2022, 9 a.m. UTC
Reorder the code such that the IPA requested startup drop frames count is
available before the pipeline handler allocates any stream buffers.

This will be used in a subsequent change to stop Unicam buffer allocations if
there are no startup drop frames required and the application has configured a
raw stream and always provides buffers for it.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 .../pipeline/raspberrypi/raspberrypi.cpp      | 30 +++++++++----------
 1 file changed, 15 insertions(+), 15 deletions(-)

Comments

Kieran Bingham Jan. 16, 2023, 5:33 p.m. UTC | #1
Quoting Naushir Patuck via libcamera-devel (2022-12-09 09:00:42)
> Reorder the code such that the IPA requested startup drop frames count is
> available before the pipeline handler allocates any stream buffers.
> 
> This will be used in a subsequent change to stop Unicam buffer allocations if
> there are no startup drop frames required and the application has configured a
> raw stream and always provides buffers for it.
> 
> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>


Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

> ---
>  .../pipeline/raspberrypi/raspberrypi.cpp      | 30 +++++++++----------
>  1 file changed, 15 insertions(+), 15 deletions(-)
> 
> diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
> index f6388d63416b..c5a489fc7581 100644
> --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
> +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
> @@ -1036,21 +1036,6 @@ int PipelineHandlerRPi::start(Camera *camera, const ControlList *controls)
>         RPiCameraData *data = cameraData(camera);
>         int ret;
>  
> -       for (auto const stream : data->streams_)
> -               stream->resetBuffers();
> -
> -       if (!data->buffersAllocated_) {
> -               /* Allocate buffers for internal pipeline usage. */
> -               ret = prepareBuffers(camera);
> -               if (ret) {
> -                       LOG(RPI, Error) << "Failed to allocate buffers";
> -                       data->freeBuffers();
> -                       stop(camera);
> -                       return ret;
> -               }
> -               data->buffersAllocated_ = true;
> -       }
> -
>         /* Check if a ScalerCrop control was specified. */
>         if (controls)
>                 data->applyScalerCrop(*controls);
> @@ -1067,6 +1052,21 @@ int PipelineHandlerRPi::start(Camera *camera, const ControlList *controls)
>         /* Configure the number of dropped frames required on startup. */
>         data->dropFrameCount_ = startConfig.dropFrameCount;
>  
> +       for (auto const stream : data->streams_)
> +               stream->resetBuffers();
> +
> +       if (!data->buffersAllocated_) {
> +               /* Allocate buffers for internal pipeline usage. */
> +               ret = prepareBuffers(camera);
> +               if (ret) {
> +                       LOG(RPI, Error) << "Failed to allocate buffers";
> +                       data->freeBuffers();
> +                       stop(camera);
> +                       return ret;
> +               }
> +               data->buffersAllocated_ = true;
> +       }
> +
>         /* We need to set the dropFrameCount_ before queueing buffers. */
>         ret = queueAllBuffers(camera);
>         if (ret) {
> -- 
> 2.25.1
>

Patch
diff mbox series

diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
index f6388d63416b..c5a489fc7581 100644
--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
@@ -1036,21 +1036,6 @@  int PipelineHandlerRPi::start(Camera *camera, const ControlList *controls)
 	RPiCameraData *data = cameraData(camera);
 	int ret;
 
-	for (auto const stream : data->streams_)
-		stream->resetBuffers();
-
-	if (!data->buffersAllocated_) {
-		/* Allocate buffers for internal pipeline usage. */
-		ret = prepareBuffers(camera);
-		if (ret) {
-			LOG(RPI, Error) << "Failed to allocate buffers";
-			data->freeBuffers();
-			stop(camera);
-			return ret;
-		}
-		data->buffersAllocated_ = true;
-	}
-
 	/* Check if a ScalerCrop control was specified. */
 	if (controls)
 		data->applyScalerCrop(*controls);
@@ -1067,6 +1052,21 @@  int PipelineHandlerRPi::start(Camera *camera, const ControlList *controls)
 	/* Configure the number of dropped frames required on startup. */
 	data->dropFrameCount_ = startConfig.dropFrameCount;
 
+	for (auto const stream : data->streams_)
+		stream->resetBuffers();
+
+	if (!data->buffersAllocated_) {
+		/* Allocate buffers for internal pipeline usage. */
+		ret = prepareBuffers(camera);
+		if (ret) {
+			LOG(RPI, Error) << "Failed to allocate buffers";
+			data->freeBuffers();
+			stop(camera);
+			return ret;
+		}
+		data->buffersAllocated_ = true;
+	}
+
 	/* We need to set the dropFrameCount_ before queueing buffers. */
 	ret = queueAllBuffers(camera);
 	if (ret) {