From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 8B990449DE for ; Mon, 5 Dec 2022 22:40:58 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9C0C268BD03; Tue, 6 Dec 2022 00:40:55 +0200 (EET) Received: from mail-pg1-f181.google.com (mail-pg1-f181.google.com [209.85.215.181]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CFFCA68A708 for ; Tue, 6 Dec 2022 00:40:49 +0200 (EET) Received: by mail-pg1-f181.google.com with SMTP id h33so11743399pgm.9 for ; Mon, 05 Dec 2022 14:40:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=AbgvcDmE2GiiwZwJgIieocGT71bmPpqNlxXFHo9Rl/s=; b=bG/IaGkJig0DY/ywaR0sjw/TDa/dB1flsonn9utiiNYXO/qE4Xml1IFM02sVy90Gn4 Ykip2uqSmmiWNrsts1jeeCJCQNelGOO5+M9GvkrC8Ii4ahR6/M1Aha3WhVMO7Snny0fA 6tsYEXqF8d5eZxSvSAqMTixtvCbiMOsL9fzok= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=AbgvcDmE2GiiwZwJgIieocGT71bmPpqNlxXFHo9Rl/s=; b=28jwhyFeqlWEVcRFr8DJV69SC4Wb0Wvx0DlNgFlagmVrrz76juzCbnRp+pqsoTm0w2 MMs+4hTdJAwanyC5r1eM3l6O3DhWUNTfi5fTFcHYVY/CC5to3zZxEJ53a9fJtZ5CrodJ z3kbyA/lWnPPwtcCmJoi0Uzf1pLjF5Wa1eGijZy9M38aXZF3UdHEuyGD0V3MHmHSrF4O TDYoHVdNUZCXk+3coyFLEDexVMC+JlSlbAlJtjGFRu71CliMxWqn5ThpXfcRL8GCG1xl g7Ss9tSheMw+c6I4Qa/U+Tnf8cJ1jd4zNKTmNhExUWoI00bP5X1egpoT3RR/TUxLKGtR N1oA== X-Gm-Message-State: ANoB5pmr5ZGH5/qqDH7Y3vUoKGHjkEmJlZJqJUgbGKGgPDpUAXoEH3KU 2fIUunq9GOrx2CaFZMYAbInlTmRmFhPQNJCI X-Google-Smtp-Source: AA0mqf6AYDC6aLxDp4IC5wz1oDuNffyIT/8PUI4mMMBaqE1cp/Xzqc6xGyS+qoVV/6YzN/pWqFDrWw== X-Received: by 2002:a63:e44b:0:b0:476:f69c:2304 with SMTP id i11-20020a63e44b000000b00476f69c2304mr79500843pgk.77.1670280047654; Mon, 05 Dec 2022 14:40:47 -0800 (PST) Received: from localhost ([2620:15c:9d:2:9b83:ae6f:f47b:bb4d]) by smtp.gmail.com with UTF8SMTPSA id w10-20020a170902e88a00b00186b0ac12c5sm11086603plg.172.2022.12.05.14.40.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 05 Dec 2022 14:40:47 -0800 (PST) From: Brian Norris To: ffmpeg-devel@ffmpeg.org Date: Mon, 5 Dec 2022 14:33:21 -0800 Message-Id: <20221205143317.v2.1.I9025996c33e0a4fe6133de948af3f3e75c214475@changeid> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2] lavu/hwcontext_vaapi: Skip 'vgem' driver X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Cc: Haihao Xiang , Brian Norris Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: There can be more than one available render node, and it's not guaranteed the first node we come across is the correct one. In particular, 'vgem' devices are common, and are never VAAPI-enabled and thus not valid here. We have a 'kernel_driver' arg already for specifying a single driver we *do* want, but it doesn't support a negation, nor a list. It's easier just to automatically skip 'vgem' anyway, to avoid foisting this burden on users. This has precedent in libva-utils already: bfb6b98ed62a exclude vgem node and invalid drm node in vainfo https://github.com/intel/libva-utils/commit/bfb6b98ed62ac14a840ba62639ab902a23912258 Signed-off-by: Brian Norris --- Changes in v2: - strncmp() -> strcmp() libavutil/hwcontext_vaapi.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c index 4bcde74f6212..938bd5447d5e 100644 --- a/libavutil/hwcontext_vaapi.c +++ b/libavutil/hwcontext_vaapi.c @@ -1700,6 +1700,7 @@ static int vaapi_device_create(AVHWDeviceContext *ctx, const char *device, char path[64]; int n, max_devices = 8; #if CONFIG_LIBDRM + drmVersion *info; const AVDictionaryEntry *kernel_driver; kernel_driver = av_dict_get(opts, "kernel_driver", NULL, 0); #endif @@ -1713,9 +1714,15 @@ static int vaapi_device_create(AVHWDeviceContext *ctx, const char *device, break; } #if CONFIG_LIBDRM + info = drmGetVersion(priv->drm_fd); + if (!info) { + av_log(ctx, AV_LOG_VERBOSE, + "Failed to get DRM version for device %d.\n", n); + close(priv->drm_fd); + priv->drm_fd = -1; + continue; + } if (kernel_driver) { - drmVersion *info; - info = drmGetVersion(priv->drm_fd); if (strcmp(kernel_driver->value, info->name)) { av_log(ctx, AV_LOG_VERBOSE, "Ignoring device %d " "with non-matching kernel driver (%s).\n", @@ -1730,12 +1737,20 @@ static int vaapi_device_create(AVHWDeviceContext *ctx, const char *device, "with matching kernel driver (%s).\n", n, info->name); drmFreeVersion(info); - } else -#endif - { - av_log(ctx, AV_LOG_VERBOSE, "Trying to use " - "DRM render node for device %d.\n", n); + break; + // drmGetVersion() ensures |info->name| is 0-terminated. + } else if (!strcmp(info->name, "vgem")) { + av_log(ctx, AV_LOG_VERBOSE, + "Skipping vgem node for device %d.\n", n); + drmFreeVersion(info); + close(priv->drm_fd); + priv->drm_fd = -1; + continue; } + drmFreeVersion(info); +#endif + av_log(ctx, AV_LOG_VERBOSE, "Trying to use " + "DRM render node for device %d.\n", n); break; } if (n >= max_devices) -- 2.39.0.rc0.267.gcb52ba06e7-goog _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".