{"id":22401,"url":"https://patchwork.libcamera.org/api/patches/22401/?format=json","web_url":"https://patchwork.libcamera.org/patch/22401/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20241218180310.7824-4-david.plowman@raspberrypi.com>","date":"2024-12-18T18:03:10","name":"[v2,3/3] controls: Add camera synchronisation controls","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"72c0eeccc328f4cfa38045026f1eeadd8ff2a5e2","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/people/42/?format=json","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/22401/mbox/","series":[{"id":4913,"url":"https://patchwork.libcamera.org/api/series/4913/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4913","date":"2024-12-18T18:03:07","name":"Wall clocks and camera sync","version":2,"mbox":"https://patchwork.libcamera.org/series/4913/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/22401/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/22401/checks/","tags":{},"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 0D2CAC3306\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 18 Dec 2024 18:03:25 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 047FB680B2;\n\tWed, 18 Dec 2024 19:03:24 +0100 (CET)","from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com\n\t[IPv6:2a00:1450:4864:20::32b])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DCF70680A2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 18 Dec 2024 19:03:19 +0100 (CET)","by mail-wm1-x32b.google.com with SMTP id\n\t5b1f17b1804b1-436249df846so47462965e9.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 18 Dec 2024 10:03:19 -0800 (PST)","from raspberrypi.pitowers.org\n\t([2a00:1098:3142:1f:c68a:6be1:5ba3:eddd])\n\tby smtp.gmail.com with ESMTPSA id\n\t5b1f17b1804b1-43656b01c88sm27927285e9.17.2024.12.18.10.03.16\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 18 Dec 2024 10:03:16 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"ZWbFTrII\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1734544999; x=1735149799;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=a34Z2mQqo6HWxuMMY6rFsnAumW5AmxjBsIlATHxwa6E=;\n\tb=ZWbFTrIIThmceZf7LlTOneW0sIXVWYLI4+hH7khMR8394KCkzJ5ZVi4I+0vqa7A6D8\n\tCx61h8NXd5j5G16Rzd0Ba08kX/2KnFjmg7IKcB9HjvHrjuJzvu7ccvB/tooVCFe9TqXb\n\tf/y02UV7GDDnUMmwT6i7p97AtMtIqDBr0Y4kZnIaLSnqLH/+NHbWd3O9siCbDNhCdbEk\n\tJhRILxAtSc/z+zY1c6aQAnpbjvbG+LRksQ2fOADP6dgKzYpLJw+mRc0HdY4uTTe3rzyX\n\tjvO8ow2zc9bY97jK7RoXwcrk23ThcbY395ETqCWl7G+tZhIV9WqfbfvU1aq+nStHLNdr\n\tp0EQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1734544999; x=1735149799;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=a34Z2mQqo6HWxuMMY6rFsnAumW5AmxjBsIlATHxwa6E=;\n\tb=LftXvkmXWIGcGsABowoValkJUUyGLFv+/mVvk9r2jkpjx6IDf6Q9Oe+6WLoyN3zO8u\n\tL858hmppw+k8PViWm16UeJu/F2sRlgj94fnRdxWIt7zut27eXGepczNUYCRuFZ6eMx7D\n\tCFi4EIA++lMbR3JHqfy7Pmv4gF/RF48+mFi7cqooTXaiva/kIBrn1IKGKLSf9aFNxAS4\n\t5va4ih6xUXN99cyuqUWY/XYYrd+pRGyg1SB4UjGjHveyAK5PQ5bbfNSy8PXZ6hdnp6ym\n\tGYAqcjy7iL3djpcvViVQkQ8oN5/r7jbfbHUyJ401g7bZLPs5NjJzmx6+s+NiRvLZY54Z\n\tNSdQ==","X-Gm-Message-State":"AOJu0YzlWzg0Z42HNbivQpwyYV/3pVCx2KJhLqMpB8cinujA0QlymjD3\n\tYeg01JizWkxM/foXxXkEf0foB/KY9IGrUQnup7weohAnNRkeFsltgp+0U3JVZp6ldfP6DTTY+hN\n\ts","X-Gm-Gg":"ASbGncu7MicWzGzkcTuTrEqvzzedsU55Scy+hTkCIJuayzPUPzUrcrFekJhIrplHJjH\n\t0iD89Ru2rIrhPlWG7dcvUf5T4fH1ItaFfgwoyTl0qsLkpmMbcjLt3493Ww0DKmTcOGKyo8uW2LM\n\tlGwf3FC6iTjmcY9O9Q9SFfM+OolLGFrXKlASgvY4Cr0CJBAkzzNHpocPZtOoEaXUaucxK3ZPTVW\n\tXoQvKNXkce4PlBzEMqIypyL/UC5B85iEcgg5qHHCanG0kVIoD2nYRK0jrlfrsgjTmdvD+1/V9w6\n\t3fqgN1Ey/NhO","X-Google-Smtp-Source":"AGHT+IEKmxBmx+hLTo1JCDz8CxHKYx3Zp20fMcF3FPJu+dG7jwOiamkKJ7vGc/lOEgawGggH3bO3rQ==","X-Received":"by 2002:a05:600c:1d15:b0:436:46f9:4fc6 with SMTP id\n\t5b1f17b1804b1-4365c78124fmr2228985e9.8.1734544998786; \n\tWed, 18 Dec 2024 10:03:18 -0800 (PST)","From":"David Plowman <david.plowman@raspberrypi.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"David Plowman <david.plowman@raspberrypi.com>,\n\tNaushir Patuck <naush@raspberrypi.com>","Subject":"[PATCH v2 3/3] controls: Add camera synchronisation controls","Date":"Wed, 18 Dec 2024 18:03:10 +0000","Message-Id":"<20241218180310.7824-4-david.plowman@raspberrypi.com>","X-Mailer":"git-send-email 2.39.5","In-Reply-To":"<20241218180310.7824-1-david.plowman@raspberrypi.com>","References":"<20241218180310.7824-1-david.plowman@raspberrypi.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","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>"},"content":"New controls are added to control the camera \"sync\" algorithm, which\nallows different cameras to synchronise their frames.\n\nSigned-off-by: David Plowman <david.plowman@raspberrypi.com>\nReviewed-by: Naushir Patuck <naush@raspberrypi.com>\n---\n src/libcamera/control_ids_core.yaml | 109 ++++++++++++++++++++++++++++\n 1 file changed, 109 insertions(+)","diff":"diff --git a/src/libcamera/control_ids_core.yaml b/src/libcamera/control_ids_core.yaml\nindex 8485f7e8..cf502944 100644\n--- a/src/libcamera/control_ids_core.yaml\n+++ b/src/libcamera/control_ids_core.yaml\n@@ -1027,4 +1027,113 @@ controls:\n \n         The FrameWallClock control can only be returned in metadata.\n \n+  - SyncMode:\n+      type: int32_t\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+      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+      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+      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","prefixes":["v2","3/3"]}