Weston: switch on/off display during runtime

Hello,

I’m using a Yocto image based on the BSP 6.2 tdx-reference-multimedia-image on a Verdin iMX8MM. A 1920x1200 MIPI-DSI touch display is connected and working with weston.

Is it possible to switch on/off this display by command line? And not only the backlight.

  • Disabling the display in weston.ini and restarting weston is not an option for me.

  • I tried to add wlr-randr to my image with the following recipe:

DESCRITPTION = "Utility to manage outputs of a Wayland compositor"
HOMEPAGE = "https://sr.ht/~emersion/wlr-randr/"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://LICENSE;md5=07e8a8f2dc9e6a7f131e81037398c61b"

#PV = "0.4.0"

SRCREV = "fdde0d1d1ce940febb9b6ea6b2faa97f4e81a788"
PV = "0.1+git${SRCPV}"
#SRC_URI = "git://git.sr.ht/~emersion/wlr-randr;branch=0.4.0;protocol=https"
SRC_URI = "git://git.sr.ht/~emersion/wlr-randr;branch=master;protocol=https"

S = "${WORKDIR}/git"

inherit meson pkgconfig

DEPENDS:append = " wayland"

do_install() {
	install -d ${D}/${bindir_native}
	install -m 0755 wlr-randr	${D}/${bindir_native}
}

but got the error during configuring that the dependency wayland-scanner is missing.

  • I found the file /sys/class/drm/card1-DSI-1/power/control but don’t know which arguments it takes

Best regards,
Markus

Hi @Mowlwurf

I’m not 100% if it works but eventually, you can turn it off by using dpms:

# Use modetest to find out which id your connector has
modetest
.....
id      encoder status          name            size (mm)       modes   encoders
236     235     connected       eDP-1           300x190         1       235
modetest -M imx-drm -w 236:DPMS:3

This should turn off the display, and:

modetest -M imx-drm -w 236:DPMS:0

Should turn it on again. 236 is the id, you would have to change it to the number for your connector.

Regards,
Stefan

Hi @stefan_e.tx,

thank you for your fast response.

I tried your suggestion, but unfortunately had no success:

root@verdin-imx8mm-07220244:~# modetest
trying to open device 'i915'...failed
trying to open device 'amdgpu'...failed
trying to open device 'radeon'...failed
trying to open device 'nouveau'...failed
trying to open device 'vmwgfx'...failed
trying to open device 'omapdrm'...failed
trying to open device 'exynos'...failed
trying to open device 'tilcdc'...failed
trying to open device 'msm'...failed
trying to open device 'sti'...failed
trying to open device 'tegra'...failed
trying to open device 'imx-drm'...done
Encoders:
id      crtc    type    possible crtcs  possible clones
34      33      DSI     0x00000001      0x00000001

Connectors:
id      encoder status          name            size (mm)       modes   encoders
35      34      connected       DSI-1           136x217         1       34
  modes:
        index name refresh (Hz) hdisp hss hse htot vdisp vss vse vtot
  #0 1200x1920 59.75 1200 1280 1304 1364 1920 1936 1940 1956 159420 flags: ; type: preferred, driver
  props:
        1 EDID:
                flags: immutable blob
                blobs:

                value:
        2 DPMS:
                flags: enum
                enums: On=0 Standby=1 Suspend=2 Off=3
                value: 0
        5 link-status:
                flags: enum
                enums: Good=0 Bad=1
                value: 0
        6 non-desktop:
                flags: immutable range
                values: 0 1
                value: 0
        4 TILE:
                flags: immutable blob
                blobs:

                value:

CRTCs:
id      fb      pos     size
33      39      (0,0)   (1200x1920)
  #0 1200x1920 59.75 1200 1280 1304 1364 1920 1936 1940 1956 159420 flags: ; type: preferred, driver
  props:
        24 VRR_ENABLED:
                flags: range
                values: 0 1
                value: 0

