安装 S3000 2.5.0(Kylin)
安装驱动依赖包
安装 dkms 依赖包
yum install dkms
安装驱动
安装驱动
根据系统架构获取相应驱动包,并安装,以 arm 版本为例:
rpm -ivh musa_2.5.0-server-Kylin_arm64.rpm
驱动安装后,可以重启操作系统使驱动加载,也可以不重启系统使驱动加载。
重启系统加载驱动
shutdown -r now
不重启系统加载驱动
不重启系统,则需要将当前的相关业务停止,并停止 Xorg,在驱动安装后,重新加载 kmd。
停止正在运行相关的业务,停止Xorg
killall Xorg
service lightdm stop
卸载已经加载的 kmd 模块
rmmod mtgpu
查看是否成功卸载 mtgpu
lsmod |grep mtgpu
重新加载 kmd
modprobe mtgpu
查看是否成功加载 mtgpu
lsmod |grep mtgpu
更换驱动
更换驱动,也支持不重启操作系统使驱动加载。更换驱动前需要停止相关业务,卸载原有驱动,安装新驱动,重新加载驱动。具体操作如下:
停止正在运行相关的业务,停止Xorg
pkill Xorg
service lightdm stop
卸载已经安装的驱动
rpm -e $(rpm -qa |grep musa)
安装新版本的驱动,以arm版本为例。
rpm -ivh musa_2.5.0-server-Kylin_arm64.rpm
卸载已经加载的kmd模块
rmmod mtgpu
查看是否成功卸载mtgpu
lsmod |grep mtgpu
重新加载kmd
modprobe mtgpu
查看是否成功加载mtgpu
lsmod |grep mtgpu
配置 Xorg
配置 Xorg 需要修改配置文件,然后重启 Xorg 生效。
配置 xorg.conf
服务器环境一般存在集显,当安装 MT 显卡用作图形渲染时,则需要配置多显卡的 Xorg。通过这样的配置,支持集显用作 BMC 远程桌面显示,同时MT显卡可以用作图形渲染。
Xorg 的配置路径为 /etc/X11/xorg.conf,配置主要包括集显的配置,MT 显卡配置和公共部分配置。集显和 MT 显卡的配置主要由 Device,Monitor,Screen 组成,公共部分配置由 OutputClass,ServerLayout,ServerFlags 组成。
集显配置
如果集显用作 BMC 远程桌面显示,则集显做为主显,Identifier 的编号都为 0,DISPLAY 为:0.0。
Device配置项说明:
- Identifier 指定 Device 的编号,如果集显做为主显,编号为 Video Device0。
- Driver 指定集显的驱动,设置为 “modesetting”。
- BusID:指定集显的 pcie busid。使用 lspci 获取集显的 pcie 地址,lspci 输出的地址为 16 进制,BusID 需要配置成 10 进制,需要将 16 进制转为10进制;另外 lspci 获取的地址分隔符为“.”,BusID 的分隔符 为“:”。例如使用lspci获取pcie的地址为:“05:00.0” ,配置项则为"PCI:5:00:0"
使用 lspci 获取显卡的 PCIE 地址
# lspci | grep -E 'VGA|3D|Display'
02:00.0 VGA compatible controller: Matrox Electronics Systems Ltd. MGA G200e [Pilot] ServerEngines (SEP1) (rev 42)
19:00.0 3D controller: Moore Threads Technology Co.,Ltd MTT S3000
1a:00.0 3D controller: Moore Threads Technology Co.,Ltd MTT S3000
1b:00.0 3D controller: Moore Threads Technology Co.,Ltd MTT S3000
1c:00.0 3D controller: Moore Threads Technology Co.,Ltd MTT S3000
b3:00.0 3D controller: Moore Threads Technology Co.,Ltd MTT S3000
b4:00.0 3D controller: Moore Threads Technology Co.,Ltd MTT S3000
b5:00.0 3D controller: Moore Threads Technology Co.,Ltd MTT S3000
b6:00.0 3D controller: Moore Threads Technology Co.,Ltd MTT S3000
将16进制转为10进制,以“1a”为例:
# echo $((16#1a))
26
Monitor配置项说明:
- Identifier:指定Monitor的编号,如果集显做为主显,编号为Monitor0
Screen配置项说明:
- Identifier:指定 Screen 的编号,如果集显做为主显,编号为 Screen0。
- Monitor:配置 Monitor 部分 Identifier 的值,为 Monitor0。
- Device:配置 Device 部分 Identifier 的值,为 Video Device0。
集显为主显的配置示例:
Section "Device"
Identifier "Video Device0"
Driver "modesetting"
BusID "PCI:5:00:0"
EndSection
Section "Monitor"
Identifier "Monitor0"
EndSection
Section "Screen"
Identifier "Screen0"
Monitor "Monitor0"
Device "Video Device0"
EndSection
MT 显卡配置
MT 的每张显卡也是由 Device,Monitor,Screen 三个 section 组成,有几张卡则有几组 Device,Monitor,Screen。在集显做主显的场景下,MT显卡的 Device,Monitor,Screen 的 Identifier 编号从 1 开始,有几张卡依此类推。第一张MT显卡为 DISPLAY 的:0.1,第二张为 :0.2。
Device配置项说明:
- Identifier 指定 Device 的编号,例如:Video Device1。
- Driver 指定MT显卡的驱动,设置为“mtgpu”
- BusID:指定MT显卡的pcie busid,获取MT显卡的pcie地址。lspci输出的地址为16进制,BusID需要配置成10进制,需要将16进制转为10进制;另外lspci获取的地址分隔符为“.”,BusID的分隔符为“:”。例如使用lspci获取pcie的地址为:01:00.0 ,配置项则为"PCI:1:00:0",具体命令可以参考上节。
Monitor配置项说明:
- Identifier:指定Monitor的编号,例如:Monitor1
- Modeline:指定显示器的显示模式。例如:"1024x768_60.00" 63.50 1024 1072 1176 1328 768 771 775 798 -hsync +vsync
- Option:指定偏好的显示模式,设置为:"PreferredMode" "1024x768_60.00"
注:为了更好的支持集显做为BMC远程显示,将MT显卡和集显的分辨率和刷新率设置为相同。本指导书推荐将ServerLayout部分的sceen是叠加在一起的,如果分辨率不同,会导致分辨率小的屏幕鼠标点击发生偏移。
Screen配置项说明:
- Identifier:指定Screen的编号,如果集显做为主显,编号为Screen1
- Monitor:配置Monitor部分Identifier的值,为Monitor1
- Device:配置Device部分Identifier的值,为Video Device1
示例:
Section "Device"
Identifier "Video Device1"
Driver "mtgpu"
BusID "PCI:1:00:0"
EndSection
Section "Monitor"
Identifier "Monitor1"
Modeline "1024x768_60.00" 63.50 1024 1072 1176 1328 768 771 775 798 -hsync +vsync
Option "PreferredMode" "1024x768_60.00"
EndSection
Section "Screen"
Identifier "Screen1"
Monitor "Monitor1"
Device "Video Device1"
EndSection
公共部分配置
公共部分配置由OutputClass,ServerLayout,ServerFlags组成。其中OutputClass和ServerFlags的配置无需单独修改;ServerLayout将根据配置显卡的数量,包含集显和MT显卡,将屏幕叠加摆放。
OutputClass配置
Section "OutputClass"
Identifier "mtgpu display"
MatchDriver "mtgpu"
EndSection
ServerLayout配置
将所有显卡,包括集显和mtgpu,屏幕叠加摆放。示例中中是将三张卡,一张集显,两张MT显卡叠加摆放。
Section "ServerLayout"
Identifier "Server Layout"
Screen 0 "Screen0" 0 0
Screen 1 "Screen1" 0 0
Screen 2 "Screen2" 0 0
EndSection
ServerFlags配置
Section "ServerFlags"
Option "DefaultServerLayout" "Server Layout"
Option "PrimaryBusDriver" "mtgpu"
Option "AutoAddGPU" "off"
EndSection
完整Xorg配置示例请参考附录。
重启Xorg进程
停止Xorg进程
如果Xorg进程启动,则关闭Xorg进程
pkill Xorg
如果Xorg进程是由lightdm服务启动的,则关闭lightdm进程。
service lightdm stop
启动Xorg进程
如果仅需要Xorg,则直接启动Xorg进程。
Xorg &
如果需要启动窗口管理系统,则使用如下命令
service lightdm start
显示配置
S3000 显卡有 DP 显示接口,可以连接显示器。S3000 可以做为主显,也可以做为副显,两种方式的 Xorg 配置不同。
系统配置检查
S3000 用作显示,需要操作系统配置内核参数 CONFIG_GENERIC_PHY 为 ”y“,如果系统未配置,则需要升级内核版本。
# cat /usr/src/kernels/`uname -r`/.config|grep CONFIG_GENERIC_PHY
CONFIG_GENERIC_PHY=y
驱动配置检查
S3000 用作显示,需要MT显卡驱动加载的 display 参数为 ”mt“,否则无法点亮显示器。以下命令可以检查当前加载驱动的 display 参数:
# cat /sys/module/mtgpu/parameters/display
mt
设置 display 参数可以修改 /etc/modprobe.d/mtgpu.conf 配置文件:
# cat /etc/modprobe.d/mtgpu.conf
options mtgpu display=mt
修改配置后,重启系统生效。
MT显卡作为主显
如果 MT 显卡作为主显,需要修改 /etc/X11/xorg.conf 配置,将其中一张 MT 显卡配置为主显,集显配置配置为副显。具体配置可参考附录 MT显卡作为主显的内容。
修改 Xorg 配置之后需要停止 Xorg 进程,具体请参考重启Xorg进程部分内容。
启动 lightdm,则显示器可点亮。
service lightdm start
注:如果 MT 显卡配置为主显,则 BMC 远程桌面显示为黑屏。
MT 显卡作为副显
安装依赖 gnome-shell
yum install gnome-shell
配置 Xorg
如果 MT 显卡作为副显,集显做为主显,配置 /etc/X11/xorg.conf,具体配置可参考附录集显作为主显部分的内容。
修改 Xorg 配置之后需要停止 Xorg 进程,具体请参考重启Xorg进程部分内容。
启动 lightdm,则显示器可点亮。
service lightdm start
获取桌面权限
通过 BMC 远程登录桌面,运行以下命令获取桌面权限,其中 -u 的参数为 BMC 登录桌面使用的用户,例如使用 root 登录桌面,则 -u 的参数为 root。
sudo -u root DISPLAY=:0.0 xhost +
启动桌面
/etc/X11/xorg.conf 指定和显卡和 Screen一一对应的关系,如果MT显卡对应 Screen1,则对应 display:0.1,如果MT显卡对应 Screen2,则对应 display:0.2,依此类推。
以下命令可以在 display :0.1,display :0.2 上启动桌面
export XAUTHORITY=/var/run/lightdm/root/:0
DISPLAY=:0.1 gnome-shell --replace
DISPLAY=:0.2 gnome-shell --replace
注:这种方式启动桌面具备键鼠和窗口功能。
DirectStream 配置
启动 DirectStream 抓屏编码功能需要在 Xorg 的配置中打开对应的选项,并设置环境变量。
修改 Xorg 配置
修改 /etc/X11/xorg.conf,将每张 mtgpu 的 Device 部分增加 Option, MTFBCAP, true,例如:
Section "Device"
Identifier "Video Device1"
Driver "mtgpu"
BusID "PCI:25:00:0"
Option "MTFBCAP" "true"
EndSection
重启 Xorg 使配置文件生效,参考重启 Xorg 进程部分。
修改分辨率
如果服务器连接了显示器,则直接修改分辨率。如果服务器未连接显示器,需要修改 kmd 的加载方式为 dummy。 检查 driver 的加载模式是否为 mt
cat /sys/module/mtgpu/parameters/display
mt
修改 kmd 的加载模式,然后重启系统。
sudo sed -i 's/=mt/=dummy/' /etc/modprobe.d/mtgpu.conf
查看修改是否成功
cat /etc/modprobe.d/mtgpu.conf
options mtgpu display=dummy
查看指定 Screen 的分辨率
export DISPLAY=:0.1
xrandr
设置指定 Screen 分辨率,“-s” 指定分辨率,“-r” 指定刷新率,以 4K 为例:
export DISPLAY=:0.1
xrandr -s 3840x2160 -r 60
用户权限设置
如果使用非 root 用户抓屏编码,需要增加 video 组和 render 组的权限
sudo usermod -a -G video user
sudo usermod -a -G render user
启动抓屏编码
设置环境变量 arm 版本的环境变量
export LIBVA_DRIVER_NAME=mtgpu
export LIBVA_DRIVERS_PATH=/usr/lib/aarch64-linux-gnu/dri/
x86_64 版本的环境变量
export LIBVA_DRIVER_NAME=mtgpu
export LIBVA_DRIVERS_PATH=/usr/lib/x86_64-linux-gnu/dri/
启动对应 Screen 的抓屏的 app,以 glxgears 为例:
export DISPLAY=:0.1
glxgears -fullscreen
启动抓屏编码
MtCaptureToEncodeDemo -n 9000 -f 60 -s 1 -c 0 -o test
查看抓屏编码demo的用法,更多抓屏编码用法请参考DirectStream API文档。
MtCaptureToEncodeDemo -h
MtCaptureToEncodeDemo: option requires an argument -- 'h'
Usage: MtCaptureToEncodeDemo [options]
Options:
-n <n> Number of frames to capture (default: 1000)
-f <n> Target fps (default: 60)
-o <str> Name of the output file
-x <n> Grab frame start x (default: 0)
-y <n> Grab frame start y (default: 0)
-w <n> Grab frame width (default: screen width)
-h <n> Grab frame height (default: screen height)
-p <n> Src pixel format (0-BGRA; 1-NV12)
-W <n> Dst frame width (default equal w)
-H <n> Dst frame height (default equal h)
-s <n> Select capture screen (default primary)
-c <n> Encode Type (0-h264; 1-h265; default h264)
-b <n> Average bit rate (kbps, default 8000 kbps)
-E <n> Export bitstream to file (0-NO; 1-Yes, default Yes)
-i <n> Show information about DS (0-NO; 1-Yes, default NO)
-m <n> Enable hardware mouse (0-NO; 1-Yes, default No)
-d <n> Use damage mode to capture screen (0-NO; 1-Yes, default NO)
附录
集显作为主显
xorg.conf 配置参考,以下示例中包含一张集显和两张 MT 显卡,三个 Screen 叠加摆放。
# X.Org X server configuration file.
Section "Device"
Identifier "Video Device0"
Driver "modesetting"
BusID "PCI:5:00:0"
EndSection
Section "Monitor"
Identifier "Monitor0"
EndSection
Section "Screen"
Identifier "Screen0"
Monitor "Monitor0"
Device "Video Device0"
EndSection
Section "Device"
Identifier "Video Device1"
Driver "mtgpu"
BusID "PCI:1:00:0"
EndSection
Section "Monitor"
Identifier "Monitor1"
Modeline "1024x768_60.00" 63.50 1024 1072 1176 1328 768 771 775 798 -hsync +vsync
Option "PreferredMode" "1024x768_60.00"
EndSection
Section "Screen"
Identifier "Screen1"
Monitor "Monitor1"
Device "Video Device1"
EndSection
Section "Device"
Identifier "Video Device2"
Driver "mtgpu"
BusID "PCI:129:00:0"
EndSection
Section "Monitor"
Identifier "Monitor2"
Modeline "1024x768_60.00" 63.50 1024 1072 1176 1328 768 771 775 798 -hsync +vsync
Option "PreferredMode" "1024x768_60.00"
EndSection
Section "Screen"
Identifier "Screen2"
Monitor "Monitor2"
Device "Video Device2"
EndSection
Section "OutputClass"
Identifier "mtgpu display"
MatchDriver "mtgpu"
EndSection
Section "ServerLayout"
Identifier "Server Layout"
Screen 0 "Screen0" 0 0
Screen 1 "Screen1" 0 0
Screen 2 "Screen2" 0 0
EndSection
Section "ServerFlags"
Option "DefaultServerLayout" "Server Layout"
Option "PrimaryBusDriver" "mtgpu"
Option "AutoAddGPU" "off"
EndSection
MT 显卡作为主显
xorg.conf 配置参考,以下示例中包含一张集显和两张 MT 显卡,三个 Screen 叠加摆放。
# X.Org X server configuration file.
Section "Device"
Identifier "Video Device0"
Driver "mtgpu"
BusID "PCI:1:00:0"
EndSection
Section "Monitor"
Identifier "Monitor0"
Modeline "1024x768_60.00" 63.50 1024 1072 1176 1328 768 771 775 798 -hsync +vsync
Option "PreferredMode" "1024x768_60.00" EndSection
Section "Screen"
Identifier "Screen0"
Monitor "Monitor0"
Device "Video Device0"
EndSection
Section "Device"
Identifier "Video Device1"
Driver "modesetting"
BusID "PCI:5:00:0"
EndSection
Section "Monitor"
Identifier "Monitor1"
EndSection
Section "Screen"
Identifier "Screen1"
Monitor "Monitor1"
Device "Video Device1"
EndSection
Section "Device"
Identifier "Video Device2"
Driver "mtgpu"
BusID "PCI:129:00:0"
EndSection
Section "Monitor"
Identifier "Monitor2"
Modeline "1024x768_60.00" 63.50 1024 1072 1176 1328 768 771 775 798 -hsync +vsync
Option "PreferredMode" "1024x768_60.00"
EndSection
Section "Screen"
Identifier "Screen2"
Monitor "Monitor2"
Device "Video Device2"
EndSection
Section "OutputClass"
Identifier "mtgpu display"
MatchDriver "mtgpu"
EndSection
Section "ServerLayout"
Identifier "Server Layout"
Screen 0 "Screen0" 0 0
Screen 1 "Screen1" 0 0
Screen 2 "Screen2" 0 0
EndSection
Section "ServerFlags"
Option "DefaultServerLayout" "Server Layout"
Option "PrimaryBusDriver" "mtgpu"
Option "AutoAddGPU" "off"
EndSection

