unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: taylanbayirli@gmail.com (Taylan Ulrich Bayırlı/Kammer)
To: 宋文武 <iyzsong@gmail.com>
Cc: guix-devel@gnu.org
Subject: Re: [PATCH] gnu: mesa: Add libva input.
Date: Tue, 28 Apr 2015 22:21:25 +0200	[thread overview]
Message-ID: <87r3r4dmwq.fsf@taylan.uni.cx> (raw)
In-Reply-To: <87383kbah1.fsf@gmail.com> ("宋文武"'s message of "Tue, 28 Apr 2015 22:20:42 +0800")

[-- Attachment #1: Type: text/plain, Size: 2583 bytes --]

宋文武 <iyzsong@gmail.com> 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:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0002-gnu-libva-Patch-a-dlopen-call-set-drivers-path.patch --]
[-- Type: text/x-diff, Size: 2086 bytes --]

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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0003-gnu-mesa-Add-libva-input.patch --]
[-- Type: text/x-diff, Size: 2434 bytes --]

From 37bd105ec9ff3d50a72a785fc3f4cb4e9827bf06 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Taylan=20Ulrich=20Bay=C4=B1rl=C4=B1/Kammer?=
 <taylanbayirli@gmail.com>
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	other threads:[~2015-04-28 20:21 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-28 13:14 [PATCH] gnu: mesa: Add libva input Taylan Ulrich Bayırlı/Kammer
2015-04-28 14:14 ` Taylan Ulrich Bayırlı/Kammer
2015-04-28 14:20 ` 宋文武
2015-04-28 20:21   ` Taylan Ulrich Bayırlı/Kammer [this message]
2015-04-29  8:59     ` 宋文武
2015-04-29 21:12     ` Andreas Enge
2015-04-29 21:52       ` Taylan Ulrich Bayırlı/Kammer
2015-04-30  7:29         ` Andreas Enge
2015-04-30  7:31           ` Andreas Enge
2015-04-30  7:52             ` Taylan Ulrich Bayırlı/Kammer
2015-04-30 13:26               ` Taylan Ulrich Bayırlı/Kammer
2015-04-30 22:18                 ` Ludovic Courtès
2015-04-30  7:49           ` Taylan Ulrich Bayırlı/Kammer
2015-04-30  8:20           ` Taylan Ulrich Bayırlı/Kammer
2015-04-30 22:17             ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r3r4dmwq.fsf@taylan.uni.cx \
    --to=taylanbayirli@gmail.com \
    --cc=guix-devel@gnu.org \
    --cc=iyzsong@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).