Tries to find a device backed by the i915 kernel driver and loads the iHD VAAPI driver to use with it. This reduces confusion on machines with multiple DRM devices and removes the surprising requirement to set the LIBVA_DRIVER_NAME environment variable to use libmfx at all.
Unified · Split
| @@ -1206,6 +1206,7 @@ static int qsv_device_create(AVHWDeviceContext *ctx, const char *device, · 1205 unmodified lines | ||
| 1206 | 1206 | QSVDevicePriv *priv; |
| 1207 | 1207 | enum AVHWDeviceType child_device_type; |
| 1208 | 1208 | AVHWDeviceContext *child_device; |
| 1209 | + AVDictionary *child_device_opts; | |
| 1209 | 1210 | AVDictionaryEntry *e; |
| 1210 | 1211 | |
| 1211 | 1212 | mfxIMPL impl; |
| @@ -1220,9 +1221,17 @@ static int qsv_device_create(AVHWDeviceContext *ctx, const char *device, · 8 unmodified lines | ||
| 1220 | 1221 | |
| 1221 | 1222 | e = av_dict_get(opts, "child_device", NULL, 0); |
| 1222 | 1223 | |
| 1223 | − if (CONFIG_VAAPI) | |
| 1224 | + child_device_opts = NULL; | |
| 1225 | + if (CONFIG_VAAPI) { | |
| 1224 | 1226 | child_device_type = AV_HWDEVICE_TYPE_VAAPI; |
| 1225 | − else if (CONFIG_DXVA2) | |
| 1227 | + // libmfx does not actually implement VAAPI properly, rather it | |
| 1228 | + // depends on the specific behaviour of a matching iHD driver when | |
| 1229 | + // used on recent Intel hardware. Set options to the VAAPI device | |
| 1230 | + // creation so that we should pick a usable setup by default if | |
| 1231 | + // possible, even when multiple devices and drivers are available. | |
| 1232 | + av_dict_set(&child_device_opts, "kernel_driver", "i915", 0); | |
| 1233 | + av_dict_set(&child_device_opts, "driver", "iHD", 0); | |
| 1234 | + } else if (CONFIG_DXVA2) | |
| 1226 | 1235 | child_device_type = AV_HWDEVICE_TYPE_DXVA2; |
| 1227 | 1236 | else { |
| 1228 | 1237 | av_log(ctx, AV_LOG_ERROR, "No supported child device type is enabled\n"); |
| @@ -1230,7 +1239,7 @@ static int qsv_device_create(AVHWDeviceContext *ctx, const char *device, · 1 unmodified line | ||
| 1230 | 1239 | } |
| 1231 | 1240 | |
| 1232 | 1241 | ret = av_hwdevice_ctx_create(&priv->child_device_ctx, child_device_type, |
| 1233 | − e ? e->value : NULL, NULL, 0); | |
| 1242 | + e ? e->value : NULL, child_device_opts, 0); | |
| 1234 | 1243 | if (ret < 0) |
| 1235 | 1244 | return ret; |
| 1236 | 1245 | |