{"id":1699,"url":"https://patchwork.libcamera.org/api/1.1/patches/1699/?format=json","web_url":"https://patchwork.libcamera.org/patch/1699/","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":"<20190715055935.21233-2-jacopo@jmondi.org>","date":"2019-07-15T05:59:33","name":"[libcamera-devel,1/3] libcamera: ipu3: Move link disabling at configure time","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"27490365472749fb115c67b356ccca43f326ad69","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/1.1/people/3/?format=json","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"delegate":{"id":15,"url":"https://patchwork.libcamera.org/api/1.1/users/15/?format=json","username":"jmondi","first_name":"Jacopo","last_name":"Mondi","email":"jacopo@jmondi.org"},"mbox":"https://patchwork.libcamera.org/patch/1699/mbox/","series":[{"id":431,"url":"https://patchwork.libcamera.org/api/1.1/series/431/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=431","date":"2019-07-15T05:59:32","name":"libcamera: misc fixes","version":1,"mbox":"https://patchwork.libcamera.org/series/431/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/1699/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/1699/checks/","tags":{},"headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net\n\t[217.70.183.197])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B20F961A96\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 15 Jul 2019 07:58:30 +0200 (CEST)","from uno.localdomain (unknown [104.132.146.101])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 853B31C0003;\n\tMon, 15 Jul 2019 05:58:29 +0000 (UTC)"],"X-Originating-IP":"104.132.146.101","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Mon, 15 Jul 2019 07:59:33 +0200","Message-Id":"<20190715055935.21233-2-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.21.0","In-Reply-To":"<20190715055935.21233-1-jacopo@jmondi.org>","References":"<20190715055935.21233-1-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 1/3] libcamera: ipu3: Move link disabling\n\tat configure time","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","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>","X-List-Received-Date":"Mon, 15 Jul 2019 05:58:30 -0000"},"content":"With the current IPU3 kernel driver implementation, if links are enabled on\nan ImgU pipe buffers should be queued on its output devices in order not to\nblock the other pipe.\n\nCurrently all links on the ImgU device are disabled at match() time,\nimplying that once an ImgU pipe gets linked, it should be used until the\nwhole pipeline handler is not re-matched and links disabled again. This is a\nsevere limitation for applications that wants to switch between cameras\nusing different pipes without going through a full library tear-down and\nre-initialization.\n\nMove the link disabling at configure() time, so that a camera\nconfiguration operation always unlock the usage of the assigned pipe,\nregardless of the status of the one previously in use.\n\nUnfortunately this requires a camera start/stop sequence to always go\nthrough a configure step, a requirement that is not enforced by the\nCamera state machine.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/libcamera/pipeline/ipu3/ipu3.cpp | 55 +++++++++++++++-------------\n 1 file changed, 29 insertions(+), 26 deletions(-)","diff":"diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nindex 22987dbf1460..5204487684c2 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -496,6 +496,35 @@ int PipelineHandlerIPU3::configure(Camera *camera, CameraConfiguration *c)\n \tImgUDevice *imgu = data->imgu_;\n \tint ret;\n \n+\t/*\n+\t * FIXME: enabled links in one ImgU pipe interfere with capture\n+\t * operations on the other one. This can be easily triggered by\n+\t * capturing from one camera and then trying to capture from the other\n+\t * one right after, without disabling media links on the first  pipe.\n+\t *\n+\t * The tricky part here is where to disable links on the ImgU instance\n+\t * which is currently not in use:\n+\t * 1) Link enable/disable cannot be done at start()/stop() time as video\n+\t * devices needs to be linked first before format can be configured on\n+\t * them.\n+\t * 2) As link enable has to be done at the least in configure(),\n+\t * before configuring formats, the only place where to disable links\n+\t * would be 'stop()', but the Camera class state machine allows\n+\t * start()<->stop() sequences without any configure() in between.\n+\t *\n+\t * As of now, disable all links in the ImgU media graph before\n+\t * configuring the device, to allow alternate usage of two pipes.\n+\t *\n+\t * As a consequence, a Camera using an ImgU shall be configured before\n+\t * any start()/stop() sequence. An application that wants to\n+\t * pre-configure all the camera and then start/stop them alternatively\n+\t * without going through any re-configuration (a sequence that is\n+\t * allowed by the Camera state machine) would now fail on the IPU3.\n+\t */\n+\tret = imguMediaDev_->disableLinks();\n+\tif (ret)\n+\t\treturn ret;\n+\n \t/*\n \t * \\todo: Enable links selectively based on the requested streams.\n \t * As of now, enable all links unconditionally.\n@@ -778,32 +807,6 @@ bool PipelineHandlerIPU3::match(DeviceEnumerator *enumerator)\n \tif (cio2MediaDev_->disableLinks())\n \t\treturn false;\n \n-\t/*\n-\t * FIXME: enabled links in one ImgU instance interfere with capture\n-\t * operations on the other one. This can be easily triggered by\n-\t * capturing from one camera and then trying to capture from the other\n-\t * one right after, without disabling media links in the media graph\n-\t * first.\n-\t *\n-\t * The tricky part here is where to disable links on the ImgU instance\n-\t * which is currently not in use:\n-\t * 1) Link enable/disable cannot be done at start/stop time as video\n-\t * devices needs to be linked first before format can be configured on\n-\t * them.\n-\t * 2) As link enable has to be done at the least in configure(),\n-\t * before configuring formats, the only place where to disable links\n-\t * would be 'stop()', but the Camera class state machine allows\n-\t * start()<->stop() sequences without any configure() in between.\n-\t *\n-\t * As of now, disable all links in the media graph at 'match()' time,\n-\t * to allow testing different cameras in different test applications\n-\t * runs. A test application that would use two distinct cameras without\n-\t * going through a library teardown->match() sequence would fail\n-\t * at the moment.\n-\t */\n-\tret = imguMediaDev_->disableLinks();\n-\tif (ret)\n-\t\treturn ret;\n \n \tret = registerCameras();\n \n","prefixes":["libcamera-devel","1/3"]}