pipeline: rpi: Increase buffer import count to 32
Hardcode the maximum number of buffers imported to the V4L2 video device to 32. This only has a minor disadvantage of over-allocating cache slots and V4L2 buffer indexes, but does allow more headroom for using dma buffers allocated from outside of libcamera. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
parent
ae9bcb2155
commit
1107999f71
1 changed files with 11 additions and 25 deletions
|
@ -8,6 +8,9 @@
|
||||||
|
|
||||||
#include <libcamera/base/log.h>
|
#include <libcamera/base/log.h>
|
||||||
|
|
||||||
|
/* Maximum number of buffer slots to allocate in the V4L2 device driver. */
|
||||||
|
static constexpr unsigned int maxV4L2BufferCount = 32;
|
||||||
|
|
||||||
namespace libcamera {
|
namespace libcamera {
|
||||||
|
|
||||||
LOG_DEFINE_CATEGORY(RPISTREAM)
|
LOG_DEFINE_CATEGORY(RPISTREAM)
|
||||||
|
@ -95,34 +98,17 @@ int Stream::prepareBuffers(unsigned int count)
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!(flags_ & StreamFlag::ImportOnly)) {
|
if (!(flags_ & StreamFlag::ImportOnly)) {
|
||||||
if (count) {
|
/* Export some frame buffers for internal use. */
|
||||||
/* Export some frame buffers for internal use. */
|
ret = dev_->exportBuffers(count, &internalBuffers_);
|
||||||
ret = dev_->exportBuffers(count, &internalBuffers_);
|
if (ret < 0)
|
||||||
if (ret < 0)
|
return ret;
|
||||||
return ret;
|
|
||||||
|
|
||||||
/* Add these exported buffers to the internal/external buffer list. */
|
/* Add these exported buffers to the internal/external buffer list. */
|
||||||
setExportedBuffers(&internalBuffers_);
|
setExportedBuffers(&internalBuffers_);
|
||||||
resetBuffers();
|
resetBuffers();
|
||||||
}
|
|
||||||
|
|
||||||
/* We must import all internal/external exported buffers. */
|
|
||||||
count = bufferMap_.size();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
return dev_->importBuffers(maxV4L2BufferCount);
|
||||||
* If this is an external stream, we must allocate slots for buffers that
|
|
||||||
* might be externally allocated. We have no indication of how many buffers
|
|
||||||
* may be used, so this might overallocate slots in the buffer cache.
|
|
||||||
* Similarly, if this stream is only importing buffers, we do the same.
|
|
||||||
*
|
|
||||||
* \todo Find a better heuristic, or, even better, an exact solution to
|
|
||||||
* this issue.
|
|
||||||
*/
|
|
||||||
if ((flags_ & StreamFlag::External) || (flags_ & StreamFlag::ImportOnly))
|
|
||||||
count = count * 2;
|
|
||||||
|
|
||||||
return dev_->importBuffers(count);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int Stream::queueBuffer(FrameBuffer *buffer)
|
int Stream::queueBuffer(FrameBuffer *buffer)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue