History

lavu/hwcontext_vaapi: Add option to allow to specify vendor id when init hw device

Vendor id will help to select desired device in case of kernel driver is unknow or unsupported, for vendor may support different kernel driver on different platforms.

Fei Wang committed 2 years ago

Commit dbd74ba1 parent c3902343 files · +38 −1Browse files

Unified · Split

3 files
  1. doc/ffmpeg.texi +8 −0
  2. libavutil/hwcontext_vaapi.c +29 −0
  3. libavutil/version.h +1 −1
doc/ffmpeg.texi+8−0
@@ -1458,6 +1458,11 @@ The following options are recognized: · 1457 unmodified lines
1458When @var{device} is not specified, use this option to specify the name of the kernel1458When @var{device} is not specified, use this option to specify the name of the kernel
1459driver associated with the desired device. This option is available only when1459driver associated with the desired device. This option is available only when
1460the hardware acceleration method @emph{drm} and @emph{vaapi} are enabled.1460the hardware acceleration method @emph{drm} and @emph{vaapi} are enabled.
1461@item vendor_id
1462When @var{device} and @var{kernel_driver} are not specified, use this option to specify
1463the vendor id associated with the desired device. This option is available only when the
1464hardware acceleration method @emph{drm} and @emph{vaapi} are enabled and @emph{kernel_driver}
1465is not specified.
1461@end table1466@end table
1462 1467
1463Examples:1468Examples:
@@ -1473,6 +1478,9 @@ Create a vaapi device on DirectX adapter 1. · 9 unmodified lines
1473 1478
1474@item -init_hw_device vaapi:,kernel_driver=i9151479@item -init_hw_device vaapi:,kernel_driver=i915
1475Create a vaapi device on a device associated with kernel driver @samp{i915}.1480Create a vaapi device on a device associated with kernel driver @samp{i915}.
1481
1482@item -init_hw_device vaapi:,vendor_id=0x8086
1483Create a vaapi device on a device associated with vendor id @samp{0x8086}.
1476@end table1484@end table
1477 1485
1478@item vdpau1486@item vdpau
libavutil/hwcontext_vaapi.c+29−0
@@ -1748,7 +1748,9 @@ static int vaapi_device_create(AVHWDeviceContext *ctx, const char *device, · 1747 unmodified lines
1748#if CONFIG_LIBDRM1748#if CONFIG_LIBDRM
1749 drmVersion *info;1749 drmVersion *info;
1750 const AVDictionaryEntry *kernel_driver;1750 const AVDictionaryEntry *kernel_driver;
1751 const AVDictionaryEntry *vendor_id;
1751 kernel_driver = av_dict_get(opts, "kernel_driver", NULL, 0);1752 kernel_driver = av_dict_get(opts, "kernel_driver", NULL, 0);
1753 vendor_id = av_dict_get(opts, "vendor_id", NULL, 0);
1752#endif1754#endif
1753 for (n = 0; n < max_devices; n++) {1755 for (n = 0; n < max_devices; n++) {
1754 snprintf(path, sizeof(path),1756 snprintf(path, sizeof(path),
@@ -1803,6 +1805,33 @@ static int vaapi_device_create(AVHWDeviceContext *ctx, const char *device, · 48 unmodified lines
1803 close(priv->drm_fd);1805 close(priv->drm_fd);
1804 priv->drm_fd = -1;1806 priv->drm_fd = -1;
1805 continue;1807 continue;
1808 } else if (vendor_id) {
1809 drmDevicePtr device;
1810 char drm_vendor[8];
1811 if (drmGetDevice(priv->drm_fd, &device)) {
1812 av_log(ctx, AV_LOG_VERBOSE,
1813 "Failed to get DRM device info for device %d.\n", n);
1814 close(priv->drm_fd);
1815 priv->drm_fd = -1;
1816 continue;
1817 }
1818
1819 snprintf(drm_vendor, sizeof(drm_vendor), "0x%x", device->deviceinfo.pci->vendor_id);
1820 if (strcmp(vendor_id->value, drm_vendor)) {
1821 av_log(ctx, AV_LOG_VERBOSE, "Ignoring device %d "
1822 "with non-matching vendor id (%s).\n",
1823 n, vendor_id->value);
1824 drmFreeDevice(&device);
1825 close(priv->drm_fd);
1826 priv->drm_fd = -1;
1827 continue;
1828 }
1829 av_log(ctx, AV_LOG_VERBOSE, "Trying to use "
1830 "DRM render node for device %d, "
1831 "with matching vendor id (%s).\n",
1832 n, vendor_id->value);
1833 drmFreeDevice(&device);
1834 break;
1806 }1835 }
1807 drmFreeVersion(info);1836 drmFreeVersion(info);
1808#endif1837#endif
libavutil/version.h+1−1
@@ -79,7 +79,7 @@ · 78 unmodified lines
79 */79 */
80 80
81#define LIBAVUTIL_VERSION_MAJOR 5981#define LIBAVUTIL_VERSION_MAJOR 59
82#define LIBAVUTIL_VERSION_MINOR 3282#define LIBAVUTIL_VERSION_MINOR 33
83#define LIBAVUTIL_VERSION_MICRO 10083#define LIBAVUTIL_VERSION_MICRO 100
84 84
85#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \85#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t