libcamera: Switch to FrameBuffer interface

Switch to the FrameBuffer interface where all buffers are treated as
external buffers and are allocated outside the camera. Applications
allocating buffers using libcamera are switched to use the
FrameBufferAllocator helper.

Follow-up changes to this one will finalize the transition to the new
FrameBuffer interface by removing code that is left unused after this
change.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Niklas Söderlund
2020-01-12 16:10:38 +01:00
parent eb4030f6c0
commit 9217f274f6
23 changed files with 267 additions and 368 deletions
+14 -34
View File
@@ -695,12 +695,6 @@ int Camera::configure(CameraConfiguration *config)
stream->configuration_ = cfg;
activeStreams_.insert(stream);
/*
* Allocate buffer objects in the pool.
* Memory will be allocated and assigned later.
*/
stream->createBuffers(cfg.memoryType, cfg.bufferCount);
}
state_ = CameraConfigured;
@@ -756,14 +750,6 @@ int Camera::freeBuffers()
if (!stateIs(CameraPrepared))
return -EACCES;
for (Stream *stream : activeStreams_) {
/*
* All mappings must be destroyed before buffers can be freed
* by the V4L2 device that has allocated them.
*/
stream->destroyBuffers();
}
state_ = CameraConfigured;
return pipe_->freeBuffers(this, activeStreams_);
@@ -834,24 +820,11 @@ int Camera::queueRequest(Request *request)
for (auto const &it : request->buffers()) {
Stream *stream = it.first;
Buffer *buffer = it.second;
if (activeStreams_.find(stream) == activeStreams_.end()) {
LOG(Camera, Error) << "Invalid request";
return -EINVAL;
}
if (stream->memoryType() == ExternalMemory) {
int index = stream->mapBuffer(buffer);
if (index < 0) {
LOG(Camera, Error) << "No buffer memory available";
return -ENOMEM;
}
buffer->index_ = index;
}
buffer->mem_ = &stream->buffers()[buffer->index_];
}
return pipe_->queueRequest(this, request);
@@ -880,6 +853,13 @@ int Camera::start()
LOG(Camera, Debug) << "Starting capture";
for (Stream *stream : activeStreams_) {
if (allocator_ && !allocator_->buffers(stream).empty())
continue;
pipe_->importFrameBuffers(this, stream);
}
int ret = pipe_->start(this);
if (ret)
return ret;
@@ -915,6 +895,13 @@ int Camera::stop()
pipe_->stop(this);
for (Stream *stream : activeStreams_) {
if (allocator_ && !allocator_->buffers(stream).empty())
continue;
pipe_->freeFrameBuffers(this, stream);
}
return 0;
}
@@ -928,13 +915,6 @@ int Camera::stop()
*/
void Camera::requestComplete(Request *request)
{
for (auto it : request->buffers()) {
Stream *stream = it.first;
Buffer *buffer = it.second;
if (stream->memoryType() == ExternalMemory)
stream->unmapBuffer(buffer);
}
requestCompleted.emit(request);
delete request;
}