メモ:Dell XPS 13 (7930)のhardware video acceleration関連で調べたこと

追記(2019/10/7): Waylandにしたら動きました⇢メモ:Dell XPS 13 (7390)にArch LinuxとGNOMEをインストールするまでの紆余曲折 - Technically, technophobic.


インストールできたはいいものの、グラフィック関連がなんかおかしいのでなんとかしたい。

たぶん今の私のカラテではなんともならない。でも調べたことをメモ。

とりあえずlspciでデバイスを調べる。

$ sudo lspci | grep -i VGA
00:02.0 VGA compatible controller: Intel Corporation Device 9b41 (rev 02)

$ lspci -v -s 00:02.0
00:02.0 VGA compatible controller: Intel Corporation Device 9b41 (rev 02) (prog-if 00 [VGA controller])
    DeviceName: To Be Filled by O.E.M.
    Subsystem: Dell Device 0962
    Flags: bus master, fast devsel, latency 0, IRQ 168
    Memory at 604a000000 (64-bit, non-prefetchable) [size=16M]
    [virtual] Memory at 4000000000 (64-bit, prefetchable) [size=256M]
    I/O ports at 3000 [size=64]
    [virtual] Expansion ROM at 000c0000 [disabled] [size=128K]
    Capabilities: <access denied>
    Kernel driver in use: i915
    Kernel modules: i915

この9b41というIDはすでにサポートされてるはずなので、もうちょいいい感じの名前で表示されてほしい気がする。ということで、まだこの辺のなんらかのドライバがきてないとか?

https://wiki.archlinux.org/index.php/Hardware_video_accelerationを読んでvainfoを実行してみたけど、なんかエラーになるのでおかしい気はする。

/etc/libva.confLIBVA_MESSAGING_LEVEL=2を指定してメッセージレベルを上げると以下のようなエラーになる。

$ vainfo 
libva info: VA-API version 1.5.0
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/lib/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_1_3
libva error: /usr/lib/dri/i965_drv_video.so init failed
libva info: va_openDriver() returns -1
vaInitialize failed with error code -1 (unknown libva error),exit

straceの結果を追うと、エラーの前後は以下のようになっている。

...
write(2, "libva info: Found init function "..., 51libva info: Found init function __vaDriverInit_1_3
) = 51
ioctl(4, DRM_IOCTL_I915_GEM_GET_APERTURE, 0x7ffe0e228370) = 0
geteuid()                               = 0
getuid()                                = 0
ioctl(4, DRM_IOCTL_I915_GETPARAM, 0x7ffe0e228380) = 0
ioctl(4, DRM_IOCTL_I915_GETPARAM, 0x7ffe0e228380) = 0
ioctl(4, DRM_IOCTL_I915_GETPARAM, 0x7ffe0e228380) = 0
ioctl(4, DRM_IOCTL_I915_GETPARAM, 0x7ffe0e228380) = 0
ioctl(4, DRM_IOCTL_I915_GETPARAM, 0x7ffe0e228380) = 0
ioctl(4, DRM_IOCTL_I915_GETPARAM, 0x7ffe0e228380) = 0
ioctl(4, DRM_IOCTL_I915_GETPARAM, 0x7ffe0e228380) = 0
ioctl(4, DRM_IOCTL_I915_GETPARAM, 0x7ffe0e228380) = 0
ioctl(4, DRM_IOCTL_I915_GETPARAM, 0x7ffe0e228380) = 0
ioctl(4, DRM_IOCTL_I915_GETPARAM, 0x7ffe0e228380) = 0
ioctl(4, DRM_IOCTL_I915_GETPARAM, 0x7ffe0e228380) = 0
write(2, "libva error: /usr/lib/dri/i965_d"..., 56libva error: /usr/lib/dri/i965_drv_video.so init failed
) = 56
write(2, "libva info: va_openDriver() retu"..., 39libva info: va_openDriver() returns -1
) = 39
write(2, "vaInitialize failed with error c"..., 66vaInitialize failed with error code -1 (unknown libva error),exit
) = 66
close(4)                                = 0
...

ここで、 va_openDriver()のコードを見ると、

static VAStatus va_openDriver(VADisplay dpy, char *driver_name)
{
    VADriverContextP ctx = CTX(dpy);
    VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN;
    char *search_path = NULL;
    char *saveptr;
    char *driver_dir;
    
    if (geteuid() == getuid())
        /* don't allow setuid apps to use LIBVA_DRIVERS_PATH */
        search_path = getenv("LIBVA_DRIVERS_PATH");
    if (!search_path)
        search_path = VA_DRIVERS_PATH;


    search_path = strdup((const char *)search_path);
    if (!search_path) {
         va_errorMessage(dpy, "%s L%d Out of memory\n",
                            __FUNCTION__, __LINE__);
         return VA_STATUS_ERROR_ALLOCATION_FAILED;
    }
    driver_dir = strtok_r(search_path, ":", &saveptr);
    while (driver_dir) {
        void *handle = NULL;
        char *driver_path = va_getDriverPath(driver_dir, driver_name);
        if (!driver_path) {
            va_errorMessage(dpy, "%s L%d Out of memory\n",
                            __FUNCTION__, __LINE__);
            free(search_path);
            return VA_STATUS_ERROR_ALLOCATION_FAILED;
        }


        va_infoMessage(dpy, "Trying to open %s\n", driver_path);

となっていて、Trying to open...というログは出てなかったので、それまでのどこかのエラーだけど...エラーになるような場所なくない??

mesaでは数日前に少し変更があったっぽいけど、表示名の変更だけっぽいのでさすがにこれは関係ないですよね...

とおもってたら、 intel-media-driver を入れて ~/.xprofile

export LIBVA_DRIVER_NAME=iHD

を指定しておくととりあえず vainfo は動くようにはなった。本来は指定しなくても勝手に選ばれるはずで、やはりここはlspciの結果で見たようにデバイスが認識されていないのが問題な気がする。

$ vainfo 
vainfo: VA-API version: 1.5 (libva 2.5.0)
vainfo: Driver version: Intel iHD driver - 1.0.0
vainfo: Supported profile and entrypoints
      VAProfileNone                   : VAEntrypointVideoProc
      VAProfileNone                   : VAEntrypointStats
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Simple            : VAEntrypointEncSlice
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointFEI
      VAProfileH264Main               : VAEntrypointEncSliceLP
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSlice
      VAProfileH264High               : VAEntrypointFEI
      VAProfileH264High               : VAEntrypointEncSliceLP
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
      VAProfileJPEGBaseline           : VAEntrypointVLD
      VAProfileJPEGBaseline           : VAEntrypointEncPicture
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
      VAProfileH264ConstrainedBaseline: VAEntrypointFEI
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSliceLP
      VAProfileVP8Version0_3          : VAEntrypointVLD
      VAProfileVP8Version0_3          : VAEntrypointEncSlice
      VAProfileHEVCMain               : VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointEncSlice
      VAProfileHEVCMain               : VAEntrypointFEI
      VAProfileHEVCMain10             : VAEntrypointVLD
      VAProfileHEVCMain10             : VAEntrypointEncSlice
      VAProfileVP9Profile0            : VAEntrypointVLD
      VAProfileVP9Profile2            : VAEntrypointVLD

とはいえやはりVS codeとかRStudioはうまく動かないので、そっちはmesa周りな気がする。