From patchwork Thu Jun 19 10:05:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 23604 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 1214AC3237 for ; Thu, 19 Jun 2025 10:09:12 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5C18968DF0; Thu, 19 Jun 2025 12:09:07 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="rFII36hj"; dkim-atps=neutral Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7D65E68DC6 for ; Thu, 19 Jun 2025 12:09:03 +0200 (CEST) Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-3a52878d37aso106284f8f.2 for ; Thu, 19 Jun 2025 03:09:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1750327743; x=1750932543; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=VZqGcoOUmsa4WYZ1V8vAzxzJY09zdLnQpU1CTW+aVRU=; b=rFII36hjAYf+OKlst3sjnVkEx6ifCOz3iY6NSYItDSRySEM4l4uwWSswR3KESglsa5 w32jYtLw+QPiFJy9XLLeos1eBDs8Yo7eBQmQpT5GHX1AiVYiIR7JeHieAUi7Lgnhvnrj O1Jn90zBWd0Ew7FUTMNGMFlYCikxGV9fSXpXQuSlci7b0XOl8CqTDtF1Yr2/27tFcabL 2F2QnILAuLnuVlBYmjs/G5KBRkMxGA/4BL4tzlDLHkyhixnQEevAM7j0wfWU0c6Xz9jp YGKkTbMaKk3CWjEp2yOs3UYqk79lGEvbRcRH67z0UWZcXloAyhrBAKluUDnmyrLSF85U I+qQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750327743; x=1750932543; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VZqGcoOUmsa4WYZ1V8vAzxzJY09zdLnQpU1CTW+aVRU=; b=f6hj4HlQDhI7TJMGYy5WQeoToWiWZvgk3cMdAokU3gvpbL3Kyqwq+XkuvWMMhS6nwQ 1edCg+Z9QvWxcIgLG3IEwLbRH1t3JLw63SS0wRCFwi4aDSyHS2t+Gw/MWH7dJ5Gv8yBL AcFmWQjvKT42L0L25rP6j2WrRuN/9zimXZppoyIBTYWf7GWhl+QTGiHFa2q4fMy/RLMA S2cC4J+NSMWBsuo2w2AHmNGtXx+JX88WQBcyyHtQ6DZrQcEzdB3/1IXZ9etjElVNkfc4 E2Iups7T0KaUUmLa/ITXl961SEf3YH0DnWH3BYa2t7uEzltpfEQZh1iG4Vl3ue5T/9/+ +rzg== X-Gm-Message-State: AOJu0YxrOegZWDnW9s6uVxy0k7LL3Cte/V8q8oW3EmQv3T3JfcD6WC4i a3FTCH/rexmqp/F4GHZRg8GrT8nT8pDUE/sXBKkXF8qJPPMX2Gn1m+8xSQa/pw0zuub2iTTzR6F XI9GU X-Gm-Gg: ASbGncsb2sksO26B93+G6xaJeLSRpLxk2iCR6XhNW21fA5NJFet1p8UBiniGOKPljEz wcGf7CeXCQ7DEJ34/r2RZAXZ9YJ8hpF4NnDStqfimGFq5vZVeJnsRlz3lps/5uniZtmJcFITbHU 3zrqxI9WiUJ8ufLkjeHCdmHg0pNo+OsFl52G74ueRRdSk+SHEk/dWTwODrxvL3bCY08eDN/JnjG haV/eVWt6C+kNxN/KzgPtIsuijN6vzMrf22Khh6nOYc9MFYFVuTZmDWhMtqDEWFaSaZUtcueSxC UwNUbB6EugjX4u1rjxKdkCkur8qM8vwOd6zwadh+tLNg86u5fH9eLTTJ5f4fqfmGDDtxWAWCV9L Ztj5Ssg== X-Google-Smtp-Source: AGHT+IHbi7QHunVNcRrGYVkHjsesT6nScoXaHyPitcmFHcI8uRd+G+lhGL2rISJ/nkTiBxZJCGvaKg== X-Received: by 2002:a05:6000:2002:b0:3a3:61ab:86c2 with SMTP id ffacd0b85a97d-3a6c98fbfc7mr836626f8f.7.1750327742709; Thu, 19 Jun 2025 03:09:02 -0700 (PDT) Received: from NAUSH-P-DELL.pitowers.org ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4535ebcecb5sm23926555e9.37.2025.06.19.03.09.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jun 2025 03:09:02 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Cc: kieran.bingham@ideasonboard.com, David Plowman , Naushir Patuck Subject: [PATCH 3/4] controls: Add camera synchronisation controls for Raspberry Pi Date: Thu, 19 Jun 2025 11:05:55 +0100 Message-ID: <20250619100857.124809-4-naush@raspberrypi.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250619100857.124809-1-naush@raspberrypi.com> References: <20250619100857.124809-1-naush@raspberrypi.com> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: David Plowman New controls are added to control the camera "sync" algorithm, which allows different cameras to synchronise their frames. For the time being, the controls are Raspberry Pi specific, though this is expected to change in future. Signed-off-by: David Plowman Reviewed-by: Naushir Patuck Signed-off-by: Naushir Patuck --- src/libcamera/control_ids_rpi.yaml | 112 +++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) diff --git a/src/libcamera/control_ids_rpi.yaml b/src/libcamera/control_ids_rpi.yaml index 8d1e8b47c821..a861511233b6 100644 --- a/src/libcamera/control_ids_rpi.yaml +++ b/src/libcamera/control_ids_rpi.yaml @@ -71,4 +71,116 @@ controls: \sa StatsOutputEnable + - SyncMode: + type: int32_t + direction: in + description: | + Enable or disable camera synchronisation ("sync") mode. + + When sync mode is enabled, a camera will synchronise frames temporally + with other cameras, either attached to the same device or a different + one. There should be one "server" device, which broadcasts timing + information to one or more "clients". Communication is one-way, from + server to clients only, and it is only clients that adjust their frame + timings to match the server. + + Sync mode requires all cameras to be running at (as far as possible) the + same fixed framerate. Clients may continue to make adjustments to keep + their cameras synchronised with the server for the duration of the + session, though any updates after the initial ones should remain small. + + \sa SyncReady + \sa SyncTimer + \sa SyncFrames + + enum: + - name: SyncModeOff + value: 0 + description: Disable sync mode. + - name: SyncModeServer + value: 1 + description: | + Enable sync mode, act as server. The server broadcasts timing + messages to any clients that are listening, so that the clients can + synchronise their camera frames with the server's. + - name: SyncModeClient + value: 2 + description: | + Enable sync mode, act as client. A client listens for any server + messages, and arranges for its camera frames to synchronise as + closely as possible with the server's. Many clients can listen out + for the same server. Clients can also be started ahead of any + servers, causing them merely to wait for the server to start. + + - SyncReady: + type: bool + direction: out + description: | + When using the camera synchronisation algorithm, the server broadcasts + timing information to the clients. This also includes the time (some + number of frames in the future, called the "ready time") at which the + server will signal its controlling application, using this control, to + start using the image frames. + + The client receives the "ready time" from the server, and will signal + its application to start using the frames at this same moment. + + While this control value is false, applications (on both client and + server) should continue to wait, and not use the frames. + + Once this value becomes true, it means that this is the first frame + where the server and its clients have agreed that they will both be + synchronised and that applications should begin consuming frames. + Thereafter, this control will continue to signal the value true for + the rest of the session. + + \sa SyncMode + \sa SyncTimer + \sa SyncFrames + + - SyncTimer: + type: int64_t + direction: out + description: | + This reports the amount of time, in microseconds, until the "ready + time", at which the server and client will signal their controlling + applications that the frames are now synchronised and should be + used. The value may be refined slightly over time, becoming more precise + as the "ready time" approaches. + + Servers always report this value, whereas clients will omit this control + until they have received a message from the server that enables them to + calculate it. + + Normally the value will start positive (the "ready time" is in the + future), and decrease towards zero, before becoming negative (the "ready + time" has elapsed). So there should be just one frame where the timer + value is, or is very close to, zero - the one for which the SyncReady + control becomes true. At this moment, the value indicates how closely + synchronised the client believes it is with the server. + + But note that if frames are being dropped, then the "near zero" valued + frame, or indeed any other, could be skipped. In these cases the timer + value allows an application to deduce that this has happened. + + \sa SyncMode + \sa SyncReady + \sa SyncFrames + + - SyncFrames: + type: int32_t + direction: in + description: | + The number of frames the server should wait, after enabling + SyncModeServer, before signalling (via the SyncReady control) that + frames should be used. This therefore determines the "ready time" for + all synchronised cameras. + + This control value should be set only for the device that is to act as + the server, before or at the same moment at which SyncModeServer is + enabled. + + \sa SyncMode + \sa SyncReady + \sa SyncTimer ...