summaryrefslogtreecommitdiff
path: root/src/libcamera/camera.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/libcamera/camera.cpp')
-rw-r--r--src/libcamera/camera.cpp48
1 files changed, 14 insertions, 34 deletions
diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp
index 20340167..3fe40feb 100644
--- a/src/libcamera/camera.cpp
+++ b/src/libcamera/camera.cpp
@@ -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;
}