summaryrefslogtreecommitdiff
path: root/va
diff options
context:
space:
mode:
authorGwenole Beauchesne <gwenole.beauchesne@intel.com>2011-10-11 10:34:37 +0200
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>2011-10-11 11:19:57 +0200
commitb1bc8cf807f481dcdd2b42aa55c764295f413e34 (patch)
treebfaaf48a664fb47759bd44719220893008998fef /va
parent549946cf2c5e0c5884d3137b1393967a6a891784 (diff)
va_fglrx: fix driver name detection.
VA_FGLRXGetClientDriverName() used to return success even if no valid driver name was found, thus returning a NULL driver name. Also fixed the X display name matching routine to filter out the screen number, which may not be in the string, and make sure to compare screen numbers from what ADL returns too. Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
Diffstat (limited to 'va')
-rw-r--r--va/x11/va_fglrx.c43
1 files changed, 32 insertions, 11 deletions
diff --git a/va/x11/va_fglrx.c b/va/x11/va_fglrx.c
index 5be0256..77149cb 100644
--- a/va/x11/va_fglrx.c
+++ b/va/x11/va_fglrx.c
@@ -78,23 +78,43 @@ static void ADL_Main_Memory_Free(void *arg)
}
}
-static int match_display(Display *x11_dpy, const char *display_name)
+static int get_display_name_length(const char *name)
+{
+ const char *m;
+
+ if (!name)
+ return 0;
+
+ /* Strip out screen number */
+ m = strchr(name, ':');
+ if (m) {
+ m = strchr(m, '.');
+ if (m)
+ return m - name;
+ }
+ return strlen(name);
+}
+
+static int match_display_name(Display *x11_dpy, const char *display_name)
{
Display *test_dpy;
char *test_dpy_name, *x11_dpy_name;
+ int test_dpy_namelen, x11_dpy_namelen;
int m;
test_dpy = XOpenDisplay(display_name);
if (!test_dpy)
return 0;
- test_dpy_name = XDisplayString(test_dpy);
- x11_dpy_name = XDisplayString(x11_dpy);
+ test_dpy_name = XDisplayString(test_dpy);
+ test_dpy_namelen = get_display_name_length(test_dpy_name);
+ x11_dpy_name = XDisplayString(x11_dpy);
+ x11_dpy_namelen = get_display_name_length(x11_dpy_name);
- if (x11_dpy_name && test_dpy_name)
- m = strcmp(x11_dpy_name, test_dpy_name) == 0;
- else
- m = !x11_dpy_name && !test_dpy_name;
+ m = (test_dpy_namelen == x11_dpy_namelen &&
+ (test_dpy_namelen == 0 ||
+ (test_dpy_namelen > 0 &&
+ strncmp(test_dpy_name, x11_dpy_name, test_dpy_namelen) == 0)));
XCloseDisplay(test_dpy);
return m;
@@ -204,14 +224,15 @@ Bool VA_FGLRXGetClientDriverName( Display *dpy, int screen,
printf(" iPresent: %d\n", lpCurrAdapterInfo->iPresent);
printf(" iXScreenNum: %d\n", lpCurrXScreenInfo->iXScreenNum);
#endif
- if (match_display(dpy, lpCurrAdapterInfo->strDisplayName) &&
- screen == lpCurrXScreenInfo->iXScreenNum) {
- *clientDriverName = strdup("fglrx");
+ if (screen == lpCurrXScreenInfo->iXScreenNum &&
+ match_display_name(dpy, lpCurrAdapterInfo->strDisplayName)) {
+ if (clientDriverName)
+ *clientDriverName = strdup("fglrx");
+ success = True;
break;
}
}
- success = True;
end:
if (lpXScreenInfo)
ADL_Main_Memory_Free(&lpXScreenInfo);