Skip to content

Commit 1aaf28d

Browse files
committed
va: Attempt to load driver name without appending drv_video as fallback
This allows LIBVA_DRIVER_NAME pointing to an path string which we want to support. Signed-off-by: Sil Vilerino <sivileri@microsoft.com>
1 parent e9cb530 commit 1aaf28d

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

va/va.c

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,12 @@
3838
#include <string.h>
3939
#if defined(_WIN32)
4040
#include "compat_win32.h"
41-
#define DRIVER_EXTENSION "_drv_video.dll"
4241
#define DRIVER_PATH_STRING "%s\\%s%s"
4342
#define ENV_VAR_SEPARATOR ";"
4443
#else
4544
#include <dlfcn.h>
4645
#include <unistd.h>
47-
#define DRIVER_EXTENSION "_drv_video.so"
48-
#define DRIVER_PATH_STRING "%s/%s%s"
46+
#define DRIVER_PATH_STRING "%s/%s%s.so"
4947
#define ENV_VAR_SEPARATOR ":"
5048
#endif
5149
#ifdef ANDROID
@@ -353,16 +351,16 @@ va_getDriverInitName(char *name, int namelen, int major, int minor)
353351
return ret > 0 && ret < namelen;
354352
}
355353

356-
static char *va_getDriverPath(const char *driver_dir, const char *driver_name)
354+
static char *va_getDriverPath(const char *driver_dir, const char *driver_name, bool use_suffix)
357355
{
358-
int n = snprintf(0, 0, DRIVER_PATH_STRING, driver_dir, driver_name, DRIVER_EXTENSION);
356+
int n = snprintf(0, 0, DRIVER_PATH_STRING, driver_dir, driver_name, use_suffix ? "_drv_video" : "");
359357
if (n < 0)
360358
return NULL;
361359
char *driver_path = (char *) malloc(n + 1);
362360
if (!driver_path)
363361
return NULL;
364362
n = snprintf(driver_path, n + 1, DRIVER_PATH_STRING,
365-
driver_dir, driver_name, DRIVER_EXTENSION);
363+
driver_dir, driver_name, use_suffix ? "_drv_video" : "");
366364
if (n < 0) {
367365
free(driver_path);
368366
return NULL;
@@ -529,19 +527,20 @@ static VAStatus va_openDriver(VADisplay dpy, char *driver_name)
529527
}
530528
driver_dir = strtok_r(search_path, ENV_VAR_SEPARATOR, &saveptr);
531529
while (driver_dir) {
532-
char *driver_path = va_getDriverPath(driver_dir, driver_name);
533-
if (!driver_path) {
534-
va_errorMessage(dpy, "%s L%d Out of memory\n",
535-
__FUNCTION__, __LINE__);
536-
free(search_path);
537-
return VA_STATUS_ERROR_ALLOCATION_FAILED;
538-
}
539-
540-
vaStatus = va_openDriverFromPath(dpy, driver_path);
541-
free(driver_path);
542-
if (VA_STATUS_SUCCESS == vaStatus)
543-
break;
530+
for (int use_suffix = 1; use_suffix >= 0; use_suffix--) {
531+
char *driver_path = va_getDriverPath(driver_dir, driver_name, use_suffix);
532+
if (!driver_path) {
533+
va_errorMessage(dpy, "%s L%d Out of memory\n",
534+
__FUNCTION__, __LINE__);
535+
free(search_path);
536+
return VA_STATUS_ERROR_ALLOCATION_FAILED;
537+
}
544538

539+
vaStatus = va_openDriverFromPath(dpy, driver_path);
540+
free(driver_path);
541+
if (VA_STATUS_SUCCESS == vaStatus)
542+
break;
543+
}
545544
driver_dir = strtok_r(NULL, ENV_VAR_SEPARATOR, &saveptr);
546545
}
547546

0 commit comments

Comments
 (0)