guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] gnu: mesa: Add libva input.


From: Taylan Ulrich Bayırlı/Kammer
Subject: Re: [PATCH] gnu: mesa: Add libva input.
Date: Tue, 28 Apr 2015 22:21:25 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

宋文武 <address@hidden> 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:

>From 51e9e9d0510fc86278a7bd125366a765a10c365a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Taylan=20Ulrich=20Bay=C4=B1rl=C4=B1/Kammer?=
 <address@hidden>
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

>From 37bd105ec9ff3d50a72a785fc3f4cb4e9827bf06 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Taylan=20Ulrich=20Bay=C4=B1rl=C4=B1/Kammer?=
 <address@hidden>
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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]