{"id":10589,"url":"https://patchwork.libcamera.org/api/1.1/patches/10589/?format=json","web_url":"https://patchwork.libcamera.org/patch/10589/","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":"<20201207093413.5479-1-jacopo@jmondi.org>","date":"2020-12-07T09:34:13","name":"[libcamera-devel,v2] android: camera_device: Stop camera when re-configuring it","commit_ref":"8fed613562677dd2402b6f67f0090fcba3301f1f","pull_url":null,"state":"accepted","archived":false,"hash":"b721452ac1ddbc08b2a0188168368f38f2ff6fb4","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/1.1/people/3/?format=json","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/10589/mbox/","series":[{"id":1509,"url":"https://patchwork.libcamera.org/api/1.1/series/1509/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1509","date":"2020-12-07T09:34:13","name":"[libcamera-devel,v2] android: camera_device: Stop camera when re-configuring it","version":2,"mbox":"https://patchwork.libcamera.org/series/1509/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/10589/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/10589/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 58FEDBDB1F\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  7 Dec 2020 10:32:55 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C826F67E16;\n\tMon,  7 Dec 2020 11:32:54 +0100 (CET)","from mslow2.mail.gandi.net (mslow2.mail.gandi.net [217.70.178.242])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6AD5467E12\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  7 Dec 2020 11:32:53 +0100 (CET)","from relay9-d.mail.gandi.net (unknown [217.70.183.199])\n\tby mslow2.mail.gandi.net (Postfix) with ESMTP id 6A9723B276E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  7 Dec 2020 09:34:32 +0000 (UTC)","from uno.lan (93-34-118-233.ip49.fastwebnet.it [93.34.118.233])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay9-d.mail.gandi.net (Postfix) with ESMTPSA id 195C6FF808\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  7 Dec 2020 09:34:11 +0000 (UTC)"],"X-Originating-IP":"93.34.118.233","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Mon,  7 Dec 2020 10:34:13 +0100","Message-Id":"<20201207093413.5479-1-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.29.1","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH v2] android: camera_device: Stop camera\n\twhen re-configuring it","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=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"The Android camera device HAL3 specification does not require a\ncamera to go through any explicit close() call between configurations.\nIt is legit for a camera to be configured, a number of requests\nprocessed and the re-configured again without any explicit stop.\n\nThe libcamera Android camera HAL starts the Camera at the first handled\nrequest, and only stops it at camera close time. This mean, that two\ncamera configuration attempts part of the same streaming session are only\ninterleaved by capture requests handling.\n\nThe libcamera::Camera state machine requires the Camera to be stopped,\nbefore any configuration take place, and this currently doesn't happen.\n\nFix this by stopping the camera and the associated worker thread if\na configuration attempt is performed while the Camera is in running\nstate.\n\nThis patch fixes cros_camera_test:\nCamera3PreviewTest/Camera3SinglePreviewTest.Camera3BasicPreviewTest/0\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n\n---\nv1 -> v2:\n- Stop the camera at the very beginning of the configureStreams() function\n\n---\n src/android/camera_device.cpp | 7 +++++++\n 1 file changed, 7 insertions(+)\n\n--\n2.29.1","diff":"diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex 675af5705055..dc711550546c 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -1210,6 +1210,13 @@ PixelFormat CameraDevice::toPixelFormat(int format) const\n  */\n int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)\n {\n+\t/* Before any configuration attempt, stop the camera if it's running. */\n+\tif (running_) {\n+\t\tworker_.stop();\n+\t\tcamera_->stop();\n+\t\trunning_ = false;\n+\t}\n+\n \t/*\n \t * Generate an empty configuration, and construct a StreamConfiguration\n \t * for each camera3_stream to add to it.\n","prefixes":["libcamera-devel","v2"]}