From patchwork Fri Sep 1 01:50:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gustavo F. Padovan" X-Patchwork-Id: 43680 X-Patchwork-Delegate: hverkuil@xs4all.nl Received: from vger.kernel.org ([209.132.180.67]) by www.linuxtv.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dnb7I-0002eG-PY; Fri, 01 Sep 2017 01:51:29 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751733AbdIABv1 (ORCPT + 1 other); Thu, 31 Aug 2017 21:51:27 -0400 Received: from mail-qt0-f195.google.com ([209.85.216.195]:37074 "EHLO mail-qt0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751725AbdIABv0 (ORCPT ); Thu, 31 Aug 2017 21:51:26 -0400 Received: by mail-qt0-f195.google.com with SMTP id x29so1000613qtc.4 for ; Thu, 31 Aug 2017 18:51:26 -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=I5UvZ1tD25ZqZ6PsgJtg6MyfPk0fQeIgEAnW2SMTJ7Y=; b=OiYHT5y/jEc6HZ2gLRE/IN/86cpq+V/PxrJKFGhrcdRrfLmDMUf/A/RX4+VM/WtR7m N67BDCm8zDNwrNH1aUBadjb4hXqGgeTrhjL11F38nGz8U5eV550gcxJsG7CaPcqetTgq 7LHeWaZDj0+KVoekVQ7osaMxTXoSA66s/twqJfx1QBprBJ9Up8GRD87lUwgLP5Tg5aTk oJso2jt7zp2SwVfZUlwLZYHTjzzcpRAg6MemLFPV8GoEUWzdb4DOdekjHJkBDzJ5aINZ q1EAnBusBxoVjOGjx7U7omLkRrv/+ZasqZ4D5OEn/q5rRYD7PL6lYiBxggDL6upbak1n Mb/A== X-Gm-Message-State: AHPjjUi4LVra4JpXdyHuwI5pDyA3AeJhI5LJOJFu6j22a6FTVxllvwGf RyoeAHXcaBLh2dlGghg= X-Google-Smtp-Source: ADKCNb7xQNl4L/wkrIEbuJNZ7F8uHRqT9i2kFXfB4t3NKvR4Xu8FfJv9dV+6XebyhKd+nZ4TUyu2cQ== X-Received: by 10.200.57.125 with SMTP id t58mr516358qtb.227.1504230685642; Thu, 31 Aug 2017 18:51:25 -0700 (PDT) Received: from localhost.localdomain ([187.10.21.246]) by smtp.gmail.com with ESMTPSA id o17sm6366232qkl.52.2017.08.31.18.51.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Aug 2017 18:51:25 -0700 (PDT) From: Gustavo Padovan To: linux-media@vger.kernel.org Cc: Hans Verkuil , Mauro Carvalho Chehab , Shuah Khan , Gustavo Padovan Subject: [PATCH v2 12/14] [media] vb2: add infrastructure to support out-fences Date: Thu, 31 Aug 2017 22:50:39 -0300 Message-Id: <20170901015041.7757-13-gustavo@padovan.org> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170901015041.7757-1-gustavo@padovan.org> References: <20170901015041.7757-1-gustavo@padovan.org> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 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 bbbae0eed567..2b9ba3dc23f0 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 @@ -1317,6 +1320,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 ad419f7204a2..bf2f0499c737 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 @@ -730,6 +734,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 *