{"id":1078,"url":"https://patchwork.libcamera.org/api/patches/1078/?format=json","web_url":"https://patchwork.libcamera.org/patch/1078/","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":"<20190419101839.10337-6-jacopo@jmondi.org>","date":"2019-04-19T10:18:36","name":"[libcamera-devel,v7,5/8] libcamera: ipu3: Add multiple stream memory management","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"606fc46419c85450827ea38c5332a1a7ad89e6ad","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/1078/mbox/","series":[{"id":261,"url":"https://patchwork.libcamera.org/api/series/261/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=261","date":"2019-04-19T10:18:31","name":"libcamera: ipu3: Multiple streams support","version":7,"mbox":"https://patchwork.libcamera.org/series/261/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/1078/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/1078/checks/","tags":{},"headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net\n\t[217.70.183.199])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D539660DCE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 19 Apr 2019 12:17:54 +0200 (CEST)","from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay9-d.mail.gandi.net (Postfix) with ESMTPSA id 32FE7FF80B;\n\tFri, 19 Apr 2019 10:17:54 +0000 (UTC)"],"X-Originating-IP":"2.224.242.101","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Fri, 19 Apr 2019 12:18:36 +0200","Message-Id":"<20190419101839.10337-6-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.21.0","In-Reply-To":"<20190419101839.10337-1-jacopo@jmondi.org>","References":"<20190419101839.10337-1-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v7 5/8] libcamera: ipu3: Add multiple\n\tstream memory management","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":"Fri, 19 Apr 2019 10:17:55 -0000"},"content":"Perform allocation and setup of memory sharing between the CIO2 output\nand the ImgU input and allocate memory for each active stream.\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/libcamera/pipeline/ipu3/ipu3.cpp | 64 +++++++++++++++++++++-------\n 1 file changed, 48 insertions(+), 16 deletions(-)","diff":"diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nindex 45edc24b5d4c..fe671b95ed8e 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -93,6 +93,7 @@ public:\n \n \tBufferPool vfPool_;\n \tBufferPool statPool_;\n+\tBufferPool outPool_;\n };\n \n class CIO2Device\n@@ -426,11 +427,20 @@ int PipelineHandlerIPU3::configureStreams(Camera *camera,\n \treturn 0;\n }\n \n+/**\n+ * \\todo Clarify if 'viewfinder' and 'stat' nodes have to be set up and\n+ * started even if not in use. As of now, if not properly configured and\n+ * enabled, the ImgU processing pipeline stalls.\n+ *\n+ * In order to be able to start the 'viewfinder' and 'stat' nodes, we need\n+ * memory to be reserved.\n+ */\n int PipelineHandlerIPU3::allocateBuffers(Camera *camera,\n \t\t\t\t\t const std::set<Stream *> &streams)\n {\n \tIPU3CameraData *data = cameraData(camera);\n-\tStream *stream = *streams.begin();\n+\tIPU3Stream *outStream = &data->outStream_;\n+\tIPU3Stream *vfStream = &data->vfStream_;\n \tCIO2Device *cio2 = &data->cio2_;\n \tImgUDevice *imgu = data->imgu_;\n \tunsigned int bufferCount;\n@@ -445,28 +455,49 @@ int PipelineHandlerIPU3::allocateBuffers(Camera *camera,\n \tif (ret)\n \t\tgoto error;\n \n-\t/* Export ImgU output buffers to the stream's pool. */\n-\tret = imgu->exportBuffers(&imgu->output_, &stream->bufferPool());\n-\tif (ret)\n-\t\tgoto error;\n-\n \t/*\n-\t * Reserve memory in viewfinder and stat output devices. Use the\n-\t * same number of buffers as the ones requested for the output\n-\t * stream.\n+\t * Use for the stat's internal pool the same number of buffer as\n+\t * for the input pool.\n+\t * \\todo To be revised when we'll actually use the stat node.\n \t */\n-\tbufferCount = stream->bufferPool().count();\n-\n-\timgu->viewfinder_.pool->createBuffers(bufferCount);\n-\tret = imgu->exportBuffers(&imgu->viewfinder_, imgu->viewfinder_.pool);\n-\tif (ret)\n-\t\tgoto error;\n-\n+\tbufferCount = pool->count();\n \timgu->stat_.pool->createBuffers(bufferCount);\n \tret = imgu->exportBuffers(&imgu->stat_, imgu->stat_.pool);\n \tif (ret)\n \t\tgoto error;\n \n+\t/* Allocate buffers for each active stream. */\n+\tfor (Stream *s : streams) {\n+\t\tIPU3Stream *stream = static_cast<IPU3Stream *>(s);\n+\t\tImgUDevice::ImgUOutput *dev = stream->device_;\n+\n+\t\tret = imgu->exportBuffers(dev, &stream->bufferPool());\n+\t\tif (ret)\n+\t\t\tgoto error;\n+\t}\n+\n+\t/*\n+\t * Allocate buffers also on non-active outputs; use the same number\n+\t * of buffers as the active ones.\n+\t */\n+\tif (!outStream->active_) {\n+\t\tbufferCount = vfStream->bufferPool().count();\n+\t\toutStream->device_->pool->createBuffers(bufferCount);\n+\t\tret = imgu->exportBuffers(outStream->device_,\n+\t\t\t\t\t  outStream->device_->pool);\n+\t\tif (ret)\n+\t\t\tgoto error;\n+\t}\n+\n+\tif (!vfStream->active_) {\n+\t\tbufferCount = outStream->bufferPool().count();\n+\t\tvfStream->device_->pool->createBuffers(bufferCount);\n+\t\tret = imgu->exportBuffers(vfStream->device_,\n+\t\t\t\t\t  vfStream->device_->pool);\n+\t\tif (ret)\n+\t\t\tgoto error;\n+\t}\n+\n \treturn 0;\n \n error:\n@@ -831,6 +862,7 @@ int ImgUDevice::init(MediaDevice *media, unsigned int index)\n \n \toutput_.pad = PAD_OUTPUT;\n \toutput_.name = \"output\";\n+\toutput_.pool = &outPool_;\n \n \tviewfinder_.dev = V4L2Device::fromEntityName(media,\n \t\t\t\t\t\t     name_ + \" viewfinder\");\n","prefixes":["libcamera-devel","v7","5/8"]}