[PATCH weston v6 00/73] Head-based output configuration API a.k.a clone mode infrastructure

Pekka Paalanen ppaalanen at gmail.com
Fri Feb 16 14:56:45 UTC 2018

From: Pekka Paalanen <pekka.paalanen at collabora.co.uk>

Hi all,

here is the v6 of the shared-CRTC clone mode series. Since v5, quite
many patches have been extracted from this series, sent out and merged
upstream. However, now the series is bigger than ever, because here I am
posting the complete series, including the full DRM-backend migration
and DRM shared-CRTC clone mode implementation, thanks to having the
basic atomic modesetting landed upstream.

The previous submission is here:

Design discussion etc. (sequence diagrams!) can be found here:

The series is available as a branch at:

Highlights since v5:
- DRM-backend migration
- shared-CRTC clone mode implemented in DRM backend
- applied review comments from v5
- don't create a weston_output just to turn it off (DRM)
- cms-colord will print a warning when used with clone mode
- cms-colord vs. clone mode mentioned in weston-drm.man

Unfortunately the testing results are not 100%, you can find my testing
procedure below the diffstat.

The patch series is structured as follows:

- Patches 1-17 introduce most of the new head-based API, and build the
  scaffolding that allows migrating the frontends and the backends one
  by one.

- Patches 18-24 migrate the frontends one by one. Patch 19 introduces
  the simple output configurator which is first used for all backends,
  including the DRM-backend.

- Patches 25-30 clean up libweston after the frontend migration.

- Patches 31-38 migrate all the backends to the head-based API. At this
  point the DRM-backend migration is basically a fake, though.

- Patch 39 removes weston_output::head with the last bits of the

- Patches 40-44 enhances libweston core to better support the
  DRM-backend's clone mode configuration and improve logging.

- Patches 45-55 implement the head-based API for real in the
  DRM-backend, culminating in patch 55 which creates heads for all

- Patch 56 removes unused_connectors array which has been replace with
  the head list.
- Patches 57-70 finally implement everything needed for shared-CRTC
  clone mode in the DRM-backend.

- Patches 71-73 add a new output configrator logic in the frontend to
  handle clone mode, supporting a new weston.ini key "same-as".

Do you think we should call the weston.ini key "clone-of" instead, to
leave "same-as" reserved for clone mode where only the desktop area is
the same but the monitors would have different video modes, scaling,

There are several imaginable uses for "same-as" variants:
- get me shared-CRTC clone mode or fail
- get me clone mode, preferring shared-CRTC but automatic fallback to
  independent CRTCs
- get me clone mode, but I want one monitor with HiDPI and one with

Here I have implemented the automatic fallback version, except it cannot
actually fall back, because we have no API to make two weston_outputs
show the same area, and libweston's damage tracking could not handle it
even if we could.

