Information for Wayland/Weston


Note: weston-ini is located /etc/xdg/weston/weston.ini
To edit the file weston.ini you can use the 'vi' editor that is in the BSP.

Restart Weston

  • If you want to restart weston, you can do this:
$ systemctl restart weston@root
  • For Yocto, the location of the .service files in the rotofs are /lib/systemd/system/ which is where the file weston@.service is located.
  • On older BSPs, the command was "systemctl restart weston" or "systemctl restart weston@1"

Remove toolbar and clock

In weston-ini,

[shell]
clock-format=none
panel-position=none

Change Weston Background

Single color setting of background

In weston-ini,

[shell]
background-color=0xff000000   <- Black
background-color=0xffff0000   <- Red
background-color=0xff00ff00   <- Green
background-color=0xff0000ff   <- Blue

Top 8 bits are an alpha value. For example, 0x7fxxxxxx is translucent, but 0x00xxxxxx is not transparent and the wallpaper is displayed.

Change the background Image

In weston-ini,

[shell]
background-image=/xxx/xxx/xxxx.png
background-type=tile   (scale, scale-crop or tile (default)

More details about weston.ini options

For more options, see the "SHELL SECTION" on this page: https://manpages.ubuntu.com/manpages/bionic/man5/weston.ini.5.html

Remove Window Frame

To remove window frame on a Qt app, follow https://stackoverflow.com/questions/3948441/how-to-remove-the-window-border-containing-minimize-maximize-and-close-buttons

Changing the Video Mode for Weston

The display configuration is controlled by a file named 'weston.ini' located in the folder /etc/xdg/weston. Currently there is this section in it that sets some specific display timings.
In order to make a display work with the RZ/G2 board, the 'mode' settings need to be change to something that the display supports. In order to find those settings, run the 'cvt' command providing it the desired mode as parameters.
For example, on the RZ/G2E board, the maximum resolution is 1080p at 30Hz. Therefore you would use the command:

cvt 1920 1080 30  

This should give you the proper display timings for running your display at 1080p 30fps and will force that specific mode.

You can also just specify a resolution (without timing).

[output]  
name=HDMI-A-1 
mode=1280x720

After modifying the configuration and saving the file, Restart the Weston desktop.

Another option is to set mode to "current" which keeps the current video resolution that the system was booted with.

[output]  
name=HDMI-A-1  
mode=current 

Then then set the resolution on the kernel command line in u-boot by changing the boot args to specify the resolution you want:

=> setenv bootargs 'root=/dev/mmcblk0p2 rootwait video=HDMI-A-1:1280x720-32 
=> saveenv

Rotation and flipping

The output can be rotated and flipped adding the transform option to the output section:

normal               Normal output.
90                   90 degrees clockwise.
180                  Upside down.
270                  90 degrees counter clockwise.
flipped              Horizontally flipped
flipped-90           Flipped and 90 degrees clockwise
flipped-180          Flipped and upside down
flipped-270          Flipped and 90 degrees counter clockwise

For example:

[output]
name=HDMI-A-1
mode=720x1280@60
transform=flipped-90

Take a Screenshot

You can take a screenshot on our board by using the utility weston-screenshooter.

  • Modify the file /etc/default/weston and add the line:
OPTARGS="--debug" 
  • While your application is running, use the following command:
$ weston-screenshooter
  • After running weston-screenshooter, a .png file will be created in that directory. For example: "wayland-screenshot-2020-09-20_10-47-10.png"


Actually there is also a Weston keyboard shortcut that can be used: Super key + s, where the Super Key is usually the key close to Ctrl and Alt with Window logo on it.

Screen recording

Similarly, Super key + r starts / stops recording the screen, the output is a .wcap file. This is a lossless Weston proprietary format, it can be converted by using wcap-decode:

wcap-decode --yuv4mpeg2 capture.wcap > capture.y4m

The .y4m is a raw format can be opened using vlc and potentially encoded using ffmpeg:

ffmpeg -y -i capture.y4m -c:v libx264 -pix_fmt yuv420p capture.mp4

Enable /dev/fb0

The legacy Frame Buffer device interface (/dev/fb0) exists in the system, but when you write to it, nothing will be changed on the LCD when Weston is running. Therefore, if you want to use /dev/fb0, please disable weston.

systemctl stop weston

When you want to use weston again, please run

systemctl start weston

Weston without GPU

By default, Weston will require a OpenGL ES library and GPU to run. However, some RZ devices might not have a GPU. In this case, you can configure Weston to use CPU software rendering instead of GPU rendering. To do this, on your target board, edit the file /etc/xdg/weston/weston.ini and add the line

[core]
use-pixman=true


Multi-display with Wayland/Weston

One of the most frequently asked question is how to drive multiple display with RZ/G2 (RZ/G2E-N-M-H, since RZ/G2L cannot really drive more than one display).

There are some limitations on what Weston, as Wayland compositor, can do. Some limitations are due to Wayland protocol itself.

The most important thing to bear in mind is that what Weston can do well is extended desktop, for clone mode there are patches but they are not tested, independent driving is not really supported because it would require two DRM/KMS devices. However, also in extended mode there are caveats. By design Wayland does not allow application to set the position, each new window has, instead, a random initial position and then the user can move it or set to full screen. Wayland does allow applications to open in full-screen but it will open in the current active display, that is the one with the mouse pointer or last touch input. (utouch-evemu could be theoretically used to select the current active display).

Because of this limitation, a workaround using IVI-shell (In-vehicle infotainment) can be considered: it extends the Wayland core protocol to tie wl_surface and a given ID. With this ID, shell can identify which wl_surface is drawn by which application.

Another possibility is not to use Weston to control both screen, so one display can be managed by Weston / DRM and therefore have the full HW acceleration, the other is instead handled by LinuxFB/DirectFB purely in SW. This can be often acceptable for relatively simple/static GUIs.

Qt

Regarding QT, theoretically there can be a Qt application using EGLFS and another one using OpenGLES through Wayland. However this option cannot work because RZ/G2 does not support EGLFS. More details about Qt for Embedded Linux are available here.

Android

On Android, instead, multi display is much better supported and the limitations above do not apply. There is also a demo showing the dual display support with RZ/G2M (details / link TBD).


Touch Screen Calibration

Touch calibration and color changing can be done normally in Wayland/Weston.

Note that touch calibration must be enabled first in weston.ini (link)

Here is an example of how to enable touch (link)

Bring Window to Top

In Weston, there is not an API to change the z-order of windows in code. Of course, individual application windows will come to the top when pressed by the mouse pointer, but many times you want to control that using application software.

However, when writing a Qt application, when you want to bring the Qt surface to the top, just set window "visible" setting to FALSE and TRUE again.



Window Always On Top

In Weston, there is not an API to change the z-order of windows in code, or to force a window to always be on top.

However, you can modify the source code of Weston Desktop Shell to add this feature.

After the supplied patch is applied, you can enter the name of the application you would like to always be on top in the weston.ini file.

Patch File:


  • Download this file to your build PC.

File:0001-desktop-shell-Add-Z-order-support.patch

How to apply the patch file:


  • In your Yocto environment, copy the patch file to the location

build/tmp/work/aarch64-poky-linux/weston/8.0.0-r0/weston-8.0.0/

  • Go to that directory and use the below command to apply it:

patch -p1 < 0001-desktop-shell-Add-Z-order-support.patch

  • Go back to the base of the Yocto directory and rebuilt Weston

bitbake poky/oe-init-build-envbitbake weston -fC compile

  • Copy your modified desktop shell library (desktop-shell.so) to your board.
  • On your build machine, copy file...

[yocto]/tmp/work/aarch64-poky-linux/weston/8.0.0-r0/build/desktop-shell/desktop-shell.so

  • ...to this directory on your board and overwrite the existing one.

/usr/lib64/weston/desktop-shell.so

Usage:


  • On your board, in file /etc/xdg/weston/weston.ini, set the app's name to top-app-name so that Weston compositor can know which apps should always be put on top:
[shell]
top-app-name=weston-simple-egl
  • Then, restart Weston compositor:
systemctl restart weston@root
  • Apps with the same name as top-app-name will always be displayed above other apps with names empty (zombie processes) or other than top-app-name.

Notes:


1. For more detailed information about weston.ini, please refer to:

https://manpages.ubuntu.com/manpages/focal/man5/weston.ini.5.html

2. The value type of top-app-name is string which must not be quoted. It does not support any escape sequences, and runs till the end of the line.

For example:

[shell]
top-app-name="weston simple egl" # Incorrect
top-app-name=weston simple egl   # Correct

Prevent Timeout and Screen Lock

By default, if Weston sits with no user input, it will time out and put up a screen lock screen. To prevent, you can do one of two methods:

Method 1:
Add --idle-time=0 to the command line of weston-start

/usr/bin/weston-start --idle-time=0

Method 2:
Add the follow lines to /etc/xdg/weston/weston.ini

[core]
idle-time=0 
[shell]
locking=false

Launching Firefox from command line

# WAYLAND_DISPLAY=wayland-0 GDK_BACKEND=wayland MOZ_OMX_RZG2L=1 firefox --width 1024 --height 600 --kiosk https://renesas.info

Low FPS

If your FPS is low, this might be caused by repaint-window parameter (in weston.ini). You might see this if you are testing by running the command weston-simple-egl and getting only 1 fps.

root@hihope-rzg2n:~# weston-simple-egl -f
5 frames in 5 seconds:  1.000000 fps
4 frames in 5 seconds:  0.800000 fps
4 frames in 5 seconds:  0.800000 fps
4 frames in 5 seconds:  0.800000 fps

If current repaint-window value is not suitable for your HDMI screen, it will cause high latency, which makes low fps.

https://man.archlinux.org/man/weston.ini.5.html#repaint-window=

Unfortunately Weston cannot detect a good value for repaint by itself. So it requires the user to set a value for it.

You can try a few other values for repaint-window to see which one is suitable for your case.

Define apps to be started from the Toolbar

The apps to be shown in the toolbar are defined as "launcher" in weston.ini.

example:

[launcher]
icon=usr/share/weston/icon_terminal.png
path=/usr/bin/weston-terminal

[launcher]
icon=<path>/start_app.png
path=<path>/start_app.sh

[launcher]
icon=<path>/stop_app.png
path=<path>/stop_app.sh

The icon (.png) should have appr. 20x20 pixel.

The app may be started directly (path=app_name) or within a shell script (path=script_name). Scripts allow to start several commands.

Apps that do not allow to exit from GUI may need to be stopped with a "kill" command.

The following examples can be used to start and stop sample applications that are called "app_*".

start application

(stops a previously started tool called "*app_*" and starts the selected one 'silently')

start_app.sh:

#!/bin/bash

/opt/eAI/stop_app.sh
cd /eAI/app_resnet50_cam
setsid ./app_resnet50_USB_cam 3 5 &>/dev/null

stop application (called "*app_*")

stop_app.sh:

#!/bin/bash

APP_PID=$(ps -aux | grep "app_" | grep -v "0:00" | awk '{print $2}')
if [ ! -z "$APP_PID" ]; then kill $APP_PID; fi
sleep 1


The Weston version used in the Verified Linux Package does not allow to define a "displayname" (= app name to be shown below the icon). Instead, the script name is shown. But if the launcher references to a link that points to the script, the link name pops up.

  • No labels