跳转至内容

DisplayLink

来自 ArchWiki

DisplayLink 是一种使用 USB 和 Wi-Fi 连接显示器的技术。

DisplayLink 设备在 Linux 上仍仅处于实验性支持阶段。虽然有些人成功地使用了它们,但这通常不是一个简单的过程,并且不保证有效。本页上的步骤描述了使用外部显示器配合 DisplayLink 的通常最成功的方法。

另外请注意,即使通过 USB 3.0,DisplayLink 显示器也可能比例如 DisplayPort 显示器表现出更明显的延迟,尤其是在屏幕的大部分区域被重绘时。

安装

USB 2.0 DL-1x5, DL-1x0 设备

DisplayLink 的内核 DRM 驱动程序是 udl,这是原始 udlfb 驱动程序的重写。它允许使用 xrandr 配置 DisplayLink 显示器。

linux 4.14.9-1 及更高版本上,这应该可以正常工作,无需任何配置更改。如果您使用的是该软件包的早期版本,或者在内核配置中设置了 CONFIG_FB_UDL=m,则需要 禁用 旧内核模块 udlfb,它可能会尝试自行加载。

USB 3.0 DL-6xxx, DL-5xxx, DL-41xx, DL-3xxx 设备

  1. 安装 evdi-dkmsAUR 以获取内核模块(配置 DKMS 后)。如 DKMS 页面所述,不要忘记安装适用于您内核的相应头文件包(例如,对于标准的 linux 内核,请安装 linux-headers),否则将不会有任何操作。如果您遇到问题,可以使用开发版本。
  2. 安装 displaylinkAUR 驱动程序。对于 Xorg,它允许使用 xrandr 以与 udl 驱动程序相同的方式配置 DisplayLink 显示器;对于 Wayland,则无需配置。
  3. 启用 displaylink.service
  4. 对于 Xorg,请使用 "modesetting" 驱动程序,并将 AccelMethod 设置为 "none",MatchDriver 设置为 "evdi"。

创建一个包含以下内容的文件

/etc/X11/xorg.conf.d/20-evdi.conf
Section "OutputClass"
	Identifier "DisplayLink"
	MatchDriver "evdi"
	Driver "modesetting"
	Option "AccelMethod" "none"
EndSection

可能需要重启才能使设置生效。重启后,检查 Displaylink 屏幕是否显示在您的显示设置中。如果没有,请继续执行下一步,这将把 DVI-I 输入连接到您的 GPU。

设置 X 显示器

在此之后,运行

$ xrandr --listproviders
Providers: number : 2
Provider 0: id: 0x49 cap: 0xb, Source Output, Sink Output, Sink Offload crtcs: 2 outputs: 8 associated providers: 0 name:Intel
Provider 1: id: 0x13c cap: 0x2, Sink Output crtcs: 1 outputs: 1 associated providers: 0 name:modesetting

在上面的输出中,我们可以看到提供者 0 是系统的常规图形提供者(Intel),而提供者 1(modesetting)是 DisplayLink 提供者。要使用 DisplayLink 设备,请将提供者 1 连接到提供者 0

$ xrandr --setprovideroutputsource 1 0

然后 xrandr 将添加一个 DVI 输出,您可以 像平常一样使用 xrandr。这仍然是实验性的,但支持热插拔,并且在工作时,这是迄今为止最简单的设置。如果它工作,那么下面的一切都是不必要的。

配置

这些说明假设您已经有一个正常运行的 X 服务器,并且只是向现有设置添加一个显示器。

加载帧缓冲设备

在您的系统识别 DisplayLink 设备之前,必须加载 udl 内核模块。要做到这一点,运行

# modprobe udl

如果您的 DisplayLink 设备已连接,它应该会显示一些视觉指示。虽然绿色屏幕是标准指示,但也有其他变化被发现并且完全正常。最重要的是,dmesg 的输出应该显示类似以下内容,表明找到了新的 DisplayLink 设备

# dmesg
usb 2-1.1: new high-speed USB device number 7 using ehci-pci
usb 2-1.1: New USB device found, idVendor=17e9, idProduct=03e0
usb 2-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 2-1.1: Product: Lenovo LT1421 wide
usb 2-1.1: Manufacturer: DisplayLink
usb 2-1.1: SerialNumber: 6V9BBRM1
[drm] vendor descriptor length:17 data:17 5f 01 00 15 05 00 01 03 00 04
udl 2-1.1:1.0: fb1: udldrmfb frame buffer device
[drm] Initialized udl 0.0.1 20120220 on minor 1

此外,/dev 应该包含一个新的 fb 设备,如果您已经为主显示器拥有了一个帧缓冲,则可能是 /dev/fb1

而不是手动加载 udl,您可以在 启动时加载模块

配置 X 服务器

使用 xrandr 或您的桌面环境的显示设置图形界面来配置您的 USB 显示器,这些显示器运行 udldisplaylink 驱动程序。

xrandr

驱动程序加载后,DisplayLink 显示器将列为一个输出提供者

$ xrandr --listproviders
Providers: number : 2
Provider 0: id: 0x43 cap: 0xb, Source Output, Sink Output, Sink Offload crtcs: 2 outputs: 2 associated providers: 1 name:Intel
Provider 1: id: 0xcb cap: 0x2, Sink Output crtcs: 1 outputs: 1 associated providers: 1 name:modesetting

在上面的例子中,提供者 1 是 DisplayLink 设备,提供者 0 是默认显示器。运行 xrandr --current 会列出可用的屏幕

$ xrandr --current
Screen 0: minimum 320 x 200, current 1600 x 900, maximum 8192 x 8192
LVDS1 connected 1600x900+0+0 (normal left inverted right x axis y axis) 309mm x 174mm
   1600x900       60.0*+   40.0  
   1440x900       59.9  
   1360x768       59.8     60.0  
   1152x864       60.0  
   1024x768       60.0  
   800x600        60.3     56.2  
   640x480        59.9  
VGA1 disconnected (normal left inverted right x axis y axis)
DVI-1-0 connected (normal left inverted right x axis y axis)
   1366x768       60.0 +
   1368x768_59.90   59.9  
  1368x768_59.90 (0xd0)   85.7MHz
        h: width  1368 start 1440 end 1584 total 1800 skew    0 clock   47.6KHz
        v: height  768 start  769 end  772 total  795           clock   59.9Hz

如果上述命令没有列出 DisplayLink 屏幕,那么您将需要将 DisplayLink 卸载到主 GPU

$ xrandr --setprovideroutputsource 1 0

一旦屏幕可用,请参阅 xrandr 以获取有关设置它的信息。有关自动化配置过程,请参阅 displaylink.sh

启动时启用 DVI 输出

在大多数情况下,DisplayLink 提供者不会自动连接到主提供者,因此 DVI 输出设备将不可用。在 X 启动时自动执行此操作有助于窗口管理器自动配置显示器。

编辑您的桌面管理器启动配置,并添加类似以下命令

$(xrandr --listproviders | grep -q "modesetting") && xrandr --setprovideroutputsource 1 0

例如,适用于 SDDM 的适当启动配置文件是 /usr/share/sddm/scripts/Xsetup

避免将这些命令放在 ~/.xprofile 中,因为这会破坏某些窗口管理器的显示配置。相反,这些命令应该在任何显示输出或设置之前运行。

注意 如果您有其他提供者,请指定提供者的名称而不是使用索引。DisplayLink 设备的名称将是 modesetting

本文或本章节已过时。

原因: AUR 中的 displaylink 包版本为 5.4.1… (在 Talk:DisplayLink 中讨论)

