[PATCH v11 00/19] lc-compliance: Add test to queue more requests than hardware depth
Sven Püschel
s.pueschel at pengutronix.de
Mon Apr 28 11:02:25 CEST 2025
The purpose of this series is to add a new test to lc-compliance that tests
queuing a lot of requests at once in order to ensure that pipeline handlers are
able to handle more requests than they have resources for (like internal buffers
and V4L2 buffer slots) [1].
[1] https://bugs.libcamera.org/show_bug.cgi?id=24
In order to achieve this, the FrameBufferAllocator had to be adapted to allow an
arbitrary number of buffers to be allocated. But there's also the issue of
reporting the minimum number of requests required by the pipeline handler, which
was solved by creating a new MinimumRequests property.
Briefly, patches 1 through 11 rework the core and pipeline handlers to use
MinimumRequests and remove bufferCount. Patches 12 through 15 rework
lc-compliance to add the new test and an additional test for MinimumRequests.
Patches 16 through 19 integrate the request queue patches for v4l2 and rkisp1.
Patch 1 adds the new MinimumRequests property to report the minimum number of
requests needed by the pipeline handler.
Patch 2 adds a count argument to allocate() so that the number of buffers to
allocate needs to be specified, as it is no longer assumed through bufferCount.
Patches 3-9 decouple the number of internal buffers and V4L2 buffer slots from
bufferCount in each pipeline handler.
Patch 10 reworks the V4L2 compatibility layer to not depend on bufferCount.
Patch 11 removes bufferCount from the StreamConfiguration and everywhere it was
still used, as it is no longer needed.
Patches 12-13 does some refactoring in lc-compliance in order to reduce code
duplication.
Patch 14 adds the test to lc-compliance. The number of buffers to allocate was
hardcoded to 8 since more than that would cause errors when allocating.
Patch 15 adds another, very short, test to lc-compliance to make sure that the
MinimumRequests property is set in the pipeline handler.
Patches 16 and 17 add request queues to the rkisp1 and uvcvideo handler.
These were originally submitted in a separate patchset [2], but linked to this
patchset, as they avoid canceling requests when too many buffers are queued.
As these are not strictly necessary for this patchset, I've only ported
the rkisp1 and uvcvideo patches, as I was able to test them
(rkisp1 only against libcamera 0.3.2).
[2] https://lists.libcamera.org/pipermail/libcamera-devel/2021-September/024121.html
Patch 18 documents the request queue pattern.
Patch 19 improves the v4l2 error to also include the amount of buffers
requested and how many were actually allocated by v4l2.
Given that the allocation function requires an unsigned amount of buffers to
allocate, the MinimumRequests property was changed to an unsigned integer
to avoid potential signedness warnings in applications when they adapt to the
MinimumRequests property.
v10: https://lists.libcamera.org/pipermail/libcamera-devel/2022-December/036255.html
v9: https://lists.libcamera.org/pipermail/libcamera-devel/2022-December/036104.html
v8: https://lists.libcamera.org/pipermail/libcamera-devel/2021-August/023773.html
v7: https://lists.libcamera.org/pipermail/libcamera-devel/2021-July/022577.html
v6: https://lists.libcamera.org/pipermail/libcamera-devel/2021-July/022356.html
v5: https://lists.libcamera.org/pipermail/libcamera-devel/2021-July/022098.html
v4: https://lists.libcamera.org/pipermail/libcamera-devel/2021-May/020150.html
v3: https://lists.libcamera.org/pipermail/libcamera-devel/2021-April/019613.html
v2: https://lists.libcamera.org/pipermail/libcamera-devel/2021-April/019398.html
v1: https://lists.libcamera.org/pipermail/libcamera-devel/2021-April/019139.html
Changes in v11:
- picked up and rebased by Sven
- add mali-c55, dcmipp, virtual, j721e, intel-ipu6 and mtk-seninf suppport
- Changed MinimumRequests property type from int32_t -> uint32_t
- Integrated internal request queue patches for v4l2 and rkisp1
Changes in v10:
- add imx8-isi, pycamera, and android
- update MinimumRequests description and pipeline hander guide
- clean up raspberry pi and ipu3 (compared to the last version)
- rename variables in simple
Changes in v9:
- picked up and rebased by Paul
Changes in v8:
(thanks to Laurent and Kieran)
- Changed internal buffer count constants for pipeline handlers to better values
- Reordered patches to group non-lc-compliance changes together
- Split buffer allocation changes into separate commits for each pipeline
handler (patches 3-7)
- Changed the MinimumRequests property meaning to require that frames aren't
dropped
- Set MinimumRequests on SimplePipeline depending on device and usage of
converter
- Undid definition of default MinimumRequests on CameraSensor constructor
- Updated application-developer and pipeline-handler guides with new allocate()
API and MinimumRequests property
- Added handling for when allocate() returns less buffers than needed in cam and
the capture unit test
- Reworked buffer allocation handling in the raspberrypi pipeline handler
- Moved V4L2 compatibility layer changes to separate commit
- Added patch 10 to fix wrong file order in lc-compliance's meson.build
- Added requests_ member to SimpleCapture to hold ownership of queued
requests during capture
- Moved CameraHolder to new test_base.{cpp,h} files
- Fixed issue in UnbalancedStop test where requests cancelled due to stop() call
were failing the test
- Moved RequiredProperties test to property_test.cpp
- Moved CameraTests to new test_base.{cpp,h} files
Changes in v7:
(thanks to Kieran and Jacopo)
- Renamed property from MinNumRequests to MinimumRequests
- Changed MinimumRequests property's description
- Added patch 11 to test if MinimumRequests is valid
Changes in v6:
(thanks to Naushir)
- Fixed style issues
- Changed static_cast to unsigned int when comparing buffer count in
lc-compliance
- Added pipeline prefix to INTERNAL_BUFFER_COUNT and BUFFER_SLOT_COUNT constants
- Removed comment from Raspberrypi MinNumRequests setting
- Switched queueRequests()'s 'buffers' and 'requests' parameters order, since
'requests' is an output variable
- Added comment to runCaptureSession()
Changes in v5:
- Rebased on master (now that lc-compliance was refactored to use Googletest)
- Added patches 3, 5, 6 and 8
- Fixed qcam to use at least two buffers
- Made sure that qcam allocates at least 2 buffers
Changes in v4:
(thanks to Laurent and Niklas)
- Renamed QueueDepth property to MinNumRequests and better documented it
- Changed patch 6 to also remove bufferCount from android
- Added patch 3 to factor common code in lc-compliance
- Added patch 5 to remove pipeline dependency on bufferCount
Changes in v3:
- Added patches 1 and 4 to add the QueueDepth property and remove bufferCount
- Made the count argument required in patch 2
- Added previously missing changes to the gstreamer and V4L2 compatibility
layers
Changes in v2:
- Renamed and reworded commits and series
- Dropped patches 2 and 3, which were hacks to test, and added patch 1 to add
count to FrameBufferAllocator
- Thanks to Niklas:
- Created new standalone test instead of looping over the other tests
Nícolas F. R. A. Prado (16):
libcamera: property: Add MinimumRequests property
libcamera: framebuffer_allocator: Make allocate() require count
libcamera: pipeline: rpi: Don't rely on bufferCount
libcamera: pipeline: ipu3: Don't rely on bufferCount
libcamera: pipeline: rkisp1: Don't rely on bufferCount
libcamera: pipeline: simple: Don't rely on bufferCount
libcamera: pipeline: vimc, uvcvideo: Don't rely on bufferCount
v4l2: Allocate buffers based on requested count and MinimumRequests
libcamera: stream: Remove bufferCount
lc-compliance: Move buffer allocation to separate function
lc-compliance: Move camera setup to CameraHolder class
lc-compliance: Add test to queue more requests than hardware depth
lc-compliance: Add test to ensure MinimumRequests is valid
libcamera: pipeline: uvcvideo: Add internal request queue
libcamera: pipeline: rkisp1: Add internal request queue
Documentation: guides: pipeline-handler: Document internal queue
pattern
Paul Elder (1):
libcamera: pipeline: imx8-isi: Don't rely on bufferCount
Sven Püschel (2):
libcamera: pipeline: mali-c55: Don't rely on bufferCount
libcamera: v4l2_videodevice: Log buffer count on error
.../guides/application-developer.rst | 9 +-
Documentation/guides/pipeline-handler.rst | 167 +++++++++++++-----
include/libcamera/camera.h | 2 +-
include/libcamera/framebuffer_allocator.h | 2 +-
include/libcamera/internal/converter.h | 2 +-
.../internal/converter/converter_v4l2_m2m.h | 7 +-
include/libcamera/internal/pipeline_handler.h | 2 +-
include/libcamera/stream.h | 2 -
src/android/camera_stream.cpp | 5 +-
src/apps/cam/camera_session.cpp | 13 +-
src/apps/lc-compliance/helpers/capture.cpp | 49 +++--
src/apps/lc-compliance/helpers/capture.h | 2 +
src/apps/lc-compliance/meson.build | 2 +
src/apps/lc-compliance/property_test.cpp | 24 +++
src/apps/lc-compliance/test_base.cpp | 38 ++++
src/apps/lc-compliance/test_base.h | 31 ++++
src/apps/lc-compliance/tests/capture_test.cpp | 81 +++++++--
src/apps/qcam/main_window.cpp | 10 +-
src/gstreamer/gstlibcameraallocator.cpp | 6 +-
src/libcamera/camera.cpp | 4 +-
src/libcamera/converter.cpp | 2 +
.../converter/converter_v4l2_m2m.cpp | 15 +-
src/libcamera/framebuffer_allocator.cpp | 9 +-
src/libcamera/pipeline/imx8-isi/imx8-isi.cpp | 14 +-
src/libcamera/pipeline/ipu3/cio2.cpp | 8 +-
src/libcamera/pipeline/ipu3/cio2.h | 4 +-
src/libcamera/pipeline/ipu3/imgu.cpp | 13 +-
src/libcamera/pipeline/ipu3/imgu.h | 3 +-
src/libcamera/pipeline/ipu3/ipu3.cpp | 59 ++++---
src/libcamera/pipeline/mali-c55/mali-c55.cpp | 27 +--
src/libcamera/pipeline/rkisp1/rkisp1.cpp | 109 ++++++++----
src/libcamera/pipeline/rkisp1/rkisp1_path.cpp | 5 +-
src/libcamera/pipeline/rkisp1/rkisp1_path.h | 4 +-
.../pipeline/rpi/common/pipeline_base.cpp | 10 +-
.../pipeline/rpi/common/pipeline_base.h | 2 +-
src/libcamera/pipeline/rpi/pisp/pisp.cpp | 2 +-
src/libcamera/pipeline/rpi/vc4/vc4.cpp | 2 +-
src/libcamera/pipeline/simple/simple.cpp | 72 +++++---
src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 120 ++++++++++---
src/libcamera/pipeline/vimc/vimc.cpp | 17 +-
src/libcamera/pipeline/virtual/virtual.cpp | 11 +-
src/libcamera/pipeline_handler.cpp | 1 +
src/libcamera/property_ids_core.yaml | 22 +++
src/libcamera/stream.cpp | 12 +-
src/libcamera/v4l2_videodevice.cpp | 3 +-
src/py/libcamera/py_main.cpp | 5 +-
src/v4l2/v4l2_camera.cpp | 21 ++-
src/v4l2/v4l2_camera.h | 5 +-
src/v4l2/v4l2_camera_proxy.cpp | 10 +-
test/camera/buffer_import.cpp | 9 +-
test/camera/camera_reconfigure.cpp | 5 +-
test/camera/capture.cpp | 11 +-
test/camera/statemachine.cpp | 5 +-
test/fence.cpp | 6 +-
test/libtest/buffer_source.cpp | 4 +-
test/libtest/buffer_source.h | 2 +-
test/mapped-buffer.cpp | 5 +-
test/v4l2_videodevice/buffer_cache.cpp | 3 +-
58 files changed, 771 insertions(+), 324 deletions(-)
create mode 100644 src/apps/lc-compliance/property_test.cpp
create mode 100644 src/apps/lc-compliance/test_base.cpp
create mode 100644 src/apps/lc-compliance/test_base.h
--
2.49.0
More information about the libcamera-devel
mailing list