From: Thierry Reding <thierry.reding@gmail.com>
To: Thierry Reding <thierry.reding@gmail.com>
Cc: linux-tegra@vger.kernel.org, "Dmitry Osipenko" <digetx@gmail.com>,
dri-devel@lists.freedesktop.org,
"Michał Mirosław" <mirq-linux@rere.qmqm.pl>
Subject: [PATCH libdrm v2 05/25] tegra: Add flink helpers
Date: Thu, 17 Feb 2022 20:16:05 +0100 [thread overview]
Message-ID: <20220217191625.2534521-6-thierry.reding@gmail.com> (raw)
In-Reply-To: <20220217191625.2534521-1-thierry.reding@gmail.com>
From: Thierry Reding <treding@nvidia.com>
Add helpers to export and import buffer objects via flink names.
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
Changes in v3:
- add drm_public annotations
---
tegra/tegra-symbols.txt | 2 ++
tegra/tegra.c | 50 +++++++++++++++++++++++++++++++++++++++++
tegra/tegra.h | 3 +++
3 files changed, 55 insertions(+)
diff --git a/tegra/tegra-symbols.txt b/tegra/tegra-symbols.txt
index 9422696c1416..630e075fa5d7 100644
--- a/tegra/tegra-symbols.txt
+++ b/tegra/tegra-symbols.txt
@@ -1,6 +1,8 @@
drm_tegra_bo_get_handle
+drm_tegra_bo_get_name
drm_tegra_bo_map
drm_tegra_bo_new
+drm_tegra_bo_open
drm_tegra_bo_ref
drm_tegra_bo_unmap
drm_tegra_bo_unref
diff --git a/tegra/tegra.c b/tegra/tegra.c
index a9087e956f94..3d645d87dd3d 100644
--- a/tegra/tegra.c
+++ b/tegra/tegra.c
@@ -240,3 +240,53 @@ drm_public int drm_tegra_bo_unmap(struct drm_tegra_bo *bo)
return 0;
}
+
+drm_public int drm_tegra_bo_get_name(struct drm_tegra_bo *bo, uint32_t *name)
+{
+ struct drm_tegra *drm = bo->drm;
+ struct drm_gem_flink args;
+ int err;
+
+ memset(&args, 0, sizeof(args));
+ args.handle = bo->handle;
+
+ err = drmIoctl(drm->fd, DRM_IOCTL_GEM_FLINK, &args);
+ if (err < 0)
+ return err;
+
+ if (name)
+ *name = args.name;
+
+ return 0;
+}
+
+drm_public int
+drm_tegra_bo_open(struct drm_tegra *drm, uint32_t name, uint32_t flags,
+ struct drm_tegra_bo **bop)
+{
+ struct drm_gem_open args;
+ struct drm_tegra_bo *bo;
+ int err;
+
+ bo = drm_tegra_bo_alloc(drm, 0, flags, 0);
+ if (!bo)
+ return -ENOMEM;
+
+ memset(&args, 0, sizeof(args));
+ args.name = name;
+
+ err = drmIoctl(drm->fd, DRM_IOCTL_GEM_OPEN, &args);
+ if (err < 0)
+ goto free;
+
+ bo->handle = args.handle;
+ bo->size = args.size;
+
+ *bop = bo;
+
+ return 0;
+
+free:
+ free(bo);
+ return err;
+}
diff --git a/tegra/tegra.h b/tegra/tegra.h
index c6b4f984de45..333690f23118 100644
--- a/tegra/tegra.h
+++ b/tegra/tegra.h
@@ -44,5 +44,8 @@ int drm_tegra_bo_get_handle(struct drm_tegra_bo *bo, uint32_t *handle);
int drm_tegra_bo_map(struct drm_tegra_bo *bo, void **ptr);
int drm_tegra_bo_unmap(struct drm_tegra_bo *bo);
+int drm_tegra_bo_get_name(struct drm_tegra_bo *bo, uint32_t *name);
+int drm_tegra_bo_open(struct drm_tegra *drm, uint32_t name, uint32_t flags,
+ struct drm_tegra_bo **bop);
#endif /* __DRM_TEGRA_H__ */
--
2.35.1
next prev parent reply other threads:[~2022-02-17 19:16 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-17 19:16 [PATCH libdrm v2 00/25] Update Tegra support Thierry Reding
2022-02-17 19:16 ` [PATCH libdrm v2 01/25] tegra: Indent according to .editorconfig Thierry Reding
2022-02-17 19:16 ` [PATCH libdrm v2 02/25] tegra: Remove unused IOCTL implementations Thierry Reding
2022-02-24 16:52 ` Dmitry Osipenko
2022-02-17 19:16 ` [PATCH libdrm v2 03/25] tegra: Extract common buffer object allocation code Thierry Reding
2022-02-17 19:16 ` [PATCH libdrm v2 04/25] tegra: Fix mmap() of GEM buffer objects Thierry Reding
2022-02-17 19:16 ` Thierry Reding [this message]
2022-02-24 17:18 ` [PATCH libdrm v2 05/25] tegra: Add flink helpers Dmitry Osipenko
2022-02-17 20:02 ` [PATCH libdrm v2 00/25] Update Tegra support Dmitry Osipenko
2022-02-17 21:37 ` Thierry Reding
2022-02-18 14:16 ` Dmitry Osipenko
2022-02-18 19:49 ` Dmitry Osipenko
2022-02-18 9:31 ` Mikko Perttunen
2022-02-21 20:29 ` Dmitry Osipenko
2022-02-22 8:41 ` Mikko Perttunen
2022-02-23 15:01 ` Thierry Reding
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220217191625.2534521-6-thierry.reding@gmail.com \
--to=thierry.reding@gmail.com \
--cc=digetx@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-tegra@vger.kernel.org \
--cc=mirq-linux@rere.qmqm.pl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox