# VAAPI X11 driver only works as root



## edenist (Oct 6, 2022)

I'm running 12-STABLE on a Thinkpad X1 [1st gen] which has an i5-3330u w/ HD4000 GPU. I've had it installed and running on this machine since 10.3 or so without issue, but I recently noticed VAAPI wasn't being used with mpv anymore. Up until recently [erm, possibly the last few months I suppose], VAAPI was working as a non root user with the x11 driver.

Investigating with vainfo has me completely puzzled what has gone wrong.

* If I run `vainfo --display x11` it fails, but `sudo vainfo --display x11` works fine, which suggests a permissions issue. 
* I am a member of the video group and have access to GPU hardware.
* `vainfo --display drm` works as non-root user, so there appears to be something up with the x11 driver [which just so happens to be what mpv uses for its optimal vaapi implementation]. 

Here are my console outputs:


```
~$ vainfo --display x11
error: XDG_RUNTIME_DIR is invalid or not set in the environment.
libva info: VA-API version 1.16.0
libva info: Trying to open /usr/local/lib/dri/iHD_drv_video.so
libva info: va_openDriver() returns -1
libva info: Trying to open /usr/local/lib/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_1_16
get chip id failed: -1 [13]
param: 4, val: 0
libva error: /usr/local/lib/dri/i965_drv_video.so init failed
libva info: va_openDriver() returns -1
vaInitialize failed with error code -1 (unknown libva error),exit
```


```
~$ sudo vainfo --display x11
error: XDG_RUNTIME_DIR is invalid or not set in the environment.
libva info: VA-API version 1.16.0
libva info: Trying to open /usr/local/lib/dri/iHD_drv_video.so
libva info: va_openDriver() returns -1
libva info: Trying to open /usr/local/lib/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_1_16
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.16 (libva 2.15.0)
vainfo: Driver version: Intel i965 driver for Intel(R) Ivybridge Mobile - 2.4.1
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
```


```
~$ vainfo --display drm
libva info: VA-API version 1.16.0
libva info: Trying to open /usr/local/lib/dri/iHD_drv_video.so
libva info: va_openDriver() returns -1
libva info: Trying to open /usr/local/lib/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_1_16
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.16 (libva 2.15.0)
vainfo: Driver version: Intel i965 driver for Intel(R) Ivybridge Mobile - 2.4.1
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
```

I've gone through my devfs configurations, checked groups and permissions of various components and nothing which suggests what would be causing this behaviour. 
My xorg configuration is pretty barebones, with no GPU related entries in config files and letting it auto configure for the most part. Is this really a problem with an obscure permission, or is it an issue with my xorg installation? 

Any advice on where to keep looking would be greatly appreciated.


----------



## Alexander88207 (Oct 6, 2022)

I dont think that --display x11 is right while drm looks correct to me.


----------



## edenist (Oct 6, 2022)

Alexander88207 said:


> I dont think that --display x11 is right while drm looks correct to me.


I included it to explicitly show what was being used, but '--display x11' is the default used by vainfo if no arguments are provided. It is also what is used by mpv as well, with the relevant lines in the logs being:



```
[vo/gpu] Loading hwdec driver 'vaapi-egl'
[vo/gpu/vaapi-egl] using VAAPI EGL interop
[vo/gpu/vaapi-egl] Trying to open a x11 VA display...
get chip id failed: -1 [13]
param: 4, val: 0
[vo/gpu/vaapi-egl/vaapi] libva: /usr/local/lib/dri/i965_drv_video.so init failed
[vo/gpu] Loading failed.
[vo/gpu] Loading hwdec driver 'drmprime-drm'
[vo/gpu/drmprime-drm] Failed to retrieve DRM fd from native display.
[vo/gpu] Loading failed.
[vd] Could not create device.
[vd] No hardware decoding available for this codec.
[vd] Using software decoding.
```


Suffice to say, when running as root the x11 VA display is successful...


----------



## VladiBG (Oct 6, 2022)

Your user need to be a member of the video group to have access to DRI.


----------



## edenist (Oct 6, 2022)

VladiBG said:


> Your user need to be a member of the video group to have access to DRI.


They are a member of the video group. All other access to the GPU works, 3D accel etc. VAAPI access through the drm driver also works, but through the x11 driver it does not.


```
~$ groups
edenist wheel operator video webcamd cups
```


----------



## VladiBG (Oct 6, 2022)

i965_drv_video.so init failed (#278) · Issues · GStreamer / gstreamer-vaapi · GitLab
					

Hi, I encountered a similar problem when try using Gstreamer VAAPI plugins on Ubuntu to hardware decode the video stream. When I run vainfo for i965 driver it...




					gitlab.freedesktop.org


----------



## edenist (Oct 7, 2022)

Thanks, I did come across that thread in my prior research on this topic.

While I can see that it my VAAPI is working, I'm still not convinced that the X11 driver should require root access though. Especially as there is software which uses that driver as it's preferred method [I still can't work out how to get mpv to use the direct drm driver instead, but perhaps it can't do that if you've got a windowed application inside X]


----------

