From patchwork Thu Jan 4 21:33:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rostislav Pehlivanov X-Patchwork-Id: 7128 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.78.2 with SMTP id r2csp742721jaa; Thu, 4 Jan 2018 13:34:04 -0800 (PST) X-Google-Smtp-Source: ACJfBosvuFcRU9E8v1iFQOKKF1nNgt22gMY0cn5U36ewPDjI5Lgc+NXjWAReyjU3+eT9VvV1Ajzx X-Received: by 10.223.153.107 with SMTP id x98mr875232wrb.210.1515101644793; Thu, 04 Jan 2018 13:34:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515101644; cv=none; d=google.com; s=arc-20160816; b=w+zKz/wG9EI+IJiNYTwOKFO+9IxpaGLfMt0dtu77esO9rgmwCQCi+DhoKvAbntk818 DWELO1LEvJhSehJt347wFupIv5g7Bs2HdhK9JbXxtP06yk6op3+0ohIZCF/9SQlJnnPC 5yrWufPA5yC8e89bX1hKymmzVj78bKhNxPRF3+sonft2ZfhhlyWXLtHI3XrNc6EWUgUJ sndvG5BEtgKrmQawrzb1Pc2XSY+lg+u/EH+suJ7+ULG/J6zL5a2HvAfK5JiFaK1EPwMk 7zJfABQKeppNbZPmbRPmWeW4RKqWVpt6oc/8xbqqvSns6UrA1dEFKgVYjkl6xlEB6OPO G8UQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=njvREcTWXzAb97BxhtjmOoV2KFvbTCytpdkD8PyHMA0=; b=Hdg11PLEzudBPv0mco72E7UFmMhh8m7grXHgumg/Dc9VWe6f/vSNWL+BuqjXEHLjTA dMQHMtxzWoPBsoUynJk4PdQkkZh9hLd9IcgCkVegOpkCy2b6Q9ipvMvqGSO4G+L2MWmW I62BImfp4X9oxf2GtwtqKvZp67q9pBwCWUTHnX2aQ6wQmXGDlv9b8BOsCUuNQ/5pJzzv U6vNeAUXglz2JrYTa4kynKpa97JwC9GL4Fte/hU4gbsec0CvnHwNIFVQm9fNi11vnDE+ Aerh//7Mfnnq0EaE4q0d3RwZ+nKxvbBdZb31BknWhAV8KsWPc8dwB7xhBZxyHLy6pftJ uoNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=Xlsn8f9T; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id g75si2698801wme.166.2018.01.04.13.33.58; Thu, 04 Jan 2018 13:34:04 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=Xlsn8f9T; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 07C51688392; Thu, 4 Jan 2018 23:33:41 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr0-f194.google.com (mail-wr0-f194.google.com [209.85.128.194]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7558E68045D for ; Thu, 4 Jan 2018 23:33:34 +0200 (EET) Received: by mail-wr0-f194.google.com with SMTP id o15so2720600wrf.12 for ; Thu, 04 Jan 2018 13:33:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=MAfGJ7HaVOYJOFXOKdxfFwd69+nyHaGZtGOrTPP0ehk=; b=Xlsn8f9TXn9w/oDjZdfPDYJ3M/LdTSNKtSabTROlvZuq9uwlOKy/ShmgOTwHazOUNU cAIsG9n1nz2Epgva6hlmIn9ldaaOaft7gvZDuuEyPcTJtmP5z6YiB5RcxOiw9InMLwKg UsyvFtlWGN5SGYilps7rdflpsBN4ABZXdQDbCgRYelT2+GD2KDoXQNBoJfW6jfmtRYDY QIjs7bcIHRNPjhumVLUJ1potM1c3IzxoFqZpLLht8LnF8vM9Ts/gCc64fuwMRlhGlWPO esXVn5zuqiocfbu760l+vEOigc8uX2+Dp7lIEgKEeaVBbj3quFmgVVISbaYIJUzX4B/f 6qNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=MAfGJ7HaVOYJOFXOKdxfFwd69+nyHaGZtGOrTPP0ehk=; b=tnx9YIWKhGGDJ/tyIPseQ/uXjs1huiH9Wb4IovArUaVccw5dkf15suwz1BOj6XoeUp nr3pJNbEeILbI97O259GumUlBQ4/4msz/duxASeuarjPh3HZlxzfUUGyV8iRtla0DAyp 5GoqYyaD2Q/z8AZ92BK+ympSkFgNb2hnhM3FiK02OYz6zvlTbQdM5XkwPI+5zuKIoWVS CqB7sPvJIKocN6ucbBoFIXKxzowaVqLMxcphF5Al+vbzMPIMbrDXxV08TAB9Z+v8Ah1v 4lr0wM4dtECnLqP6lvDHZGrjSfKsIt18BxoF0PcSYdABeaDF+6nVKHTyhMZGvpXtDf2N E1UA== X-Gm-Message-State: AKGB3mK2x3qL0VaAqE5aPZFXVlHPwu0bVbezV5pBTx5o+aJh7HjYivS/ A+GyP8zshPeu0aFBaUinJlSdfAsE X-Received: by 10.223.147.39 with SMTP id 36mr871904wro.63.1515101630808; Thu, 04 Jan 2018 13:33:50 -0800 (PST) Received: from skyhide.pars.ee (host86-148-80-88.range86-148.btcentralplus.com. [86.148.80.88]) by smtp.gmail.com with ESMTPSA id j26sm2569545wre.55.2018.01.04.13.33.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Jan 2018 13:33:50 -0800 (PST) From: Rostislav Pehlivanov To: ffmpeg-devel@ffmpeg.org Date: Thu, 4 Jan 2018 21:33:48 +0000 Message-Id: <20180104213348.2341-1-atomnuker@gmail.com> X-Mailer: git-send-email 2.16.0.rc0.223.g4a4ac83678 In-Reply-To: References: Subject: [FFmpeg-devel] [PATCH v2] hwcontext_vaapi: implement auto connecting to a wayland display 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 Cc: Rostislav Pehlivanov MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Allows Wayland users to use vaapi without having to specify a vaapi drm device path. "wayland-0" is the default display name (like ":0") under Wayland, and given there's no way to get the display name from a connection, use it. Signed-off-by: Rostislav Pehlivanov --- configure | 6 +++++- libavutil/hwcontext_vaapi.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 1d2fffa132..1a785ce0af 100755 --- a/configure +++ b/configure @@ -2062,6 +2062,7 @@ SYSTEM_FUNCS=" SYSTEM_LIBRARIES=" vaapi_drm + vaapi_wayland vaapi_x11 vdpau_x11 wincrypt @@ -3347,7 +3348,7 @@ swscale_suggest="libm" avcodec_extralibs="pthreads_extralibs iconv_extralibs" avfilter_extralibs="pthreads_extralibs" -avutil_extralibs="d3d11va_extralibs nanosleep_extralibs pthreads_extralibs vaapi_drm_extralibs vaapi_x11_extralibs vdpau_x11_extralibs" +avutil_extralibs="d3d11va_extralibs nanosleep_extralibs pthreads_extralibs vaapi_drm_extralibs vaapi_x11_extralibs vaapi_wayland_extralibs vdpau_x11_extralibs" # programs ffmpeg_deps="avcodec avfilter avformat swresample" @@ -6162,6 +6163,9 @@ enabled vaapi && enabled vaapi && check_lib vaapi_x11 "va/va.h va/va_x11.h" vaGetDisplay -lva -lva-x11 -lX11 +enabled vaapi && + check_lib vaapi_wayland "va/va.h va/va_wayland.h" vaGetDisplayWl -lva -lva-wayland -lwayland-client + enabled vaapi && check_cpp_condition "va/va.h" "VA_CHECK_VERSION(1, 0, 0)" && enable vaapi_1 diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c index 29698d1b27..02437806ad 100644 --- a/libavutil/hwcontext_vaapi.c +++ b/libavutil/hwcontext_vaapi.c @@ -24,6 +24,9 @@ #if HAVE_VAAPI_DRM # include #endif +#if HAVE_VAAPI_WAYLAND +# include +#endif #if CONFIG_LIBDRM # include @@ -51,6 +54,9 @@ #endif typedef struct VAAPIDevicePriv { +#if HAVE_VAAPI_WAYLAND + struct wl_display *wayland_display; +#endif #if HAVE_VAAPI_X11 Display *x11_display; #endif @@ -1196,6 +1202,10 @@ static void vaapi_device_free(AVHWDeviceContext *ctx) if (hwctx->display) vaTerminate(hwctx->display); +#if HAVE_VAAPI_WAYLAND + if (priv->wayland_display) + wl_display_disconnect(priv->wayland_display); +#endif #if HAVE_VAAPI_X11 if (priv->x11_display) XCloseDisplay(priv->x11_display); @@ -1264,6 +1274,27 @@ static int vaapi_device_create(AVHWDeviceContext *ctx, const char *device, ctx->user_opaque = priv; ctx->free = vaapi_device_free; +#if HAVE_VAAPI_WAYLAND + if (!display && !(device && device[0] == '/')) { + const char *disp_name = display ? display : "wayland-0"; + priv->wayland_display = wl_display_connect(disp_name); + if (!priv->wayland_display) { + av_log(ctx, AV_LOG_VERBOSE, "Cannot connect to Wayland display " + "%s.\n", disp_name); + } else { + display = vaGetDisplayWl(priv->wayland_display); + if (!display) { + av_log(ctx, AV_LOG_ERROR, "Cannot open a VA display " + "from Wayland display %s.\n", disp_name); + return AVERROR_UNKNOWN; + } + + av_log(ctx, AV_LOG_VERBOSE, "Opened VA display via " + "Wayland display %s.\n", disp_name); + } + } +#endif + #if HAVE_VAAPI_X11 if (!display && !(device && device[0] == '/')) { // Try to open the device as an X11 display.