{"id":814,"url":"https://patchwork.libcamera.org/api/patches/814/?format=json","web_url":"https://patchwork.libcamera.org/patch/814/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20190326083902.26121-20-jacopo@jmondi.org>","date":"2019-03-26T08:39:02","name":"[libcamera-devel,v5,19/19] libcamera: ipu3: Enable ImgU media links","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"81f7f67fb73395545730254e88b7fa9f87c78fe0","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/?format=json","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/814/mbox/","series":[{"id":219,"url":"https://patchwork.libcamera.org/api/series/219/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=219","date":"2019-03-26T08:38:43","name":"libcamera: ipu3: Add ImgU support","version":5,"mbox":"https://patchwork.libcamera.org/series/219/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/814/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/814/checks/","tags":{},"headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay10.mail.gandi.net (relay10.mail.gandi.net\n\t[217.70.178.230])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2170961112\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 26 Mar 2019 09:38:43 +0100 (CET)","from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay10.mail.gandi.net (Postfix) with ESMTPSA id ADA3024000A;\n\tTue, 26 Mar 2019 08:38:42 +0000 (UTC)"],"From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Tue, 26 Mar 2019 09:39:02 +0100","Message-Id":"<20190326083902.26121-20-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.21.0","In-Reply-To":"<20190326083902.26121-1-jacopo@jmondi.org>","References":"<20190326083902.26121-1-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v5 19/19] libcamera: ipu3: Enable ImgU\n\tmedia links","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":"Tue, 26 Mar 2019 08:38:43 -0000"},"content":"As the lenghty comment reports, link enable/disable is not trivial, as\nlinks in one ImgU instance interfere with capture operations in the\nother one. As it is not yet clear if this behaviour is intended,\nas of now reset the media graph during pipeline's match() and enable\nthe required links at streamConfiguration time.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/libcamera/pipeline/ipu3/ipu3.cpp | 111 +++++++++++++++++++++++++++\n 1 file changed, 111 insertions(+)","diff":"diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nindex 66efcc37d695..f92728ae5b85 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -114,6 +114,11 @@ public:\n \tint start();\n \tvoid stop();\n \n+\tint linkSetup(const std::string &source, unsigned int sourcePad,\n+\t\t      const std::string &sink, unsigned int sinkPad,\n+\t\t      bool enable);\n+\tint enableLinks(bool enable);\n+\n \tunsigned int index_;\n \tstd::string name_;\n \tMediaDevice *media_;\n@@ -304,6 +309,14 @@ int PipelineHandlerIPU3::configureStreams(Camera *camera,\n \t\treturn -EINVAL;\n \t}\n \n+\t/*\n+\t * \\todo: Enable links selectively based on the requested streams.\n+\t * As of now, enable all links unconditionally.\n+\t */\n+\tret = data->imgu_->enableLinks(true);\n+\tif (ret)\n+\t\treturn ret;\n+\n \t/*\n \t * Pass the requested output image size to the sensor and get back the\n \t * adjusted one to be propagated to the to the ImgU devices.\n@@ -506,6 +519,30 @@ bool PipelineHandlerIPU3::match(DeviceEnumerator *enumerator)\n \t\treturn false;\n \t}\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 configureStreams,\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 streamConfiguration() in\n+\t * 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 \tif (imguMediaDev_->disableLinks())\n \t\tgoto error;\n \n@@ -946,6 +983,80 @@ void ImgUDevice::stop()\n \tinput_->streamOff();\n }\n \n+/**\n+ * \\brief Enable or disable a single link on the ImgU instance\n+ *\n+ * This method assumes the media device associated with the ImgU instance\n+ * is open.\n+ *\n+ * \\return 0 on success or a negative error code otherwise\n+ */\n+int ImgUDevice::linkSetup(const std::string &source, unsigned int sourcePad,\n+\t\t\t  const std::string &sink, unsigned int sinkPad,\n+\t\t\t  bool enable)\n+{\n+\tMediaLink *link = media_->link(source, sourcePad, sink, sinkPad);\n+\tif (!link) {\n+\t\tLOG(IPU3, Error)\n+\t\t\t<< \"Failed to get link: '\" << source << \"':\"\n+\t\t\t<< sourcePad << \" -> '\" << sink << \"':\" << sinkPad;\n+\t\treturn -ENODEV;\n+\t}\n+\n+\treturn link->setEnabled(enable);\n+}\n+\n+/**\n+ * \\brief Enable or disable all media links in the ImgU instance to prepare\n+ * for capture operations\n+ *\n+ * \\todo This method will probably be removed or changed once links will be\n+ * enabled or disabled selectively.\n+ *\n+ * \\return 0 on success or a negative error code otherwise\n+ */\n+int ImgUDevice::enableLinks(bool enable)\n+{\n+\tint ret;\n+\n+\t/* \\todo Establish rules to handle media devices open/close. */\n+\tret = media_->open();\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tstd::string inputName = name_ + \" input\";\n+\tret = linkSetup(inputName, 0, name_, PAD_INPUT, enable);\n+\tif (ret) {\n+\t\tmedia_->close();\n+\t\treturn ret;\n+\t}\n+\n+\tstd::string outputName = name_ + \" output\";\n+\tret = linkSetup(name_, PAD_OUTPUT, outputName, 0, enable);\n+\tif (ret) {\n+\t\tmedia_->close();\n+\t\treturn ret;\n+\t}\n+\n+\tstd::string viewfinderName = name_ + \" viewfinder\";\n+\tret = linkSetup(name_, PAD_VF, viewfinderName, 0, enable);\n+\tif (ret) {\n+\t\tmedia_->close();\n+\t\treturn ret;\n+\t}\n+\n+\tstd::string statName = name_ + \" 3a stat\";\n+\tret = linkSetup(name_, PAD_STAT, statName, 0, enable);\n+\tif (ret) {\n+\t\tmedia_->close();\n+\t\treturn ret;\n+\t}\n+\n+\tmedia_->close();\n+\n+\treturn 0;\n+}\n+\n /*------------------------------------------------------------------------------\n  * CIO2 Device\n  */\n","prefixes":["libcamera-devel","v5","19/19"]}