Skip to content

Commit

Permalink
Upgrade to release tag: Libva 2.20.0
Browse files Browse the repository at this point in the history
* Release tag: https://github.com/intel/libva/releases/tag/2.20.0

Tracked-On: OAM-113713
Signed-off-by: zhangyichix <[email protected]>
  • Loading branch information
zhangyichix committed Dec 1, 2023
1 parent 2787a79 commit 1642615
Show file tree
Hide file tree
Showing 29 changed files with 491 additions and 544 deletions.
30 changes: 29 additions & 1 deletion NEWS
Original file line number Diff line number Diff line change
@@ -1,6 +1,34 @@
libva NEWS -- summary of user visible changes. 2023-07-04
libva NEWS -- summary of user visible changes. 2023-09-14
Copyright (C) 2009-2023 Intel Corporation

version 2.20.0 - 14.Sep.2023
* va: drop no longer applicable vaGetDriverNames check
* va: remove unreachable "DRIVER BUG"
* x11/dri2: limit the array handling to avoid out of range access
* va/backend: document the vaGetDriver* APIs
* va/backend: annotate vafool as deprecated
* win32: remove duplicate adapter_luid entry
* va: Added Q416 fourcc (three-plane 16-bit YUV 4:4:4)
* trace: fix minor issue about printf data type and value range
* jpeg: add support for crop and partial decode
* trace: Unlock mutex before return
* trace: Add trace for vaExportSurfaceHandle
* av1: Revise offsets comments for av1 encode
* va: Add new VADecodeErrorType to indicate the reset happended in the driver.
* drm: limit the array size to avoid out of range
* va: fix:set driver number to be zero if vaGetDriverNames failed
* va: fix:don't leak driver names, when override is set
* win32: Only print win32 driver messages in DEBUG builds
* va: Add vendor string on va_TraceInitialize
* va: remove legacy code paths
* drm: remove no longer used helpers
* x11: remove legacy code paths
* x11: allow disabling DRI3 via LIBVA_DRI3_DISABLE env var
* x11: implement vaGetDriverNames
* va/x11/va_nvctrl: remove some dead code
* va/x11/va_fglrx: remove some dead code
* va: optimize code of getting driver name for all protocols/os(wayland,x11,drm,win32,android)

version 2.19.0 - 04.Jul.2023
* docs: fix references and descriptions snf focyhrn mstkup
* ci: add build docs test
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
# - reset micro version to zero when minor version is incremented
# - reset minor version to zero when major version is incremented
m4_define([va_api_major_version], [1])
m4_define([va_api_minor_version], [19])
m4_define([va_api_minor_version], [20])
m4_define([va_api_micro_version], [0])

