[{"id":33403,"web_url":"https://patchwork.libcamera.org/comment/33403/","msgid":"<Z7bsKNrihBOjvIbT@pyrite.rasen.tech>","date":"2025-02-20T08:47:36","subject":"Re: [RFC PATCH 1/7] libcamera: delayed_controls: Add push() function\n\tthat accepts a sequence number","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"On Fri, Dec 20, 2024 at 05:26:47PM +0100, Stefan Klug wrote:\n> The push function is assymetric to the get() and applyControls()\n> function in that it doesn't allow to specify a frame number. This leads\n> to the unfortunate situation that it is very difficult to detect if\n> anything goes out of sync. Add a version of the push() function that\n> takes a sequence paramater and warns when the sequence provided differs\n> from the expected sequence. Don't take any further actions for now to\n> see where issues pop up.\n> \n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n> ---\n>  include/libcamera/internal/delayed_controls.h |  1 +\n>  src/libcamera/delayed_controls.cpp            | 33 +++++++++++++++++--\n>  2 files changed, 32 insertions(+), 2 deletions(-)\n> \n> diff --git a/include/libcamera/internal/delayed_controls.h b/include/libcamera/internal/delayed_controls.h\n> index e8d3014d92cb..f1467fd79814 100644\n> --- a/include/libcamera/internal/delayed_controls.h\n> +++ b/include/libcamera/internal/delayed_controls.h\n> @@ -30,6 +30,7 @@ public:\n>  \tvoid reset();\n>  \n>  \tbool push(const ControlList &controls);\n> +\tbool push(uint32_t sequence, const ControlList &controls);\n>  \tControlList get(uint32_t sequence);\n>  \n>  \tvoid applyControls(uint32_t sequence);\n> diff --git a/src/libcamera/delayed_controls.cpp b/src/libcamera/delayed_controls.cpp\n> index 94d0a575b01b..6c82d5058ae8 100644\n> --- a/src/libcamera/delayed_controls.cpp\n> +++ b/src/libcamera/delayed_controls.cpp\n> @@ -144,10 +144,39 @@ void DelayedControls::reset()\n>   * Push a set of controls to the control queue. This increases the control queue\n>   * depth by one.\n>   *\n> + * \\note The usage of this function is discouraged as it does not provide a way\n> + * to detect double pushes for the same sequence. Better\n> + * DelayedControls::push(uint32_t sequence, const ControlList &controls)\n> + * instead.\n> + *\n>   * \\returns true if \\a controls are accepted, or false otherwise\n>   */\n> -bool DelayedControls::push(const ControlList &controls)\n> +bool DelayedControls::push(const ControlList &controls) {\n> +\tLOG(DelayedControls, Debug) << \"Deprecated: Push without sequence number\";\n> +\treturn push(queueCount_, controls);\n> +}\n> +\n> +/**\n> + * \\brief Push a set of controls on the queue\n> + * \\param[in] sequence The sequence number to push for\n> + * \\param[in] controls List of controls to add to the device queue\n> + *\n> + * Push a set of controls to the control queue. This increases the control queue\n> + * depth by one.\n> + *\n> + * The \\a sequence number is used to do some sanity checks to detect double\n> + * pushes for the same sequence (either due to a bug or a request underrun).\n> + *\n> + * \\returns true if \\a controls are accepted, or false otherwise\n> + */\n> +bool DelayedControls::push(uint32_t sequence, const ControlList &controls)\n>  {\n> +\tif(sequence != queueCount_) {\n> +\t\tLOG(DelayedControls, Warning)\n> +\t\t\t<< \"Double push for sequence \" << sequence\n> +\t\t\t<< \" current queue index: \" << queueCount_;\n> +\t}\n> +\n>  \t/* Copy state from previous frame. */\n>  \tfor (auto &ctrl : values_) {\n>  \t\tInfo &info = ctrl.second[queueCount_];\n> @@ -276,7 +305,7 @@ void DelayedControls::applyControls(uint32_t sequence)\n>  \twhile (writeCount_ > queueCount_) {\n>  \t\tLOG(DelayedControls, Debug)\n>  \t\t\t<< \"Queue is empty, auto queue no-op.\";\n> -\t\tpush({});\n> +\t\tpush(queueCount_, {});\n>  \t}\n>  \n>  \tdevice_->setControls(&out);\n> -- \n> 2.43.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 DC80DBE175\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 20 Feb 2025 08:47:47 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B795768695;\n\tThu, 20 Feb 2025 09:47:46 +0100 (CET)","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 AFBA76185D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 20 Feb 2025 09:47:44 +0100 (CET)","from pyrite.rasen.tech (unknown\n\t[IPv6:2404:7a81:160:2100:4292:75df:25cd:1836])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 20287526;\n\tThu, 20 Feb 2025 09:46:19 +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=\"evGWfKCN\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1740041181;\n\tbh=OP/XCSRVyAbtoa5FyxQgW0EuxJ33J/N74NloFQ6aI18=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=evGWfKCNqr/EPdBZQETHiRQhKSE2xRXA/g5CF4WeqhFvfII5UPiD58X5XskY8eTOR\n\tpSuixtnkUWC4Vucdn5ptkKy/w4s/eUhQrYm9bCNM+TrGV+MpsmluqS5Sx3OnIAHdpD\n\tCtBymbhEDj1NUTnIRBFzY3xQtMGeLN4cY6Xt5IVE=","Date":"Thu, 20 Feb 2025 17:47:36 +0900","From":"Paul Elder <paul.elder@ideasonboard.com>","To":"Stefan Klug <stefan.klug@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [RFC PATCH 1/7] libcamera: delayed_controls: Add push() function\n\tthat accepts a sequence number","Message-ID":"<Z7bsKNrihBOjvIbT@pyrite.rasen.tech>","References":"<20241220162724.756494-1-stefan.klug@ideasonboard.com>\n\t<20241220162724.756494-2-stefan.klug@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20241220162724.756494-2-stefan.klug@ideasonboard.com>","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]