Pekka Paalanen (73):
  libweston: introduce weston_head
  libweston: move wl_output to weston_head
  libweston: use head in wl_output global
  libweston: make wl_output point to weston_head
  libweston: refactor weston_mode_switch_finish
  libweston: introduce weston_output::head_list
  libweston: properly orphan wl_output resources
  libweston: strdup head make, model, serial_number
  cms-colord: find a good head
  libweston: add name to weston_head
  libweston: add weston_head::connected
  libweston: add weston_head_is_enabled()
  libweston: add compositor list of heads
  libweston: add heads_changed hook
  libweston: new head-based output management API
  libweston: add weston_head destroy signal
  libweston: add weston_head_is_device_changed() API
  weston: move weston_output_enable() into callers
  weston: migrate headless to head-based output API
  weston: migrate x11 to head-based output API
  weston: migrate wayland to head-based output API
  weston: migrate fbdev to head-based output API
  weston: migrate RDP to head-based output API
  weston: migrate DRM to head-based output API
  libweston: change windowed_output_api output_create to create_head
  libweston: remove output_pending_signal
  libweston: stop auto-adding the implicit head
  libweston: assert make/model in weston_output_enable()
  libweston: assert current_mode in weston_output_enable()
  libweston: cancel idle_repaint on output destroy
  compositor-headless: migrate to head-based output API
  compositor-rdp: migrate to head-based output API
  compositor-fbdev: make re-enable less drastic
  compositor-fbdev: migrate to head-based output API
  compositor-x11: migrate to head-based output API
  compositor-wayland: strict surface create/destroy
  compositor-wayland: migrate to head-based output API
  compositor-drm: start migration to head-based output API
  libweston: remove weston_output::head
  libweston: print head names on output enable
  libweston: create/find output by name
  libweston: support user data on weston_output
  libweston: allow attaching heads to enabled outputs
  libweston: log head detach on enabled output
  compositor-drm: drm_output_find_by_connector from head_list
  compositor-drm: use head_find_by_connector in update_unused_outputs
  compositor-drm: find disconnects from head_list
  compositor-drm: move backlight into drm_head
  compositor-drm: move connector fields into drm_head
  compositor-drm: allocate CRTC on enable()
  compositor-drm: simplify drm_output_find_by_crtc()
  compositor-drm: simplify drm_output_find_special_plane()
  compositor-drm: get current mode on head discovery
  compositor-drm: move mode list to set_mode()
  compositor-drm: create heads for all connectors
  compositor-drm: remove unused_connectors array
  compositor-drm: drm_output_apply_state_legacy heads
  compositor-drm: drm_output_apply_state_atomic heads
  compositor-drm: drm_set_backlight heads
  compositor-drm: unify head status logging
  compositor-drm: combine mode list from heads
  compositor-drm: backlight control for all heads
  compositor-drm: update video mode printing
  compositor-drm: introduce drm_head_read_current_setup()
  compositor-drm: no need to clear inherited_mode
  compositor-drm: rewrite crtc picking for clone mode
  compositor-drm: preserve CRTC routing harder
  compositor-drm: head detach requires a modeset
  compositor-drm: head attach requires a modeset
  compositor-drm: allow shared-CRTC cloning
  weston: store weston_compositor in wet_compositor
  weston: use wet.compositor consistently in main()
  weston: support clone mode on DRM-frontend

 compositor/cms-colord.c             |   45 +-
 compositor/main.c                   |  818 +++++++++++++++++++++----
 compositor/weston-screenshooter.c   |    2 +-
 desktop-shell/input-panel.c         |    4 +-
 desktop-shell/shell.c               |    4 +-
 fullscreen-shell/fullscreen-shell.c |    4 +-
 ivi-shell/input-panel-ivi.c         |    4 +-
 libweston-desktop/wl-shell.c        |    2 +-
 libweston-desktop/xdg-shell-v6.c    |    2 +-
 libweston/compositor-drm.c          | 1128 +++++++++++++++++++++++------------
 libweston/compositor-fbdev.c        |  206 ++++---
 libweston/compositor-headless.c     |   75 ++-
 libweston/compositor-rdp.c          |   64 +-
 libweston/compositor-wayland.c      |  254 ++++++--
 libweston/compositor-x11.c          |   71 ++-
 libweston/compositor.c              | 1107 +++++++++++++++++++++++++++++++---
 libweston/compositor.h              |  198 +++++-
 libweston/windowed-output-api.h     |   23 +-
 man/weston-drm.man                  |   12 +
 tests/weston-test.c                 |    2 +-
 20 files changed, 3249 insertions(+), 776 deletions(-)

Testing procedure and results:

All tests were successful except where otherwise mentioned.

headless-backend testing:

$ make -j7 distcheck

x11-backend testing:

$ weston
$ weston --output-count=3
  - close x11 windows one by one
$ weston --fullscreen (equally broken before and after)

Wayland-backend testing:

parent: $ weston --output-count=2 --width=700
outputs have different height


weston --use-pixman
weston --use-pixman --fullscreen
weston --use-pixman --output-count=2
weston --use-pixman --sprawl
- close parent outputs one by one

In the --sprawl case, closing the first output soon results in the
parent compositor:

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7ba3b8f in wl_signal_emit (signal=0x555555da74a8, data=0x555555da74a0) at /home/pq/local/include/wayland-server-core.h:467
467		wl_list_for_each_safe(l, next, &signal->listener_list, link)
(gdb) bt
#0  0x00007ffff7ba3b8f in wl_signal_emit (signal=0x555555da74a8, data=0x555555da74a0) at /home/pq/local/include/wayland-server-core.h:467
#1  0x00007ffff7ba8a4c in weston_surface_destroy (surface=0x555555da74a0) at /home/pq/git/weston/libweston/compositor.c:1904
#2  0x00007fffee108196 in fade_out_done_idle_cb (data=0x555555da7d20) at /home/pq/git/weston/desktop-shell/shell.c:2281
#3  0x00007ffff798dcac in wl_event_loop_dispatch_idle (loop=loop at entry=0x55555576c250) at src/event-loop.c:600
#4  0x00007ffff798dd64 in wl_event_loop_dispatch (loop=0x55555576c250, timeout=timeout at entry=-1) at src/event-loop.c:646
#5  0x00007ffff798c4fa in wl_display_run (display=0x55555576c170) at src/wayland-server.c:1260
#6  0x000055555555dd86 in main (argc=1, argv=0x7fffffffdb58) at /home/pq/git/weston/compositor/main.c:2477

parent: $ weston --output-count=2 --width=700 --shell=fullscreen-shell.so


weston --use-pixman
- close parent outputs one by one

RDP-backend testing:

- using remmina as client, connected twice in a row

fbdev-backend testing:

$ weston -Bfbdev-backend.so

DRM-backend testing:

Two outputs plugged in, third unplugged.
1. start Weston, ensure both outputs work
2. unplug one output, ensure remaining output works
3. re-plug the output, ensure both outputs work
4. quit

One output plugged in, the rest unplugged. The plugged-in output is
configured to be off in weston.ini.
1. start Weston, zero outputs, check via remote login weston-info works
2. plug in an output, check it works
3. unplug the output, check weston-info via remote


More information about the wayland-devel mailing list