libweston: move weston_output::mode_list init to core
authorPekka Paalanen <pekka.paalanen@collabora.co.uk>
Wed, 6 Sep 2017 13:47:52 +0000 (16:47 +0300)
committerPekka Paalanen <pekka.paalanen@collabora.co.uk>
Wed, 4 Oct 2017 11:55:58 +0000 (14:55 +0300)
Initialize the list in weston_output_init() instead of doing it
separately in each backend.

One would expect weston_output_init() to initialize all weston_output
members, at least those that are not NULL.

We rely on the set_size() functions to be called only once, as is
assert()'d. If set_size() becomes callable multiple times, this patch
will force them to be fixed to properly manage the mode list instead of
losing all members.

compositor-wayland.c is strange in
wayland_output_create_for_parent_output(): it first called
wayland_output_set_size() that initialized the mode list with a single
mode manufactured from width and height and set that mode as current.
Then it continued to reset the mode list and adding the list of modes
from the parent output, leaving the current mode left to point to a mode
struct that is no longer in the mode list and with a broken 'link'
element. This patch changes things such that the manufactured mode is
left in the list, and the parent mode list is added. This is probably
not quite right either.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Emre Ucan <eucan@de.adit-jv.com>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Acked-by Daniel Stone <daniels@collabora.com>

libweston/compositor-drm.c
libweston/compositor-fbdev.c
libweston/compositor-headless.c
libweston/compositor-rdp.c
libweston/compositor-wayland.c
libweston/compositor-x11.c
libweston/compositor.c

index 5e87cb416d113d7959d16a62501825a534edc662..e3fe7d59531e7c124dd4258cb25a7e0e53dd3ca0 100644 (file)
@@ -3375,8 +3375,6 @@ create_output_for_connector(struct drm_backend *b,
 
        weston_output_init(&output->base, b->compositor);
 
-       wl_list_init(&output->base.mode_list);
-
        for (i = 0; i < output->connector->count_modes; i++) {
                drm_mode = drm_output_add_mode(output, &output->connector->modes[i]);
                if (!drm_mode) {
index 62ffa0ba5fbf7d4009a3a718d319938afe339d4d..9d49f4b950610fcd84d80317ffcf37a716455c0b 100644 (file)
@@ -523,7 +523,6 @@ fbdev_output_create(struct fbdev_backend *backend,
        output->mode.width = output->fb_info.x_resolution;
        output->mode.height = output->fb_info.y_resolution;
        output->mode.refresh = output->fb_info.refresh_rate;
-       wl_list_init(&output->base.mode_list);
        wl_list_insert(&output->base.mode_list, &output->mode.link);
 
        output->base.current_mode = &output->mode;
index 9e42e7f62e6366c0723b09541cec164a687d98b4..5425ad5bc146c9618e3927e31b8705c39c89568e 100644 (file)
@@ -201,7 +201,6 @@ headless_output_set_size(struct weston_output *base,
        output->mode.width = output_width;
        output->mode.height = output_height;
        output->mode.refresh = 60000;
-       wl_list_init(&output->base.mode_list);
        wl_list_insert(&output->base.mode_list, &output->mode.link);
 
        output->base.current_mode = &output->mode;
index ddc49ab6867fd16dd1e801ae1593e51769877917..2f9c9783d5d25fd0eef941dcacb19b0bebb7ffe8 100644 (file)
@@ -488,7 +488,6 @@ rdp_output_set_size(struct weston_output *base,
        assert(!output->base.current_mode);
 
        wl_list_init(&output->peers);
-       wl_list_init(&output->base.mode_list);
 
        initMode.flags = WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED;
        initMode.width = width;
index b144d6e5dffd33e21bcfcf102d1060f608324f87..1fb1be6c6ce401a0205b4b5408a80f99930d4c46 100644 (file)
@@ -1318,7 +1318,6 @@ wayland_output_set_size(struct weston_output *base, int width, int height)
        output->mode.height = output_height;
        output->mode.refresh = 60000;
        output->scale = output->base.scale;
-       wl_list_init(&output->base.mode_list);
        wl_list_insert(&output->base.mode_list, &output->mode.link);
 
        output->base.current_mode = &output->mode;
@@ -1369,7 +1368,6 @@ wayland_output_create_for_parent_output(struct wayland_backend *b,
        output->base.make = poutput->physical.make;
        output->base.model = poutput->physical.model;
 
-       wl_list_init(&output->base.mode_list);
        wl_list_insert_list(&output->base.mode_list, &poutput->mode_list);
        wl_list_init(&poutput->mode_list);
 
index 02cdf3eaf580b8f236e5d448f7413b3dab8ba88c..8cf512febf837b09f65c7eef51c382a8436a92aa 100644 (file)
@@ -999,7 +999,6 @@ x11_output_set_size(struct weston_output *base, int width, int height)
        output->mode.height = output_height;
        output->mode.refresh = 60000;
        output->scale = output->base.scale;
-       wl_list_init(&output->base.mode_list);
        wl_list_insert(&output->base.mode_list, &output->mode.link);
 
        output->base.current_mode = &output->mode;
index 878cd53513a5aecef6f531e1e4c603f68f59f46c..bed3cd8f5010c45f043905b043474edb7c9f1fe6 100644 (file)
@@ -4710,6 +4710,7 @@ weston_output_init(struct weston_output *output,
 
        pixman_region32_init(&output->previous_damage);
        pixman_region32_init(&output->region);
+       wl_list_init(&output->mode_list);
 }
 
 /** Adds weston_output object to pending output list.