From patchwork Fri Oct 4 11:55:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 21513 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 88654BD80A for ; Fri, 4 Oct 2024 11:56:14 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5CAA863530; Fri, 4 Oct 2024 13:56:12 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="cvKvB1Lz"; dkim-atps=neutral Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4C3FD63524 for ; Fri, 4 Oct 2024 13:56:04 +0200 (CEST) Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-42e748f78d6so18538215e9.0 for ; Fri, 04 Oct 2024 04:56:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1728042963; x=1728647763; 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=m60dYGWd9WItWVLwXEyJ3xnk5Efq/SYRBpGuZAumOCc=; b=cvKvB1LztbUKQHOzW+i69zeTVKC6rfU6S4AkNS1zMalubwvVFilVcfGSXoZlsVa8C+ mge5irmj1Dn1bFnEeuyLPUvp8r9ScJcIcxOGFPWcFicH0KPRpvfXy03u5K3OlpxqeXz5 1Ob05EFyc9ebNuo97O4RTaM8NpjF+MhRfXXnoDCDGbC1irFMlRApIjFL7DQLBS6m0C2b WBwKb03duGs7WMGtz62XTpRAUZ+FDQLwwAYyMR+ZRdMgB7ysRiUKotp3T62LuaRoDfiP zAH+Xrg8cbis9NJjgyzkPat+yrxNoQ/+McxdcrIkwALmigKyih8JmjSTmFg0ZDFyemMo fIBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728042963; x=1728647763; 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=m60dYGWd9WItWVLwXEyJ3xnk5Efq/SYRBpGuZAumOCc=; b=R3pr72F23ID8bygG0wSNjYV20LPPGcGQ387qD5fZpR6NdrubQmy50FJgPkF7W12e0K XVwwNQsf3ua786MfUJQDTzfIYdzHvIIcgUmOktVihVB7ZWpY4aCozirZ/X6sIpsnX7zh vCQxXMG4bkANhpizFQLFZyVw/NIzjqIKC95tBLLjj/VWjZ+h/dn7+LDyKhXZ7nN7obrk uFcLiQo4pVePZ6CJ/yggSVdDZdaxnDcUkoKXp0Ay/D8iFmbns/p1k2uvfwXwO21UAPZ0 BYcpxRp14ENx4xhjWs14TbbcKZ06ykuoeAV3htgynuDTHCtdQbDGnO43YrssfdEu6uHi K11Q== X-Gm-Message-State: AOJu0Yx9+YzbMFJBYTM2oiLDgtHWD9fVVAcdbm6qLqe44nBsnKJwOfHS lKtAqxp8cXmyCSQFQpxUjx8uP1pNgRHun7d/KsJWbf380oHPhXOKbNF98x/NemIcVOKBiaG3TSe C X-Google-Smtp-Source: AGHT+IHz1gvW0tNf8QpT1yvW+NcTJuny1KzCpe5X12VUmadgkeykxN67q3LVJYvONwJf5K9ml2wK0A== X-Received: by 2002:adf:a18e:0:b0:37c:d54c:a41 with SMTP id ffacd0b85a97d-37d0e7d53f9mr1229535f8f.54.1728042963361; Fri, 04 Oct 2024 04:56:03 -0700 (PDT) Received: from raspberrypi.pitowers.org ([2a00:1098:3142:1f:daa2:371b:a97:3e3e]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37d081f743esm3107147f8f.21.2024.10.04.04.56.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Oct 2024 04:56:02 -0700 (PDT) From: David Plowman To: libcamera-devel@lists.libcamera.org Cc: Naushir Patuck , David Plowman Subject: [PATCH 2/6] pipeline: rpi: Add queue of wallclock timestamps Date: Fri, 4 Oct 2024 12:55:54 +0100 Message-Id: <20241004115558.9166-3-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241004115558.9166-1-david.plowman@raspberrypi.com> References: <20241004115558.9166-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" From: Naushir Patuck Subsequent commits will add actual values to this queue, which we can then use for sending wallclock timestamps over to the IPAs, where a future "synchonisation algorithm" can use them. Also add code to return the wallclock time to the application through the frame metadata. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman --- src/libcamera/pipeline/rpi/common/pipeline_base.cpp | 9 +++++++++ src/libcamera/pipeline/rpi/common/pipeline_base.h | 2 ++ 2 files changed, 11 insertions(+) diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp index 3041fd1e..253fac96 100644 --- a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp +++ b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp @@ -676,6 +676,7 @@ int PipelineHandlerBase::start(Camera *camera, const ControlList *controls) */ data->delayedCtrls_->reset(0); data->state_ = CameraData::State::Idle; + data->frameWallClock_ = {}; /* Enable SOF event generation. */ data->frontendDevice()->setFrameStartEnabled(true); @@ -1353,6 +1354,11 @@ void CameraData::cameraTimeout() void CameraData::frameStarted(uint32_t sequence) { + /* Get frame wall clock. */ + auto now = std::chrono::system_clock::now(); + auto durNow = std::chrono::duration_cast(now.time_since_epoch()); + frameWallClock_.emplace(sequence, durNow); + LOG(RPI, Debug) << "Frame start " << sequence; /* Write any controls for the next frame as soon as we can. */ @@ -1483,6 +1489,9 @@ void CameraData::fillRequestMetadata(const ControlList &bufferControls, Request request->metadata().set(controls::SensorTimestamp, bufferControls.get(controls::SensorTimestamp).value_or(0)); + request->metadata().set(controls::rpi::FrameWallClock, + bufferControls.get(controls::rpi::FrameWallClock).value_or(0)); + request->metadata().set(controls::ScalerCrop, scalerCrop_); } diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.h b/src/libcamera/pipeline/rpi/common/pipeline_base.h index f9cecf70..b7f5470f 100644 --- a/src/libcamera/pipeline/rpi/common/pipeline_base.h +++ b/src/libcamera/pipeline/rpi/common/pipeline_base.h @@ -163,6 +163,8 @@ public: Config config_; + std::queue> frameWallClock_; + protected: void fillRequestMetadata(const ControlList &bufferControls, Request *request);