diff options
author | Niklas Söderlund <niklas.soderlund@ragnatech.se> | 2019-10-28 00:21:48 +0100 |
---|---|---|
committer | Niklas Söderlund <niklas.soderlund@ragnatech.se> | 2020-01-12 16:10:37 +0100 |
commit | cadae67e45785dc5dc005adb63c2dec841f44b1d (patch) | |
tree | f90fd44076c47aa052e3979866e79c48d2093dda /src/libcamera/include | |
parent | 9e71540ebbde3592805aff0e2e26803406b2e15c (diff) |
libcamera: v4l2_videodevice: Add FrameBuffer interface
Add a new interface in parallel with the existing Buffer implementation
to also support FrameBuffer. The reason it's added in parallel is to aid
in the migration from Buffer to FrameBuffer throughout libcamera. With
this change discrete parts of libcamera can be migrated and tested
independently.
As the new interface is added in parallel there are some oddities in
this change which will be undone in a follow up patch once libcamera
have migrated away from the Buffer interface.
- There is a nasty hack in V4L2VideoDevice::bufferAvailable(). It is
needed to allow both interfaces to exist and function at the same
time. The idea is if buffers are allocated using the FrameBuffer
interface V4L2VideoDevice::cache_ is set and we know to call the
FrameBuffer 'buffer ready' signal, and likewise if it's not to call
the Buffer variant.
- There is some code duplication between the two interfaces as they aim
to solve the same thing in slightly different ways. As all Buffer
related code is soon to be removed no effort to create code sharing
between them have been made.
- Some function and variables which can't be distinguished by their
argument types have been given a frameBuffer prefix instead of a
buffer prefix. They are clearly documented in the code and will be
renamed to the correct buffer prefix when the Buffer interface is
removed.
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src/libcamera/include')
-rw-r--r-- | src/libcamera/include/v4l2_videodevice.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/libcamera/include/v4l2_videodevice.h b/src/libcamera/include/v4l2_videodevice.h index 9d22754a..09967d3c 100644 --- a/src/libcamera/include/v4l2_videodevice.h +++ b/src/libcamera/include/v4l2_videodevice.h @@ -184,11 +184,17 @@ public: int exportBuffers(BufferPool *pool); int importBuffers(BufferPool *pool); + int exportBuffers(unsigned int count, + std::vector<std::unique_ptr<FrameBuffer>> *buffers); + int importBuffers(unsigned int count); int releaseBuffers(); int queueBuffer(Buffer *buffer); std::vector<std::unique_ptr<Buffer>> queueAllBuffers(); Signal<Buffer *> bufferReady; + int queueBuffer(FrameBuffer *buffer); + /* todo Rename to bufferReady when the Buffer version is removed */ + Signal<FrameBuffer *> frameBufferReady; int streamOn(); int streamOff(); @@ -219,10 +225,13 @@ private: int requestBuffers(unsigned int count); int createPlane(BufferMemory *buffer, unsigned int index, unsigned int plane, unsigned int length); + std::unique_ptr<FrameBuffer> createFrameBuffer(const struct v4l2_buffer &buf); FileDescriptor exportDmabufFd(unsigned int index, unsigned int plane); Buffer *dequeueBuffer(); void bufferAvailable(EventNotifier *notifier); + /* todo Rename to dequeueBuffer() when the Buffer version is removed */ + FrameBuffer *dequeueFrameBuffer(); V4L2Capability caps_; @@ -230,7 +239,10 @@ private: enum v4l2_memory memoryType_; BufferPool *bufferPool_; + V4L2BufferCache *cache_; std::map<unsigned int, Buffer *> queuedBuffers_; + /* todo Rename to queuedBuffers_ when the Buffer version is removed */ + std::map<unsigned int, FrameBuffer *> queuedFrameBuffers_; EventNotifier *fdEvent_; }; |