{"id":12092,"url":"https://patchwork.libcamera.org/api/patches/12092/?format=json","web_url":"https://patchwork.libcamera.org/patch/12092/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20210423040738.1227220-3-hiroh@chromium.org>","date":"2021-04-23T04:07:38","name":"[libcamera-devel,v2,2/2] android: CameraDevice: Implement HAL3 API flush","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"e3c281a6c78975bfb97bc2ef4a680fd7f91bbca1","submitter":{"id":63,"url":"https://patchwork.libcamera.org/api/people/63/?format=json","name":"Hirokazu Honda","email":"hiroh@chromium.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/12092/mbox/","series":[{"id":1968,"url":"https://patchwork.libcamera.org/api/series/1968/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1968","date":"2021-04-23T04:07:36","name":"Support HAL3 API flush","version":2,"mbox":"https://patchwork.libcamera.org/series/1968/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/12092/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/12092/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 02BA5BDB15\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 23 Apr 2021 04:07:52 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B4CA368872;\n\tFri, 23 Apr 2021 06:07:51 +0200 (CEST)","from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com\n\t[IPv6:2607:f8b0:4864:20::1032])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3D42468861\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 23 Apr 2021 06:07:48 +0200 (CEST)","by mail-pj1-x1032.google.com with SMTP id\n\tf6-20020a17090a6546b029015088cf4a1eso549347pjs.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 22 Apr 2021 21:07:48 -0700 (PDT)","from hiroh2.tok.corp.google.com\n\t([2401:fa00:8f:2:8537:2d4f:8d35:5777])\n\tby smtp.gmail.com with ESMTPSA id\n\tj23sm3229670pfh.179.2021.04.22.21.07.45\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 22 Apr 2021 21:07:46 -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=\"fj2iZxD+\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=aYyEl85BGRXcwUXnJTysQs2J8kpH0ejwtwgIxJEe4R0=;\n\tb=fj2iZxD+b/Zg1Xpmuc3liLpcPsT0rti+ts1MUZHHJVM6xZshVSK8eSLbK6+Dftyavc\n\t2VD3nBgc4on801FcEbZvcxOJfj5DDRShDOHI4BIpa3qOtnQPTQv5es+SL2NCCLQEMZ2f\n\tMoAAf8VjyrEsGWRNjbKBz5ZDN/4yxm/IGzpXI=","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:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=aYyEl85BGRXcwUXnJTysQs2J8kpH0ejwtwgIxJEe4R0=;\n\tb=Hi6aIf6O9wDhuSNYmeiuK8jWX3BAhuqaGUpVIw6iZPBemOC8FPYbS8XVvpDlAH70ho\n\tkf1AwxW0AUlaAMogckl68PnRxIMopFFsN1GTebgH8kR7YLGcQelMNaUHNJdJsn09mhyy\n\tAR1/PE9VRXYqgLTkRi+8xh9ubtOLSByLqjsj7v4ZnaegwlM/0gh9ZXk1aq3cGGmiZrCT\n\tjHKSEUXwi8L/b2PeQMzayXLWkywqhXJRpx0L+chrIeCyQ1wX812rLdD41ZSvqXbLmp72\n\t73pG7MGpBU0BN6ZmPCJt2SmDZ2M0e+BzkHrrzL+pL0CZ/s1hYr6fUnce2vwGYYdDURqX\n\t/bnQ==","X-Gm-Message-State":"AOAM532kpwVozRaRBa1v00mZ509br/Dyg+dIkWWdIamfaj59OuQLdR56\n\tg8bOvgLP9XxKJ+L25E7NkTjnQ4PKaT4h+A==","X-Google-Smtp-Source":"ABdhPJxb2QjyiY0it+Kbs2QjO7c40eJ64FNnzhiqyaymh4/zu+0mfwUfe41rquXdoxv1WNUzH3qs4Q==","X-Received":"by 2002:a17:90a:a613:: with SMTP id\n\tc19mr3579691pjq.117.1619150866680; \n\tThu, 22 Apr 2021 21:07:46 -0700 (PDT)","From":"Hirokazu Honda <hiroh@chromium.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Fri, 23 Apr 2021 13:07:38 +0900","Message-Id":"<20210423040738.1227220-3-hiroh@chromium.org>","X-Mailer":"git-send-email 2.31.1.498.g6c1eba8ee3d-goog","In-Reply-To":"<20210423040738.1227220-1-hiroh@chromium.org>","References":"<20210423040738.1227220-1-hiroh@chromium.org>","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH v2 2/2] android: CameraDevice: Implement\n\tHAL3 API 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 flush(). It is mostly the same as close()\nthough the canceled events are reported with error messages.\n\nSigned-off-by: Hirokazu Honda <hiroh@chromium.org>\n---\n src/android/camera_device.cpp | 41 +++++++++++++++++++++++++++++------\n src/android/camera_device.h   |  1 +\n src/android/camera_ops.cpp    |  6 ++++-\n 3 files changed, 40 insertions(+), 8 deletions(-)","diff":"diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex c74dc0e7..22a2e13c 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -753,6 +753,15 @@ void CameraDevice::close()\n \tstop(/*releaseCamera=*/true);\n }\n \n+int CameraDevice::flush()\n+{\n+\tstd::scoped_lock<std::mutex> lock(mutex_);\n+\n+\tstop();\n+\n+\treturn 0;\n+}\n+\n void CameraDevice::stop(bool releaseCamera)\n {\n \tstreams_.clear();\n@@ -770,6 +779,23 @@ void CameraDevice::stop(bool releaseCamera)\n \tworker_.stop();\n \tcamera_->stop();\n \n+\tfor (auto &[cookie, descriptor] : descriptors_) {\n+\t\tLOG(HAL, Debug) << \"request is canceled: \" << cookie;\n+\n+\t\tcamera3_capture_result_t captureResult = {};\n+\t\tcaptureResult.frame_number = descriptor.frameNumber_;\n+\t\tcaptureResult.num_output_buffers = descriptor.buffers_.size();\n+\t\tfor (camera3_stream_buffer_t &buffer : descriptor.buffers_) {\n+\t\t\tbuffer.acquire_fence = -1;\n+\t\t\tbuffer.release_fence = -1;\n+\t\t\tbuffer.status = CAMERA3_BUFFER_STATUS_ERROR;\n+\t\t}\n+\t\tcaptureResult.output_buffers = descriptor.buffers_.data();\n+\n+\t\tnotifyError(descriptor.frameNumber_,\n+\t\t\t    descriptor.buffers_[0].stream);\n+\t\tcallbacks_->process_capture_result(callbacks_, &captureResult);\n+\t}\n \tdescriptors_.clear();\n \n \trunning_ = false;\n@@ -2128,6 +2154,14 @@ void CameraDevice::requestComplete(Request *request)\n \t}\n \n \tif (status == CAMERA3_BUFFER_STATUS_ERROR || !captureResult.result) {\n+\t\t/*\n+\t\t * \\todo Report and identify the stream number or configuration\n+\t\t * to clarify the stream that failed.\n+\t\t */\n+\t\tLOG(HAL, Error)\n+\t\t\t<< \"Error occurred on frame \" << descriptor.frameNumber_ << \" (\"\n+\t\t\t<< toPixelFormat(descriptor.buffers_[0].stream->format).toString() << \")\";\n+\n \t\t/* \\todo Improve error handling. In case we notify an error\n \t\t * because the metadata generation fails, a shutter event has\n \t\t * already been notified for this frame number before the error\n@@ -2161,13 +2195,6 @@ void CameraDevice::notifyError(uint32_t frameNumber, camera3_stream_t *stream)\n {\n \tcamera3_notify_msg_t notify = {};\n \n-\t/*\n-\t * \\todo Report and identify the stream number or configuration to\n-\t * clarify the stream that failed.\n-\t */\n-\tLOG(HAL, Error) << \"Error occurred on frame \" << frameNumber << \" (\"\n-\t\t\t<< toPixelFormat(stream->format).toString() << \")\";\n-\n \tnotify.type = CAMERA3_MSG_ERROR;\n \tnotify.message.error.error_stream = stream;\n \tnotify.message.error.frame_number = frameNumber;\ndiff --git a/src/android/camera_device.h b/src/android/camera_device.h\nindex 08553584..7004c89a 100644\n--- a/src/android/camera_device.h\n+++ b/src/android/camera_device.h\n@@ -41,6 +41,7 @@ public:\n \n \tint open(const hw_module_t *hardwareModule);\n \tvoid close();\n+\tint flush();\n \n \tunsigned int id() const { return id_; }\n \tcamera3_device_t *camera3Device() { return &camera3Device_; }\ndiff --git a/src/android/camera_ops.cpp b/src/android/camera_ops.cpp\nindex 696e8043..981a3d30 100644\n--- a/src/android/camera_ops.cpp\n+++ b/src/android/camera_ops.cpp\n@@ -68,7 +68,11 @@ 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+\tif (!dev)\n+\t\treturn -EINVAL;\n+\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","v2","2/2"]}