{"id":723,"url":"https://patchwork.libcamera.org/api/1.1/patches/723/?format=json","web_url":"https://patchwork.libcamera.org/patch/723/","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":"<20190312121242.2253-9-jacopo@jmondi.org>","date":"2019-03-12T12:12:36","name":"[libcamera-devel,v2,08/14] libcamera: ipu3: Implement buffer allocation","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"ed2894c2278bdd5d10bb8e289854aa583f99925d","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/723/mbox/","series":[{"id":205,"url":"https://patchwork.libcamera.org/api/1.1/series/205/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=205","date":"2019-03-12T12:12:28","name":"libcamera: ipu3: ImgU support","version":2,"mbox":"https://patchwork.libcamera.org/series/205/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/723/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/723/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 62522611A2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 12 Mar 2019 13:12:24 +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 relay5-d.mail.gandi.net (Postfix) with ESMTPSA id EEBE41C000A;\n\tTue, 12 Mar 2019 12:12:23 +0000 (UTC)"],"X-Originating-IP":"2.224.242.101","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Tue, 12 Mar 2019 13:12:36 +0100","Message-Id":"<20190312121242.2253-9-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.20.1","In-Reply-To":"<20190312121242.2253-1-jacopo@jmondi.org>","References":"<20190312121242.2253-1-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v2 08/14] libcamera: ipu3: Implement\n\tbuffer allocation","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, 12 Mar 2019 12:12:25 -0000"},"content":"Implement buffer allocation in IPU3 pipeline handlers.\nAs the pipeline handler supports a single stream, preprare two buffer\npools for 'viewfinder' and 'stat' video devices, and export the 'output'\nvideo device buffers to the Stream's pool.\n\nShare buffers between the CIO2 output and the ImgU input video devices,\nas the output of the former should immediately be provided to the\nlatter for further processing.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/libcamera/pipeline/ipu3/ipu3.cpp | 48 +++++++++++++++++++++++++---\n 1 file changed, 43 insertions(+), 5 deletions(-)","diff":"diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nindex 363b24ceead2..ad866346e13c 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -62,6 +62,9 @@ public:\n \tV4L2Device *viewfinder;\n \tV4L2Device *stat;\n \t/* \\todo Add param video device for 3A tuning */\n+\n+\tBufferPool vfPool;\n+\tBufferPool statPool;\n };\n \n struct CIO2Device {\n@@ -80,6 +83,8 @@ struct CIO2Device {\n \tV4L2Device *output;\n \tV4L2Subdevice *csi2;\n \tV4L2Subdevice *sensor;\n+\n+\tBufferPool pool;\n };\n \n class IPU3CameraData : public CameraData\n@@ -123,6 +128,8 @@ public:\n private:\n \tstatic constexpr unsigned int IPU3_IMGU_COUNT = 2;\n \tstatic constexpr unsigned int IPU3_BUFFER_COUNT = 4;\n+\tstatic constexpr unsigned int IPU3_CIO2_BUFFER_COUNT = 4;\n+\tstatic constexpr unsigned int IPU3_IMGU_BUFFER_COUNT = 4;\n \n \tIPU3CameraData *cameraData(const Camera *camera)\n \t{\n@@ -305,16 +312,47 @@ int PipelineHandlerIPU3::configureStreams(Camera *camera,\n \n int PipelineHandlerIPU3::allocateBuffers(Camera *camera, Stream *stream)\n {\n-\tconst StreamConfiguration &cfg = stream->configuration();\n \tIPU3CameraData *data = cameraData(camera);\n+\tV4L2Device *viewfinder = data->imgu->viewfinder;\n+\tV4L2Device *output = data->imgu->output;\n+\tV4L2Device *input = data->imgu->input;\n \tV4L2Device *cio2 = data->cio2.output;\n+\tV4L2Device *stat = data->imgu->stat;\n+\tint ret;\n \n-\tif (!cfg.bufferCount)\n-\t\treturn -EINVAL;\n+\t/* Share buffers between CIO2 output and ImgU input. */\n+\tdata->cio2.pool.createBuffers(IPU3_CIO2_BUFFER_COUNT);\n+\tret = cio2->exportBuffers(&data->cio2.pool);\n+\tif (ret) {\n+\t\tLOG(IPU3, Error) << \"Failed to reserve CIO2 memory\";\n+\t\treturn ret;\n+\t}\n+\n+\tret = input->importBuffers(&data->cio2.pool);\n+\tif (ret) {\n+\t\tLOG(IPU3, Error) << \"Failed to import ImgU memory\";\n+\t\treturn ret;\n+\t}\n+\n+\t/* Prepare the buffer pools for viewfinder and stat. */\n+\tdata->imgu->vfPool.createBuffers(IPU3_IMGU_BUFFER_COUNT);\n+\tret = viewfinder->exportBuffers(&data->imgu->vfPool);\n+\tif (ret) {\n+\t\tLOG(IPU3, Error) << \"Failed to reserve ImgU viewfinder memory\";\n+\t\treturn ret;\n+\t}\n+\n+\tdata->imgu->statPool.createBuffers(IPU3_IMGU_BUFFER_COUNT);\n+\tret = stat->exportBuffers(&data->imgu->statPool);\n+\tif (ret) {\n+\t\tLOG(IPU3, Error) << \"Failed to reserve ImgU stat memory\";\n+\t\treturn ret;\n+\t}\n \n-\tint ret = cio2->exportBuffers(&stream->bufferPool());\n+\t/* Export ImgU output buffers to the stream's pool. */\n+\tret = output->exportBuffers(&stream->bufferPool());\n \tif (ret) {\n-\t\tLOG(IPU3, Error) << \"Failed to request memory\";\n+\t\tLOG(IPU3, Error) << \"Failed to reserve ImgU output memory\";\n \t\treturn ret;\n \t}\n \n","prefixes":["libcamera-devel","v2","08/14"]}