Skip to content

Commit

Permalink
enable driver candidate select fucntion for DRM
Browse files Browse the repository at this point in the history
add multiple backend driver support part 3
enable vaGetDriverNameByIndex for DRM

Signed-off-by: Carl Zhang <carl.zhang@intel.com>
  • Loading branch information
XinfengZhang committed Dec 10, 2019
1 parent 19ee041 commit 7af8faa
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
7 changes: 4 additions & 3 deletions va/drm/va_drm.c
Expand Up @@ -55,7 +55,8 @@ va_DisplayContextDestroy(VADisplayContextP pDisplayContext)
static VAStatus
va_DisplayContextGetDriverName(
VADisplayContextP pDisplayContext,
char **driver_name_ptr
char **driver_name_ptr,
int candidate_index
)
{

Expand All @@ -65,7 +66,7 @@ va_DisplayContextGetDriverName(
VAStatus status;
int ret;

status = VA_DRM_GetDriverName(ctx, driver_name_ptr);
status = VA_DRM_GetDriverName(ctx, driver_name_ptr, candidate_index);
if (status != VA_STATUS_SUCCESS)
return status;

Expand Down Expand Up @@ -108,7 +109,7 @@ vaGetDisplayDRM(int fd)

pDisplayContext->vaIsValid = va_DisplayContextIsValid;
pDisplayContext->vaDestroy = va_DisplayContextDestroy;
pDisplayContext->vaGetDriverName = va_DisplayContextGetDriverName;
pDisplayContext->vaGetDriverNameByIndex = va_DisplayContextGetDriverName;

pDriverContext = va_newDriverContext(pDisplayContext);
if (!pDriverContext)
Expand Down
12 changes: 10 additions & 2 deletions va/drm/va_drm_utils.c
Expand Up @@ -50,12 +50,13 @@ static const struct driver_name_map g_driver_name_map[] = {

/* Returns the VA driver name for the active display */
VAStatus
VA_DRM_GetDriverName(VADriverContextP ctx, char **driver_name_ptr)
VA_DRM_GetDriverName(VADriverContextP ctx, char **driver_name_ptr, int candidate_index)
{
struct drm_state * const drm_state = ctx->drm_state;
drmVersionPtr drm_version;
char *driver_name = NULL;
const struct driver_name_map *m;
int current_index = 0;

*driver_name_ptr = NULL;

Expand All @@ -69,7 +70,14 @@ VA_DRM_GetDriverName(VADriverContextP ctx, char **driver_name_ptr)
for (m = g_driver_name_map; m->key != NULL; m++) {
if (drm_version->name_len >= m->key_len &&
strncmp(drm_version->name, m->key, m->key_len) == 0)
break;
{
if(current_index == candidate_index)
{
break;
}
current_index ++;
}

}
drmFreeVersion(drm_version);

Expand Down
2 changes: 1 addition & 1 deletion va/drm/va_drm_utils.h
Expand Up @@ -62,7 +62,7 @@ extern "C" {
*/
DLL_HIDDEN
VAStatus
VA_DRM_GetDriverName(VADriverContextP ctx, char **driver_name_ptr);
VA_DRM_GetDriverName(VADriverContextP ctx, char **driver_name_ptr, int candidate_index);

/**
* \brief Checks whether the file descriptor is a DRM Render-Nodes one
Expand Down
2 changes: 1 addition & 1 deletion va/wayland/va_wayland_drm.c
Expand Up @@ -124,7 +124,7 @@ va_DisplayContextGetDriverName(
{
VADriverContextP const ctx = pDisplayContext->pDriverContext;

return VA_DRM_GetDriverName(ctx, driver_name_ptr);
return VA_DRM_GetDriverName(ctx, driver_name_ptr, 0);
}

void
Expand Down

0 comments on commit 7af8faa

Please sign in to comment.