From f1ab146eda953dcfba215dfd80ea895a6a406bc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Zatloukal?= Date: Tue, 14 Apr 2020 16:02:58 +0200 Subject: [PATCH] Forgot to add patch for previous commit --- 406.patch | 255 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 255 insertions(+) create mode 100644 406.patch diff --git a/406.patch b/406.patch new file mode 100644 index 0000000..de1b29a --- /dev/null +++ b/406.patch @@ -0,0 +1,255 @@ +From 98fbb3aa53be8201ccc82508d37a8b0109f9042b Mon Sep 17 00:00:00 2001 +From: "U. Artie Eoff" +Date: Mon, 13 Apr 2020 12:22:06 -0700 +Subject: [PATCH 1/2] VA/X11: enable driver candidate selection for DRI2 + +Map the i965 DRI driver to iHD and i965 vaapi +driver candidates. + +Signed-off-by: U. Artie Eoff +--- + va/x11/va_x11.c | 126 ++++++++++++++++++++++++++++++++++++++++++------ + 1 file changed, 112 insertions(+), 14 deletions(-) + +diff --git a/va/x11/va_x11.c b/va/x11/va_x11.c +index c40c8c4d..3b88a624 100644 +--- a/va/x11/va_x11.c ++++ b/va/x11/va_x11.c +@@ -44,6 +44,18 @@ + #include + #include + ++struct driver_name_map { ++ const char *key; ++ int key_len; ++ const char *name; ++}; ++ ++static const struct driver_name_map g_dri2_driver_name_map[] = { ++ { "i965", 4, "iHD" }, // Intel iHD VAAPI driver with i965 DRI driver ++ { "i965", 4, "i965" }, // Intel i965 VAAPI driver with i965 DRI driver ++ { NULL, 0, NULL } ++}; ++ + static int va_DisplayContextIsValid ( + VADisplayContextP pDisplayContext + ) +@@ -73,29 +85,93 @@ static void va_DisplayContextDestroy ( + free(pDisplayContext); + } + ++static VAStatus va_DRI2_GetNumCandidates ( ++ VADisplayContextP pDisplayContext, ++ int *num_candidates ++) ++{ ++ char *driver_name = NULL; ++ const struct driver_name_map *m = NULL; ++ VADriverContextP ctx = pDisplayContext->pDriverContext; ++ ++ *num_candidates = 0; ++ ++ if (!(va_isDRI2Connected(ctx, &driver_name) && driver_name)) ++ return VA_STATUS_ERROR_UNKNOWN; ++ ++ for (m = g_dri2_driver_name_map; m->key != NULL; m++) { ++ if (strlen(driver_name) >= m->key_len && ++ strncmp(driver_name, m->key, m->key_len) == 0) { ++ (*num_candidates)++; ++ } ++ } ++ ++ free(driver_name); ++ ++ /* ++ * If the dri2 driver name does not have a mapped vaapi driver name, then ++ * assume they have the same name. ++ */ ++ if (*num_candidates == 0) ++ *num_candidates = 1; + +-static VAStatus va_DRI2GetDriverName ( ++ return VA_STATUS_SUCCESS; ++} ++ ++static VAStatus va_DRI2_GetDriverName ( + VADisplayContextP pDisplayContext, +- char **driver_name ++ char **driver_name_ptr, ++ int candidate_index + ) + { ++ const struct driver_name_map *m = NULL; ++ int current_index = 0; + VADriverContextP ctx = pDisplayContext->pDriverContext; + +- if (!va_isDRI2Connected(ctx, driver_name)) ++ *driver_name_ptr = NULL; ++ ++ if (!(va_isDRI2Connected(ctx, driver_name_ptr) && *driver_name_ptr)) + return VA_STATUS_ERROR_UNKNOWN; + ++ for (m = g_dri2_driver_name_map; m->key != NULL; m++) { ++ if (strlen(*driver_name_ptr) >= m->key_len && ++ strncmp(*driver_name_ptr, m->key, m->key_len) == 0) { ++ if (current_index == candidate_index) { ++ break; ++ } ++ current_index++; ++ } ++ } ++ ++ /* ++ * If the dri2 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; ++ + return VA_STATUS_SUCCESS; + } + + static VAStatus va_NVCTRL_GetDriverName ( + VADisplayContextP pDisplayContext, +- char **driver_name ++ char **driver_name, ++ int candidate_index + ) + { + VADriverContextP ctx = pDisplayContext->pDriverContext; + int direct_capable, driver_major, driver_minor, driver_patch; + Bool result; + ++ if (candidate_index != 0) ++ return VA_STATUS_ERROR_INVALID_PARAMETER; ++ + result = VA_NVCTRLQueryDirectRenderingCapable(ctx->native_dpy, ctx->x11_screen, + &direct_capable); + if (!result || !direct_capable) +@@ -112,13 +188,17 @@ static VAStatus va_NVCTRL_GetDriverName ( + + static VAStatus va_FGLRX_GetDriverName ( + VADisplayContextP pDisplayContext, +- char **driver_name ++ char **driver_name, ++ int candidate_index + ) + { + VADriverContextP ctx = pDisplayContext->pDriverContext; + int driver_major, driver_minor, driver_patch; + Bool result; + ++ if (candidate_index != 0) ++ return VA_STATUS_ERROR_INVALID_PARAMETER; ++ + result = VA_FGLRXGetClientDriverName(ctx->native_dpy, ctx->x11_screen, + &driver_major, &driver_minor, + &driver_patch, driver_name); +@@ -130,24 +210,43 @@ static VAStatus va_FGLRX_GetDriverName ( + + static VAStatus va_DisplayContextGetDriverName ( + VADisplayContextP pDisplayContext, +- char **driver_name ++ char **driver_name, int candidate_index + ) + { + VAStatus vaStatus; + + if (driver_name) +- *driver_name = NULL; ++ *driver_name = NULL; + else + return VA_STATUS_ERROR_UNKNOWN; +- +- vaStatus = va_DRI2GetDriverName(pDisplayContext, driver_name); ++ ++ vaStatus = va_DRI2_GetDriverName(pDisplayContext, driver_name, candidate_index); + if (vaStatus != VA_STATUS_SUCCESS) +- vaStatus = va_NVCTRL_GetDriverName(pDisplayContext, driver_name); ++ vaStatus = va_NVCTRL_GetDriverName(pDisplayContext, driver_name, candidate_index); + if (vaStatus != VA_STATUS_SUCCESS) +- vaStatus = va_FGLRX_GetDriverName(pDisplayContext, driver_name); ++ vaStatus = va_FGLRX_GetDriverName(pDisplayContext, driver_name, candidate_index); ++ + return vaStatus; + } + ++static VAStatus va_DisplayContextGetNumCandidates ( ++ VADisplayContextP pDisplayContext, ++ int *num_candidates ++) ++{ ++ VAStatus vaStatus; ++ ++ vaStatus = va_DRI2_GetNumCandidates(pDisplayContext, num_candidates); ++ ++ /* A call to va_DisplayContextGetDriverName will fallback to other ++ * methods (i.e. NVCTRL, FGLRX) when DRI2 is unsuccessful. All of those ++ * fallbacks only have 1 candidate driver. ++ */ ++ if (vaStatus != VA_STATUS_SUCCESS) ++ *num_candidates = 1; ++ ++ return VA_STATUS_SUCCESS; ++} + + VADisplay vaGetDisplay ( + Display *native_dpy /* implementation specific */ +@@ -166,7 +265,8 @@ VADisplay vaGetDisplay ( + + pDisplayContext->vaIsValid = va_DisplayContextIsValid; + pDisplayContext->vaDestroy = va_DisplayContextDestroy; +- pDisplayContext->vaGetDriverName = va_DisplayContextGetDriverName; ++ pDisplayContext->vaGetNumCandidates = va_DisplayContextGetNumCandidates; ++ pDisplayContext->vaGetDriverNameByIndex = va_DisplayContextGetDriverName; + + pDriverContext = va_newDriverContext(pDisplayContext); + if (!pDriverContext) { +@@ -190,7 +290,6 @@ VADisplay vaGetDisplay ( + return (VADisplay)pDisplayContext; + } + +- + void va_TracePutSurface ( + VADisplay dpy, + VASurfaceID surface, +@@ -208,7 +307,6 @@ void va_TracePutSurface ( + unsigned int flags /* de-interlacing flags */ + ); + +- + VAStatus vaPutSurface ( + VADisplay dpy, + VASurfaceID surface, + +From 253e1b90cdd791524f06f25e08d0be5a3098d5e4 Mon Sep 17 00:00:00 2001 +From: "U. Artie Eoff" +Date: Mon, 13 Apr 2020 12:39:45 -0700 +Subject: [PATCH 2/2] VA/X11: VAAPI driver mapping for iris DRI driver + +Fixes #396 + +Signed-off-by: U. Artie Eoff +--- + va/x11/va_x11.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/va/x11/va_x11.c b/va/x11/va_x11.c +index 3b88a624..cb231681 100644 +--- a/va/x11/va_x11.c ++++ b/va/x11/va_x11.c +@@ -53,6 +53,8 @@ struct driver_name_map { + static const struct driver_name_map g_dri2_driver_name_map[] = { + { "i965", 4, "iHD" }, // Intel iHD VAAPI driver with i965 DRI driver + { "i965", 4, "i965" }, // Intel i965 VAAPI driver with i965 DRI driver ++ { "iris", 4, "iHD" }, // Intel iHD VAAPI driver with iris DRI driver ++ { "iris", 4, "i965" }, // Intel i965 VAAPI driver with iris DRI driver + { NULL, 0, NULL } + }; +