diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/android/camera_device.cpp | 11 | ||||
-rw-r--r-- | src/cam/capture.cpp | 8 | ||||
-rw-r--r-- | src/libcamera/camera.cpp | 100 | ||||
-rw-r--r-- | src/libcamera/framebuffer_allocator.cpp | 5 | ||||
-rw-r--r-- | src/qcam/main_window.cpp | 9 | ||||
-rw-r--r-- | src/v4l2/v4l2_camera.cpp | 5 |
6 files changed, 22 insertions, 116 deletions
diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 49321db0..a98fd744 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -77,8 +77,6 @@ int CameraDevice::open() void CameraDevice::close() { camera_->stop(); - - camera_->freeBuffers(); camera_->release(); running_ = false; @@ -690,16 +688,9 @@ void CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reque /* Start the camera if that's the first request we handle. */ if (!running_) { - int ret = camera_->allocateBuffers(); - if (ret) { - LOG(HAL, Error) << "Failed to allocate buffers"; - return; - } - - ret = camera_->start(); + int ret = camera_->start(); if (ret) { LOG(HAL, Error) << "Failed to start camera"; - camera_->freeBuffers(); return; } diff --git a/src/cam/capture.cpp b/src/cam/capture.cpp index 738fa1c2..7d970f99 100644 --- a/src/cam/capture.cpp +++ b/src/cam/capture.cpp @@ -42,12 +42,6 @@ int Capture::run(EventLoop *loop, const OptionsParser::Options &options) return ret; } - ret = camera_->allocateBuffers(); - if (ret) { - std::cerr << "Failed to allocate buffers" << std::endl; - return ret; - } - camera_->requestCompleted.connect(this, &Capture::requestComplete); if (options.isSet(OptFile)) { @@ -67,8 +61,6 @@ int Capture::run(EventLoop *loop, const OptionsParser::Options &options) writer_ = nullptr; } - camera_->freeBuffers(); - delete allocator; return ret; diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp index f3a7578d..79a5f994 100644 --- a/src/libcamera/camera.cpp +++ b/src/libcamera/camera.cpp @@ -275,15 +275,13 @@ std::size_t CameraConfiguration::size() const * \section camera_operation Operating the Camera * * An application needs to perform a sequence of operations on a camera before - * it is ready to process requests. The camera needs to be acquired, configured - * and resources allocated or imported to prepare the camera for capture. Once - * started the camera can process requests until it is stopped. When an - * application is done with a camera all resources allocated need to be freed - * and the camera released. + * it is ready to process requests. The camera needs to be acquired and + * configured to prepare the camera for capture. Once started the camera can + * process requests until it is stopped. When an application is done with a + * camera, the camera needs to be released. * * An application may start and stop a camera multiple times as long as it is - * not released. The camera may also be reconfigured provided that all - * resources allocated are freed prior to the reconfiguration. + * not released. The camera may also be reconfigured. * * \subsection Camera States * @@ -297,7 +295,6 @@ std::size_t CameraConfiguration::size() const * node [shape = doublecircle ]; Available; * node [shape = circle ]; Acquired; * node [shape = circle ]; Configured; - * node [shape = circle ]; Prepared; * node [shape = circle ]; Running; * * Available -> Available [label = "release()"]; @@ -307,14 +304,10 @@ std::size_t CameraConfiguration::size() const * Acquired -> Configured [label = "configure()"]; * * Configured -> Available [label = "release()"]; - * Configured -> Configured [label = "configure()"]; - * Configured -> Prepared [label = "allocateBuffers()"]; + * Configured -> Configured [label = "configure(), createRequest()"]; + * Configured -> Running [label = "start()"]; * - * Prepared -> Configured [label = "freeBuffers()"]; - * Prepared -> Prepared [label = "createRequest()"]; - * Prepared -> Running [label = "start()"]; - * - * Running -> Prepared [label = "stop()"]; + * Running -> Configured [label = "stop()"]; * Running -> Running [label = "createRequest(), queueRequest()"]; * } * \enddot @@ -330,19 +323,14 @@ std::size_t CameraConfiguration::size() const * Configured state. * * \subsubsection Configured - * The camera is configured and ready for the application to prepare it with - * resources. The camera may be reconfigured multiple times until resources - * are provided and the state progresses to Prepared. - * - * \subsubsection Prepared - * The camera has been configured and provided with resources and is ready to be - * started. The application may free the camera's resources to get back to the - * Configured state or start() it to progress to the Running state. + * The camera is configured and ready to be started. The application may + * release() the camera and to get back to the Available state or start() + * it to progress to the Running state. * * \subsubsection Running * The camera is running and ready to process requests queued by the * application. The camera remains in this state until it is stopped and moved - * to the Prepared state. + * to the Configured state. */ /** @@ -420,7 +408,6 @@ static const char *const camera_state_names[] = { "Available", "Acquired", "Configured", - "Prepared", "Running", }; @@ -465,8 +452,6 @@ bool Camera::stateIs(State state) const * * \todo Deal with pending requests if the camera is disconnected in a * running state. - * \todo Update comment about Running state when importing buffers as well as - * allocating them are supported. */ void Camera::disconnect() { @@ -474,11 +459,11 @@ void Camera::disconnect() /* * If the camera was running when the hardware was removed force the - * state to Prepared to allow applications to call freeBuffers() and - * release() before deleting the camera. + * state to Configured state to allow applications to free resources + * and call release() before deleting the camera. */ if (state_ == CameraRunning) - state_ = CameraPrepared; + state_ = CameraConfigured; disconnected_ = true; disconnected.emit(this); @@ -703,53 +688,6 @@ int Camera::configure(CameraConfiguration *config) } /** - * \brief Allocate buffers for all configured streams - * - * This function affects the state of the camera, see \ref camera_operation. - * - * \return 0 on success or a negative error code otherwise - * \retval -ENODEV The camera has been disconnected from the system - * \retval -EACCES The camera is not in a state where buffers can be allocated - * \retval -EINVAL The configuration is not valid - */ -int Camera::allocateBuffers() -{ - if (disconnected_) - return -ENODEV; - - if (!stateIs(CameraConfigured)) - return -EACCES; - - if (activeStreams_.empty()) { - LOG(Camera, Error) - << "Can't allocate buffers without streams"; - return -EINVAL; - } - - state_ = CameraPrepared; - - return 0; -} - -/** - * \brief Release all buffers from allocated pools in each stream - * - * This function affects the state of the camera, see \ref camera_operation. - * - * \return 0 on success or a negative error code otherwise - * \retval -EACCES The camera is not in a state where buffers can be freed - */ -int Camera::freeBuffers() -{ - if (!stateIs(CameraPrepared)) - return -EACCES; - - state_ = CameraConfigured; - - return 0; -} - -/** * \brief Create a request object for the camera * \param[in] cookie Opaque cookie for application use * @@ -764,14 +702,14 @@ int Camera::freeBuffers() * The ownership of the returned request is passed to the caller, which is * responsible for either queueing the request or deleting it. * - * This function shall only be called when the camera is in the Prepared + * This function shall only be called when the camera is in the Configured * or Running state, see \ref camera_operation. * * \return A pointer to the newly created request, or nullptr on error */ Request *Camera::createRequest(uint64_t cookie) { - if (disconnected_ || !stateBetween(CameraPrepared, CameraRunning)) + if (disconnected_ || !stateBetween(CameraConfigured, CameraRunning)) return nullptr; return new Request(this, cookie); @@ -842,7 +780,7 @@ int Camera::start() if (disconnected_) return -ENODEV; - if (!stateIs(CameraPrepared)) + if (!stateIs(CameraConfigured)) return -EACCES; LOG(Camera, Debug) << "Starting capture"; @@ -885,7 +823,7 @@ int Camera::stop() LOG(Camera, Debug) << "Stopping capture"; - state_ = CameraPrepared; + state_ = CameraConfigured; pipe_->stop(this); diff --git a/src/libcamera/framebuffer_allocator.cpp b/src/libcamera/framebuffer_allocator.cpp index 57789b24..207a13bd 100644 --- a/src/libcamera/framebuffer_allocator.cpp +++ b/src/libcamera/framebuffer_allocator.cpp @@ -116,8 +116,7 @@ FrameBufferAllocator::~FrameBufferAllocator() */ int FrameBufferAllocator::allocate(Stream *stream) { - if (camera_->state_ != Camera::CameraConfigured && - camera_->state_ != Camera::CameraPrepared) { + if (camera_->state_ != Camera::CameraConfigured) { LOG(Allocator, Error) << "Camera must be in the configured state to allocate buffers"; return -EACCES; @@ -163,7 +162,7 @@ int FrameBufferAllocator::allocate(Stream *stream) */ int FrameBufferAllocator::free(Stream *stream) { - if (camera_->state_ != Camera::CameraConfigured && camera_->state_ != Camera::CameraPrepared) { + if (camera_->state_ != Camera::CameraConfigured) { LOG(Allocator, Error) << "Camera must be in the configured state to free buffers"; return -EACCES; diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp index 047bf15e..1d9c756f 100644 --- a/src/qcam/main_window.cpp +++ b/src/qcam/main_window.cpp @@ -172,13 +172,6 @@ int MainWindow::startCapture() adjustSize(); - ret = camera_->allocateBuffers(); - if (ret) { - std::cerr << "Failed to allocate buffers" - << std::endl; - return ret; - } - ret = allocator_->allocate(stream); if (ret < 0) { std::cerr << "Failed to allocate capture buffers" << std::endl; @@ -244,7 +237,6 @@ error: } mappedBuffers_.clear(); - camera_->freeBuffers(); return ret; } @@ -264,7 +256,6 @@ void MainWindow::stopCapture() } mappedBuffers_.clear(); - camera_->freeBuffers(); isCapturing_ = false; config_.reset(); diff --git a/src/v4l2/v4l2_camera.cpp b/src/v4l2/v4l2_camera.cpp index 10db15d6..44cb4e7c 100644 --- a/src/v4l2/v4l2_camera.cpp +++ b/src/v4l2/v4l2_camera.cpp @@ -121,10 +121,6 @@ int V4L2Camera::configure(StreamConfiguration *streamConfigOut, int V4L2Camera::allocBuffers(unsigned int count) { - int ret = camera_->allocateBuffers(); - if (ret) - return ret == -EACCES ? -EBUSY : ret; - Stream *stream = *camera_->streams().begin(); return bufferAllocator_->allocate(stream); @@ -134,7 +130,6 @@ void V4L2Camera::freeBuffers() { Stream *stream = *camera_->streams().begin(); bufferAllocator_->free(stream); - camera_->freeBuffers(); } FileDescriptor V4L2Camera::getBufferFd(unsigned int index) |