From patchwork Wed May 12 08:47:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 12251 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 AA50AC31E3 for ; Wed, 12 May 2021 08:47:51 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0A51668920; Wed, 12 May 2021 10:47:51 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="qDa0Fasy"; dkim-atps=neutral Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7D0CA688E4 for ; Wed, 12 May 2021 10:47:49 +0200 (CEST) Received: by mail-wr1-x42c.google.com with SMTP id q5so3298588wrs.4 for ; Wed, 12 May 2021 01:47:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=AJ6XpHi6pLrZNinv13+3uvM+Ynhndyf1PXAUaNkGF1c=; b=qDa0FasyUNKRJ36FpC3Q7Mz52otpUBD1vW6z3qrk6chBU2eAU+pKbfNNDJ+OF/bJNv b1T6Yq+5/c5Ql2PUjAKd4tUT+P7Mac33zuMHZdxlWh3s20+NLfhuWOpUihv5FdeJ1Dev bLxPohDF8cCwPPGlZHWO6yBlyIXf5lOY/n6l9K/IvKzlvQ70dm/6AYyb6WUuGoz+XsFl Xe0t0XM/FHsht52Teo5BGnXi8lF4AEOtdxA8215JRMdmIT9VNDjvohTpGbk3Dp1sgE7k 9uV57sgIJLiPLgZqFSpjA11L5tP3FBqAncbQJC20YLs+j+weAH1e/FaAHzSyuL5Fg1zx uJFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=AJ6XpHi6pLrZNinv13+3uvM+Ynhndyf1PXAUaNkGF1c=; b=Z8biXyxC2jf99svDlvmWORQlzAprLxP5xavOyLwTccFTxjGaX6kRTD47+fd6bLsmbA L3GGYPyNe4GGZ0QpPO+ey6vhOdXzhPQhkVAO/wpAYI7/iDLhOLbx304+6kRX7VBvfe7G uOT1RJCG7xXa6F/inBsp3s+AudsRmxn55184JUOAbkI+NxkM44Z+aCrHAkMGZrxpGPuE NvRnIaFb+xSLuo7YW6Ddn6pcceRVHIHA3K6xmkZmGmbWzR3DqcPDAT/IlrHPQmkIKY2T 42spfTJFGiFFCVojOUV1w0Xu0XQLvf+edfDe195Y3NptcJIvwd6eTwHv/mN3KtoYeiMS 2J6A== X-Gm-Message-State: AOAM532FgiOiCj1j2x4Z8K/raeX5hTLfiqO/v+7wPAecGBOztZBkjWRu O3RhGTskT16zjg8I5BdbA87xTKVj2aQUXw== X-Google-Smtp-Source: ABdhPJx5rwiuWmvZVr0ky4BYxjfGEdrFzbGrA1GXffJccbU7NVHM6GHMCiUBcs/aKmrWK6qAM89yMA== X-Received: by 2002:a5d:524f:: with SMTP id k15mr43414469wrc.412.1620809268941; Wed, 12 May 2021 01:47:48 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:d29a:cbe2:1c54:7a47]) by smtp.gmail.com with ESMTPSA id d3sm16370759wrs.41.2021.05.12.01.47.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 May 2021 01:47:48 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Wed, 12 May 2021 09:47:43 +0100 Message-Id: <20210512084744.1499469-1-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/2] pipeline: raspberrypi: Store timestamp in the correct Request metadata 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" Write the controls::SensorTimestamp value in the Request metadata when the request is popped from the queue ready to run the pipeline. This ensures that the timestamp is written to the correct Request item, which may not be at the top of the queue when the Unicam buffer dequeue occurs. Fixes: fcfb1dc02a6b ("libcamera: raspberry: Report sensor timestamp") Signed-off-by: Naushir Patuck Reviewed-by: David Plowman Tested-by: David Plowman Reviewed-by: Kieran Bingham --- .../pipeline/raspberrypi/raspberrypi.cpp | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 6fbdba0487bf..eb6d31670567 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -221,6 +221,8 @@ public: private: void checkRequestCompleted(); + void fillRequestMetadata(const ControlList &bufferControls, + Request *request); void tryRunPipeline(); bool findMatchingBuffers(BayerFrame &bayerFrame, FrameBuffer *&embeddedBuffer); @@ -1416,18 +1418,6 @@ void RPiCameraData::unicamBufferDequeue(FrameBuffer *buffer) << ", timestamp: " << buffer->metadata().timestamp; if (stream == &unicam_[Unicam::Image]) { - /* - * Record the sensor timestamp in the Request. - * - * \todo Do not assume the request in the front of the queue - * is the correct one - */ - Request *request = requestQueue_.front(); - ASSERT(request); - - request->metadata().set(controls::SensorTimestamp, - buffer->metadata().timestamp); - /* * Lookup the sensor controls used for this frame sequence from * DelayedControl and queue them along with the frame buffer. @@ -1689,6 +1679,13 @@ void RPiCameraData::applyScalerCrop(const ControlList &controls) } } +void RPiCameraData::fillRequestMetadata(const ControlList &bufferControls, + Request *request) +{ + request->metadata().set(controls::SensorTimestamp, + bufferControls.get(controls::SensorTimestamp)); +} + void RPiCameraData::tryRunPipeline() { FrameBuffer *embeddedBuffer; @@ -1708,6 +1705,14 @@ void RPiCameraData::tryRunPipeline() /* See if a new ScalerCrop value needs to be applied. */ applyScalerCrop(request->controls()); + /* + * Clear the request metadata and fill it with some initial non-IPA + * related controls. We clear it first because the request metadata + * may have been populated if we have dropped the previous frame. + */ + request->metadata().clear(); + fillRequestMetadata(bayerFrame.controls, request); + /* * Process all the user controls by the IPA. Once this is complete, we * queue the ISP output buffer listed in the request to start the HW