{"id":27198,"url":"https://patchwork.libcamera.org/api/patches/27198/?format=json","web_url":"https://patchwork.libcamera.org/patch/27198/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20260703224817.15650-2-ballen4705@googlemail.com>","date":"2026-07-03T22:48:16","name":"[v2,1/2] libcamera: Add SensorSequence metadata control","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"7fc9ffa36aa5fa4dd6d61a3043669c2aaa7ffe45","submitter":{"id":321,"url":"https://patchwork.libcamera.org/api/people/321/?format=json","name":"Bruce Allen","email":"ballen4705@googlemail.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/27198/mbox/","series":[{"id":6037,"url":"https://patchwork.libcamera.org/api/series/6037/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=6037","date":"2026-07-03T22:48:15","name":"libcamera: Add SensorSequence request metadata control","version":2,"mbox":"https://patchwork.libcamera.org/series/6037/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/27198/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/27198/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 389A8C330A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  3 Jul 2026 22:50:01 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 79FF465FC1;\n\tSat,  4 Jul 2026 00:49:59 +0200 (CEST)","from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com\n\t[IPv6:2a00:1450:4864:20::32e])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 03A5A65FC1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat,  4 Jul 2026 00:49:57 +0200 (CEST)","by mail-wm1-x32e.google.com with SMTP id\n\t5b1f17b1804b1-493b1710405so5912585e9.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 03 Jul 2026 15:49:57 -0700 (PDT)","from localhost.localdomain (tmo-121-138.customers.d1-online.com.\n\t[80.187.121.138]) by smtp.gmail.com with ESMTPSA id\n\t5b1f17b1804b1-493c63ba971sm255611285e9.13.2026.07.03.15.49.55\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 03 Jul 2026 15:49:55 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=googlemail.com header.i=@googlemail.com\n\theader.b=\"PZOIs5XA\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=googlemail.com; s=20251104; t=1783118996; x=1783723796;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=dJS2lyOWBfoBNbBgM2SdI4CsiTkDw7Ch+iLzxHa5S2U=;\n\tb=PZOIs5XAhjW7Y+MZMrIftByZhOJfMGqdFbFZ06dtkqK3dLXFMD6VTiZfA05e1h3ylx\n\tjuADF0l4RMxKyEFWB+Arat1/YD4Btoej+bJFF/8AmvrSGy5k2wONTVBub3dI02JK9kyM\n\t5q6bedblNq6Sk83m0ndfx4rIXQtKFYvKObIjkVfPLde4y6nwchoruunVaf5LU0ruxtxY\n\ttgeygSJsA74iCGv/qYca/HTzSTnu+njYFoake37hgVF0SNnCiilAMK/vBQAW2OgwdcRO\n\tL6BcGTqMC5McAZDiDEwAbLsyPAtJwfTCxLAJ1QSIC/YgqJ9nN8ibCjaJb8AL0fRb460n\n\tPSRw==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20251104; t=1783118996; x=1783723796;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n\t:to:cc:subject:date:message-id:reply-to;\n\tbh=dJS2lyOWBfoBNbBgM2SdI4CsiTkDw7Ch+iLzxHa5S2U=;\n\tb=Vobl3bPiREpTaIXTlFKJF8n1kIudj2T7MWOPwYasbI4VIGyQN6oPKn41KzJJZLPACd\n\tX/gU0BGMjx5Wsk0mpy3ZLo30r79oA48w8GZj6P2HAFIQbHkLJbV3QFhFuXEPS0bt4No2\n\tqbPM0SXbgJIsNwtCG/qCwcI2Z4QGUF43sTE9Or7Ekg+ZqHkQ1vWyPAUoa2pHMvnhpHgh\n\tQ0Ged9NW7M/SGT0db3LR6hk9We6X9khsZCjZ8sZeM+CCrg67OK4aKytdDqCBt9Ku/JAV\n\tPpCjfrha+9dtO8v9Pdvuo3edyq5PPceNCiwG1gMlZTCLyh3LfWu16Uigblb0Xgsw6hr6\n\txdfw==","X-Gm-Message-State":"AOJu0YxtY4xALHflDIcQ2DAz3PzQ14IQ+7WIwCgOCfoYjto3HWuyQKdn\n\t2F5x52PuvGEUbEK3IXuY6RSgwNClCyphBFyZEfvFk0SL7/0vuhSM1WWg/vHjUrO2","X-Gm-Gg":"AfdE7cnfCzCEwqNghWZTCVdsodw4Ma86uF4LDpyMPl80n6xFRtMo1Y8Yrlm/NnOWzsQ\n\tDlKi89yfm7QiArJXV21keZwhWnulHNS+X0ULtZcIzerYmIAeAd7nFsrcGyWZqGXNe8JHMPAadZf\n\t0yQZxiQeu5/k+Jm38WuMTxEL2wIt9bRVc1XyMPifB5sEz1alozIxmkReolT0LJOcEluZSfzyoU/\n\tLCuS7ukGR1SkAcUMBeIWPu/hqdYx4bmx/FuEc9o0nRQsGs/kpYCXolQR5py9JgVf25O5+3HbD7y\n\tlS8SBwa2a49RaLDXffjwDaKb6mrvfce8rv1JgzA9Unho0qkx9uJ7TUlJIyX7zxDznvqoM8PigJI\n\tZbsjQwSoHrlVSQtfNVfPRQpJSoX6Uoa1qMgnA0OXA60RcNSjzah/ayUnOdOHPitD2YKhphsW+se\n\tgtvIjx0ys7TitL/SR7SgcqWOE6EtTx+tXON/KzJ1MAY4PHMO5mMi0dyJ/rBsxsoie8uDDBX68Mp\n\td1J3wBCNTM=","X-Received":"by 2002:a05:600c:6287:b0:490:e5c1:b8b9 with SMTP id\n\t5b1f17b1804b1-493d1188014mr11954295e9.0.1783118996318; \n\tFri, 03 Jul 2026 15:49:56 -0700 (PDT)","From":"Bruce Allen <ballen4705@googlemail.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Bruce Allen <ballen4705@googlemail.com>","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>\n\t<20260703224817.15650-1-ballen4705@googlemail.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Add controls::SensorSequence (int64_t, out) to report the monotonic\nsequence number from the sensor-facing capture device in request\nmetadata. Populate the control in all pipeline handlers that already\nreport SensorTimestamp.\n\nSigned-off-by: Bruce Allen <ballen4705@googlemail.com>\n---\n src/libcamera/control_ids_core.yaml                | 18 ++++++++++++++++++\n src/libcamera/pipeline/imx8-isi/imx8-isi.cpp       |  3 +++\n src/libcamera/pipeline/ipu3/ipu3.cpp               |  2 ++\n src/libcamera/pipeline/mali-c55/mali-c55.cpp       |  2 ++\n src/libcamera/pipeline/rkisp1/rkisp1.cpp           |  2 ++\n src/libcamera/pipeline/rpi/common/pipeline_base.cpp |  2 ++\n src/libcamera/pipeline/rpi/pisp/pisp.cpp          |  2 ++\n src/libcamera/pipeline/rpi/vc4/vc4.cpp             |  2 ++\n src/libcamera/pipeline/simple/simple.cpp           |  5 ++++-\n src/libcamera/pipeline/uvcvideo/uvcvideo.cpp        |  2 ++\n src/libcamera/pipeline/vimc/vimc.cpp               |  2 ++\n 11 files changed, 41 insertions(+), 1 deletion(-)","diff":"diff --git a/src/libcamera/control_ids_core.yaml b/src/libcamera/control_ids_core.yaml\nindex 89991d0..d6bc114 100644\n--- a/src/libcamera/control_ids_core.yaml\n+++ b/src/libcamera/control_ids_core.yaml\n@@ -792,6 +792,24 @@ controls:\n         \\todo Define how the sensor timestamp has to be used in the reprocessing\n         use case.\n \n+  - SensorSequence:\n+      type: int64_t\n+      direction: out\n+      description: |\n+        The monotonic sequence number from the sensor capture device.\n+\n+        Pipeline handlers populate this metadata control with the sequence\n+        number reported by the sensor-facing capture device (for example the\n+        CSI-2 receiver or V4L2 video node). Any break in this sequence number\n+        indicates that frames were dropped or not captured before the previous\n+        request completed.\n+\n+        While per-buffer FrameMetadata::sequence identifies frames in each\n+        completed stream, SensorSequence reflects the sensor-side capture path\n+        and is intended for diagnosing frame continuity.\n+\n+        The SensorSequence control can only be returned in metadata.\n+\n   - AfMode:\n       type: int32_t\n       direction: inout\ndiff --git a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp\nindex c3d2695..d2175b9 100644\n--- a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp\n+++ b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp\n@@ -1130,6 +1130,9 @@ void PipelineHandlerISI::bufferReady(FrameBuffer *buffer)\n \tif (!metadata.contains(controls::SensorTimestamp.id()))\n \t\tmetadata.set(controls::SensorTimestamp,\n \t\t\t     buffer->metadata().timestamp);\n+\tif (!metadata.contains(controls::SensorSequence.id()))\n+\t\tmetadata.set(controls::SensorSequence,\n+\t\t\t     static_cast<int64_t>(buffer->metadata().sequence));\n \n \tif (completeBuffer(request, buffer))\n \t\tcompleteRequest(request);\ndiff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nindex 0f3e169..6494259 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -1317,6 +1317,8 @@ void IPU3CameraData::cio2BufferReady(FrameBuffer *buffer)\n \t */\n \trequest->_d()->metadata().set(controls::SensorTimestamp,\n \t\t\t\t      buffer->metadata().timestamp);\n+\trequest->_d()->metadata().set(controls::SensorSequence,\n+\t\t\t\t      static_cast<int64_t>(buffer->metadata().sequence));\n \n \tinfo->effectiveSensorControls = delayedCtrls_->get(buffer->metadata().sequence);\n \ndiff --git a/src/libcamera/pipeline/mali-c55/mali-c55.cpp b/src/libcamera/pipeline/mali-c55/mali-c55.cpp\nindex 599ff88..119b249 100644\n--- a/src/libcamera/pipeline/mali-c55/mali-c55.cpp\n+++ b/src/libcamera/pipeline/mali-c55/mali-c55.cpp\n@@ -1704,6 +1704,8 @@ void PipelineHandlerMaliC55::cruBufferReady(FrameBuffer *buffer)\n \tRequest *request = info->request;\n \trequest->_d()->metadata().set(controls::SensorTimestamp,\n \t\t\t\t      buffer->metadata().timestamp);\n+\trequest->_d()->metadata().set(controls::SensorSequence,\n+\t\t\t\t      static_cast<int64_t>(buffer->metadata().sequence));\n \n \tMaliC55CameraData *data = cameraData(request->_d()->camera());\n \tdata->ipa_->fillParams(request->sequence(), info->paramBuffer->cookie());\ndiff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\nindex 4f9c0aa..0c73f5a 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n@@ -1647,6 +1647,8 @@ void PipelineHandlerRkISP1::imageBufferReady(FrameBuffer *buffer)\n \t\t */\n \t\trequest->_d()->metadata().set(controls::SensorTimestamp,\n \t\t\t\t\t      metadata.timestamp);\n+\t\trequest->_d()->metadata().set(controls::SensorSequence,\n+\t\t\t\t\t      static_cast<int64_t>(metadata.sequence));\n \n \t\tif (isRaw_) {\n \t\t\tconst ControlList &ctrls =\ndiff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp\nindex 5a5acf6..dcf8e6a 100644\n--- a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp\n+++ b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp\n@@ -1514,6 +1514,8 @@ void CameraData::fillRequestMetadata(const ControlList &bufferControls, Request\n {\n \tif (auto x = bufferControls.get(controls::SensorTimestamp))\n \t\trequest->_d()->metadata().set(controls::SensorTimestamp, *x);\n+\tif (auto x = bufferControls.get(controls::SensorSequence))\n+\t\trequest->_d()->metadata().set(controls::SensorSequence, *x);\n \tif (auto x = bufferControls.get(controls::FrameWallClock))\n \t\trequest->_d()->metadata().set(controls::FrameWallClock, *x);\n \ndiff --git a/src/libcamera/pipeline/rpi/pisp/pisp.cpp b/src/libcamera/pipeline/rpi/pisp/pisp.cpp\nindex b744c90..0832432 100644\n--- a/src/libcamera/pipeline/rpi/pisp/pisp.cpp\n+++ b/src/libcamera/pipeline/rpi/pisp/pisp.cpp\n@@ -1766,6 +1766,8 @@ void PiSPCameraData::cfeBufferDequeue(FrameBuffer *buffer)\n \n \t\tctrl.set(controls::SensorTimestamp, sensorTimestamp);\n \t\tctrl.set(controls::FrameWallClock, wallClockTimestamp);\n+\t\tctrl.set(controls::SensorSequence,\n+\t\t\t static_cast<int64_t>(buffer->metadata().sequence));\n \t\tjob.sensorControls = std::move(ctrl);\n \t\tjob.delayContext = delayContext;\n \t} else if (stream == &cfe_[Cfe::Config]) {\ndiff --git a/src/libcamera/pipeline/rpi/vc4/vc4.cpp b/src/libcamera/pipeline/rpi/vc4/vc4.cpp\nindex 3e9a490..1e7b26a 100644\n--- a/src/libcamera/pipeline/rpi/vc4/vc4.cpp\n+++ b/src/libcamera/pipeline/rpi/vc4/vc4.cpp\n@@ -787,6 +787,8 @@ void Vc4CameraData::unicamBufferDequeue(FrameBuffer *buffer)\n \n \t\tctrl.set(controls::SensorTimestamp, sensorTimestamp);\n \t\tctrl.set(controls::FrameWallClock, wallClockTimestamp);\n+\t\tctrl.set(controls::SensorSequence,\n+\t\t\t static_cast<int64_t>(buffer->metadata().sequence));\n \t\tbayerQueue_.push({ buffer, std::move(ctrl), delayContext });\n \t} else {\n \t\tembeddedQueue_.push(buffer);\ndiff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp\nindex e26f438..ce34bb2 100644\n--- a/src/libcamera/pipeline/simple/simple.cpp\n+++ b/src/libcamera/pipeline/simple/simple.cpp\n@@ -939,9 +939,12 @@ void SimpleCameraData::imageBufferReady(FrameBuffer *buffer)\n \t\t}\n \t}\n \n-\tif (request)\n+\tif (request) {\n \t\trequest->_d()->metadata().set(controls::SensorTimestamp,\n \t\t\t\t\t      buffer->metadata().timestamp);\n+\t\trequest->_d()->metadata().set(controls::SensorSequence,\n+\t\t\t\t\t      static_cast<int64_t>(buffer->metadata().sequence));\n+\t}\n \n \t/*\n \t * Queue the captured and the request buffer to the converter or Software\ndiff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\nindex 3435a76..e0b7dad 100644\n--- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n+++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n@@ -897,6 +897,8 @@ void UVCCameraData::imageBufferReady(FrameBuffer *buffer)\n \t/* \\todo Use the UVC metadata to calculate a more precise timestamp */\n \trequest->_d()->metadata().set(controls::SensorTimestamp,\n \t\t\t\t      buffer->metadata().timestamp);\n+\trequest->_d()->metadata().set(controls::SensorSequence,\n+\t\t\t\t      static_cast<int64_t>(buffer->metadata().sequence));\n \n \tpipe()->completeBuffer(request, buffer);\n \tpipe()->completeRequest(request);\ndiff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp\nindex 01d8fb2..ff809a1 100644\n--- a/src/libcamera/pipeline/vimc/vimc.cpp\n+++ b/src/libcamera/pipeline/vimc/vimc.cpp\n@@ -617,6 +617,8 @@ void VimcCameraData::imageBufferReady(FrameBuffer *buffer)\n \t/* Record the sensor's timestamp in the request metadata. */\n \trequest->_d()->metadata().set(controls::SensorTimestamp,\n \t\t\t\t      buffer->metadata().timestamp);\n+\trequest->_d()->metadata().set(controls::SensorSequence,\n+\t\t\t\t      static_cast<int64_t>(buffer->metadata().sequence));\n \n \tpipe->completeBuffer(request, buffer);\n \tpipe->completeRequest(request);\n","prefixes":["v2","1/2"]}