[{"id":16339,"web_url":"https://patchwork.libcamera.org/comment/16339/","msgid":"<CAO5uPHM10PBrUKMB2HBHA=RxuovCLYXL747O=+R7TPWooUbW7Q@mail.gmail.com>","date":"2021-04-19T05:56:33","subject":"Re: [libcamera-devel] [PATCH v2 1/2] libcamera:\n\tframebuffer_allocator: Make allocate() accept count","submitter":{"id":63,"url":"https://patchwork.libcamera.org/api/people/63/","name":"Hirokazu Honda","email":"hiroh@chromium.org"},"content":"Hi Nicolas, thanks for the patch.\n\nOn Sat, Apr 17, 2021 at 7:29 AM Nícolas F. R. A. Prado\n<nfraprado@collabora.com> wrote:\n>\n> Add a 'count' argument to FrameBufferAllocator::allocate() so that a\n> custom amount of buffers can be allocated. If 0 is passed, the pipeline\n> handler allocates the default amount, which is the configured\n> bufferCount.\n>\n> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>\n> ---\n>  include/libcamera/camera.h                         | 3 ++-\n>  include/libcamera/framebuffer_allocator.h          | 2 +-\n>  include/libcamera/internal/pipeline_handler.h      | 3 ++-\n>  src/cam/capture.cpp                                | 2 +-\n>  src/lc-compliance/simple_capture.cpp               | 8 ++++----\n>  src/lc-compliance/simple_capture.h                 | 2 +-\n>  src/libcamera/camera.cpp                           | 5 +++--\n>  src/libcamera/framebuffer_allocator.cpp            | 5 +++--\n>  src/libcamera/pipeline/ipu3/ipu3.cpp               | 9 ++++++---\n>  src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 9 ++++++---\n>  src/libcamera/pipeline/rkisp1/rkisp1.cpp           | 9 ++++++---\n>  src/libcamera/pipeline/simple/simple.cpp           | 9 ++++++---\n>  src/libcamera/pipeline/uvcvideo/uvcvideo.cpp       | 9 ++++++---\n>  src/libcamera/pipeline/vimc/vimc.cpp               | 9 ++++++---\n>  src/libcamera/pipeline_handler.cpp                 | 1 +\n>  src/qcam/main_window.cpp                           | 2 +-\n>  test/camera/capture.cpp                            | 2 +-\n>  test/camera/statemachine.cpp                       | 2 +-\n>  test/mapped-buffer.cpp                             | 2 +-\n>  19 files changed, 58 insertions(+), 35 deletions(-)\n>\n> diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h\n> index 326b14d0ca01..ef6113113b6c 100644\n> --- a/include/libcamera/camera.h\n> +++ b/include/libcamera/camera.h\n> @@ -116,7 +116,8 @@ private:\n>\n>         friend class FrameBufferAllocator;\n>         int exportFrameBuffers(Stream *stream,\n> -                              std::vector<std::unique_ptr<FrameBuffer>> *buffers);\n> +                              std::vector<std::unique_ptr<FrameBuffer>> *buffers,\n> +                              unsigned int count);\n>  };\n\nIn my humble opinion, giving some number a special meaning is not a good design.\nI would like to ask others' opinions.\nAlternative (better) design is change the type of count to std::optional.\n\n-Hiro\n\n>\n>  } /* namespace libcamera */\n> diff --git a/include/libcamera/framebuffer_allocator.h b/include/libcamera/framebuffer_allocator.h\n> index 0c85631a1da2..f1ae37288d50 100644\n> --- a/include/libcamera/framebuffer_allocator.h\n> +++ b/include/libcamera/framebuffer_allocator.h\n> @@ -25,7 +25,7 @@ public:\n>         FrameBufferAllocator(std::shared_ptr<Camera> camera);\n>         ~FrameBufferAllocator();\n>\n> -       int allocate(Stream *stream);\n> +       int allocate(Stream *stream, unsigned int count);\n>         int free(Stream *stream);\n>\n>         bool allocated() const { return !buffers_.empty(); }\n> diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h\n> index c6454db6b2c4..37c51f3f0604 100644\n> --- a/include/libcamera/internal/pipeline_handler.h\n> +++ b/include/libcamera/internal/pipeline_handler.h\n> @@ -76,7 +76,8 @@ public:\n>         virtual int configure(Camera *camera, CameraConfiguration *config) = 0;\n>\n>         virtual int exportFrameBuffers(Camera *camera, Stream *stream,\n> -                                      std::vector<std::unique_ptr<FrameBuffer>> *buffers) = 0;\n> +                                      std::vector<std::unique_ptr<FrameBuffer>> *buffers,\n> +                                      unsigned int count) = 0;\n>\n>         virtual int start(Camera *camera, const ControlList *controls) = 0;\n>         virtual void stop(Camera *camera) = 0;\n> diff --git a/src/cam/capture.cpp b/src/cam/capture.cpp\n> index 7b55fc677022..dc24b12f4d10 100644\n> --- a/src/cam/capture.cpp\n> +++ b/src/cam/capture.cpp\n> @@ -80,7 +80,7 @@ int Capture::capture(FrameBufferAllocator *allocator)\n>         /* Identify the stream with the least number of buffers. */\n>         unsigned int nbuffers = UINT_MAX;\n>         for (StreamConfiguration &cfg : *config_) {\n> -               ret = allocator->allocate(cfg.stream());\n> +               ret = allocator->allocate(cfg.stream(), 0);\n>                 if (ret < 0) {\n>                         std::cerr << \"Can't allocate buffers\" << std::endl;\n>                         return -ENOMEM;\n> diff --git a/src/lc-compliance/simple_capture.cpp b/src/lc-compliance/simple_capture.cpp\n> index 64e862a08e3a..42e4c9b1302d 100644\n> --- a/src/lc-compliance/simple_capture.cpp\n> +++ b/src/lc-compliance/simple_capture.cpp\n> @@ -39,10 +39,10 @@ Results::Result SimpleCapture::configure(StreamRole role)\n>         return { Results::Pass, \"Configure camera\" };\n>  }\n>\n> -Results::Result SimpleCapture::start()\n> +Results::Result SimpleCapture::start(unsigned int numBuffers)\n>  {\n>         Stream *stream = config_->at(0).stream();\n> -       if (allocator_->allocate(stream) < 0)\n> +       if (allocator_->allocate(stream, numBuffers) < 0)\n>                 return { Results::Fail, \"Failed to allocate buffers\" };\n>\n>         if (camera_->start())\n> @@ -73,7 +73,7 @@ SimpleCaptureBalanced::SimpleCaptureBalanced(std::shared_ptr<Camera> camera)\n>\n>  Results::Result SimpleCaptureBalanced::capture(unsigned int numRequests)\n>  {\n> -       Results::Result ret = start();\n> +       Results::Result ret = start(0);\n>         if (ret.first != Results::Pass)\n>                 return ret;\n>\n> @@ -161,7 +161,7 @@ SimpleCaptureUnbalanced::SimpleCaptureUnbalanced(std::shared_ptr<Camera> camera)\n>\n>  Results::Result SimpleCaptureUnbalanced::capture(unsigned int numRequests)\n>  {\n> -       Results::Result ret = start();\n> +       Results::Result ret = start(0);\n>         if (ret.first != Results::Pass)\n>                 return ret;\n>\n> diff --git a/src/lc-compliance/simple_capture.h b/src/lc-compliance/simple_capture.h\n> index d9de53fb63a3..2b1493ecaf96 100644\n> --- a/src/lc-compliance/simple_capture.h\n> +++ b/src/lc-compliance/simple_capture.h\n> @@ -23,7 +23,7 @@ protected:\n>         SimpleCapture(std::shared_ptr<libcamera::Camera> camera);\n>         virtual ~SimpleCapture();\n>\n> -       Results::Result start();\n> +       Results::Result start(unsigned int numBuffers);\n>         void stop();\n>\n>         virtual void requestComplete(libcamera::Request *request) = 0;\n> diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\n> index 763f3b9926fd..7df110ee2f52 100644\n> --- a/src/libcamera/camera.cpp\n> +++ b/src/libcamera/camera.cpp\n> @@ -657,7 +657,8 @@ void Camera::disconnect()\n>  }\n>\n>  int Camera::exportFrameBuffers(Stream *stream,\n> -                              std::vector<std::unique_ptr<FrameBuffer>> *buffers)\n> +                              std::vector<std::unique_ptr<FrameBuffer>> *buffers,\n> +                              unsigned int count)\n>  {\n>         Private *const d = LIBCAMERA_D_PTR();\n>\n> @@ -673,7 +674,7 @@ int Camera::exportFrameBuffers(Stream *stream,\n>\n>         return d->pipe_->invokeMethod(&PipelineHandler::exportFrameBuffers,\n>                                       ConnectionTypeBlocking, this, stream,\n> -                                     buffers);\n> +                                     buffers, count);\n>  }\n>\n>  /**\n> diff --git a/src/libcamera/framebuffer_allocator.cpp b/src/libcamera/framebuffer_allocator.cpp\n> index 2fbba37a1b0b..6b07203017cd 100644\n> --- a/src/libcamera/framebuffer_allocator.cpp\n> +++ b/src/libcamera/framebuffer_allocator.cpp\n> @@ -70,6 +70,7 @@ FrameBufferAllocator::~FrameBufferAllocator()\n>  /**\n>   * \\brief Allocate buffers for a configured stream\n>   * \\param[in] stream The stream to allocate buffers for\n> + * \\param[in] count The amount of buffers to allocate\n>   *\n>   * Allocate buffers suitable for capturing frames from the \\a stream. The Camera\n>   * shall have been previously configured with Camera::configure() and shall be\n> @@ -85,14 +86,14 @@ FrameBufferAllocator::~FrameBufferAllocator()\n>   * not part of the active camera configuration\n>   * \\retval -EBUSY Buffers are already allocated for the \\a stream\n>   */\n> -int FrameBufferAllocator::allocate(Stream *stream)\n> +int FrameBufferAllocator::allocate(Stream *stream, unsigned int count)\n>  {\n>         if (buffers_.count(stream)) {\n>                 LOG(Allocator, Error) << \"Buffers already allocated for stream\";\n>                 return -EBUSY;\n>         }\n>\n> -       int ret = camera_->exportFrameBuffers(stream, &buffers_[stream]);\n> +       int ret = camera_->exportFrameBuffers(stream, &buffers_[stream], count);\n>         if (ret == -EINVAL)\n>                 LOG(Allocator, Error)\n>                         << \"Stream is not part of \" << camera_->id()\n> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> index 519cad4f8148..7a44900b9fbc 100644\n> --- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n> +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> @@ -131,7 +131,8 @@ public:\n>         int configure(Camera *camera, CameraConfiguration *config) override;\n>\n>         int exportFrameBuffers(Camera *camera, Stream *stream,\n> -                              std::vector<std::unique_ptr<FrameBuffer>> *buffers) override;\n> +                              std::vector<std::unique_ptr<FrameBuffer>> *buffers,\n> +                              unsigned int count) override;\n>\n>         int start(Camera *camera, const ControlList *controls) override;\n>         void stop(Camera *camera) override;\n> @@ -641,10 +642,12 @@ int PipelineHandlerIPU3::configure(Camera *camera, CameraConfiguration *c)\n>  }\n>\n>  int PipelineHandlerIPU3::exportFrameBuffers(Camera *camera, Stream *stream,\n> -                                           std::vector<std::unique_ptr<FrameBuffer>> *buffers)\n> +                                           std::vector<std::unique_ptr<FrameBuffer>> *buffers,\n> +                                           unsigned int count)\n>  {\n>         IPU3CameraData *data = cameraData(camera);\n> -       unsigned int count = stream->configuration().bufferCount;\n> +       if (!count)\n> +               count = stream->configuration().bufferCount;\n>\n>         if (stream == &data->outStream_)\n>                 return data->imgu_->output_->exportBuffers(count, buffers);\n> diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> index f22e286ed87a..3ab27123b1ac 100644\n> --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> @@ -250,7 +250,8 @@ public:\n>         int configure(Camera *camera, CameraConfiguration *config) override;\n>\n>         int exportFrameBuffers(Camera *camera, Stream *stream,\n> -                              std::vector<std::unique_ptr<FrameBuffer>> *buffers) override;\n> +                              std::vector<std::unique_ptr<FrameBuffer>> *buffers,\n> +                              unsigned int count) override;\n>\n>         int start(Camera *camera, const ControlList *controls) override;\n>         void stop(Camera *camera) override;\n> @@ -786,10 +787,12 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config)\n>  }\n>\n>  int PipelineHandlerRPi::exportFrameBuffers([[maybe_unused]] Camera *camera, Stream *stream,\n> -                                          std::vector<std::unique_ptr<FrameBuffer>> *buffers)\n> +                                          std::vector<std::unique_ptr<FrameBuffer>> *buffers,\n> +                                          unsigned int count)\n>  {\n>         RPi::Stream *s = static_cast<RPi::Stream *>(stream);\n> -       unsigned int count = stream->configuration().bufferCount;\n> +       if (!count)\n> +               count = stream->configuration().bufferCount;\n>         int ret = s->dev()->exportBuffers(count, buffers);\n>\n>         s->setExportedBuffers(buffers);\n> diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> index 549f4a4e61a8..4cc3c7739251 100644\n> --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> @@ -140,7 +140,8 @@ public:\n>         int configure(Camera *camera, CameraConfiguration *config) override;\n>\n>         int exportFrameBuffers(Camera *camera, Stream *stream,\n> -                              std::vector<std::unique_ptr<FrameBuffer>> *buffers) override;\n> +                              std::vector<std::unique_ptr<FrameBuffer>> *buffers,\n> +                              unsigned int count) override;\n>\n>         int start(Camera *camera, const ControlList *controls) override;\n>         void stop(Camera *camera) override;\n> @@ -666,10 +667,12 @@ int PipelineHandlerRkISP1::configure(Camera *camera, CameraConfiguration *c)\n>  }\n>\n>  int PipelineHandlerRkISP1::exportFrameBuffers([[maybe_unused]] Camera *camera, Stream *stream,\n> -                                             std::vector<std::unique_ptr<FrameBuffer>> *buffers)\n> +                                             std::vector<std::unique_ptr<FrameBuffer>> *buffers,\n> +                                             unsigned int count)\n>  {\n>         RkISP1CameraData *data = cameraData(camera);\n> -       unsigned int count = stream->configuration().bufferCount;\n> +       if (!count)\n> +               count = stream->configuration().bufferCount;\n>\n>         if (stream == &data->mainPathStream_)\n>                 return mainPath_.exportBuffers(count, buffers);\n> diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp\n> index f6095d38e97a..e9b0698813fc 100644\n> --- a/src/libcamera/pipeline/simple/simple.cpp\n> +++ b/src/libcamera/pipeline/simple/simple.cpp\n> @@ -223,7 +223,8 @@ public:\n>         int configure(Camera *camera, CameraConfiguration *config) override;\n>\n>         int exportFrameBuffers(Camera *camera, Stream *stream,\n> -                              std::vector<std::unique_ptr<FrameBuffer>> *buffers) override;\n> +                              std::vector<std::unique_ptr<FrameBuffer>> *buffers,\n> +                              unsigned int count) override;\n>\n>         int start(Camera *camera, const ControlList *controls) override;\n>         void stop(Camera *camera) override;\n> @@ -762,10 +763,12 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c)\n>  }\n>\n>  int SimplePipelineHandler::exportFrameBuffers(Camera *camera, Stream *stream,\n> -                                             std::vector<std::unique_ptr<FrameBuffer>> *buffers)\n> +                                             std::vector<std::unique_ptr<FrameBuffer>> *buffers,\n> +                                             unsigned int count)\n>  {\n>         SimpleCameraData *data = cameraData(camera);\n> -       unsigned int count = stream->configuration().bufferCount;\n> +       if (!count)\n> +               count = stream->configuration().bufferCount;\n>\n>         /*\n>          * Export buffers on the converter or capture video node, depending on\n> diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n> index b6c6ade5ebaf..298e7031d23b 100644\n> --- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n> +++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n> @@ -70,7 +70,8 @@ public:\n>         int configure(Camera *camera, CameraConfiguration *config) override;\n>\n>         int exportFrameBuffers(Camera *camera, Stream *stream,\n> -                              std::vector<std::unique_ptr<FrameBuffer>> *buffers) override;\n> +                              std::vector<std::unique_ptr<FrameBuffer>> *buffers,\n> +                              unsigned int count) override;\n>\n>         int start(Camera *camera, const ControlList *controls) override;\n>         void stop(Camera *camera) override;\n> @@ -224,10 +225,12 @@ int PipelineHandlerUVC::configure(Camera *camera, CameraConfiguration *config)\n>  }\n>\n>  int PipelineHandlerUVC::exportFrameBuffers(Camera *camera, Stream *stream,\n> -                                          std::vector<std::unique_ptr<FrameBuffer>> *buffers)\n> +                                          std::vector<std::unique_ptr<FrameBuffer>> *buffers,\n> +                                          unsigned int count)\n>  {\n>         UVCCameraData *data = cameraData(camera);\n> -       unsigned int count = stream->configuration().bufferCount;\n> +       if (!count)\n> +               count = stream->configuration().bufferCount;\n>\n>         return data->video_->exportBuffers(count, buffers);\n>  }\n> diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp\n> index 8f5f4ba30953..2f889347b624 100644\n> --- a/src/libcamera/pipeline/vimc/vimc.cpp\n> +++ b/src/libcamera/pipeline/vimc/vimc.cpp\n> @@ -84,7 +84,8 @@ public:\n>         int configure(Camera *camera, CameraConfiguration *config) override;\n>\n>         int exportFrameBuffers(Camera *camera, Stream *stream,\n> -                              std::vector<std::unique_ptr<FrameBuffer>> *buffers) override;\n> +                              std::vector<std::unique_ptr<FrameBuffer>> *buffers,\n> +                              unsigned int count) override;\n>\n>         int start(Camera *camera, const ControlList *controls) override;\n>         void stop(Camera *camera) override;\n> @@ -299,10 +300,12 @@ int PipelineHandlerVimc::configure(Camera *camera, CameraConfiguration *config)\n>  }\n>\n>  int PipelineHandlerVimc::exportFrameBuffers(Camera *camera, Stream *stream,\n> -                                           std::vector<std::unique_ptr<FrameBuffer>> *buffers)\n> +                                           std::vector<std::unique_ptr<FrameBuffer>> *buffers,\n> +                                           unsigned int count)\n>  {\n>         VimcCameraData *data = cameraData(camera);\n> -       unsigned int count = stream->configuration().bufferCount;\n> +       if (!count)\n> +               count = stream->configuration().bufferCount;\n>\n>         return data->video_->exportBuffers(count, buffers);\n>  }\n> diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp\n> index 3b3150bdbbf7..ab5f21a01438 100644\n> --- a/src/libcamera/pipeline_handler.cpp\n> +++ b/src/libcamera/pipeline_handler.cpp\n> @@ -323,6 +323,7 @@ const ControlList &PipelineHandler::properties(const Camera *camera) const\n>   * \\param[in] camera The camera\n>   * \\param[in] stream The stream to allocate buffers for\n>   * \\param[out] buffers Array of buffers successfully allocated\n> + * \\param[in] count The amount of buffers to allocate\n>   *\n>   * This method allocates buffers for the \\a stream from the devices associated\n>   * with the stream in the corresponding pipeline handler. Those buffers shall be\n> diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp\n> index 39d034de6bb2..4e1dbb0656c8 100644\n> --- a/src/qcam/main_window.cpp\n> +++ b/src/qcam/main_window.cpp\n> @@ -463,7 +463,7 @@ int MainWindow::startCapture()\n>         for (StreamConfiguration &config : *config_) {\n>                 Stream *stream = config.stream();\n>\n> -               ret = allocator_->allocate(stream);\n> +               ret = allocator_->allocate(stream, 0);\n>                 if (ret < 0) {\n>                         qWarning() << \"Failed to allocate capture buffers\";\n>                         goto error;\n> diff --git a/test/camera/capture.cpp b/test/camera/capture.cpp\n> index c4bc21100777..6cbca15b30bc 100644\n> --- a/test/camera/capture.cpp\n> +++ b/test/camera/capture.cpp\n> @@ -96,7 +96,7 @@ protected:\n>\n>                 Stream *stream = cfg.stream();\n>\n> -               int ret = allocator_->allocate(stream);\n> +               int ret = allocator_->allocate(stream, 0);\n>                 if (ret < 0)\n>                         return TestFail;\n>\n> diff --git a/test/camera/statemachine.cpp b/test/camera/statemachine.cpp\n> index f0c3d7764027..9e076d05bc6f 100644\n> --- a/test/camera/statemachine.cpp\n> +++ b/test/camera/statemachine.cpp\n> @@ -118,7 +118,7 @@ protected:\n>                 /* Use internally allocated buffers. */\n>                 allocator_ = new FrameBufferAllocator(camera_);\n>                 Stream *stream = *camera_->streams().begin();\n> -               if (allocator_->allocate(stream) < 0)\n> +               if (allocator_->allocate(stream, 0) < 0)\n>                         return TestFail;\n>\n>                 if (camera_->start())\n> diff --git a/test/mapped-buffer.cpp b/test/mapped-buffer.cpp\n> index 5de8201e45f6..f5c2e2c0169a 100644\n> --- a/test/mapped-buffer.cpp\n> +++ b/test/mapped-buffer.cpp\n> @@ -54,7 +54,7 @@ protected:\n>\n>                 stream_ = cfg.stream();\n>\n> -               int ret = allocator_->allocate(stream_);\n> +               int ret = allocator_->allocate(stream_, 0);\n>                 if (ret < 0)\n>                         return TestFail;\n>\n> --\n> 2.31.1\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id B0E0CBD814\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 19 Apr 2021 05:56:47 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E8F41605AE;\n\tMon, 19 Apr 2021 07:56:46 +0200 (CEST)","from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com\n\t[IPv6:2a00:1450:4864:20::52d])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 478E560516\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 19 Apr 2021 07:56:45 +0200 (CEST)","by mail-ed1-x52d.google.com with SMTP id j7so2229536eds.8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 18 Apr 2021 22:56:45 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"QxXLfWz0\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc:content-transfer-encoding;\n\tbh=aoGSmZfUgE466wXhIkbrCvJY41Ps5g75AtQ+TucgMkg=;\n\tb=QxXLfWz0259oqbfr2be7fVgyjYa5kN2s8d2WZKSD/HsCxux/PHIxhOcYSLK+Tp4L1F\n\tsP5EtCQqkvrZzW5Uu7Tog2g5n93oo/O4kjoANM78x6WV6rQr26CZo9qWkeWb2WQ2Lewh\n\tvHqcLkj4OV9juq9H3vW0HBcR6kB2KMb3wClBc=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc:content-transfer-encoding;\n\tbh=aoGSmZfUgE466wXhIkbrCvJY41Ps5g75AtQ+TucgMkg=;\n\tb=hiZqt/B7sU3dqF4+el8L/IrSfWrZqEcFsfYiZS2YcZp2fpUciIOa7UR8mP0SHqc5Uz\n\tC5If11f6BsTY5o44IqBksO5HXtNL+A6BcM2t7+btGNI2j3mqVIw/KKKe8JPPLs+MGoGu\n\tk6aTAV/SWzgUDBEuczlEw0xWNMkflgaQj8ZZqLrznP0p0vQ8eTq3EIQQaa5b4GM8uYQQ\n\tXI4w2lUg8B+q8LQyRJXdqfd9imWdlxh5T3K3vwnufHNG5w8zzaegmSQ61HcIyfu3zNFO\n\tjKK5qWPUtfuSwaVv0xeWO1UQxMlJKhYyf5Y63tvH54g6L1n8xC41aPc3FadOT00Kiv6D\n\t4VVw==","X-Gm-Message-State":"AOAM531XoZ5AMvs00zTc3xgkvkD54YXDC+3OFBjAB1QE6ntfi58gyq49\n\tj4YluHTXCRJ/dycSf+Kead3q5sF6YzfoDi2E7DEJfQ==","X-Google-Smtp-Source":"ABdhPJxQbk4vj+qF8AfWVlLpYFQcpiP5i7cMavSIZYve8opYJEJST8CZH905qI3u1Rz3VdyjJ9z2JG4N0vUCPJLxiNY=","X-Received":"by 2002:a05:6402:5211:: with SMTP id\n\ts17mr23724408edd.327.1618811804703; \n\tSun, 18 Apr 2021 22:56:44 -0700 (PDT)","MIME-Version":"1.0","References":"<20210416222830.335755-1-nfraprado@collabora.com>\n\t<20210416222830.335755-2-nfraprado@collabora.com>","In-Reply-To":"<20210416222830.335755-2-nfraprado@collabora.com>","From":"Hirokazu Honda <hiroh@chromium.org>","Date":"Mon, 19 Apr 2021 14:56:33 +0900","Message-ID":"<CAO5uPHM10PBrUKMB2HBHA=RxuovCLYXL747O=+R7TPWooUbW7Q@mail.gmail.com>","To":"=?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= <nfraprado@collabora.com>","Subject":"Re: [libcamera-devel] [PATCH v2 1/2] libcamera:\n\tframebuffer_allocator: Make allocate() accept count","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","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>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":16340,"web_url":"https://patchwork.libcamera.org/comment/16340/","msgid":"<YH0eP0R2qFfQUzEN@pendragon.ideasonboard.com>","date":"2021-04-19T06:07:59","subject":"Re: [libcamera-devel] [PATCH v2 1/2] libcamera:\n\tframebuffer_allocator: Make allocate() accept count","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hello,\n\nOn Mon, Apr 19, 2021 at 02:56:33PM +0900, Hirokazu Honda wrote:\n> Hi Nicolas, thanks for the patch.\n> \n> On Sat, Apr 17, 2021 at 7:29 AM Nícolas F. R. A. Prado wrote:\n> >\n> > Add a 'count' argument to FrameBufferAllocator::allocate() so that a\n> > custom amount of buffers can be allocated. If 0 is passed, the pipeline\n> > handler allocates the default amount, which is the configured\n> > bufferCount.\n> >\n> > Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>\n> > ---\n> >  include/libcamera/camera.h                         | 3 ++-\n> >  include/libcamera/framebuffer_allocator.h          | 2 +-\n> >  include/libcamera/internal/pipeline_handler.h      | 3 ++-\n> >  src/cam/capture.cpp                                | 2 +-\n> >  src/lc-compliance/simple_capture.cpp               | 8 ++++----\n> >  src/lc-compliance/simple_capture.h                 | 2 +-\n> >  src/libcamera/camera.cpp                           | 5 +++--\n> >  src/libcamera/framebuffer_allocator.cpp            | 5 +++--\n> >  src/libcamera/pipeline/ipu3/ipu3.cpp               | 9 ++++++---\n> >  src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 9 ++++++---\n> >  src/libcamera/pipeline/rkisp1/rkisp1.cpp           | 9 ++++++---\n> >  src/libcamera/pipeline/simple/simple.cpp           | 9 ++++++---\n> >  src/libcamera/pipeline/uvcvideo/uvcvideo.cpp       | 9 ++++++---\n> >  src/libcamera/pipeline/vimc/vimc.cpp               | 9 ++++++---\n> >  src/libcamera/pipeline_handler.cpp                 | 1 +\n> >  src/qcam/main_window.cpp                           | 2 +-\n> >  test/camera/capture.cpp                            | 2 +-\n> >  test/camera/statemachine.cpp                       | 2 +-\n> >  test/mapped-buffer.cpp                             | 2 +-\n> >  19 files changed, 58 insertions(+), 35 deletions(-)\n> >\n> > diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h\n> > index 326b14d0ca01..ef6113113b6c 100644\n> > --- a/include/libcamera/camera.h\n> > +++ b/include/libcamera/camera.h\n> > @@ -116,7 +116,8 @@ private:\n> >\n> >         friend class FrameBufferAllocator;\n> >         int exportFrameBuffers(Stream *stream,\n> > -                              std::vector<std::unique_ptr<FrameBuffer>> *buffers);\n> > +                              std::vector<std::unique_ptr<FrameBuffer>> *buffers,\n> > +                              unsigned int count);\n> >  };\n> \n> In my humble opinion, giving some number a special meaning is not a good design.\n> I would like to ask others' opinions.\n> Alternative (better) design is change the type of count to std::optional.\n\nstd::optional isn't an option, as it's a C++17 feature, and the public\nAPI has to stay compatible with C++14 to support Chromium (the browser,\nnot the OS).\n\nHow about making the buffer count mandatory, always passing a value\nexplicitly ?\n\n> >  } /* namespace libcamera */\n> > diff --git a/include/libcamera/framebuffer_allocator.h b/include/libcamera/framebuffer_allocator.h\n> > index 0c85631a1da2..f1ae37288d50 100644\n> > --- a/include/libcamera/framebuffer_allocator.h\n> > +++ b/include/libcamera/framebuffer_allocator.h\n> > @@ -25,7 +25,7 @@ public:\n> >         FrameBufferAllocator(std::shared_ptr<Camera> camera);\n> >         ~FrameBufferAllocator();\n> >\n> > -       int allocate(Stream *stream);\n> > +       int allocate(Stream *stream, unsigned int count);\n> >         int free(Stream *stream);\n> >\n> >         bool allocated() const { return !buffers_.empty(); }\n> > diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h\n> > index c6454db6b2c4..37c51f3f0604 100644\n> > --- a/include/libcamera/internal/pipeline_handler.h\n> > +++ b/include/libcamera/internal/pipeline_handler.h\n> > @@ -76,7 +76,8 @@ public:\n> >         virtual int configure(Camera *camera, CameraConfiguration *config) = 0;\n> >\n> >         virtual int exportFrameBuffers(Camera *camera, Stream *stream,\n> > -                                      std::vector<std::unique_ptr<FrameBuffer>> *buffers) = 0;\n> > +                                      std::vector<std::unique_ptr<FrameBuffer>> *buffers,\n> > +                                      unsigned int count) = 0;\n> >\n> >         virtual int start(Camera *camera, const ControlList *controls) = 0;\n> >         virtual void stop(Camera *camera) = 0;\n> > diff --git a/src/cam/capture.cpp b/src/cam/capture.cpp\n> > index 7b55fc677022..dc24b12f4d10 100644\n> > --- a/src/cam/capture.cpp\n> > +++ b/src/cam/capture.cpp\n> > @@ -80,7 +80,7 @@ int Capture::capture(FrameBufferAllocator *allocator)\n> >         /* Identify the stream with the least number of buffers. */\n> >         unsigned int nbuffers = UINT_MAX;\n> >         for (StreamConfiguration &cfg : *config_) {\n> > -               ret = allocator->allocate(cfg.stream());\n> > +               ret = allocator->allocate(cfg.stream(), 0);\n> >                 if (ret < 0) {\n> >                         std::cerr << \"Can't allocate buffers\" << std::endl;\n> >                         return -ENOMEM;\n> > diff --git a/src/lc-compliance/simple_capture.cpp b/src/lc-compliance/simple_capture.cpp\n> > index 64e862a08e3a..42e4c9b1302d 100644\n> > --- a/src/lc-compliance/simple_capture.cpp\n> > +++ b/src/lc-compliance/simple_capture.cpp\n> > @@ -39,10 +39,10 @@ Results::Result SimpleCapture::configure(StreamRole role)\n> >         return { Results::Pass, \"Configure camera\" };\n> >  }\n> >\n> > -Results::Result SimpleCapture::start()\n> > +Results::Result SimpleCapture::start(unsigned int numBuffers)\n> >  {\n> >         Stream *stream = config_->at(0).stream();\n> > -       if (allocator_->allocate(stream) < 0)\n> > +       if (allocator_->allocate(stream, numBuffers) < 0)\n> >                 return { Results::Fail, \"Failed to allocate buffers\" };\n> >\n> >         if (camera_->start())\n> > @@ -73,7 +73,7 @@ SimpleCaptureBalanced::SimpleCaptureBalanced(std::shared_ptr<Camera> camera)\n> >\n> >  Results::Result SimpleCaptureBalanced::capture(unsigned int numRequests)\n> >  {\n> > -       Results::Result ret = start();\n> > +       Results::Result ret = start(0);\n> >         if (ret.first != Results::Pass)\n> >                 return ret;\n> >\n> > @@ -161,7 +161,7 @@ SimpleCaptureUnbalanced::SimpleCaptureUnbalanced(std::shared_ptr<Camera> camera)\n> >\n> >  Results::Result SimpleCaptureUnbalanced::capture(unsigned int numRequests)\n> >  {\n> > -       Results::Result ret = start();\n> > +       Results::Result ret = start(0);\n> >         if (ret.first != Results::Pass)\n> >                 return ret;\n> >\n> > diff --git a/src/lc-compliance/simple_capture.h b/src/lc-compliance/simple_capture.h\n> > index d9de53fb63a3..2b1493ecaf96 100644\n> > --- a/src/lc-compliance/simple_capture.h\n> > +++ b/src/lc-compliance/simple_capture.h\n> > @@ -23,7 +23,7 @@ protected:\n> >         SimpleCapture(std::shared_ptr<libcamera::Camera> camera);\n> >         virtual ~SimpleCapture();\n> >\n> > -       Results::Result start();\n> > +       Results::Result start(unsigned int numBuffers);\n> >         void stop();\n> >\n> >         virtual void requestComplete(libcamera::Request *request) = 0;\n> > diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\n> > index 763f3b9926fd..7df110ee2f52 100644\n> > --- a/src/libcamera/camera.cpp\n> > +++ b/src/libcamera/camera.cpp\n> > @@ -657,7 +657,8 @@ void Camera::disconnect()\n> >  }\n> >\n> >  int Camera::exportFrameBuffers(Stream *stream,\n> > -                              std::vector<std::unique_ptr<FrameBuffer>> *buffers)\n> > +                              std::vector<std::unique_ptr<FrameBuffer>> *buffers,\n> > +                              unsigned int count)\n> >  {\n> >         Private *const d = LIBCAMERA_D_PTR();\n> >\n> > @@ -673,7 +674,7 @@ int Camera::exportFrameBuffers(Stream *stream,\n> >\n> >         return d->pipe_->invokeMethod(&PipelineHandler::exportFrameBuffers,\n> >                                       ConnectionTypeBlocking, this, stream,\n> > -                                     buffers);\n> > +                                     buffers, count);\n> >  }\n> >\n> >  /**\n> > diff --git a/src/libcamera/framebuffer_allocator.cpp b/src/libcamera/framebuffer_allocator.cpp\n> > index 2fbba37a1b0b..6b07203017cd 100644\n> > --- a/src/libcamera/framebuffer_allocator.cpp\n> > +++ b/src/libcamera/framebuffer_allocator.cpp\n> > @@ -70,6 +70,7 @@ FrameBufferAllocator::~FrameBufferAllocator()\n> >  /**\n> >   * \\brief Allocate buffers for a configured stream\n> >   * \\param[in] stream The stream to allocate buffers for\n> > + * \\param[in] count The amount of buffers to allocate\n> >   *\n> >   * Allocate buffers suitable for capturing frames from the \\a stream. The Camera\n> >   * shall have been previously configured with Camera::configure() and shall be\n> > @@ -85,14 +86,14 @@ FrameBufferAllocator::~FrameBufferAllocator()\n> >   * not part of the active camera configuration\n> >   * \\retval -EBUSY Buffers are already allocated for the \\a stream\n> >   */\n> > -int FrameBufferAllocator::allocate(Stream *stream)\n> > +int FrameBufferAllocator::allocate(Stream *stream, unsigned int count)\n> >  {\n> >         if (buffers_.count(stream)) {\n> >                 LOG(Allocator, Error) << \"Buffers already allocated for stream\";\n> >                 return -EBUSY;\n> >         }\n> >\n> > -       int ret = camera_->exportFrameBuffers(stream, &buffers_[stream]);\n> > +       int ret = camera_->exportFrameBuffers(stream, &buffers_[stream], count);\n> >         if (ret == -EINVAL)\n> >                 LOG(Allocator, Error)\n> >                         << \"Stream is not part of \" << camera_->id()\n> > diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> > index 519cad4f8148..7a44900b9fbc 100644\n> > --- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n> > +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> > @@ -131,7 +131,8 @@ public:\n> >         int configure(Camera *camera, CameraConfiguration *config) override;\n> >\n> >         int exportFrameBuffers(Camera *camera, Stream *stream,\n> > -                              std::vector<std::unique_ptr<FrameBuffer>> *buffers) override;\n> > +                              std::vector<std::unique_ptr<FrameBuffer>> *buffers,\n> > +                              unsigned int count) override;\n> >\n> >         int start(Camera *camera, const ControlList *controls) override;\n> >         void stop(Camera *camera) override;\n> > @@ -641,10 +642,12 @@ int PipelineHandlerIPU3::configure(Camera *camera, CameraConfiguration *c)\n> >  }\n> >\n> >  int PipelineHandlerIPU3::exportFrameBuffers(Camera *camera, Stream *stream,\n> > -                                           std::vector<std::unique_ptr<FrameBuffer>> *buffers)\n> > +                                           std::vector<std::unique_ptr<FrameBuffer>> *buffers,\n> > +                                           unsigned int count)\n> >  {\n> >         IPU3CameraData *data = cameraData(camera);\n> > -       unsigned int count = stream->configuration().bufferCount;\n> > +       if (!count)\n> > +               count = stream->configuration().bufferCount;\n> >\n> >         if (stream == &data->outStream_)\n> >                 return data->imgu_->output_->exportBuffers(count, buffers);\n> > diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> > index f22e286ed87a..3ab27123b1ac 100644\n> > --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> > +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> > @@ -250,7 +250,8 @@ public:\n> >         int configure(Camera *camera, CameraConfiguration *config) override;\n> >\n> >         int exportFrameBuffers(Camera *camera, Stream *stream,\n> > -                              std::vector<std::unique_ptr<FrameBuffer>> *buffers) override;\n> > +                              std::vector<std::unique_ptr<FrameBuffer>> *buffers,\n> > +                              unsigned int count) override;\n> >\n> >         int start(Camera *camera, const ControlList *controls) override;\n> >         void stop(Camera *camera) override;\n> > @@ -786,10 +787,12 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config)\n> >  }\n> >\n> >  int PipelineHandlerRPi::exportFrameBuffers([[maybe_unused]] Camera *camera, Stream *stream,\n> > -                                          std::vector<std::unique_ptr<FrameBuffer>> *buffers)\n> > +                                          std::vector<std::unique_ptr<FrameBuffer>> *buffers,\n> > +                                          unsigned int count)\n> >  {\n> >         RPi::Stream *s = static_cast<RPi::Stream *>(stream);\n> > -       unsigned int count = stream->configuration().bufferCount;\n> > +       if (!count)\n> > +               count = stream->configuration().bufferCount;\n> >         int ret = s->dev()->exportBuffers(count, buffers);\n> >\n> >         s->setExportedBuffers(buffers);\n> > diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> > index 549f4a4e61a8..4cc3c7739251 100644\n> > --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> > +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> > @@ -140,7 +140,8 @@ public:\n> >         int configure(Camera *camera, CameraConfiguration *config) override;\n> >\n> >         int exportFrameBuffers(Camera *camera, Stream *stream,\n> > -                              std::vector<std::unique_ptr<FrameBuffer>> *buffers) override;\n> > +                              std::vector<std::unique_ptr<FrameBuffer>> *buffers,\n> > +                              unsigned int count) override;\n> >\n> >         int start(Camera *camera, const ControlList *controls) override;\n> >         void stop(Camera *camera) override;\n> > @@ -666,10 +667,12 @@ int PipelineHandlerRkISP1::configure(Camera *camera, CameraConfiguration *c)\n> >  }\n> >\n> >  int PipelineHandlerRkISP1::exportFrameBuffers([[maybe_unused]] Camera *camera, Stream *stream,\n> > -                                             std::vector<std::unique_ptr<FrameBuffer>> *buffers)\n> > +                                             std::vector<std::unique_ptr<FrameBuffer>> *buffers,\n> > +                                             unsigned int count)\n> >  {\n> >         RkISP1CameraData *data = cameraData(camera);\n> > -       unsigned int count = stream->configuration().bufferCount;\n> > +       if (!count)\n> > +               count = stream->configuration().bufferCount;\n> >\n> >         if (stream == &data->mainPathStream_)\n> >                 return mainPath_.exportBuffers(count, buffers);\n> > diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp\n> > index f6095d38e97a..e9b0698813fc 100644\n> > --- a/src/libcamera/pipeline/simple/simple.cpp\n> > +++ b/src/libcamera/pipeline/simple/simple.cpp\n> > @@ -223,7 +223,8 @@ public:\n> >         int configure(Camera *camera, CameraConfiguration *config) override;\n> >\n> >         int exportFrameBuffers(Camera *camera, Stream *stream,\n> > -                              std::vector<std::unique_ptr<FrameBuffer>> *buffers) override;\n> > +                              std::vector<std::unique_ptr<FrameBuffer>> *buffers,\n> > +                              unsigned int count) override;\n> >\n> >         int start(Camera *camera, const ControlList *controls) override;\n> >         void stop(Camera *camera) override;\n> > @@ -762,10 +763,12 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c)\n> >  }\n> >\n> >  int SimplePipelineHandler::exportFrameBuffers(Camera *camera, Stream *stream,\n> > -                                             std::vector<std::unique_ptr<FrameBuffer>> *buffers)\n> > +                                             std::vector<std::unique_ptr<FrameBuffer>> *buffers,\n> > +                                             unsigned int count)\n> >  {\n> >         SimpleCameraData *data = cameraData(camera);\n> > -       unsigned int count = stream->configuration().bufferCount;\n> > +       if (!count)\n> > +               count = stream->configuration().bufferCount;\n> >\n> >         /*\n> >          * Export buffers on the converter or capture video node, depending on\n> > diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n> > index b6c6ade5ebaf..298e7031d23b 100644\n> > --- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n> > +++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n> > @@ -70,7 +70,8 @@ public:\n> >         int configure(Camera *camera, CameraConfiguration *config) override;\n> >\n> >         int exportFrameBuffers(Camera *camera, Stream *stream,\n> > -                              std::vector<std::unique_ptr<FrameBuffer>> *buffers) override;\n> > +                              std::vector<std::unique_ptr<FrameBuffer>> *buffers,\n> > +                              unsigned int count) override;\n> >\n> >         int start(Camera *camera, const ControlList *controls) override;\n> >         void stop(Camera *camera) override;\n> > @@ -224,10 +225,12 @@ int PipelineHandlerUVC::configure(Camera *camera, CameraConfiguration *config)\n> >  }\n> >\n> >  int PipelineHandlerUVC::exportFrameBuffers(Camera *camera, Stream *stream,\n> > -                                          std::vector<std::unique_ptr<FrameBuffer>> *buffers)\n> > +                                          std::vector<std::unique_ptr<FrameBuffer>> *buffers,\n> > +                                          unsigned int count)\n> >  {\n> >         UVCCameraData *data = cameraData(camera);\n> > -       unsigned int count = stream->configuration().bufferCount;\n> > +       if (!count)\n> > +               count = stream->configuration().bufferCount;\n> >\n> >         return data->video_->exportBuffers(count, buffers);\n> >  }\n> > diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp\n> > index 8f5f4ba30953..2f889347b624 100644\n> > --- a/src/libcamera/pipeline/vimc/vimc.cpp\n> > +++ b/src/libcamera/pipeline/vimc/vimc.cpp\n> > @@ -84,7 +84,8 @@ public:\n> >         int configure(Camera *camera, CameraConfiguration *config) override;\n> >\n> >         int exportFrameBuffers(Camera *camera, Stream *stream,\n> > -                              std::vector<std::unique_ptr<FrameBuffer>> *buffers) override;\n> > +                              std::vector<std::unique_ptr<FrameBuffer>> *buffers,\n> > +                              unsigned int count) override;\n> >\n> >         int start(Camera *camera, const ControlList *controls) override;\n> >         void stop(Camera *camera) override;\n> > @@ -299,10 +300,12 @@ int PipelineHandlerVimc::configure(Camera *camera, CameraConfiguration *config)\n> >  }\n> >\n> >  int PipelineHandlerVimc::exportFrameBuffers(Camera *camera, Stream *stream,\n> > -                                           std::vector<std::unique_ptr<FrameBuffer>> *buffers)\n> > +                                           std::vector<std::unique_ptr<FrameBuffer>> *buffers,\n> > +                                           unsigned int count)\n> >  {\n> >         VimcCameraData *data = cameraData(camera);\n> > -       unsigned int count = stream->configuration().bufferCount;\n> > +       if (!count)\n> > +               count = stream->configuration().bufferCount;\n> >\n> >         return data->video_->exportBuffers(count, buffers);\n> >  }\n> > diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp\n> > index 3b3150bdbbf7..ab5f21a01438 100644\n> > --- a/src/libcamera/pipeline_handler.cpp\n> > +++ b/src/libcamera/pipeline_handler.cpp\n> > @@ -323,6 +323,7 @@ const ControlList &PipelineHandler::properties(const Camera *camera) const\n> >   * \\param[in] camera The camera\n> >   * \\param[in] stream The stream to allocate buffers for\n> >   * \\param[out] buffers Array of buffers successfully allocated\n> > + * \\param[in] count The amount of buffers to allocate\n> >   *\n> >   * This method allocates buffers for the \\a stream from the devices associated\n> >   * with the stream in the corresponding pipeline handler. Those buffers shall be\n> > diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp\n> > index 39d034de6bb2..4e1dbb0656c8 100644\n> > --- a/src/qcam/main_window.cpp\n> > +++ b/src/qcam/main_window.cpp\n> > @@ -463,7 +463,7 @@ int MainWindow::startCapture()\n> >         for (StreamConfiguration &config : *config_) {\n> >                 Stream *stream = config.stream();\n> >\n> > -               ret = allocator_->allocate(stream);\n> > +               ret = allocator_->allocate(stream, 0);\n> >                 if (ret < 0) {\n> >                         qWarning() << \"Failed to allocate capture buffers\";\n> >                         goto error;\n> > diff --git a/test/camera/capture.cpp b/test/camera/capture.cpp\n> > index c4bc21100777..6cbca15b30bc 100644\n> > --- a/test/camera/capture.cpp\n> > +++ b/test/camera/capture.cpp\n> > @@ -96,7 +96,7 @@ protected:\n> >\n> >                 Stream *stream = cfg.stream();\n> >\n> > -               int ret = allocator_->allocate(stream);\n> > +               int ret = allocator_->allocate(stream, 0);\n> >                 if (ret < 0)\n> >                         return TestFail;\n> >\n> > diff --git a/test/camera/statemachine.cpp b/test/camera/statemachine.cpp\n> > index f0c3d7764027..9e076d05bc6f 100644\n> > --- a/test/camera/statemachine.cpp\n> > +++ b/test/camera/statemachine.cpp\n> > @@ -118,7 +118,7 @@ protected:\n> >                 /* Use internally allocated buffers. */\n> >                 allocator_ = new FrameBufferAllocator(camera_);\n> >                 Stream *stream = *camera_->streams().begin();\n> > -               if (allocator_->allocate(stream) < 0)\n> > +               if (allocator_->allocate(stream, 0) < 0)\n> >                         return TestFail;\n> >\n> >                 if (camera_->start())\n> > diff --git a/test/mapped-buffer.cpp b/test/mapped-buffer.cpp\n> > index 5de8201e45f6..f5c2e2c0169a 100644\n> > --- a/test/mapped-buffer.cpp\n> > +++ b/test/mapped-buffer.cpp\n> > @@ -54,7 +54,7 @@ protected:\n> >\n> >                 stream_ = cfg.stream();\n> >\n> > -               int ret = allocator_->allocate(stream_);\n> > +               int ret = allocator_->allocate(stream_, 0);\n> >                 if (ret < 0)\n> >                         return TestFail;\n> >","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 18DAEBD812\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 19 Apr 2021 06:08:06 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 288D7687EF;\n\tMon, 19 Apr 2021 08:08:05 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B0BDC60516\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 19 Apr 2021 08:08:03 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 0E343897;\n\tMon, 19 Apr 2021 08:08:03 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"TdhcubRt\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1618812483;\n\tbh=7+WvUEYmzeyqSUbBvlnfHcDWKUETZ4qW0zNz1NBoVpA=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=TdhcubRtvHViuADicBQce3eNv34PYcSYlQ6QaJOvFCU0+Cmfjiyo8IdynWlRB9Tfh\n\tyX4v/ISC9VIDv+jZNwfsRal1yivGQcl0c/vmazr6VCqTJYUxrQnQUNSFkQDPU3ZzLO\n\trqixrfh8eaHZ2IuhDpSnNneaGWf/mefHKkT692Qc=","Date":"Mon, 19 Apr 2021 09:07:59 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Hirokazu Honda <hiroh@chromium.org>","Message-ID":"<YH0eP0R2qFfQUzEN@pendragon.ideasonboard.com>","References":"<20210416222830.335755-1-nfraprado@collabora.com>\n\t<20210416222830.335755-2-nfraprado@collabora.com>\n\t<CAO5uPHM10PBrUKMB2HBHA=RxuovCLYXL747O=+R7TPWooUbW7Q@mail.gmail.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<CAO5uPHM10PBrUKMB2HBHA=RxuovCLYXL747O=+R7TPWooUbW7Q@mail.gmail.com>","Subject":"Re: [libcamera-devel] [PATCH v2 1/2] libcamera:\n\tframebuffer_allocator: Make allocate() accept count","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","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>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":16341,"web_url":"https://patchwork.libcamera.org/comment/16341/","msgid":"<CAO5uPHOOUa+uJZVHkDVxw6Nc0-sVQAkRfeRgY_vce0H81RtO5A@mail.gmail.com>","date":"2021-04-19T06:09:30","subject":"Re: [libcamera-devel] [PATCH v2 1/2] libcamera:\n\tframebuffer_allocator: Make allocate() accept count","submitter":{"id":63,"url":"https://patchwork.libcamera.org/api/people/63/","name":"Hirokazu Honda","email":"hiroh@chromium.org"},"content":"Hi Laurent,\n\nOn Mon, Apr 19, 2021 at 3:08 PM Laurent Pinchart\n<laurent.pinchart@ideasonboard.com> wrote:\n>\n> Hello,\n>\n> On Mon, Apr 19, 2021 at 02:56:33PM +0900, Hirokazu Honda wrote:\n> > Hi Nicolas, thanks for the patch.\n> >\n> > On Sat, Apr 17, 2021 at 7:29 AM Nícolas F. R. A. Prado wrote:\n> > >\n> > > Add a 'count' argument to FrameBufferAllocator::allocate() so that a\n> > > custom amount of buffers can be allocated. If 0 is passed, the pipeline\n> > > handler allocates the default amount, which is the configured\n> > > bufferCount.\n> > >\n> > > Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>\n> > > ---\n> > >  include/libcamera/camera.h                         | 3 ++-\n> > >  include/libcamera/framebuffer_allocator.h          | 2 +-\n> > >  include/libcamera/internal/pipeline_handler.h      | 3 ++-\n> > >  src/cam/capture.cpp                                | 2 +-\n> > >  src/lc-compliance/simple_capture.cpp               | 8 ++++----\n> > >  src/lc-compliance/simple_capture.h                 | 2 +-\n> > >  src/libcamera/camera.cpp                           | 5 +++--\n> > >  src/libcamera/framebuffer_allocator.cpp            | 5 +++--\n> > >  src/libcamera/pipeline/ipu3/ipu3.cpp               | 9 ++++++---\n> > >  src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 9 ++++++---\n> > >  src/libcamera/pipeline/rkisp1/rkisp1.cpp           | 9 ++++++---\n> > >  src/libcamera/pipeline/simple/simple.cpp           | 9 ++++++---\n> > >  src/libcamera/pipeline/uvcvideo/uvcvideo.cpp       | 9 ++++++---\n> > >  src/libcamera/pipeline/vimc/vimc.cpp               | 9 ++++++---\n> > >  src/libcamera/pipeline_handler.cpp                 | 1 +\n> > >  src/qcam/main_window.cpp                           | 2 +-\n> > >  test/camera/capture.cpp                            | 2 +-\n> > >  test/camera/statemachine.cpp                       | 2 +-\n> > >  test/mapped-buffer.cpp                             | 2 +-\n> > >  19 files changed, 58 insertions(+), 35 deletions(-)\n> > >\n> > > diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h\n> > > index 326b14d0ca01..ef6113113b6c 100644\n> > > --- a/include/libcamera/camera.h\n> > > +++ b/include/libcamera/camera.h\n> > > @@ -116,7 +116,8 @@ private:\n> > >\n> > >         friend class FrameBufferAllocator;\n> > >         int exportFrameBuffers(Stream *stream,\n> > > -                              std::vector<std::unique_ptr<FrameBuffer>> *buffers);\n> > > +                              std::vector<std::unique_ptr<FrameBuffer>> *buffers,\n> > > +                              unsigned int count);\n> > >  };\n> >\n> > In my humble opinion, giving some number a special meaning is not a good design.\n> > I would like to ask others' opinions.\n> > Alternative (better) design is change the type of count to std::optional.\n>\n> std::optional isn't an option, as it's a C++17 feature, and the public\n> API has to stay compatible with C++14 to support Chromium (the browser,\n> not the OS).\n>\n> How about making the buffer count mandatory, always passing a value\n> explicitly ?\n>\n\nI got it. It sounds good to me.\n\n> > >  } /* namespace libcamera */\n> > > diff --git a/include/libcamera/framebuffer_allocator.h b/include/libcamera/framebuffer_allocator.h\n> > > index 0c85631a1da2..f1ae37288d50 100644\n> > > --- a/include/libcamera/framebuffer_allocator.h\n> > > +++ b/include/libcamera/framebuffer_allocator.h\n> > > @@ -25,7 +25,7 @@ public:\n> > >         FrameBufferAllocator(std::shared_ptr<Camera> camera);\n> > >         ~FrameBufferAllocator();\n> > >\n> > > -       int allocate(Stream *stream);\n> > > +       int allocate(Stream *stream, unsigned int count);\n> > >         int free(Stream *stream);\n> > >\n> > >         bool allocated() const { return !buffers_.empty(); }\n> > > diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h\n> > > index c6454db6b2c4..37c51f3f0604 100644\n> > > --- a/include/libcamera/internal/pipeline_handler.h\n> > > +++ b/include/libcamera/internal/pipeline_handler.h\n> > > @@ -76,7 +76,8 @@ public:\n> > >         virtual int configure(Camera *camera, CameraConfiguration *config) = 0;\n> > >\n> > >         virtual int exportFrameBuffers(Camera *camera, Stream *stream,\n> > > -                                      std::vector<std::unique_ptr<FrameBuffer>> *buffers) = 0;\n> > > +                                      std::vector<std::unique_ptr<FrameBuffer>> *buffers,\n> > > +                                      unsigned int count) = 0;\n> > >\n> > >         virtual int start(Camera *camera, const ControlList *controls) = 0;\n> > >         virtual void stop(Camera *camera) = 0;\n> > > diff --git a/src/cam/capture.cpp b/src/cam/capture.cpp\n> > > index 7b55fc677022..dc24b12f4d10 100644\n> > > --- a/src/cam/capture.cpp\n> > > +++ b/src/cam/capture.cpp\n> > > @@ -80,7 +80,7 @@ int Capture::capture(FrameBufferAllocator *allocator)\n> > >         /* Identify the stream with the least number of buffers. */\n> > >         unsigned int nbuffers = UINT_MAX;\n> > >         for (StreamConfiguration &cfg : *config_) {\n> > > -               ret = allocator->allocate(cfg.stream());\n> > > +               ret = allocator->allocate(cfg.stream(), 0);\n> > >                 if (ret < 0) {\n> > >                         std::cerr << \"Can't allocate buffers\" << std::endl;\n> > >                         return -ENOMEM;\n> > > diff --git a/src/lc-compliance/simple_capture.cpp b/src/lc-compliance/simple_capture.cpp\n> > > index 64e862a08e3a..42e4c9b1302d 100644\n> > > --- a/src/lc-compliance/simple_capture.cpp\n> > > +++ b/src/lc-compliance/simple_capture.cpp\n> > > @@ -39,10 +39,10 @@ Results::Result SimpleCapture::configure(StreamRole role)\n> > >         return { Results::Pass, \"Configure camera\" };\n> > >  }\n> > >\n> > > -Results::Result SimpleCapture::start()\n> > > +Results::Result SimpleCapture::start(unsigned int numBuffers)\n> > >  {\n> > >         Stream *stream = config_->at(0).stream();\n> > > -       if (allocator_->allocate(stream) < 0)\n> > > +       if (allocator_->allocate(stream, numBuffers) < 0)\n> > >                 return { Results::Fail, \"Failed to allocate buffers\" };\n> > >\n> > >         if (camera_->start())\n> > > @@ -73,7 +73,7 @@ SimpleCaptureBalanced::SimpleCaptureBalanced(std::shared_ptr<Camera> camera)\n> > >\n> > >  Results::Result SimpleCaptureBalanced::capture(unsigned int numRequests)\n> > >  {\n> > > -       Results::Result ret = start();\n> > > +       Results::Result ret = start(0);\n> > >         if (ret.first != Results::Pass)\n> > >                 return ret;\n> > >\n> > > @@ -161,7 +161,7 @@ SimpleCaptureUnbalanced::SimpleCaptureUnbalanced(std::shared_ptr<Camera> camera)\n> > >\n> > >  Results::Result SimpleCaptureUnbalanced::capture(unsigned int numRequests)\n> > >  {\n> > > -       Results::Result ret = start();\n> > > +       Results::Result ret = start(0);\n> > >         if (ret.first != Results::Pass)\n> > >                 return ret;\n> > >\n> > > diff --git a/src/lc-compliance/simple_capture.h b/src/lc-compliance/simple_capture.h\n> > > index d9de53fb63a3..2b1493ecaf96 100644\n> > > --- a/src/lc-compliance/simple_capture.h\n> > > +++ b/src/lc-compliance/simple_capture.h\n> > > @@ -23,7 +23,7 @@ protected:\n> > >         SimpleCapture(std::shared_ptr<libcamera::Camera> camera);\n> > >         virtual ~SimpleCapture();\n> > >\n> > > -       Results::Result start();\n> > > +       Results::Result start(unsigned int numBuffers);\n> > >         void stop();\n> > >\n> > >         virtual void requestComplete(libcamera::Request *request) = 0;\n> > > diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\n> > > index 763f3b9926fd..7df110ee2f52 100644\n> > > --- a/src/libcamera/camera.cpp\n> > > +++ b/src/libcamera/camera.cpp\n> > > @@ -657,7 +657,8 @@ void Camera::disconnect()\n> > >  }\n> > >\n> > >  int Camera::exportFrameBuffers(Stream *stream,\n> > > -                              std::vector<std::unique_ptr<FrameBuffer>> *buffers)\n> > > +                              std::vector<std::unique_ptr<FrameBuffer>> *buffers,\n> > > +                              unsigned int count)\n> > >  {\n> > >         Private *const d = LIBCAMERA_D_PTR();\n> > >\n> > > @@ -673,7 +674,7 @@ int Camera::exportFrameBuffers(Stream *stream,\n> > >\n> > >         return d->pipe_->invokeMethod(&PipelineHandler::exportFrameBuffers,\n> > >                                       ConnectionTypeBlocking, this, stream,\n> > > -                                     buffers);\n> > > +                                     buffers, count);\n> > >  }\n> > >\n> > >  /**\n> > > diff --git a/src/libcamera/framebuffer_allocator.cpp b/src/libcamera/framebuffer_allocator.cpp\n> > > index 2fbba37a1b0b..6b07203017cd 100644\n> > > --- a/src/libcamera/framebuffer_allocator.cpp\n> > > +++ b/src/libcamera/framebuffer_allocator.cpp\n> > > @@ -70,6 +70,7 @@ FrameBufferAllocator::~FrameBufferAllocator()\n> > >  /**\n> > >   * \\brief Allocate buffers for a configured stream\n> > >   * \\param[in] stream The stream to allocate buffers for\n> > > + * \\param[in] count The amount of buffers to allocate\n> > >   *\n> > >   * Allocate buffers suitable for capturing frames from the \\a stream. The Camera\n> > >   * shall have been previously configured with Camera::configure() and shall be\n> > > @@ -85,14 +86,14 @@ FrameBufferAllocator::~FrameBufferAllocator()\n> > >   * not part of the active camera configuration\n> > >   * \\retval -EBUSY Buffers are already allocated for the \\a stream\n> > >   */\n> > > -int FrameBufferAllocator::allocate(Stream *stream)\n> > > +int FrameBufferAllocator::allocate(Stream *stream, unsigned int count)\n> > >  {\n> > >         if (buffers_.count(stream)) {\n> > >                 LOG(Allocator, Error) << \"Buffers already allocated for stream\";\n> > >                 return -EBUSY;\n> > >         }\n> > >\n> > > -       int ret = camera_->exportFrameBuffers(stream, &buffers_[stream]);\n> > > +       int ret = camera_->exportFrameBuffers(stream, &buffers_[stream], count);\n> > >         if (ret == -EINVAL)\n> > >                 LOG(Allocator, Error)\n> > >                         << \"Stream is not part of \" << camera_->id()\n> > > diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> > > index 519cad4f8148..7a44900b9fbc 100644\n> > > --- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n> > > +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> > > @@ -131,7 +131,8 @@ public:\n> > >         int configure(Camera *camera, CameraConfiguration *config) override;\n> > >\n> > >         int exportFrameBuffers(Camera *camera, Stream *stream,\n> > > -                              std::vector<std::unique_ptr<FrameBuffer>> *buffers) override;\n> > > +                              std::vector<std::unique_ptr<FrameBuffer>> *buffers,\n> > > +                              unsigned int count) override;\n> > >\n> > >         int start(Camera *camera, const ControlList *controls) override;\n> > >         void stop(Camera *camera) override;\n> > > @@ -641,10 +642,12 @@ int PipelineHandlerIPU3::configure(Camera *camera, CameraConfiguration *c)\n> > >  }\n> > >\n> > >  int PipelineHandlerIPU3::exportFrameBuffers(Camera *camera, Stream *stream,\n> > > -                                           std::vector<std::unique_ptr<FrameBuffer>> *buffers)\n> > > +                                           std::vector<std::unique_ptr<FrameBuffer>> *buffers,\n> > > +                                           unsigned int count)\n> > >  {\n> > >         IPU3CameraData *data = cameraData(camera);\n> > > -       unsigned int count = stream->configuration().bufferCount;\n> > > +       if (!count)\n> > > +               count = stream->configuration().bufferCount;\n> > >\n> > >         if (stream == &data->outStream_)\n> > >                 return data->imgu_->output_->exportBuffers(count, buffers);\n> > > diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> > > index f22e286ed87a..3ab27123b1ac 100644\n> > > --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> > > +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> > > @@ -250,7 +250,8 @@ public:\n> > >         int configure(Camera *camera, CameraConfiguration *config) override;\n> > >\n> > >         int exportFrameBuffers(Camera *camera, Stream *stream,\n> > > -                              std::vector<std::unique_ptr<FrameBuffer>> *buffers) override;\n> > > +                              std::vector<std::unique_ptr<FrameBuffer>> *buffers,\n> > > +                              unsigned int count) override;\n> > >\n> > >         int start(Camera *camera, const ControlList *controls) override;\n> > >         void stop(Camera *camera) override;\n> > > @@ -786,10 +787,12 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config)\n> > >  }\n> > >\n> > >  int PipelineHandlerRPi::exportFrameBuffers([[maybe_unused]] Camera *camera, Stream *stream,\n> > > -                                          std::vector<std::unique_ptr<FrameBuffer>> *buffers)\n> > > +                                          std::vector<std::unique_ptr<FrameBuffer>> *buffers,\n> > > +                                          unsigned int count)\n> > >  {\n> > >         RPi::Stream *s = static_cast<RPi::Stream *>(stream);\n> > > -       unsigned int count = stream->configuration().bufferCount;\n> > > +       if (!count)\n> > > +               count = stream->configuration().bufferCount;\n> > >         int ret = s->dev()->exportBuffers(count, buffers);\n> > >\n> > >         s->setExportedBuffers(buffers);\n> > > diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> > > index 549f4a4e61a8..4cc3c7739251 100644\n> > > --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> > > +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> > > @@ -140,7 +140,8 @@ public:\n> > >         int configure(Camera *camera, CameraConfiguration *config) override;\n> > >\n> > >         int exportFrameBuffers(Camera *camera, Stream *stream,\n> > > -                              std::vector<std::unique_ptr<FrameBuffer>> *buffers) override;\n> > > +                              std::vector<std::unique_ptr<FrameBuffer>> *buffers,\n> > > +                              unsigned int count) override;\n> > >\n> > >         int start(Camera *camera, const ControlList *controls) override;\n> > >         void stop(Camera *camera) override;\n> > > @@ -666,10 +667,12 @@ int PipelineHandlerRkISP1::configure(Camera *camera, CameraConfiguration *c)\n> > >  }\n> > >\n> > >  int PipelineHandlerRkISP1::exportFrameBuffers([[maybe_unused]] Camera *camera, Stream *stream,\n> > > -                                             std::vector<std::unique_ptr<FrameBuffer>> *buffers)\n> > > +                                             std::vector<std::unique_ptr<FrameBuffer>> *buffers,\n> > > +                                             unsigned int count)\n> > >  {\n> > >         RkISP1CameraData *data = cameraData(camera);\n> > > -       unsigned int count = stream->configuration().bufferCount;\n> > > +       if (!count)\n> > > +               count = stream->configuration().bufferCount;\n> > >\n> > >         if (stream == &data->mainPathStream_)\n> > >                 return mainPath_.exportBuffers(count, buffers);\n> > > diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp\n> > > index f6095d38e97a..e9b0698813fc 100644\n> > > --- a/src/libcamera/pipeline/simple/simple.cpp\n> > > +++ b/src/libcamera/pipeline/simple/simple.cpp\n> > > @@ -223,7 +223,8 @@ public:\n> > >         int configure(Camera *camera, CameraConfiguration *config) override;\n> > >\n> > >         int exportFrameBuffers(Camera *camera, Stream *stream,\n> > > -                              std::vector<std::unique_ptr<FrameBuffer>> *buffers) override;\n> > > +                              std::vector<std::unique_ptr<FrameBuffer>> *buffers,\n> > > +                              unsigned int count) override;\n> > >\n> > >         int start(Camera *camera, const ControlList *controls) override;\n> > >         void stop(Camera *camera) override;\n> > > @@ -762,10 +763,12 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c)\n> > >  }\n> > >\n> > >  int SimplePipelineHandler::exportFrameBuffers(Camera *camera, Stream *stream,\n> > > -                                             std::vector<std::unique_ptr<FrameBuffer>> *buffers)\n> > > +                                             std::vector<std::unique_ptr<FrameBuffer>> *buffers,\n> > > +                                             unsigned int count)\n> > >  {\n> > >         SimpleCameraData *data = cameraData(camera);\n> > > -       unsigned int count = stream->configuration().bufferCount;\n> > > +       if (!count)\n> > > +               count = stream->configuration().bufferCount;\n> > >\n> > >         /*\n> > >          * Export buffers on the converter or capture video node, depending on\n> > > diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n> > > index b6c6ade5ebaf..298e7031d23b 100644\n> > > --- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n> > > +++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n> > > @@ -70,7 +70,8 @@ public:\n> > >         int configure(Camera *camera, CameraConfiguration *config) override;\n> > >\n> > >         int exportFrameBuffers(Camera *camera, Stream *stream,\n> > > -                              std::vector<std::unique_ptr<FrameBuffer>> *buffers) override;\n> > > +                              std::vector<std::unique_ptr<FrameBuffer>> *buffers,\n> > > +                              unsigned int count) override;\n> > >\n> > >         int start(Camera *camera, const ControlList *controls) override;\n> > >         void stop(Camera *camera) override;\n> > > @@ -224,10 +225,12 @@ int PipelineHandlerUVC::configure(Camera *camera, CameraConfiguration *config)\n> > >  }\n> > >\n> > >  int PipelineHandlerUVC::exportFrameBuffers(Camera *camera, Stream *stream,\n> > > -                                          std::vector<std::unique_ptr<FrameBuffer>> *buffers)\n> > > +                                          std::vector<std::unique_ptr<FrameBuffer>> *buffers,\n> > > +                                          unsigned int count)\n> > >  {\n> > >         UVCCameraData *data = cameraData(camera);\n> > > -       unsigned int count = stream->configuration().bufferCount;\n> > > +       if (!count)\n> > > +               count = stream->configuration().bufferCount;\n> > >\n> > >         return data->video_->exportBuffers(count, buffers);\n> > >  }\n> > > diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp\n> > > index 8f5f4ba30953..2f889347b624 100644\n> > > --- a/src/libcamera/pipeline/vimc/vimc.cpp\n> > > +++ b/src/libcamera/pipeline/vimc/vimc.cpp\n> > > @@ -84,7 +84,8 @@ public:\n> > >         int configure(Camera *camera, CameraConfiguration *config) override;\n> > >\n> > >         int exportFrameBuffers(Camera *camera, Stream *stream,\n> > > -                              std::vector<std::unique_ptr<FrameBuffer>> *buffers) override;\n> > > +                              std::vector<std::unique_ptr<FrameBuffer>> *buffers,\n> > > +                              unsigned int count) override;\n> > >\n> > >         int start(Camera *camera, const ControlList *controls) override;\n> > >         void stop(Camera *camera) override;\n> > > @@ -299,10 +300,12 @@ int PipelineHandlerVimc::configure(Camera *camera, CameraConfiguration *config)\n> > >  }\n> > >\n> > >  int PipelineHandlerVimc::exportFrameBuffers(Camera *camera, Stream *stream,\n> > > -                                           std::vector<std::unique_ptr<FrameBuffer>> *buffers)\n> > > +                                           std::vector<std::unique_ptr<FrameBuffer>> *buffers,\n> > > +                                           unsigned int count)\n> > >  {\n> > >         VimcCameraData *data = cameraData(camera);\n> > > -       unsigned int count = stream->configuration().bufferCount;\n> > > +       if (!count)\n> > > +               count = stream->configuration().bufferCount;\n> > >\n> > >         return data->video_->exportBuffers(count, buffers);\n> > >  }\n> > > diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp\n> > > index 3b3150bdbbf7..ab5f21a01438 100644\n> > > --- a/src/libcamera/pipeline_handler.cpp\n> > > +++ b/src/libcamera/pipeline_handler.cpp\n> > > @@ -323,6 +323,7 @@ const ControlList &PipelineHandler::properties(const Camera *camera) const\n> > >   * \\param[in] camera The camera\n> > >   * \\param[in] stream The stream to allocate buffers for\n> > >   * \\param[out] buffers Array of buffers successfully allocated\n> > > + * \\param[in] count The amount of buffers to allocate\n> > >   *\n> > >   * This method allocates buffers for the \\a stream from the devices associated\n> > >   * with the stream in the corresponding pipeline handler. Those buffers shall be\n> > > diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp\n> > > index 39d034de6bb2..4e1dbb0656c8 100644\n> > > --- a/src/qcam/main_window.cpp\n> > > +++ b/src/qcam/main_window.cpp\n> > > @@ -463,7 +463,7 @@ int MainWindow::startCapture()\n> > >         for (StreamConfiguration &config : *config_) {\n> > >                 Stream *stream = config.stream();\n> > >\n> > > -               ret = allocator_->allocate(stream);\n> > > +               ret = allocator_->allocate(stream, 0);\n> > >                 if (ret < 0) {\n> > >                         qWarning() << \"Failed to allocate capture buffers\";\n> > >                         goto error;\n> > > diff --git a/test/camera/capture.cpp b/test/camera/capture.cpp\n> > > index c4bc21100777..6cbca15b30bc 100644\n> > > --- a/test/camera/capture.cpp\n> > > +++ b/test/camera/capture.cpp\n> > > @@ -96,7 +96,7 @@ protected:\n> > >\n> > >                 Stream *stream = cfg.stream();\n> > >\n> > > -               int ret = allocator_->allocate(stream);\n> > > +               int ret = allocator_->allocate(stream, 0);\n> > >                 if (ret < 0)\n> > >                         return TestFail;\n> > >\n> > > diff --git a/test/camera/statemachine.cpp b/test/camera/statemachine.cpp\n> > > index f0c3d7764027..9e076d05bc6f 100644\n> > > --- a/test/camera/statemachine.cpp\n> > > +++ b/test/camera/statemachine.cpp\n> > > @@ -118,7 +118,7 @@ protected:\n> > >                 /* Use internally allocated buffers. */\n> > >                 allocator_ = new FrameBufferAllocator(camera_);\n> > >                 Stream *stream = *camera_->streams().begin();\n> > > -               if (allocator_->allocate(stream) < 0)\n> > > +               if (allocator_->allocate(stream, 0) < 0)\n> > >                         return TestFail;\n> > >\n> > >                 if (camera_->start())\n> > > diff --git a/test/mapped-buffer.cpp b/test/mapped-buffer.cpp\n> > > index 5de8201e45f6..f5c2e2c0169a 100644\n> > > --- a/test/mapped-buffer.cpp\n> > > +++ b/test/mapped-buffer.cpp\n> > > @@ -54,7 +54,7 @@ protected:\n> > >\n> > >                 stream_ = cfg.stream();\n> > >\n> > > -               int ret = allocator_->allocate(stream_);\n> > > +               int ret = allocator_->allocate(stream_, 0);\n> > >                 if (ret < 0)\n> > >                         return TestFail;\n> > >\n>\n> --\n> Regards,\n>\n> Laurent Pinchart","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id AC166BD812\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 19 Apr 2021 06:09:42 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 68F9B687F3;\n\tMon, 19 Apr 2021 08:09:42 +0200 (CEST)","from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com\n\t[IPv6:2a00:1450:4864:20::52f])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A249860516\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 19 Apr 2021 08:09:41 +0200 (CEST)","by mail-ed1-x52f.google.com with SMTP id w18so39256899edc.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 18 Apr 2021 23:09:41 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"jLBg/1li\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc:content-transfer-encoding;\n\tbh=azY6hRMcnDMtZB7dGPowcmg1M2ckdSvXMveK8CkdNmA=;\n\tb=jLBg/1liI9kIyuhqQmo0DbxLS5vFjun5P6eMjGCp6K6yNI8LJ3D9lxRmENkB0K+MB2\n\t1UPzMrbwbKIDDMld2CjK8N1xpyQMa9kGovtqcQcXxlfYxOrHkQ058brsqbQ2xYuIQnpp\n\tiMpkbO+mKfDRxFfyuf7Zxfo6b+KRBZbZx2vbY=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc:content-transfer-encoding;\n\tbh=azY6hRMcnDMtZB7dGPowcmg1M2ckdSvXMveK8CkdNmA=;\n\tb=dsVoGYt0EFM+0x/7sxwj1Xm8emzkCTcX0JbFxF76w/QzZHDIT25V6Cj1Gv44gWWOMy\n\tgAGzgC98JRjARw9phV0gSpP3ySECOTPoa1SOeMQyKWkj7DMJvPlk2gZf3eIsWc2HMq2K\n\tZcS6J6N0cLGf49KyrZdFvfYfaPzpqAvo3QRY/dUvYuLWQDDWnMBpijh5UJSZb0/5mz5f\n\txL8+hfZw1Ni1AFBcBQ5GQ8/k26u/tq5tYDJWanaJI9QECCYNU2dhdIfRNQcb4X4vuRI+\n\teVJMNRkPGujlHZeNcFi99ADTdcnyPEB8AqXi0bG8orVCrll/WT+CWqw8vOa49U1vpJu7\n\tr9kg==","X-Gm-Message-State":"AOAM533TvOGHvRzFQeB8nBqazffOMY5a9iT+MYl9pIIiTedUZl54rFq2\n\t+5MiZKsrwPWcXmz3Gjh4Kui4tSXJYl1R6uCdzOWjVA==","X-Google-Smtp-Source":"ABdhPJy/vcqkViDAWkd+Lm2MoILmPDTYzz5M6lKqy4YGuQjaO448BEMoMiOssk/l9c+5SEs/B4xNLrYi5q804mWgTEA=","X-Received":"by 2002:a05:6402:51cd:: with SMTP id\n\tr13mr23602205edd.116.1618812581011; \n\tSun, 18 Apr 2021 23:09:41 -0700 (PDT)","MIME-Version":"1.0","References":"<20210416222830.335755-1-nfraprado@collabora.com>\n\t<20210416222830.335755-2-nfraprado@collabora.com>\n\t<CAO5uPHM10PBrUKMB2HBHA=RxuovCLYXL747O=+R7TPWooUbW7Q@mail.gmail.com>\n\t<YH0eP0R2qFfQUzEN@pendragon.ideasonboard.com>","In-Reply-To":"<YH0eP0R2qFfQUzEN@pendragon.ideasonboard.com>","From":"Hirokazu Honda <hiroh@chromium.org>","Date":"Mon, 19 Apr 2021 15:09:30 +0900","Message-ID":"<CAO5uPHOOUa+uJZVHkDVxw6Nc0-sVQAkRfeRgY_vce0H81RtO5A@mail.gmail.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v2 1/2] libcamera:\n\tframebuffer_allocator: Make allocate() accept count","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","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>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":16356,"web_url":"https://patchwork.libcamera.org/comment/16356/","msgid":"<CARQTMSMFW3H.2N672XOK7WEMX@notapiano>","date":"2021-04-19T13:43:40","subject":"Re: [libcamera-devel] [PATCH v2 1/2] libcamera:\n\tframebuffer_allocator: Make allocate() accept count","submitter":{"id":84,"url":"https://patchwork.libcamera.org/api/people/84/","name":"Nícolas F. R. A. Prado","email":"nfraprado@collabora.com"},"content":"Em 2021-04-19 03:07, Laurent Pinchart escreveu:\n\n> Hello,\n>\n> On Mon, Apr 19, 2021 at 02:56:33PM +0900, Hirokazu Honda wrote:\n> > Hi Nicolas, thanks for the patch.\n> > \n> > On Sat, Apr 17, 2021 at 7:29 AM Nícolas F. R. A. Prado wrote:\n> > >\n> > > Add a 'count' argument to FrameBufferAllocator::allocate() so that a\n> > > custom amount of buffers can be allocated. If 0 is passed, the pipeline\n> > > handler allocates the default amount, which is the configured\n> > > bufferCount.\n> > >\n> > > Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>\n> > > ---\n> > >  include/libcamera/camera.h                         | 3 ++-\n> > >  include/libcamera/framebuffer_allocator.h          | 2 +-\n> > >  include/libcamera/internal/pipeline_handler.h      | 3 ++-\n> > >  src/cam/capture.cpp                                | 2 +-\n> > >  src/lc-compliance/simple_capture.cpp               | 8 ++++----\n> > >  src/lc-compliance/simple_capture.h                 | 2 +-\n> > >  src/libcamera/camera.cpp                           | 5 +++--\n> > >  src/libcamera/framebuffer_allocator.cpp            | 5 +++--\n> > >  src/libcamera/pipeline/ipu3/ipu3.cpp               | 9 ++++++---\n> > >  src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 9 ++++++---\n> > >  src/libcamera/pipeline/rkisp1/rkisp1.cpp           | 9 ++++++---\n> > >  src/libcamera/pipeline/simple/simple.cpp           | 9 ++++++---\n> > >  src/libcamera/pipeline/uvcvideo/uvcvideo.cpp       | 9 ++++++---\n> > >  src/libcamera/pipeline/vimc/vimc.cpp               | 9 ++++++---\n> > >  src/libcamera/pipeline_handler.cpp                 | 1 +\n> > >  src/qcam/main_window.cpp                           | 2 +-\n> > >  test/camera/capture.cpp                            | 2 +-\n> > >  test/camera/statemachine.cpp                       | 2 +-\n> > >  test/mapped-buffer.cpp                             | 2 +-\n> > >  19 files changed, 58 insertions(+), 35 deletions(-)\n> > >\n> > > diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h\n> > > index 326b14d0ca01..ef6113113b6c 100644\n> > > --- a/include/libcamera/camera.h\n> > > +++ b/include/libcamera/camera.h\n> > > @@ -116,7 +116,8 @@ private:\n> > >\n> > >         friend class FrameBufferAllocator;\n> > >         int exportFrameBuffers(Stream *stream,\n> > > -                              std::vector<std::unique_ptr<FrameBuffer>> *buffers);\n> > > +                              std::vector<std::unique_ptr<FrameBuffer>> *buffers,\n> > > +                              unsigned int count);\n> > >  };\n> > \n> > In my humble opinion, giving some number a special meaning is not a good design.\n> > I would like to ask others' opinions.\n> > Alternative (better) design is change the type of count to std::optional.\n>\n> std::optional isn't an option, as it's a C++17 feature, and the public\n> API has to stay compatible with C++14 to support Chromium (the browser,\n> not the OS).\n>\n> How about making the buffer count mandatory, always passing a value\n> explicitly ?\n\nSounds good to me.\n\nGiven that this makes the configuration's bufferCount pointless, I should add a\npatch removing it in this series, right?\n\nThanks,\nNícolas","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 47A86BD814\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 19 Apr 2021 13:48:37 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 134E468839;\n\tMon, 19 Apr 2021 15:48:37 +0200 (CEST)","from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8D1F268824\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 19 Apr 2021 15:48:36 +0200 (CEST)","from [127.0.0.1] (localhost [127.0.0.1])\n\t(Authenticated sender: nfraprado) with ESMTPSA id EF0F61F41FAA"],"Mime-Version":"1.0","From":"=?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= <nfraprado@collabora.com>","To":"\"Laurent Pinchart\" <laurent.pinchart@ideasonboard.com>, \"Hirokazu Honda\"\n\t<hiroh@chromium.org>","Date":"Mon, 19 Apr 2021 10:43:40 -0300","Message-Id":"<CARQTMSMFW3H.2N672XOK7WEMX@notapiano>","In-Reply-To":"<YH0eP0R2qFfQUzEN@pendragon.ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v2 1/2] libcamera:\n\tframebuffer_allocator: Make allocate() accept count","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","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>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":16365,"web_url":"https://patchwork.libcamera.org/comment/16365/","msgid":"<CARVTBID55G8.AJEG1T8SNF33@notapiano>","date":"2021-04-19T17:38:21","subject":"Re: [libcamera-devel] [PATCH v2 1/2] libcamera:\n\tframebuffer_allocator: Make allocate() accept count","submitter":{"id":84,"url":"https://patchwork.libcamera.org/api/people/84/","name":"Nícolas F. R. A. Prado","email":"nfraprado@collabora.com"},"content":"Em 2021-04-16 19:28, Nícolas F. R. A. Prado escreveu:\n\n> Add a 'count' argument to FrameBufferAllocator::allocate() so that a\n> custom amount of buffers can be allocated. If 0 is passed, the pipeline\n> handler allocates the default amount, which is the configured\n> bufferCount.\n>\n> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>\n> ---\n> include/libcamera/camera.h | 3 ++-\n> include/libcamera/framebuffer_allocator.h | 2 +-\n> include/libcamera/internal/pipeline_handler.h | 3 ++-\n> src/cam/capture.cpp | 2 +-\n> src/lc-compliance/simple_capture.cpp | 8 ++++----\n> src/lc-compliance/simple_capture.h | 2 +-\n> src/libcamera/camera.cpp | 5 +++--\n> src/libcamera/framebuffer_allocator.cpp | 5 +++--\n> src/libcamera/pipeline/ipu3/ipu3.cpp | 9 ++++++---\n> src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 9 ++++++---\n> src/libcamera/pipeline/rkisp1/rkisp1.cpp | 9 ++++++---\n> src/libcamera/pipeline/simple/simple.cpp | 9 ++++++---\n> src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 9 ++++++---\n> src/libcamera/pipeline/vimc/vimc.cpp | 9 ++++++---\n> src/libcamera/pipeline_handler.cpp | 1 +\n> src/qcam/main_window.cpp | 2 +-\n> test/camera/capture.cpp | 2 +-\n> test/camera/statemachine.cpp | 2 +-\n> test/mapped-buffer.cpp | 2 +-\n> 19 files changed, 58 insertions(+), 35 deletions(-)\n>\n\n[ ... ]\n\n> diff --git a/src/libcamera/pipeline_handler.cpp\n> b/src/libcamera/pipeline_handler.cpp\n> index 3b3150bdbbf7..ab5f21a01438 100644\n> --- a/src/libcamera/pipeline_handler.cpp\n> +++ b/src/libcamera/pipeline_handler.cpp\n> @@ -323,6 +323,7 @@ const ControlList &PipelineHandler::properties(const Camera\n> *camera) const\n> * \\param[in] camera The camera\n> * \\param[in] stream The stream to allocate buffers for\n> * \\param[out] buffers Array of buffers successfully allocated\n> + * \\param[in] count The amount of buffers to allocate\n\nShould the 'count' parameter come before 'buffers' so that all 'in' are before\nall 'out' parameters?\n\nThanks,\nNícolas","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 2A17ABD814\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 19 Apr 2021 17:42:03 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6E3276883C;\n\tMon, 19 Apr 2021 19:42:02 +0200 (CEST)","from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 858D768824\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 19 Apr 2021 19:42:01 +0200 (CEST)","from [127.0.0.1] (localhost [127.0.0.1])\n\t(Authenticated sender: nfraprado) with ESMTPSA id 938E11F41F4E"],"Mime-Version":"1.0","To":"=?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= <nfraprado@collabora.com>,\n\t<libcamera-devel@lists.libcamera.org>","From":"=?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= <nfraprado@collabora.com>","Date":"Mon, 19 Apr 2021 14:38:21 -0300","Message-Id":"<CARVTBID55G8.AJEG1T8SNF33@notapiano>","In-Reply-To":"<20210416222830.335755-2-nfraprado@collabora.com>","Subject":"Re: [libcamera-devel] [PATCH v2 1/2] libcamera:\n\tframebuffer_allocator: Make allocate() accept count","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","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>","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":16366,"web_url":"https://patchwork.libcamera.org/comment/16366/","msgid":"<YH3Xntk8X3pDK2et@pendragon.ideasonboard.com>","date":"2021-04-19T19:18:54","subject":"Re: [libcamera-devel] [PATCH v2 1/2] libcamera:\n\tframebuffer_allocator: Make allocate() accept count","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Nícolas,\n\nOn Mon, Apr 19, 2021 at 02:38:21PM -0300, Nícolas F. R. A. Prado wrote:\n> Em 2021-04-16 19:28, Nícolas F. R. A. Prado escreveu:\n> \n> > Add a 'count' argument to FrameBufferAllocator::allocate() so that a\n> > custom amount of buffers can be allocated. If 0 is passed, the pipeline\n> > handler allocates the default amount, which is the configured\n> > bufferCount.\n> >\n> > Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>\n> > ---\n> > include/libcamera/camera.h | 3 ++-\n> > include/libcamera/framebuffer_allocator.h | 2 +-\n> > include/libcamera/internal/pipeline_handler.h | 3 ++-\n> > src/cam/capture.cpp | 2 +-\n> > src/lc-compliance/simple_capture.cpp | 8 ++++----\n> > src/lc-compliance/simple_capture.h | 2 +-\n> > src/libcamera/camera.cpp | 5 +++--\n> > src/libcamera/framebuffer_allocator.cpp | 5 +++--\n> > src/libcamera/pipeline/ipu3/ipu3.cpp | 9 ++++++---\n> > src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 9 ++++++---\n> > src/libcamera/pipeline/rkisp1/rkisp1.cpp | 9 ++++++---\n> > src/libcamera/pipeline/simple/simple.cpp | 9 ++++++---\n> > src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 9 ++++++---\n> > src/libcamera/pipeline/vimc/vimc.cpp | 9 ++++++---\n> > src/libcamera/pipeline_handler.cpp | 1 +\n> > src/qcam/main_window.cpp | 2 +-\n> > test/camera/capture.cpp | 2 +-\n> > test/camera/statemachine.cpp | 2 +-\n> > test/mapped-buffer.cpp | 2 +-\n> > 19 files changed, 58 insertions(+), 35 deletions(-)\n> >\n> \n> [ ... ]\n> \n> > diff --git a/src/libcamera/pipeline_handler.cpp\n> > b/src/libcamera/pipeline_handler.cpp\n> > index 3b3150bdbbf7..ab5f21a01438 100644\n> > --- a/src/libcamera/pipeline_handler.cpp\n> > +++ b/src/libcamera/pipeline_handler.cpp\n> > @@ -323,6 +323,7 @@ const ControlList &PipelineHandler::properties(const Camera\n> > *camera) const\n> > * \\param[in] camera The camera\n> > * \\param[in] stream The stream to allocate buffers for\n> > * \\param[out] buffers Array of buffers successfully allocated\n> > + * \\param[in] count The amount of buffers to allocate\n> \n> Should the 'count' parameter come before 'buffers' so that all 'in' are before\n> all 'out' parameters?\n\nI'd have a preference for that, yes.","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 8B29ABD816\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 19 Apr 2021 19:19:00 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id EA41868830;\n\tMon, 19 Apr 2021 21:18:59 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7D67D68824\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 19 Apr 2021 21:18:58 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id F1A6B897;\n\tMon, 19 Apr 2021 21:18:57 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"MLi0tYW4\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1618859938;\n\tbh=VYHZIdmCL6K26IId2YgX+2LlYWAD92JTfn3orfjgJTQ=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=MLi0tYW45qoL7u927pNEAb4LgOMPN3ghw3WKxU2HCVS/HjGSussmL772z+lXRKwAF\n\tUiMRV013KLLtIFRsHrLzG+Z5VBjZqL3kVk+BtgMF2MMEFIu1x2WE3mV1kYmZ2GyVBx\n\twpeftJZC0fGOy197pn+XhBVFQUIe886SNeoCsEog=","Date":"Mon, 19 Apr 2021 22:18:54 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"=?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4=?= Prado <nfraprado@collabora.com>","Message-ID":"<YH3Xntk8X3pDK2et@pendragon.ideasonboard.com>","References":"<20210416222830.335755-2-nfraprado@collabora.com>\n\t<CARVTBID55G8.AJEG1T8SNF33@notapiano>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<CARVTBID55G8.AJEG1T8SNF33@notapiano>","Subject":"Re: [libcamera-devel] [PATCH v2 1/2] libcamera:\n\tframebuffer_allocator: Make allocate() accept count","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","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>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":16367,"web_url":"https://patchwork.libcamera.org/comment/16367/","msgid":"<YH3X5Lhfjau95Lbz@pendragon.ideasonboard.com>","date":"2021-04-19T19:20:04","subject":"Re: [libcamera-devel] [PATCH v2 1/2] libcamera:\n\tframebuffer_allocator: Make allocate() accept count","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Nícolas,\n\nOn Mon, Apr 19, 2021 at 10:43:40AM -0300, Nícolas F. R. A. Prado wrote:\n> Em 2021-04-19 03:07, Laurent Pinchart escreveu:\n> > On Mon, Apr 19, 2021 at 02:56:33PM +0900, Hirokazu Honda wrote:\n> > > On Sat, Apr 17, 2021 at 7:29 AM Nícolas F. R. A. Prado wrote:\n> > > >\n> > > > Add a 'count' argument to FrameBufferAllocator::allocate() so that a\n> > > > custom amount of buffers can be allocated. If 0 is passed, the pipeline\n> > > > handler allocates the default amount, which is the configured\n> > > > bufferCount.\n> > > >\n> > > > Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>\n> > > > ---\n> > > >  include/libcamera/camera.h                         | 3 ++-\n> > > >  include/libcamera/framebuffer_allocator.h          | 2 +-\n> > > >  include/libcamera/internal/pipeline_handler.h      | 3 ++-\n> > > >  src/cam/capture.cpp                                | 2 +-\n> > > >  src/lc-compliance/simple_capture.cpp               | 8 ++++----\n> > > >  src/lc-compliance/simple_capture.h                 | 2 +-\n> > > >  src/libcamera/camera.cpp                           | 5 +++--\n> > > >  src/libcamera/framebuffer_allocator.cpp            | 5 +++--\n> > > >  src/libcamera/pipeline/ipu3/ipu3.cpp               | 9 ++++++---\n> > > >  src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 9 ++++++---\n> > > >  src/libcamera/pipeline/rkisp1/rkisp1.cpp           | 9 ++++++---\n> > > >  src/libcamera/pipeline/simple/simple.cpp           | 9 ++++++---\n> > > >  src/libcamera/pipeline/uvcvideo/uvcvideo.cpp       | 9 ++++++---\n> > > >  src/libcamera/pipeline/vimc/vimc.cpp               | 9 ++++++---\n> > > >  src/libcamera/pipeline_handler.cpp                 | 1 +\n> > > >  src/qcam/main_window.cpp                           | 2 +-\n> > > >  test/camera/capture.cpp                            | 2 +-\n> > > >  test/camera/statemachine.cpp                       | 2 +-\n> > > >  test/mapped-buffer.cpp                             | 2 +-\n> > > >  19 files changed, 58 insertions(+), 35 deletions(-)\n> > > >\n> > > > diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h\n> > > > index 326b14d0ca01..ef6113113b6c 100644\n> > > > --- a/include/libcamera/camera.h\n> > > > +++ b/include/libcamera/camera.h\n> > > > @@ -116,7 +116,8 @@ private:\n> > > >\n> > > >         friend class FrameBufferAllocator;\n> > > >         int exportFrameBuffers(Stream *stream,\n> > > > -                              std::vector<std::unique_ptr<FrameBuffer>> *buffers);\n> > > > +                              std::vector<std::unique_ptr<FrameBuffer>> *buffers,\n> > > > +                              unsigned int count);\n> > > >  };\n> > > \n> > > In my humble opinion, giving some number a special meaning is not a good design.\n> > > I would like to ask others' opinions.\n> > > Alternative (better) design is change the type of count to std::optional.\n> >\n> > std::optional isn't an option, as it's a C++17 feature, and the public\n> > API has to stay compatible with C++14 to support Chromium (the browser,\n> > not the OS).\n> >\n> > How about making the buffer count mandatory, always passing a value\n> > explicitly ?\n> \n> Sounds good to me.\n> \n> Given that this makes the configuration's bufferCount pointless, I\n> should add a patch removing it in this series, right?\n\nOn top of the series, yes.","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 9569BBD816\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 19 Apr 2021 19:20:09 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5CF1468838;\n\tMon, 19 Apr 2021 21:20:09 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E94BA68824\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 19 Apr 2021 21:20:07 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 7ED58A27;\n\tMon, 19 Apr 2021 21:20:07 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"NOcrGP30\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1618860007;\n\tbh=Qztn4ahWvgQ0NgGS3ZeeRK94j6KZe1SADu8KZNqIkTA=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=NOcrGP30EQ4T9dD4yKgc73mSvsACLFb+PNuJGqz0KwRh5N40VnP8DcoZ0WNEvfd4h\n\tBMX1jvw8b8LgaKYiVhXj/B++yeyg+C8hYrRIOGaleBtKE36vCB0ywyeXRUnrjxAyzP\n\txEXrMQQr57AooUiXU6qx6ZPkrtoyw3HhBoz/gKgA=","Date":"Mon, 19 Apr 2021 22:20:04 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"=?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4=?= Prado <nfraprado@collabora.com>","Message-ID":"<YH3X5Lhfjau95Lbz@pendragon.ideasonboard.com>","References":"<YH0eP0R2qFfQUzEN@pendragon.ideasonboard.com>\n\t<CARQTMSMFW3H.2N672XOK7WEMX@notapiano>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<CARQTMSMFW3H.2N672XOK7WEMX@notapiano>","Subject":"Re: [libcamera-devel] [PATCH v2 1/2] libcamera:\n\tframebuffer_allocator: Make allocate() accept count","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","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>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]