[libcamera-devel,v1,09/10] pipeline: raspberrypi: Add minimal memory usage config file
diff mbox series

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

Commit Message

Naushir Patuck Oct. 14, 2022, 1:18 p.m. UTC
Add a platform configuration file that allocates the least amount of frame
buffer memory possible. This configuration does come with the following
compromises:

- Startup frame drops are disabled, so the first few frames will not have
fully converged AE/AWB/ALSC applied.

- Applications must provide ISP Output0 and Unicam Image (if a RAW stream is
configured) buffers in requests.

- Only 1 Unicam Image buffer will be allocated if a RAW stream is not
configured, causing the framerate to be effectively halved.

To use the configuration on the Raspberry Pi platform, invoke the application
with the following prepended to the command line:

LIBCAMERA_RPI_CONFIG_FILE=/usr/local/share/libcamera/pipeline/raspberrypi/minimal_memory.json

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
---
 .../pipeline/raspberrypi/data/meson.build     |  1 +
 .../raspberrypi/data/minimal_mem.json         | 28 +++++++++++++++++++
 2 files changed, 29 insertions(+)
 create mode 100644 src/libcamera/pipeline/raspberrypi/data/minimal_mem.json

Comments

David Plowman Nov. 1, 2022, 12:25 p.m. UTC | #1
Hi Naush

Thanks for the patch!

On Fri, 14 Oct 2022 at 14:19, Naushir Patuck via libcamera-devel
<libcamera-devel@lists.libcamera.org> wrote:
>
> Add a platform configuration file that allocates the least amount of frame
> buffer memory possible. This configuration does come with the following
> compromises:
>
> - Startup frame drops are disabled, so the first few frames will not have
> fully converged AE/AWB/ALSC applied.
>
> - Applications must provide ISP Output0 and Unicam Image (if a RAW stream is
> configured) buffers in requests.
>
> - Only 1 Unicam Image buffer will be allocated if a RAW stream is not
> configured, causing the framerate to be effectively halved.

I wonder how useful this really is with a limitation like this? On the
other hand, I could imagine it might be more useful in conjunction
with, for example, stills capture rather than preview or video. Making
it camera mode (or better, use-case) specific sounds like a whole new
can of worms. Perhaps better not go there right now!

Is there any benefit in a minimal-but-not-framerate-halving version?
Though we could easily end up with a plethora of configuration files
that we would really want to be testing all the time.

Anyway, I shall sit back and wait for the "I pointed my Pi Zero at
this config file so that Picamera2 would work with my
zillion-megapixel sensor" bugs  :)

Reviewed-by: David Plowman <david.plowman@raspberrypi.com>

Thanks!
David

>
> To use the configuration on the Raspberry Pi platform, invoke the application
> with the following prepended to the command line:
>
> LIBCAMERA_RPI_CONFIG_FILE=/usr/local/share/libcamera/pipeline/raspberrypi/minimal_memory.json
>
> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
> ---
>  .../pipeline/raspberrypi/data/meson.build     |  1 +
>  .../raspberrypi/data/minimal_mem.json         | 28 +++++++++++++++++++
>  2 files changed, 29 insertions(+)
>  create mode 100644 src/libcamera/pipeline/raspberrypi/data/minimal_mem.json
>
> diff --git a/src/libcamera/pipeline/raspberrypi/data/meson.build b/src/libcamera/pipeline/raspberrypi/data/meson.build
> index 232f8b43c5fd..0592fc53877d 100644
> --- a/src/libcamera/pipeline/raspberrypi/data/meson.build
> +++ b/src/libcamera/pipeline/raspberrypi/data/meson.build
> @@ -2,6 +2,7 @@
>
>  conf_files = files([
>      'default.json',
> +    'minimal_mem.json',
>  ])
>
>  install_data(conf_files,
> diff --git a/src/libcamera/pipeline/raspberrypi/data/minimal_mem.json b/src/libcamera/pipeline/raspberrypi/data/minimal_mem.json
> new file mode 100644
> index 000000000000..fb306aa08f94
> --- /dev/null
> +++ b/src/libcamera/pipeline/raspberrypi/data/minimal_mem.json
> @@ -0,0 +1,28 @@
> +{
> +        "version": 1.0,
> +        "target": "bcm2835",
> +
> +        "pipeline_handler":
> +        {
> +                # The minimum number of internal buffers to be allocated for Unicam.
> +                # This value must less than or equal to min_total_unicam_buffers.
> +                "min_unicam_buffers": 0,
> +
> +                # The minimum total (internal + external) buffer count used for Unicam.
> +                # The number of internal buffers allocated for Unicam is given by:
> +                # internal buffer count = max(min_unicam_buffers,
> +                #                             min_total_unicam_buffers - external buffer count)
> +                "min_total_unicam_buffers": 1,
> +
> +                # The number of internal buffers used for ISP Output0.
> +                "num_output0_buffers": 0,
> +
> +                # Override any request from the IPA to drop a number of startup frames.
> +                "disable_startup_frame_drops": true,
> +
> +                # Always process a pending request with the last captured sensor frame.
> +                # Note that this might lead to avoidable frame drops during periods
> +                # of transient heavey CPU loading.
> +                "return_newest_frames": false
> +        }
> +}
> --
> 2.25.1
>

Patch
diff mbox series

diff --git a/src/libcamera/pipeline/raspberrypi/data/meson.build b/src/libcamera/pipeline/raspberrypi/data/meson.build
index 232f8b43c5fd..0592fc53877d 100644
--- a/src/libcamera/pipeline/raspberrypi/data/meson.build
+++ b/src/libcamera/pipeline/raspberrypi/data/meson.build
@@ -2,6 +2,7 @@ 
 
 conf_files = files([
     'default.json',
+    'minimal_mem.json',
 ])
 
 install_data(conf_files,
diff --git a/src/libcamera/pipeline/raspberrypi/data/minimal_mem.json b/src/libcamera/pipeline/raspberrypi/data/minimal_mem.json
new file mode 100644
index 000000000000..fb306aa08f94
--- /dev/null
+++ b/src/libcamera/pipeline/raspberrypi/data/minimal_mem.json
@@ -0,0 +1,28 @@ 
+{
+        "version": 1.0,
+        "target": "bcm2835",
+
+        "pipeline_handler":
+        {
+                # The minimum number of internal buffers to be allocated for Unicam.
+                # This value must less than or equal to min_total_unicam_buffers.
+                "min_unicam_buffers": 0,
+
+                # The minimum total (internal + external) buffer count used for Unicam.
+                # The number of internal buffers allocated for Unicam is given by:
+                # internal buffer count = max(min_unicam_buffers,
+                #                             min_total_unicam_buffers - external buffer count)
+                "min_total_unicam_buffers": 1,
+
+                # The number of internal buffers used for ISP Output0.
+                "num_output0_buffers": 0,
+
+                # Override any request from the IPA to drop a number of startup frames.
+                "disable_startup_frame_drops": true,
+
+                # Always process a pending request with the last captured sensor frame.
+                # Note that this might lead to avoidable frame drops during periods
+                # of transient heavey CPU loading.
+                "return_newest_frames": false
+        }
+}