aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnand Balagopalakrishnan2015-11-17 22:50:34 -0600
committerAnand Balagopalakrishnan2015-11-17 22:50:34 -0600
commit77a737dc27e1a8b1220bd0d71398b51a8a492fba (patch)
treef95aaa4a3a2913bfe9943a6779381aca599b9e87
parentcb86a2f2cecd41023bf1bf12fbcf11be11220f31 (diff)
downloadexternal-libgbm-77a737dc27e1a8b1220bd0d71398b51a8a492fba.tar.gz
external-libgbm-77a737dc27e1a8b1220bd0d71398b51a8a492fba.tar.xz
external-libgbm-77a737dc27e1a8b1220bd0d71398b51a8a492fba.zip
gbm: sync with upstream Mesa
Sync with Mesa repository for latest GBM interface. Mesa repo : git://anongit.freedesktop.org/mesa/mesa commit : dd05ffebfcb5d2e7ca44def1907aa2fbadd5e19d Signed-off-by: Anand Balagopalakrishnan <anandb@ti.com>
-rw-r--r--gbm.c46
-rw-r--r--gbm.h32
-rw-r--r--gbmint.h5
3 files changed, 62 insertions, 21 deletions
diff --git a/gbm.c b/gbm.c
index c58576dd..c046b1ad 100644
--- a/gbm.c
+++ b/gbm.c
@@ -26,6 +26,7 @@
26 */ 26 */
27 27
28#define _BSD_SOURCE 28#define _BSD_SOURCE
29#define _DEFAULT_SOURCE
29 30
30#include <stddef.h> 31#include <stddef.h>
31#include <stdio.h> 32#include <stdio.h>
@@ -36,15 +37,15 @@
36#include <sys/types.h> 37#include <sys/types.h>
37#include <sys/stat.h> 38#include <sys/stat.h>
38#include <unistd.h> 39#include <unistd.h>
40#include <errno.h>
39 41
40#include "gbm.h" 42#include "gbm.h"
41#include "gbmint.h" 43#include "gbmint.h"
42#include "common.h"
43#include "backend.h" 44#include "backend.h"
44 45
45#define ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0])) 46#define ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0]))
46 47
47struct gbm_device *devices[16]; 48static struct gbm_device *devices[16];
48 49
49static int device_num = 0; 50static int device_num = 0;
50 51
@@ -82,7 +83,7 @@ gbm_device_get_backend_name(struct gbm_device *gbm)
82 * 83 *
83 * \sa enum gbm_bo_format for the list of formats 84 * \sa enum gbm_bo_format for the list of formats
84 */ 85 */
85int 86GBM_EXPORT int
86gbm_device_is_format_supported(struct gbm_device *gbm, 87gbm_device_is_format_supported(struct gbm_device *gbm,
87 uint32_t format, uint32_t usage) 88 uint32_t format, uint32_t usage)
88{ 89{
@@ -101,7 +102,7 @@ gbm_device_destroy(struct gbm_device *gbm)
101 gbm->destroy(gbm); 102 gbm->destroy(gbm);
102} 103}
103 104
104GBM_EXPORT struct gbm_device * 105struct gbm_device *
105_gbm_mesa_get_device(int fd) 106_gbm_mesa_get_device(int fd)
106{ 107{
107 struct gbm_device *gbm = NULL; 108 struct gbm_device *gbm = NULL;
@@ -110,7 +111,7 @@ _gbm_mesa_get_device(int fd)
110 int i; 111 int i;
111 112
112 if (fd < 0 || fstat(fd, &buf) < 0 || !S_ISCHR(buf.st_mode)) { 113 if (fd < 0 || fstat(fd, &buf) < 0 || !S_ISCHR(buf.st_mode)) {
113 fprintf(stderr, "_gbm_mesa_get_device: invalid fd: %d\n", fd); 114 errno = EINVAL;
114 return NULL; 115 return NULL;
115 } 116 }
116 117
@@ -146,7 +147,7 @@ gbm_create_device(int fd)
146 struct stat buf; 147 struct stat buf;
147 148
148 if (fd < 0 || fstat(fd, &buf) < 0 || !S_ISCHR(buf.st_mode)) { 149 if (fd < 0 || fstat(fd, &buf) < 0 || !S_ISCHR(buf.st_mode)) {
149 fprintf(stderr, "gbm_create_device: invalid fd: %d\n", fd); 150 errno = EINVAL;
150 return NULL; 151 return NULL;
151 } 152 }
152 153
@@ -231,6 +232,23 @@ gbm_bo_get_handle(struct gbm_bo *bo)
231 return bo->handle; 232 return bo->handle;
232} 233}
233 234
235/** Get a DMA-BUF file descriptor for the buffer object
236 *
237 * This function creates a DMA-BUF (also known as PRIME) file descriptor
238 * handle for the buffer object. Eeach call to gbm_bo_get_fd() returns a new
239 * file descriptor and the caller is responsible for closing the file
240 * descriptor.
241
242 * \param bo The buffer object
243 * \return Returns a file descriptor referring to the underlying buffer
244 */
245GBM_EXPORT int
246gbm_bo_get_fd(struct gbm_bo *bo)
247{
248 return bo->gbm->bo_get_fd(bo);
249}
250
251
234/** Write data into the buffer object 252/** Write data into the buffer object
235 * 253 *
236 * If the buffer object was created with the GBM_BO_USE_WRITE flag, 254 * If the buffer object was created with the GBM_BO_USE_WRITE flag,
@@ -242,7 +260,7 @@ gbm_bo_get_handle(struct gbm_bo *bo)
242 * \param bo The buffer object 260 * \param bo The buffer object
243 * \param buf The data to write 261 * \param buf The data to write
244 * \param count The number of bytes to write 262 * \param count The number of bytes to write
245 * \return Returns -1 on error, 0 otherwise 263 * \return Returns 0 on success, otherwise -1 is returned an errno set
246 */ 264 */
247GBM_EXPORT int 265GBM_EXPORT int
248gbm_bo_write(struct gbm_bo *bo, const void *buf, size_t count) 266gbm_bo_write(struct gbm_bo *bo, const void *buf, size_t count)
@@ -316,7 +334,7 @@ gbm_bo_destroy(struct gbm_bo *bo)
316 * 334 *
317 * \return A newly allocated buffer that should be freed with gbm_bo_destroy() 335 * \return A newly allocated buffer that should be freed with gbm_bo_destroy()
318 * when no longer needed. If an error occurs during allocation %NULL will be 336 * when no longer needed. If an error occurs during allocation %NULL will be
319 * returned. 337 * returned and errno set.
320 * 338 *
321 * \sa enum gbm_bo_format for the list of formats 339 * \sa enum gbm_bo_format for the list of formats
322 * \sa enum gbm_bo_flags for the list of usage flags 340 * \sa enum gbm_bo_flags for the list of usage flags
@@ -326,12 +344,10 @@ gbm_bo_create(struct gbm_device *gbm,
326 uint32_t width, uint32_t height, 344 uint32_t width, uint32_t height,
327 uint32_t format, uint32_t usage) 345 uint32_t format, uint32_t usage)
328{ 346{
329 if (width == 0 || height == 0) 347 if (width == 0 || height == 0) {
330 return NULL; 348 errno = EINVAL;
331
332 if (usage & GBM_BO_USE_CURSOR_64X64 &&
333 (width != 64 || height != 64))
334 return NULL; 349 return NULL;
350 }
335 351
336 return gbm->bo_create(gbm, width, height, format, usage); 352 return gbm->bo_create(gbm, width, height, format, usage);
337} 353}
@@ -346,6 +362,7 @@ gbm_bo_create(struct gbm_device *gbm,
346 * 362 *
347 * GBM_BO_IMPORT_WL_BUFFER 363 * GBM_BO_IMPORT_WL_BUFFER
348 * GBM_BO_IMPORT_EGL_IMAGE 364 * GBM_BO_IMPORT_EGL_IMAGE
365 * GBM_BO_IMPORT_FD
349 * 366 *
350 * The the gbm bo shares the underlying pixels but its life-time is 367 * The the gbm bo shares the underlying pixels but its life-time is
351 * independent of the foreign object. 368 * independent of the foreign object.
@@ -356,7 +373,8 @@ gbm_bo_create(struct gbm_device *gbm,
356 * \param usage The union of the usage flags for this buffer 373 * \param usage The union of the usage flags for this buffer
357 * 374 *
358 * \return A newly allocated buffer object that should be freed with 375 * \return A newly allocated buffer object that should be freed with
359 * gbm_bo_destroy() when no longer needed. 376 * gbm_bo_destroy() when no longer needed. On error, %NULL is returned
377 * and errno is set.
360 * 378 *
361 * \sa enum gbm_bo_flags for the list of usage flags 379 * \sa enum gbm_bo_flags for the list of usage flags
362 */ 380 */
diff --git a/gbm.h b/gbm.h
index 9d2a0308..8db2153e 100644
--- a/gbm.h
+++ b/gbm.h
@@ -35,6 +35,7 @@ extern "C" {
35 35
36#define __GBM__ 1 36#define __GBM__ 1
37 37
38#include <stddef.h>
38#include <stdint.h> 39#include <stdint.h>
39 40
40/** 41/**
@@ -192,10 +193,13 @@ enum gbm_bo_flags {
192 */ 193 */
193 GBM_BO_USE_SCANOUT = (1 << 0), 194 GBM_BO_USE_SCANOUT = (1 << 0),
194 /** 195 /**
195 * Buffer is going to be used as cursor - the dimensions for the buffer 196 * Buffer is going to be used as cursor
196 * must be 64x64 if this flag is passed.
197 */ 197 */
198 GBM_BO_USE_CURSOR_64X64 = (1 << 1), 198 GBM_BO_USE_CURSOR = (1 << 1),
199 /**
200 * Deprecated
201 */
202 GBM_BO_USE_CURSOR_64X64 = GBM_BO_USE_CURSOR,
199 /** 203 /**
200 * Buffer is to be used for rendering - for example it is going to be used 204 * Buffer is to be used for rendering - for example it is going to be used
201 * as the storage for a color buffer 205 * as the storage for a color buffer
@@ -203,10 +207,13 @@ enum gbm_bo_flags {
203 GBM_BO_USE_RENDERING = (1 << 2), 207 GBM_BO_USE_RENDERING = (1 << 2),
204 /** 208 /**
205 * Buffer can be used for gbm_bo_write. This is guaranteed to work 209 * Buffer can be used for gbm_bo_write. This is guaranteed to work
206 * with GBM_BO_USE_CURSOR_64X64. but may not work for other 210 * with GBM_BO_USE_CURSOR. but may not work for other combinations.
207 * combinations.
208 */ 211 */
209 GBM_BO_USE_WRITE = (1 << 3), 212 GBM_BO_USE_WRITE = (1 << 3),
213 /**
214 * Buffer is linear, i.e. not tiled.
215 */
216 GBM_BO_USE_LINEAR = (1 << 4),
210}; 217};
211 218
212int 219int
@@ -232,6 +239,15 @@ gbm_bo_create(struct gbm_device *gbm,
232 239
233#define GBM_BO_IMPORT_WL_BUFFER 0x5501 240#define GBM_BO_IMPORT_WL_BUFFER 0x5501
234#define GBM_BO_IMPORT_EGL_IMAGE 0x5502 241#define GBM_BO_IMPORT_EGL_IMAGE 0x5502
242#define GBM_BO_IMPORT_FD 0x5503
243
244struct gbm_import_fd_data {
245 int fd;
246 uint32_t width;
247 uint32_t height;
248 uint32_t stride;
249 uint32_t format;
250};
235 251
236struct gbm_bo * 252struct gbm_bo *
237gbm_bo_import(struct gbm_device *gbm, uint32_t type, 253gbm_bo_import(struct gbm_device *gbm, uint32_t type,
@@ -256,6 +272,9 @@ union gbm_bo_handle
256gbm_bo_get_handle(struct gbm_bo *bo); 272gbm_bo_get_handle(struct gbm_bo *bo);
257 273
258int 274int
275gbm_bo_get_fd(struct gbm_bo *bo);
276
277int
259gbm_bo_write(struct gbm_bo *bo, const void *buf, size_t count); 278gbm_bo_write(struct gbm_bo *bo, const void *buf, size_t count);
260 279
261void 280void
@@ -273,6 +292,9 @@ gbm_surface_create(struct gbm_device *gbm,
273 uint32_t width, uint32_t height, 292 uint32_t width, uint32_t height,
274 uint32_t format, uint32_t flags); 293 uint32_t format, uint32_t flags);
275 294
295int
296gbm_surface_needs_lock_front_buffer(struct gbm_surface *surface);
297
276struct gbm_bo * 298struct gbm_bo *
277gbm_surface_lock_front_buffer(struct gbm_surface *surface); 299gbm_surface_lock_front_buffer(struct gbm_surface *surface);
278 300
diff --git a/gbmint.h b/gbmint.h
index a467beae..155eb12b 100644
--- a/gbmint.h
+++ b/gbmint.h
@@ -32,7 +32,7 @@
32#include <sys/stat.h> 32#include <sys/stat.h>
33 33
34/* GCC visibility */ 34/* GCC visibility */
35#if defined(__GNUC__) && __GNUC__ >= 4 35#if defined(__GNUC__)
36#define GBM_EXPORT __attribute__ ((visibility("default"))) 36#define GBM_EXPORT __attribute__ ((visibility("default")))
37#else 37#else
38#define GBM_EXPORT 38#define GBM_EXPORT
@@ -69,6 +69,7 @@ struct gbm_device {
69 struct gbm_bo *(*bo_import)(struct gbm_device *gbm, uint32_t type, 69 struct gbm_bo *(*bo_import)(struct gbm_device *gbm, uint32_t type,
70 void *buffer, uint32_t usage); 70 void *buffer, uint32_t usage);
71 int (*bo_write)(struct gbm_bo *bo, const void *buf, size_t data); 71 int (*bo_write)(struct gbm_bo *bo, const void *buf, size_t data);
72 int (*bo_get_fd)(struct gbm_bo *bo);
72 void (*bo_destroy)(struct gbm_bo *bo); 73 void (*bo_destroy)(struct gbm_bo *bo);
73 74
74 struct gbm_surface *(*surface_create)(struct gbm_device *gbm, 75 struct gbm_surface *(*surface_create)(struct gbm_device *gbm,
@@ -110,7 +111,7 @@ struct gbm_backend {
110 struct gbm_device *(*create_device)(int fd); 111 struct gbm_device *(*create_device)(int fd);
111}; 112};
112 113
113GBM_EXPORT struct gbm_device * 114struct gbm_device *
114_gbm_mesa_get_device(int fd); 115_gbm_mesa_get_device(int fd);
115 116
116#endif 117#endif