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 BE81444022 for ; Wed, 23 Nov 2022 21:54:59 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3B63068B6A0; Wed, 23 Nov 2022 23:54:57 +0200 (EET) Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D68E868AF85 for ; Wed, 23 Nov 2022 23:54:50 +0200 (EET) Received: by mail-pj1-f43.google.com with SMTP id w15-20020a17090a380f00b0021873113cb4so3036766pjb.0 for ; Wed, 23 Nov 2022 13:54:50 -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=OxIbeSzbQy0flJ5IFIdI8ouC+tzM3pnKpD2kDp+dGBU=; b=RRL5Y7EuSynE+/Q4IA84wcYBGlXe6mRGry6nG9hF+mE8LUE7idKVF8AAu4Bp0RutvS FLbUPWkA4bL0gGESMIY1wj9hVqVNXVtnN+nks/5iEEjaIerBMOiDeITHH7jAAhB6X4Oa 0ADc5cWCW9mESt3vfuummBWWaXhi/qcR+tUwQ= 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=OxIbeSzbQy0flJ5IFIdI8ouC+tzM3pnKpD2kDp+dGBU=; b=dxMUaTL44dvGzmofCCsY+4dhOItHPbESQIjj7Qn7jpHO3kxdY+yVvnFYxNt29Q5eb5 qmx0tWB2JDAfllsbSx7jizf4myfBXxgUmBQ/qj98NB+Zx3tXq0Gq6AMyygKOvfEzeqj/ 25jYDZCzqcbGuY65mML7lGooVvQlFggSRfhXR14NvH4RhgFGXNwRDTTZUEJIvX9FcuBC b9o3UMUYo2O7ZPTGUXFDuUZKNBahxWz7HlgYTOJLvhX72vt1qZRGuC2ewbZpUKfiXBNu 6bDLBs9ol9JAbwUNX9lmSqP6UQ5AFIcxdnaGQHhylRooXC/bfFjhEq9u7zUcdKenJA2/ Exuw== X-Gm-Message-State: ANoB5pkkgrkuhfqF9b8ByJEfY2edlj2yf33Fj5ick/RUF58fiCawgHHb /cOqfgfTS+AOx18WQnT5WR5Ua2um43O2lQ== X-Google-Smtp-Source: AA0mqf6ViOc+oeiCCACdBp6SkTHCfjhH50Z+GzlR8ZAwYZdNJwzfdWQ0sK8ShUh5mtldMXDUqe+cFg== X-Received: by 2002:a17:903:300c:b0:17c:b7ac:86f with SMTP id o12-20020a170903300c00b0017cb7ac086fmr10827830pla.140.1669240488562; Wed, 23 Nov 2022 13:54:48 -0800 (PST) Received: from localhost ([2620:15c:9d:2:398f:3ae8:aee3:41c4]) by smtp.gmail.com with UTF8SMTPSA id x9-20020aa79409000000b005623f96c24bsm13177959pfo.89.2022.11.23.13.54.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 23 Nov 2022 13:54:48 -0800 (PST) From: Brian Norris To: ffmpeg-devel@ffmpeg.org Date: Wed, 23 Nov 2022 13:54:44 -0800 Message-Id: <20221123215444.1754721-1-briannorris@chromium.org> X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] 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: 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 --- libavutil/hwcontext_vaapi.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c index 4bcde74f6212..84b03b633251 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,19 @@ 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; + } else if (!strncmp(info->name, "vgem", 4)) { + 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.38.1.584.g0f3c55d4c2-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".