summaryrefslogtreecommitdiff
path: root/src/lib/ecore_drm2/ecore_drm2.c
diff options
context:
space:
mode:
authorChris Michael <cp.michael@samsung.com>2016-11-14 13:34:54 -0500
committerChris Michael <cp.michael@samsung.com>2016-11-15 08:42:07 -0500
commit0a2c06fc58b4eac4cdcd9f7907e940d1c742dd92 (patch)
tree2b93d076327dbb263c797b2b7944ebc6046b12c8 /src/lib/ecore_drm2/ecore_drm2.c
parentb820ad367641cceef2071fd25619a0dc09a4681a (diff)
ecore-drm2: Symlink to libdrm functions during init time
Signed-off-by: Chris Michael <cp.michael@samsung.com>
Diffstat (limited to 'src/lib/ecore_drm2/ecore_drm2.c')
-rw-r--r--src/lib/ecore_drm2/ecore_drm2.c90
1 files changed, 90 insertions, 0 deletions
diff --git a/src/lib/ecore_drm2/ecore_drm2.c b/src/lib/ecore_drm2/ecore_drm2.c
index 339362a..3728866 100644
--- a/src/lib/ecore_drm2/ecore_drm2.c
+++ b/src/lib/ecore_drm2/ecore_drm2.c
@@ -1,12 +1,97 @@
1#include "ecore_drm2_private.h" 1#include "ecore_drm2_private.h"
2 2
3static int _ecore_drm2_init_count = 0; 3static int _ecore_drm2_init_count = 0;
4static void *drm_lib = NULL;
4 5
5int _ecore_drm2_log_dom = -1; 6int _ecore_drm2_log_dom = -1;
6 7
7EAPI int ECORE_DRM2_EVENT_OUTPUT_CHANGED = -1; 8EAPI int ECORE_DRM2_EVENT_OUTPUT_CHANGED = -1;
8EAPI int ECORE_DRM2_EVENT_ACTIVATE = -1; 9EAPI int ECORE_DRM2_EVENT_ACTIVATE = -1;
9 10
11static Eina_Bool
12_ecore_drm2_link(void)
13{
14 int i, fail;
15 const char *drm_libs[] =
16 {
17 "libdrm.so.2",
18 "libdrm.so.1",
19 "libdrm.so.0",
20 "libdrm.so",
21 NULL,
22 };
23
24#define SYM(lib, xx) \
25 do { \
26 sym_ ## xx = dlsym(lib, #xx); \
27 if (!(sym_ ## xx)) { \
28 fail = 1; \
29 } \
30 } while (0)
31
32 if (drm_lib) return EINA_TRUE;
33
34 for (i = 0; drm_libs[i]; i++)
35 {
36 drm_lib = dlopen(drm_libs[i], RTLD_LOCAL | RTLD_LAZY);
37 if (!drm_lib) continue;
38
39 fail = 0;
40
41 SYM(drm_lib, drmIoctl);
42 /* SYM(drm_lib, drmClose); */
43 /* SYM(drm_lib, drmWaitVBlank); */
44 SYM(drm_lib, drmHandleEvent);
45 SYM(drm_lib, drmGetVersion);
46 SYM(drm_lib, drmFreeVersion);
47 SYM(drm_lib, drmModeGetProperty);
48 SYM(drm_lib, drmModeFreeProperty);
49 SYM(drm_lib, drmModeGetPropertyBlob);
50 SYM(drm_lib, drmModeFreePropertyBlob);
51 SYM(drm_lib, drmModeDestroyPropertyBlob);
52 SYM(drm_lib, drmModeObjectGetProperties);
53 SYM(drm_lib, drmModeFreeObjectProperties);
54 SYM(drm_lib, drmModeCreatePropertyBlob);
55#ifdef HAVE_ATOMIC_DRM
56 SYM(drm_lib, drmModeAtomicAlloc);
57 SYM(drm_lib, drmModeAtomicFree);
58 SYM(drm_lib, drmModeAtomicAddProperty);
59 SYM(drm_lib, drmModeAtomicCommit);
60 SYM(drm_lib, drmModeAtomicSetCursor);
61#endif
62 SYM(drm_lib, drmModeGetEncoder);
63 SYM(drm_lib, drmModeFreeEncoder);
64 SYM(drm_lib, drmModeGetCrtc);
65 SYM(drm_lib, drmModeFreeCrtc);
66 SYM(drm_lib, drmModeSetCrtc);
67 SYM(drm_lib, drmModeGetResources);
68 SYM(drm_lib, drmModeFreeResources);
69 SYM(drm_lib, drmModeGetConnector);
70 SYM(drm_lib, drmModeFreeConnector);
71 SYM(drm_lib, drmModeConnectorSetProperty);
72 SYM(drm_lib, drmGetCap);
73 SYM(drm_lib, drmSetClientCap);
74 SYM(drm_lib, drmModeGetPlaneResources);
75 SYM(drm_lib, drmModeFreePlaneResources);
76 SYM(drm_lib, drmModeGetPlane);
77 SYM(drm_lib, drmModeFreePlane);
78 SYM(drm_lib, drmModeAddFB);
79 SYM(drm_lib, drmModeRmFB);
80 SYM(drm_lib, drmModeDirtyFB);
81
82 if (fail)
83 {
84 dlclose(drm_lib);
85 drm_lib = NULL;
86 }
87 else
88 break;
89 }
90
91 if (!drm_lib) return EINA_FALSE;
92 return EINA_TRUE;
93}
94
10EAPI int 95EAPI int
11ecore_drm2_init(void) 96ecore_drm2_init(void)
12{ 97{
@@ -43,8 +128,13 @@ ecore_drm2_init(void)
43 ECORE_DRM2_EVENT_OUTPUT_CHANGED = ecore_event_type_new(); 128 ECORE_DRM2_EVENT_OUTPUT_CHANGED = ecore_event_type_new();
44 ECORE_DRM2_EVENT_ACTIVATE = ecore_event_type_new(); 129 ECORE_DRM2_EVENT_ACTIVATE = ecore_event_type_new();
45 130
131 if (!_ecore_drm2_link()) goto link_err;
132
46 return _ecore_drm2_init_count; 133 return _ecore_drm2_init_count;
47 134
135link_err:
136 eina_log_domain_unregister(_ecore_drm2_log_dom);
137 _ecore_drm2_log_dom = -1;
48log_err: 138log_err:
49 elput_shutdown(); 139 elput_shutdown();
50elput_err: 140elput_err: