summaryrefslogtreecommitdiff
path: root/src/libcamera/pipeline/raspberrypi/rpi_stream.h
diff options
context:
space:
mode:
authorNaushir Patuck <naush@raspberrypi.com>2020-09-18 10:42:27 +0100
committerNiklas Söderlund <niklas.soderlund@ragnatech.se>2020-09-21 13:10:48 +0200
commit2df7bf168105d02e7f2cb8090938d58eccd208f1 (patch)
tree711fff9f67387d49015721c75894e7f47af043b1 /src/libcamera/pipeline/raspberrypi/rpi_stream.h
parent3e7ee080d6dcc3f674ccdd14e08b7cf25df06ddd (diff)
libcamera: pipeline: raspberrypi: Rework stream buffer logic for zero-copy
Stop using v4l2_videodevice::allocateBuffer() for internal buffers and instead export/import all buffers. This allows the pipeline to return any stream buffer requested by the application as zero-copy. Advertise the Unicam Image stream as the RAW capture stream now. The RPiStream object now maintains a new list of buffers that are available to queue into a device. This is needed to distinguish between FrameBuffers allocated for internal use vs externally provided buffers. When a Request comes in, if a buffer is not provided for an exported stream, we re-use a buffer from this list. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Tested-by: David Plowman <david.plowman@raspberrypi.com> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Diffstat (limited to 'src/libcamera/pipeline/raspberrypi/rpi_stream.h')
-rw-r--r--src/libcamera/pipeline/raspberrypi/rpi_stream.h33
1 files changed, 23 insertions, 10 deletions
diff --git a/src/libcamera/pipeline/raspberrypi/rpi_stream.h b/src/libcamera/pipeline/raspberrypi/rpi_stream.h
index 8fcf522b..73954ec7 100644
--- a/src/libcamera/pipeline/raspberrypi/rpi_stream.h
+++ b/src/libcamera/pipeline/raspberrypi/rpi_stream.h
@@ -44,20 +44,23 @@ public:
void setExternal(bool external);
bool isExternal() const;
- void setExternalBuffers(std::vector<std::unique_ptr<FrameBuffer>> *buffers);
- const std::vector<std::unique_ptr<FrameBuffer>> *getBuffers() const;
+ void setExportedBuffers(std::vector<std::unique_ptr<FrameBuffer>> *buffers);
+ const std::vector<FrameBuffer *> &getBuffers() const;
bool findFrameBuffer(FrameBuffer *buffer) const;
- int importBuffers(unsigned int count);
- int allocateBuffers(unsigned int count);
+ int prepareBuffers(unsigned int count);
+ int queueBuffer(FrameBuffer *buffer);
+ void returnBuffer(FrameBuffer *buffer);
- int queueBuffers();
+ int queueAllBuffers();
void releaseBuffers();
private:
+ void clearBuffers();
+
/*
* Indicates that this stream is active externally, i.e. the buffers
- * are provided by the application.
+ * might be provided by (and returned to) the application.
*/
bool external_;
@@ -70,11 +73,21 @@ private:
/* The actual device stream. */
std::unique_ptr<V4L2VideoDevice> dev_;
- /* Internally allocated framebuffers associated with this device stream. */
- std::vector<std::unique_ptr<FrameBuffer>> internalBuffers_;
+ /* All framebuffers associated with this device stream. */
+ std::vector<FrameBuffer *> bufferList_;
+
+ /*
+ * List of frame buffers that we can use if none have been provided by
+ * the application for external streams. This is populated by the
+ * buffers exported internally.
+ */
+ std::queue<FrameBuffer *> availableBuffers_;
- /* Externally allocated framebuffers associated with this device stream. */
- std::vector<std::unique_ptr<FrameBuffer>> *externalBuffers_;
+ /*
+ * This is a list of buffers exported internally. Need to keep this around
+ * as the stream needs to maintain ownership of these buffers.
+ */
+ std::vector<std::unique_ptr<FrameBuffer>> internalBuffers_;
};
/*