Bug 217825 - multimedia/libva-intel-driver: problem with the driver name
Summary: multimedia/libva-intel-driver: problem with the driver name
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Guido Falsi
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-03-16 06:01 UTC by Henry Hu
Modified: 2017-03-19 15:10 UTC (History)
1 user (show)

See Also:
madpilot: maintainer-feedback+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Henry Hu 2017-03-16 06:01:59 UTC
Today, I tried mpv on some mp4 file, and it says
libva info: Trying to open /usr/local/lib/va/i915_drv_video.so
libva info: va_openDriver() returns -1
The same happens for vainfo.

It seems like that only i965_drv_video.so is installed. The reason seems to be that on Linux, they have i915 and i965 drivers, and only the devices supported by i965 supports vaapi (some of them).
However, on FreeBSD we only have i915 which supports all the devices.
From Xorg.0.log we can see
[   405.175] (II) modeset(0): [DRI2] Setup complete
[   405.175] (II) modeset(0): [DRI2]   DRI driver: i915
[   405.175] (II) modeset(0): [DRI2]   VDPAU driver: i915
while old hardware under linux says
[    80.051] (II) intel(0): [DRI2] Setup complete
[    80.051] (II) intel(0): [DRI2]   DRI driver: i965
[    80.051] (II) intel(0): [DRI2]   VDPAU driver: va_gl
and libva seems to be loading drivers based on the dri driver name.

The most simple fix seems to be making a symlink to i915_drv_video.so, which is also somewhere correct, because we do have i915 driver which supports VAAPI. Another fix may be changing libva's logic and load i965_drv_video.so instead.
Comment 1 Guido Falsi freebsd_committer freebsd_triage 2017-03-16 11:37:28 UTC
Hi,

Did you test manually creating the symlink you suggest? Does that make it work as expected?

Thanks for reporting the issue and for the further feedback!
Comment 2 Henry Hu 2017-03-16 13:58:31 UTC
(In reply to Guido Falsi from comment #1)
Yes, with the symlink, it says

libva info: VA-API version 0.39.4
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/local/lib/va/i915_drv_video.so
libva info: Found init function __vaDriverInit_0_39
libva info: va_openDriver() returns 0
vainfo: VA-API version: 0.39 (libva 1.7.3)
vainfo: Driver version: Intel i965 driver for Intel(R) Ivybridge Mobile - 1.7.3
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Simple            : VAEntrypointEncSlice
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointEncSlice
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSlice
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSlice
      VAProfileH264StereoHigh         : VAEntrypointVLD
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
      VAProfileNone                   : VAEntrypointVideoProc
      VAProfileJPEGBaseline           : VAEntrypointVLD

and mpv also works.
Comment 3 Guido Falsi freebsd_committer freebsd_triage 2017-03-16 20:26:55 UTC
(In reply to Henry Hu from comment #2)
> (In reply to Guido Falsi from comment #1)
> Yes, with the symlink, it says
> 

Thanks.

My intel equipped laptop uses the i965 driver, that explains why I failed to notice this.

Thanks again for the report, I'll commit the symlink fix after some testing.
Comment 4 commit-hook freebsd_committer freebsd_triage 2017-03-19 11:26:37 UTC
A commit references this bug:

Author: madpilot
Date: Sun Mar 19 11:26:19 UTC 2017
New revision: 436483
URL: https://svnweb.freebsd.org/changeset/ports/436483

Log:
  X11 looks for this driver with two names depending on the hardware, since linux has tow separate drivers. Having just one KMS driver in FreeBSD I create a symlink with the alternative name, so X11 can alys find the driver.

  PR:		217825
  Submitted by:	Henry Hu <henry.hu.sh@gmail.com>

Changes:
  head/multimedia/libva-intel-driver/Makefile
Comment 5 Guido Falsi freebsd_committer freebsd_triage 2017-03-19 11:27:11 UTC
Change committed. Thanks!
Comment 6 Jan Beich freebsd_committer freebsd_triage 2017-03-19 13:03:22 UTC
I don't understand the rationale here. Looks like a pilot error instead. Linux doesn't install i915_drv_video.so, see https://www.archlinux.org/packages/extra/x86_64/libva-intel-driver/files/ Hardware that doesn't support i965 is unlikely to have VAAPI as well.

> From Xorg.0.log we can see
> [   405.175] (II) modeset(0): [DRI2] Setup complete
> [   405.175] (II) modeset(0): [DRI2]   DRI driver: i915
> [   405.175] (II) modeset(0): [DRI2]   VDPAU driver: i915

Try to explicitly set BusID (e.g. "pci:0:2:0"), so modeset DDX doesn't fallback on i915 DRI and VAAPI driver. i965 auto-detection appears to be flaky on FreeBSD with more than one GPU.

> while old hardware under linux says
> [    80.051] (II) intel(0): [DRI2] Setup complete
> [    80.051] (II) intel(0): [DRI2]   DRI driver: i965
> [    80.051] (II) intel(0): [DRI2]   VDPAU driver: va_gl

x11-drivers/xf86-video-intel (aka intel DDX) on FreeBSD behaves in the same way.
Comment 7 Henry Hu 2017-03-19 14:41:24 UTC
(In reply to Jan Beich (mail not working) from comment #6)

With a minial xorg.conf which specifies BusID, i965 is correctly detected. Sorry for my misunderstanding.
[    44.301] (II) modeset(0): [DRI2] Setup complete
[    44.301] (II) modeset(0): [DRI2]   DRI driver: i965
[    44.301] (II) modeset(0): [DRI2]   VDPAU driver: i965

Current xorg.conf:
Section "ServerLayout"
	Identifier     "minimal"
	Screen      0  "Screen0" 0 0
EndSection

Section "Device"
	Identifier  "Card0"
	Driver      "modesetting"
	BusID       "PCI:0:2:0"
EndSection

Section "Screen"
	Identifier "Screen0"
	Device     "Card0"
	Monitor    "Monitor0"
EndSection

Yes, this is an optimus laptop with both an intel card and a nvidia card. The nvidia card is powered off through acpi_call. It is still visible through pciconf, but not in lspci.

[    43.623] (!!) More than one possible primary device found
[    43.623] (--) PCI: (0:0:2:0) 8086:0166:1043:15a7 rev 9, Mem @ 0xf7400000/4194304, 0xd0000000/268435456, I/O @ 0x0000f000/64, BIOS @ 0x????????/65536
[    43.623] (--) PCI: (0:1:0:0) 10de:0fd1:1043:15a7 rev 161, Mem @ 0xf6000000/16777216, 0xe0000000/268435456, 0xf0000000/33554432, I/O @ 0x0000e000/128, BIOS @ 0x????????/65536

The X even requires a symlink from /dev/dri/card0 to /dev/dri/card1, or it would not start, saying
[   415.125] (EE) open /dev/dri/card0: No such file or directory
[   415.125] (WW) Falling back to old probe method for modesetting
[   415.125] (EE) open /dev/dri/card0: No such file or directory

However, other users may also use Xorg with no configuration file, and hit the same problem. With a symlink to i915_drv_video.so, other uses would not hit this problem again.
Comment 8 Guido Falsi freebsd_committer freebsd_triage 2017-03-19 15:10:45 UTC
I understand the problem, but, since today X11 working correctly without needing a configuration file is expected I'd rather leave the symlink.

I think loading the driver on unsupported hardware causes no problems, and it could fix such corner cases.

This, obviously, except it is shown that this patch causes problems.