截至 displaylink 版本 1.3.54-1,在基于 Optimus 的笔记本电脑上无法同时使用 displaylink 设备和 NVIDIA/nouveau 驱动程序。目前,要能够在 Intel GPU 上使用 displaylink 设备,您应该创建一个配置文件(参见下面的 #Troubleshooting)。但是,使用该配置文件无法使用 primusrun。Bumblebee 服务正在运行,但它无法工作。此外,笔记本风扇会变得非常响亮,笔记本温度会变得非常高。当您想切换回激活 NVIDIA 驱动程序时,请注释掉该文件中的所有内容并重启。

为了简化切换过程,您可以 安装 dl-switchAUR,并使用 内核参数 systemd.unit=displaylink.target 向引导加载程序添加一个额外的菜单项,从而激活 displaylink 变通方案。

要检查您的独立显卡使用的是哪个驱动程序,请运行 lspci -nnk -s xx:xx.x(将 xx:xx.x 替换为您的 NVIDIA GPU PCI ID)。

故障排除

未正常工作的配置

这些是在 Xfce 上使用 Display 设置(包含在 XFCE4 包中)和外部工具 - arandr 进行测试的。XFCE4 Display 设置很可能会崩溃,因此 ARandR 可能会有帮助。

当您通过 USB 将显示链接设备连接到计算机时,计算机应该会在显示设置中显示显示器。有一些故障排除步骤应尝试

  • 检查 #设置 X 显示器。如果您找不到任何外部显示器被识别,您应该尝试通过以下一些命令使其可见
    $ xrandr --setprovideroutputsource 1 0
    $ xrandr --setprovideroutputsource 2 0
    $ xrandr --setprovideroutputsource 3 0
    ...
    
    这将使它们在显示设置中可见并被识别。
  • 重启 displaylink.service
  • 重新连接 USB 线缆。
  • 检查 udl 驱动程序是否已加载以及显示器是否已连接。

屏幕重绘损坏

如果您正在使用 udl 作为内核驱动程序,并且显示器似乎可以工作,但仅在移动鼠标或某些地方的窗口发生变化时才更新,那么您可能为屏幕使用了错误的 modeline。使用类似以下命令获取屏幕的正确 modeline

$ gtf 1366 768 59.9

其中 1366768 是显示器的水平和垂直分辨率,59.9 是其规格中的刷新率。要使用它,请使用 xrandr 创建一个新的模式,如下所示

$ xrandr --newmode "1368x768_59.90"  85.72  1368 1440 1584 1800  768 769 772 795  -HSync +Vsync

并将其添加到 xrandr

$ xrandr --addmode DVI-0 1368x768_59.90

然后告诉显示器为 DisplayLink 显示器使用该模式,这将解决重绘问题。查看 xrandr 页面以获取有关使用不同模式的信息。

如果这不能解决问题(或者因为正确的 DDC 数据已经存在正确的 modeline),运行一个 合成器可能会有帮助。

重影

如果您遇到由移动光标引起的重影,则可能是您的合成器配置导致了问题。更改设置可能会给您一个可用的设置,例如在启动时关闭合成器可以解决它。

用户已 报告,注销然后重新登录(以刷新显示管理器)可以暂时纠正问题。可以通过以下方法在您的系统上实现一个更持久的解决方案

/etc/systemd/system/display-manager.service
[Service]
# ...
ExecStartPre=/bin/sleep 10

延迟 10 秒对某些用户来说似乎有效,但可能可以实现更短的延迟。用户报告说在 GNOME 中关闭自动登录可以解决该问题。

此外,可能可以通过启用或禁用“辅助功能”中的缩放来解决。用户报告说关闭它解决了问题,而另一些用户报告说启用它有时可以解决问题(缩放设置为 1.0)。

设置 DisplayLink 后,如果您的整个桌面变得缓慢,请尝试设置一个“更简单”的背景图像,例如完全黑色。此外,自 2019 年以来已有报告称旋转的 Displaylink 屏幕本身就很慢,因此请查看将显示器设置为正常方向是否也能纠正问题。

禁用内置屏幕时所有显示器均被限制为 1 FPS

https://gitlab.freedesktop.org/xorg/xserver/-/issues/1028#note_504826 中的补丁应用于 xorg-server 似乎可以解决问题。

Google Chrome 和 Webkit2 系列应用程序中重绘缓慢/无响应

这与硬件加速中的错误有关,可以通过在 displaylink 屏幕上运行 glxgears 进行测试,结果为 1fps。目前没有完整的解决方案,但关闭受影响应用程序中的硬件加速可以作为临时解决方案。

对于没有硬件加速选项的应用程序,可以通过在前面加上 LIBGL_ALWAYS_SOFTWARE=1 环境变量来完成。

无法激活 DisplayLink 的屏幕

如果您可以在屏幕设置中看到通过 DisplayLink 设备连接的显示器,但在打开并应用设置后,它会停用,那么请尝试禁用 nouveau 模块并重启

/etc/modprobe.d/nouveau.conf
blacklist nouveau
options nouveau modeset=0

挂起问题

挂起后 Displaylink 不工作。拔下 DisplayLink 的 USB 线缆,然后重新插入您的计算机。通过 DisplayLink 连接的显示器将保持黑色。如果您有锁屏界面,请登录系统,然后图片将出现在该显示器上,您就可以像正常一样使用 DisplayLink 了。

要能够使用 DisplayLink 显示器,其 USB 线缆应该在启动时连接到笔记本电脑。否则,它可能表现得好像可用,并且鼠标可以在上面移动,但图像是冻结的,即使配置正确(参见变通方案 1)。如果未在启动时连接,请连接它并重启。

正如 此支持页面所说,将 X Window Server 升级到高于 1.18.3 的版本将使系统默认与 DisplayLink 不兼容。这适用于使用集成 Intel GPU 或集成 Intel GPU 和独立 GPU 组合的系统。在 X Windows System 中发布修复程序之前,有两种变通方法

使用旧版 intel 驱动作为备用

使用 "intel" 驱动程序来代替 "modesetting"(现在是默认的)来驱动集成 GPU。

创建一个包含以下内容的文件

/usr/share/X11/xorg.conf.d/20-displaylink.conf
Section "Device" 
  Identifier "Intel Graphics"
  Driver "intel"
EndSection

需要重启才能使设置生效。

您可能需要 evdi-dkms-gitAUR 包。

暂时禁用 PageFlip 以进行 modesetting

对于希望继续使用 "modesetting" 驱动程序的用户,禁用 page flipping 也应该会有帮助。创建一个包含以下内容的文件,或者将 PageFlip 选项添加到现有配置文件(例如 20-evdidevice.conf

/usr/share/X11/xorg.conf.d/20-displaylink.conf
Section "Device"
  Identifier "DisplayLink"
  Driver "modesetting"
  Option "PageFlip" "false"
EndSection 

使用 Dell D6000 扩展坞时,显示器会随机断开连接

用户 报告,在使用 Dell D6000 扩展坞时,他们的显示器在使用的过程中可能会随机断开连接。这需要物理上重新连接扩展坞才能重新初始化显示器。

此问题似乎是由 PulseAudiomodule-suspend-on-idle 模块引起的,该模块会在空闲时自动挂起接收器/源。

要禁用 module-suspend-on-idle 模块的加载,请注释掉当前使用的配置文件(~/.config/pulse/default.pa/etc/pulse/default.pa)中的以下行

/etc/pulse/default.pa
### Automatically suspend sinks/sources that become idle for too long
# load-module module-suspend-on-idle

启动后仅识别 1 个显示器

如果多个显示器连接到 DisplayLink 扩展坞,但启动后只识别 1 个,可能的解决方案是通过将 evdi 模块添加到 /etc/modules-load.d/evdi.conf,并将 "options evdi initial_device_count=2" 添加到 /etc/modprobe.d/dkms.conf 来强制 evdi 在启动时搜索多个显示器

如果使用 NVIDIA Optimus 的笔记本电脑处于更固定的环境中(使用 X11),最好永久将视频输出设置为使用 dGPU。nvidia-xconfig 可能会生成以下内容

/etc/X11/xorg.conf
Section "ServerLayout"
    Identifier     "Layout0"
    Screen      0  "Screen0"
    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"
EndSection

# ...
# Keyboard0
# Mouse0
# ...

Section "Monitor"
    Identifier     "Monitor0"
    VendorName     "Unknown"
    ModelName      "Unknown"
    Option         "DPMS"
EndSection

Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BusID          "PCI:1:0:0"
EndSection

Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Monitor0"
    DefaultDepth    24
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection

即使安装了 evdi-dkmsAURdisplaylinkAUR 包,DisplayLink 连接的显示器可能仍然不会出现。手动,我们可以指示 Xorg 使用由 displaylinkAUR 驱动程序提供的视频接口的 modesetting(4) 插件。

识别哪个 DRI 设备。最简单的识别设备方法是按路径列出所有 DRI 设备

$ ls -al /dev/dri/by-path
total 0
drwxr-xr-x 2 root root 160 May 11 19:10 .
drwxr-xr-x 3 root root 180 May 10 16:03 ..
lrwxrwxrwx 1 root root   8 May 10 16:03 pci-0000:00:02.0-card -> ../card0
lrwxrwxrwx 1 root root  13 May 10 16:03 pci-0000:00:02.0-render -> ../renderD128
lrwxrwxrwx 1 root root   8 May 11 19:10 pci-0000:01:00.0-card -> ../card1
lrwxrwxrwx 1 root root  13 May 10 16:03 pci-0000:01:00.0-render -> ../renderD129
lrwxrwxrwx 1 root root   8 May 10 16:03 platform-evdi.0-card -> ../card2
lrwxrwxrwx 1 root root   8 May 10 16:03 platform-evdi.1-card -> ../card3

如您所见,第一个 evdi-dkmsAUR 设备是 /dev/dri/card2

将以下内容添加到 Xorg 配置中

/etc/X11/xorg.conf
# Add the following to the ServerLayout section after Screen0
# ...
    Screen      1  "Screen1"
# ...
# ... at the end, add:
Section "Device"
    Identifier    "usbdev"
    Driver        "modesetting"
    Option        "kmsdev" "/dev/dri/card2"
EndSection


Section "Screen"
    Identifier    "Screen1"
    Device        "usbdev"
EndSection

重启 X 服务器以查看更改。

DL 显示器应该会出现。根据需要使用 xrandr 进行配置。

本文或本章节已过时。

原因: 在较新的内核版本中,UDL 不会报错:消息已更改为警告。 (在 Talk:DisplayLink 中讨论)

udl 相当挑剔。一些 USB 2 设备可以使用它,有些则不能。例如,HP NL571AA, Lenovo LT1421 wide 已经测试过可以使用。如果您的 USB 2.0 设备无法与 udl 一起使用(例如 EVGA "UV PLUS+16"),您将在您的 journal 中收到以下错误 

[drm] vendor descriptor length:e0 data:00 00 00 00 00 00 00 00 00 00 00
[drm:udl_init [udl]] *ERROR* Unrecognized vendor firmware descriptor
[drm] Initialized udl 0.0.1 20120220 for 1-1.3:1.0 on minor 1
[drm] Initialized udl on minor 1
udl 1-1.3:1.0: [drm] fb1: udldrmfb frame buffer device
usbcore: registered new interface driver udl

竖直方向的显示器底部被截断

通过 DisplayLink 连接的显示器在竖直方向上显示时,底部可能会被截断成一个不可用的死黑区域。这可能是由于 udl 加载在 displaylink 驱动程序之前并接管了 DisplayLink 连接,导致 displaylink 未被使用。禁用 udl 以便 displaylink 处理 DisplayLink 连接,可能会使显示器恢复正常。

您可以通过 停止 displaylink.service 并查看 DisplayLink 显示器是否停止工作来检查 DisplayLink 连接是否由 displaylink 配置。如果这导致屏幕变黑并且 xrandr 无法检测到,那么 DisplayLink 连接由 displaylink 控制,udl 不是问题。

但是,如果停止 displaylink.service 对 DisplayLink 显示器没有影响,并且 lsmod | grep udl 显示 udl 已加载,那么可能是 udldisplaylink 之前加载以处理 DisplayLink 连接,并且 udl 不兼容导致了显示问题。

禁用 udl重新生成 initramfs

重启后,检查 udlevdidisplaylink.service 的状态

$ lsmod | grep 'evdi\|udl'
evdi                  122880  2
$ systemctl status displaylink.service
● displaylink.service - DisplayLink Manager Service
    Loaded: loaded (/usr/lib/systemd/system/displaylink.service; enabled; preset: disabled)
    Drop-In: /usr/lib/systemd/system/displaylink.service.d
             └─displaylink-connect.conf
     Active: active (running) since ...

如果 udl 未加载,evdi 已加载,并且 displaylink.service 处于活动状态,如上所示,请再次使用 xrandr 显示检测到的显示器。如果在输出中出现了 DisplayLink 设备,则 displaylink 现在正在处理 DisplayLink 连接,并且设备的名称可能已更改。如果出现这种情况,请使用此新名称配置显示器设置,看看显示问题是否已解决。

参见