diff options
author | Niklas Söderlund <niklas.soderlund@ragnatech.se> | 2019-11-26 00:04:53 +0100 |
---|---|---|
committer | Niklas Söderlund <niklas.soderlund@ragnatech.se> | 2020-01-12 16:10:37 +0100 |
commit | ae9a05847cead7ddedba0ae150e538562afbb13f (patch) | |
tree | 0a73fab59990c825235e31075676717dfede16d5 /src/cam/buffer_writer.cpp | |
parent | 007517618c8440d09cfd39db5dbf451e87ef703a (diff) |
libcamera: buffer: Switch from Plane to FrameBuffer::Plane
It is not libcamera's responsibility to handle memory mappings. Switch
from the soon to be removed Plane class which deals with memory
mappings to FrameBuffer::Plane which just describes it. This makes the
transition to the full FrameBuffer easier.
As the full FrameBuffer interface has not yet spread to all parts of
libcamera core it is hard to create efficient caching of memory mappings
in the qcam application. This will be fixed in a later patch, for now
the dmabuf is mapped and unmapped each time it is seen by the
application.
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src/cam/buffer_writer.cpp')
-rw-r--r-- | src/cam/buffer_writer.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/cam/buffer_writer.cpp b/src/cam/buffer_writer.cpp index c33e99c5..765a1762 100644 --- a/src/cam/buffer_writer.cpp +++ b/src/cam/buffer_writer.cpp @@ -10,6 +10,7 @@ #include <iostream> #include <sstream> #include <string.h> +#include <sys/mman.h> #include <unistd.h> #include "buffer_writer.h" @@ -43,9 +44,11 @@ int BufferWriter::write(Buffer *buffer, const std::string &streamName) return -errno; BufferMemory *mem = buffer->mem(); - for (Plane &plane : mem->planes()) { - void *data = plane.mem(); - unsigned int length = plane.length(); + for (const FrameBuffer::Plane &plane : mem->planes()) { + /* \todo Once the FrameBuffer is done cache mapped memory. */ + void *data = mmap(NULL, plane.length, PROT_READ, MAP_SHARED, + plane.fd.fd(), 0); + unsigned int length = plane.length; ret = ::write(fd, data, length); if (ret < 0) { @@ -59,6 +62,8 @@ int BufferWriter::write(Buffer *buffer, const std::string &streamName) << length << std::endl; break; } + + munmap(data, length); } close(fd); |