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:
+14
-34
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user