{"id":1042,"url":"https://patchwork.libcamera.org/api/1.1/patches/1042/?format=json","web_url":"https://patchwork.libcamera.org/patch/1042/","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":"<20190418104715.22622-11-jacopo@jmondi.org>","date":"2019-04-18T10:47:11","name":"[libcamera-devel,v5,10/14] libcamera: ipu3: Add multiple stream memory management","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"daefeaaf966865e5bc260383c07bbe9c60ccd9f6","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/1042/mbox/","series":[{"id":255,"url":"https://patchwork.libcamera.org/api/1.1/series/255/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=255","date":"2019-04-18T10:47:01","name":"libcamera: ipu3: Multiple streams support","version":5,"mbox":"https://patchwork.libcamera.org/series/255/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/1042/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/1042/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 75DE660DC8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 18 Apr 2019 12:46:37 +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 relay5-d.mail.gandi.net (Postfix) with ESMTPSA id D1CDC1C0002;\n\tThu, 18 Apr 2019 10:46:36 +0000 (UTC)"],"X-Originating-IP":"2.224.242.101","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Thu, 18 Apr 2019 12:47:11 +0200","Message-Id":"<20190418104715.22622-11-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.21.0","In-Reply-To":"<20190418104715.22622-1-jacopo@jmondi.org>","References":"<20190418104715.22622-1-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v5 10/14] 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":"Thu, 18 Apr 2019 10:46:37 -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 b1e289919d4e..9837637b800b 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -91,6 +91,7 @@ public:\n \n \tBufferPool vfPool_;\n \tBufferPool statPool_;\n+\tBufferPool outPool_;\n };\n \n class CIO2Device\n@@ -381,11 +382,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@@ -400,28 +410,49 @@ int PipelineHandlerIPU3::allocateBuffers(Camera *camera,\n \tif (ret)\n \t\tgoto error_free_cio2;\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_free_imgu;\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_free_imgu;\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_free_imgu;\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_free_imgu;\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_free_imgu;\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_free_imgu;\n+\t}\n+\n \treturn 0;\n \n error_free_imgu:\n@@ -789,6 +820,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","v5","10/14"]}