Patch Detail
Show a patch.
GET /api/patches/13873/?format=api
{ "id": 13873, "url": "https://patchwork.libcamera.org/api/patches/13873/?format=api", "web_url": "https://patchwork.libcamera.org/patch/13873/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20210920173752.1346190-10-umang.jain@ideasonboard.com>", "date": "2021-09-20T17:37:51", "name": "[libcamera-devel,v3,09/10] android: camera_device: Send capture results inspecting the descriptor", "commit_ref": null, "pull_url": null, "state": "rfc", "archived": false, "hash": "73b6604dca23aaa0b89b8e16ce77b6a5e589ee9f", "submitter": { "id": 86, "url": "https://patchwork.libcamera.org/api/people/86/?format=api", "name": "Umang Jain", "email": "umang.jain@ideasonboard.com" }, "delegate": { "id": 12, "url": "https://patchwork.libcamera.org/api/users/12/?format=api", "username": "uajain", "first_name": "Umang", "last_name": "Jain", "email": "umang.jain@ideasonboard.com" }, "mbox": "https://patchwork.libcamera.org/patch/13873/mbox/", "series": [ { "id": 2539, "url": "https://patchwork.libcamera.org/api/series/2539/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2539", "date": "2021-09-20T17:37:42", "name": "Async post processor", "version": 3, "mbox": "https://patchwork.libcamera.org/series/2539/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/13873/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/13873/checks/", "tags": {}, "headers": { "Return-Path": "<libcamera-devel-bounces@lists.libcamera.org>", "X-Original-To": "parsemail@patchwork.libcamera.org", "Delivered-To": "parsemail@patchwork.libcamera.org", "Received": [ "from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 7B01FBF01C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 20 Sep 2021 17:38:21 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3AE5269190;\n\tMon, 20 Sep 2021 19:38:21 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6034969199\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 20 Sep 2021 19:38:18 +0200 (CEST)", "from perceval.ideasonboard.com (unknown [103.251.226.144])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 5CB0A45E;\n\tMon, 20 Sep 2021 19:38:17 +0200 (CEST)" ], "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"IpDitSvj\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1632159498;\n\tbh=nLP58YsDKIF7yn5cRXa8rn+Hp3N35MqBoz+xB0SL5u4=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=IpDitSvjIrqDaAx6x+sPbd+loqW0s49XeQHxV6NKzKvvCtpmjOHuGigSaU25V3u18\n\ttnoBnRm0IW1oRRdPj2LpA/Dpwb//Vd3w4BFBgrlvBj/+3EGr1tK0/dHJfci28pL3OQ\n\t186V6JOxvq82pDdvyN/QbQV31iGxmqK3FkYc1xxs=", "From": "Umang Jain <umang.jain@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Mon, 20 Sep 2021 23:07:51 +0530", "Message-Id": "<20210920173752.1346190-10-umang.jain@ideasonboard.com>", "X-Mailer": "git-send-email 2.31.1", "In-Reply-To": "<20210920173752.1346190-1-umang.jain@ideasonboard.com>", "References": "<20210920173752.1346190-1-umang.jain@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v3 09/10] android: camera_device: Send\n\tcapture results inspecting the descriptor", "X-BeenThere": "libcamera-devel@lists.libcamera.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "<libcamera-devel.lists.libcamera.org>", "List-Unsubscribe": "<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>", "List-Archive": "<https://lists.libcamera.org/pipermail/libcamera-devel/>", "List-Post": "<mailto:libcamera-devel@lists.libcamera.org>", "List-Help": "<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>", "List-Subscribe": "<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "A Camera3RequestDescriptors is constructed and queued to descriptors_\nqueue as soon as an (incoming) capture request is received on the\nlibcamera HAL. The capture request is picked up by HAL, in order to run\nit to completion. At completion, CameraDevice::requestComplete() gets\ninvoked and capture results are populated and ready to be sent back\nto the framework.\n\nAll the data and framebuffers associated with the request are alive\nand encapsulated inside this Camera3RequestDescriptor descriptor.\nBy inspecting the ProcessStatus on the descriptor, we can now send\ncapture results via the process_capture_result() callback.\n\nHence, introduce a new private member function sendCaptureResults()\nwhich will be responsible to send capture results back to the\nframework by inspecting the descriptor on the queue. In subsequent\ncommit, when the post processsor shall run async, sendCaptureResults()\ncan be called from the post-processor's thread for e.g.\nstreamProcessComplete() hence, introduce the mutex lock to avoid the\nraces.\n\nSigned-off-by: Umang Jain <umang.jain@ideasonboard.com>\n---\n src/android/camera_device.cpp | 47 +++++++++++++++++++++++++----------\n src/android/camera_device.h | 4 +++\n 2 files changed, 38 insertions(+), 13 deletions(-)", "diff": "diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex 4658e881..16ecdfc5 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -1078,7 +1078,7 @@ void CameraDevice::requestComplete(Request *request)\n \t * The buffer status is set to OK and later changed to ERROR if\n \t * post-processing/compression fails.\n \t */\n-\tcamera3_capture_result_t captureResult = {};\n+\tcamera3_capture_result_t &captureResult = descriptor->captureResult_;\n \tcaptureResult.frame_number = descriptor->frameNumber_;\n \tcaptureResult.num_output_buffers = descriptor->buffers_.size();\n \tfor (camera3_stream_buffer_t &buffer : descriptor->buffers_) {\n@@ -1156,26 +1156,25 @@ void CameraDevice::requestComplete(Request *request)\n \t\t\tcontinue;\n \t\t}\n \n+\t\tif (cameraStream->type() == CameraStream::Type::Internal)\n+\t\t\tdescriptor->internalBuffer_ = src;\n+\n \t\tdescriptor->status_ = Camera3RequestDescriptor::ProcessStatus::Processing;\n \n \t\tcameraStream->process(src, *buffer.buffer, descriptor);\n-\n-\t\t/*\n-\t\t * Return the FrameBuffer to the CameraStream now that we're\n-\t\t * done processing it.\n-\t\t */\n-\t\tif (cameraStream->type() == CameraStream::Type::Internal)\n-\t\t\tcameraStream->putBuffer(src);\n+\t\treturn;\n \t}\n \n-\tcaptureResult.result = descriptor->resultMetadata_->get();\n-\tcallbacks_->process_capture_result(callbacks_, &captureResult);\n-\n-\tdescriptors_.pop_front();\n+\t/*\n+\t * Mark the status on the descriptor as success as no processing\n+\t * is neeeded.\n+\t */\n+\tdescriptor->status_ = Camera3RequestDescriptor::ProcessStatus::Success;\n+\tsendCaptureResults();\n }\n \n \n-void CameraDevice::streamProcessingComplete([[maybe_unused]] CameraStream *cameraStream,\n+void CameraDevice::streamProcessingComplete(CameraStream *cameraStream,\n \t\t\t\t\t Camera3RequestDescriptor *request)\n {\n \tif (request->status_ == Camera3RequestDescriptor::ProcessStatus::Error) {\n@@ -1190,6 +1189,28 @@ void CameraDevice::streamProcessingComplete([[maybe_unused]] CameraStream *camer\n \t\t\t\t CAMERA3_MSG_ERROR_BUFFER);\n \t\t}\n \t}\n+\n+\t/*\n+\t * Return the FrameBuffer to the CameraStream now that we're\n+\t * done processing it.\n+\t */\n+\tif (cameraStream->type() == CameraStream::Type::Internal)\n+\t\tcameraStream->putBuffer(request->internalBuffer_);\n+\n+\tsendCaptureResults();\n+}\n+\n+void CameraDevice::sendCaptureResults()\n+{\n+\tCamera3RequestDescriptor *d = descriptors_.front().get();\n+\tif (d->status_ == Camera3RequestDescriptor::ProcessStatus::Processing ||\n+\t d->status_ == Camera3RequestDescriptor::ProcessStatus::None)\n+\t\treturn;\n+\n+\tMutexLocker lock(descriptorsMutex_);\n+\td->captureResult_.result = d->resultMetadata_->get();\n+\tcallbacks_->process_capture_result(callbacks_, &(d->captureResult_));\n+\tdescriptors_.pop_front();\n }\n \n std::string CameraDevice::logPrefix() const\ndiff --git a/src/android/camera_device.h b/src/android/camera_device.h\nindex 60c134dc..0bd570a1 100644\n--- a/src/android/camera_device.h\n+++ b/src/android/camera_device.h\n@@ -56,6 +56,9 @@ struct Camera3RequestDescriptor {\n \tstd::unique_ptr<CaptureRequest> request_;\n \tstd::unique_ptr<CameraMetadata> resultMetadata_;\n \n+\tcamera3_capture_result_t captureResult_ = {};\n+\tlibcamera::FrameBuffer *internalBuffer_;\n+\n \tProcessStatus status_;\n };\n \n@@ -118,6 +121,7 @@ private:\n \tint processControls(Camera3RequestDescriptor *descriptor);\n \tstd::unique_ptr<CameraMetadata> getResultMetadata(\n \t\tconst Camera3RequestDescriptor *descriptor) const;\n+\tvoid sendCaptureResults();\n \n \tunsigned int id_;\n \tcamera3_device_t camera3Device_;\n", "prefixes": [ "libcamera-devel", "v3", "09/10" ] }