summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2014-09-23 21:31:54 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2014-09-23 21:31:54 +0900
commit13295d7350489b0d814e62a9fb8c218d032ee95a (patch)
tree065350206d2e32192b02b467844dd8f7f89cda79
parent119134751fc0e4aa12d29faf8675a9e111ac5e08 (diff)
efl - vsync - deal with both broken and non-broken libdrm
@fix
-rw-r--r--src/lib/ecore_x/xlib/ecore_x_vsync.c68
1 files changed, 56 insertions, 12 deletions
diff --git a/src/lib/ecore_x/xlib/ecore_x_vsync.c b/src/lib/ecore_x/xlib/ecore_x_vsync.c
index 59a9231..748d1af 100644
--- a/src/lib/ecore_x/xlib/ecore_x_vsync.c
+++ b/src/lib/ecore_x/xlib/ecore_x_vsync.c
@@ -96,7 +96,7 @@ typedef struct _drmEventContext
96 void *user_data); 96 void *user_data);
97} drmEventContext; 97} drmEventContext;
98 98
99typedef struct _drmVersion 99typedef struct _drmVersionBroken
100{ 100{
101 int version_major; 101 int version_major;
102 int version_minor; 102 int version_minor;
@@ -110,6 +110,22 @@ typedef struct _drmVersion
110 char *date; 110 char *date;
111 size_t desc_len; 111 size_t desc_len;
112 char *desc; 112 char *desc;
113} drmVersionBroken;
114
115typedef struct _drmVersion
116{
117 int version_major;
118 int version_minor;
119 int version_patchlevel;
120 size_t name_len;
121 // WARNING! this does NOT match the system drm.h headers because
122 // literally drm.h is wrong. the below is correct. drm hapily
123 // broke its ABI at some point.
124 char *name;
125 size_t date_len;
126 char *date;
127 size_t desc_len;
128 char *desc;
113} drmVersion; 129} drmVersion;
114 130
115static int (*sym_drmClose)(int fd) = NULL; 131static int (*sym_drmClose)(int fd) = NULL;
@@ -428,8 +444,10 @@ _drm_init(void)
428 if (!getenv("ECORE_VSYNC_DRM_ALL")) 444 if (!getenv("ECORE_VSYNC_DRM_ALL"))
429 { 445 {
430 drmVersion *drmver; 446 drmVersion *drmver;
447 drmVersionBroken *drmverbroken;
431 448
432 drmver = sym_drmGetVersion(drm_fd); 449 drmver = sym_drmGetVersion(drm_fd);
450 drmverbroken = (drmVersionBroken *)drmver;
433 if (!drmver) 451 if (!drmver)
434 { 452 {
435 close(drm_fd); 453 close(drm_fd);
@@ -441,25 +459,51 @@ _drm_init(void)
441 // not garbage (within a sensible range) 459 // not garbage (within a sensible range)
442 if (getenv("ECORE_VSYNC_DRM_VERSION_DEBUG")) 460 if (getenv("ECORE_VSYNC_DRM_VERSION_DEBUG"))
443 { 461 {
444 fprintf(stderr, 462 if ((drmverbroken->name > (char *)4000L) &&
445 "DRM Version: %i.%i\n" 463 (drmverbroken->date_len < 200))
446 "Name: '%s'\n" 464 fprintf(stderr,
447 "Date: '%s'\n" 465 "!BROKEN DRM! Do FIXUP of ABI\n"
448 "Desc: '%s'\n", 466 "DRM Version: %i.%i\n"
449 drmver->version_major, drmver->version_minor, 467 "Name: '%s'\n"
450 drmver->name, drmver->date, drmver->desc); 468 "Date: '%s'\n"
469 "Desc: '%s'\n",
470 drmverbroken->version_major, drmverbroken->version_minor,
471 drmverbroken->name, drmverbroken->date, drmverbroken->desc);
472 else
473 fprintf(stderr,
474 "OK DRM\n"
475 "DRM Version: %i.%i\n"
476 "Name: '%s'\n"
477 "Date: '%s'\n"
478 "Desc: '%s'\n",
479 drmver->version_major, drmver->version_minor,
480 drmver->name, drmver->date, drmver->desc);
451 } 481 }
452 if ((drmver->version_major >= 1) && 482 if ((drmver->version_major >= 1) &&
453 (drmver->version_minor >= 6) && 483 (drmver->version_minor >= 6) &&
454 (drmver->name) && 484 (drmver->name > (char *)4000L) &&
455 (drmver->desc) && 485 (drmver->date_len < 200))
456 (drmver->desc_len > 0) &&
457 (drmver->desc_len < 200))
458 { 486 {
459 // whitelist of known-to-work drivers 487 // whitelist of known-to-work drivers
460 if ((!strcmp(drmver->name, "i915")) && 488 if ((!strcmp(drmver->name, "i915")) &&
461 (strstr(drmver->desc, "Intel Graphics"))) 489 (strstr(drmver->desc, "Intel Graphics")))
462 { 490 {
491 if (getenv("ECORE_VSYNC_DRM_VERSION_DEBUG"))
492 fprintf(stderr, "Whitelisted intel OK\n");
493 ok = EINA_TRUE;
494 }
495 }
496 else if ((drmverbroken->version_major >= 1) &&
497 (drmverbroken->version_minor >= 6) &&
498 (drmverbroken->name > (char *)4000L) &&
499 (drmverbroken->date_len < 200))
500 {
501 // whitelist of known-to-work drivers
502 if ((!strcmp(drmverbroken->name, "i915")) &&
503 (strstr(drmverbroken->desc, "Intel Graphics")))
504 {
505 if (getenv("ECORE_VSYNC_DRM_VERSION_DEBUG"))
506 fprintf(stderr, "Whitelisted intel OK\n");
463 ok = EINA_TRUE; 507 ok = EINA_TRUE;
464 } 508 }
465 } 509 }