[{"id":22050,"web_url":"https://patchwork.libcamera.org/comment/22050/","msgid":"<20220119084212.tjzvfhhayqsma5na@uno.localdomain>","date":"2022-01-19T08:42:12","subject":"Re: [libcamera-devel] [PATCH v2 1/2] libcamera: pipeline_handler:\n\tRegister requests","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Kieran,\n\nOn Wed, Jan 19, 2022 at 12:17:16AM +0000, Kieran Bingham wrote:\n> Provide a call allowing requests to be registered and associated with\n> the pipeline handler after being constructed by the camera.\n>\n> This provides an opportunity for the Pipeline Handler to connect any\n> signals it may be interested in receiving for the request such as\n> getting notifications when the request is ready for processing when\n> using a fence.\n>\n> While here, update the existing usage of the d pointer in\n> Camera::createRequest() to match the style of other functions.\n>\n> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> ---\n>  include/libcamera/internal/pipeline_handler.h |  1 +\n>  src/libcamera/camera.cpp                      | 14 +++++++++++---\n>  src/libcamera/pipeline_handler.cpp            | 19 ++++++++++++++++---\n>  3 files changed, 28 insertions(+), 6 deletions(-)\n>\n> diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h\n> index e5b8ffb4db3d..c3e4c2587ecd 100644\n> --- a/include/libcamera/internal/pipeline_handler.h\n> +++ b/include/libcamera/internal/pipeline_handler.h\n> @@ -59,6 +59,7 @@ public:\n>  \tvoid stop(Camera *camera);\n>  \tbool hasPendingRequests(const Camera *camera) const;\n>\n> +\tvoid registerRequest(Request *request);\n>  \tvoid queueRequest(Request *request);\n>\n>  \tbool completeBuffer(Request *request, FrameBuffer *buffer);\n> diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\n> index 86d84ac0a77d..5e4b84e24235 100644\n> --- a/src/libcamera/camera.cpp\n> +++ b/src/libcamera/camera.cpp\n> @@ -1074,12 +1074,20 @@ int Camera::configure(CameraConfiguration *config)\n>   */\n>  std::unique_ptr<Request> Camera::createRequest(uint64_t cookie)\n>  {\n> -\tint ret = _d()->isAccessAllowed(Private::CameraConfigured,\n> -\t\t\t\t\tPrivate::CameraRunning);\n> +\tPrivate *const d = _d();\n> +\n> +\tint ret = d->isAccessAllowed(Private::CameraConfigured,\n> +\t\t\t\t     Private::CameraRunning);\n>  \tif (ret < 0)\n>  \t\treturn nullptr;\n>\n> -\treturn std::make_unique<Request>(this, cookie);\n> +\tstd::unique_ptr<Request> request = std::make_unique<Request>(this, cookie);\n> +\n> +\t/* Associate the request with the pipeline handler. */\n> +\tif (request)\n> +\t\td->pipe_->registerRequest(request.get());\n\nCan a constructor fail ?\n\nApart from that:\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n\nThanks\n  j\n\n> +\n> +\treturn request;\n>  }\n>\n>  /**\n> diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp\n> index 03e4b9e66aa6..e27dc182c128 100644\n> --- a/src/libcamera/pipeline_handler.cpp\n> +++ b/src/libcamera/pipeline_handler.cpp\n> @@ -337,6 +337,22 @@ bool PipelineHandler::hasPendingRequests(const Camera *camera) const\n>  \treturn !camera->_d()->queuedRequests_.empty();\n>  }\n>\n> +/**\n> + * \\fn PipelineHandler::registerRequest()\n> + * \\brief Register a request for use by the Pipeline Handler\n> + * \\param[in] request The request to register\n> + */\n> +void PipelineHandler::registerRequest(Request *request)\n> +{\n> +\t/*\n> +\t * Connect the request prepared signal to notify the pipeline handler\n> +\t * when a request is ready to be processed.\n> +\t */\n> +\trequest->_d()->prepared.connect(this, [this]() {\n> +\t\t\t\t\t\tdoQueueRequests();\n> +\t\t\t\t\t});\n> +}\n> +\n>  /**\n>   * \\fn PipelineHandler::queueRequest()\n>   * \\brief Queue a request\n> @@ -366,9 +382,6 @@ void PipelineHandler::queueRequest(Request *request)\n>\n>  \twaitingRequests_.push(request);\n>\n> -\trequest->_d()->prepared.connect(this, [this]() {\n> -\t\t\t\t\t\tdoQueueRequests();\n> -\t\t\t\t\t});\n>  \trequest->_d()->prepare(300ms);\n>  }\n>\n> --\n> 2.32.0\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 AE0EBBF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 19 Jan 2022 08:41:11 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0B05260868;\n\tWed, 19 Jan 2022 09:41:11 +0100 (CET)","from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net\n\t[217.70.183.201])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D00346017F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 19 Jan 2022 09:41:09 +0100 (CET)","(Authenticated sender: jacopo@jmondi.org)\n\tby mail.gandi.net (Postfix) with ESMTPSA id 52B761BF20D;\n\tWed, 19 Jan 2022 08:41:09 +0000 (UTC)"],"Date":"Wed, 19 Jan 2022 09:42:12 +0100","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Message-ID":"<20220119084212.tjzvfhhayqsma5na@uno.localdomain>","References":"<20220119001717.2503111-1-kieran.bingham@ideasonboard.com>\n\t<20220119001717.2503111-2-kieran.bingham@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20220119001717.2503111-2-kieran.bingham@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v2 1/2] libcamera: pipeline_handler:\n\tRegister requests","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":22060,"web_url":"https://patchwork.libcamera.org/comment/22060/","msgid":"<164277455107.10801.18190544318208787668@Monstersaurus>","date":"2022-01-21T14:15:51","subject":"Re: [libcamera-devel] [PATCH v2 1/2] libcamera: pipeline_handler:\n\tRegister requests","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Jacopo Mondi (2022-01-19 08:42:12)\n> Hi Kieran,\n> \n> On Wed, Jan 19, 2022 at 12:17:16AM +0000, Kieran Bingham wrote:\n> > Provide a call allowing requests to be registered and associated with\n> > the pipeline handler after being constructed by the camera.\n> >\n> > This provides an opportunity for the Pipeline Handler to connect any\n> > signals it may be interested in receiving for the request such as\n> > getting notifications when the request is ready for processing when\n> > using a fence.\n> >\n> > While here, update the existing usage of the d pointer in\n> > Camera::createRequest() to match the style of other functions.\n> >\n> > Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> > ---\n> >  include/libcamera/internal/pipeline_handler.h |  1 +\n> >  src/libcamera/camera.cpp                      | 14 +++++++++++---\n> >  src/libcamera/pipeline_handler.cpp            | 19 ++++++++++++++++---\n> >  3 files changed, 28 insertions(+), 6 deletions(-)\n> >\n> > diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h\n> > index e5b8ffb4db3d..c3e4c2587ecd 100644\n> > --- a/include/libcamera/internal/pipeline_handler.h\n> > +++ b/include/libcamera/internal/pipeline_handler.h\n> > @@ -59,6 +59,7 @@ public:\n> >       void stop(Camera *camera);\n> >       bool hasPendingRequests(const Camera *camera) const;\n> >\n> > +     void registerRequest(Request *request);\n> >       void queueRequest(Request *request);\n> >\n> >       bool completeBuffer(Request *request, FrameBuffer *buffer);\n> > diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\n> > index 86d84ac0a77d..5e4b84e24235 100644\n> > --- a/src/libcamera/camera.cpp\n> > +++ b/src/libcamera/camera.cpp\n> > @@ -1074,12 +1074,20 @@ int Camera::configure(CameraConfiguration *config)\n> >   */\n> >  std::unique_ptr<Request> Camera::createRequest(uint64_t cookie)\n> >  {\n> > -     int ret = _d()->isAccessAllowed(Private::CameraConfigured,\n> > -                                     Private::CameraRunning);\n> > +     Private *const d = _d();\n> > +\n> > +     int ret = d->isAccessAllowed(Private::CameraConfigured,\n> > +                                  Private::CameraRunning);\n> >       if (ret < 0)\n> >               return nullptr;\n> >\n> > -     return std::make_unique<Request>(this, cookie);\n> > +     std::unique_ptr<Request> request = std::make_unique<Request>(this, cookie);\n> > +\n> > +     /* Associate the request with the pipeline handler. */\n> > +     if (request)\n> > +             d->pipe_->registerRequest(request.get());\n> \n> Can a constructor fail ?\n> \n\nGood point, I think we can leave this with the assumption that it\nsucceeds. C-habbits die hard.\n\n> Apart from that:\n> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n> \n\nThanks.\n\nK\n\n> Thanks\n>   j\n> \n> > +\n> > +     return request;\n> >  }\n> >\n> >  /**\n> > diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp\n> > index 03e4b9e66aa6..e27dc182c128 100644\n> > --- a/src/libcamera/pipeline_handler.cpp\n> > +++ b/src/libcamera/pipeline_handler.cpp\n> > @@ -337,6 +337,22 @@ bool PipelineHandler::hasPendingRequests(const Camera *camera) const\n> >       return !camera->_d()->queuedRequests_.empty();\n> >  }\n> >\n> > +/**\n> > + * \\fn PipelineHandler::registerRequest()\n> > + * \\brief Register a request for use by the Pipeline Handler\n> > + * \\param[in] request The request to register\n> > + */\n> > +void PipelineHandler::registerRequest(Request *request)\n> > +{\n> > +     /*\n> > +      * Connect the request prepared signal to notify the pipeline handler\n> > +      * when a request is ready to be processed.\n> > +      */\n> > +     request->_d()->prepared.connect(this, [this]() {\n> > +                                             doQueueRequests();\n> > +                                     });\n> > +}\n> > +\n> >  /**\n> >   * \\fn PipelineHandler::queueRequest()\n> >   * \\brief Queue a request\n> > @@ -366,9 +382,6 @@ void PipelineHandler::queueRequest(Request *request)\n> >\n> >       waitingRequests_.push(request);\n> >\n> > -     request->_d()->prepared.connect(this, [this]() {\n> > -                                             doQueueRequests();\n> > -                                     });\n> >       request->_d()->prepare(300ms);\n> >  }\n> >\n> > --\n> > 2.32.0\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 79E2EBDCBF\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 21 Jan 2022 14:15:56 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C767460213;\n\tFri, 21 Jan 2022 15:15:55 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 27C546017A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 21 Jan 2022 15:15:54 +0100 (CET)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id B26C025B;\n\tFri, 21 Jan 2022 15:15:53 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"rzfSw5pk\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1642774553;\n\tbh=Yl42vG42MT/NpDwGt6PhDWU38NOPYnQCqut4jBxoj44=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=rzfSw5pkMg1doPyuWddOydLHFSDFhnVUcsHbZuaEix5FpV99xSBa18OTAcz0bUkId\n\tbZGqRB1TI+QJeqi8Jgp5b3jkCOki5kEx2Rfexfno3CoEBpJPVHFQ/ZoDWM27hz2VOI\n\t0WLC5GZUsp70mfOzSCNop8mO63iCrj4cJNJET0TM=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20220119084212.tjzvfhhayqsma5na@uno.localdomain>","References":"<20220119001717.2503111-1-kieran.bingham@ideasonboard.com>\n\t<20220119001717.2503111-2-kieran.bingham@ideasonboard.com>\n\t<20220119084212.tjzvfhhayqsma5na@uno.localdomain>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Date":"Fri, 21 Jan 2022 14:15:51 +0000","Message-ID":"<164277455107.10801.18190544318208787668@Monstersaurus>","User-Agent":"alot/0.10","Subject":"Re: [libcamera-devel] [PATCH v2 1/2] libcamera: pipeline_handler:\n\tRegister requests","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]