From patchwork Mon Mar 13 19:20:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Padovan X-Patchwork-Id: 9621903 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D78AE60244 for ; Mon, 13 Mar 2017 19:22:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BED5D284F4 for ; Mon, 13 Mar 2017 19:22:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B35DF2850D; Mon, 13 Mar 2017 19:22:28 +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=-6.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM 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 63C31284F4 for ; Mon, 13 Mar 2017 19:22:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754178AbdCMTW1 (ORCPT ); Mon, 13 Mar 2017 15:22:27 -0400 Received: from mail-qt0-f196.google.com ([209.85.216.196]:34489 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753498AbdCMTVJ (ORCPT ); Mon, 13 Mar 2017 15:21:09 -0400 Received: by mail-qt0-f196.google.com with SMTP id x35so7472753qtc.1; Mon, 13 Mar 2017 12:21:08 -0700 (PDT) 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=Jzt5hM5ro8PwB3waFpXqnAaWZZJMGauV0ROeuwkcDm4=; b=mRHDmzcJMxhuKntB63qyLzWpIooznfdy448KkVMdCa0+lzBKra2zyw22U8xKZsAsUq 2iCLGhg2mQOX/7b9oMkxqP9gXqFEmJ6Y2xZBbLJvw2ewTvLW11O7RCafczSD6h5QJP59 XOtJKKhMtxKT+cAbOlvcfXUI7TW9+hLm6sxG2w65ZR3hEVFTGOt4a7UTH32NBCPO8UiL 5kYxpAQVV0L9JCewC67UR67GBoZdEzqtHhZsEyNzrCDV+vWulPBJdYQ+rpNATdAk23Kz M5zs2t3l6jIQrVPouwgBa8jiebJbuu9KDePa7Pe6Q91wzJp4dTBzgI4OzLXeA56IgES2 g8lw== X-Gm-Message-State: AMke39lz2L6SNuzpht4SCHQvTh+BuwaWQE3j7vTpgz5/CkQww40GT0s8lt0cJmMQBOfz2Q== X-Received: by 10.200.0.25 with SMTP id a25mr32056413qtg.199.1489432867423; Mon, 13 Mar 2017 12:21:07 -0700 (PDT) Received: from localhost.localdomain ([179.159.9.225]) by smtp.gmail.com with ESMTPSA id a19sm12821047qta.48.2017.03.13.12.21.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Mar 2017 12:21:07 -0700 (PDT) From: Gustavo Padovan To: linux-media@vger.kernel.org Cc: Hans Verkuil , Mauro Carvalho Chehab , Laurent Pinchart , Javier Martinez Canillas , linux-kernel@vger.kernel.org, Gustavo Padovan Subject: [RFC 09/10] [media] vb2: add infrastructure to support out-fences Date: Mon, 13 Mar 2017 16:20:34 -0300 Message-Id: <20170313192035.29859-10-gustavo@padovan.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170313192035.29859-1-gustavo@padovan.org> References: <20170313192035.29859-1-gustavo@padovan.org> 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 From: Gustavo Padovan Add vb2_setup_out_fence() and the needed members to struct vb2_buffer. Signed-off-by: Gustavo Padovan --- drivers/media/v4l2-core/videobuf2-core.c | 31 +++++++++++++++++++++++++++++++ include/media/videobuf2-core.h | 5 +++++ 2 files changed, 36 insertions(+) diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c index d9cb777..54b1404 100644 --- a/drivers/media/v4l2-core/videobuf2-core.c +++ b/drivers/media/v4l2-core/videobuf2-core.c @@ -23,8 +23,11 @@ #include #include #include +#include +#include #include +#include #include #include @@ -1315,6 +1318,34 @@ int vb2_core_prepare_buf(struct vb2_queue *q, unsigned int index, void *pb) } EXPORT_SYMBOL_GPL(vb2_core_prepare_buf); +int vb2_setup_out_fence(struct vb2_queue *q, unsigned int index) +{ + struct vb2_buffer *vb = q->bufs[index]; + + vb->out_fence_fd = get_unused_fd_flags(O_CLOEXEC); + if (vb->out_fence_fd < 0) + return vb->out_fence_fd; + + vb->out_fence = vb2_fence_alloc(); + if (!vb->out_fence) + goto err; + + vb->sync_file = sync_file_create(vb->out_fence); + if (!vb->sync_file) { + dma_fence_put(vb->out_fence); + vb->out_fence = NULL; + goto err; + } + + return 0; + +err: + put_unused_fd(vb->out_fence_fd); + vb->out_fence_fd = -1; + return -ENOMEM; +} +EXPORT_SYMBOL_GPL(vb2_setup_out_fence); + /** * vb2_start_streaming() - Attempt to start streaming. * @q: videobuf2 queue diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h index fe2de99..efdc390 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h @@ -263,6 +263,10 @@ struct vb2_buffer { struct dma_fence *in_fence; struct dma_fence_cb fence_cb; + + struct dma_fence *out_fence; + struct sync_file *sync_file; + int out_fence_fd; #ifdef CONFIG_VIDEO_ADV_DEBUG /* * Counters for how often these buffer-related ops are @@ -710,6 +714,7 @@ int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory, */ int vb2_core_prepare_buf(struct vb2_queue *q, unsigned int index, void *pb); +int vb2_setup_out_fence(struct vb2_queue *q, unsigned int index); /** * vb2_core_qbuf() - Queue a buffer from userspace *