From patchwork Fri Oct 20 21:50:09 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: 45067 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 1e5fE1-0001jE-5C; Fri, 20 Oct 2017 21:53:05 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753184AbdJTVws (ORCPT + 1 other); Fri, 20 Oct 2017 17:52:48 -0400 Received: from mail-qk0-f196.google.com ([209.85.220.196]:44328 "EHLO mail-qk0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753396AbdJTVvI (ORCPT ); Fri, 20 Oct 2017 17:51:08 -0400 Received: by mail-qk0-f196.google.com with SMTP id r64so16025744qkc.1; Fri, 20 Oct 2017 14:51: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=I4bSOdYEAnLjaMoMAAeknZsFgz7jzjpEuFzTdX9w/8E=; b=rdrcxtD6D5W8388uLohnkw26Q1v48bNuFRw43oSgAxI6jP3O8rMdNQ/s64bCQEMfiT uUiD4LOiMsf3ukfSVmV90l8q31m7/5Zcbh+ABvbBHU2znkAUaEYedhSpCqK719+x67Dr LyxXF1jpVaiIEsaPxidy0cWyrkr6oq/3O6sm0CsvvMbpSZHNZJqoAN6Yae+jnNr2hRO3 QBk6lYwpxp087yErLY35nT23SUpHedzN9Np094PD/F6daMUA3PTBaoH/V5wMvoaccQa9 oj+rINU0LzK7Eg14EIe6tJaekR2kaB9JznSiDqNph/DjAC0z+36RSj9jEHZEUuAneKz9 e7Jw== X-Gm-Message-State: AMCzsaUeNENULWTmH1HeDtPKqdkNtBx7qdcGjvavA2u1nq22n2GtHoWf pUB3XnJZKxpVqdVig+KZqistqs35 X-Google-Smtp-Source: ABhQp+RhRsn2HGif/hgY3bvInsnjkJt3DGwJHvemJchcZsibTrgdFY51nWhDhCpA0gEgdWR2PijugA== X-Received: by 10.55.156.141 with SMTP id f135mr9264458qke.309.1508536267825; Fri, 20 Oct 2017 14:51:07 -0700 (PDT) Received: from localhost.localdomain (189-19-125-192.dsl.telesp.net.br. [189.19.125.192]) by smtp.gmail.com with ESMTPSA id j4sm1167039qkf.75.2017.10.20.14.51.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 20 Oct 2017 14:51:07 -0700 (PDT) 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 , linux-kernel@vger.kernel.org, Javier Martinez Canillas Subject: [RFC v4 14/17] [media] vb2: add videobuf2 dma-buf fence helpers Date: Fri, 20 Oct 2017 19:50:09 -0200 Message-Id: <20171020215012.20646-15-gustavo@padovan.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171020215012.20646-1-gustavo@padovan.org> References: <20171020215012.20646-1-gustavo@padovan.org> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 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; +}