硬件软件系统方案应用范例智能车大赛技术支持学习园地关于我们恩智浦官网

Wayland & Weston 显示服务启动log分析启动流程

Wayland & Weston 显示服务启动log分析启动流程

前言

众所周知,i.MX系列芯片在多媒体领域有着广泛的应用。基于此点,我们在之前的系列中介绍了多种不同的显示接口及GStreamer管道的搭建方法。本文我们将分析说明显示部分的另一重要组成部分 -- Wayland & Weston。

执行步骤:

1        预定板子:

打开云实验室网页,点击右上角登陆按钮输入账号密码。

https://aiotcloud.nxp.com.cn/

登陆后依次点击硬件 -> i.MX 9 系列开发板

                   

找到i.MX 93 EVK “可立即使用”状态,并且外设中有DY1212-4856 LVDS屏幕的板子,如下图点击“i.MX93EVK #2”进入。

然后点击“立即预定“按钮:

 

选择立即使用,填写使用结束时间

 

然后进入我的预定,

 

点击右侧蓝色“调试”按钮,之后就进入到板子的实物页面和系统启动log页面。到此为止,板子预定并且启动成功。

 

默认用户名为“root”,默认密码为“root


Wayland & Weston 的应用

在之前的文章中,手把手教你利用systemd设置开机自启动,我们介绍了systemd是一种用于 Linux 操作系统的初始化系统和服务管理器,负责启动和管理系统中各种服务和进程。Weston同样可以通过systemd的service在Kernel启动过程中进行自启动,我们可以通过systemctl list-unit-files --type=service 命令查看Weston所对应的service名称:

随后,可以找到其启动服务对应的文件路径为 /lib/systemd/system/weston.service。从中可以看到Weston启动的依赖项及启动顺序,其中Service部分定义了启动时所执行文件及log保存目录:

ExecStart=/usr/bin/weston --log=${XDG_RUNTIME_DIR}/weston.log --modules=systemd-notify.so

通过Weston的启动log (/run/user/0/weston.log),我们可以对Weston的启动进行进一步的分析,可以看到BSP及Weston所使用的的对应版本号。针对i.MX93, Lf 6.1.55 将搭配 11.0.0.3 版本Weston使用:

[09:49:27.620] weston 11.0.3
https://wayland.freedesktop.org
Bug reports to: https://gitlab.freedesktop.org/wayland/weston/issues/
Build: 11.0.3-54-gba6a8a02+
[09:49:27.621] Command line: /usr/bin/weston --log=/run/user/0/weston.log --modules=systemd-notify.so
[09:49:27.621] OS: Linux, 6.1.55+gde8d5a614f8f, #1 SMP PREEMPT Fri Mar  8 07:53:09 UTC 2024, aarch64

随后,我们可以看到其调用了配置文件,weston.ini,进行显示相关配置。在之前的多篇演示示例中,我们便是通过设置weston.ini实现多屏同显及相应分辨率的设置。

[09:49:27.623] Using config file '/etc/xdg/weston/weston.ini'

紧接着可以看到Weston默认使用DRM作为后端(backend)。该模式下,Wayland输出界面直接通过/dev/dri/card0节点来显示:

[09:49:27.631] Loading module '/usr/lib/libweston-11/drm-backend.so'
[09:49:27.637] initializing drm backend
[09:49:27.637] Trying logind launcher...
[09:49:27.650] logind: session control granted
[09:49:27.663] using /dev/dri/card0
[09:49:27.663] DRM: supports atomic modesetting
[09:49:27.663] DRM: does not support GBM modifiers
[09:49:27.663] DRM: supports picture aspect ratio

我们使用i.MX93官方配套的DSI屏幕 (MX8-DSI-OLED1A)作为显示配置,其所配套的设备树为 'imx93-11x11-evk-rm67199.dtb'。从DTS中我们可以看到,这款DSI屏幕配置触屏,即Goodix:

&lpi2c1 {
touchscreen@14 {
compatible = "goodix,gt1151";
reg = <0x14>;
interrupt-parent = <&pcal6524>;
interrupts = <7 IRQ_TYPE_EDGE_FALLING>;
irq-gpios = <&pcal6524 7 GPIO_ACTIVE_HIGH>;
reset-gpios = <&adp5585gpio 9 GPIO_ACTIVE_HIGH>;
edge-failling-trigger;
touchscreen-size-x = <1080>;
touchscreen-size-y = <1920>;
};
};

因此,我们可以在Weston的log中看到触控事件的注册。关于触控,键盘及鼠标在Weston中的输入设置,我们将在未来的理论篇中通过代码详细说明:

