summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Michael <cp.michael@samsung.com>2015-04-07 10:48:11 -0400
committerChris Michael <cp.michael@samsung.com>2015-04-08 14:03:48 -0400
commite1d6cbdee93f2915277fc8065381cd980dfbfe71 (patch)
treeb546c8801bc7aa94c690e145502193fa84159393
parenta39b72c79825a4058b75860088dcf3b53d9fa243 (diff)
evas-drm: Remove evas_bufmgr.c from the Evas Drm engine
Summary: This file is not needed for the software drm engine. This was added (initially) for combining the drm software & hardware engines into one. As that is not the case, this file is unused. @fix Signed-off-by: Chris Michael <cp.michael@samsung.com>
-rw-r--r--src/Makefile_Evas.am1
-rw-r--r--src/modules/evas/engines/drm/evas_bufmgr.c538
2 files changed, 0 insertions, 539 deletions
diff --git a/src/Makefile_Evas.am b/src/Makefile_Evas.am
index 3b57e96b04..0716b03586 100644
--- a/src/Makefile_Evas.am
+++ b/src/Makefile_Evas.am
@@ -1136,7 +1136,6 @@ if BUILD_ENGINE_DRM
1136dist_installed_evasmainheaders_DATA += modules/evas/engines/drm/Evas_Engine_Drm.h 1136dist_installed_evasmainheaders_DATA += modules/evas/engines/drm/Evas_Engine_Drm.h
1137DRM_SOURCES = \ 1137DRM_SOURCES = \
1138modules/evas/engines/drm/evas_drm.c \ 1138modules/evas/engines/drm/evas_drm.c \
1139modules/evas/engines/drm/evas_bufmgr.c \
1140modules/evas/engines/drm/evas_outbuf.c \ 1139modules/evas/engines/drm/evas_outbuf.c \
1141modules/evas/engines/drm/evas_engine.c \ 1140modules/evas/engines/drm/evas_engine.c \
1142modules/evas/engines/drm/evas_engine.h \ 1141modules/evas/engines/drm/evas_engine.h \
diff --git a/src/modules/evas/engines/drm/evas_bufmgr.c b/src/modules/evas/engines/drm/evas_bufmgr.c
deleted file mode 100644
index b4a7c654a1..0000000000
--- a/src/modules/evas/engines/drm/evas_bufmgr.c
+++ /dev/null
@@ -1,538 +0,0 @@
1#include "evas_engine.h"
2#include <dlfcn.h>
3
4#ifdef HAVE_DRM_HW_ACCEL
5# define EGL_EGLEXT_PROTOTYPES
6# define GL_GLEXT_PROTOTYPES
7
8# include <GLES2/gl2.h>
9# include <GLES2/gl2ext.h>
10# include <EGL/egl.h>
11# include <EGL/eglext.h>
12#endif
13
14/* NB: This union is the same in GBM and TBM so we can use it
15 * to return 'handles' */
16union _ebi_bo_handle
17{
18 void *ptr;
19 int32_t s32;
20 uint32_t u32;
21 int64_t s64;
22 uint64_t u64;
23};
24
25enum _ebi_bo_format
26{
27 EBI_BO_FORMAT_XRGB8888,
28 EBI_BO_FORMAT_ARGB8888
29};
30
31enum _ebi_bo_gbm_flags
32{
33 EBI_BO_GBM_SCANOUT = (1 << 0),
34 EBI_BO_GBM_CURSOR = (1 << 1),
35 EBI_BO_GBM_RENDER = (1 << 2),
36 EBI_BO_GBM_WRITE = (1 << 3),
37};
38
39enum _ebi_bo_tbm_flags
40{
41 EBI_BO_TBM_DEFAULT = 0,
42 EBI_BO_TBM_SCANOUT = (1 << 0),
43 EBI_BO_TBM_NONCACHE = (1 << 1),
44 EBI_BO_TBM_WC = (1 << 2),
45 EBI_BO_TBM_VENDOR = (0xffff0000),
46};
47
48typedef struct _Evas_Bufmgr_Interface Evas_Bufmgr_Interface;
49struct _Evas_Bufmgr_Interface
50{
51 int fd;
52
53 /* actual library we linked to */
54 void *lib;
55
56 /* actual buffer manager returned from library init */
57 void *mgr;
58
59 union
60 {
61 struct
62 {
63 void *(*init)(int fd);
64 void (*shutdown)(void *mgr);
65 void *(*surface_create)(void *mgr, unsigned int width, unsigned int height, unsigned int format, unsigned int flags);
66 void (*surface_destroy)(void *surface);
67 void *(*buffer_create)(void *mgr, unsigned int width, unsigned int height, unsigned int format, unsigned int flags);
68 void (*buffer_destroy)(void *buffer);
69 union _ebi_bo_handle (*buffer_handle_get)(void *buffer);
70 unsigned int (*buffer_stride_get)(void *buffer);
71 } gbm;
72 struct
73 {
74 void *(*init)(int fd);
75 void (*shutdown)(void *mgr);
76 } tbm;
77 } funcs;
78
79#ifdef HAVE_DRM_HW_ACCEL
80 struct
81 {
82 EGLDisplay disp;
83 EGLContext ctx;
84 EGLConfig cfg;
85
86 PFNEGLCREATEIMAGEKHRPROC image_create;
87 PFNEGLDESTROYIMAGEKHRPROC image_destroy;
88 PFNGLEGLIMAGETARGETTEXTURE2DOESPROC image_texture;
89 } egl;
90#endif
91};
92
93/* buffer manager interface */
94static Evas_Bufmgr_Interface *_ebi;
95
96static Eina_Bool
97_evas_bufmgr_egl_init(void)
98{
99#ifdef HAVE_DRM_HW_ACCEL
100 /* const char *ext; */
101 EGLint maj, min, n;
102 EGLint atts[] =
103 {
104 EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
105 EGL_RED_SIZE, 1, EGL_GREEN_SIZE, 1, EGL_BLUE_SIZE, 1,
106 EGL_ALPHA_SIZE, 1, EGL_DEPTH_SIZE, 1,
107 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL_NONE
108 };
109
110 /* try to get the egl display from the manager */
111 _ebi->egl.disp = eglGetDisplay(_ebi->mgr);
112 if (_ebi->egl.disp == EGL_NO_DISPLAY)
113 {
114 ERR("Could not get EGLDisplay: %m");
115 return EINA_FALSE;
116 }
117
118 /* try to init egl library */
119 if (!eglInitialize(_ebi->egl.disp, &maj, &min))
120 {
121 ERR("Could not init EGL library: %m");
122 goto init_err;
123 }
124
125 /* check egl extensions for what we need */
126 /* ext = eglQueryString(_ebi->egl.disp, EGL_EXTENSIONS); */
127 /* if (!strstr(ext, "EGL_KHR_surfaceless_opengl")) */
128 /* { */
129 /* ERR("EGL_KHR_surfaceless_opengl Not Supported"); */
130 /* goto init_err; */
131 /* } */
132
133 eglBindAPI(EGL_OPENGL_ES_API);
134
135 /* try to find matching egl config */
136 if (!eglChooseConfig(_ebi->egl.disp, atts, &_ebi->egl.cfg, 1, &n) ||
137 (n != 1))
138 {
139 ERR("Could not find EGLConfig: %m");
140 goto init_err;
141 }
142
143 /* try to create a context */
144 if (!(_ebi->egl.ctx =
145 eglCreateContext(_ebi->egl.disp, _ebi->egl.cfg, EGL_NO_CONTEXT, NULL)))
146 {
147 ERR("Could not create EGL Context: %m");
148 goto init_err;
149 }
150
151 /* try to make this context current */
152 if (!eglMakeCurrent(_ebi->egl.disp, EGL_NO_SURFACE, EGL_NO_SURFACE,
153 _ebi->egl.ctx))
154 {
155 ERR("Could not make EGL Context current: %m");
156 goto curr_err;
157 }
158
159 /* TODO: setup shaders ?? */
160
161 /* link to egl functions */
162 _ebi->egl.image_create = (PFNEGLCREATEIMAGEKHRPROC)
163 eglGetProcAddress("eglCreateImageKHR");
164 _ebi->egl.image_destroy = (PFNEGLDESTROYIMAGEKHRPROC)
165 eglGetProcAddress("eglDestroyImageKHR");
166 _ebi->egl.image_texture = (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC)
167 eglGetProcAddress("glEGLImageTargetTexture2DOES");
168
169 return EINA_TRUE;
170
171curr_err:
172 /* destroy the egl context */
173 eglDestroyContext(_ebi->egl.disp, _ebi->egl.ctx);
174
175init_err:
176 /* close egl display */
177 eglTerminate(_ebi->egl.disp);
178 eglReleaseThread();
179#endif
180 return EINA_FALSE;
181}
182
183static void
184_evas_bufmgr_egl_shutdown(void)
185{
186#ifdef HAVE_DRM_HW_ACCEL
187 if (_ebi->egl.disp)
188 {
189 eglMakeCurrent(_ebi->egl.disp,
190 EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
191 eglTerminate(_ebi->egl.disp);
192 eglReleaseThread();
193 }
194#endif
195}
196
197static Eina_Bool
198_evas_bufmgr_gbm_init(void)
199{
200 int flags = 0;
201
202 /* set dlopen flags */
203 flags = (RTLD_LAZY | RTLD_GLOBAL);
204
205 /* try to find gbm library */
206 _ebi->lib = dlopen("libgbm.so", flags);
207 if (!_ebi->lib) _ebi->lib = dlopen("libgbm.so.1", flags);
208 if (!_ebi->lib) _ebi->lib = dlopen("libgbm.so.1.0.0", flags);
209
210 /* fail if we did not find the library */
211 if (!_ebi->lib) return EINA_FALSE;
212
213 /* with the library found, lets symlink the functions we need */
214 _ebi->funcs.gbm.init = dlsym(_ebi->lib, "gbm_create_device");
215 _ebi->funcs.gbm.shutdown = dlsym(_ebi->lib, "gbm_device_destroy");
216 _ebi->funcs.gbm.surface_create = dlsym(_ebi->lib, "gbm_surface_create");
217 _ebi->funcs.gbm.surface_destroy = dlsym(_ebi->lib, "gbm_surface_destroy");
218 _ebi->funcs.gbm.buffer_create = dlsym(_ebi->lib, "gbm_bo_create");
219 _ebi->funcs.gbm.buffer_destroy = dlsym(_ebi->lib, "gbm_bo_destroy");
220 _ebi->funcs.gbm.buffer_handle_get = dlsym(_ebi->lib, "gbm_bo_get_handle");
221 _ebi->funcs.gbm.buffer_stride_get = dlsym(_ebi->lib, "gbm_bo_get_stride");
222
223 return EINA_TRUE;
224}
225
226static Eina_Bool
227_evas_bufmgr_tbm_init(void)
228{
229 int flags = 0;
230
231 /* set dlopen flags */
232 flags = (RTLD_LAZY | RTLD_GLOBAL);
233
234 /* try to find gbm library */
235 _ebi->lib = dlopen("libtbm.so", flags);
236 if (!_ebi->lib) _ebi->lib = dlopen("libtbm.so.1", flags);
237 if (!_ebi->lib) _ebi->lib = dlopen("libtbm.so.1.0.0", flags);
238
239 /* fail if we did not find the library */
240 if (!_ebi->lib) return EINA_FALSE;
241
242 /* with the library found, lets symlink the functions we need */
243 /* TODO */
244
245 return EINA_TRUE;
246}
247
248Eina_Bool
249evas_bufmgr_init(int fd)
250{
251 /* if we already have an interface, then we have been here before */
252 if (_ebi) return EINA_TRUE;
253
254 /* try to allocate space for interface */
255 if (!(_ebi = calloc(1, sizeof(Evas_Bufmgr_Interface)))) return EINA_FALSE;
256
257 /* save drm card fd for later use */
258 _ebi->fd = fd;
259
260 /* try to find and link gbm library first */
261 if (!_evas_bufmgr_gbm_init())
262 {
263 /* try to find and link tbm library */
264 if (!_evas_bufmgr_tbm_init())
265 {
266 ERR("Could not init buffer library");
267 goto err;
268 }
269 }
270
271 /* with the library open and functions linked, lets try to init */
272 if (_ebi->funcs.gbm.init)
273 _ebi->mgr = _ebi->funcs.gbm.init(fd);
274 else if (_ebi->funcs.tbm.init)
275 _ebi->mgr = _ebi->funcs.tbm.init(fd);
276
277 if (!_ebi->mgr)
278 {
279 ERR("Could not init buffer manager");
280 goto init_err;
281 }
282
283 /* with the manager initialized, we need to init egl */
284 if (!_evas_bufmgr_egl_init())
285 WRN("Could not init egl");
286
287 return EINA_TRUE;
288
289/* egl_err: */
290/* if (_ebi->mgr) */
291/* { */
292/* if (_ebi->funcs.gbm.shutdown) _ebi->funcs.gbm.shutdown(_ebi->mgr); */
293/* else if (_ebi->funcs.tbm.shutdown) _ebi->funcs.tbm.shutdown(_ebi->mgr); */
294/* _ebi->mgr = NULL; */
295/* } */
296
297init_err:
298 /* close library */
299 if (_ebi->lib) dlclose(_ebi->lib);
300 _ebi->lib = NULL;
301err:
302 /* free allocated space */
303 free(_ebi);
304 _ebi = NULL;
305
306 return EINA_FALSE;
307}
308
309void
310evas_bufmgr_shutdown(void)
311{
312 /* check for valid interface */
313 if (!_ebi) return;
314
315 /* shutdown egl */
316 _evas_bufmgr_egl_shutdown();
317
318 /* shutdown manager */
319 if (_ebi->mgr)
320 {
321 if (_ebi->funcs.gbm.shutdown) _ebi->funcs.gbm.shutdown(_ebi->mgr);
322 else if (_ebi->funcs.tbm.shutdown) _ebi->funcs.tbm.shutdown(_ebi->mgr);
323 _ebi->mgr = NULL;
324 }
325
326 /* close library */
327 if (_ebi->lib) dlclose(_ebi->lib);
328 _ebi->lib = NULL;
329
330 /* free allocated space */
331 free(_ebi);
332 _ebi = NULL;
333}
334
335#ifdef HAVE_DRM_HW_ACCEL
336void *
337evas_bufmgr_window_create(void *surface)
338{
339 void *win;
340
341 /* check for valid interface */
342 if ((!_ebi) || (_ebi->egl.disp == EGL_NO_DISPLAY)) return NULL;
343
344 /* try to create the egl window surface */
345 win = eglCreateWindowSurface(_ebi->egl.disp, _ebi->egl.cfg,
346 (EGLNativeWindowType)surface, NULL);
347 if (win == EGL_NO_SURFACE)
348 {
349 ERR("Failed to create egl window surface: %m");
350 return NULL;
351 }
352
353 /* try to make this window surface current */
354 if (!eglMakeCurrent(_ebi->egl.disp, win, win, _ebi->egl.ctx))
355 ERR("Could not make window surface current: %m");
356
357 return win;
358}
359
360void
361evas_bufmgr_window_destroy(void *win)
362{
363 /* check for valid interface */
364 if ((!_ebi) || (_ebi->egl.disp == EGL_NO_DISPLAY)) return;
365
366 /* destroy the egl window */
367 if (win) eglDestroySurface(_ebi->egl.disp, win);
368}
369
370void *
371evas_bufmgr_surface_create(int w, int h, Eina_Bool alpha)
372{
373 unsigned int format, flags;
374
375 /* check for valid interface */
376 if ((!_ebi) || (!_ebi->mgr)) return NULL;
377
378 format = EBI_BO_FORMAT_XRGB8888;
379 if (alpha) format = EBI_BO_FORMAT_ARGB8888;
380
381 /* call function to create surface */
382 if (_ebi->funcs.gbm.surface_create)
383 {
384 flags = (EBI_BO_GBM_SCANOUT | EBI_BO_GBM_RENDER);
385 return _ebi->funcs.gbm.surface_create(_ebi->mgr, w, h, format, flags);
386 }
387
388 /* else if (_ebi->funcs.tbm.surface_create) */
389 /* surface = _ebi->funcs.tbm.surface_create(); */
390
391 return NULL;
392}
393
394void
395evas_bufmgr_surface_destroy(void *surface)
396{
397 /* check for valid interface */
398 if ((!_ebi) || (!_ebi->mgr)) return;
399
400 /* check for valid surface */
401 if (!surface) return;
402
403 /* call destroy surface */
404 if (_ebi->funcs.gbm.surface_destroy)
405 _ebi->funcs.gbm.surface_destroy(surface);
406
407 /* else if (_ebi->funcs.tbm.surface_destroy) */
408 /* _ebi->funcs.tbm.surface_destroy(surface); */
409}
410
411void *
412evas_bufmgr_buffer_create(int w, int h, Eina_Bool alpha)
413{
414 unsigned int format, flags;
415
416 /* check for valid interface */
417 if ((!_ebi) || (!_ebi->mgr)) return NULL;
418
419 format = EBI_BO_FORMAT_XRGB8888;
420 if (alpha) format = EBI_BO_FORMAT_ARGB8888;
421
422 /* call function to create surface */
423 if (_ebi->funcs.gbm.buffer_create)
424 {
425 flags = (EBI_BO_GBM_SCANOUT | EBI_BO_GBM_RENDER);
426 return _ebi->funcs.gbm.buffer_create(_ebi->mgr, w, h, format, flags);
427 }
428
429 /* else if (_ebi->funcs.tbm.buffer_create) */
430 /* surface = _ebi->funcs.tbm.buffer_create(); */
431
432 return NULL;
433}
434
435void
436evas_bufmgr_buffer_destroy(void *buffer)
437{
438 /* check for valid interface */
439 if ((!_ebi) || (!_ebi->mgr)) return;
440
441 /* check for valid buffer */
442 if (!buffer) return;
443
444 /* call function to destroy buffer */
445 if (_ebi->funcs.gbm.buffer_destroy)
446 _ebi->funcs.gbm.buffer_destroy(buffer);
447
448 /* else if (_ebi->funcs.tbm.buffer_destroy) */
449 /* _ebi->funcs.tbm.buffer_destroy(buffer); */
450}
451
452int
453evas_bufmgr_buffer_handle_get(void *buffer)
454{
455 /* check for valid interface */
456 if ((!_ebi) || (!_ebi->mgr)) return 0;
457
458 /* check for valid buffer */
459 if (!buffer) return 0;
460
461 /* call function to get buffer handle */
462 if (_ebi->funcs.gbm.buffer_handle_get)
463 return _ebi->funcs.gbm.buffer_handle_get(buffer).u32;
464
465 return 0;
466}
467
468int
469evas_bufmgr_buffer_stride_get(void *buffer)
470{
471 /* check for valid interface */
472 if ((!_ebi) || (!_ebi->mgr)) return 0;
473
474 /* check for valid buffer */
475 if (!buffer) return 0;
476
477 /* call function to get buffer stride */
478 if (_ebi->funcs.gbm.buffer_stride_get)
479 return _ebi->funcs.gbm.buffer_stride_get(buffer);
480
481 /* else if (_ebi->funcs.tbm.buffer_stride_get) */
482 /* return _ebi->funcs.tbm.buffer_stride_get(buffer); */
483
484 return 0;
485}
486
487void *
488evas_bufmgr_image_create(void *buffer)
489{
490 /* check for valid interface */
491 if ((!_ebi) || (_ebi->egl.disp == EGL_NO_DISPLAY)) return NULL;
492
493 /* check for valid buffer */
494 if (!buffer) return NULL;
495
496 /* try to create an egl image from this buffer */
497 if (_ebi->egl.image_create)
498 return _ebi->egl.image_create(_ebi->egl.disp, EGL_NO_CONTEXT,
499 EGL_NATIVE_PIXMAP_KHR, buffer, NULL);
500
501 return NULL;
502}
503
504void
505evas_bufmgr_image_destroy(void *image)
506{
507 /* check for valid interface */
508 if ((!_ebi) || (_ebi->egl.disp == EGL_NO_DISPLAY)) return;
509
510 /* check for valid image */
511 if (!image) return;
512
513 /* destroy egl image */
514 if (_ebi->egl.image_destroy)
515 _ebi->egl.image_destroy(_ebi->egl.disp, image);
516}
517
518unsigned int
519evas_bufmgr_texture_create(void *image)
520{
521 GLuint tex;
522
523 /* check for valid interface */
524 if ((!_ebi) || (_ebi->egl.disp == EGL_NO_DISPLAY)) return 0;
525
526 /* check for valid image */
527 if (!image) return 0;
528
529 glGenTextures(1, &tex);
530 glBindTexture(GL_TEXTURE_2D, tex);
531 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
532 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
533 if (_ebi->egl.image_texture) _ebi->egl.image_texture(GL_TEXTURE_2D, image);
534 glBindTexture(GL_TEXTURE_2D, 0);
535
536 return tex;
537}
538#endif