[{"id":32978,"web_url":"https://patchwork.libcamera.org/comment/32978/","msgid":"<173643998581.2992722.850296072346350557@ping.linuxembedded.co.uk>","date":"2025-01-09T16:26:25","subject":"Re: [PATCH v3 3/7] controls: Add camera synchronisation controls for\n\tRaspberry Pi","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting David Plowman (2025-01-09 14:32:07)\n> New controls are added to control the camera \"sync\" algorithm, which\n> allows different cameras to synchronise their frames. For the time\n> being, the controls are Raspberry Pi specific, though this is expected\n> to change in future.\n> \n> Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n> Reviewed-by: Naushir Patuck <naush@raspberrypi.com>\n\nAcked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> ---\n>  src/libcamera/control_ids_rpi.yaml | 113 +++++++++++++++++++++++++++++\n>  1 file changed, 113 insertions(+)\n> \n> diff --git a/src/libcamera/control_ids_rpi.yaml b/src/libcamera/control_ids_rpi.yaml\n> index 7524c5d2..5c2721c0 100644\n> --- a/src/libcamera/control_ids_rpi.yaml\n> +++ b/src/libcamera/control_ids_rpi.yaml\n> @@ -58,4 +58,117 @@ controls:\n>          official libcamera API support for per-stream controls in the future.\n>  \n>          \\sa ScalerCrop\n> +\n> +  - SyncMode:\n> +      type: int32_t\n> +      direction: in\n> +      description: |\n> +        Enable or disable camera synchronisation (\"sync\") mode.\n> +\n> +        When sync mode is enabled, a camera will synchronise frames temporally\n> +        with other cameras, either attached to the same device or a different\n> +        one. There should be one \"server\" device, which broadcasts timing\n> +        information to one or more \"clients\". Communication is one-way, from\n> +        server to clients only, and it is only clients that adjust their frame\n> +        timings to match the server.\n> +\n> +        Sync mode requires all cameras to be running at (as far as possible) the\n> +        same fixed framerate. Clients may continue to make adjustments to keep\n> +        their cameras synchronised with the server for the duration of the\n> +        session, though any updates after the initial ones should remain small.\n> +\n> +        \\sa SyncReady\n> +        \\sa SyncTimer\n> +        \\sa SyncFrames\n> +\n> +      enum:\n> +        - name: SyncModeOff\n> +          value: 0\n> +          description: Disable sync mode.\n> +        - name: SyncModeServer\n> +          value: 1\n> +          description: |\n> +            Enable sync mode, act as server. The server broadcasts timing\n> +            messages to any clients that are listening, so that the clients can\n> +            synchronise their camera frames with the server's.\n> +        - name: SyncModeClient\n> +          value: 2\n> +          description: |\n> +            Enable sync mode, act as client. A client listens for any server\n> +            messages, and arranges for its camera frames to synchronise as\n> +            closely as possible with the server's. Many clients can listen out\n> +            for the same server. Clients can also be started ahead of any\n> +            servers, causing them merely to wait for the server to start.\n> +\n> +  - SyncReady:\n> +      type: bool\n> +      direction: out\n> +      description: |\n> +        When using the camera synchronisation algorithm, the server broadcasts\n> +        timing information to the clients. This also includes the time (some\n> +        number of frames in the future, called the \"ready time\") at which the\n> +        server will signal its controlling application, using this control, to\n> +        start using the image frames.\n> +\n> +        The client receives the \"ready time\" from the server, and will signal\n> +        its application to start using the frames at this same moment.\n> +\n> +        While this control value is false, applications (on both client and\n> +        server) should continue to wait, and not use the frames.\n> +\n> +        Once this value becomes true, it means that this is the first frame\n> +        where the server and its clients have agreed that they will both be\n> +        synchronised and that applications should begin consuming frames.\n> +        Thereafter, this control will continue to signal the value true for\n> +        the rest of the session.\n> +\n> +        \\sa SyncMode\n> +        \\sa SyncTimer\n> +        \\sa SyncFrames\n> +\n> +  - SyncTimer:\n> +      type: int64_t\n> +      direction: out\n> +      description: |\n> +        This reports the amount of time, in microseconds, until the \"ready\n> +        time\", at which the server and client will signal their controlling\n> +        applications that the frames are now synchronised and should be\n> +        used. The value may be refined slightly over time, becoming more precise\n> +        as the \"ready time\" approaches.\n> +\n> +        Servers always report this value, whereas clients will omit this control\n> +        until they have received a message from the server that enables them to\n> +        calculate it.\n> +\n> +        Normally the value will start positive (the \"ready time\" is in the\n> +        future), and decrease towards zero, before becoming negative (the \"ready\n> +        time\" has elapsed). So there should be just one frame where the timer\n> +        value is, or is very close to, zero - the one for which the SyncReady\n> +        control becomes true. At this moment, the value indicates how closely\n> +        synchronised the client believes it is with the server.\n> +\n> +        But note that if frames are being dropped, then the \"near zero\" valued\n> +        frame, or indeed any other, could be skipped. In these cases the timer\n> +        value allows an application to deduce that this has happened.\n> +\n> +        \\sa SyncMode\n> +        \\sa SyncReady\n> +        \\sa SyncFrames\n> +\n> +  - SyncFrames:\n> +      type: int32_t\n> +      direction: in\n> +      description: |\n> +        The number of frames the server should wait, after enabling\n> +        SyncModeServer, before signalling (via the SyncReady control) that\n> +        frames should be used. This therefore determines the \"ready time\" for\n> +        all synchronised cameras.\n> +\n> +        This control value should be set only for the device that is to act as\n> +        the server, before or at the same moment at which SyncModeServer is\n> +        enabled.\n> +\n> +        \\sa SyncMode\n> +        \\sa SyncReady\n> +        \\sa SyncTimer\n>  ...\n> -- \n> 2.39.5\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 A734AC32EA\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  9 Jan 2025 16:26:30 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4D136684F3;\n\tThu,  9 Jan 2025 17:26:30 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D8CE561880\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  9 Jan 2025 17:26:28 +0100 (CET)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 42C85110F;\n\tThu,  9 Jan 2025 17:25:35 +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=\"IB1uEz63\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1736439935;\n\tbh=w/fu3bEh0gCPHST5gb1JRUmsSWY42BdHj9BPiiVnypk=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=IB1uEz63o0odepFWrKtbYb0scuxa9b1iBBUQh0Hi+gwp3XNOgIxQjxEv2ixEBx+f2\n\tc9stbtYOe4tNun6lgQewW/NV+IXj7kRqRxHnZDoFhfR/4PE0UCjS4RvpLJMDfLkk1J\n\tCfKzlvjGC4BtK/9+TUlTpkV76Yoeq2kldwlyo4co=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20250109143211.11939-4-david.plowman@raspberrypi.com>","References":"<20250109143211.11939-1-david.plowman@raspberrypi.com>\n\t<20250109143211.11939-4-david.plowman@raspberrypi.com>","Subject":"Re: [PATCH v3 3/7] controls: Add camera synchronisation controls for\n\tRaspberry Pi","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"David Plowman <david.plowman@raspberrypi.com>,\n\tNaushir Patuck <naush@raspberrypi.com>","To":"David Plowman <david.plowman@raspberrypi.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Thu, 09 Jan 2025 16:26:25 +0000","Message-ID":"<173643998581.2992722.850296072346350557@ping.linuxembedded.co.uk>","User-Agent":"alot/0.10","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>"}}]