From patchwork Fri Jun 16 07:39:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Padovan X-Patchwork-Id: 9790799 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 6000860326 for ; Fri, 16 Jun 2017 07:39:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 543F6280B0 for ; Fri, 16 Jun 2017 07:39:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 492452857E; Fri, 16 Jun 2017 07:39:51 +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 A2079280B0 for ; Fri, 16 Jun 2017 07:39:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752729AbdFPHjt (ORCPT ); Fri, 16 Jun 2017 03:39:49 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:35491 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752134AbdFPHjs (ORCPT ); Fri, 16 Jun 2017 03:39:48 -0400 Received: by mail-pf0-f195.google.com with SMTP id s66so4710084pfs.2 for ; Fri, 16 Jun 2017 00:39:48 -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=4Xnx88icCL8ig4Kk5LXtAIqYQzo6nN5ZGCoNLKQrQ8c=; b=bK2rb9SZNfvMBvk7DktaEArqaNxrbisUizHIg7ByME0rhaW7C/geJRabEuqcUVaL5P MiBxwrsrowoxOWMgt7EZUuOnZKPv8GnfTGi3ybH1rkjI+0XsWii3xEJn0xkEzbGIpzlO fjuaT3C0ce5QNYI8hCAiqWPd+/i/fFzTAVPPpdBuRwLFUkhcWQCRYnWdzkokkmTly1X1 hfU5Dye1E/yjBt3wkBMOiPPEHlqKLGtQyJUeao5hVRXJIdvZKbOWhzQK2nanKCxTih/M Ifs2OxKm3HHzcgYocmrWPoP9f3RdA3wYoytGXO126UORW76Tpv9W7ZMzR/6qVITdjtvZ aERQ== X-Gm-Message-State: AKS2vOwsGisuOA1YwkvFdFdqxsXcgqu0zH2WFRq18fnKFFk7E407rBG2 3KzKOvu/BRhX+e6XKKk= X-Received: by 10.98.105.138 with SMTP id e132mr2876217pfc.191.1497598787477; Fri, 16 Jun 2017 00:39:47 -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.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Jun 2017 00:39:46 -0700 (PDT) From: Gustavo Padovan To: linux-media@vger.kernel.org Cc: Hans Verkuil , Javier Martinez Canillas , Mauro Carvalho Chehab , Shuah Khan Subject: [PATCH 10/12] [media] vb2: add videobuf2 dma-buf fence helpers Date: Fri, 16 Jun 2017 16:39:13 +0900 Message-Id: <20170616073915.5027-11-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: Javier Martinez Canillas Add a videobuf2-fence.h header file that contains different helpers for DMA buffer sharing explicit fence support in videobuf2. Signed-off-by: Javier Martinez Canillas Signed-off-by: Gustavo Padovan --- include/media/videobuf2-fence.h | 49 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 include/media/videobuf2-fence.h diff --git a/include/media/videobuf2-fence.h b/include/media/videobuf2-fence.h new file mode 100644 index 0000000..ed5612c --- /dev/null +++ b/include/media/videobuf2-fence.h @@ -0,0 +1,49 @@ +/* + * videobuf2-fence.h - DMA buffer sharing fence helpers for videobuf 2 + * + * Copyright (C) 2016 Samsung Electronics + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation. + */ + +#include +#include + +static DEFINE_SPINLOCK(vb2_fence_lock); + +static inline const char *vb2_fence_get_driver_name(struct dma_fence *fence) +{ + return "vb2_fence"; +} + +static inline const char *vb2_fence_get_timeline_name(struct dma_fence *fence) +{ + return "vb2_fence_timeline"; +} + +static inline bool vb2_fence_enable_signaling(struct dma_fence *fence) +{ + return true; +} + +static const struct dma_fence_ops vb2_fence_ops = { + .get_driver_name = vb2_fence_get_driver_name, + .get_timeline_name = vb2_fence_get_timeline_name, + .enable_signaling = vb2_fence_enable_signaling, + .wait = dma_fence_default_wait, +}; + +static inline struct dma_fence *vb2_fence_alloc(void) +{ + struct dma_fence *vb2_fence = kzalloc(sizeof(*vb2_fence), GFP_KERNEL); + + if (!vb2_fence) + return NULL; + + dma_fence_init(vb2_fence, &vb2_fence_ops, &vb2_fence_lock, + dma_fence_context_alloc(1), 1); + + return vb2_fence; +}