m4_define([va_api_version],
Expand Down
4 changes: 2 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# - reset micro version to zero when VA-API major or minor version is changed
project(
'libva', 'c',
version : '2.19.0',
version : '2.20.0',
meson_version : '>= 0.53.0',
default_options : [ 'warning_level=1',
'buildtype=debugoptimized' ])
Expand All @@ -19,7 +19,7 @@ project(
# - reset micro version to zero when minor version is incremented
# - reset minor version to zero when major version is incremented
va_api_major_version = 1
va_api_minor_version = 19
va_api_minor_version = 20
va_api_micro_version = 0

va_api_version = '@0@.@1@.@2@'.format(va_api_major_version,
Expand Down
28 changes: 14 additions & 14 deletions va/android/va_android.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2007 Intel Corporation. All Rights Reserved.
* Copyright (c) 2023 Emil Velikov
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
Expand Down Expand Up @@ -61,38 +62,38 @@ static void va_DisplayContextDestroy(
free(pDisplayContext);
}

static VAStatus va_DisplayContextGetNumCandidates(
VADisplayContextP pDisplayContext,
int *num_candidates
static VAStatus va_DisplayContextConnect(
VADisplayContextP pDisplayContext
)
{
VADriverContextP const ctx = pDisplayContext->pDriverContext;
struct drm_state * drm_state = (struct drm_state *)ctx->drm_state;
struct drm_state * const drm_state = (struct drm_state *)ctx->drm_state;

memset(drm_state, 0, sizeof(*drm_state));
drm_state->fd = open(DEVICE_NAME, O_RDWR | O_CLOEXEC);

if (drm_state->fd < 0) {
fprintf(stderr, "Cannot open DRM device '%s': %d, %s\n",
DEVICE_NAME, errno, strerror(errno));
return VA_STATUS_ERROR_UNKNOWN;
}
drm_state->auth_type = VA_DRM_AUTH_CUSTOM;
return VA_DRM_GetNumCandidates(ctx, num_candidates);
return VA_STATUS_SUCCESS;
}

static VAStatus va_DisplayContextGetDriverNameByIndex(
static VAStatus
va_DisplayContextGetDriverNames(
VADisplayContextP pDisplayContext,
char **driver_name,
int candidate_index
char **drivers,
unsigned *num_drivers
)
{
VADriverContextP const ctx = pDisplayContext->pDriverContext;
VAStatus status = va_DisplayContextConnect(pDisplayContext);
if (status != VA_STATUS_SUCCESS)
return status;

return VA_DRM_GetDriverName(ctx, driver_name, candidate_index);
return VA_DRM_GetDriverNames(ctx, drivers, num_drivers);
}


VADisplay vaGetDisplay(
void *native_dpy /* implementation specific */
)
Expand All @@ -109,8 +110,7 @@ VADisplay vaGetDisplay(
return NULL;

pDisplayContext->vaDestroy = va_DisplayContextDestroy;
pDisplayContext->vaGetDriverNameByIndex = va_DisplayContextGetDriverNameByIndex;
pDisplayContext->vaGetNumCandidates = va_DisplayContextGetNumCandidates;
pDisplayContext->vaGetDriverNames = va_DisplayContextGetDriverNames;

pDriverContext = va_newDriverContext(pDisplayContext);
if (!pDriverContext) {
Expand Down
29 changes: 15 additions & 14 deletions va/drm/va_drm.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2012 Intel Corporation. All Rights Reserved.
* Copyright (c) 2023 Emil Velikov
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
Expand Down Expand Up @@ -41,19 +42,17 @@ va_DisplayContextDestroy(VADisplayContextP pDisplayContext)
free(pDisplayContext->pDriverContext);
free(pDisplayContext);
}
static VAStatus va_DisplayContextGetNumCandidates(
VADisplayContextP pDisplayContext,
int *num_candidates


static VAStatus va_DisplayContextConnect(
VADisplayContextP pDisplayContext
)
{
VADriverContextP const ctx = pDisplayContext->pDriverContext;
struct drm_state * const drm_state = ctx->drm_state;
VAStatus status = VA_STATUS_SUCCESS;
drm_magic_t magic;
int ret;
status = VA_DRM_GetNumCandidates(ctx, num_candidates);
if (status != VA_STATUS_SUCCESS)
return status;

/* Authentication is only needed for a legacy DRM device */
if (ctx->display_type != VA_DISPLAY_DRM_RENDERNODES) {
ret = drmGetMagic(drm_state->fd, &magic);
Expand All @@ -68,17 +67,20 @@ static VAStatus va_DisplayContextGetNumCandidates(
return VA_STATUS_SUCCESS;
}


static VAStatus
va_DisplayContextGetDriverNameByIndex(
va_DisplayContextGetDriverNames(
VADisplayContextP pDisplayContext,
char **driver_name_ptr,
int candidate_index
char **drivers,
unsigned *num_drivers
)
{

VADriverContextP const ctx = pDisplayContext->pDriverContext;
VAStatus status = va_DisplayContextConnect(pDisplayContext);
if (status != VA_STATUS_SUCCESS)
return status;

return VA_DRM_GetDriverName(ctx, driver_name_ptr, candidate_index);
return VA_DRM_GetDriverNames(ctx, drivers, num_drivers);
}

VADisplay
Expand All @@ -104,8 +106,7 @@ vaGetDisplayDRM(int fd)
goto error;

pDisplayContext->vaDestroy = va_DisplayContextDestroy;
pDisplayContext->vaGetNumCandidates = va_DisplayContextGetNumCandidates;
pDisplayContext->vaGetDriverNameByIndex = va_DisplayContextGetDriverNameByIndex;
pDisplayContext->vaGetDriverNames = va_DisplayContextGetDriverNames;

pDriverContext = va_newDriverContext(pDisplayContext);
if (!pDriverContext)
Expand Down
131 changes: 45 additions & 86 deletions va/drm/va_drm_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* va_drm_utils.c - VA/DRM Utilities
*
* Copyright (c) 2012 Intel Corporation. All Rights Reserved.
* Copyright (c) 2023 Emil Velikov
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
Expand Down Expand Up @@ -31,22 +32,7 @@
#include "va_drm_utils.h"
#include "va_drmcommon.h"

struct driver_name_map {
const char *key;
const char *name;
};

static const struct driver_name_map g_driver_name_map[] = {
{ "i915", "iHD" }, // Intel Media driver
{ "i915", "i965" }, // Intel OTC GenX driver
{ "pvrsrvkm", "pvr" }, // Intel UMG PVR driver
{ "radeon", "r600" }, // Mesa Gallium driver
{ "radeon", "radeonsi" }, // Mesa Gallium driver
{ "amdgpu", "radeonsi" }, // Mesa Gallium driver
{ "WSL", "d3d12" }, // Mesa Gallium driver
{ "nvidia-drm", "nvidia" }, // NVIDIA driver
{ NULL, NULL }
};
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))

static char *
va_DRM_GetDrmDriverName(int fd)
Expand All @@ -63,88 +49,61 @@ va_DRM_GetDrmDriverName(int fd)
return driver_name;
}

/* Returns the VA driver candidate num for the active display*/
/* Returns the VA driver names and how many they are, for the active display */
VAStatus
VA_DRM_GetNumCandidates(VADriverContextP ctx, int * num_candidates)
VA_DRM_GetDriverNames(VADriverContextP ctx, char **drivers, unsigned *num_drivers)
{
struct drm_state * const drm_state = ctx->drm_state;
int count = 0;
const struct driver_name_map *m = NULL;
char *driver_name;

if (!drm_state || drm_state->fd < 0)
return VA_STATUS_ERROR_INVALID_DISPLAY;

driver_name = va_DRM_GetDrmDriverName(drm_state->fd);
if (!driver_name)
return VA_STATUS_ERROR_UNKNOWN;

for (m = g_driver_name_map; m->key != NULL; m++) {
if (strcmp(m->key, driver_name) == 0) {
count ++;
}
}

free(driver_name);

/*
* If the drm driver name does not have a mapped vaapi driver name, then
* assume they have the same name.
*/
if (count == 0)
count = 1;

*num_candidates = count;
return VA_STATUS_SUCCESS;
}

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

*driver_name_ptr = NULL;

if (!drm_state || drm_state->fd < 0)
return VA_STATUS_ERROR_INVALID_DISPLAY;

*driver_name_ptr = va_DRM_GetDrmDriverName(drm_state->fd);

if (!*driver_name_ptr)
#define MAX_NAMES 2 // Adjust if needed

static const struct {
const char * const drm_driver;
const char * const va_driver[MAX_NAMES];
} map[] = {
{ "i915", { "iHD", "i965" } }, // Intel Media and OTC GenX
{ "pvrsrvkm", { "pvr" } }, // Intel UMG PVR
{ "radeon", { "r600", "radeonsi" } }, // Mesa Gallium
{ "amdgpu", { "radeonsi" } }, // Mesa Gallium
{ "WSL", { "d3d12" } }, // Mesa Gallium
{ "nvidia-drm", { "nvidia" } }, // Unofficial NVIDIA
};

const struct drm_state * const drm_state = ctx->drm_state;
char *drm_driver;
unsigned count = 0;

drm_driver = va_DRM_GetDrmDriverName(drm_state->fd);
if (!drm_driver)
return VA_STATUS_ERROR_UNKNOWN;

/* Map vgem to WSL2 for Windows subsystem for linux */
struct utsname sysinfo = {};
if (!strncmp(*driver_name_ptr, "vgem", 4) && uname(&sysinfo) >= 0 &&
if (!strncmp(drm_driver, "vgem", 4) && uname(&sysinfo) >= 0 &&
strstr(sysinfo.release, "WSL")) {
free(*driver_name_ptr);
*driver_name_ptr = strdup("WSL");
free(drm_driver);
drm_driver = strdup("WSL");
if (!drm_driver)
return VA_STATUS_ERROR_UNKNOWN;
}

for (m = g_driver_name_map; m->key != NULL; m++) {
if (strcmp(m->key, *driver_name_ptr) == 0) {
if (current_index == candidate_index) {
break;
}
current_index ++;
for (unsigned i = 0; i < ARRAY_SIZE(map); i++) {
if (strcmp(map[i].drm_driver, drm_driver) == 0) {
const char * const *va_drivers = map[i].va_driver;
for (; count < MAX_NAMES && va_drivers[count] && count < *num_drivers; count++)
drivers[count] = strdup(va_drivers[count]);

break;
}
}

/*
* If the drm driver name does not have a mapped vaapi driver name, then
* assume they have the same name.
*/
if (!m->name)
return VA_STATUS_SUCCESS;

/* Use the mapped vaapi driver name */
free(*driver_name_ptr);
*driver_name_ptr = strdup(m->name);
if (!*driver_name_ptr)
return VA_STATUS_ERROR_ALLOCATION_FAILED;
/* Fallback to the drm driver, if there's no va equivalent in the map. */
if (!count) {
drivers[count] = drm_driver;
count++;
} else {
free(drm_driver);
}

*num_drivers = count;

return VA_STATUS_SUCCESS;
}
24 changes: 2 additions & 22 deletions va/drm/va_drm_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,30 +41,10 @@
#ifdef __cplusplus
extern "C" {
#endif

DLL_HIDDEN
VAStatus
VA_DRM_GetNumCandidates(VADriverContextP ctx, int * num_candidates);
/**
* \brief Returns the VA driver name for the active display.
*
* This functions returns a newly allocated buffer in @driver_name_ptr that
* contains the VA driver name for the active display. Active display means
* the display obtained with any of the vaGetDisplay*() functions.
*
* The VADriverContext.drm_state structure must be valid, i.e. allocated
* and containing an open DRM connection descriptor. The DRM connection
* does *not* need to be authenticated as it only performs a call to
* drmGetVersion().
*
* @param[in] ctx the pointer to a VADriverContext
* @param[out] driver_name_ptr the newly allocated buffer containing
* the VA driver name
* @return VA_STATUS_SUCCESS if operation is successful, or another
* #VAStatus value otherwise.
*/
DLL_HIDDEN
VAStatus
VA_DRM_GetDriverName(VADriverContextP ctx, char **driver_name_ptr, int candidate_index);
VA_DRM_GetDriverNames(VADriverContextP ctx, char **drivers, unsigned *num_drivers);

/**@}*/

Expand Down
Loading

0 comments on commit 1642615

Please sign in to comment.