From patchwork Sat Feb 9 13:54:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 10804481 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B4D6C14E1 for ; Sat, 9 Feb 2019 13:54:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A37372A64F for ; Sat, 9 Feb 2019 13:54:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 90CA42B2B8; Sat, 9 Feb 2019 13:54:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 884772A64F for ; Sat, 9 Feb 2019 13:54:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726989AbfBINyu (ORCPT ); Sat, 9 Feb 2019 08:54:50 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:40651 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726977AbfBINyt (ORCPT ); Sat, 9 Feb 2019 08:54:49 -0500 Received: by mail-wm1-f68.google.com with SMTP id q21so8291123wmc.5 for ; Sat, 09 Feb 2019 05:54:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=TlKFNkDS2fbLkZSLb0kMW0CriAnXfc9THTHiuvSZcqk=; b=tgaO87+skbDLQg6oGFUaYRMMXQRrw2BCegspj5z3tUI9eKBNcqR79JncdwyjO100/m w6krzIDx8lxwMc8DRxYfoeTWRQ4ZM3UHxtljpH/JgiXLqhH3S1dYN2Y+O8sOEPLu4c/f ANBE6t/SEEVHrylD5osX3mcpf8cSORRs2Eb+eTa9orbN855wupJdVK/N8hKyRxrKZ6tX Xk6myjZIIPOEZu4PULH3Z+/R8QE39nMuPfIx7LF/NqjakbNp8NaZMzjU1qEfs1dDcxMX 1xRL9LXgOuP41XXNb8b9vWMZ3+qmmaAgJvnJ8RSi7cR3HXqlABIhndUr+xxnUaX6vMuc ujzg== 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:in-reply-to :references; bh=TlKFNkDS2fbLkZSLb0kMW0CriAnXfc9THTHiuvSZcqk=; b=CUGNHOTZEscCNW7O4+xO2fzAnPRIN6uJdH8e3HjXl6dsQP7d1nZPHXzikv7EXUPPS2 u7w5cipAiqfgvpGYSqgC1X42FkLVLVYJ1VC9Bfa2z4K+rf7EPqHBJfxy+fORMQ759xky 0UhsrodC8V+1E2LnpUFXFu/NZRgc4OK2T2icOZEUi7g7chqFQcmDfhsFCCoP1vPDTNeu MZK5lfQItLFBuukFi9F8C0Q2DBQjvy0qxhIPZXLOTmGMmqcqlflcLUuKH/CCDIk6JWqS p1T370iDasO1sL4oCYJpPLDLAyzAFX8KaSSmO7Ozbm2eeFOYf4knfJXAVRfuUDU4UISu Ur/w== X-Gm-Message-State: AHQUAubOX2Y0Bx8MIgcuWNWDyLdpLhyjUwCXHDHEgz1krO2aGzuLyYGb bzRYHubRv6NTYiBfVQ+brPDa7d1Oans= X-Google-Smtp-Source: AHgI3IYhDHGLocAzpLRcslJ6kHdEkSQDdOJrgfGnQrfJ33395yb20xFthu/0ymnKRDSmsNQXr7QwRw== X-Received: by 2002:a5d:50c5:: with SMTP id f5mr19828790wrt.37.1549720487532; Sat, 09 Feb 2019 05:54:47 -0800 (PST) Received: from localhost.localdomain ([87.70.76.19]) by smtp.gmail.com with ESMTPSA id a15sm2864081wrx.58.2019.02.09.05.54.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 09 Feb 2019 05:54:47 -0800 (PST) From: Dafna Hirschfeld To: linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, helen.koike@collabora.com, Dafna Hirschfeld Subject: [PATCH 7/9] media: vb2: Add func that return buffer by timestamp Date: Sat, 9 Feb 2019 05:54:25 -0800 Message-Id: <20190209135427.20630-8-dafna3@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190209135427.20630-1-dafna3@gmail.com> References: <20190209135427.20630-1-dafna3@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add the function 'vb2_find_timestamp_buf' that returns the vb2 buffer that matches the given timestamp Signed-off-by: Dafna Hirschfeld --- drivers/media/common/videobuf2/videobuf2-v4l2.c | 14 ++++++++++++++ include/media/videobuf2-v4l2.h | 3 +++ 2 files changed, 17 insertions(+) diff --git a/drivers/media/common/videobuf2/videobuf2-v4l2.c b/drivers/media/common/videobuf2/videobuf2-v4l2.c index 3aeaea3af42a..47c245a76561 100644 --- a/drivers/media/common/videobuf2/videobuf2-v4l2.c +++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c @@ -598,6 +598,20 @@ static const struct vb2_buf_ops v4l2_buf_ops = { .copy_timestamp = __copy_timestamp, }; +struct vb2_buffer *vb2_find_timestamp_buf(const struct vb2_queue *q, + u64 timestamp, + unsigned int start_idx) +{ + unsigned int i; + + for (i = start_idx; i < q->num_buffers; i++) { + if (q->bufs[i]->timestamp == timestamp) + return q->bufs[i]; + } + return NULL; +} +EXPORT_SYMBOL_GPL(vb2_find_timestamp_buf); + int vb2_find_timestamp(const struct vb2_queue *q, u64 timestamp, unsigned int start_idx) { diff --git a/include/media/videobuf2-v4l2.h b/include/media/videobuf2-v4l2.h index 8a10889dc2fd..7fc2a235064e 100644 --- a/include/media/videobuf2-v4l2.h +++ b/include/media/videobuf2-v4l2.h @@ -71,6 +71,9 @@ struct vb2_v4l2_buffer { int vb2_find_timestamp(const struct vb2_queue *q, u64 timestamp, unsigned int start_idx); +struct vb2_buffer *vb2_find_timestamp_buf(const struct vb2_queue *q, + u64 timestamp, + unsigned int start_idx); int vb2_querybuf(struct vb2_queue *q, struct v4l2_buffer *b); /**