[{"id":1400,"web_url":"https://patchwork.libcamera.org/comment/1400/","msgid":"<20190416194054.GB28515@bigcity.dyn.berto.se>","date":"2019-04-16T19:40:54","subject":"Re: [libcamera-devel] [PATCH v6 5/7] libcamera: camera: Validate\n\tRequest befor queueing it","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Jacopo,\n\nThanks for your work.\n\nOn 2019-04-16 15:42:08 +0200, Jacopo Mondi wrote:\n> Validate the Request before proceeding to prepare it at\n> Camera::queueRequest() time.\n> \n> For now limit the validation to making sure the Request contains at\n> least one Stream to capture from.\n\nI think you should reword the commit message, it feels it have diverged \na bit from the change it self. I would at least drop the mentioning of \nCamera::queueRequest().\n\n> \n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> ---\n>  src/libcamera/camera.cpp  | 10 ++++++++--\n>  src/libcamera/request.cpp | 15 ++++++++++++++-\n>  2 files changed, 22 insertions(+), 3 deletions(-)\n> \n> diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\n> index 2d0a80664214..0709047341d7 100644\n> --- a/src/libcamera/camera.cpp\n> +++ b/src/libcamera/camera.cpp\n> @@ -714,8 +714,14 @@ Request *Camera::createRequest()\n>   * \\param[in] request The request to queue to the camera\n>   *\n>   * This method queues a \\a request allocated with createRequest() to the camera\n> - * for capture. Once the request has been queued, the camera will notify its\n> - * completion through the \\ref requestCompleted signal.\n> + * for capture.\n> + *\n> + * After allocating the request with createRequest(), the application shall\n> + * fill it with at least one capture buffer before queuing it. Requests that\n> + * contain no buffers are invalid and are rejected without being queued.\n> + *\n> + * Once the request has been queued, the camera will notify its completion\n> + * through the \\ref requestCompleted signal.\n>   *\n>   * Ownership of the request is transferred to the camera. It will be deleted\n>   * automatically after it completes.\n> diff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp\n> index 5e86c8e10128..12a3c5204f24 100644\n> --- a/src/libcamera/request.cpp\n> +++ b/src/libcamera/request.cpp\n> @@ -115,10 +115,23 @@ Buffer *Request::findBuffer(Stream *stream) const\n>   */\n>  \n>  /**\n> - * \\brief Prepare the resources for the completion handler\n> + * \\brief Prepare and validate the request for the completion handler\n> + *\n> + * This method prepares resources and validates the request to prepare it for\n> + * capture operations.\n\nI think you can drop this sentence.\n\n> + *\n> + * Requests that contain no buffers are invalid and are rejected by this method.\n\ns/by this method//\n\n> + *\n> + * \\return 0 on success a negative error code otherwise\n\ns/success a/success or a/\n\n> + * \\retval -EVINAL The request is invalid\n>   */\n>  int Request::prepare()\n>  {\n> +\tif (!hasPendingBuffers()) {\n> +\t\tLOG(Request, Error) << \"Invalid request due to missing buffers\";\n> +\t\treturn -EINVAL;\n> +\t}\n> +\n>  \tfor (auto const &pair : bufferMap_) {\n>  \t\tBuffer *buffer = pair.second;\n>  \t\tpending_.insert(buffer);\n> -- \n> 2.21.0\n> \n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","headers":{"Return-Path":"<niklas.soderlund@ragnatech.se>","Received":["from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com\n\t[IPv6:2a00:1450:4864:20::12d])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 60A6C60004\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 16 Apr 2019 21:40:57 +0200 (CEST)","by mail-lf1-x12d.google.com with SMTP id v1so7631438lfg.5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 16 Apr 2019 12:40:57 -0700 (PDT)","from localhost (89-233-230-99.cust.bredband2.com. [89.233.230.99])\n\tby smtp.gmail.com with ESMTPSA id\n\ts64sm10650127lje.49.2019.04.16.12.40.55\n\t(version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);\n\tTue, 16 Apr 2019 12:40:55 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to\n\t:user-agent; bh=b3BFMArD/y1fSQFfI3trjJhFxh0Iivo8UNhJJPftUk0=;\n\tb=YbsnwIGPRG2MBxaRYQz8eGvSahpMfKfBfpqfKysQEC55L6W25L3hRmb3BE97+7Axf4\n\tR9ZnmiQpywvy9ZjCDj9MH7i0NH/4gQ/W4RvmF/YShHDNe9Z9dm3sDPqfREnPdG3iHVZl\n\tV022f0WPRcWfJ359po/KILvC1gOX0CsbwyfAVQUNLSgvmOtvjttEkIF3cvH1EgkSMtNT\n\tywsLq1MEjFPYlKV+GpO36b7CGrfXRlG7PpPGfDaE8vRWdNreum9uTo1akR1uS1xrkWmO\n\twMw8CtKa2w9K84wfZtqmkE2PuiubVG+DkTM65vMo/6hfI+CxiI1zSjtw6sDv+OKDy88X\n\tkQEQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to:user-agent;\n\tbh=b3BFMArD/y1fSQFfI3trjJhFxh0Iivo8UNhJJPftUk0=;\n\tb=kBj7dkAiXtJSxZN/OR1dweVkjvah0/LXyCkDzUzi7O4JwVPnJpxhtCWRBKUo3hVeiL\n\tvU+OQ3TVrWRSL/bv/u00wJVtYQpd4XdPDNf7ps7MEW4uFIwh9SgGhukWoqM38EEHMnf8\n\tdxxFDSN3QOYm6rXiXNJFghCW8sNUPGkHfQhHMR/3a84oi5wJOcLY9GalbN7bx4uASDu1\n\t1W5/sw37ADUBK6kfmCClPa1g/26yAUBwrdHz61QxGN/FBM7Ca+PGlQYuiMY2v/xcW8+/\n\tyCOB2d3sXk1+WmpoUQi03JCwlHzTzGBfpt+5jQxSfn8HLNwxTxxmakple+yaUK6JwxIK\n\tap0A==","X-Gm-Message-State":"APjAAAU571hkkajxGpSHAtpukcSzns8jUQnwcP6K5CD8deT6xEEJL6Dk\n\tbHxkJuWpYjI24WTF00DLgJC7qQ==","X-Google-Smtp-Source":"APXvYqyJsJtOZ8Lq8MPTv8hYuvDSZukcR9AUE66KnPmO6eFnpp7i8CJPTmsWzBHUSjDPFa8gqpFv/g==","X-Received":"by 2002:ac2:5207:: with SMTP id a7mr26792926lfl.70.1555443656687;\n\tTue, 16 Apr 2019 12:40:56 -0700 (PDT)","Date":"Tue, 16 Apr 2019 21:40:54 +0200","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190416194054.GB28515@bigcity.dyn.berto.se>","References":"<20190416134210.21097-1-jacopo@jmondi.org>\n\t<20190416134210.21097-6-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=iso-8859-1","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20190416134210.21097-6-jacopo@jmondi.org>","User-Agent":"Mutt/1.11.3 (2019-02-01)","Subject":"Re: [libcamera-devel] [PATCH v6 5/7] libcamera: camera: Validate\n\tRequest befor queueing it","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Tue, 16 Apr 2019 19:40:57 -0000"}},{"id":1413,"web_url":"https://patchwork.libcamera.org/comment/1413/","msgid":"<20190416222252.GK4822@pendragon.ideasonboard.com>","date":"2019-04-16T22:22:52","subject":"Re: [libcamera-devel] [PATCH v6 5/7] libcamera: camera: Validate\n\tRequest befor queueing it","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jacopo,\n\nThank you for the patch.\n\nOn Tue, Apr 16, 2019 at 09:40:54PM +0200, Niklas Söderlund wrote:\n> On 2019-04-16 15:42:08 +0200, Jacopo Mondi wrote:\n\nIn the subject line, s/befor/before/\n\n> > Validate the Request before proceeding to prepare it at\n> > Camera::queueRequest() time.\n> > \n> > For now limit the validation to making sure the Request contains at\n> > least one Stream to capture from.\n> \n> I think you should reword the commit message, it feels it have diverged \n> a bit from the change it self. I would at least drop the mentioning of \n> Camera::queueRequest().\n\n\"Extend the Request::prepare() operation to validate the request before\npreparing it. Return an error if the request is invalid, which for now\nis limited to ensuring that the request contains at least one buffer.\"\n\n> > Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> > ---\n> >  src/libcamera/camera.cpp  | 10 ++++++++--\n> >  src/libcamera/request.cpp | 15 ++++++++++++++-\n> >  2 files changed, 22 insertions(+), 3 deletions(-)\n> > \n> > diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\n> > index 2d0a80664214..0709047341d7 100644\n> > --- a/src/libcamera/camera.cpp\n> > +++ b/src/libcamera/camera.cpp\n> > @@ -714,8 +714,14 @@ Request *Camera::createRequest()\n> >   * \\param[in] request The request to queue to the camera\n> >   *\n> >   * This method queues a \\a request allocated with createRequest() to the camera\n\nI would s/allocated with createRequest() // as it is mentioned in the\nnext paragraph.\n\n> > - * for capture. Once the request has been queued, the camera will notify its\n> > - * completion through the \\ref requestCompleted signal.\n> > + * for capture.\n> > + *\n> > + * After allocating the request with createRequest(), the application shall\n> > + * fill it with at least one capture buffer before queuing it. Requests that\n> > + * contain no buffers are invalid and are rejected without being queued.\n> > + *\n> > + * Once the request has been queued, the camera will notify its completion\n> > + * through the \\ref requestCompleted signal.\n> >   *\n> >   * Ownership of the request is transferred to the camera. It will be deleted\n> >   * automatically after it completes.\n> > diff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp\n> > index 5e86c8e10128..12a3c5204f24 100644\n> > --- a/src/libcamera/request.cpp\n> > +++ b/src/libcamera/request.cpp\n> > @@ -115,10 +115,23 @@ Buffer *Request::findBuffer(Stream *stream) const\n> >   */\n> >  \n> >  /**\n> > - * \\brief Prepare the resources for the completion handler\n> > + * \\brief Prepare and validate the request for the completion handler\n\n\"Validate the request and prepare it for the completion handler\" as the\nrequest is validated first and then prepared ?\n\n> > + *\n> > + * This method prepares resources and validates the request to prepare it for\n> > + * capture operations.\n> \n> I think you can drop this sentence.\n> \n> > + *\n> > + * Requests that contain no buffers are invalid and are rejected by this method.\n> \n> s/by this method//\n> \n> > + *\n> > + * \\return 0 on success a negative error code otherwise\n> \n> s/success a/success or a/\n\nThose three comments look good to me.\n\n> > + * \\retval -EVINAL The request is invalid\n\ns/-EVINAL/-EINVAL/\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> >   */\n> >  int Request::prepare()\n> >  {\n> > +\tif (!hasPendingBuffers()) {\n> > +\t\tLOG(Request, Error) << \"Invalid request due to missing buffers\";\n> > +\t\treturn -EINVAL;\n> > +\t}\n> > +\n> >  \tfor (auto const &pair : bufferMap_) {\n> >  \t\tBuffer *buffer = pair.second;\n> >  \t\tpending_.insert(buffer);","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2B29960004\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 17 Apr 2019 00:23:01 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(dfj612yhrgyx302h3jwwy-3.rev.dnainternet.fi\n\t[IPv6:2001:14ba:21f5:5b00:ce28:277f:58d7:3ca4])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 8BA40E2;\n\tWed, 17 Apr 2019 00:23:00 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1555453380;\n\tbh=FL1XL2J5QKfGIY12zv605VI5G/JnB9PpveHZuQo3h+g=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=kbcHc19AYm9V4xetcB9UwKwasJWLBxk5nHoJIL3nW5e6L2zcqPKLt68ZeCEPDEo5l\n\trx3jsMBFEBBLvPlcX0Vp7pDMUxIMJQUS8b8Sap1YteFvBajoF9wK8lCC7SErPMsKRR\n\tdITkguFgPtOOlNxlfj9Rb9IkKgWF7A0EDfteV+jE=","Date":"Wed, 17 Apr 2019 01:22:52 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"Niklas =?utf-8?q?S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>,\n\tlibcamera-devel@lists.libcamera.org","Message-ID":"<20190416222252.GK4822@pendragon.ideasonboard.com>","References":"<20190416134210.21097-1-jacopo@jmondi.org>\n\t<20190416134210.21097-6-jacopo@jmondi.org>\n\t<20190416194054.GB28515@bigcity.dyn.berto.se>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20190416194054.GB28515@bigcity.dyn.berto.se>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH v6 5/7] libcamera: camera: Validate\n\tRequest befor queueing it","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Tue, 16 Apr 2019 22:23:01 -0000"}}]