From patchwork Mon May 6 14:49:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Thompson X-Patchwork-Id: 13010 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 7FC304482AD for ; Mon, 6 May 2019 17:49:44 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5ED9268AD60; Mon, 6 May 2019 17:49:44 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AB24968AD5C for ; Mon, 6 May 2019 17:49:38 +0300 (EEST) Received: by mail-wr1-f68.google.com with SMTP id f7so7317843wrq.1 for ; Mon, 06 May 2019 07:49:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jkqxz-net.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=uUFv59se0M4lTnBICMta5tE9+t3Q86eU4lWWc0ep0fg=; b=ihzSvaWg1NHeEzgvwzSVKcV4L3tDDcepuc0aFMPQk+O07xfVPxHwvO/6HgnwjIEkbK XB1R+eOVYbu+nDS45gF8IAp1V/KVuiSsMzI/C3UST7p02O64u0LrfU+R0Y+HY5JxumsL gTuI/2r2JoMiM7Z+WrCemsx6KKpFGyR9ZAhRKf1+KzcmdYu4DFXBQCOFEOuXHb1/kzKv E1jzr2okQafjFg2+W4dOJ9O4K6QEddOxAvK0mpuzBhwHMFaUkpQJS3kIlowJHnpIWsYW ChusCLoQN6ZlCSlYxxV9o/lkurScvzOBfCMK8pz0mw9dvcgX22h5zCkVzBScDqRFq8S0 sFLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uUFv59se0M4lTnBICMta5tE9+t3Q86eU4lWWc0ep0fg=; b=mEjoCim0xkiy7Qk2IZpOe3bKdrhYULFsSbCGXfowHQw2Y1cmrLy7gfLS9rcnNAzbmN q6ttVJZaRmBtC57sN7O02uhUfW4KGG1IxpXaYuwy6ljh749T15St5BKz4xj20LtFwDfy lFvprZ+QJ3IaO1bylrcgnuIbpBx8trK/l7g3QYUVUlymLIAD6bwb5HINziW0m2/ZDL6D 4a8ch0h5zBhgTjb5COC4nlwwjYe/lWRHxa2+m2NQnymo94LYmjS2/ED+AI4e2HWiVT+c oFYuben7ScNbibQRfWEQkjaqYsGkj4/RYJMciBH3Sc9FLvwxQiM6/7mo7aXkJtJxKy1f wAaA== X-Gm-Message-State: APjAAAWWDRd7czi+jKJVlLV09NpRMNidl8nDyfguqwo6V8o5vW34JfaH IIyFX5Bag+1W0ftljmE4L1q5gKCjhhk= X-Google-Smtp-Source: APXvYqw64cWrzOgPJtuGtljt7W+ZE+D1eCV2GUffeJrDZxcsEyaMY8d+dzf+2I6K3O5i8dtTEAGm3g== X-Received: by 2002:adf:ef43:: with SMTP id c3mr19497162wrp.141.1557154177905; Mon, 06 May 2019 07:49:37 -0700 (PDT) Received: from rywe.jkqxz.net (cpc91242-cmbg18-2-0-cust650.5-4.cable.virginm.net. [82.8.130.139]) by smtp.gmail.com with ESMTPSA id l19sm14691742wrg.29.2019.05.06.07.49.36 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 May 2019 07:49:36 -0700 (PDT) From: Mark Thompson To: ffmpeg-devel@ffmpeg.org Date: Mon, 6 May 2019 15:49:27 +0100 Message-Id: <20190506144928.28501-7-sw@jkqxz.net> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190506144928.28501-1-sw@jkqxz.net> References: <20190506144928.28501-1-sw@jkqxz.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 7/7] hwcontext_qsv: Try to select a matching VAAPI device by default X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" 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. --- libavutil/hwcontext_qsv.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c index 49b5952cef..59e4ed9157 100644 --- a/libavutil/hwcontext_qsv.c +++ b/libavutil/hwcontext_qsv.c @@ -1206,6 +1206,7 @@ static int qsv_device_create(AVHWDeviceContext *ctx, const char *device, QSVDevicePriv *priv; enum AVHWDeviceType child_device_type; AVHWDeviceContext *child_device; + AVDictionary *child_device_opts; AVDictionaryEntry *e; mfxIMPL impl; @@ -1220,9 +1221,17 @@ static int qsv_device_create(AVHWDeviceContext *ctx, const char *device, e = av_dict_get(opts, "child_device", NULL, 0); - if (CONFIG_VAAPI) + child_device_opts = NULL; + if (CONFIG_VAAPI) { child_device_type = AV_HWDEVICE_TYPE_VAAPI; - else if (CONFIG_DXVA2) + // libmfx does not actually implement VAAPI properly, rather it + // depends on the specific behaviour of a matching iHD driver when + // used on recent Intel hardware. Set options to the VAAPI device + // creation so that we should pick a usable setup by default if + // possible, even when multiple devices and drivers are available. + av_dict_set(&child_device_opts, "kernel_driver", "i915", 0); + av_dict_set(&child_device_opts, "driver", "iHD", 0); + } else if (CONFIG_DXVA2) child_device_type = AV_HWDEVICE_TYPE_DXVA2; else { 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, } ret = av_hwdevice_ctx_create(&priv->child_device_ctx, child_device_type, - e ? e->value : NULL, NULL, 0); + e ? e->value : NULL, child_device_opts, 0); if (ret < 0) return ret;