Planes:
id      crtc    fb      CRTC x,y        x,y     gamma size      possible crtcs
31      33      39      0,0             0,0     0               0x00000001
  formats: XR24 AR24 RG16 XB24 AB24 RX24 RA24 AR15 XR15 AB15 XB15 BG16
  props:
        8 type:
                flags: immutable enum
                enums: Overlay=0 Primary=1 Cursor=2
                value: 1
        32 zpos:
                flags: immutable range
                values: 0 0
                value: 0

Frame buffers:
id      size    pitch
root@verdin-imx8mm-07220244:~# modetest -M imx-drm -w 35:DPMS:3
failed to set CONNECTOR 35 property DPMS to 3: Permission denied

Best regards,
Markus

Hi @Mowlwurf

Unfortunately, you are right and this is not working as long as weston is running. It seems weston does not support DPMS and because it is the master device controlling the drm device it will block modetest from taking over the control. The only way to achieve a proper power-off would be to expand weston. There seems to be a weston plugin that tries to address this. Maybe you can make it work?

Also see the discussion here:

Regards,
Stefan

Hello @stefan_e.tx

thank you for your reply.

I tried to create this extension with the following Yocto recipe:

DESCRITPTION = "Module for Weston compositor kiosk shell providing DPMS functionality"
HOMEPAGE = "https://github.com/akhilharihar/Weston-kiosk-shell-DPMS"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://LICENSE;md5=4b8ef887b5d26d4b038225869bda92d3"

PV = "0.2"
SRC_URI = "file://Weston-kiosk-shell-DPMS-${PV}.tar.gz"

inherit meson pkgconfig

DEPENDS = "weston"

S = "${WORKDIR}/Weston-kiosk-shell-DPMS-${PV}"

do_install() {
	install -d ${D}/${bindir_native}
	install -m 0755 dpms-client	${D}/${bindir_native}
}

But again I get the error message

| Did not find CMake 'cmake'
| Found CMake: NO
| Build-time dependency wayland-scanner found: NO (tried pkgconfig)
|
| ../Weston-kiosk-shell-DPMS-0.2/meson.build:19:0: ERROR: Dependency "wayland-scanner" not found, tried pkgconfig

What do I have to add to the recipe so that wayland-scanner is found?

Best regards,
Markus

Hi @Mowlwurf

I guess you would have to add wayland-native as dependency:

DESCRITPTION = "Module for Weston compositor kiosk shell providing DPMS functionality"
HOMEPAGE = "https://github.com/akhilharihar/Weston-kiosk-shell-DPMS"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://LICENSE;md5=4b8ef887b5d26d4b038225869bda92d3"

PV = "0.2"
SRC_URI = "file://Weston-kiosk-shell-DPMS-${PV}.tar.gz"

inherit meson pkgconfig

DEPENDS = "weston wayland-native"

S = "${WORKDIR}/Weston-kiosk-shell-DPMS-${PV}"

do_install() {
	install -d ${D}/${bindir_native}
	install -m 0755 dpms-client	${D}/${bindir_native}
}

Regards,
Stefan

Hi @stefan_e.tx ,

that was a good hint, thank you.

Now I get the following error:

../Weston-kiosk-shell-DPMS-0.2/meson.build:43:0: ERROR: Include dir /usr/include/libweston-10 does not exist.

Why does the recipe search the directory in my host rootfs instead of the working directory tmp/work/cortexa53-mx8mm-tdx-linux/weston-kiosk-shell-dpms/0.2-r0/recipe-sysroot/usr/include?

Best regards,
Markus

Hi @Mowlwurf

I’m not a meson expert but what about adding a patch similar to this?

diff --git a/meson.build b/meson.build
index f1fb908..770bbf9 100644
--- a/meson.build
+++ b/meson.build
@@ -10,7 +10,10 @@ libweston_version = 10
 dir_prefix = get_option('prefix')
 dir_lib = dir_prefix / get_option('libdir')
 dir_module_weston = dir_lib / 'weston'
+dir_system_include = get_option('includedir')
+if dir_system_inclue == ''
   dir_system_include = '/usr/include'
+endif
 
 weston = dependency('libweston-@0@'.format(libweston_version), method: 'pkg-config')
 wayland_server = dependency('wayland-server', method: 'pkg-config')

