1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
From e6d4594481a2c7d9625d1f4abf898cd461c30c42 Mon Sep 17 00:00:00 2001
From: Grigory Kletsko <grigory.kletsko@cogentembedded.com>
Date: Wed, 2 Nov 2016 16:17:16 +0300
Subject: [PATCH] Add gbm_bo_get_fd() function
---
backend_kms.c | 8 ++++++++
gbm.c | 15 +++++++++++++++
gbm.h | 3 +++
gbmint.h | 1 +
4 files changed, 27 insertions(+)
diff --git a/backend_kms.c b/backend_kms.c
index cfee3b0..3fc1d66 100644
--- a/backend_kms.c
+++ b/backend_kms.c
@@ -339,6 +339,13 @@ static int gbm_kms_surface_has_free_buffers(struct gbm_surface *_surface)
return ((!surface->bo[0]->locked) || (!surface->bo[1]->locked));
}
+static int gbm_kms_bo_get_fd(struct gbm_bo *_bo)
+{
+ struct gbm_kms_bo *bo = (struct gbm_kms_bo*)_bo;
+
+ return bo->fd;
+}
+
struct gbm_device kms_gbm_device = {
.name = "kms",
@@ -349,6 +356,7 @@ struct gbm_device kms_gbm_device = {
.bo_import = gbm_kms_bo_import,
.bo_write = gbm_kms_bo_write,
.bo_destroy = gbm_kms_bo_destroy,
+ .bo_get_fd = gbm_kms_bo_get_fd,
.surface_create = gbm_kms_surface_create,
.surface_lock_front_buffer = gbm_kms_surface_lock_front_buffer,
diff --git a/gbm.c b/gbm.c
index c58576d..458fac0 100644
--- a/gbm.c
+++ b/gbm.c
@@ -470,3 +470,18 @@ gbm_surface_has_free_buffers(struct gbm_surface *surf)
{
return surf->gbm->surface_has_free_buffers(surf);
}
+
+/** Get a DMA-BUF file descriptor for the buffer object
+ *
+ * This function creates a DMA-BUF (also known as PRIME) file descriptor
+ * handle for the buffer object. Eeach call to gbm_bo_get_fd() returns a new
+ * file descriptor and the caller is responsible for closing the file
+ * descriptor.
+ * \param bo The buffer object
+ * \return Returns a file descriptor referring to the underlying buffer
+ */
+GBM_EXPORT int
+gbm_bo_get_fd(struct gbm_bo *bo)
+{
+ return bo->gbm->bo_get_fd(bo);
+}
diff --git a/gbm.h b/gbm.h
index 9d2a030..ad92935 100644
--- a/gbm.h
+++ b/gbm.h
@@ -285,6 +285,9 @@ gbm_surface_has_free_buffers(struct gbm_surface *surface);
void
gbm_surface_destroy(struct gbm_surface *surface);
+int
+gbm_bo_get_fd(struct gbm_bo *bo);
+
#ifdef __cplusplus
}
#endif
diff --git a/gbmint.h b/gbmint.h
index a467bea..70a8d4a 100644
--- a/gbmint.h
+++ b/gbmint.h
@@ -70,6 +70,7 @@ struct gbm_device {
void *buffer, uint32_t usage);
int (*bo_write)(struct gbm_bo *bo, const void *buf, size_t data);
void (*bo_destroy)(struct gbm_bo *bo);
+ int (*bo_get_fd)(struct gbm_bo *_bo);
struct gbm_surface *(*surface_create)(struct gbm_device *gbm,
uint32_t width, uint32_t height,
--
2.7.4
|