From patchwork Thu Mar 17 10:47:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 15467 X-Patchwork-Delegate: umang.jain@ideasonboard.com 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 653E4BF415 for ; Thu, 17 Mar 2022 10:48:00 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 172DE604E7; Thu, 17 Mar 2022 11:48:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1647514080; bh=QrHewiwr1p6gh6db+ZbzoHZ+xKjSPTmddti8+OdsEPA=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=Oai80aMnFNtMDBIziX+D+v3EMI2CT3kubUwg1fhb17y5ngLkD52t6gS33YkjU6xLc 2SOAEVkgrDsue4NnbzhcPrYLjTlESxyr8SOntGa3vG7fz/RQsviqb7dth2PWm5tdVV 1rvYarW+AOdwnmfjtTE7rADONm6LMnRQeYFqr6XwNQ1ppXFRPj51mWfcMBmQX7qdmN +d9ZMHEp6aZjTkvTPbF4tyQbe2MMZXosGs2zV7q247bQ8bvMQJwu6F1+WZW+LhE6Nt AL3qEDitZ8s309Odz7TjMeQSzf+TUxYb/ilOrZvdoDA3canq9isHZdz2YWyYSLYRHy s+ZqY1OptzmUA== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3FEBA604DB for ; Thu, 17 Mar 2022 11:47:58 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Xs2At/4z"; dkim-atps=neutral Received: from perceval.ideasonboard.com (unknown [103.251.226.83]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 2CE1C929; Thu, 17 Mar 2022 11:47:55 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1647514077; bh=QrHewiwr1p6gh6db+ZbzoHZ+xKjSPTmddti8+OdsEPA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Xs2At/4zIM0B9VIBnANmHdDnlBoSiBprTtiI7gRSVw1aBalBoMKLZE6ztNNx6Q0Ry Uw3qT/OKUAQGUruFgxiIrjgr9gdl/ezy0Hd5eI8pR9jMoBQA2O7E6xe9m8iOfouylZ VhND34aQQxp4MzDuXuAz2qPgmqLPZHzaYFDgu1J0= To: libcamera-devel@lists.libcamera.org Date: Thu, 17 Mar 2022 16:17:39 +0530 Message-Id: <20220317104740.569310-3-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220317104740.569310-1-umang.jain@ideasonboard.com> References: <20220317104740.569310-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/3] libcamera: v4l2_videodevice: Clarify setting of v4l2_buffer timestamp 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: , X-Patchwork-Original-From: Umang Jain via libcamera-devel From: Umang Jain Reply-To: Umang Jain Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add a comment to clarify why we set v4l2_buffer timestamp while queuing the buffer (VIDIOC_QBUF). The timstamps are required to be supplied for memory-to-memory devices for output streams which then are copied to capture stream buffers with the help of V4L2_BUF_FLAG_TIMESTAMP_COPY (set by the driver). Signed-off-by: Umang Jain Reviewed-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- src/libcamera/v4l2_videodevice.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp index 5580269f..a6c54b19 100644 --- a/src/libcamera/v4l2_videodevice.cpp +++ b/src/libcamera/v4l2_videodevice.cpp @@ -1600,6 +1600,14 @@ int V4L2VideoDevice::queueBuffer(FrameBuffer *buffer) buf.length = planes[0].length; } + /* + * Timestamps are to be supplied if the device is a mem-to-mem + * device. The drivers will have V4L2_BUF_FLAG_TIMESTAMP_COPY + * set hence these timestamps will be copied from the output + * buffers to capture buffers. If the device is not mem-to-men, + * there is no harm in setting the timestamps as they will be + * ignored (and over-written). + */ buf.timestamp.tv_sec = metadata.timestamp / 1000000000; buf.timestamp.tv_usec = (metadata.timestamp / 1000) % 1000000; }