{"id":16560,"url":"https://patchwork.libcamera.org/api/1.1/patches/16560/?format=json","web_url":"https://patchwork.libcamera.org/patch/16560/","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":"<20220706092218.2761216-1-kieran.bingham@ideasonboard.com>","date":"2022-07-06T09:22:18","name":"[libcamera-devel,RFC] qcam: Fix IPU3 camera switching","commit_ref":null,"pull_url":null,"state":"rejected","archived":false,"hash":"ff132279e319f29aa5b89265fa8c61b6e82d5e1d","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/1.1/people/4/?format=json","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"delegate":{"id":11,"url":"https://patchwork.libcamera.org/api/1.1/users/11/?format=json","username":"kbingham","first_name":"Kieran","last_name":"Bingham","email":"kieran.bingham@ideasonboard.com"},"mbox":"https://patchwork.libcamera.org/patch/16560/mbox/","series":[{"id":3260,"url":"https://patchwork.libcamera.org/api/1.1/series/3260/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3260","date":"2022-07-06T09:22:18","name":"[libcamera-devel,RFC] qcam: Fix IPU3 camera switching","version":1,"mbox":"https://patchwork.libcamera.org/series/3260/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/16560/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/16560/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 D9931BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  6 Jul 2022 09:22:23 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8660063315;\n\tWed,  6 Jul 2022 11:22:23 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 888F86330F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  6 Jul 2022 11:22:22 +0200 (CEST)","from Monstersaurus.ksquared.org.uk.beta.tailscale.net\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id E19AF30A;\n\tWed,  6 Jul 2022 11:22:21 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1657099343;\n\tbh=Qqxl+tZPoLNBl5IGNN12T5kzRZ/OaFUmuu0d85KdJ3w=;\n\th=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:From;\n\tb=pHWZ+cce3CI9IpESGm1DW3m1Prwct0R2r5+xqSgiSAwoD4dhpmHxIViuwL2jFX3hq\n\tB1UZA1htpT5qrKvC14qm3NjqFc+FoC0bVg6FCVXFbxh7evk5A4vNMPQDE7Mgkcw5J8\n\tqy1aLq6a4IQiEBJSNMASG/YWhV+E/sdE1lOdAiCUj/xjcEGjl13W58GH1/ba4VkXNJ\n\td5oVxV4yGCKY24AclZHr8CyE3WoSff100PjGOybJKbZSfcotRA+TRAsh4Acj+D6+1X\n\tXwYppPysy5KmIOOm2u7inAH9DH67Pr+NxnZtW5V4uCxwm4KLSLnoQZoZAiR4YFIwSW\n\tJLozdvaS/HVTg==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1657099342;\n\tbh=Qqxl+tZPoLNBl5IGNN12T5kzRZ/OaFUmuu0d85KdJ3w=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=dkBjWWHvhgJ/FW8ddETkUx01hbr+tC7ntuv2jt52Zrz1ZS5lXDEC/miSbgvI568EG\n\tQMiGJVyg1KIv8yRwisZGyigcQD22DKu6xjIqAEVdmU+1OHHEZ7CH8cnQtSrP/DWoV3\n\tnYH73WmkEsb+FPrUaQ9/LjEwpXFIp1iUs7L+NitQ="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"dkBjWWHv\"; dkim-atps=neutral","To":"libcamera devel <libcamera-devel@lists.libcamera.org>","Date":"Wed,  6 Jul 2022 10:22:18 +0100","Message-Id":"<20220706092218.2761216-1-kieran.bingham@ideasonboard.com>","X-Mailer":"git-send-email 2.34.1","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [RFC PATCH] qcam: Fix IPU3 camera switching","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>","From":"Kieran Bingham via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"On the IPU3 we will disallow acquiring a second camera while one is\nactive.  This prevents us from doing a camera switch between the\navailable cameras.\n\nRe-instate this facility by ensuring we release the current camera\nbefore attempting to acquire the new camera.\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n\nQCam is broken on IPU3 in that once one camera is running, we can't swap\nto the other without closing qcam (or swapping to a non IPU3 camera).\n\nThis seems a bit of a pain - but here's a potential fix.\n\nSince writing this patch (some time ago) I know think that trying to\nreaquire the previous camera if the switch fails might be wrong.\n\nI wonder if we should just leave the camera halted, with our 'no-image'\nlogo displayed, and wait. But the only way to 'fix' this would be for\nthe user to choose a new camera, there's no current option to retry\nacquiring a camera...\n\n\n src/qcam/main_window.cpp | 26 ++++++++++++++++++++------\n 1 file changed, 20 insertions(+), 6 deletions(-)","diff":"diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp\nindex 7433d647e8a0..487f522748ca 100644\n--- a/src/qcam/main_window.cpp\n+++ b/src/qcam/main_window.cpp\n@@ -269,11 +269,6 @@ void MainWindow::switchCamera(int index)\n \n \tconst std::shared_ptr<Camera> &cam = cameras[index];\n \n-\tif (cam->acquire()) {\n-\t\tqInfo() << \"Failed to acquire camera\" << cam->id().c_str();\n-\t\treturn;\n-\t}\n-\n \tqInfo() << \"Switching to camera\" << cam->id().c_str();\n \n \t/*\n@@ -283,7 +278,26 @@ void MainWindow::switchCamera(int index)\n \tstartStopAction_->setChecked(false);\n \n \tcamera_->release();\n-\tcamera_ = cam;\n+\n+\t/*\n+\t * Only attempt to acquire after releasing to ensure we support\n+\t * pipelines which can only stream from one device at a time.\n+\t *\n+\t * Todo: Consider how we could acquire more than one camera\n+\t *       but ensure only one could stream at a time.\n+\t */\n+\tif (cam->acquire()) {\n+\t\tqInfo() << \"Failed to acquire camera\" << cam->id().c_str();\n+\t\tqInfo() << \"Switching back to \" << camera_->id().c_str();\n+\n+\t\tif (camera_->acquire()) {\n+\t\t\tqInfo() << \"Failed to reacquire \" << camera_->id().c_str();\n+\t\t\treturn;\n+\t\t}\n+\t} else {\n+\t\t/* Acquire was successful, Switch to this camera */\n+\t\tcamera_ = cam;\n+\t}\n \n \tstartStopAction_->setChecked(true);\n }\n","prefixes":["libcamera-devel","RFC"]}