Regards,
Stefan

Hello @stefan_e.tx,

I am completely new to meson, but with your help and an additional configuration parameter for meson (EXTRA_OEMESON) I got it working.

My recipe weston-kiosk-shell-dpms now looks as follow:

DESCRITPTION = "Module for Weston compositor kiosk shell providing DPMS functionality"
HOMEPAGE = "https://github.com/akhilharihar/Weston-kiosk-shell-DPMS"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://LICENSE;md5=4b8ef887b5d26d4b038225869bda92d3"

FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"

SRCREV = "5cf171084c02b468c40777c22243925fd900dc66"
PV = "0.2+git${SRCPV}"
SRC_URI  = "git://github.com/akhilharihar/Weston-kiosk-shell-DPMS;branch=main;protocol=https"
SRC_URI += "file://weston-kiosk-shell-dpms.patch"
S = "${WORKDIR}/git"

inherit meson pkgconfig

DEPENDS = "weston wayland-native"

EXTRA_OEMESON += "--prefix=${STAGING_DIR_TARGET}/usr"

do_install() {
	install -d ${D}/${bindir_native}
	install -m 0755 dpms-client	${D}/${bindir_native}

	install -d ${D}/${libdir_native}/weston
	install -m 0755 kiosk-shell-dpms.so ${D}${libdir_native}/weston
}

FILES:${PN} += "\
	${bindir_native}/* \
	${libdir_native}/weston/* \
"

The patch for the meson.build:

index f1fb908..cae3ee9 100644
--- a/meson.build
+++ b/meson.build
@@ -10,7 +10,10 @@ libweston_version = 10
 dir_prefix = get_option('prefix')
 dir_lib = dir_prefix / get_option('libdir')
 dir_module_weston = dir_lib / 'weston'
-dir_system_include = '/usr/include'
+dir_system_include = dir_prefix / get_option('includedir')
+if dir_system_include == ''
+  dir_system_include = '/usr/include'
+endif
 
 weston = dependency('libweston-@0@'.format(libweston_version), method: 'pkg-config')
 wayland_server = dependency('wayland-server', method: 'pkg-config')

I’ve tested it on my system and it works :slight_smile: Thank you very much for your help!

I just have one more question:
To activate the weston extension when building the image I added the following to my image recipe

weston_kiosk_shell_dpms_modify_ini() {
    echo "$(awk '{print} /[core]/ && !x {print "shell=kiosk-shell.so"; x=1}' ${IMAGE_ROOTFS}${sysconfdir}/xdg/weston/weston.ini)" > ${IMAGE_ROOTFS}${sysconfdir}/xdg/weston/weston.ini
    echo "$(awk '/^modules=/ && !x {$0=$0",kiosk-shell-dpms.so"; x=1} 1' ${IMAGE_ROOTFS}${sysconfdir}/xdg/weston/weston.ini)" > ${IMAGE_ROOTFS}${sysconfdir}/xdg/weston/weston.ini
}
ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains("IMAGE_INSTALL", "weston-kiosk-shell-dpms", "weston_kiosk_shell_dpms_modify_ini; ", "", d)}'

Is there a more elegant way to modify the weston.ini? It would be best to do it directly in the recipe of the extension.

Best regards,
Markus

Hi @Mowlwurf

Great to hear that it works and thanks a lot for sharing the solution, this will most likely help others to solve the issue as well!

Regarding the weston.ini file, there is the recipe openembedded-core/meta/recipes-graphics/wayland/weston-init.bb which addds the init file. You can just point to your weston.ini file by adding a bbappend:
weston-init.bbappend:

FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"

Then you can put your weston.ini into the weston-init directory in the folder where you store the weston-init.bbappend.

Regards,
Stefan

Hello @stefan_e.tx,

I am already modifying the weston.ini in a weston-init.bbappend. I was hoping that it is also possible to modify the weston.ini from within the extension recipe. This would have made it an all-in-one solution.

Thanks again for your help!

Best regards,
Markus