From patchwork Mon Dec 21 23:53:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 10691 X-Patchwork-Delegate: niklas.soderlund@ragnatech.se Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id CF08BC0F1A for ; Mon, 21 Dec 2020 23:54:05 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A71A0615D5; Tue, 22 Dec 2020 00:54:05 +0100 (CET) Received: from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net [195.74.38.227]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B4EB76159A for ; Tue, 22 Dec 2020 00:54:03 +0100 (CET) X-Halon-ID: cc7ee80e-43e7-11eb-a076-005056917f90 Authorized-sender: niklas.soderlund@fsdn.se Received: from wyvern.dyn.berto.se (h-209-203.a463.priv.bahnhof.se [155.4.209.203]) by bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA id cc7ee80e-43e7-11eb-a076-005056917f90; Tue, 22 Dec 2020 00:54:01 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Tue, 22 Dec 2020 00:53:44 +0100 Message-Id: <20201221235345.1965878-2-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201221235345.1965878-1-niklas.soderlund@ragnatech.se> References: <20201221235345.1965878-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 1/2] libcamera: pipeline_handler: Remove Camera argument from request handling X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" There is no need to pass the Camera pointer to queueRequest(), completeBuffer() and completeRequest() as the Request also passed contains the same information. Remove the Camera argument to avoid situations where the information in the Request and the argument differ. There is no functional change and no public API change as the interface is only used between the Camera and PipelineHandler. Signed-off-by: Niklas Söderlund Reviewed-by: Kieran Bingham Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- Documentation/guides/pipeline-handler.rst | 4 ++-- include/libcamera/internal/pipeline_handler.h | 7 +++---- src/libcamera/camera.cpp | 2 +- src/libcamera/pipeline/ipu3/ipu3.cpp | 8 ++++---- .../pipeline/raspberrypi/raspberrypi.cpp | 8 ++++---- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 5 ++--- src/libcamera/pipeline/simple/simple.cpp | 12 ++++++------ src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 4 ++-- src/libcamera/pipeline/vimc/vimc.cpp | 4 ++-- src/libcamera/pipeline_handler.cpp | 16 ++++++++-------- 10 files changed, 34 insertions(+), 36 deletions(-) diff --git a/Documentation/guides/pipeline-handler.rst b/Documentation/guides/pipeline-handler.rst index 63275a12e81bcd08..f4a31d3c9588f890 100644 --- a/Documentation/guides/pipeline-handler.rst +++ b/Documentation/guides/pipeline-handler.rst @@ -1421,8 +1421,8 @@ code-base. { Request *request = buffer->request(); - pipe_->completeBuffer(camera_, request, buffer); - pipe_->completeRequest(camera_, request); + pipe_->completeBuffer(request, buffer); + pipe_->completeRequest(request); } Testing a pipeline handler diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h index bd3c4a81d6389db6..5f9a26be1f7a9e9e 100644 --- a/include/libcamera/internal/pipeline_handler.h +++ b/include/libcamera/internal/pipeline_handler.h @@ -81,11 +81,10 @@ public: virtual int start(Camera *camera, ControlList *controls) = 0; virtual void stop(Camera *camera) = 0; - int queueRequest(Camera *camera, Request *request); + int queueRequest(Request *request); - bool completeBuffer(Camera *camera, Request *request, - FrameBuffer *buffer); - void completeRequest(Camera *camera, Request *request); + bool completeBuffer(Request *request, FrameBuffer *buffer); + void completeRequest(Request *request); const char *name() const { return name_; } diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp index c1de1fee701a3240..d9b817871cbf5b85 100644 --- a/src/libcamera/camera.cpp +++ b/src/libcamera/camera.cpp @@ -997,7 +997,7 @@ int Camera::queueRequest(Request *request) } return d->pipe_->invokeMethod(&PipelineHandler::queueRequest, - ConnectionTypeQueued, this, request); + ConnectionTypeQueued, request); } /** diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 8a1918d5e4c5b815..f1151733d9fe81ff 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -836,13 +836,13 @@ void IPU3CameraData::imguOutputBufferReady(FrameBuffer *buffer) { Request *request = buffer->request(); - if (!pipe_->completeBuffer(camera_, request, buffer)) + if (!pipe_->completeBuffer(request, buffer)) /* Request not completed yet, return here. */ return; /* Mark the request as complete. */ request->metadata().set(controls::draft::PipelineDepth, 3); - pipe_->completeRequest(camera_, request); + pipe_->completeRequest(request); } /** @@ -865,10 +865,10 @@ void IPU3CameraData::cio2BufferReady(FrameBuffer *buffer) * now as there's no need for ImgU processing. */ if (request->findBuffer(&rawStream_)) { - bool isComplete = pipe_->completeBuffer(camera_, request, buffer); + bool isComplete = pipe_->completeBuffer(request, buffer); if (isComplete) { request->metadata().set(controls::draft::PipelineDepth, 2); - pipe_->completeRequest(camera_, request); + pipe_->completeRequest(request); return; } } diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 7a5f5881b9b30129..f121328ee9a9b6f2 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1507,10 +1507,10 @@ void RPiCameraData::clearIncompleteRequests() * request? If not, do so now. */ if (buffer && buffer->request()) - pipe_->completeBuffer(camera_, request, buffer); + pipe_->completeBuffer(request, buffer); } - pipe_->completeRequest(camera_, request); + pipe_->completeRequest(request); requestQueue_.pop_front(); } } @@ -1534,7 +1534,7 @@ void RPiCameraData::handleStreamBuffer(FrameBuffer *buffer, RPi::Stream *stream) * Tag the buffer as completed, returning it to the * application. */ - pipe_->completeBuffer(camera_, request, buffer); + pipe_->completeBuffer(request, buffer); } else { /* * This buffer was not part of the Request, or there is no @@ -1597,7 +1597,7 @@ void RPiCameraData::checkRequestCompleted() if (state_ != State::IpaComplete) return; - pipe_->completeRequest(camera_, request); + pipe_->completeRequest(request); requestQueue_.pop_front(); requestCompleted = true; } diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 021d0ffe3ffb39ed..5ce37febc1d7c11c 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -1135,15 +1135,14 @@ void PipelineHandlerRkISP1::tryCompleteRequest(Request *request) data->frameInfo_.destroy(info->frame); - completeRequest(activeCamera_, request); + completeRequest(request); } void PipelineHandlerRkISP1::bufferReady(FrameBuffer *buffer) { - ASSERT(activeCamera_); Request *request = buffer->request(); - completeBuffer(activeCamera_, request, buffer); + completeBuffer(request, buffer); tryCompleteRequest(request); } diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index b719171ab6d1a0be..6eb9ab0ce6ecd60a 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -899,8 +899,8 @@ void SimplePipelineHandler::bufferReady(FrameBuffer *buffer) } Request *request = buffer->request(); - completeBuffer(activeCamera_, request, buffer); - completeRequest(activeCamera_, request); + completeBuffer(request, buffer); + completeRequest(request); return; } @@ -924,8 +924,8 @@ void SimplePipelineHandler::bufferReady(FrameBuffer *buffer) /* Otherwise simply complete the request. */ Request *request = buffer->request(); - completeBuffer(activeCamera_, request, buffer); - completeRequest(activeCamera_, request); + completeBuffer(request, buffer); + completeRequest(request); } void SimplePipelineHandler::converterDone(FrameBuffer *input, @@ -936,8 +936,8 @@ void SimplePipelineHandler::converterDone(FrameBuffer *input, /* Complete the request. */ Request *request = output->request(); - completeBuffer(activeCamera_, request, output); - completeRequest(activeCamera_, request); + completeBuffer(request, output); + completeRequest(request); /* Queue the input buffer back for capture. */ data->video_->queueBuffer(input); diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp index e54f45bb8825f11f..7cb310e205114333 100644 --- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp @@ -646,8 +646,8 @@ void UVCCameraData::bufferReady(FrameBuffer *buffer) { Request *request = buffer->request(); - pipe_->completeBuffer(camera_, request, buffer); - pipe_->completeRequest(camera_, request); + pipe_->completeBuffer(request, buffer); + pipe_->completeRequest(request); } REGISTER_PIPELINE_HANDLER(PipelineHandlerUVC) diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp index 8bda746f3136427c..36325ffbbd7d01cc 100644 --- a/src/libcamera/pipeline/vimc/vimc.cpp +++ b/src/libcamera/pipeline/vimc/vimc.cpp @@ -519,8 +519,8 @@ void VimcCameraData::bufferReady(FrameBuffer *buffer) { Request *request = buffer->request(); - pipe_->completeBuffer(camera_, request, buffer); - pipe_->completeRequest(camera_, request); + pipe_->completeBuffer(request, buffer); + pipe_->completeRequest(request); } REGISTER_PIPELINE_HANDLER(PipelineHandlerVimc) diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp index c75ebbd5a443cb87..26d6c07d2d6e69e9 100644 --- a/src/libcamera/pipeline_handler.cpp +++ b/src/libcamera/pipeline_handler.cpp @@ -376,8 +376,7 @@ const ControlList &PipelineHandler::properties(const Camera *camera) const /** * \fn PipelineHandler::queueRequest() - * \brief Queue a request to the camera - * \param[in] camera The camera to queue the request to + * \brief Queue a request * \param[in] request The request to queue * * This method queues a capture request to the pipeline handler for processing. @@ -392,8 +391,9 @@ const ControlList &PipelineHandler::properties(const Camera *camera) const * * \return 0 on success or a negative error code otherwise */ -int PipelineHandler::queueRequest(Camera *camera, Request *request) +int PipelineHandler::queueRequest(Request *request) { + Camera *camera = request->camera_; CameraData *data = cameraData(camera); data->queuedRequests_.push_back(request); @@ -423,7 +423,6 @@ int PipelineHandler::queueRequest(Camera *camera, Request *request) /** * \brief Complete a buffer for a request - * \param[in] camera The camera the request belongs to * \param[in] request The request the buffer belongs to * \param[in] buffer The buffer that has completed * @@ -439,16 +438,15 @@ int PipelineHandler::queueRequest(Camera *camera, Request *request) * \return True if all buffers contained in the request have completed, false * otherwise */ -bool PipelineHandler::completeBuffer(Camera *camera, Request *request, - FrameBuffer *buffer) +bool PipelineHandler::completeBuffer(Request *request, FrameBuffer *buffer) { + Camera *camera = request->camera_; camera->bufferCompleted.emit(request, buffer); return request->completeBuffer(buffer); } /** * \brief Signal request completion - * \param[in] camera The camera that the request belongs to * \param[in] request The request that has completed * * The pipeline handler shall call this method to notify the \a camera that the @@ -461,8 +459,10 @@ bool PipelineHandler::completeBuffer(Camera *camera, Request *request, * * \context This function shall be called from the CameraManager thread. */ -void PipelineHandler::completeRequest(Camera *camera, Request *request) +void PipelineHandler::completeRequest(Request *request) { + Camera *camera = request->camera_; + request->complete(); CameraData *data = cameraData(camera);