[{"id":1331,"web_url":"https://patchwork.libcamera.org/comment/1331/","msgid":"<20190414195358.GI1980@bigcity.dyn.berto.se>","date":"2019-04-14T19:53:58","subject":"Re: [libcamera-devel] [PATCH v4 03/12] libcamera: camera:\n\tallocateBuffers: Pass the stream set","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Jacopo,\n\nThanks for your patch.\n\nOn 2019-04-09 21:25:39 +0200, Jacopo Mondi wrote:\n> Pipeline handlers might need to perform allocation of internal buffers,\n> setup operations, or simple sanity check before going into the\n> per-stream buffer allocation.\n> \n> As of now, PipelineHandler::allocateBuffers() is called once for each\n> active stream, leaving no space for stream-independent configuration.\n> \n> Change this by providing to the pipeline handlers the full set of active\n> streams, and ask them to loop over them to perform per-streams\n> allocations.\n> \n> While at it, propagate the freeBuffer() error code to the applications\n> in case of failure.\n\nI think you should do this in a separate patch... yea I know you heard \nit before. I'm going to keep pestering you with comments about this as \nreviewing patches larger then ~40 lines which do more then one thing is \na huge pain for me ;-)\n\n> \n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n\nI think you can put this patch at the beginning of the series or \npotentially merge/post it as a separate patch as it solves a design \nissue not strictly related to the IPU3 code.\n\nI would drop 'allocateBuffers:' from the path subject as it's not our \nconvention to annotate using function names, how about\n\n    libcamera: camera: Pass all active streams in allocateBuffers()\n\nWith the subject fixed and with or without breaking the patch in two,\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\n> ---\n>  src/libcamera/camera.cpp                 | 17 +++++++++--------\n>  src/libcamera/include/pipeline_handler.h |  6 ++++--\n>  src/libcamera/pipeline/ipu3/ipu3.cpp     | 13 +++++++++----\n>  src/libcamera/pipeline/uvcvideo.cpp      | 13 +++++++++----\n>  src/libcamera/pipeline/vimc.cpp          | 13 +++++++++----\n>  src/libcamera/pipeline_handler.cpp       | 11 ++++++-----\n>  6 files changed, 46 insertions(+), 27 deletions(-)\n> \n> diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\n> index bdf14b31d8ee..cb392ca3b7e7 100644\n> --- a/src/libcamera/camera.cpp\n> +++ b/src/libcamera/camera.cpp\n> @@ -647,13 +647,11 @@ int Camera::allocateBuffers()\n>  \t\treturn -EINVAL;\n>  \t}\n>  \n> -\tfor (Stream *stream : activeStreams_) {\n> -\t\tint ret = pipe_->allocateBuffers(this, stream);\n> -\t\tif (ret) {\n> -\t\t\tLOG(Camera, Error) << \"Failed to allocate buffers\";\n> -\t\t\tfreeBuffers();\n> -\t\t\treturn ret;\n> -\t\t}\n> +\tint ret = pipe_->allocateBuffers(this, activeStreams_);\n> +\tif (ret) {\n> +\t\tLOG(Camera, Error) << \"Failed to allocate buffers\";\n> +\t\tfreeBuffers();\n> +\t\treturn ret;\n>  \t}\n>  \n>  \tstate_ = CameraPrepared;\n> @@ -683,9 +681,12 @@ int Camera::freeBuffers()\n>  \t\t * by the V4L2 device that has allocated them.\n>  \t\t */\n>  \t\tstream->bufferPool().destroyBuffers();\n> -\t\tpipe_->freeBuffers(this, stream);\n>  \t}\n>  \n> +\tint ret = pipe_->freeBuffers(this, activeStreams_);\n> +\tif (ret)\n> +\t\treturn ret;\n> +\n>  \tstate_ = CameraConfigured;\n>  \n>  \treturn 0;\n> diff --git a/src/libcamera/include/pipeline_handler.h b/src/libcamera/include/pipeline_handler.h\n> index b6cbd3bae51b..253820e8eaf8 100644\n> --- a/src/libcamera/include/pipeline_handler.h\n> +++ b/src/libcamera/include/pipeline_handler.h\n> @@ -57,8 +57,10 @@ public:\n>  \tstreamConfiguration(Camera *camera, const std::vector<StreamUsage> &usages) = 0;\n>  \tvirtual int configureStreams(Camera *camera, const CameraConfiguration &config) = 0;\n>  \n> -\tvirtual int allocateBuffers(Camera *camera, Stream *stream) = 0;\n> -\tvirtual int freeBuffers(Camera *camera, Stream *stream) = 0;\n> +\tvirtual int allocateBuffers(Camera *camera,\n> +\t\t\t\t    const std::set<Stream *> &streams) = 0;\n> +\tvirtual int freeBuffers(Camera *camera,\n> +\t\t\t\tconst std::set<Stream *> &streams) = 0;\n>  \n>  \tvirtual int start(Camera *camera) = 0;\n>  \tvirtual void stop(Camera *camera);\n> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> index 712e57c5a459..527213a8970a 100644\n> --- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n> +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> @@ -159,8 +159,10 @@ public:\n>  \tint configureStreams(Camera *camera,\n>  \t\t\t     const CameraConfiguration &config) override;\n>  \n> -\tint allocateBuffers(Camera *camera, Stream *stream) override;\n> -\tint freeBuffers(Camera *camera, Stream *stream) override;\n> +\tint allocateBuffers(Camera *camera,\n> +\t\t\t    const std::set<Stream *> &streams) override;\n> +\tint freeBuffers(Camera *camera,\n> +\t\t\tconst std::set<Stream *> &streams) override;\n>  \n>  \tint start(Camera *camera) override;\n>  \tvoid stop(Camera *camera) override;\n> @@ -378,9 +380,11 @@ int PipelineHandlerIPU3::configureStreams(Camera *camera,\n>  \treturn 0;\n>  }\n>  \n> -int PipelineHandlerIPU3::allocateBuffers(Camera *camera, Stream *stream)\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>  \tCIO2Device *cio2 = &data->cio2_;\n>  \tImgUDevice *imgu = data->imgu_;\n>  \tint ret;\n> @@ -419,7 +423,8 @@ int PipelineHandlerIPU3::allocateBuffers(Camera *camera, Stream *stream)\n>  \treturn 0;\n>  }\n>  \n> -int PipelineHandlerIPU3::freeBuffers(Camera *camera, Stream *stream)\n> +int PipelineHandlerIPU3::freeBuffers(Camera *camera,\n> +\t\t\t\t     const std::set<Stream *> &streams)\n>  {\n>  \tIPU3CameraData *data = cameraData(camera);\n>  \n> diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp\n> index cd472cfadd86..b8f634d88b46 100644\n> --- a/src/libcamera/pipeline/uvcvideo.cpp\n> +++ b/src/libcamera/pipeline/uvcvideo.cpp\n> @@ -32,8 +32,10 @@ public:\n>  \tint configureStreams(Camera *camera,\n>  \t\t\t     const CameraConfiguration &config) override;\n>  \n> -\tint allocateBuffers(Camera *camera, Stream *stream) override;\n> -\tint freeBuffers(Camera *camera, Stream *stream) override;\n> +\tint allocateBuffers(Camera *camera,\n> +\t\t\t    const std::set<Stream *> &streams) override;\n> +\tint freeBuffers(Camera *camera,\n> +\t\t\tconst std::set<Stream *> &streams) override;\n>  \n>  \tint start(Camera *camera) override;\n>  \tvoid stop(Camera *camera) override;\n> @@ -127,9 +129,11 @@ int PipelineHandlerUVC::configureStreams(Camera *camera,\n>  \treturn 0;\n>  }\n>  \n> -int PipelineHandlerUVC::allocateBuffers(Camera *camera, Stream *stream)\n> +int PipelineHandlerUVC::allocateBuffers(Camera *camera,\n> +\t\t\t\t\tconst std::set<Stream *> &streams)\n>  {\n>  \tUVCCameraData *data = cameraData(camera);\n> +\tStream *stream = *streams.begin();\n>  \tconst StreamConfiguration &cfg = stream->configuration();\n>  \n>  \tLOG(UVC, Debug) << \"Requesting \" << cfg.bufferCount << \" buffers\";\n> @@ -137,7 +141,8 @@ int PipelineHandlerUVC::allocateBuffers(Camera *camera, Stream *stream)\n>  \treturn data->video_->exportBuffers(&stream->bufferPool());\n>  }\n>  \n> -int PipelineHandlerUVC::freeBuffers(Camera *camera, Stream *stream)\n> +int PipelineHandlerUVC::freeBuffers(Camera *camera,\n> +\t\t\t\t    const std::set<Stream *> &streams)\n>  {\n>  \tUVCCameraData *data = cameraData(camera);\n>  \treturn data->video_->releaseBuffers();\n> diff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp\n> index c8bbe2a19847..22449e47bc2d 100644\n> --- a/src/libcamera/pipeline/vimc.cpp\n> +++ b/src/libcamera/pipeline/vimc.cpp\n> @@ -32,8 +32,10 @@ public:\n>  \tint configureStreams(Camera *camera,\n>  \t\t\t     const CameraConfiguration &config) override;\n>  \n> -\tint allocateBuffers(Camera *camera, Stream *stream) override;\n> -\tint freeBuffers(Camera *camera, Stream *stream) override;\n> +\tint allocateBuffers(Camera *camera,\n> +\t\t\t    const std::set<Stream *> &streams) override;\n> +\tint freeBuffers(Camera *camera,\n> +\t\t\tconst std::set<Stream *> &streams) override;\n>  \n>  \tint start(Camera *camera) override;\n>  \tvoid stop(Camera *camera) override;\n> @@ -127,9 +129,11 @@ int PipelineHandlerVimc::configureStreams(Camera *camera,\n>  \treturn 0;\n>  }\n>  \n> -int PipelineHandlerVimc::allocateBuffers(Camera *camera, Stream *stream)\n> +int PipelineHandlerVimc::allocateBuffers(Camera *camera,\n> +\t\t\t\t\t const std::set<Stream *> &streams)\n>  {\n>  \tVimcCameraData *data = cameraData(camera);\n> +\tStream *stream = *streams.begin();\n>  \tconst StreamConfiguration &cfg = stream->configuration();\n>  \n>  \tLOG(VIMC, Debug) << \"Requesting \" << cfg.bufferCount << \" buffers\";\n> @@ -137,7 +141,8 @@ int PipelineHandlerVimc::allocateBuffers(Camera *camera, Stream *stream)\n>  \treturn data->video_->exportBuffers(&stream->bufferPool());\n>  }\n>  \n> -int PipelineHandlerVimc::freeBuffers(Camera *camera, Stream *stream)\n> +int PipelineHandlerVimc::freeBuffers(Camera *camera,\n> +\t\t\t\t     const std::set<Stream *> &streams)\n>  {\n>  \tVimcCameraData *data = cameraData(camera);\n>  \treturn data->video_->releaseBuffers();\n> diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp\n> index 43550c0e0210..911d08448e69 100644\n> --- a/src/libcamera/pipeline_handler.cpp\n> +++ b/src/libcamera/pipeline_handler.cpp\n> @@ -193,10 +193,11 @@ PipelineHandler::~PipelineHandler()\n>   * \\fn PipelineHandler::allocateBuffers()\n>   * \\brief Allocate buffers for a stream\n>   * \\param[in] camera The camera the \\a stream belongs to\n> - * \\param[in] stream The stream to allocate buffers for\n> + * \\param[in] streams The set of streams to allocate buffers for\n>   *\n> - * This method allocates buffers internally in the pipeline handler and\n> - * associates them with the stream's buffer pool.\n> + * This method allocates buffers internally in the pipeline handler for each\n> + * stream in the \\a streams buffer set, and associates them with the stream's\n> + * buffer pool.\n>   *\n>   * The intended caller of this method is the Camera class.\n>   *\n> @@ -207,9 +208,9 @@ PipelineHandler::~PipelineHandler()\n>   * \\fn PipelineHandler::freeBuffers()\n>   * \\brief Free all buffers associated with a stream\n>   * \\param[in] camera The camera the \\a stream belongs to\n> - * \\param[in] stream The stream to free buffers from\n> + * \\param[in] streams The set of streams to free buffers from\n>   *\n> - * After a capture session has been stopped all buffers associated with the\n> + * After a capture session has been stopped all buffers associated with each\n>   * stream shall be freed.\n>   *\n>   * The intended caller of this method is the Camera class.\n> -- \n> 2.21.0\n> \n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","headers":{"Return-Path":"<niklas.soderlund@ragnatech.se>","Received":["from mail-lf1-x134.google.com (mail-lf1-x134.google.com\n\t[IPv6:2a00:1450:4864:20::134])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C939160DBE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 14 Apr 2019 21:54:01 +0200 (CEST)","by mail-lf1-x134.google.com with SMTP id t11so6873500lfl.12\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 14 Apr 2019 12:54:01 -0700 (PDT)","from localhost (89-233-230-99.cust.bredband2.com. [89.233.230.99])\n\tby smtp.gmail.com with ESMTPSA id\n\tb19sm9602990lfi.96.2019.04.14.12.53.58\n\t(version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);\n\tSun, 14 Apr 2019 12:53:59 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to\n\t:user-agent; bh=ttYqBOut8FqF5k2WxlQvC+wE2oTquM6pIpIF4zkGgFA=;\n\tb=lav3vaZla6P9U/8OlOWATTVnE4pWqSuYIUHyVi1qS87FWwK47qtOeG2AcYHBWLIM4H\n\tMZzI9IUq6sVGVDEtdP29xPVfI7QVugelSX15en0i5j1L03udpYbVcxYv62uuW6SC9UiQ\n\t6ZfC/w3EoXgJgZY0mHFlH4xjCFvaJLr+IEevIUHNB4PKGQY+AamlzhSf/pD26GiT2/n5\n\tMluz9gs7/JtCp7lRM7OeX3ilYekGSIzJteWv7mvF39rZN2pYUZawRXNm6w+6G/xUmmUm\n\tocegCyn8kdxSSPg++q9C0S4/Onj7oY6Vc9F8XI7HPr8SjmtceBuSxd5lWw9UhP7YlVtH\n\tj5bA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to:user-agent;\n\tbh=ttYqBOut8FqF5k2WxlQvC+wE2oTquM6pIpIF4zkGgFA=;\n\tb=kW7Kg3Sl3sd9wmqpHZP9Z1v02JQbYVWgPc2Mz9pBRzOHZCthZtWPI/bS9zolbyFVpn\n\tE8embjSSGCrVhTeDEXsE0HdybBWSatTklmtJsJ9L4gExxFipZWTsl0czZ1a3RhEtdRqC\n\tLe77kMmpe2z4pmLualAGLFHOvClg6LJ/ZFaFo1vmdknCZqRiOk6UBUIOxou1uxqdUdN4\n\tPxVaWWYTY0mk3slFCLldcGtkcq/jVkJHeMc20CNBltryTpynmtlbcBrApvbA7szKM1Ok\n\tEdY2TPgrlRtanpLLU8oCf3GyhQlQ13+BSRIk6+6AiEVcQvci8TdlH3Msm8O33qKaoZiL\n\tYt8A==","X-Gm-Message-State":"APjAAAWKQGxEOBZmcX/ZtdnQoiiGlPDbtufY17gFbcMx7pMV5wtUrbeY\n\tV9bQ55lxJ6LuhY7WPTTziGqOYwqr6cI=","X-Google-Smtp-Source":"APXvYqxylqckcDFtdQRY972bABpzP656SizjE9WBWGDBYDpWON0SlvuD7/3tQQjirFvg5q/bR8eqhg==","X-Received":"by 2002:ac2:5495:: with SMTP id t21mr519484lfk.3.1555271640772; \n\tSun, 14 Apr 2019 12:54:00 -0700 (PDT)","Date":"Sun, 14 Apr 2019 21:53:58 +0200","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190414195358.GI1980@bigcity.dyn.berto.se>","References":"<20190409192548.20325-1-jacopo@jmondi.org>\n\t<20190409192548.20325-4-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=iso-8859-1","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20190409192548.20325-4-jacopo@jmondi.org>","User-Agent":"Mutt/1.11.3 (2019-02-01)","Subject":"Re: [libcamera-devel] [PATCH v4 03/12] libcamera: camera:\n\tallocateBuffers: Pass the stream set","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":"Sun, 14 Apr 2019 19:54:02 -0000"}},{"id":1345,"web_url":"https://patchwork.libcamera.org/comment/1345/","msgid":"<20190415114840.GD4809@pendragon.ideasonboard.com>","date":"2019-04-15T11:48:40","subject":"Re: [libcamera-devel] [PATCH v4 03/12] libcamera: camera:\n\tallocateBuffers: Pass the stream set","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hello,\n\nOn Sun, Apr 14, 2019 at 09:53:58PM +0200, Niklas Söderlund wrote:\n> On 2019-04-09 21:25:39 +0200, Jacopo Mondi wrote:\n> > Pipeline handlers might need to perform allocation of internal buffers,\n> > setup operations, or simple sanity check before going into the\n> > per-stream buffer allocation.\n> > \n> > As of now, PipelineHandler::allocateBuffers() is called once for each\n> > active stream, leaving no space for stream-independent configuration.\n> > \n> > Change this by providing to the pipeline handlers the full set of active\n> > streams, and ask them to loop over them to perform per-streams\n> > allocations.\n> > \n> > While at it, propagate the freeBuffer() error code to the applications\n> > in case of failure.\n> \n> I think you should do this in a separate patch... yea I know you heard \n> it before. I'm going to keep pestering you with comments about this as \n> reviewing patches larger then ~40 lines which do more then one thing is \n> a huge pain for me ;-)\n\nI'm fine with a single patch or two separate patches.\n\n> > Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> \n> I think you can put this patch at the beginning of the series or \n> potentially merge/post it as a separate patch as it solves a design \n> issue not strictly related to the IPU3 code.\n> \n> I would drop 'allocateBuffers:' from the path subject as it's not our \n> convention to annotate using function names, how about\n> \n>     libcamera: camera: Pass all active streams in allocateBuffers()\n\nI agree with all this.\n\n> With the subject fixed and with or without breaking the patch in two,\n> \n> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> \n> > ---\n> >  src/libcamera/camera.cpp                 | 17 +++++++++--------\n> >  src/libcamera/include/pipeline_handler.h |  6 ++++--\n> >  src/libcamera/pipeline/ipu3/ipu3.cpp     | 13 +++++++++----\n> >  src/libcamera/pipeline/uvcvideo.cpp      | 13 +++++++++----\n> >  src/libcamera/pipeline/vimc.cpp          | 13 +++++++++----\n> >  src/libcamera/pipeline_handler.cpp       | 11 ++++++-----\n> >  6 files changed, 46 insertions(+), 27 deletions(-)\n> > \n> > diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\n> > index bdf14b31d8ee..cb392ca3b7e7 100644\n> > --- a/src/libcamera/camera.cpp\n> > +++ b/src/libcamera/camera.cpp\n> > @@ -647,13 +647,11 @@ int Camera::allocateBuffers()\n> >  \t\treturn -EINVAL;\n> >  \t}\n> >  \n> > -\tfor (Stream *stream : activeStreams_) {\n> > -\t\tint ret = pipe_->allocateBuffers(this, stream);\n> > -\t\tif (ret) {\n> > -\t\t\tLOG(Camera, Error) << \"Failed to allocate buffers\";\n> > -\t\t\tfreeBuffers();\n> > -\t\t\treturn ret;\n> > -\t\t}\n> > +\tint ret = pipe_->allocateBuffers(this, activeStreams_);\n> > +\tif (ret) {\n> > +\t\tLOG(Camera, Error) << \"Failed to allocate buffers\";\n> > +\t\tfreeBuffers();\n\nThis is under discussion so I won't repeat my comment here :-)\n\n> > +\t\treturn ret;\n> >  \t}\n> >  \n> >  \tstate_ = CameraPrepared;\n> > @@ -683,9 +681,12 @@ int Camera::freeBuffers()\n> >  \t\t * by the V4L2 device that has allocated them.\n> >  \t\t */\n> >  \t\tstream->bufferPool().destroyBuffers();\n> > -\t\tpipe_->freeBuffers(this, stream);\n> >  \t}\n> >  \n> > +\tint ret = pipe_->freeBuffers(this, activeStreams_);\n> > +\tif (ret)\n> > +\t\treturn ret;\n> > +\n> >  \tstate_ = CameraConfigured;\n\nI wonder if we should set state_ to CameraConfigured even when\npipe_->freeBuffers() fails. Otherwise we won't be able to release the\ncamera, and we'll get more errors when closing the application (such as\nstopping the camera manager with a camera still in use).\n\n> >  \n> >  \treturn 0;\n> > diff --git a/src/libcamera/include/pipeline_handler.h b/src/libcamera/include/pipeline_handler.h\n> > index b6cbd3bae51b..253820e8eaf8 100644\n> > --- a/src/libcamera/include/pipeline_handler.h\n> > +++ b/src/libcamera/include/pipeline_handler.h\n> > @@ -57,8 +57,10 @@ public:\n> >  \tstreamConfiguration(Camera *camera, const std::vector<StreamUsage> &usages) = 0;\n> >  \tvirtual int configureStreams(Camera *camera, const CameraConfiguration &config) = 0;\n> >  \n> > -\tvirtual int allocateBuffers(Camera *camera, Stream *stream) = 0;\n> > -\tvirtual int freeBuffers(Camera *camera, Stream *stream) = 0;\n> > +\tvirtual int allocateBuffers(Camera *camera,\n> > +\t\t\t\t    const std::set<Stream *> &streams) = 0;\n> > +\tvirtual int freeBuffers(Camera *camera,\n> > +\t\t\t\tconst std::set<Stream *> &streams) = 0;\n> >  \n> >  \tvirtual int start(Camera *camera) = 0;\n> >  \tvirtual void stop(Camera *camera);\n> > diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> > index 712e57c5a459..527213a8970a 100644\n> > --- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n> > +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> > @@ -159,8 +159,10 @@ public:\n> >  \tint configureStreams(Camera *camera,\n> >  \t\t\t     const CameraConfiguration &config) override;\n> >  \n> > -\tint allocateBuffers(Camera *camera, Stream *stream) override;\n> > -\tint freeBuffers(Camera *camera, Stream *stream) override;\n> > +\tint allocateBuffers(Camera *camera,\n> > +\t\t\t    const std::set<Stream *> &streams) override;\n> > +\tint freeBuffers(Camera *camera,\n> > +\t\t\tconst std::set<Stream *> &streams) override;\n> >  \n> >  \tint start(Camera *camera) override;\n> >  \tvoid stop(Camera *camera) override;\n> > @@ -378,9 +380,11 @@ int PipelineHandlerIPU3::configureStreams(Camera *camera,\n> >  \treturn 0;\n> >  }\n> >  \n> > -int PipelineHandlerIPU3::allocateBuffers(Camera *camera, Stream *stream)\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> >  \tCIO2Device *cio2 = &data->cio2_;\n> >  \tImgUDevice *imgu = data->imgu_;\n> >  \tint ret;\n> > @@ -419,7 +423,8 @@ int PipelineHandlerIPU3::allocateBuffers(Camera *camera, Stream *stream)\n> >  \treturn 0;\n> >  }\n> >  \n> > -int PipelineHandlerIPU3::freeBuffers(Camera *camera, Stream *stream)\n> > +int PipelineHandlerIPU3::freeBuffers(Camera *camera,\n> > +\t\t\t\t     const std::set<Stream *> &streams)\n> >  {\n> >  \tIPU3CameraData *data = cameraData(camera);\n> >  \n> > diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp\n> > index cd472cfadd86..b8f634d88b46 100644\n> > --- a/src/libcamera/pipeline/uvcvideo.cpp\n> > +++ b/src/libcamera/pipeline/uvcvideo.cpp\n> > @@ -32,8 +32,10 @@ public:\n> >  \tint configureStreams(Camera *camera,\n> >  \t\t\t     const CameraConfiguration &config) override;\n> >  \n> > -\tint allocateBuffers(Camera *camera, Stream *stream) override;\n> > -\tint freeBuffers(Camera *camera, Stream *stream) override;\n> > +\tint allocateBuffers(Camera *camera,\n> > +\t\t\t    const std::set<Stream *> &streams) override;\n> > +\tint freeBuffers(Camera *camera,\n> > +\t\t\tconst std::set<Stream *> &streams) override;\n> >  \n> >  \tint start(Camera *camera) override;\n> >  \tvoid stop(Camera *camera) override;\n> > @@ -127,9 +129,11 @@ int PipelineHandlerUVC::configureStreams(Camera *camera,\n> >  \treturn 0;\n> >  }\n> >  \n> > -int PipelineHandlerUVC::allocateBuffers(Camera *camera, Stream *stream)\n> > +int PipelineHandlerUVC::allocateBuffers(Camera *camera,\n> > +\t\t\t\t\tconst std::set<Stream *> &streams)\n> >  {\n> >  \tUVCCameraData *data = cameraData(camera);\n> > +\tStream *stream = *streams.begin();\n> >  \tconst StreamConfiguration &cfg = stream->configuration();\n> >  \n> >  \tLOG(UVC, Debug) << \"Requesting \" << cfg.bufferCount << \" buffers\";\n> > @@ -137,7 +141,8 @@ int PipelineHandlerUVC::allocateBuffers(Camera *camera, Stream *stream)\n> >  \treturn data->video_->exportBuffers(&stream->bufferPool());\n> >  }\n> >  \n> > -int PipelineHandlerUVC::freeBuffers(Camera *camera, Stream *stream)\n> > +int PipelineHandlerUVC::freeBuffers(Camera *camera,\n> > +\t\t\t\t    const std::set<Stream *> &streams)\n> >  {\n> >  \tUVCCameraData *data = cameraData(camera);\n> >  \treturn data->video_->releaseBuffers();\n> > diff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp\n> > index c8bbe2a19847..22449e47bc2d 100644\n> > --- a/src/libcamera/pipeline/vimc.cpp\n> > +++ b/src/libcamera/pipeline/vimc.cpp\n> > @@ -32,8 +32,10 @@ public:\n> >  \tint configureStreams(Camera *camera,\n> >  \t\t\t     const CameraConfiguration &config) override;\n> >  \n> > -\tint allocateBuffers(Camera *camera, Stream *stream) override;\n> > -\tint freeBuffers(Camera *camera, Stream *stream) override;\n> > +\tint allocateBuffers(Camera *camera,\n> > +\t\t\t    const std::set<Stream *> &streams) override;\n> > +\tint freeBuffers(Camera *camera,\n> > +\t\t\tconst std::set<Stream *> &streams) override;\n> >  \n> >  \tint start(Camera *camera) override;\n> >  \tvoid stop(Camera *camera) override;\n> > @@ -127,9 +129,11 @@ int PipelineHandlerVimc::configureStreams(Camera *camera,\n> >  \treturn 0;\n> >  }\n> >  \n> > -int PipelineHandlerVimc::allocateBuffers(Camera *camera, Stream *stream)\n> > +int PipelineHandlerVimc::allocateBuffers(Camera *camera,\n> > +\t\t\t\t\t const std::set<Stream *> &streams)\n> >  {\n> >  \tVimcCameraData *data = cameraData(camera);\n> > +\tStream *stream = *streams.begin();\n> >  \tconst StreamConfiguration &cfg = stream->configuration();\n> >  \n> >  \tLOG(VIMC, Debug) << \"Requesting \" << cfg.bufferCount << \" buffers\";\n> > @@ -137,7 +141,8 @@ int PipelineHandlerVimc::allocateBuffers(Camera *camera, Stream *stream)\n> >  \treturn data->video_->exportBuffers(&stream->bufferPool());\n> >  }\n> >  \n> > -int PipelineHandlerVimc::freeBuffers(Camera *camera, Stream *stream)\n> > +int PipelineHandlerVimc::freeBuffers(Camera *camera,\n> > +\t\t\t\t     const std::set<Stream *> &streams)\n> >  {\n> >  \tVimcCameraData *data = cameraData(camera);\n> >  \treturn data->video_->releaseBuffers();\n> > diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp\n> > index 43550c0e0210..911d08448e69 100644\n> > --- a/src/libcamera/pipeline_handler.cpp\n> > +++ b/src/libcamera/pipeline_handler.cpp\n> > @@ -193,10 +193,11 @@ PipelineHandler::~PipelineHandler()\n> >   * \\fn PipelineHandler::allocateBuffers()\n> >   * \\brief Allocate buffers for a stream\n> >   * \\param[in] camera The camera the \\a stream belongs to\n> > - * \\param[in] stream The stream to allocate buffers for\n> > + * \\param[in] streams The set of streams to allocate buffers for\n> >   *\n> > - * This method allocates buffers internally in the pipeline handler and\n> > - * associates them with the stream's buffer pool.\n> > + * This method allocates buffers internally in the pipeline handler for each\n> > + * stream in the \\a streams buffer set, and associates them with the stream's\n> > + * buffer pool.\n> >   *\n> >   * The intended caller of this method is the Camera class.\n> >   *\n> > @@ -207,9 +208,9 @@ PipelineHandler::~PipelineHandler()\n> >   * \\fn PipelineHandler::freeBuffers()\n> >   * \\brief Free all buffers associated with a stream\n> >   * \\param[in] camera The camera the \\a stream belongs to\n> > - * \\param[in] stream The stream to free buffers from\n> > + * \\param[in] streams The set of streams to free buffers from\n\ns/from/for/\n\nWith the small comments addressed, and the freeBuffers() issue solved,\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> >   *\n> > - * After a capture session has been stopped all buffers associated with the\n> > + * After a capture session has been stopped all buffers associated with each\n> >   * stream shall be freed.\n> >   *\n> >   * The intended caller of this method is the Camera class.","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3AA15600F9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 15 Apr 2019 13:48:49 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(dfj612yhrgyx302h3jwwy-3.rev.dnainternet.fi\n\t[IPv6:2001:14ba:21f5:5b00:ce28:277f:58d7:3ca4])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id AE62A333;\n\tMon, 15 Apr 2019 13:48:48 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1555328928;\n\tbh=PXqFSHhL8h7aAH+V/Er4rW8/ILl7N9Llyr6ikqsVjyM=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=TyJtPHx4hp8BXIThDigepDHYnbxvcC4+VyK++RIOzcuqicxzz4USCKjGRIbnGusOm\n\tCyd1GrZL+KU/y6Ey/NYOf0SIcu4hwVpiUmi/v6zyMP3AgxXF1T5zGekllxRF0AmKCf\n\tlRDc7rGaIq7ITXL8yIzJX+ObLwjxB8rT7SqoCMwc=","Date":"Mon, 15 Apr 2019 14:48:40 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Niklas =?utf-8?q?S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","Cc":"Jacopo Mondi <jacopo@jmondi.org>, libcamera-devel@lists.libcamera.org","Message-ID":"<20190415114840.GD4809@pendragon.ideasonboard.com>","References":"<20190409192548.20325-1-jacopo@jmondi.org>\n\t<20190409192548.20325-4-jacopo@jmondi.org>\n\t<20190414195358.GI1980@bigcity.dyn.berto.se>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20190414195358.GI1980@bigcity.dyn.berto.se>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH v4 03/12] libcamera: camera:\n\tallocateBuffers: Pass the stream set","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":"Mon, 15 Apr 2019 11:48:49 -0000"}},{"id":1354,"web_url":"https://patchwork.libcamera.org/comment/1354/","msgid":"<20190415145023.xnl3bbyv37w5nwnq@uno.localdomain>","date":"2019-04-15T14:50:23","subject":"Re: [libcamera-devel] [PATCH v4 03/12] libcamera: camera:\n\tallocateBuffers: Pass the stream set","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Laurent,\n\nOn Mon, Apr 15, 2019 at 02:48:40PM +0300, Laurent Pinchart wrote:\n> Hello,\n>\n> On Sun, Apr 14, 2019 at 09:53:58PM +0200, Niklas Söderlund wrote:\n> > On 2019-04-09 21:25:39 +0200, Jacopo Mondi wrote:\n> > > Pipeline handlers might need to perform allocation of internal buffers,\n> > > setup operations, or simple sanity check before going into the\n> > > per-stream buffer allocation.\n> > >\n> > > As of now, PipelineHandler::allocateBuffers() is called once for each\n> > > active stream, leaving no space for stream-independent configuration.\n> > >\n> > > Change this by providing to the pipeline handlers the full set of active\n> > > streams, and ask them to loop over them to perform per-streams\n> > > allocations.\n> > >\n> > > While at it, propagate the freeBuffer() error code to the applications\n> > > in case of failure.\n> >\n> > I think you should do this in a separate patch... yea I know you heard\n> > it before. I'm going to keep pestering you with comments about this as\n> > reviewing patches larger then ~40 lines which do more then one thing is\n> > a huge pain for me ;-)\n>\n> I'm fine with a single patch or two separate patches.\n>\n> > > Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> >\n> > I think you can put this patch at the beginning of the series or\n> > potentially merge/post it as a separate patch as it solves a design\n> > issue not strictly related to the IPU3 code.\n> >\n> > I would drop 'allocateBuffers:' from the path subject as it's not our\n> > convention to annotate using function names, how about\n> >\n> >     libcamera: camera: Pass all active streams in allocateBuffers()\n>\n> I agree with all this.\n>\n> > With the subject fixed and with or without breaking the patch in two,\n> >\n> > Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> >\n> > > ---\n> > >  src/libcamera/camera.cpp                 | 17 +++++++++--------\n> > >  src/libcamera/include/pipeline_handler.h |  6 ++++--\n> > >  src/libcamera/pipeline/ipu3/ipu3.cpp     | 13 +++++++++----\n> > >  src/libcamera/pipeline/uvcvideo.cpp      | 13 +++++++++----\n> > >  src/libcamera/pipeline/vimc.cpp          | 13 +++++++++----\n> > >  src/libcamera/pipeline_handler.cpp       | 11 ++++++-----\n> > >  6 files changed, 46 insertions(+), 27 deletions(-)\n> > >\n> > > diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\n> > > index bdf14b31d8ee..cb392ca3b7e7 100644\n> > > --- a/src/libcamera/camera.cpp\n> > > +++ b/src/libcamera/camera.cpp\n> > > @@ -647,13 +647,11 @@ int Camera::allocateBuffers()\n> > >  \t\treturn -EINVAL;\n> > >  \t}\n> > >\n> > > -\tfor (Stream *stream : activeStreams_) {\n> > > -\t\tint ret = pipe_->allocateBuffers(this, stream);\n> > > -\t\tif (ret) {\n> > > -\t\t\tLOG(Camera, Error) << \"Failed to allocate buffers\";\n> > > -\t\t\tfreeBuffers();\n> > > -\t\t\treturn ret;\n> > > -\t\t}\n> > > +\tint ret = pipe_->allocateBuffers(this, activeStreams_);\n> > > +\tif (ret) {\n> > > +\t\tLOG(Camera, Error) << \"Failed to allocate buffers\";\n> > > +\t\tfreeBuffers();\n>\n> This is under discussion so I won't repeat my comment here :-)\n>\n> > > +\t\treturn ret;\n> > >  \t}\n> > >\n> > >  \tstate_ = CameraPrepared;\n> > > @@ -683,9 +681,12 @@ int Camera::freeBuffers()\n> > >  \t\t * by the V4L2 device that has allocated them.\n> > >  \t\t */\n> > >  \t\tstream->bufferPool().destroyBuffers();\n> > > -\t\tpipe_->freeBuffers(this, stream);\n> > >  \t}\n> > >\n> > > +\tint ret = pipe_->freeBuffers(this, activeStreams_);\n> > > +\tif (ret)\n> > > +\t\treturn ret;\n> > > +\n> > >  \tstate_ = CameraConfigured;\n>\n> I wonder if we should set state_ to CameraConfigured even when\n> pipe_->freeBuffers() fails. Otherwise we won't be able to release the\n> camera, and we'll get more errors when closing the application (such as\n> stopping the camera manager with a camera still in use).\n>\n\nGood point... I should only propagate the error up but not return\neralier then. Thanks.\n\n> > >\n> > >  \treturn 0;\n> > > diff --git a/src/libcamera/include/pipeline_handler.h b/src/libcamera/include/pipeline_handler.h\n> > > index b6cbd3bae51b..253820e8eaf8 100644\n> > > --- a/src/libcamera/include/pipeline_handler.h\n> > > +++ b/src/libcamera/include/pipeline_handler.h\n> > > @@ -57,8 +57,10 @@ public:\n> > >  \tstreamConfiguration(Camera *camera, const std::vector<StreamUsage> &usages) = 0;\n> > >  \tvirtual int configureStreams(Camera *camera, const CameraConfiguration &config) = 0;\n> > >\n> > > -\tvirtual int allocateBuffers(Camera *camera, Stream *stream) = 0;\n> > > -\tvirtual int freeBuffers(Camera *camera, Stream *stream) = 0;\n> > > +\tvirtual int allocateBuffers(Camera *camera,\n> > > +\t\t\t\t    const std::set<Stream *> &streams) = 0;\n> > > +\tvirtual int freeBuffers(Camera *camera,\n> > > +\t\t\t\tconst std::set<Stream *> &streams) = 0;\n> > >\n> > >  \tvirtual int start(Camera *camera) = 0;\n> > >  \tvirtual void stop(Camera *camera);\n> > > diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> > > index 712e57c5a459..527213a8970a 100644\n> > > --- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n> > > +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> > > @@ -159,8 +159,10 @@ public:\n> > >  \tint configureStreams(Camera *camera,\n> > >  \t\t\t     const CameraConfiguration &config) override;\n> > >\n> > > -\tint allocateBuffers(Camera *camera, Stream *stream) override;\n> > > -\tint freeBuffers(Camera *camera, Stream *stream) override;\n> > > +\tint allocateBuffers(Camera *camera,\n> > > +\t\t\t    const std::set<Stream *> &streams) override;\n> > > +\tint freeBuffers(Camera *camera,\n> > > +\t\t\tconst std::set<Stream *> &streams) override;\n> > >\n> > >  \tint start(Camera *camera) override;\n> > >  \tvoid stop(Camera *camera) override;\n> > > @@ -378,9 +380,11 @@ int PipelineHandlerIPU3::configureStreams(Camera *camera,\n> > >  \treturn 0;\n> > >  }\n> > >\n> > > -int PipelineHandlerIPU3::allocateBuffers(Camera *camera, Stream *stream)\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> > >  \tCIO2Device *cio2 = &data->cio2_;\n> > >  \tImgUDevice *imgu = data->imgu_;\n> > >  \tint ret;\n> > > @@ -419,7 +423,8 @@ int PipelineHandlerIPU3::allocateBuffers(Camera *camera, Stream *stream)\n> > >  \treturn 0;\n> > >  }\n> > >\n> > > -int PipelineHandlerIPU3::freeBuffers(Camera *camera, Stream *stream)\n> > > +int PipelineHandlerIPU3::freeBuffers(Camera *camera,\n> > > +\t\t\t\t     const std::set<Stream *> &streams)\n> > >  {\n> > >  \tIPU3CameraData *data = cameraData(camera);\n> > >\n> > > diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp\n> > > index cd472cfadd86..b8f634d88b46 100644\n> > > --- a/src/libcamera/pipeline/uvcvideo.cpp\n> > > +++ b/src/libcamera/pipeline/uvcvideo.cpp\n> > > @@ -32,8 +32,10 @@ public:\n> > >  \tint configureStreams(Camera *camera,\n> > >  \t\t\t     const CameraConfiguration &config) override;\n> > >\n> > > -\tint allocateBuffers(Camera *camera, Stream *stream) override;\n> > > -\tint freeBuffers(Camera *camera, Stream *stream) override;\n> > > +\tint allocateBuffers(Camera *camera,\n> > > +\t\t\t    const std::set<Stream *> &streams) override;\n> > > +\tint freeBuffers(Camera *camera,\n> > > +\t\t\tconst std::set<Stream *> &streams) override;\n> > >\n> > >  \tint start(Camera *camera) override;\n> > >  \tvoid stop(Camera *camera) override;\n> > > @@ -127,9 +129,11 @@ int PipelineHandlerUVC::configureStreams(Camera *camera,\n> > >  \treturn 0;\n> > >  }\n> > >\n> > > -int PipelineHandlerUVC::allocateBuffers(Camera *camera, Stream *stream)\n> > > +int PipelineHandlerUVC::allocateBuffers(Camera *camera,\n> > > +\t\t\t\t\tconst std::set<Stream *> &streams)\n> > >  {\n> > >  \tUVCCameraData *data = cameraData(camera);\n> > > +\tStream *stream = *streams.begin();\n> > >  \tconst StreamConfiguration &cfg = stream->configuration();\n> > >\n> > >  \tLOG(UVC, Debug) << \"Requesting \" << cfg.bufferCount << \" buffers\";\n> > > @@ -137,7 +141,8 @@ int PipelineHandlerUVC::allocateBuffers(Camera *camera, Stream *stream)\n> > >  \treturn data->video_->exportBuffers(&stream->bufferPool());\n> > >  }\n> > >\n> > > -int PipelineHandlerUVC::freeBuffers(Camera *camera, Stream *stream)\n> > > +int PipelineHandlerUVC::freeBuffers(Camera *camera,\n> > > +\t\t\t\t    const std::set<Stream *> &streams)\n> > >  {\n> > >  \tUVCCameraData *data = cameraData(camera);\n> > >  \treturn data->video_->releaseBuffers();\n> > > diff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp\n> > > index c8bbe2a19847..22449e47bc2d 100644\n> > > --- a/src/libcamera/pipeline/vimc.cpp\n> > > +++ b/src/libcamera/pipeline/vimc.cpp\n> > > @@ -32,8 +32,10 @@ public:\n> > >  \tint configureStreams(Camera *camera,\n> > >  \t\t\t     const CameraConfiguration &config) override;\n> > >\n> > > -\tint allocateBuffers(Camera *camera, Stream *stream) override;\n> > > -\tint freeBuffers(Camera *camera, Stream *stream) override;\n> > > +\tint allocateBuffers(Camera *camera,\n> > > +\t\t\t    const std::set<Stream *> &streams) override;\n> > > +\tint freeBuffers(Camera *camera,\n> > > +\t\t\tconst std::set<Stream *> &streams) override;\n> > >\n> > >  \tint start(Camera *camera) override;\n> > >  \tvoid stop(Camera *camera) override;\n> > > @@ -127,9 +129,11 @@ int PipelineHandlerVimc::configureStreams(Camera *camera,\n> > >  \treturn 0;\n> > >  }\n> > >\n> > > -int PipelineHandlerVimc::allocateBuffers(Camera *camera, Stream *stream)\n> > > +int PipelineHandlerVimc::allocateBuffers(Camera *camera,\n> > > +\t\t\t\t\t const std::set<Stream *> &streams)\n> > >  {\n> > >  \tVimcCameraData *data = cameraData(camera);\n> > > +\tStream *stream = *streams.begin();\n> > >  \tconst StreamConfiguration &cfg = stream->configuration();\n> > >\n> > >  \tLOG(VIMC, Debug) << \"Requesting \" << cfg.bufferCount << \" buffers\";\n> > > @@ -137,7 +141,8 @@ int PipelineHandlerVimc::allocateBuffers(Camera *camera, Stream *stream)\n> > >  \treturn data->video_->exportBuffers(&stream->bufferPool());\n> > >  }\n> > >\n> > > -int PipelineHandlerVimc::freeBuffers(Camera *camera, Stream *stream)\n> > > +int PipelineHandlerVimc::freeBuffers(Camera *camera,\n> > > +\t\t\t\t     const std::set<Stream *> &streams)\n> > >  {\n> > >  \tVimcCameraData *data = cameraData(camera);\n> > >  \treturn data->video_->releaseBuffers();\n> > > diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp\n> > > index 43550c0e0210..911d08448e69 100644\n> > > --- a/src/libcamera/pipeline_handler.cpp\n> > > +++ b/src/libcamera/pipeline_handler.cpp\n> > > @@ -193,10 +193,11 @@ PipelineHandler::~PipelineHandler()\n> > >   * \\fn PipelineHandler::allocateBuffers()\n> > >   * \\brief Allocate buffers for a stream\n> > >   * \\param[in] camera The camera the \\a stream belongs to\n> > > - * \\param[in] stream The stream to allocate buffers for\n> > > + * \\param[in] streams The set of streams to allocate buffers for\n> > >   *\n> > > - * This method allocates buffers internally in the pipeline handler and\n> > > - * associates them with the stream's buffer pool.\n> > > + * This method allocates buffers internally in the pipeline handler for each\n> > > + * stream in the \\a streams buffer set, and associates them with the stream's\n> > > + * buffer pool.\n> > >   *\n> > >   * The intended caller of this method is the Camera class.\n> > >   *\n> > > @@ -207,9 +208,9 @@ PipelineHandler::~PipelineHandler()\n> > >   * \\fn PipelineHandler::freeBuffers()\n> > >   * \\brief Free all buffers associated with a stream\n> > >   * \\param[in] camera The camera the \\a stream belongs to\n> > > - * \\param[in] stream The stream to free buffers from\n> > > + * \\param[in] streams The set of streams to free buffers from\n>\n> s/from/for/\n>\n> With the small comments addressed, and the freeBuffers() issue solved,\n>\n\nI will send separate patches to:\n1) propagate the freeBuffers() error up\n2) remove freeBuffers() call in allocateBuffers() error path\n3) pass the active stream vector to allocate/free\n\nThanks\n  j\n\n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n>\n> > >   *\n> > > - * After a capture session has been stopped all buffers associated with the\n> > > + * After a capture session has been stopped all buffers associated with each\n> > >   * stream shall be freed.\n> > >   *\n> > >   * The intended caller of this method is the Camera class.\n>\n> --\n> Regards,\n>\n> Laurent Pinchart","headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net\n\t[217.70.183.200])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D791E600F9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 15 Apr 2019 16:49:33 +0200 (CEST)","from uno.localdomain (unknown [31.159.28.121])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay7-d.mail.gandi.net (Postfix) with ESMTPSA id 12C5D2001C;\n\tMon, 15 Apr 2019 14:49:31 +0000 (UTC)"],"X-Originating-IP":"31.159.28.121","Date":"Mon, 15 Apr 2019 16:50:23 +0200","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"Niklas =?utf-8?q?S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>,\n\tlibcamera-devel@lists.libcamera.org","Message-ID":"<20190415145023.xnl3bbyv37w5nwnq@uno.localdomain>","References":"<20190409192548.20325-1-jacopo@jmondi.org>\n\t<20190409192548.20325-4-jacopo@jmondi.org>\n\t<20190414195358.GI1980@bigcity.dyn.berto.se>\n\t<20190415114840.GD4809@pendragon.ideasonboard.com>","MIME-Version":"1.0","Content-Type":"multipart/signed; micalg=pgp-sha256;\n\tprotocol=\"application/pgp-signature\"; boundary=\"qqc2odscykdf6ois\"","Content-Disposition":"inline","In-Reply-To":"<20190415114840.GD4809@pendragon.ideasonboard.com>","User-Agent":"NeoMutt/20180716","Subject":"Re: [libcamera-devel] [PATCH v4 03/12] libcamera: camera:\n\tallocateBuffers: Pass the stream set","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":"Mon, 15 Apr 2019 14:49:34 -0000"}}]