From patchwork Tue Jul 8 08:49:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 23774 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 D06A3C0DA4 for ; Tue, 8 Jul 2025 08:52:03 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D5FC068ED9; Tue, 8 Jul 2025 10:51:58 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="ScPGHqrH"; dkim-atps=neutral Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6A0A468ED8 for ; Tue, 8 Jul 2025 10:51:52 +0200 (CEST) Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-3a4eb4dfd8eso651681f8f.2 for ; Tue, 08 Jul 2025 01:51:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1751964712; x=1752569512; 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=Cwrk/J36Sca+wZPcZjNJQiPdG4DcMzwpKlU4oI1zKXU=; b=ScPGHqrHiuqnPesie2Z4u49NYPOQdFsa5icWkRETbj/n7GZ0qP/KWp/bgIFjWHfgaU DFNXE2SvvOnl6vLWVQUBdPQZZP3Ez+rcD3uUmQg6qUyV6RmkrG8zxIUmNSnfMIj1Eh0v lmz4k8cJ6bcTnpmXtsvVMzrDmxhG9jbtgbFePBpqbZ01QWVG0lhzIRte0ojXxsoNONe9 yWq03zLuf/v4qmEXpF2R4PVRM71ncJAjtvmxJdAzARmCe9uG/jmblxqIuP+3qfhVpjXk IBhK3A59rIirewk9/l6u1Sx1jwe3jNhnL5TkbMmEPVr6GL9wC+/YPYh70P8r1BVz1vdM +l7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751964712; x=1752569512; 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=Cwrk/J36Sca+wZPcZjNJQiPdG4DcMzwpKlU4oI1zKXU=; b=sq0GUliLdLEnjg0mX2Tra5itdI4hINPC0Wy9hy0mu/hkzhxnu/sDUMTzmzMvWaMDpt O7XatslF7XwcojBB0zV8LE7l3XL5iWv5Un70kRghh7WayADcHAgVOtAmIDZH1ut+jpSW 1iqL7aTuSj4FDZPxDzomFWRIJ+dUIvbDJx17qoV0MuJ0h0z8a1OVfagbZT5PuonyDmKu JDrxC3ZpHy/pdjsGDhDHt7ZYgYTWly4uNIaAtNY+nWdZisA++ALqiYFScRpps36+n2BG BgIVZh1HUrip56AuFAqVwdMB9bhOGQ3VG7DUyMKdyr0ZOes56CifBWdzK/ch0yBkRoKr 59LQ== X-Gm-Message-State: AOJu0Yw869xaFuTcieePuZtbvvzapCHWeuQ+dJifuFvqZTQGxJib+zdE 3LQCuth7FNgVR5OQo+G+tRq97zbKdw13RIeHxS8iiMSnpl18f4gTzbwxfI1pF6sn/kgT8uZFhsN fZ4NH X-Gm-Gg: ASbGnctYBpPlndipv77QH19Brs9HXkWxg6O2YorE1DG5Y8yMyXt8jQaHteNiiI2xMvC tiF98kQZfM8NG77lpcy6RLh89S6yELgMXGBq6burO1QxTIHRiWIQozZxPL1tHdkkbWL3HoNzDLk TO7uk9Bg+Mjo9vKNS2uysghBM/jkLrfZA2B5WyfXmGK9bqc/XXi+gWIsx2jt5ArNACitYb6r8xD mzd1D6BsqNKwDiSAZei80VB2QQkH2K1K9xlu9ClWOMWsqrEvcTfdaQQf9L3myQ28PSnQJQB9oUg wUH75IP2tt5mDLzAmJbem2oPZrTYo1uLlOW53605mYS++EqJFEaQekj2x036a7xlct6U1wg+q1M PQzis7JgPniU= X-Google-Smtp-Source: AGHT+IGqdkfUFXV6EAZ2r54LHsw8oM9XpWttqpC8nxJanzeFnk0UBysKPSMJ6zJrZWao/crchDk23g== X-Received: by 2002:a05:600c:a30a:b0:453:bf1:8895 with SMTP id 5b1f17b1804b1-454ccefa197mr6476165e9.5.1751964711519; Tue, 08 Jul 2025 01:51:51 -0700 (PDT) Received: from NAUSH-P-DELL.tail9c427.ts.net ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-454cd4938ffsm15112805e9.21.2025.07.08.01.51.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Jul 2025 01:51:51 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Cc: Naushir Patuck Subject: [PATCH v1 2/2] libcamera: controls: Use nanoseconds units for FrameWallClock Date: Tue, 8 Jul 2025 09:49:15 +0100 Message-ID: <20250708085147.752248-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250708085147.752248-1-naush@raspberrypi.com> References: <20250708085147.752248-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" Use nanoseconds for the FrameWallClock control to match the units for other timestamp controls, including SensorTimestamp. Update the RPi pipeline handlers to match the new nanoseconds units when converting from SensorTimestamp to FrameWallClock. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman Reviewed-by: Kieran Bingham --- src/libcamera/control_ids_core.yaml | 3 ++- src/libcamera/pipeline/rpi/pisp/pisp.cpp | 2 +- src/libcamera/pipeline/rpi/vc4/vc4.cpp | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/libcamera/control_ids_core.yaml b/src/libcamera/control_ids_core.yaml index 566e1533702f..eec4b4f937ee 100644 --- a/src/libcamera/control_ids_core.yaml +++ b/src/libcamera/control_ids_core.yaml @@ -1274,7 +1274,8 @@ controls: description: | This timestamp corresponds to the same moment in time as the SensorTimestamp, but is represented as a wall clock time as measured by - the CLOCK_REALTIME clock. + the CLOCK_REALTIME clock. Like SensorTimestamp, the timestamp value is + expressed in nanoseconds. Being a wall clock measurement, it can be used to synchronise timing across different devices. diff --git a/src/libcamera/pipeline/rpi/pisp/pisp.cpp b/src/libcamera/pipeline/rpi/pisp/pisp.cpp index 2df91bacf3be..92b9070c1bc2 100644 --- a/src/libcamera/pipeline/rpi/pisp/pisp.cpp +++ b/src/libcamera/pipeline/rpi/pisp/pisp.cpp @@ -1760,7 +1760,7 @@ void PiSPCameraData::cfeBufferDequeue(FrameBuffer *buffer) */ wallClockRecovery_.addSample(); uint64_t sensorTimestamp = buffer->metadata().timestamp; - uint64_t wallClockTimestamp = wallClockRecovery_.getOutput(sensorTimestamp / 1000); + uint64_t wallClockTimestamp = wallClockRecovery_.getOutput(sensorTimestamp); ctrl.set(controls::SensorTimestamp, sensorTimestamp); ctrl.set(controls::FrameWallClock, wallClockTimestamp); diff --git a/src/libcamera/pipeline/rpi/vc4/vc4.cpp b/src/libcamera/pipeline/rpi/vc4/vc4.cpp index e99a7edf809c..5cadef52712f 100644 --- a/src/libcamera/pipeline/rpi/vc4/vc4.cpp +++ b/src/libcamera/pipeline/rpi/vc4/vc4.cpp @@ -778,7 +778,7 @@ void Vc4CameraData::unicamBufferDequeue(FrameBuffer *buffer) */ wallClockRecovery_.addSample(); uint64_t sensorTimestamp = buffer->metadata().timestamp; - uint64_t wallClockTimestamp = wallClockRecovery_.getOutput(sensorTimestamp / 1000); + uint64_t wallClockTimestamp = wallClockRecovery_.getOutput(sensorTimestamp); ctrl.set(controls::SensorTimestamp, sensorTimestamp); ctrl.set(controls::FrameWallClock, wallClockTimestamp);