Advertisement
Guest User

Untitled

a guest
Oct 1st, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. From 3254eef4558651697804ef675d89d5dc69dea9d2 Mon Sep 17 00:00:00 2001
  2. From: Bernhard Frauendienst <git@nospam.obeliks.de>
  3. Date: Sat, 1 Oct 2016 17:44:13 +0200
  4. Subject: [PATCH] Support drm devices for probing auto-copy hwdecs
  5.  
  6. ---
  7. video/decode/vaapi.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++
  8. 1 file changed, 56 insertions(+)
  9.  
  10. diff --git a/video/decode/vaapi.c b/video/decode/vaapi.c
  11. index aa8291d..5080850 100644
  12. --- a/video/decode/vaapi.c
  13. +++ b/video/decode/vaapi.c
  14. @@ -99,7 +99,63 @@ static const struct va_native_display disp_x11 = {
  15. };
  16. #endif
  17.  
  18. +#if HAVE_VAAPI_DRM
  19. +#include <unistd.h>
  20. +#include <fcntl.h>
  21. +#include <va/va_drm.h>
  22. +
  23. +struct va_native_display_drm {
  24. + int drm_fd;
  25. +};
  26. +
  27. +static void drm_destroy(struct priv *p)
  28. +{
  29. + struct va_native_display_drm *native_display;
  30. + if (p->native_display) {
  31. + native_display = p->native_display;
  32. + if (native_display->drm_fd < 0)
  33. + close(native_display->drm_fd);
  34. + talloc_free(native_display);
  35. + p->native_display = NULL;
  36. + }
  37. +}
  38. +
  39. +static void drm_create(struct priv *p)
  40. +{
  41. + int i, drm_fd;
  42. +
  43. + static const char *drm_device_paths[] = {
  44. + "/dev/dri/renderD128",
  45. + "/dev/dri/card0",
  46. + NULL
  47. + };
  48. +
  49. + for (i = 0; drm_device_paths[i]; i++) {
  50. + drm_fd = open(drm_device_paths[i], O_RDWR);
  51. + if (drm_fd < 0)
  52. + continue;
  53. +
  54. + struct va_native_display_drm *native_display = talloc_ptrtype(NULL, native_display);
  55. + native_display->drm_fd = drm_fd;
  56. + p->native_display = native_display;
  57. + p->display = vaGetDisplayDRM(drm_fd);
  58. + if (p->display)
  59. + return;
  60. +
  61. + drm_destroy(p);
  62. + }
  63. +}
  64. +
  65. +static const struct va_native_display disp_drm = {
  66. + .create = drm_create,
  67. + .destroy = drm_destroy,
  68. +};
  69. +#endif
  70. +
  71. static const struct va_native_display *const native_displays[] = {
  72. +#if HAVE_VAAPI_DRM
  73. + &disp_drm,
  74. +#endif
  75. #if HAVE_VAAPI_X11
  76. &disp_x11,
  77. #endif
  78. --
  79. 2.10.0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement