RK3568学习笔记5:屏幕操作【Weston】相关

Dr.Guo
发布于 2024-01-15 / 2984 阅读
0
0

RK3568学习笔记5:屏幕操作【Weston】相关

Weston是Wayland开源显示协议的官方参考实现,Rockchip Buildroot SDK的显示服务默认使用Weston 10.0.0 drm后端。

参考资料:Rockchip Buildroot Weston 开发指南

一、介绍

Weston 配置方式有5种

  1. 启动参数

即启动Weston时命令所带参数,如weston --tty=2,位于/etc/init.d/S49weston,对应SDK代码中位置为:buildroot/package/weston/S49weston

  1. weston.ini文件【一般方法】

位于/etc/xdg/weston/weston.ini及/etc/xdg/weston/weston.ini.d/下的.ini文件,对应SDK代码中位置如:
buildroot/board/rockchip/common/base/etc/xdg/weston/weston.ini

  1. 特殊环境变量

此类环境变量一般设置在/etc/profile.d/weston.sh,对应SDK代码中位置为:buildroot/package/weston/weston.sh.

  1. 动态配置文件

对于drm后端显示功能,Buildroot SDK中的Weston提供一些动态配置支持,默认路径为/tmp/.weston_drm.conf,可以通过环境变量WESTON_DRM_CONFIG指定。

  1. udev rules

Weston中输入设备的部分配置需要通过udev rules。

二、相关配置

2.1 屏幕区分

  1. Weston 指令
root@ATK-DLRK356X:~# weston&
[2] 938
root@ATK-DLRK356X:~# Date: 2024-01-15 CST
[11:30:49.920] weston 10.0.0
               https://wayland.freedesktop.org
               Bug reports to: https://gitlab.freedesktop.org/wayland/weston/issues/
               Build: 10.0.0
[11:30:49.920] Command line: weston
[11:30:49.920] OS: Linux, 4.19.232, #1 SMP Tue Nov 28 12:38:24 CST 2023, aarch64
[11:30:49.920] Flight recorder: enabled
[11:30:49.921] Using config file '/etc/xdg/weston/weston.ini'
[11:30:49.921] Output repaint window is -1 ms maximum.
[11:30:49.921] Loading module '/usr/lib/libweston-10/drm-backend.so'
[11:30:49.922] initializing drm backend
[11:30:49.922] Entering mirror mode.
[11:30:49.922] Trying weston_launch launcher...
[11:30:49.922] could not get launcher fd from env
[11:30:49.922] Trying direct launcher...
[11:30:49.924] using /dev/dri/card0
[11:30:49.924] DRM: does not support atomic modesetting
[11:30:49.924] DRM: does not support GBM modifiers
[11:30:49.924] DRM: supports picture aspect ratio
[11:30:49.925] Loading module '/usr/lib/libweston-10/gl-renderer.so'
[11:30:49.926] EGL client extensions: EGL_EXT_client_extensions
               EGL_EXT_platform_base EGL_KHR_client_get_all_proc_addresses
               EGL_KHR_platform_gbm EGL_KHR_platform_wayland
               EGL_EXT_platform_wayland
[11:30:49.938] EGL version: 1.4 Bifrost-"g2p0-01eac0"
[11:30:49.938] EGL vendor: ARM
[11:30:49.938] EGL client APIs: OpenGL_ES
[11:30:49.938] EGL extensions: EGL_WL_bind_wayland_display
               EGL_KHR_partial_update EGL_KHR_config_attribs EGL_KHR_image
               EGL_KHR_image_base EGL_KHR_fence_sync EGL_KHR_wait_sync
               EGL_KHR_gl_colorspace EGL_KHR_get_all_proc_addresses
               EGL_IMG_context_priority EGL_KHR_no_config_context
               EGL_EXT_image_dma_buf_import
               EGL_EXT_image_dma_buf_import_modifiers EGL_EXT_yuv_surface
               EGL_EXT_pixel_format_float EGL_ARM_pixmap_multisample_discard
               EGL_ARM_implicit_external_sync EGL_KHR_gl_texture_2D_image
               EGL_KHR_gl_renderbuffer_image EGL_KHR_create_context
               EGL_KHR_surfaceless_context EGL_KHR_gl_texture_cubemap_image
               EGL_EXT_image_gl_colorspace EGL_EXT_create_context_robustness
[11:30:49.939] warning: Disabling render GPU timeline and explicit synchronization due to missing EGL_ANDROID_native_fence_sync extension
[11:30:49.939] EGL_KHR_surfaceless_context available
[11:30:49.949] GL version: OpenGL ES 3.2 v1.g2p0-01eac0.a728b64d6b9d8cadf7f54eb4e167984c
[11:30:49.949] GLSL version: OpenGL ES GLSL ES 3.20
[11:30:49.949] GL vendor: ARM
[11:30:49.949] GL renderer: Mali-G52
[11:30:49.949] GL extensions: GL_ARM_rgba8 GL_ARM_mali_shader_binary
               GL_OES_depth24 GL_OES_depth_texture
               GL_OES_depth_texture_cube_map GL_OES_packed_depth_stencil
               GL_OES_rgb8_rgba8 GL_EXT_read_format_bgra
               GL_OES_compressed_paletted_texture
               GL_OES_compressed_ETC1_RGB8_texture GL_OES_standard_derivatives
               GL_OES_EGL_image GL_OES_EGL_image_external
               GL_OES_EGL_image_external_essl3 GL_OES_EGL_sync
               GL_OES_texture_npot GL_OES_vertex_half_float
               GL_OES_required_internalformat GL_OES_vertex_array_object
               GL_OES_mapbuffer GL_EXT_texture_format_BGRA8888
               GL_EXT_texture_rg GL_EXT_texture_type_2_10_10_10_REV
               GL_OES_fbo_render_mipmap GL_OES_element_index_uint
               GL_EXT_shadow_samplers GL_OES_texture_compression_astc
               GL_KHR_texture_compression_astc_ldr
               GL_KHR_texture_compression_astc_hdr
               GL_KHR_texture_compression_astc_sliced_3d
               GL_EXT_texture_compression_astc_decode_mode
               GL_EXT_texture_compression_astc_decode_mode_rgb9e5 GL_KHR_debug
               GL_EXT_occlusion_query_boolean GL_EXT_disjoint_timer_query
               GL_EXT_blend_minmax GL_EXT_discard_framebuffer
               GL_OES_get_program_binary GL_OES_texture_3D
               GL_EXT_texture_storage GL_EXT_multisampled_render_to_texture
               GL_EXT_multisampled_render_to_texture2
               GL_OES_surfaceless_context GL_OES_texture_stencil8
               GL_EXT_shader_pixel_local_storage
               GL_ARM_shader_framebuffer_fetch
               GL_ARM_shader_framebuffer_fetch_depth_stencil
               GL_ARM_mali_program_binary GL_EXT_sRGB
               GL_EXT_sRGB_write_control GL_EXT_texture_sRGB_decode
               GL_EXT_texture_sRGB_R8 GL_EXT_texture_sRGB_RG8
               GL_KHR_blend_equation_advanced
               GL_KHR_blend_equation_advanced_coherent
               GL_OES_texture_storage_multisample_2d_array
               GL_OES_shader_image_atomic GL_EXT_robustness
               GL_EXT_draw_buffers_indexed GL_OES_draw_buffers_indexed
               GL_EXT_texture_border_clamp GL_OES_texture_border_clamp
               GL_EXT_texture_cube_map_array GL_OES_texture_cube_map_array
               GL_OES_sample_variables GL_OES_sample_shading
               GL_OES_shader_multisample_interpolation GL_EXT_shader_io_blocks
               GL_OES_shader_io_blocks GL_EXT_tessellation_shader
               GL_OES_tessellation_shader GL_EXT_primitive_bounding_box
               GL_OES_primitive_bounding_box GL_EXT_geometry_shader
               GL_OES_geometry_shader GL_ANDROID_extension_pack_es31a
               GL_EXT_gpu_shader5 GL_OES_gpu_shader5 GL_EXT_texture_buffer
               GL_OES_texture_buffer GL_EXT_copy_image GL_OES_copy_image
               GL_EXT_shader_non_constant_global_initializers
               GL_EXT_color_buffer_half_float GL_EXT_color_buffer_float
               GL_EXT_YUV_target GL_OVR_multiview GL_OVR_multiview2
               GL_OVR_multiview_multisampled_render_to_texture
               GL_KHR_robustness GL_KHR_robust_buffer_access_behavior
               GL_EXT_draw_elements_base_vertex
               GL_OES_draw_elements_base_vertex GL_EXT_buffer_storage
               GL_EXT_texture_filter_anisotropic
               GL_ARM_texture_unnormalized_coordinates
[11:30:49.975] GL ES 3.2 - renderer features:
               read-back format: BGRA
               wl_shm sub-image to texture: yes
               EGL Wayland extension: yes
[11:30:49.976] couldn't fstat launcher tty: Bad file descriptor
[11:30:49.983] event5  - adc-keys: is tagged by udev as: Keyboard
[11:30:49.984] event5  - adc-keys: device is a keyboard
[11:30:49.985] event1  - rk805 pwrkey: is tagged by udev as: Keyboard
[11:30:49.985] event1  - rk805 pwrkey: device is a keyboard
[11:30:49.987] event2  - dsi1_ts_gt9xx: is tagged by udev as: Touchscreen
[11:30:49.987] event2  - dsi1_ts_gt9xx: device is a touch device
[11:30:49.989] event4  - proximity: not tagged as supported input device
[11:30:50.008] event4  - not using input device '/dev/input/event4'
[11:30:50.100] Color manager: no-op
[11:30:50.100] Output 'DSI-1' using color profile: built-in default sRGB SDR profile
[11:30:50.100] Chosen EGL config details: id:   9 rgba: 8 8 8 0 buf: 24 dep:  0 stcl: 0 int: 0-1 type: win|pbf|swap_preserved vis_id: XRGB8888 (0x34325258)
[11:30:50.100] Output DSI-1 (crtc 115) video modes:
               1080x1920@59.8, preferred, current, 136.0 MHz
[11:30:50.101] associating input device event5 with output DSI-1 (none by udev)
[11:30:50.101] associating input device event1 with output DSI-1 (none by udev)
[11:30:50.101] associating input device event2 with output DSI-1 (none by udev)
[11:30:50.101] associating input device event0 with output DSI-1 (none by udev)
[11:30:50.101] Output 'DSI-1' enabled with head(s) DSI-1
[11:30:50.101] Compositor capabilities:
               arbitrary surface rotation: yes
               screen capture uses y-flip: yes
               cursor planes: no
               arbitrary resolutions: no
               view mask clipping: yes
               explicit sync: no
               color operations: no
               presentation clock: CLOCK_MONOTONIC, id 1
               presentation clock resolution: 0.000000001 s
[11:30:50.102] libwayland: unable to lock lockfile /var/run/wayland-0.lock, maybe another compositor is running
[11:30:50.102] libwayland: unable to lock lockfile /var/run/wayland-1.lock, maybe another compositor is running
[11:30:50.102] Loading module '/usr/lib/weston/desktop-shell.so'
[11:30:50.103] launching '/usr/libexec/weston-keyboard'
[11:30:50.105] Note: support for the deprecated wl_shell interface is disabled. If a legacy client still needs it, it can be re-enabled by passing -Ddeprecated-wl-shell=true to Meson when building Weston.
[11:30:50.106] launching '/usr/libexec/weston-desktop-shell'
could not load cursor 'dnd-move'
could not load cursor 'dnd-move'
could not load cursor 'dnd-copy'
could not load cursor 'dnd-copy'
could not load cursor 'dnd-none'
could not load cursor 'dnd-none'
xkbcommon: ERROR: couldn't find a Compose file for locale "en_US.UTF-8"
could not create XKB compose table for locale 'en_US.UTF-8'.  Disabiling compose
xkbcommon: ERROR: couldn't find a Compose file for locale "en_US.UTF-8"
could not create XKB compose table for locale 'en_US.UTF-8'.  Disabiling compose

从输出信息中可以看到连接的屏幕

3. wayland-info指令

root@ATK-DLRK356X:~# wayland-info
interface: 'wl_compositor',                              version:  4, name:  1
interface: 'wl_subcompositor',                           version:  1, name:  2
interface: 'wp_viewporter',                              version:  1, name:  3
interface: 'zxdg_output_manager_v1',                     version:  2, name:  4
        xdg_output_v1
                output: 15
                name: 'DSI-1'
                logical_x: 0, logical_y: 0
                logical_width: 1080, logical_height: 1920
interface: 'wp_presentation',                            version:  1, name:  5
        presentation clock id: 1 (CLOCK_MONOTONIC)
interface: 'zwp_relative_pointer_manager_v1',            version:  1, name:  6
interface: 'zwp_pointer_constraints_v1',                 version:  1, name:  7
interface: 'zwp_input_timestamps_manager_v1',            version:  1, name:  8
interface: 'wl_data_device_manager',                     version:  3, name:  9
interface: 'wl_shm',                                     version:  1, name: 10
        formats: 'XB30'(0x30334258) 'AB30'(0x30334241) 'XYUV'(0x56555958) 'YUYV'(0x56595559) 'NV16'(0x3631564e) 'NV12'(0x3231564e) 'YU12'(0x32315559) RGB565 XRGB8888 ARGB8888
interface: 'mali_buffer_sharing',                        version:  4, name: 11
interface: 'wl_seat',                                    version:  7, name: 12
        name: default
        capabilities: keyboard touch
        keyboard repeat rate: 40
        keyboard repeat delay: 400
interface: 'zwp_linux_dmabuf_v1',                        version:  3, name: 13
        formats:
        'Q401'(0x31303451), modifier: 0x0000000000000000
        'Q410'(0x30313451), modifier: 0x0000000000000000
        'YV24'(0x34325659), modifier: 0x0000000000000000
        'YU24'(0x34325559), modifier: 0x0000000000000000
        'NV15'(0x3531564e), modifier: 0x0000000000000000
        'Y410'(0x30313459), modifier: 0x0000000000000000
        'Y0L2'(0x324c3059), modifier: 0x0000000000000000
        'YU10'(0x30315559), modifier: 0x0000000000000000
        'YU08'(0x38305559), modifier: 0x0800000000000142
        'YU08'(0x38305559), modifier: 0x0800000000000042
        'YU08'(0x38305559), modifier: 0x0800000000000141
        'YU08'(0x38305559), modifier: 0x0800000000000041
        'YU08'(0x38305559), modifier: 0x0000000000000000
        'YU12'(0x32315559), modifier: 0x0000000000000000
        'YV12'(0x32315659), modifier: 0x0000000000000000
        'P210'(0x30313250), modifier: 0x0000000000000000
        'P010'(0x30313050), modifier: 0x0000000000000000
        'Y210'(0x30313259), modifier: 0x0800000000000142
        'Y210'(0x30313259), modifier: 0x0800000000000042
        'Y210'(0x30313259), modifier: 0x0800000000000141
        'Y210'(0x30313259), modifier: 0x0800000000000041
        'Y210'(0x30313259), modifier: 0x0000000000000000
        'NV16'(0x3631564e), modifier: 0x0000000000000000
        'NV21'(0x3132564e), modifier: 0x0000000000000000
        'NV12'(0x3231564e), modifier: 0x0000000000000000
        'YUYV'(0x56595559), modifier: 0x0800000000000142
        'YUYV'(0x56595559), modifier: 0x0800000000000042
        'YUYV'(0x56595559), modifier: 0x0800000000000141
        'YUYV'(0x56595559), modifier: 0x0800000000000041
        'YUYV'(0x56595559), modifier: 0x0000000000000000
        'AYUV'(0x56555941), modifier: 0x0000000000000000
        'GR32'(0x32335247), modifier: 0x0000000000000000
        'R8  '(0x20203852), modifier: 0x0800000000000142
        'R8  '(0x20203852), modifier: 0x0800000000000042
        'R8  '(0x20203852), modifier: 0x0800000000000361
        'R8  '(0x20203852), modifier: 0x0800000000000341
        'R8  '(0x20203852), modifier: 0x0800000000000061
        'R8  '(0x20203852), modifier: 0x0800000000000041
        'R8  '(0x20203852), modifier: 0x0000000000000000
        'AB4H'(0x48344241), modifier: 0x0000000000000000
        'AB30'(0x30334241), modifier: 0x0800000000000372
        'AB30'(0x30334241), modifier: 0x0800000000000362
        'AB30'(0x30334241), modifier: 0x0800000000000072
        'AB30'(0x30334241), modifier: 0x0800000000000062
        'AB30'(0x30334241), modifier: 0x0800000000000371
        'AB30'(0x30334241), modifier: 0x0800000000000351
        'AB30'(0x30334241), modifier: 0x0800000000000361
        'AB30'(0x30334241), modifier: 0x0800000000000341
        'AB30'(0x30334241), modifier: 0x0800000000000071
        'AB30'(0x30334241), modifier: 0x0800000000000051
        'AB30'(0x30334241), modifier: 0x0800000000000061
        'AB30'(0x30334241), modifier: 0x0800000000000041
        'AB30'(0x30334241), modifier: 0x0000000000000000
        'BG24'(0x34324742), modifier: 0x0800000000000372
        'BG24'(0x34324742), modifier: 0x0800000000000362
        'BG24'(0x34324742), modifier: 0x0800000000000072
        'BG24'(0x34324742), modifier: 0x0800000000000062
        'BG24'(0x34324742), modifier: 0x0800000000000371
        'BG24'(0x34324742), modifier: 0x0800000000000351
        'BG24'(0x34324742), modifier: 0x0800000000000361
        'BG24'(0x34324742), modifier: 0x0800000000000341
        'BG24'(0x34324742), modifier: 0x0800000000000071
        'BG24'(0x34324742), modifier: 0x0800000000000051
        'BG24'(0x34324742), modifier: 0x0800000000000061
        'BG24'(0x34324742), modifier: 0x0800000000000041
        'BG24'(0x34324742), modifier: 0x0000000000000000
        'RG24'(0x34324752), modifier: 0x0000000000000000
        'BA24'(0x34324142), modifier: 0x0000000000000000
        'RA24'(0x34324152), modifier: 0x0000000000000000
        'AB24'(0x34324241), modifier: 0x0800000000000372
        'AB24'(0x34324241), modifier: 0x0800000000000362
        'AB24'(0x34324241), modifier: 0x0800000000000072
        'AB24'(0x34324241), modifier: 0x0800000000000062
        'AB24'(0x34324241), modifier: 0x0800000000000371
        'AB24'(0x34324241), modifier: 0x0800000000000351
        'AB24'(0x34324241), modifier: 0x0800000000000361
        'AB24'(0x34324241), modifier: 0x0800000000000341
        'AB24'(0x34324241), modifier: 0x0800000000000071
        'AB24'(0x34324241), modifier: 0x0800000000000051
        'AB24'(0x34324241), modifier: 0x0800000000000061
        'AB24'(0x34324241), modifier: 0x0800000000000041
        'AB24'(0x34324241), modifier: 0x0000000000000000
        'AR24'(0x34325241), modifier: 0x0000000000000000
        'BX24'(0x34325842), modifier: 0x0000000000000000
        'RX24'(0x34325852), modifier: 0x0000000000000000
        'XB24'(0x34324258), modifier: 0x0000000000000000
        'XR24'(0x34325258), modifier: 0x0000000000000000
        'BA12'(0x32314142), modifier: 0x0000000000000000
        'RA12'(0x32314152), modifier: 0x0000000000000000
        'AB12'(0x32314241), modifier: 0x0800000000000152
        'AB12'(0x32314241), modifier: 0x0800000000000142
        'AB12'(0x32314241), modifier: 0x0800000000000052
        'AB12'(0x32314241), modifier: 0x0800000000000042
        'AB12'(0x32314241), modifier: 0x0800000000000371
        'AB12'(0x32314241), modifier: 0x0800000000000351
        'AB12'(0x32314241), modifier: 0x0800000000000361
        'AB12'(0x32314241), modifier: 0x0800000000000341
        'AB12'(0x32314241), modifier: 0x0800000000000071
        'AB12'(0x32314241), modifier: 0x0800000000000051
        'AB12'(0x32314241), modifier: 0x0800000000000061
        'AB12'(0x32314241), modifier: 0x0800000000000041
        'AB12'(0x32314241), modifier: 0x0000000000000000
        'AR12'(0x32315241), modifier: 0x0000000000000000
        'BA15'(0x35314142), modifier: 0x0000000000000000
        'RA15'(0x35314152), modifier: 0x0000000000000000
        'AB15'(0x35314241), modifier: 0x0800000000000152
        'AB15'(0x35314241), modifier: 0x0800000000000142
        'AB15'(0x35314241), modifier: 0x0800000000000052
        'AB15'(0x35314241), modifier: 0x0800000000000042
        'AB15'(0x35314241), modifier: 0x0800000000000371
        'AB15'(0x35314241), modifier: 0x0800000000000351
        'AB15'(0x35314241), modifier: 0x0800000000000361
        'AB15'(0x35314241), modifier: 0x0800000000000341
        'AB15'(0x35314241), modifier: 0x0800000000000071
        'AB15'(0x35314241), modifier: 0x0800000000000051
        'AB15'(0x35314241), modifier: 0x0800000000000061
        'AB15'(0x35314241), modifier: 0x0800000000000041
        'AB15'(0x35314241), modifier: 0x0000000000000000
        'AR15'(0x35315241), modifier: 0x0000000000000000
        'BG16'(0x36314742), modifier: 0x0800000000000152
        'BG16'(0x36314742), modifier: 0x0800000000000142
        'BG16'(0x36314742), modifier: 0x0800000000000052
        'BG16'(0x36314742), modifier: 0x0800000000000042
        'BG16'(0x36314742), modifier: 0x0800000000000371
        'BG16'(0x36314742), modifier: 0x0800000000000351
        'BG16'(0x36314742), modifier: 0x0800000000000361
        'BG16'(0x36314742), modifier: 0x0800000000000341
        'BG16'(0x36314742), modifier: 0x0800000000000071
        'BG16'(0x36314742), modifier: 0x0800000000000051
        'BG16'(0x36314742), modifier: 0x0800000000000061
        'BG16'(0x36314742), modifier: 0x0800000000000041
        'BG16'(0x36314742), modifier: 0x0000000000000000
        'RG16'(0x36314752), modifier: 0x0000000000000000
interface: 'weston_direct_display_v1',                   version:  1, name: 14
interface: 'wl_output',                                  version:  3, name: 15
        x: 0, y: 0, scale: 1,
        physical_width: 0 mm, physical_height: 0 mm,
        make: 'unknown', model: 'unknown',
        subpixel_orientation: unknown, output_transform: normal,
        mode:
                width: 1080 px, height: 1920 px, refresh: 59.785 Hz,
                flags: current preferred
interface: 'zwp_input_panel_v1',                         version:  1, name: 16
interface: 'zwp_input_method_v1',                        version:  1, name: 17
interface: 'zwp_text_input_manager_v1',                  version:  1, name: 18
interface: 'xdg_wm_base',                                version:  3, name: 19
interface: 'weston_desktop_shell',                       version:  1, name: 20
interface: 'weston_screenshooter',                       version:  1, name: 21

从输出信息中可以看到相关输出

2.2 鼠标样式及大小

Weston支持在weston.ini配置文件的shell段设置鼠标样式和大小。

[shell]
cursor-theme=whiteglass
# Buildroot SDK支持comix/obsidian/xcursor/xcursortransparent
鼠标主题包
cursor-size=24

2.3 状态栏

/etc/xdg/weston/weston.ini shell段设置状态栏的背景色、位置,以及在launcher段设置快捷启动程序

[shell]
panel-color=0x90ff0000
# 颜色格式为ARGB8888
panel-position=bottom
# top|bottom|left|right|none,none为禁止
[launcher]
icon=/usr/share/icons/gnome/24x24/apps/utilities-terminal.png
# 图标路径
path=/usr/bin/gnome-terminal
# 快捷启动命令

Weston目前不支持设置状态栏的大小,如要调整,必须进行代码级别的修改:
weston/clients/desktop-shell.c

static void
panel_configure(void *data,
struct weston_desktop_shell *desktop_shell,
uint32_t edges, struct window *window,
int32_t width, int32_t height)
{
  switch (desktop->panel_position) {
    case WESTON_DESKTOP_SHELL_PANEL_POSITION_TOP:
    case WESTON_DESKTOP_SHELL_PANEL_POSITION_BOTTOM:
      height = 32; # 高度
      break;
    case WESTON_DESKTOP_SHELL_PANEL_POSITION_LEFT:
    case WESTON_DESKTOP_SHELL_PANEL_POSITION_RIGHT:
      switch (desktop->clock_format) {
        case CLOCK_FORMAT_NONE:
          width = 32;
          break;
        case CLOCK_FORMAT_MINUTES:
          width = 150;
          break;
        case CLOCK_FORMAT_SECONDS:
          width = 170;
          break;
      }
      break;
  }
}

2.4 背景配置

[shell]
background-image=/usr/share/backgrounds/gnome/Aqua.jpg
# 背景图案(壁纸)绝对路径
background-type=tile
# scale|scale-crop|tile
background-color=0xff002244
# 颜色格式为ARGB8888,未设置背景图案时生效

2.5 待机及锁屏配置

Weston的超时待机时长可以在启动参数中配置,/etc/init.d/S49weston

start_weston()
{
  /usr/bin/weston --idle-time=0& # 0为禁止待机,单位为秒
}

也可以在weston.ini的core段配置,/etc/xdg/weston/weston.ini

[core]
idle-time=10

锁屏设置,/etc/xdg/weston/weston.ini

[shell]
locking=false
# 禁止锁屏
lockscreen-icon=/usr/share/icons/gnome/256x256/actions/lock.png
# 解锁按钮图案
lockscreen=/usr/share/backgrounds/gnome/Garden.jpg
# 锁屏界面背景

2.6 显示颜色格式

默认格式ARGB8888,低性能平台可以设置为RGB565

[core]
gbm-format=rgb565
# xrgb8888|rgb565|xrgb2101010

也可以在weston.ini的output段单独配置每个屏幕的显示格式

[output]
name=LVDS-1
gbm-format=rgb565
# xrgb8888|rgb565|xrgb2101010

2.7 屏幕方向

[output]
name=LVDS-1
transform=rotate-90
# normal|rotate-90|rotate-180|rotate-270|flipped|flipped-rotate-90|flippedrotate--180|flippedrotate--270

动态配置方法

echo "output:all:rotate90" > /tmp/.weston_drm.conf # 所有屏幕旋转90度
echo "output:eDP-1::rotate180" > /tmp/.weston_drm.conf # eDP-1旋转180度

2.8 分辨率及缩放配置

[output]
name=LVDS-1
mode=1280x800
# 需为屏幕支持的有效分辨率
scale=2
# 需为整数倍数,支持应用内部实现缩放

如需要缩放到特定分辨率(物理分辨率不变),可以通过WESTON_DRM_VIRTUAL_SIZE环境变量配置所有屏幕的大小/etc/profile.d/weston.sh

export WESTON_DRM_VIRTUAL_SIZE=1024x768

如果需要动态配置分辨率及缩放,可以通过动态配置文件

echo "output:HDMI-A-1:mode=800x600" > /tmp/.weston_drm.conf # 修改HDMI-A-1分辨
率为800x600
echo "output:eDP-1:rect=<10,20,410,620>" > /tmp/.weston_drm.conf # eDP-1显示到
(10,20)位置,大小缩放为400x600
echo "output:HDMI-A-1:size=1920x1080" > /tmp/.weston_drm.conf # 缩放HDMI-A-1到
1080p,物理分辨率不变

2.9 冻结屏幕

在启动Weston时,开机logo到UI显示之间存在短暂切换黑屏。如需要防止黑屏,可以通过以下方式短暂冻结Weston屏幕内容:
使用定制--warm-up运行参数在UI启动后开始显示,/etc/init.d/S49weston

start_weston()
{
  /usr/bin/weston --warm-up&
}

或者 /etc/init.d/S49weston

start_weston()
{
export WESTON_FREEZE_DISPLAY=/tmp/.weston_freeze # 设置特殊配置文件路径
touch /tmp/.weston_freeze # 冻结显示
/usr/bin/weston&
sleep 1 && rm /tmp/.weston_freeze& # 1秒后解冻
}

或者

start_weston()
{
  echo "output:all:freeze" > /tmp/.weston_drm.conf # 冻结显示
  /usr/bin/weston&
  ...
  sleep 1 && \
  echo "output:all:unfreeze" > /tmp/.weston_drm.conf& # 1秒后解冻
}

2.10 屏幕状态配置

DRM框架支持强制配置屏幕状态:

echo on > /sys/class/drm/card0-HDMI-A-1/status # 强制HDMI-A-1为接入状态
#on|off|detect,detect为热拔插

如果需要更具体的动态屏幕状态配置,可以通过动态配置文件

echo "output:DSI-1:off" > /tmp/.weston_drm.conf #关闭DSI(非拔出)
echo "output:HDMI-A-1:freeze" > /tmp/.weston_drm.conf #冻结HDMI-A-1
echo "output:eDP-1:on" > /tmp/.weston_drm.conf #开启eDP
echo "compositor:state:off" > /tmp/.weston_drm.conf #显示休眠
echo "compositor:state:sleep" > /tmp/.weston_drm.conf #显示休眠,触屏唤醒
echo "compositor:state:on" > /tmp/.weston_drm.conf #显示唤醒

2.11 多屏管理

Buildroot SDK的Weston支持多屏镜像同显、多屏异显、屏幕位置配置及热拔插等功能。镜像模式缩放时,如果硬件VOP显示模块不支持缩放,则需要依赖RGA处理。
相关配置通过环境变量设置 /etc/profile.d/weston.sh

export WESTON_DRM_PRIMARY=HDMI-A-1 # 指定主显为HDMI-A-1
export WESTON_DRM_SINGLE_HEAD=1 # 强制单显
export WESTON_DRM_MIRROR=1 # 使用镜像模式(多屏同显),不设置此环境变量即为异显
export WESTON_DRM_KEEP_RATIO=1 # 镜像模式下缩放保持纵横比,不设置此变量即为强制全屏
export WESTON_DRM_HEAD_MODE=primary # 只使能主显
export WESTON_DRM_HEAD_MODE=internal # 只使能内置显示器
export WESTON_DRM_HEAD_MODE=external # 只使能外置显示器
export WESTON_DRM_HEAD_MODE=external-dual # 使能所有显示器,优先外置显示器
export WESTON_DRM_HEAD_FALLBACK=1 # 未匹配到显示器时,使能任意一个有效显示器
export WESTON_OUTPUT_FLOW=horizontal # 默认水平排列
export WESTON_OUTPUT_FLOW=vertical # 默认垂直排列
export WESTON_OUTPUT_FLOW=same-as # 所有显示器默认位置(0,0)

也支持在weston.ini的output段单独禁用指定屏幕:

[output]
name=LVDS-1
mode=off
# off|current|preferred|<WIDTHxHEIGHT@RATE>

2.12 输入设备配置

Weston服务默认需要至少一个输入设备,如无输入设备,则需要在weston.ini中的core段特殊设置:

[core]
require-input=false

Weston中如存在多个屏幕,需要把输入设备和屏幕进行绑定,则需要通过触摸设备的udev规则配置WL_OUTPUT,如:

# /lib/udev/rules.d/99-goodix-ts.rules
ATTRS{idVendor}=="dead", ATTRS{idProduct}=="beef", ENV{WL_OUTPUT}="HDMI-A-1"

或者配置WL_SEAT

# /lib/udev/rules.d/99-goodix-ts.rules
ATTRS{idVendor}=="dead", ATTRS{idProduct}=="beef", ENV{WL_SEAT}="seat1"
[output]
name=LVDS-1
seat=seat1

2.13 触屏校准

Weston如果需要校准触屏,可以通过WESTON_TOUCH_CALIBRATION环境变量,如:/etc/profile.d/weston.sh

export WESTON_TOUCH_CALIBRATION="1.013788 0.0 -0.061495 0.0 1.332709 -0.276154"

校准参数的获取可以使用Weston校准工具: weston-calibrator,工具运行后会生成若干随机点,依次点击后输出校准参数,如:Final calibration values: 1.013788 0.0 -0.061495 0.0 1.332709 -0.276154
也可以直接使用Weston提供的另一个校准工具:weston-touch-calibrator,需要配置:

# /etc/xdg/weston/weston.ini
[libinput]
touchscreen_calibrator=true
calibration_helper=/bin/weston-calibration-helper.sh

评论