专栏
天翼云开发者社区

Xorg驱动

2023-12-13 16:05:40 44阅读

0 前言

    Xorg至少需要一个显示驱动和一个输入驱动,这些驱动指定的都是应用空间的,由它负责和内核空间的驱动打交道,有点类似Android的HAL层。

1 目录

  路径 说明
驱动 /usr/lib/xorg/modules 默认Xorg使用路径
/usr/local/lib/x86_64-linux-gnu/xorg/modules/drivers 自编译安装Xorg使用的路径
配置 /usr/share/X11/xorg.conf.d 默认Xorg使用路径
/usr/local/share/X11/xorg.conf.d 自编译安装Xorg使用的路径

2 输入

    Xorg的输入驱动有两套:

kernel -> libevdev -+-> xf86-input-evdev -> X server -> X client                  # xorg-xserver old
                    |-> libinput -+-> Wayland compositor -> Wayland client        # Weston/Wayland compositor
                                  |-> xf86-input-libinput -> X server -> X client # xorg-xserver-1.16+

    各发行版默输入驱动:

发行版 输入驱动
Ubuntu 14.04 evdev
16.04
18.04 libinput
20.04
22.04
UOS Pro V20
银河麒麟 V10

  • 验证Ubuntu20.04同时安装evdev和libinput两种驱动,会优先使用后者!只有将后者的配置文件删除,才会使用前者!
  • Ubuntu18.04编译安装libinput驱动失败,改为安装evdev驱动是成功的!

2.1 evdev

[    19.877] (II) LoadModule: "evdev"
[    19.877] (II) Loading /usr/lib/xorg/modules/input/evdev_drv.so
[    19.961] (II) Module evdev: vendor="X.Org Foundation"
[    19.961]    compiled for 1.18.3, module version = 2.10.1
[    19.961]    Module class: X.Org XInput Driver
[    19.961]    ABI class: X.Org XInput driver, version 22.1

2.2 libinput

[     4.984] (II) LoadModule: "libinput"
[     4.985] (II) Loading /usr/local/lib/x86_64-linux-gnu/xorg/modules/input/libinput_drv.so
[     4.992] (II) Module libinput: vendor="X.Org Foundation"
[     4.992]    compiled for 1.20.13, module version = 1.3.0
[     4.992]    Module class: X.Org XInput Driver
[     4.992]    ABI class: X.Org XInput driver, version 24.1

3 显示

    不同虚拟机/物理机的显卡驱动如下表所示:

虚拟机/物理机 显卡 系统 驱动 Mesa3D 说明
内核 应用 实现 DRI
VirtualBox7.0 VMSVGA Ubuntu14.04 vmwgfx vmware_drv.so VMware SVGA3D vmwgfx_dri.so 启动3D加速正常
VBoxVGA vboxvideo vboxvideo_drv.so VMware llvmpipe swrast_dri.so 必须禁用3D加速才可以切换到该显卡。
VBoxSVGA
QEMU7.0 QXL Ubuntu18.04 qxl qxl_drv.so  
Virtio virtio_gpu modesetting_drv.so Mesa VirGL virtio_gpu_dri.so 需要启动3D加速功能才行
Ramfb fbdev fbdev_drv.so VMware llvmpipe  
Bochs  
OptiPlex7050 Intel Ubuntu22.04 i915 modesetting_drv.so Intel i915_dri.so、
i965_dri.so、
iris_dri.so(默认)
 
Precision3530 Intel 内置屏幕是连接i915显卡上的,因此无法单独使用NVIDIA显卡,只能同时使用。
NVIDIA nvidia-drm nvidia_drv.so NVIDIA

    无论是fbdev还是drm类型的驱动,实现的都是如下结构:

typedef struct _DriverRec {
    int driverVersion;
    const char *driverName;
    void (*Identify) (int flags);
    Bool (*Probe) (struct _DriverRec * drv, int flags); // probe方法1:这是旧方法,其它方法都不支持或失败了才会用
    const OptionInfoRec *(*AvailableOptions) (int chipid, int bustype);
    void *module;
    int refCount;
    xorgDriverFuncProc *driverFunc;
    const struct pci_id_match *supported_devices;
    // probe方法2:其次使用
    Bool (*PciProbe) (struct _DriverRec * drv, int entity_num, struct pci_device * dev, intptr_t match_data);
    // probe方法3:最优先使用
    Bool (*platformProbe) (struct _DriverRec * drv, int entity_num, int flags, struct xf86_platform_device * dev, intptr_t match_data);
} DriverRec, *DriverPtr;
// @file: xorg-server-1.20.13/hw/xfree86/common/xf86str.h

    上述结构体定义了3种probe方法,不同驱动选择不同的方式。

参考资料

[1]Screen Tearing on Ubuntu Xorg 20.04 with Intel Graphics
[2]failed to create screen resources (EE)
[3]解决Ubuntu系统/usr/lib/xorg/Xorg占用显卡内存问题
[4]一切皆文件:强化学习的 Xorg 虚拟环境(多显卡配置)
[5]报错:libtool: Version mismatch error. This is libtool 2.4.6解决
[6]Nvidia显卡在ubuntu下xorg.conf 配置

  • 0
  • 0
  • 0
0 评论
0/1000
评论(0) 发表评论
李****海

李****海

14 篇文章 0 粉丝
关注

