From patchwork Wed Nov 15 17:10:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Padovan X-Patchwork-Id: 10059937 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 CFFA360231 for ; Wed, 15 Nov 2017 17:14:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BB11B29FB3 for ; Wed, 15 Nov 2017 17:14:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AEB9929FDF; Wed, 15 Nov 2017 17:14:20 +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 8BBC729FB3 for ; Wed, 15 Nov 2017 17:14:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933290AbdKOROR (ORCPT ); Wed, 15 Nov 2017 12:14:17 -0500 Received: from mail-qt0-f195.google.com ([209.85.216.195]:49800 "EHLO mail-qt0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933303AbdKORLf (ORCPT ); Wed, 15 Nov 2017 12:11:35 -0500 Received: by mail-qt0-f195.google.com with SMTP id p44so25526797qtj.6; Wed, 15 Nov 2017 09:11:35 -0800 (PST) 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=I4bSOdYEAnLjaMoMAAeknZsFgz7jzjpEuFzTdX9w/8E=; b=brQmHCckS7wH1y4kKDzkwlQgTHtWUHbcLhJwZ9z20xmaCrgTu7/rqqqqMIaRYrPMVt vi3Uv4ji9husK+A8SzIRooyfCFLNVEEawBoVRgYX0jDNOexEKt0P8xYWbVxct0n3RwCW rzMkp5uGHwski0Y4vt4aZ9Eu36blUpUd3XwZEJtcZHJpxsuTLdQUR4uvJl3+44WrSmpJ qXQcYvUJrduOkXYKkFQ10wRocdJqFgmbcksav7OtgW0YR53sNjAbqeg2rqoD2IelGgNi I6oFwhyyyQRLdZvDIUlegfsCs98kw2wmwtughmC7GfxLkLuH95ed+Lf9vuGLINZ+Usgr 2m5w== X-Gm-Message-State: AJaThX5aXShOrLY3q7JBbsJqARz68uP9XXP5wvI8X5t7txXdIOfkN/LI 55rlhmSn8JvR1Of0KqhrgEBfKUyF X-Google-Smtp-Source: AGs4zMa536QULBrSfYiuk45jXwAgJPJUjgemjqaRZHc8B+AkOkzel/NqD08DAettyXFbKzn5dAHOrA== X-Received: by 10.200.44.154 with SMTP id 26mr16607502qtw.186.1510765894431; Wed, 15 Nov 2017 09:11:34 -0800 (PST) Received: from localhost.localdomain ([179.110.36.75]) by smtp.gmail.com with ESMTPSA id p85sm15211633qkp.94.2017.11.15.09.11.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 15 Nov 2017 09:11:33 -0800 (PST) From: Gustavo Padovan To: linux-media@vger.kernel.org Cc: Hans Verkuil , Mauro Carvalho Chehab , Shuah Khan , Pawel Osciak , Alexandre Courbot , Sakari Ailus , Brian Starkey , Thierry Escande , linux-kernel@vger.kernel.org, Javier Martinez Canillas Subject: [RFC v5 08/11] [media] vb2: add videobuf2 dma-buf fence helpers Date: Wed, 15 Nov 2017 15:10:54 -0200 Message-Id: <20171115171057.17340-9-gustavo@padovan.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171115171057.17340-1-gustavo@padovan.org> References: <20171115171057.17340-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. v2: - use fence context provided by the caller in vb2_fence_alloc() Signed-off-by: Javier Martinez Canillas Signed-off-by: Gustavo Padovan --- include/media/videobuf2-fence.h | 48 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 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 000000000000..b49cc1bf6bb4 --- /dev/null +++ b/include/media/videobuf2-fence.h @@ -0,0 +1,48 @@ +/* + * 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(u64 context) +{ + 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, context, 1); + + return vb2_fence; +}