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>
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user