Commit b1bc8cf8 authored by Gwenole Beauchesne's avatar Gwenole Beauchesne

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: default avatarGwenole Beauchesne <gwenole.beauchesne@intel.com>
parent 549946cf
...@@ -78,23 +78,43 @@ static void ADL_Main_Memory_Free(void *arg) ...@@ -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; Display *test_dpy;
char *test_dpy_name, *x11_dpy_name; char *test_dpy_name, *x11_dpy_name;
int test_dpy_namelen, x11_dpy_namelen;
int m; int m;
test_dpy = XOpenDisplay(display_name); test_dpy = XOpenDisplay(display_name);
if (!test_dpy) if (!test_dpy)
return 0; return 0;
test_dpy_name = XDisplayString(test_dpy); test_dpy_name = XDisplayString(test_dpy);
x11_dpy_name = XDisplayString(x11_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 = (test_dpy_namelen == x11_dpy_namelen &&
m = strcmp(x11_dpy_name, test_dpy_name) == 0; (test_dpy_namelen == 0 ||
else (test_dpy_namelen > 0 &&
m = !x11_dpy_name && !test_dpy_name; strncmp(test_dpy_name, x11_dpy_name, test_dpy_namelen) == 0)));
XCloseDisplay(test_dpy); XCloseDisplay(test_dpy);
return m; return m;
...@@ -204,14 +224,15 @@ Bool VA_FGLRXGetClientDriverName( Display *dpy, int screen, ...@@ -204,14 +224,15 @@ Bool VA_FGLRXGetClientDriverName( Display *dpy, int screen,
printf(" iPresent: %d\n", lpCurrAdapterInfo->iPresent); printf(" iPresent: %d\n", lpCurrAdapterInfo->iPresent);
printf(" iXScreenNum: %d\n", lpCurrXScreenInfo->iXScreenNum); printf(" iXScreenNum: %d\n", lpCurrXScreenInfo->iXScreenNum);
#endif #endif
if (match_display(dpy, lpCurrAdapterInfo->strDisplayName) && if (screen == lpCurrXScreenInfo->iXScreenNum &&
screen == lpCurrXScreenInfo->iXScreenNum) { match_display_name(dpy, lpCurrAdapterInfo->strDisplayName)) {
*clientDriverName = strdup("fglrx"); if (clientDriverName)
*clientDriverName = strdup("fglrx");
success = True;
break; break;
} }
} }
success = True;
end: end:
if (lpXScreenInfo) if (lpXScreenInfo)
ADL_Main_Memory_Free(&lpXScreenInfo); ADL_Main_Memory_Free(&lpXScreenInfo);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment