[{"id":1088,"web_url":"https://patchwork.libcamera.org/comment/1088/","msgid":"<20190321100331.GL4615@pendragon.ideasonboard.com>","date":"2019-03-21T10:03:31","subject":"Re: [libcamera-devel] [PATCH v4 09/31] libcamera: ipu3: Implement\n\tbuffer allocation","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jacopo,\n\nThank you for the patch.\n\nOn Wed, Mar 20, 2019 at 05:30:33PM +0100, Jacopo Mondi wrote:\n> Implement buffer allocation in IPU3 pipeline handlers.\n> As the pipeline handler supports a single stream, preprare two buffer\n\ns/preprare/prepare/\n\n> pools for 'viewfinder' and 'stat' video devices, and export the 'output'\n> video device buffers to the Stream's pool.\n> \n> Share buffers between the CIO2 output and the ImgU input video devices,\n> as the output of the former should immediately be provided to the\n> latter for further processing.\n> \n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> ---\n>  src/libcamera/pipeline/ipu3/ipu3.cpp | 48 +++++++++++++++++++++++++---\n>  1 file changed, 43 insertions(+), 5 deletions(-)\n> \n> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> index 994c95692dd4..659a7ca4829f 100644\n> --- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n> +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> @@ -63,6 +63,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> @@ -81,6 +84,8 @@ struct CIO2Device {\n>  \tV4L2Device *output;\n>  \tV4L2Subdevice *csi2;\n>  \tV4L2Subdevice *sensor;\n> +\n> +\tBufferPool pool;\n>  };\n>  \n>  class PipelineHandlerIPU3 : public PipelineHandler\n> @@ -108,6 +113,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>  \tclass IPU3CameraData : public CameraData\n>  \t{\n> @@ -301,16 +308,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\nDon't you need the same number of buffers for viewfinder and stat than\nfor output ?\n\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\nThis looks good overall, I just wonder if it would make sense to move\ncode to the CIO2Device and ImgUDevice classes (creating\nallocateBuffers() methods there).\n\n>","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3A781600F9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 21 Mar 2019 11:03:43 +0100 (CET)","from pendragon.ideasonboard.com (30.net042126252.t-com.ne.jp\n\t[42.126.252.30])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 96B2023A;\n\tThu, 21 Mar 2019 11:03:41 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1553162622;\n\tbh=aFroJqrgFJT1/cza7Vua/gst7C6Rl7tQMCjztiuz5PU=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=TgwUUG1KrH44cLo2fRZztru67SX8iVLjOezNcAl85zpGiVUYRb69eDpmwqYnuzdP0\n\theU8QmRch4sY4pyDorE/NgyxRpCaDZ+3Ag4awklXiCrzwiKtxzerdxQhrP1sjQA9kZ\n\thIG23JiiEFlf/M68Nvv8KIgSl87nPsq5/j8iZkuw=","Date":"Thu, 21 Mar 2019 12:03:31 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190321100331.GL4615@pendragon.ideasonboard.com>","References":"<20190320163055.22056-1-jacopo@jmondi.org>\n\t<20190320163055.22056-10-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20190320163055.22056-10-jacopo@jmondi.org>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH v4 09/31] 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":"Thu, 21 Mar 2019 10:03:43 -0000"}}]