From patchwork Tue Jun 8 15:16:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 12522 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id E09ACC3206 for ; Tue, 8 Jun 2021 15:15:48 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 571116892E; Tue, 8 Jun 2021 17:15:48 +0200 (CEST) Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id AFF37602A0 for ; Tue, 8 Jun 2021 17:15:47 +0200 (CEST) Received: (Authenticated sender: jacopo@jmondi.org) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 16F886001B; Tue, 8 Jun 2021 15:15:46 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Tue, 8 Jun 2021 17:16:25 +0200 Message-Id: <20210608151633.73465-1-jacopo@jmondi.org> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 0/8] Implement flush() camera operation X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Implement the flush() camera operation in Android CameraDevice class. To get to a successfull implementation of flush() a bit of preparatory work is required as currently Requests that fails to queue to the pipeline handler are not returned to the application. Add Request::cancel() and call it in the PipelineHandler base class when calling queueRequestDevice() fails to allow application to keep track of the queued requests. On top of that, prepare the CameraDevice to support flush with a few clean-up patches, then implement the operation. Tested with CTS in LIMITED mode - No subplan =============== Summary =============== Total Run time: 22m 22s 1/1 modules completed Total Tests : 253 PASSED : 233 FAILED : 20 ============== End of Results ============== android.hardware.camera2.cts.ImageReaderTest#testAllOutputYUVResolutions android.hardware.camera2.cts.ImageReaderTest#testRawPrivate android.hardware.camera2.cts.ImageReaderTest#testRepeatingRawPrivate android.hardware.camera2.cts.RobustnessTest#testMandatoryOutputCombinations android.hardware.camera2.cts.StillCaptureTest#testStillPreviewCombination android.hardware.camera2.cts.SurfaceViewPreviewTest#testDeferredSurfaces android.hardware.cts.CameraGLTest#testSetPreviewTextureBothCallbacks android.hardware.cts.CameraGLTest#testSetPreviewTexturePreviewCallback android.hardware.cts.CameraTest#testFocusDistances android.hardware.cts.CameraTest#testImmediateZoom android.hardware.cts.CameraTest#testPreviewCallback android.hardware.cts.CameraTest#testPreviewCallbackWithBuffer android.hardware.cts.CameraTest#testPreviewCallbackWithPicture android.hardware.cts.CameraTest#testPreviewFormats android.hardware.cts.CameraTest#testPreviewFpsRange android.hardware.cts.CameraTest#testPreviewPictureSizesCombination android.hardware.cts.CameraTest#testSetOneShotPreviewCallback android.hardware.cts.CameraTest#testSetPreviewDisplay android.hardware.cts.CameraTest#testVideoSnapshot android.hardware.multiprocess.camera.cts.CameraEvictionTest#testMediaRecorderCameraActivityEviction - libcamera subplan =============== Summary =============== Total Run time: 17m 26s 1/1 modules completed Total Tests : 231 PASSED : 230 FAILED : 1 ============== End of Results ============== android.hardware.camera2.cts.RecordingTest#testVideoSnapshot Tested with cros_camera_test: # cros_camera_test --gtest_filter="Camera3FrameTest/Camera3FlushRequestsTest*" [==========] 12 tests from 1 test suite ran. (1380 ms total) [ PASSED ] 12 tests. Thanks j v4->v5: - [1/8] Rebasing on metadata auto-resize caused a segfault when the camera metadata pack has to be relocated: fix this by assigning the capture result metadata pack after the JPEG encoding - [8/8] Drop the first check in process capture request: the camera start and flushing state check is only performed before queueing the request v3->v4: - [1/8] Set stream to nullptr when the error code does not require it - [1/8] Drop a useless error message - [2/8] Take in style suggestion from Laurent - [4/8] Use enum class CameraDevice::State - [8/8] Reimplement flush assuming it only races with processCaptureRequest v2->v3: - Request::cancel(): - Add tracepoint in request.tp - Emitt Camera::bufferCompleted signal for each cancelled buffer - Do not complete the Request - PipelineHandler - Do not emit Camera::bufferCompleted as Request::cancel() does so - Do not complete the request immediately but call PipelineHandler::completeRequest() - Flush - Use CameraMutex_ in place of FlushMutex_ to wait on the flushed_ condition as suggested by Hiro. This guarantees that any access to the camera state is protected by the same mutex and code is simplified. - Assert that stop() does not get called while flushing as suggested by Hiro. v1->v2: - The majority of patches in the series have not been changed if not for collecting tags. However 8/8 which implement the actual flush() has been changed to address Hiro's comment about protecting close() and configureStreams() from being concurrently run with flush(). - 8/8: - Introduce a new flushed_ condition variable to be used by close() and configureStreams() to be unlocked when flushing has terminated. Jacopo Mondi (8): android: Rework request completion notification libcamera: request: Add Request::cancel() libcamera: pipeline_handler: Cancel Request on queueing failure android: camera_device: Replace running_ with CameraState android: Replace scoped_lock<> with libcamera::MutexLocker android: Guard access to the camera state android: Rename CameraDevice::mutex_ android: Implement flush() camera operation .../libcamera/internal/tracepoints/request.tp | 8 + include/libcamera/request.h | 1 + src/android/camera_device.cpp | 217 ++++++++++++------ src/android/camera_device.h | 18 +- src/android/camera_ops.cpp | 8 +- src/libcamera/pipeline_handler.cpp | 8 +- src/libcamera/request.cpp | 23 ++ 7 files changed, 205 insertions(+), 78 deletions(-) --- 2.31.1