Message ID | 20211112100305.2217099-4-naush@raspberrypi.com |
---|---|
State | Superseded |
Headers | show |
Series |
|
Related | show |
Hi Naush, Thank you for the patch. On Fri, Nov 12, 2021 at 10:03:05AM +0000, Naushir Patuck wrote: > If a stream is marked as external, double the number of V4L2BufferCache slots > that are allocated. This is to account for additional buffers that may be > allocated directly by the application. > > Signed-off-by: Naushir Patuck <naush@raspberrypi.com> > Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> > Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> > --- > src/libcamera/pipeline/raspberrypi/rpi_stream.cpp | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/src/libcamera/pipeline/raspberrypi/rpi_stream.cpp b/src/libcamera/pipeline/raspberrypi/rpi_stream.cpp > index b3265d0e8aab..67901936d6b6 100644 > --- a/src/libcamera/pipeline/raspberrypi/rpi_stream.cpp > +++ b/src/libcamera/pipeline/raspberrypi/rpi_stream.cpp > @@ -107,6 +107,14 @@ int Stream::prepareBuffers(unsigned int count) > count = bufferMap_.size(); > } > > + /* > + * 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. With * \todo Find a better heuristic, or, even better, an exact solution to * this issue Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > + */ > + if (isExternal()) > + count = count * 2; > + > return dev_->importBuffers(count); > } >
diff --git a/src/libcamera/pipeline/raspberrypi/rpi_stream.cpp b/src/libcamera/pipeline/raspberrypi/rpi_stream.cpp index b3265d0e8aab..67901936d6b6 100644 --- a/src/libcamera/pipeline/raspberrypi/rpi_stream.cpp +++ b/src/libcamera/pipeline/raspberrypi/rpi_stream.cpp @@ -107,6 +107,14 @@ int Stream::prepareBuffers(unsigned int count) count = bufferMap_.size(); } + /* + * 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. + */ + if (isExternal()) + count = count * 2; + return dev_->importBuffers(count); }