Xorg驱动

2023-12-13 16:05:40 44阅读

0 前言

    Xorg至少需要一个显示驱动和一个输入驱动,这些驱动指定的都是应用空间的,由它负责和内核空间的驱动打交道,有点类似Android的HAL层。

1 目录

  路径 说明
驱动 /usr/lib/xorg/modules 默认Xorg使用路径
/usr/local/lib/x86_64-linux-gnu/xorg/modules/drivers 自编译安装Xorg使用的路径
配置 /usr/share/X11/xorg.conf.d 默认Xorg使用路径
/usr/local/share/X11/xorg.conf.d 自编译安装Xorg使用的路径

2 输入

    Xorg的输入驱动有两套:

kernel -> libevdev -+-> xf86-input-evdev -> X server -> X client                  # xorg-xserver old
                    |-> libinput -+-> Wayland compositor -> Wayland client        # Weston/Wayland compositor
                                  |-> xf86-input-libinput -> X server -> X client # xorg-xserver-1.16+

    各发行版默输入驱动:

发行版 输入驱动
Ubuntu 14.04 evdev
16.04
18.04 libinput
20.04
22.04
UOS Pro V20
银河麒麟 V10

  • 验证Ubuntu20.04同时安装evdev和libinput两种驱动,会优先使用后者!只有将后者的配置文件删除,才会使用前者!
  • Ubuntu18.04编译安装libinput驱动失败,改为安装evdev驱动是成功的!

2.1 evdev

[    19.877] (II) LoadModule: "evdev"
[    19.877] (II) Loading /usr/lib/xorg/modules/input/evdev_drv.so
[    19.961] (II) Module evdev: vendor="X.Org Foundation"
[    19.961]    compiled for 1.18.3, module version = 2.10.1
[    19.961]    Module class: X.Org XInput Driver
[    19.961]    ABI class: X.Org XInput driver, version 22.1

2.2 libinput

[     4.984] (II) LoadModule: "libinput"
[     4.985] (II) Loading /usr/local/lib/x86_64-linux-gnu/xorg/modules/input/libinput_drv.so
[     4.992] (II) Module libinput: vendor="X.Org Foundation"
[     4.992]    compiled for 1.20.13, module version = 1.3.0
[     4.992]    Module class: X.Org XInput Driver
[     4.992]    ABI class: X.Org XInput driver, version 24.1

3 显示

    不同虚拟机/物理机的显卡驱动如下表所示:

虚拟机/物理机 显卡 系统 驱动 Mesa3D 说明
内核 应用 实现 DRI
VirtualBox7.0 VMSVGA Ubuntu14.04 vmwgfx vmware_drv.so VMware SVGA3D vmwgfx_dri.so 启动3D加速正常
VBoxVGA vboxvideo vboxvideo_drv.so VMware llvmpipe swrast_dri.so 必须禁用3D加速才可以切换到该显卡。
VBoxSVGA
QEMU7.0 QXL Ubuntu18.04 qxl qxl_drv.so  
Virtio virtio_gpu modesetting_drv.so Mesa VirGL virtio_gpu_dri.so 需要启动3D加速功能才行
Ramfb fbdev fbdev_drv.so VMware llvmpipe  
Bochs  
OptiPlex7050 Intel Ubuntu22.04 i915 modesetting_drv.so Intel i915_dri.so、
i965_dri.so、
iris_dri.so(默认)
 
Precision3530 Intel 内置屏幕是连接i915显卡上的,因此无法单独使用NVIDIA显卡,只能同时使用。
NVIDIA nvidia-drm nvidia_drv.so NVIDIA

    无论是fbdev还是drm类型的驱动,实现的都是如下结构:

typedef struct _DriverRec {
    int driverVersion;
    const char *driverName;
    void (*Identify) (int flags);
    Bool (*Probe) (struct _DriverRec * drv, int flags); // probe方法1:这是旧方法,其它方法都不支持或失败了才会用
    const OptionInfoRec *(*AvailableOptions) (int chipid, int bustype);
    void *module;
    int refCount;
    xorgDriverFuncProc *driverFunc;
    const struct pci_id_match *supported_devices;
    // probe方法2:其次使用
    Bool (*PciProbe) (struct _DriverRec * drv, int entity_num, struct pci_device * dev, intptr_t match_data);
    // probe方法3:最优先使用
    Bool (*platformProbe) (struct _DriverRec * drv, int entity_num, int flags, struct xf86_platform_device * dev, intptr_t match_data);
} DriverRec, *DriverPtr;
// @file: xorg-server-1.20.13/hw/xfree86/common/xf86str.h

    上述结构体定义了3种probe方法,不同驱动选择不同的方式。

参考资料

[1]Screen Tearing on Ubuntu Xorg 20.04 with Intel Graphics
[2]failed to create screen resources (EE)
[3]解决Ubuntu系统/usr/lib/xorg/Xorg占用显卡内存问题
[4]一切皆文件:强化学习的 Xorg 虚拟环境(多显卡配置)
[5]报错:libtool: Version mismatch error. This is libtool 2.4.6解决
[6]Nvidia显卡在ubuntu下xorg.conf 配置

文章来自专栏

云桌面

13 篇文章 1 订阅
0 评论
0/1000
评论(0) 发表评论
  • 0
    点赞
  • 0
    收藏
  • 0
    评论