From patchwork Fri Jun 16 07:39:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Padovan X-Patchwork-Id: 9790801 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 8BC2660326 for ; Fri, 16 Jun 2017 07:39:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 80B0E280B0 for ; Fri, 16 Jun 2017 07:39:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7592B2857E; Fri, 16 Jun 2017 07:39:53 +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.9 required=2.0 tests=BAYES_00,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 23405280B0 for ; Fri, 16 Jun 2017 07:39:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752777AbdFPHjv (ORCPT ); Fri, 16 Jun 2017 03:39:51 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:36111 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752134AbdFPHju (ORCPT ); Fri, 16 Jun 2017 03:39:50 -0400 Received: by mail-pf0-f193.google.com with SMTP id y7so4715434pfd.3 for ; Fri, 16 Jun 2017 00:39:50 -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=RHVRnOa+YjPieT1w1vvKGCHvCJ9maatwte/zHXvRm7I=; b=sr9PuSOqWll+imXyW2SyBZD2py+2QzeV6N2mofLVWmqJXDu0940p78nlWoj1/JDwjX 26D/xq7nbhzxgf86GCQ8OGfVR5rj3S7yq8eU609j0xFNya1xNI07J9fw5Aqd9awXJ0fo xkE6JDdEz2e3U/3e3+V1k5o/D2ZkEh3Q9ulf14Mwp33IHZHpqSecGrFgk6M8LtCEEDPT 8tJd9p65rY/PUcdpj+mLkLuC1tEyB2XHdErsbFlfouJjBz2c6rXlvTR6D+/wNTGpCsdY YaxYWjIMoVdbWyBUqwDR1skjIf3oG4DOYVkLCa4Rx5Ot703RKETgrqj0ECEhQhZJQrua npnw== X-Gm-Message-State: AKS2vOxJgthXpiGZgGi33Q6n8YX6mK+Gkpko5WQFqZN0B3ampbSkgrkl h8zr1S0Seq+ObO3JqPw= X-Received: by 10.98.158.138 with SMTP id f10mr9689980pfk.177.1497598789776; Fri, 16 Jun 2017 00:39:49 -0700 (PDT) Received: from jade.nodan1.kt.home.ne.jp (202-72-64-244.koalanet.ne.jp. [202.72.64.244]) by smtp.gmail.com with ESMTPSA id a2sm2760568pfj.8.2017.06.16.00.39.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Jun 2017 00:39:49 -0700 (PDT) From: Gustavo Padovan To: linux-media@vger.kernel.org Cc: Hans Verkuil , Javier Martinez Canillas , Mauro Carvalho Chehab , Shuah Khan , Gustavo Padovan Subject: [PATCH 11/12] [media] vb2: add infrastructure to support out-fences Date: Fri, 16 Jun 2017 16:39:14 +0900 Message-Id: <20170616073915.5027-12-gustavo@padovan.org> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170616073915.5027-1-gustavo@padovan.org> References: <20170616073915.5027-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 00d9c35..21cc4ed 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 @@ -1335,6 +1338,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 a8b800e..5f3e3eb 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 @@ -714,6 +718,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 *