diff --git a/va/va.c b/va/va.c index fc1f51736..920b76c50 100644 --- a/va/va.c +++ b/va/va.c @@ -674,10 +674,6 @@ static VAStatus va_new_opendriver(VADisplay dpy) const char *driver_name_env; VADriverContextP ctx; - /* XXX: Temporary dummy return, until all platforms are converted */ - if (!pDisplayContext->vaGetDriverNames) - return VA_STATUS_ERROR_INVALID_PARAMETER; - /* XXX: The order is bonkers - env var should take highest priority, then * override (which ought to be nuked) than native. It's not possible atm, * since the DPY connect/init happens during the GetDriverNames. @@ -687,9 +683,6 @@ static VAStatus va_new_opendriver(VADisplay dpy) /* Print and error yet continue, as per the above ordering note */ va_errorMessage(dpy, "vaGetDriverNames() failed with %s\n", vaErrorStr(vaStatus)); num_drivers = 0; - } else if (num_drivers > ARRAY_SIZE(drivers)) { - va_errorMessage(dpy, "DRIVER BUG: vaGetDriverNames() provides too many drivers\n"); - num_drivers = ARRAY_SIZE(drivers); } ctx = CTX(dpy); diff --git a/va/va_backend.h b/va/va_backend.h index ea626b0fc..51e80d058 100644 --- a/va/va_backend.h +++ b/va/va_backend.h @@ -663,6 +663,7 @@ struct VADisplayContext { VADisplayContextP ctx ); + /* Deprecated */ VAStatus(*vaGetDriverName)( VADisplayContextP ctx, char **driver_name @@ -670,23 +671,43 @@ struct VADisplayContext { void *opaque; /* opaque for display extensions (e.g. GLX) */ void *vatrace; /* opaque for VA trace context */ + /* Deprecated */ void *vafool; /* opaque for VA fool context */ VAMessageCallback error_callback; void *error_callback_user_context; VAMessageCallback info_callback; void *info_callback_user_context; + + /* Deprecated */ VAStatus(*vaGetNumCandidates)( VADisplayContextP ctx, int * num_candidates ); + /* Deprecated */ VAStatus(*vaGetDriverNameByIndex)( VADisplayContextP ctx, char **driver_name, int candidate_index ); + /** + * \brief Callback to get an array of driver names. + * + * + * The caller must provide a num_drivers + * This structure is allocated from libva with calloc(). + * + * @param drivers An num_drivers sized array of null terminated strings. + * The array is managed my the caller. The callee will + * populate the individual driver name strings and the + * caller must free them. + * @param num_driver The number of driver strings contained within drivers. + * The caller must set that to the size of the drivers + * array, where the callee will update the value to + * min(caller num_driver, num_drivers_support). + */ VAStatus(*vaGetDriverNames)( VADisplayContextP ctx, char **drivers, diff --git a/va/win32/va_win32.c b/va/win32/va_win32.c index 789933e6b..7a6a895d3 100644 --- a/va/win32/va_win32.c +++ b/va/win32/va_win32.c @@ -38,18 +38,17 @@ const char VAAPI_DEFAULT_DRIVER_NAME[] = "vaon12"; typedef struct _VADisplayContextWin32 { - LUID adapter_luid; char registry_driver_name[MAX_PATH]; bool registry_driver_available_flag; } VADisplayContextWin32; -static void LoadDriverNameFromRegistry(VADisplayContextWin32* pWin32Ctx) +static void LoadDriverNameFromRegistry(const LUID* adapter_luid, VADisplayContextWin32* pWin32Ctx) { HMODULE hGdi32 = LoadLibraryA("gdi32.dll"); if (!hGdi32) return; - D3DKMT_OPENADAPTERFROMLUID OpenArgs = { .AdapterLuid = pWin32Ctx->adapter_luid }; + D3DKMT_OPENADAPTERFROMLUID OpenArgs = { .AdapterLuid = *adapter_luid }; D3DDDI_QUERYREGISTRY_INFO RegistryInfo = { .QueryType = D3DDDI_QUERYREGISTRY_ADAPTERKEY, .QueryFlags.TranslatePath = true, @@ -180,16 +179,13 @@ VADisplay vaGetDisplayWin32( VADisplayContextWin32* pWin32Ctx = (VADisplayContextWin32*) pDisplayContext->opaque; if (adapter_luid) { - /* Copy LUID information to display context */ - memcpy(&pWin32Ctx->adapter_luid, adapter_luid, sizeof(pWin32Ctx->adapter_luid)); - /* Load the preferred driver name from the driver registry if available */ - LoadDriverNameFromRegistry(pWin32Ctx); + LoadDriverNameFromRegistry(adapter_luid, pWin32Ctx); #ifdef _DEBUG if (pWin32Ctx->registry_driver_available_flag) { - fprintf(stderr, "VA_Win32: Found driver %s in the registry for LUID %ld %ld \n", pWin32Ctx->registry_driver_name, pWin32Ctx->adapter_luid.LowPart, pWin32Ctx->adapter_luid.HighPart); + fprintf(stderr, "VA_Win32: Found driver %s in the registry for LUID %ld %ld \n", pWin32Ctx->registry_driver_name, adapter_luid.LowPart, adapter_luid.HighPart); } else { - fprintf(stderr, "VA_Win32: Couldn't find a driver in the registry for LUID %ld %ld. Using default driver: %s \n", pWin32Ctx->adapter_luid.LowPart, pWin32Ctx->adapter_luid.HighPart, VAAPI_DEFAULT_DRIVER_NAME); + fprintf(stderr, "VA_Win32: Couldn't find a driver in the registry for LUID %ld %ld. Using default driver: %s \n", adapter_luid.LowPart, adapter_luid.HighPart, VAAPI_DEFAULT_DRIVER_NAME); } #endif // _DEBUG } diff --git a/va/x11/va_dri2.c b/va/x11/va_dri2.c index 109c2e126..da2a9f40b 100644 --- a/va/x11/va_dri2.c +++ b/va/x11/va_dri2.c @@ -456,11 +456,9 @@ VAStatus va_DRI2_GetDriverNames( if (strcmp(map[i].dri_driver, dri_driver) == 0) { const char * const *va_drivers = map[i].va_driver; - while (va_drivers[count]) { - if (count < MAX_NAMES && count < *num_drivers) - drivers[count] = strdup(va_drivers[count]); - count++; - } + for (; count < MAX_NAMES && va_drivers[count] && count < *num_drivers; count++) + drivers[count] = strdup(va_drivers[count]); + break; } }