Skip to content

v4l2: raise the capture buffer cap from four to eight - #345

Open
vrilutza wants to merge 2 commits into
patjak:masterfrom
vrilutza:buffer-count
Open

vrilutza wants to merge 2 commits into
patjak:masterfrom
vrilutza:buffer-count

Conversation

@vrilutza

@vrilutza vrilutza commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

The four-context limit prevents clients from allocating a deeper capture queue even when the 16 MiB budget can hold more frames. If a consumer retains all four buffers, the camera has none available for another frame.

This revision has two commits:

  1. Correct the buffer-queue debug message to read descriptor zero of the current buffer's list. The old code uses the capture-context slot as an index into a four-element descriptor array. Increasing the context count to eight therefore makes debug logging read outside that array for slots 4–7.
  2. Raise FTHD_BUFFERS from four to eight. The allocation budget still limits the actual count; eight 1296x736 YUYV buffers fit within it.

The descriptor correction is new relative to the previous one-line PR. An extracted UBSan check reproduces the old out-of-bounds access at index four and passes with descriptor zero. The corrected combined series also captured using all eight buffer indices, with no V4L2 buffer error flags in the recorded tests.

This raises the permitted queue depth. It does not guarantee that every PipeWire client negotiates eight buffers, and retaining all eight still stalls capture. The cumulative CREATE_BUFS accounting correction is in #342; the eight-buffer tests quoted here used that correction as part of the combined series.

Validation scope: this individual rebased branch builds against Linux 7.1.13+deb14-amd64 with W=1; the two existing compiler warnings remain. The complete nine-topic series previously passed 57/57 streaming-inclusive v4l2-compliance checks on MacBookPro14,1. Its final source tree is unchanged by the commit-message rewrite. The combined hardware tests are not nine separate hardware certifications, and no new module reload or hardware test was performed for this publication.

Revision: b1a9b40bb3d4130808a15f39cb189d81a4ba69c5.

Each queued buffer uses descriptor zero of its own list, but the debug
message indexes that list with the capture-context slot. For nonzero
slots it reports another descriptor, and slots four and above exceed the
four-element descriptor array when debug logging is enabled.

Read descriptor zero, matching the descriptor populated for this buffer.
This fixes the diagnostic and makes logging safe before increasing the
capture-context limit beyond four. The firmware buffer submission is
unchanged.

Based-on: patjak#345
The four-context limit prevents clients from allocating a deeper capture
queue even when the 16 MiB budget has room. A consumer holding all four
buffers leaves none available for another frame.

Raise the limit to eight so clients can retain more frames while leaving
buffers available to the camera. The allocation budget still constrains
the actual count; eight 1296x736 YUYV buffers fit within it.

This increases the permitted queue depth, not the negotiated count of
every userspace pipeline. Holding all eight buffers still stalls
capture. Keep the descriptor-index correction before this change so
debug logging remains within the per-buffer descriptor array.

Based-on: patjak#345
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant