From mboxrd@z Thu Jan 1 00:00:00 1970 From: taylanbayirli@gmail.com (Taylan Ulrich =?utf-8?Q?Bay=C4=B1rl=C4=B1?= =?utf-8?Q?=2FKammer?=) Subject: Re: [PATCH] gnu: mesa: Add libva input. Date: Tue, 28 Apr 2015 22:21:25 +0200 Message-ID: <87r3r4dmwq.fsf@taylan.uni.cx> References: <87zj5se6o0.fsf@taylan.uni.cx> <87383kbah1.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:41822) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YnC0Z-00052B-2F for guix-devel@gnu.org; Tue, 28 Apr 2015 16:21:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YnC0W-00067v-TR for guix-devel@gnu.org; Tue, 28 Apr 2015 16:21:30 -0400 Received: from mail-wi0-x22b.google.com ([2a00:1450:400c:c05::22b]:36016) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YnC0W-00067d-Hv for guix-devel@gnu.org; Tue, 28 Apr 2015 16:21:28 -0400 Received: by wizk4 with SMTP id k4so155083209wiz.1 for ; Tue, 28 Apr 2015 13:21:27 -0700 (PDT) In-Reply-To: <87383kbah1.fsf@gmail.com> (=?utf-8?B?IuWui+aWh+atpiIncw==?= message of "Tue, 28 Apr 2015 22:20:42 +0800") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: =?utf-8?B?5a6L5paH5q2m?= Cc: guix-devel@gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable =E5=AE=8B=E6=96=87=E6=AD=A6 writes: > Look good to me, but how does it work? > According to archlinux, it will build 'gallium_drv_video.so', > described as VA-API implementation for gallium. > IIUC, libva may dlopen this gallium_drv_video.so? I had to tinker and research for several hours to be able to answer your question, but good thing you asked. :-) Firstly: I grepped the libva sources for 'dlopen' and found three places it's used: - to open libatiadlxx.so, which AFAIUI is a proprietary ATI driver which we wouldn't support anyway, - to open libva-x11.so, which it installs in $prefix/lib; I patched the .c file to use the absolute path to this .so, and - to open drivers found in $LIBVA_DRIVERS_PATH, falling back to the CPP macro VA_DRIVERS_PATH, which should both contain absolute directory names so it's fine. Secondly: The default value for VA_DRIVERS_PATH is $prefix/lib/dri (where $prefix is that of libva), which contains only some dummy driver installed by libva; most drivers are instead in $mesa_prefix/lib/dri. So it's probably best to set VA_DRIVERS_PATH to $mesa_prefix/lib/dri. So I added --with-drivers-path to libva's configure flags (plus added a make flag to solve a certain problem; see patch). By the way: If a package wants to use libva with a driver that doesn't come with mesa, then they will have to set LIBVA_DRIVERS_PATH. A user may also add ~/.guix-profile/lib/dri to LIBVA_DRIVERS_PATH, and install any number of packages installing graphics drivers there. Thirdly, and I can finally answer your question: Comes out "gallium_drv_video.so", found in Arch's "libva-mesa" package, is actually Mesa's Gallium-based implementation of VA API, alternative to stock libva. (Arch also has a regular libva package, containing the real libva.) The gallium_drv_video.so driver is installed in mesa's $prefix/lib/dri when building it is enabled, so all is fine. Also, Mesa needs libva's header files for building it, and this actually seems to be the sole reason Mesa depends on libva. I considered making a "libva-headers" package (like the mesa-headers package), but Mesa uses pkg-config to test libva's presence so I'm not sure if that would work, and libva is small anyway so building it twice should be OK. Based on all that, here's a patch that applies *before* the one adding libva to mesa, and then a fixed version of the patch adding libva to mesa; notably I put the libva-without-mesa package into video.scm because I was getting circular import problems: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0002-gnu-libva-Patch-a-dlopen-call-set-drivers-path.patch >From 51e9e9d0510fc86278a7bd125366a765a10c365a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Taylan=20Ulrich=20Bay=C4=B1rl=C4=B1/Kammer?= Date: Tue, 28 Apr 2015 17:48:24 +0200 Subject: [PATCH 2/4] gnu: libva: Patch a dlopen call, set drivers path. * gnu/packages/video.scm (libva): Patch the reference to libva-x11.so (passed to dlopen()) to use an absolute path. Add --with-drivers-path= to #:configure-flags with a value pointing to mesa's $prefix/lib/dri. --- gnu/packages/video.scm | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/gnu/packages/video.scm b/gnu/packages/video.scm index 2e2460d..c890d45 100644 --- a/gnu/packages/video.scm +++ b/gnu/packages/video.scm @@ -264,6 +264,27 @@ SMPTE 314M.") ("libxext" ,libxext) ("libxfixes" ,libxfixes) ("mesa" ,mesa))) + (arguments + `(#:phases + (modify-phases %standard-phases + (add-before + 'build 'fix-dlopen-paths + (lambda* (#:key outputs #:allow-other-keys) + (let ((out (assoc-ref outputs "out"))) + (substitute* "va/drm/va_drm_auth_x11.c" + (("\"libva-x11\\.so\\.%d\"") + (string-append "\"" out "/lib/libva-x11.so.%d\""))))))) + ;; Most drivers are in mesa's $prefix/lib/dri, so use that. (Can be + ;; overridden at run-time via LIBVA_DRIVERS_PATH.) + #:configure-flags + (list (string-append "--with-drivers-path=" + (assoc-ref %build-inputs "mesa") "/lib/dri")) + ;; However, we can't write to mesa's store directory, so override the + ;; following make variable to install the dummy driver to libva's + ;; $prefix/lib/dri directory. + #:make-flags + (list (string-append "dummy_drv_video_ladir=" + (assoc-ref %outputs "out") "/lib/dri")))) (home-page "http://www.freedesktop.org/wiki/Software/vaapi/") (synopsis "Video acceleration library") (description "The main motivation for VA-API (Video Acceleration API) is -- 2.2.1 --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0003-gnu-mesa-Add-libva-input.patch >From 37bd105ec9ff3d50a72a785fc3f4cb4e9827bf06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Taylan=20Ulrich=20Bay=C4=B1rl=C4=B1/Kammer?= Date: Tue, 28 Apr 2015 15:08:47 +0200 Subject: [PATCH 3/4] gnu: mesa: Add libva input. There is a circular dependency between Mesa and libVA, so we use a libva-for-mesa package that builds libVA without GLX and EGL support, and use that for building Mesa. * gnu/packages/gl.scm (libva-for-mesa): New variable. (mesa): Add as input. --- gnu/packages/gl.scm | 4 ++-- gnu/packages/video.scm | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/gnu/packages/gl.scm b/gnu/packages/gl.scm index a40749e..c350e29 100644 --- a/gnu/packages/gl.scm +++ b/gnu/packages/gl.scm @@ -37,6 +37,7 @@ #:use-module (gnu packages xml) #:use-module (gnu packages fontutils) #:use-module (gnu packages guile) + #:use-module (gnu packages video) #:use-module (gnu packages xdisorg)) (define-public glu @@ -188,8 +189,7 @@ also known as DXTn or DXTC) for Mesa.") ("dri3proto" ,dri3proto) ("presentproto" ,presentproto) ("expat" ,expat) - ;; TODO: Solve circular dependency with libva. - ;; ("libva" ,libva) + ("libva" ,libva-no-mesa) ("libxml2" ,libxml2) ;; TODO: Add 'libxml2-python' for OpenGL ES 1.1 and 2.0 support ("libxvmc" ,libxvmc) diff --git a/gnu/packages/video.scm b/gnu/packages/video.scm index c890d45..4d8100d 100644 --- a/gnu/packages/video.scm +++ b/gnu/packages/video.scm @@ -21,6 +21,7 @@ (define-module (gnu packages video) #:use-module (ice-9 match) + #:use-module (guix build utils) #:use-module ((guix licenses) #:prefix license:) #:use-module (guix utils) #:use-module (guix packages) @@ -293,6 +294,18 @@ entry-points (VLD, IDCT, Motion Compensation etc.) for prevailing coding standards (MPEG-2, MPEG-4 ASP/H.263, MPEG-4 AVC/H.264, and VC-1/VMW3).") (license license:expat))) +(define-public libva-no-mesa + (package + (inherit libva) + (name "libva-no-mesa") + (inputs (alist-delete "mesa" (package-inputs libva))) + (arguments + (strip-keyword-arguments + '(#:make-flags) + (substitute-keyword-arguments (package-arguments libva) + ((#:configure-flags flags) + '(list "--disable-glx" "--disable-egl"))))))) + (define-public ffmpeg (package (name "ffmpeg") -- 2.2.1 --=-=-=--