From patchwork Fri Jul 3 22:48:16 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Allen X-Patchwork-Id: 27198 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 389A8C330A for ; Fri, 3 Jul 2026 22:50:01 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 79FF465FC1; Sat, 4 Jul 2026 00:49:59 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=googlemail.com header.i=@googlemail.com header.b="PZOIs5XA"; dkim-atps=neutral Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 03A5A65FC1 for ; Sat, 4 Jul 2026 00:49:57 +0200 (CEST) Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-493b1710405so5912585e9.2 for ; Fri, 03 Jul 2026 15:49:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20251104; t=1783118996; x=1783723796; 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=dJS2lyOWBfoBNbBgM2SdI4CsiTkDw7Ch+iLzxHa5S2U=; b=PZOIs5XAhjW7Y+MZMrIftByZhOJfMGqdFbFZ06dtkqK3dLXFMD6VTiZfA05e1h3ylx juADF0l4RMxKyEFWB+Arat1/YD4Btoej+bJFF/8AmvrSGy5k2wONTVBub3dI02JK9kyM 5q6bedblNq6Sk83m0ndfx4rIXQtKFYvKObIjkVfPLde4y6nwchoruunVaf5LU0ruxtxY tgeygSJsA74iCGv/qYca/HTzSTnu+njYFoake37hgVF0SNnCiilAMK/vBQAW2OgwdcRO L6BcGTqMC5McAZDiDEwAbLsyPAtJwfTCxLAJ1QSIC/YgqJ9nN8ibCjaJb8AL0fRb460n PSRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783118996; x=1783723796; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=dJS2lyOWBfoBNbBgM2SdI4CsiTkDw7Ch+iLzxHa5S2U=; b=Vobl3bPiREpTaIXTlFKJF8n1kIudj2T7MWOPwYasbI4VIGyQN6oPKn41KzJJZLPACd X/gU0BGMjx5Wsk0mpy3ZLo30r79oA48w8GZj6P2HAFIQbHkLJbV3QFhFuXEPS0bt4No2 qbPM0SXbgJIsNwtCG/qCwcI2Z4QGUF43sTE9Or7Ekg+ZqHkQ1vWyPAUoa2pHMvnhpHgh Q0Ged9NW7M/SGT0db3LR6hk9We6X9khsZCjZ8sZeM+CCrg67OK4aKytdDqCBt9Ku/JAV PpCjfrha+9dtO8v9Pdvuo3edyq5PPceNCiwG1gMlZTCLyh3LfWu16Uigblb0Xgsw6hr6 xdfw== X-Gm-Message-State: AOJu0YxtY4xALHflDIcQ2DAz3PzQ14IQ+7WIwCgOCfoYjto3HWuyQKdn 2F5x52PuvGEUbEK3IXuY6RSgwNClCyphBFyZEfvFk0SL7/0vuhSM1WWg/vHjUrO2 X-Gm-Gg: AfdE7cnfCzCEwqNghWZTCVdsodw4Ma86uF4LDpyMPl80n6xFRtMo1Y8Yrlm/NnOWzsQ DlKi89yfm7QiArJXV21keZwhWnulHNS+X0ULtZcIzerYmIAeAd7nFsrcGyWZqGXNe8JHMPAadZf 0yQZxiQeu5/k+Jm38WuMTxEL2wIt9bRVc1XyMPifB5sEz1alozIxmkReolT0LJOcEluZSfzyoU/ LCuS7ukGR1SkAcUMBeIWPu/hqdYx4bmx/FuEc9o0nRQsGs/kpYCXolQR5py9JgVf25O5+3HbD7y lS8SBwa2a49RaLDXffjwDaKb6mrvfce8rv1JgzA9Unho0qkx9uJ7TUlJIyX7zxDznvqoM8PigJI ZbsjQwSoHrlVSQtfNVfPRQpJSoX6Uoa1qMgnA0OXA60RcNSjzah/ayUnOdOHPitD2YKhphsW+se gtvIjx0ys7TitL/SR7SgcqWOE6EtTx+tXON/KzJ1MAY4PHMO5mMi0dyJ/rBsxsoie8uDDBX68Mp d1J3wBCNTM= X-Received: by 2002:a05:600c:6287:b0:490:e5c1:b8b9 with SMTP id 5b1f17b1804b1-493d1188014mr11954295e9.0.1783118996318; Fri, 03 Jul 2026 15:49:56 -0700 (PDT) Received: from localhost.localdomain (tmo-121-138.customers.d1-online.com. [80.187.121.138]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-493c63ba971sm255611285e9.13.2026.07.03.15.49.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jul 2026 15:49:55 -0700 (PDT) From: Bruce Allen To: libcamera-devel@lists.libcamera.org Cc: Bruce Allen Subject: [PATCH v2 1/2] libcamera: Add SensorSequence metadata control Date: Fri, 3 Jul 2026 23:48:16 +0100 Message-ID: <20260703224817.15650-2-ballen4705@googlemail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260703224817.15650-1-ballen4705@googlemail.com> References: <20260626003712.26624-1-ballen4705@googlemail.com> <20260703224817.15650-1-ballen4705@googlemail.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" Add controls::SensorSequence (int64_t, out) to report the monotonic sequence number from the sensor-facing capture device in request metadata. Populate the control in all pipeline handlers that already report SensorTimestamp. Signed-off-by: Bruce Allen --- src/libcamera/control_ids_core.yaml | 18 ++++++++++++++++++ src/libcamera/pipeline/imx8-isi/imx8-isi.cpp | 3 +++ src/libcamera/pipeline/ipu3/ipu3.cpp | 2 ++ src/libcamera/pipeline/mali-c55/mali-c55.cpp | 2 ++ src/libcamera/pipeline/rkisp1/rkisp1.cpp | 2 ++ src/libcamera/pipeline/rpi/common/pipeline_base.cpp | 2 ++ src/libcamera/pipeline/rpi/pisp/pisp.cpp | 2 ++ src/libcamera/pipeline/rpi/vc4/vc4.cpp | 2 ++ src/libcamera/pipeline/simple/simple.cpp | 5 ++++- src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 2 ++ src/libcamera/pipeline/vimc/vimc.cpp | 2 ++ 11 files changed, 41 insertions(+), 1 deletion(-) diff --git a/src/libcamera/control_ids_core.yaml b/src/libcamera/control_ids_core.yaml index 89991d0..d6bc114 100644 --- a/src/libcamera/control_ids_core.yaml +++ b/src/libcamera/control_ids_core.yaml @@ -792,6 +792,24 @@ controls: \todo Define how the sensor timestamp has to be used in the reprocessing use case. + - SensorSequence: + type: int64_t + direction: out + description: | + The monotonic sequence number from the sensor capture device. + + Pipeline handlers populate this metadata control with the sequence + number reported by the sensor-facing capture device (for example the + CSI-2 receiver or V4L2 video node). Any break in this sequence number + indicates that frames were dropped or not captured before the previous + request completed. + + While per-buffer FrameMetadata::sequence identifies frames in each + completed stream, SensorSequence reflects the sensor-side capture path + and is intended for diagnosing frame continuity. + + The SensorSequence control can only be returned in metadata. + - AfMode: type: int32_t direction: inout diff --git a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp index c3d2695..d2175b9 100644 --- a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp +++ b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp @@ -1130,6 +1130,9 @@ void PipelineHandlerISI::bufferReady(FrameBuffer *buffer) if (!metadata.contains(controls::SensorTimestamp.id())) metadata.set(controls::SensorTimestamp, buffer->metadata().timestamp); + if (!metadata.contains(controls::SensorSequence.id())) + metadata.set(controls::SensorSequence, + static_cast(buffer->metadata().sequence)); if (completeBuffer(request, buffer)) completeRequest(request); diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 0f3e169..6494259 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -1317,6 +1317,8 @@ void IPU3CameraData::cio2BufferReady(FrameBuffer *buffer) */ request->_d()->metadata().set(controls::SensorTimestamp, buffer->metadata().timestamp); + request->_d()->metadata().set(controls::SensorSequence, + static_cast(buffer->metadata().sequence)); info->effectiveSensorControls = delayedCtrls_->get(buffer->metadata().sequence); diff --git a/src/libcamera/pipeline/mali-c55/mali-c55.cpp b/src/libcamera/pipeline/mali-c55/mali-c55.cpp index 599ff88..119b249 100644 --- a/src/libcamera/pipeline/mali-c55/mali-c55.cpp +++ b/src/libcamera/pipeline/mali-c55/mali-c55.cpp @@ -1704,6 +1704,8 @@ void PipelineHandlerMaliC55::cruBufferReady(FrameBuffer *buffer) Request *request = info->request; request->_d()->metadata().set(controls::SensorTimestamp, buffer->metadata().timestamp); + request->_d()->metadata().set(controls::SensorSequence, + static_cast(buffer->metadata().sequence)); MaliC55CameraData *data = cameraData(request->_d()->camera()); data->ipa_->fillParams(request->sequence(), info->paramBuffer->cookie()); diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 4f9c0aa..0c73f5a 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -1647,6 +1647,8 @@ void PipelineHandlerRkISP1::imageBufferReady(FrameBuffer *buffer) */ request->_d()->metadata().set(controls::SensorTimestamp, metadata.timestamp); + request->_d()->metadata().set(controls::SensorSequence, + static_cast(metadata.sequence)); if (isRaw_) { const ControlList &ctrls = diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp index 5a5acf6..dcf8e6a 100644 --- a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp +++ b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp @@ -1514,6 +1514,8 @@ void CameraData::fillRequestMetadata(const ControlList &bufferControls, Request { if (auto x = bufferControls.get(controls::SensorTimestamp)) request->_d()->metadata().set(controls::SensorTimestamp, *x); + if (auto x = bufferControls.get(controls::SensorSequence)) + request->_d()->metadata().set(controls::SensorSequence, *x); if (auto x = bufferControls.get(controls::FrameWallClock)) request->_d()->metadata().set(controls::FrameWallClock, *x); diff --git a/src/libcamera/pipeline/rpi/pisp/pisp.cpp b/src/libcamera/pipeline/rpi/pisp/pisp.cpp index b744c90..0832432 100644 --- a/src/libcamera/pipeline/rpi/pisp/pisp.cpp +++ b/src/libcamera/pipeline/rpi/pisp/pisp.cpp @@ -1766,6 +1766,8 @@ void PiSPCameraData::cfeBufferDequeue(FrameBuffer *buffer) ctrl.set(controls::SensorTimestamp, sensorTimestamp); ctrl.set(controls::FrameWallClock, wallClockTimestamp); + ctrl.set(controls::SensorSequence, + static_cast(buffer->metadata().sequence)); job.sensorControls = std::move(ctrl); job.delayContext = delayContext; } else if (stream == &cfe_[Cfe::Config]) { diff --git a/src/libcamera/pipeline/rpi/vc4/vc4.cpp b/src/libcamera/pipeline/rpi/vc4/vc4.cpp index 3e9a490..1e7b26a 100644 --- a/src/libcamera/pipeline/rpi/vc4/vc4.cpp +++ b/src/libcamera/pipeline/rpi/vc4/vc4.cpp @@ -787,6 +787,8 @@ void Vc4CameraData::unicamBufferDequeue(FrameBuffer *buffer) ctrl.set(controls::SensorTimestamp, sensorTimestamp); ctrl.set(controls::FrameWallClock, wallClockTimestamp); + ctrl.set(controls::SensorSequence, + static_cast(buffer->metadata().sequence)); bayerQueue_.push({ buffer, std::move(ctrl), delayContext }); } else { embeddedQueue_.push(buffer); diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index e26f438..ce34bb2 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -939,9 +939,12 @@ void SimpleCameraData::imageBufferReady(FrameBuffer *buffer) } } - if (request) + if (request) { request->_d()->metadata().set(controls::SensorTimestamp, buffer->metadata().timestamp); + request->_d()->metadata().set(controls::SensorSequence, + static_cast(buffer->metadata().sequence)); + } /* * Queue the captured and the request buffer to the converter or Software diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp index 3435a76..e0b7dad 100644 --- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp @@ -897,6 +897,8 @@ void UVCCameraData::imageBufferReady(FrameBuffer *buffer) /* \todo Use the UVC metadata to calculate a more precise timestamp */ request->_d()->metadata().set(controls::SensorTimestamp, buffer->metadata().timestamp); + request->_d()->metadata().set(controls::SensorSequence, + static_cast(buffer->metadata().sequence)); pipe()->completeBuffer(request, buffer); pipe()->completeRequest(request); diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp index 01d8fb2..ff809a1 100644 --- a/src/libcamera/pipeline/vimc/vimc.cpp +++ b/src/libcamera/pipeline/vimc/vimc.cpp @@ -617,6 +617,8 @@ void VimcCameraData::imageBufferReady(FrameBuffer *buffer) /* Record the sensor's timestamp in the request metadata. */ request->_d()->metadata().set(controls::SensorTimestamp, buffer->metadata().timestamp); + request->_d()->metadata().set(controls::SensorSequence, + static_cast(buffer->metadata().sequence)); pipe->completeBuffer(request, buffer); pipe->completeRequest(request);