{"id":12454,"url":"https://patchwork.libcamera.org/api/1.1/covers/12454/?format=json","web_url":"https://patchwork.libcamera.org/cover/12454/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/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":"<20210527220359.30127-1-jacopo@jmondi.org>","date":"2021-05-27T22:03:51","name":"[libcamera-devel,v4,0/8] Implement flush() camera operation","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/1.1/people/3/?format=json","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"mbox":"https://patchwork.libcamera.org/cover/12454/mbox/","series":[{"id":2088,"url":"https://patchwork.libcamera.org/api/1.1/series/2088/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2088","date":"2021-05-27T22:03:51","name":"Implement flush() camera operation","version":4,"mbox":"https://patchwork.libcamera.org/series/2088/mbox/"}],"comments":"https://patchwork.libcamera.org/api/covers/12454/comments/","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 3450BC3206\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 27 May 2021 22:03:21 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2DC726891D;\n\tFri, 28 May 2021 00:03:20 +0200 (CEST)","from relay10.mail.gandi.net (relay10.mail.gandi.net\n\t[217.70.178.230])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A989E602AE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 28 May 2021 00:03:18 +0200 (CEST)","(Authenticated sender: jacopo@jmondi.org)\n\tby relay10.mail.gandi.net (Postfix) with ESMTPSA id 040EB240008;\n\tThu, 27 May 2021 22:03:17 +0000 (UTC)"],"From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Fri, 28 May 2021 00:03:51 +0200","Message-Id":"<20210527220359.30127-1-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.31.1","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v4 0/8] Implement flush() camera operation","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":"To get to a successfull implementation of flush() a bit of preparatory work is\nrequired as currently Requests that fails to queue to the pipeline handler are\nnot returned to the application. Add Request::cancel() and call it in the\nPipelineHandler base class when calling queueRequestDevice() fails to allow\napplication to keep track of the queued requests.\n\nOn top of that, prepare the CameraDevice to support flush with a few clean-up\npatches, then implement the operation.\n\nNo regression detected when running CTS in LIMITED mode.\n\nTested with cros_camera_test:\n\n   # cros_camera_test --gtest_filter=\"Camera3FrameTest/Camera3FlushRequestsTest*\"\n   [==========] 12 tests from 1 test suite ran. (1380 ms total)\n   [  PASSED  ] 12 tests.\n\nAll patches reviewed but the last!\n\nThanks\n  j\n\nv3->v4:\n - [1/8] Set stream to nullptr when the error code does not require it\n - [1/8] Drop a useless error message\n - [2/8] Take in style suggestion from Laurent\n - [4/8] Use enum class CameraDevice::State\n - [8/8] Reimplement flush assuming it only races with processCaptureRequest\n\nv2->v3:\n - Request::cancel():\n   - Add tracepoint in request.tp\n   - Emitt Camera::bufferCompleted signal for each cancelled buffer\n   - Do not complete the Request\n\n - PipelineHandler\n   - Do not emit Camera::bufferCompleted as Request::cancel() does so\n   - Do not complete the request immediately but call\n     PipelineHandler::completeRequest()\n\n - Flush\n   - Use CameraMutex_ in place of FlushMutex_ to wait on the flushed_ condition\n     as suggested by Hiro. This guarantees that any access to the camera state\n     is protected by the same mutex and code is simplified.\n   - Assert that stop() does not get called while flushing as suggested by Hiro.\n\nv1->v2:\n - The majority of patches in the series have not been changed if not for\n   collecting tags. However 8/8 which implement the actual flush() has been\n   changed to address Hiro's comment about protecting close() and\n   configureStreams() from being concurrently run with flush().\n\n   - 8/8:\n     - Introduce a new flushed_ condition variable to be used by close() and\n       configureStreams() to be unlocked when flushing has terminated.\n\n- The patches that introduce Request::cancel() has pending discussion with\n  Hiro and Niklas. As they impact the libcamera API I'll wait for Laurent to\n  chime-in.\n\nJacopo Mondi (8):\n  android: Rework request completion notification\n  libcamera: request: Add Request::cancel()\n  libcamera: pipeline_handler: Cancel Request on queueing failure\n  android: camera_device: Replace running_ with CameraState\n  android: Replace scoped_lock<> with libcamera::MutexLocker\n  android: Guard access to the camera state\n  android: Rename CameraDevice::mutex_\n  android: Implement flush() camera operation\n\n .../libcamera/internal/tracepoints/request.tp |   8 +\n include/libcamera/request.h                   |   1 +\n src/android/camera_device.cpp                 | 236 +++++++++++++-----\n src/android/camera_device.h                   |  18 +-\n src/android/camera_ops.cpp                    |   8 +-\n src/libcamera/pipeline_handler.cpp            |   8 +-\n src/libcamera/request.cpp                     |  23 ++\n 7 files changed, 228 insertions(+), 74 deletions(-)\n\n--\n2.31.1"}