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:
@@ -257,13 +257,13 @@ void *Plane::mem()
|
||||
/**
|
||||
* \fn BufferMemory::planes() const
|
||||
* \brief Retrieve the planes within the buffer
|
||||
* \return A const reference to a vector holding all Planes within the buffer
|
||||
* \return A const reference to a vector holding all planes within the buffer
|
||||
*/
|
||||
|
||||
/**
|
||||
* \fn BufferMemory::planes()
|
||||
* \brief Retrieve the planes within the buffer
|
||||
* \return A reference to a vector holding all Planes within the buffer
|
||||
* \return A reference to a vector holding all planes within the buffer
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
@@ -687,22 +687,14 @@ int PipelineHandlerRkISP1::allocateBuffers(Camera *camera,
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < stream->configuration().bufferCount + 1; i++) {
|
||||
FrameBuffer::Plane plane;
|
||||
plane.fd = FileDescriptor(paramPool_.buffers()[i].planes()[0].dmabuf());
|
||||
plane.length = paramPool_.buffers()[i].planes()[0].length();
|
||||
|
||||
data->ipaBuffers_.push_back({ .id = RKISP1_PARAM_BASE | i,
|
||||
.planes = { plane } });
|
||||
.planes = paramPool_.buffers()[i].planes() });
|
||||
paramBuffers_.push(new Buffer(i));
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < stream->configuration().bufferCount + 1; i++) {
|
||||
FrameBuffer::Plane plane;
|
||||
plane.fd = FileDescriptor(statPool_.buffers()[i].planes()[0].dmabuf());
|
||||
plane.length = statPool_.buffers()[i].planes()[0].length();
|
||||
|
||||
data->ipaBuffers_.push_back({ .id = RKISP1_STAT_BASE | i,
|
||||
.planes = { plane } });
|
||||
.planes = statPool_.buffers()[i].planes() });
|
||||
statBuffers_.push(new Buffer(i));
|
||||
}
|
||||
|
||||
|
||||
@@ -577,8 +577,10 @@ int Stream::mapBuffer(const Buffer *buffer)
|
||||
if (dmabufs[i] == -1)
|
||||
break;
|
||||
|
||||
mem->planes().emplace_back();
|
||||
mem->planes().back().setDmabuf(dmabufs[i], 0);
|
||||
FrameBuffer::Plane plane;
|
||||
plane.fd = FileDescriptor(dmabufs[i]);
|
||||
plane.length = 0;
|
||||
mem->planes().push_back(plane);
|
||||
}
|
||||
|
||||
/* Remove the buffer from the cache and return its index. */
|
||||
|
||||
@@ -922,9 +922,10 @@ int V4L2VideoDevice::createPlane(BufferMemory *buffer, unsigned int index,
|
||||
return ret;
|
||||
}
|
||||
|
||||
buffer->planes().emplace_back();
|
||||
Plane &plane = buffer->planes().back();
|
||||
plane.setDmabuf(expbuf.fd, length);
|
||||
FrameBuffer::Plane plane;
|
||||
plane.fd = FileDescriptor(expbuf.fd);
|
||||
plane.length = length;
|
||||
buffer->planes().push_back(plane);
|
||||
::close(expbuf.fd);
|
||||
|
||||
return 0;
|
||||
@@ -987,14 +988,14 @@ int V4L2VideoDevice::queueBuffer(Buffer *buffer)
|
||||
|
||||
bool multiPlanar = V4L2_TYPE_IS_MULTIPLANAR(buf.type);
|
||||
BufferMemory *mem = &bufferPool_->buffers()[buf.index];
|
||||
const std::vector<Plane> &planes = mem->planes();
|
||||
const std::vector<FrameBuffer::Plane> &planes = mem->planes();
|
||||
|
||||
if (buf.memory == V4L2_MEMORY_DMABUF) {
|
||||
if (multiPlanar) {
|
||||
for (unsigned int p = 0; p < planes.size(); ++p)
|
||||
v4l2Planes[p].m.fd = planes[p].dmabuf();
|
||||
v4l2Planes[p].m.fd = planes[p].fd.fd();
|
||||
} else {
|
||||
buf.m.fd = planes[0].dmabuf();
|
||||
buf.m.fd = planes[0].fd.fd();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user