From patchwork Mon Dec 9 16:27:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 22258 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 52A22BE080 for ; Mon, 9 Dec 2024 16:27:54 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A3E3467E6E; Mon, 9 Dec 2024 17:27:53 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="O8hsH5hy"; dkim-atps=neutral Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 93A1467E5F for ; Mon, 9 Dec 2024 17:27:51 +0100 (CET) Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-434f3d934fcso9467575e9.3 for ; Mon, 09 Dec 2024 08:27:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1733761671; x=1734366471; 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=/JZQehJkjkg/nlRQ144f+Imy3KC1ThU+0sq9ZOmOejk=; b=O8hsH5hy68lm2KeOO+FusaRCEiz6SwvNWxa3OOhn4/tIftHXT4tREF0cHq+f8yfXqp hRcAOWDgxfsrY+AMJv6gFJPYQik9cmeb63SP06lx09qOqFtVJkaGaxiyuley9aP3q7NO 8xivVMqC8Z4cIQw663IbNm8PbBKKEXZt0pfZDkbsqZhKx9ENKzjxeEOcMJq/jPjPIVxn u6BL6BaL2YNge6sArhtMFagowNeriA5ZZkbr5KKlSlLovBQRalFFaBSGdUnzmdnDIXgf O8PON4NNMNQjUCAdkq5mHZkzvCWHncr+jitSVI3k0SOsxVSOXI6sBiFcySy57SwqFeNw BziQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733761671; x=1734366471; 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=/JZQehJkjkg/nlRQ144f+Imy3KC1ThU+0sq9ZOmOejk=; b=emLeBOY/s7ocxgjp6gvNmfxzPisvBoNZ/Fw5EJDAIanzwS9Ddxpg/hXggBEFlGzwuW hhKHi5ywtIA3E8Vzb5FSViaNdcC6NXjtrvSka/4RKTrTYPvmlNMycU7MyVk1Ku/gwnW7 r5vCze1l3nizzzaI9x4mOBwl3e/9xgEPU608etmdH0rmcbbttALdZuOk0n7O/ZqSrYVz p51ah64f5dLcqjJ3YjU+B9WYW973tWIUdrKFvvYJ8PDxcbbyt4e7aaZkNLfd3JpUtbxc pc9GEsPPSTLdlcz24KkTdQJxTSMFMmuakX3F11L6c5triYdMPdos/sfo/rG6m/yiBSRs nFog== X-Gm-Message-State: AOJu0YyRwd9zF1R1tzre0+sm6kHo5/ZbP7KFybZBukSzk9pBCRYeXe3Q uk+yrpZbeEw8U4Fkr2sgOFl8MNSz70uQldS3pNFFes6uWgSFh7GcuknV6Avs4HAlMWHg5842aMP x X-Gm-Gg: ASbGncs1Bw5pHbUO63lQJcTZxp3Ygg4ZSE3nnPFt5N5i11CdG+YPnfLpQs/JY0/tM52 c4t8qB77AEd2ctgeSFmu/VdN0bn3QTWIi1CnsjjkOW1iXbMAjufPpzwD5t6mbji9UQNy7Jyprh9 KFhECrZ8y/xsDkkUMqW0VgC/lOWNo3IjeUsKUA3CH38U4CH008IHO8GJ5/wbEVDyAJKDGnXTeqd by7ieZuVKKo/u7Uk7aZ9GVxZK5OlGSfg6i2xVJ6OY8GTSajUji6dylKPKqP/NZkQW50LtYxKrrt bYD7Ew== X-Google-Smtp-Source: AGHT+IErfOkbpUMgZjbG1oSYM86SiComIBk3WfyNYDGgoxg3pTD78w/1f1xMbLcCv/8iytPjdaLUmw== X-Received: by 2002:a05:600c:1c21:b0:434:f82b:c5e6 with SMTP id 5b1f17b1804b1-434fff5b64fmr9754375e9.1.1733761670826; Mon, 09 Dec 2024 08:27:50 -0800 (PST) Received: from raspberrypi.pitowers.org ([2a00:1098:3142:1f:c68a:6be1:5ba3:eddd]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-434f2b08972sm67631325e9.27.2024.12.09.08.27.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Dec 2024 08:27:50 -0800 (PST) From: David Plowman To: libcamera-devel@lists.libcamera.org Cc: David Plowman Subject: [PATCH 1/1] controls: Add camera synchronisation controls Date: Mon, 9 Dec 2024 16:27:47 +0000 Message-Id: <20241209162747.2961-2-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241209162747.2961-1-david.plowman@raspberrypi.com> References: <20241209162747.2961-1-david.plowman@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" New controls are added to control the camera "sync" algorithm, which allows different cameras to synchronise their frames. Signed-off-by: David Plowman Reviewed-by: Naushir Patuck --- src/libcamera/control_ids_core.yaml | 104 ++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) diff --git a/src/libcamera/control_ids_core.yaml b/src/libcamera/control_ids_core.yaml index d45cf8e5..6d45b757 100644 --- a/src/libcamera/control_ids_core.yaml +++ b/src/libcamera/control_ids_core.yaml @@ -971,4 +971,108 @@ controls: description: | Enable or disable the debug metadata. + - SyncMode: + type: int32_t + 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". + + Sync mode requires all cameras to be running at (as far as possible) the + same fixed framerate, and may continue to make adjustments to keep the + cameras together for the duration of the session. + + 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. + + \sa SyncReady + \sa SyncTimer + \sa SyncFrames + + - SyncReady: + type: bool + 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 client and server have agreed that they will both be synchronised + and that applications should begin consuming frames. + + \sa SyncMode + \sa SyncTImer + \sa SyncFrames + + - SyncTimer: + type: int64_t + 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 + 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 that SyncModeServer is + enabled. + + \sa SyncMode + \sa SyncReady + \sa SyncTimer + ...