{"id":12351,"url":"https://patchwork.libcamera.org/api/1.1/covers/12351/?format=json","web_url":"https://patchwork.libcamera.org/cover/12351/","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":"<20210521154227.60186-1-jacopo@jmondi.org>","date":"2021-05-21T15:42:19","name":"[libcamera-devel,v3,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/12351/mbox/","series":[{"id":2045,"url":"https://patchwork.libcamera.org/api/1.1/series/2045/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2045","date":"2021-05-21T15:42:19","name":"Implement flush() camera operation","version":3,"mbox":"https://patchwork.libcamera.org/series/2045/mbox/"}],"comments":"https://patchwork.libcamera.org/api/covers/12351/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 7099EC31FF\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 21 May 2021 15:41:48 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A0C7A6891F;\n\tFri, 21 May 2021 17:41:47 +0200 (CEST)","from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net\n\t[217.70.183.201])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 30E246891A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 21 May 2021 17:41:46 +0200 (CEST)","(Authenticated sender: jacopo@jmondi.org)\n\tby relay8-d.mail.gandi.net (Postfix) with ESMTPSA id AEFE31BF20A;\n\tFri, 21 May 2021 15:41:45 +0000 (UTC)"],"From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Fri, 21 May 2021 17:42:19 +0200","Message-Id":"<20210521154227.60186-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 v3 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":"Implement the flush() camera operation in Android CameraDevice class.\n\nThe series includes the already sent\n\"android: Rework request completion notification\" patch slightly modified:\n\n- set partial_results = 0 in case of error (as reported by cros_camera_test)\n- on fatal ERROR_DEVICE notify() to the framework first then call Fatal. Record\n  with a \\todo the on-going discussion on the requirement to close the camera\n  to handle failures gracefully.\n\nTo 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\nThanks\n   j\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                 | 260 +++++++++++++-----\n src/android/camera_device.h                   |  20 +-\n src/android/camera_ops.cpp                    |   8 +-\n src/libcamera/pipeline_handler.cpp            |   8 +-\n src/libcamera/request.cpp                     |  28 ++\n 7 files changed, 256 insertions(+), 77 deletions(-)\n\n--\n2.31.1"}