From patchwork Wed Oct 16 13:17:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cheng-Hao Yang X-Patchwork-Id: 21642 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 D24FCC32FA for ; Wed, 16 Oct 2024 13:17:40 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 89D056537F; Wed, 16 Oct 2024 15:17:39 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="cgJ0mAbe"; dkim-atps=neutral Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 498956537E for ; Wed, 16 Oct 2024 15:17:37 +0200 (CEST) Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-20c805a0753so53961745ad.0 for ; Wed, 16 Oct 2024 06:17:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1729084655; x=1729689455; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=rWWA1rt5ePfkk+kLieZFRk1f2IM3EcWsIRC4Jkz6C/8=; b=cgJ0mAbeH2pfZGAg2flBv2C+pgMWFmFGsPBWSmNSB2Xf58qIQvo4raIucX9uh7HFnb 3vYcHHZ7YZoAQUkumg37R9k5uKveVQzGa60z06xRZdhFsFjjySgcJ51q4j0ZzKU6Qeun g/czJlUL7l8mCXhApSSqmT/L9MVOCfJTqAYHQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729084655; x=1729689455; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=rWWA1rt5ePfkk+kLieZFRk1f2IM3EcWsIRC4Jkz6C/8=; b=Pe7DgYNkMeN1QQ/Iu64cP6R8josOaXlQCcrLYzqFrLZtGJVHTg2ofoX16fE/plIJxb 67UgcWVl3DytsoLTgxgFFJfLi/gy8rxp+ylitBgADEFM9wVUUCQ/bNroDhuweFSkqSpp lY0y+b2ccBfrJZHYH8GfPDBABl/1xWKYEE3ZsRS390FlU1BTY9BeN+INaWCMnE5i8+9E i6/0HUFdrumM0LroNXrTM/0UxVjDELYLQTVYTg2pybbBL5KXVNNJkNC0IlRDNweKmdtp fSRu3SvFNWnnpQyCb76UDsciZNgGokVJFgetLO/xlmnoLIwH600b6EMCyRotjLgCeezT OkqQ== X-Gm-Message-State: AOJu0YxWPbqRcQhmE3BfJ+U+yCzP3G7p8+Zv0Xg9uBnXaha+u1ztwWjZ 7uOKwoozT8/XPcDRUkkMejXo2D7WjA6SElSqONDOH0XdYf+S6D+2SDyEfBl15fbSjX2HbIzncZQ = X-Google-Smtp-Source: AGHT+IHSVWd7Ge/Q8SvndviogqSjDPX32IVMK3zBJ1ivZAneso37cJEJRRFpHACVG+lKOM/08Feapw== X-Received: by 2002:a17:902:f792:b0:20d:2804:bcde with SMTP id d9443c01a7336-20d2804bd8fmr41406015ad.35.1729084655270; Wed, 16 Oct 2024 06:17:35 -0700 (PDT) Received: from chenghaoyang-low.c.googlers.com.com (199.211.81.34.bc.googleusercontent.com. [34.81.211.199]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20d17f9a0cbsm28315325ad.81.2024.10.16.06.17.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Oct 2024 06:17:34 -0700 (PDT) From: Harvey Yang To: libcamera-devel@lists.libcamera.org Cc: Yudhistira Erlandinata , Harvey Yang Subject: [PATCH] libcamera: reserve frame sequence reported from the hardware Date: Wed, 16 Oct 2024 13:17:28 +0000 Message-ID: <20241016131730.3634805-1-chenghaoyang@chromium.org> X-Mailer: git-send-email 2.47.0.rc1.288.g06298d1525-goog 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: Yudhistira Erlandinata Originally libcamera resets the sequence to 0 on streamOn. However, However, there are occasions when the user needs the original hardware sequence to query processing information of the particular frame. The patch reserves the hwSequence in the FrameMetadata. Signed-off-by: Yudhistira Erlandinata Co-developed-by: Harvey Yang Signed-off-by: Harvey Yang Reviewed-by: Jacopo Mondi --- include/libcamera/framebuffer.h | 1 + src/libcamera/framebuffer.cpp | 9 +++++++++ src/libcamera/v4l2_videodevice.cpp | 1 + 3 files changed, 11 insertions(+) diff --git a/include/libcamera/framebuffer.h b/include/libcamera/framebuffer.h index ff8392430..fccfaa82a 100644 --- a/include/libcamera/framebuffer.h +++ b/include/libcamera/framebuffer.h @@ -34,6 +34,7 @@ struct FrameMetadata { Status status; unsigned int sequence; + unsigned int hwSequence; uint64_t timestamp; Span planes() { return planes_; } diff --git a/src/libcamera/framebuffer.cpp b/src/libcamera/framebuffer.cpp index 826848f75..d9d6294bc 100644 --- a/src/libcamera/framebuffer.cpp +++ b/src/libcamera/framebuffer.cpp @@ -86,6 +86,15 @@ LOG_DEFINE_CATEGORY(Buffer) * Gaps in the sequence numbers indicate dropped frames. */ +/** + * \var FrameMetadata::hwSequence + * \brief The real hardware Frame sequence number + * + * \a FrameMetadata::sequence auto-corrects the initial value to zero on frame + * start. This value keeps the original hardware sequence to allow users to + * query processing information of particular frames. + */ + /** * \var FrameMetadata::timestamp * \brief Time when the frame was captured diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp index 14eba0561..9bc677edf 100644 --- a/src/libcamera/v4l2_videodevice.cpp +++ b/src/libcamera/v4l2_videodevice.cpp @@ -1862,6 +1862,7 @@ FrameBuffer *V4L2VideoDevice::dequeueBuffer() ? FrameMetadata::FrameError : FrameMetadata::FrameSuccess; metadata.sequence = buf.sequence; + metadata.hwSequence = buf.sequence; metadata.timestamp = buf.timestamp.tv_sec * 1000000000ULL + buf.timestamp.tv_usec * 1000ULL;