[09:49:27.804] event1  - Goodix Capacitive TouchScreen: is tagged by udev as: Keyboard Touchscreen
[09:49:27.805] event1  - Goodix Capacitive TouchScreen: device is a keyboard
[09:49:27.805] event1  - Goodix Capacitive TouchScreen: device is a touch device
[09:49:27.813] event2  - WM8962 Beep Generator: not tagged as supported input device
[09:49:27.813] event2  - not using input device '/dev/input/event2'
[09:49:27.822] event0  - 44440000.bbnsm:pwrkey: is tagged by udev as: Keyboard
[09:49:27.822] event0  - 44440000.bbnsm:pwrkey: device is a keyboard
[09:49:27.863] Touchscreen - Goodix Capacitive TouchScreen - /sys/devices/platform/soc@0/44000000.bus/44340000.i2c/i2c-0/0-0014/input/input1/event1
[09:49:27.863] libinput: configuring device "Goodix Capacitive TouchScreen".
[09:49:27.863] input device event1 has no enabled output associated (none named), skipping calibration for now.
[09:49:27.863] libinput: configuring device "44440000.bbnsm:pwrkey".

随后,便是真正的显示输出部分,我们这里使用的DSI屏幕将作为Weston显示输出

[09:49:27.864] DRM: head 'DSI-1' updated, connector 35 is connected, EDID make 'unknown', model 'unknown', serial 'unknown'
               Supported EOTF modes: SDR
[09:49:27.864] DRM: head 'DSI-1' found, connector 35 is connected, EDID make 'unknown', model 'unknown', serial 'unknown'
               Supported EOTF modes: SDR
[09:49:27.864] Registered plugin API 'weston_drm_output_api_v1' of size 32
[09:49:27.864] Color manager: no-op
[09:49:27.864] Module '/usr/lib/libgbm.so' already loaded
[09:49:27.864] Failed to lookup init function: /usr/lib/libgbm.so.1: undefined symbol: gbm_surface_get_in_fence_fd
[09:49:27.865] Output 'DSI-1' attempts EOTF mode: SDR
[09:49:27.865] Output 'DSI-1' using color profile: built-in default sRGB SDR profile
[09:49:27.874] Initialized backlight for head 'DSI-1', device /sys/class/backlight/4ae10000.dsi.0
[09:49:27.874] Output DSI-1 (crtc 33) video modes:
               1080x1920@55.0, preferred, current, 121.0 MHz
[09:49:27.874] associating input device event1 with output DSI-1 (none by udev)
[09:49:27.875] associating input device event0 with output DSI-1 (none by udev)
[09:49:27.875] Output 'DSI-1' enabled with head(s) DSI-1

log中同时包含DSI显示的部分信息,其connector编号为‘35’,输出显示为1080x1920@55.0 及其他相关信息。这部分信息我们同样可以通过modetest -M imx-drm 命令进行确认。在最后的部分,从log我们可以看到窗口管理(shell)相关的模块被加载。这里可以看到负责系统全局界面的weston-desktop-shell及软键盘面板的weston-keyboard由Weston加载并启动:

[09:49:27.875] Compositor capabilities:
               arbitrary surface rotation: yes
               screen capture uses y-flip: yes
               cursor planes: yes
               arbitrary resolutions: no
               view mask clipping: yes
               explicit sync: yes
               color operations: no
               presentation clock: CLOCK_MONOTONIC, id 1
               presentation clock resolution: 0.000000001 s
[09:49:27.876] Loading module '/usr/lib/weston/desktop-shell.so'
[09:49:27.879] Loading module '/usr/lib/libweston-11/xwayland.so'
[09:49:27.913] Registered plugin API 'weston_xwayland_v1' of size 32
[09:49:27.913] Registered plugin API 'weston_xwayland_surface_v1' of size 16
[09:49:27.913] xserver listening on display :0
[09:49:27.914] Loading module '/usr/lib/weston/systemd-notify.so'
[09:49:27.915] info: add 1 socket(s) provided by systemd
[09:49:27.915] launching '/usr/libexec/weston-keyboard'
[09:49:27.918] launching '/usr/libexec/weston-desktop-shell'

在Weston通过自启动服务成功启动之后,Weston桌面便会显示到DSI屏幕上。使用场景方面,例如之前GStreamer文章中,我们使用waylandsink做显示输出至Weston桌面中显示视频画面。我们可以使用以下命令将通过摄像头拍摄的视频使用waylandsink元素将视频画面显示在Weston桌面中。

gst-launch-1.0 v4l2src device=/dev/video3 ! video/x-raw,format=YUY2,width=1920,height=1080 ! waylandsink