Patch Detail
Show a patch.
GET /api/1.1/patches/11842/?format=api
{ "id": 11842, "url": "https://patchwork.libcamera.org/api/1.1/patches/11842/?format=api", "web_url": "https://patchwork.libcamera.org/patch/11842/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/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": "<20210406091334.3823748-1-hiroh@chromium.org>", "date": "2021-04-06T09:13:34", "name": "[libcamera-devel] android: Implement flush()", "commit_ref": null, "pull_url": null, "state": "changes-requested", "archived": false, "hash": "038fbde3bb482df6df2d27262e6aba394b582651", "submitter": { "id": 63, "url": "https://patchwork.libcamera.org/api/1.1/people/63/?format=api", "name": "Hirokazu Honda", "email": "hiroh@chromium.org" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/11842/mbox/", "series": [ { "id": 1894, "url": "https://patchwork.libcamera.org/api/1.1/series/1894/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1894", "date": "2021-04-06T09:13:34", "name": "[libcamera-devel] android: Implement flush()", "version": 1, "mbox": "https://patchwork.libcamera.org/series/1894/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/11842/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/11842/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 AC484BD695\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 6 Apr 2021 09:13:43 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2288160517;\n\tTue, 6 Apr 2021 11:13:43 +0200 (CEST)", "from mail-pl1-x633.google.com (mail-pl1-x633.google.com\n\t[IPv6:2607:f8b0:4864:20::633])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E2CD860517\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 6 Apr 2021 11:13:41 +0200 (CEST)", "by mail-pl1-x633.google.com with SMTP id a6so3802955pls.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 06 Apr 2021 02:13:41 -0700 (PDT)", "from hiroh2.tok.corp.google.com\n\t([2401:fa00:8f:2:4180:40db:6f79:a143])\n\tby smtp.gmail.com with ESMTPSA id\n\tt1sm1880124pjo.45.2021.04.06.02.13.39\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 06 Apr 2021 02:13:39 -0700 (PDT)" ], "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"cF7i8yVu\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; h=from:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding;\n\tbh=0Bfvx94STaPlZ4O7KYc37woJ/yIFoNmkTlkh+7RzEOE=;\n\tb=cF7i8yVuiAL9b7RangQmjWGiy4DqEwRanXd7UVuv9GPPUq6UkjP4RpoZqJHQt9Coqo\n\t/bQXsovk5WvE1XkxdB/zK+vZq80Z76wNcNk6W1s712NoZoqL+qzZjg038dwSLd9MOSeU\n\tSBrOuKszzH8b3Yq2YsRIvQQnc2EYFkkvyD/4M=", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding;\n\tbh=0Bfvx94STaPlZ4O7KYc37woJ/yIFoNmkTlkh+7RzEOE=;\n\tb=rCng95Hoh1t3XkMVBjLIB+/a3+PtdmIGhcYMKwF5+5W/yhjFfxQc9Ykd3WJfFdUL5a\n\tk/x3W8zKuVeL6ox4Pntic9ipVaSg4vT89Rbxhm1NI/k1DPMwpa0L7tdV6fMTe+Pfg7l6\n\tf70P9Nv7G0h50nmG8dXjLkcgc9IcrguFXt3S5SqhYcPgfMW4W62fq6L0fNsoRz678wpl\n\tjqSvlLbEqI2r7RT4qb+VK7Z8xMhyLUwOk6iT0FOHNJCOk0FeiMWWod1o3Qa0bgBM6Rfk\n\tgtWCv/BZTPkG/WiymAlikYp1kPcUL4AwEbMvHPai9QE/NrhyVkvMcwnvi3BLWIWt6Zwi\n\tZ2uw==", "X-Gm-Message-State": "AOAM531MSfnUja2AwBhM6HcQiZWe6yTg3Y+OF/n/gXkfSOUTP0xL8nag\n\t1vgxOuWkxlKG2mVg975YGnk0CrC73snyKQ==", "X-Google-Smtp-Source": "ABdhPJwC+mw2wxkcwhoKgS6vY2mHebC48pbbSwjeTB0ydLmnc/bJdMs3IOHaGiQCrwB2CgYI+KPj+g==", "X-Received": "by 2002:a17:90a:8c06:: with SMTP id\n\ta6mr3418624pjo.106.1617700420264; \n\tTue, 06 Apr 2021 02:13:40 -0700 (PDT)", "From": "Hirokazu Honda <hiroh@chromium.org>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Tue, 6 Apr 2021 18:13:34 +0900", "Message-Id": "<20210406091334.3823748-1-hiroh@chromium.org>", "X-Mailer": "git-send-email 2.31.0.208.g409f899ff0-goog", "MIME-Version": "1.0", "Subject": "[libcamera-devel] [PATCH] android: Implement flush()", "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>", "Content-Type": "text/plain; charset=\"us-ascii\"", "Content-Transfer-Encoding": "7bit", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "This implements camera3_device_ops::flush().\n\nSigned-off-by: Hirokazu Honda <hiroh@chromium.org>\n---\n src/android/camera_device.cpp | 48 +++++++++++++++++++++++++++++++----\n src/android/camera_device.h | 3 +++\n src/android/camera_ops.cpp | 3 ++-\n 3 files changed, 48 insertions(+), 6 deletions(-)", "diff": "diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex 4a3f6f8e..5a56fe4b 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -2029,20 +2029,22 @@ void CameraDevice::requestComplete(Request *request)\n \tcamera3_buffer_status status = CAMERA3_BUFFER_STATUS_OK;\n \tstd::unique_ptr<CameraMetadata> resultMetadata;\n \n-\tdecltype(descriptors_)::node_type node;\n+\tCamera3RequestDescriptor descriptor;\n \t{\n \t\tstd::scoped_lock<std::mutex> lock(mutex_);\n \t\tauto it = descriptors_.find(request->cookie());\n \t\tif (it == descriptors_.end()) {\n \t\t\tLOG(HAL, Fatal)\n \t\t\t\t<< \"Unknown request: \" << request->cookie();\n-\t\t\tstatus = CAMERA3_BUFFER_STATUS_ERROR;\n \t\t\treturn;\n \t\t}\n \n-\t\tnode = descriptors_.extract(it);\n+\t\tdescriptor = std::move(it->second);\n+\t\t/* Restore frameNumber_ because it is used in the case of flush\n+\t\t * timeout case.\n+\t\t */\n+\t\tit->second.frameNumber_ = descriptor.frameNumber_;\n \t}\n-\tCamera3RequestDescriptor &descriptor = node.mapped();\n \n \tif (request->status() != Request::RequestComplete) {\n \t\tLOG(HAL, Error) << \"Request not successfully completed: \"\n@@ -2122,7 +2124,43 @@ void CameraDevice::requestComplete(Request *request)\n \t\t\t descriptor.buffers_[0].stream);\n \t}\n \n-\tcallbacks_->process_capture_result(callbacks_, &captureResult);\n+\t{\n+\t\tstd::scoped_lock<std::mutex> lock(mutex_);\n+\t\tif (descriptors_.erase(request->cookie()) == 0) {\n+\t\t\t// flush() cleans up the descriptor due to time out\n+\t\t\t// during a post processing.\n+\t\t\treturn;\n+\t\t}\n+\t\tcallbacks_->process_capture_result(callbacks_, &captureResult);\n+\t\tconditionVariable_.notify_one();\n+\t}\n+}\n+\n+int CameraDevice::flush()\n+{\n+\tstd::unique_lock<std::mutex> lock(mutex_);\n+\t/* flush() should return in less than one second. Sets the timeout to 900ms. */\n+\tauto flushTimeout =\n+\t\tstd::chrono::system_clock::now() + std::chrono::milliseconds(900);\n+\tbool completeAllRequests = conditionVariable_.wait_until(\n+\t\tlock, flushTimeout, [this]() { return descriptors_.empty(); });\n+\n+\tif (!completeAllRequests) {\n+\t\tfor (auto &node : descriptors_) {\n+\t\t\tauto &descriptor = node.second;\n+\t\t\tcamera3_capture_result_t captureResult{};\n+\t\t\tcaptureResult.frame_number = descriptor.frameNumber_;\n+\t\t\tfor (camera3_stream_buffer_t &buffer : descriptor.buffers_) {\n+\t\t\t\tbuffer.acquire_fence = -1;\n+\t\t\t\tbuffer.release_fence = -1;\n+\t\t\t\tbuffer.status = CAMERA3_BUFFER_STATUS_ERROR;\n+\t\t\t}\n+\t\t\tcallbacks_->process_capture_result(callbacks_, &captureResult);\n+\t\t}\n+\t\tdescriptors_.clear();\n+\t}\n+\n+\treturn 0;\n }\n \n std::string CameraDevice::logPrefix() const\ndiff --git a/src/android/camera_device.h b/src/android/camera_device.h\nindex c63e8e21..dd5336ee 100644\n--- a/src/android/camera_device.h\n+++ b/src/android/camera_device.h\n@@ -7,6 +7,7 @@\n #ifndef __ANDROID_CAMERA_DEVICE_H__\n #define __ANDROID_CAMERA_DEVICE_H__\n \n+#include <condition_variable>\n #include <map>\n #include <memory>\n #include <mutex>\n@@ -62,6 +63,7 @@ public:\n \tint configureStreams(camera3_stream_configuration_t *stream_list);\n \tint processCaptureRequest(camera3_capture_request_t *request);\n \tvoid requestComplete(libcamera::Request *request);\n+\tint flush();\n \n protected:\n \tstd::string logPrefix() const override;\n@@ -128,6 +130,7 @@ private:\n \tstd::vector<CameraStream> streams_;\n \n \tstd::mutex mutex_; /* Protect descriptors_ */\n+\tstd::condition_variable conditionVariable_;\n \tstd::map<uint64_t, Camera3RequestDescriptor> descriptors_;\n \n \tstd::string maker_;\ndiff --git a/src/android/camera_ops.cpp b/src/android/camera_ops.cpp\nindex 696e8043..1b73af13 100644\n--- a/src/android/camera_ops.cpp\n+++ b/src/android/camera_ops.cpp\n@@ -68,7 +68,8 @@ static void hal_dev_dump([[maybe_unused]] const struct camera3_device *dev,\n \n static int hal_dev_flush([[maybe_unused]] const struct camera3_device *dev)\n {\n-\treturn 0;\n+\tCameraDevice *camera = reinterpret_cast<CameraDevice *>(dev->priv);\n+\treturn camera->flush();\n }\n \n int hal_dev_close(hw_device_t *hw_device)\n", "prefixes": [ "libcamera-devel" ] }