Skip to content
Snippets Groups Projects
  1. Dec 13, 2017
    • Pekka Paalanen's avatar
      compositor-wayland: migrate to head-based output API · c892d93d
      Pekka Paalanen authored
      
      Follow the standard pattern used in the headless and x11 backend
      migration, but also cater for the two other backend modes: --sprawl or
      fullscreen-shell, and --fullscreen.
      
      Stops relying on the implicit weston_output::head.
      
      Unlike other backends, this uses the attach_head hook to do the
      required head setup that is not possible to do without an output, but
      must be done before weston_output_enable(). This also requires the
      detach_head hook for the one case where the user attaches a --fullscreen
      head and then detaches it without enabling the output.
      
      It is a little awkward to fully initialize heads as late as attach, but
      aside from the --sprawl/fullscreen-shell case, there is not really a way
      to know the head properties without creating the parent wl_surface and
      configuring it.
      
      Heads/outputs created for parent outputs now have distinct names instead
      of all being called "wlparent".
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      c892d93d
    • Pekka Paalanen's avatar
      compositor-wayland: strict surface create/destroy · 23b8cccc
      Pekka Paalanen authored
      
      Add safeguards to make it painfully obvious if we ever get the pairing
      of wayland_backend_create_output_surface() and
      wayland_backend_destroy_output_surface() wrong. Helps catching bugs.
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      23b8cccc
    • Pekka Paalanen's avatar
      compositor-x11: migrate to head-based output API · 52c7aa12
      Pekka Paalanen authored
      
      Follow the standard pattern set by the headless backend which also uses
      the the window output API.
      
      Stops relying on the implicit weston_output::head.
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      52c7aa12
    • Pekka Paalanen's avatar
      compositor-fbdev: migrate to head-based output API · b8c7479b
      Pekka Paalanen authored
      
      Implement the head-based output API in this backend, and stop relying on
      the implicit weston_output::head.
      
      The split between fbdev_head and fbdev_output is somewhat arbitrary.
      There is no hotplug or unplug, and there is always 1:1 relationship.
      Struct fbdev_screeninfo could have been split as well, but it would not
      have made much difference.
      
      I chose fbdev_output to carry the mmap details (buffer_length is now
      duplicated here), and fbdev_head to carry the display parameters and
      device node path. The device node identifies the head, similar to a
      connector.
      
      The backend init creates a head. The compositor uses it to create an
      output. Libweston core attaches the head automatically after creating
      the output. The attach hook is a suitable place to set up the video
      modes on the output as they are dictated by the head, it would be too
      late at enable() time.
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      b8c7479b
    • Pekka Paalanen's avatar
      compositor-fbdev: make re-enable less drastic · 8d6304a2
      Pekka Paalanen authored
      
      Destroying the whole output in reenable would cause list walk
      corruption: the loop over output_list in session_notify() is not using
      wl_list_for_each_safe so output removal would break it.
      
      Creating a new output is also problematic as it needs the compositor to
      configure it, but that probably saved us from another list walk failure:
      adding the new output to be list while walking the list, possibly
      causing it to be destroyed and re-created ad infinitum.
      
      Instead of a complete destroy/create cycle, just do our internal
      disable/enable cycle. That will re-open the fbdev, re-read the
      parameters, re-create hw_surface, and reinitialize the renderer output.
      
      A problem with this is if fbdev_set_screen_info() fails. We do read the
      new parameters, but we don't communicate them to libweston core or old
      clients.
      
      However, it is hard to care: to trigger this path, one needs to
      VT-switch to another fbdev app which changes the fbdev parameters. That
      is quite difficult as VT-switching has been broken for a good while for
      fbdev-backend, at least with logind. Also fbdev_set_screen_info() would
      have to fail before one should be able to tell something is wrong.
      
      The real reason behind this patch, though, is the migration to the
      head-based output API. Destroying and re-creating an output really does
      not fit that design. Destroying and re-creating a head would be better,
      but again not testable in the current state.
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      8d6304a2
    • Pekka Paalanen's avatar
      compositor-rdp: migrate to head-based output API · 34c3ef46
      Pekka Paalanen authored
      
      Follow the starndard patttern as the other backends, headless and x11 in
      particular, to stop relying on the implicit weston_output::head.
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      34c3ef46
    • Pekka Paalanen's avatar
      compositor-headless: migrate to head-based output API · 5735daee
      Pekka Paalanen authored
      
      Implement the head-based output API in this backend, and stop relying on
      the implicit weston_output::head.
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      5735daee
    • Pekka Paalanen's avatar
      libweston: cancel idle_repaint on output destroy · 424bb4a9
      Pekka Paalanen authored
      
      If the idle_repaint() callback has been scheduled when a weston_output
      gets destroyed, the callback will hit use-after-free. I have encountered
      this when migrating the wayland backend to the head-based API, using
      --sprawl, and closing/disconnecting one of the parent compositor
      outputs.
      
      Store the idle_repaint callback source, and destroy it in
      weston_output_release(), ensuring we don't get a stale call to
      start_repaint_loop later.
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      424bb4a9
    • Pekka Paalanen's avatar
      libweston: assert current_mode in weston_output_enable() · c4abf076
      Pekka Paalanen authored
      
      The functions called here, particularly
      weston_output_transform_scale_init(), rely on current mode being set.
      The current mode must also be found in the mode list, though we don't
      explicitly check it here.
      
      current_mode not being set is a programmer error. It could be a backend
      bug, but it could also be a libweston user bug not calling a set size
      function.
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      c4abf076
    • Pekka Paalanen's avatar
      libweston: assert make/model in weston_output_enable() · e9cf4138
      Pekka Paalanen authored
      
      Output make and model are not allowed to be NULL in the protocol, so
      ensure they are not forgotten when enabling an output.
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      e9cf4138
    • Pekka Paalanen's avatar
      libweston: stop auto-adding the implicit head · 6db5303e
      Pekka Paalanen authored
      
      All frontends have been converted to the new head-based output
      management API, which means that
      weston_compositor_create_output_with_head() is calling
      weston_output_attach_head(). We will never hit the implicit attach
      anymore.
      
      Therefore we can now require that an output has at least one head when
      calling weston_output_enable(). An output without heads is useless.
      
      The auto-add code is removed as dead.
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      6db5303e
    • Pekka Paalanen's avatar
      libweston: remove output_pending_signal · 2d837841
      Pekka Paalanen authored
      
      The signal has been replaced with the heads_changed hook and is no
      longer useful.
      
      weston_pending_output_coldplug() is renamed to
      weston_compositor_flush_heads_changed() for two reasons: it better
      describes what it does now, and it serves as an obvious flag that
      libweston ABI has been broken.
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      2d837841
    • Pekka Paalanen's avatar
      libweston: change windowed_output_api output_create to create_head · 8c5601da
      Pekka Paalanen authored
      
      Rename the function pointer to create_head() because that is what it
      does on backends that are converted to the head-based API. Update the
      documentation to match.
      
      Surprisingly this is not an ABI break, as the function behaviour and
      signature remain intact. Hence API_NAME is not bumped.
      
      This is only an API break, and main.c is fixed accordingly.
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      8c5601da
    • Pekka Paalanen's avatar
      weston: migrate DRM to head-based output API · 8f77d4dd
      Pekka Paalanen authored
      
      Migrate the DRM frontend to use the simple head-based output
      configurator, maintaining the exact same features and semantics as
      before.
      
      This is an intermediate step. It is unoptimal to create a weston_output
      just to turn it off, but the libweston implementation and the DRM
      backend require it for now. In the future, the DRM frontend will get its
      own configurator that does not create useless weston_outputs and
      supports clone mode by attaching multiple heads to the same
      weston_output. Clone mode is not yet supported by libweston/DRM.
      
      This is the last frontend migrated, wet_set_pending_output_handler() is
      deleted as dead code.
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      8f77d4dd
    • Pekka Paalanen's avatar
      weston: migrate RDP to head-based output API · 2e6d70d6
      Pekka Paalanen authored
      
      Migrate the RDP frontend to use the new head-based output configuration
      API: listen for heads_changed, and process all heads.
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      2e6d70d6
    • Pekka Paalanen's avatar
      weston: migrate fbdev to head-based output API · 3a565d21
      Pekka Paalanen authored
      
      Migrate the fbdev frontend to use the new head-based output
      configuration API: listen for heads_changed, and process all heads.
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      3a565d21
    • Pekka Paalanen's avatar
      weston: migrate wayland to head-based output API · bed7da3a
      Pekka Paalanen authored
      
      Migrate the Wayland frontend to use the new head-based output
      configuration API: listen for heads_changed, and process all heads.
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      bed7da3a
    • Pekka Paalanen's avatar
      weston: migrate x11 to head-based output API · 138173d0
      Pekka Paalanen authored
      
      Migrate the x11 frontend to use the new head-based output configuration
      API: listen for heads_changed, and process all heads.
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      138173d0
    • Pekka Paalanen's avatar
      weston: migrate headless to head-based output API · 526a96c7
      Pekka Paalanen authored
      
      Migrate the headless frontend to use the new head-based output
      configuration API: listen for heads_changed, and process all heads.
      
      The simple_heads_changed() function is written to be able to cater for
      all backends. The rest will be migrated individually.
      
      The head destroy listeners are not exactly necessary, for headless
      anyway, but this is an example excercising the API. Also
      is_device_changed() check is mostly useful with DRM.
      
      v3: Print "Detected a monitor change" only for enabled heads.
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      526a96c7
    • Pekka Paalanen's avatar
      weston: move weston_output_enable() into callers · 3e7b7279
      Pekka Paalanen authored
      
      Move the call out of wet_configure_windowed_output_from_config() and
      into its callers.
      
      This allows to migrate each frontend one by one.
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      3e7b7279
    • Pekka Paalanen's avatar
      libweston: add weston_head_is_device_changed() API · b8625c2a
      Pekka Paalanen authored
      
      Reacting to DRM hotplug events is racy. It is theoretically possible to
      get hotplug events for a quick swap from one monitor to another and
      process both only after the new monitor is connected. Hence it is
      possible for display device information to change without going through
      a disconnected state for the head.
      
      To support such cases, add API to allow detecting it in the compositor.
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      b8625c2a
    • Pekka Paalanen's avatar
      libweston: add weston_head destroy signal · b15db7e1
      Pekka Paalanen authored
      
      Add support for subscribing to weston_head destruction.
      
      The primary use case for heads being destroyed arbitrarily is the
      DRM-backend with MST connectors, which may disappear on unplug. It is
      not just the connector becoming disconnected, it is the connector
      actually disappearing.
      
      The compositor needs to know about disappearing heads so that it has a
      chance to clean up "orphaned" outputs which do get disabled but still
      need destroying at run time. Shutdown would destroy them as well.
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      b15db7e1
    • Pekka Paalanen's avatar
      libweston: new head-based output management API · 521641d9
      Pekka Paalanen authored
      
      Introduce the API for users (compositors) to create an output from a
      head, attach and detach heads, and destroy outputs created this way.
      This also adds the backend-facing API to libweston.
      
      In the new API design, a backend creates heads, and the compositor
      chooses one or more heads (clone mode) to be driven by an output.
      In the future backends will be converted to not create outputs directly
      but only in the new create_output hook.
      
      The user subscribes to a heads_changed hook and arranges heads into
      outputs from there.
      
      Adding the API this way will allow frontends (main.c) and backends to be
      converted one by one. This adds compatiblity paths in
      weston_compositor_create_output_with_head() and weston_output_destroy()
      so that frontends can be converted first to call these, and then
      backends can be converted one by one to the new design. Afterwards, the
      compatibility paths will be removed along with weston_output::head.
      
      Currently heads can be added to a disabled output only. This is less
      than ideal for clone mode hotplug and should be improved on later.
      
      v4: Remove the wl_output global on head detach if output is enabled.
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      521641d9
    • Pekka Paalanen's avatar
      libweston: add heads_changed hook · 3de12182
      Pekka Paalanen authored
      
      Add a hook for compositors to get a callback when heads are added or
      their connection status changes, to which compositors likely want to
      react to by enabling or disabling outputs (API for that to be added
      later).
      
      As many head changes as possible should be coalesced into a single
      heads_changed call. Therefore the callback is made from an idle task.
      This anticipates a future atomic output configuration API, where the
      global output configuration is tested and set atomically instead of one
      by one.
      
      weston_pending_output_coldplug() needs to manually execute the
      heads_changed call so that initial outputs are created before any
      plugins get their start-up idle tasks ran. This is especially important
      for ivi-shell which does not support output hotplug, and for tests to
      guarantee the expected outputs.
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      3de12182
    • Pekka Paalanen's avatar
      libweston: add compositor list of heads · 80449cf9
      Pekka Paalanen authored
      
      weston_compositor needs to maintain a list of all available heads, so
      that a compositor can pick and choose which heads to take into or out of
      use at arbitrary times. The heads may be on or off, and connected or
      disconnected.
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      80449cf9
    • Pekka Paalanen's avatar
      libweston: add weston_head::connected · f11631bf
      Pekka Paalanen authored
      
      Heads may be disconnected or connected and the compositor needs to be
      able to know the state to know which heads to take into use.
      
      Currently a single head is automatically created with an output, and
      outputs are only ever created as connected and destroyed on
      disconnection, so it suffices to set connected to true. In the future,
      backends are expected to create heads for both connected and
      disconnected connectors, so that a connector can be forced on without it
      being actually connected.
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      f11631bf
    • Pekka Paalanen's avatar
      libweston: add name to weston_head · 0797f37b
      Pekka Paalanen authored
      
      Heads need to be named, so they can be referenced in logs and
      configuration sources.
      
      When clone mode is implemented, output and head names may differ.
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      0797f37b
    • Pekka Paalanen's avatar
      cms-colord: find a good head · 5a5ff625
      Pekka Paalanen authored
      
      The 'head' member of 'struct weston_output' is going to go unused and
      then disappear, so stop using it and find a head from the proper list.
      
      However, this leaves a problem in cms-colord: if you have multiple
      monitors driver with the same CRTC, what do you say to the color
      management system? The monitors could be different, but all the color
      LUTs etc. are in the CRTC and are shared, as is the framebuffer.
      
      Do the simple hack here and just use whatever head happens to be the
      first in the list.
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      5a5ff625
    • Pekka Paalanen's avatar
      libweston: strdup head make, model, serial_number · 8891d62b
      Pekka Paalanen authored
      
      Duplicate these strings to decouple their lifetime from whatever the
      backends used. This should prevent hard to catch use after frees and
      such problems in the future.
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      Reviewed-by: default avatarQuentin Glidic <sardemff7+git@sardemff7.net>
      8891d62b
    • Pekka Paalanen's avatar
      libweston: properly orphan wl_output resources · dd114d4a
      Pekka Paalanen authored
      
      Remove the wl_resource in the head's resource list when we are
      removing the wl_output global. We sent global removal events to clients,
      the resources should become dummies until clients reap them. Reset user
      data so that clients triying to use dummy objects don't hit e.g. a freed
      head pointer.
      
      This fixes a theoretical issue: if an enabled output is disabled and
      then gets enabled again, mode changes and wl_surface.enter/leave would
      still attempt to use the dummy objects. If a client destroyed a dummy
      object, we don't have the destructor to remove it from the resource
      list, and libweston would hit freed memory.
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      dd114d4a
    • Pekka Paalanen's avatar
      libweston: introduce weston_output::head_list · 0015a413
      Pekka Paalanen authored
      
      The intention is that in the future backends will dynamically allocate
      weston_heads based on the resources they have. The lifetime of a
      weston_head will be independent of the lifetime of a weston_output it
      may be attached to. Backends allocate objects derived from weston_head,
      like they currently do for weston_output. Backend will choose when to
      destroy a weston_head.
      
      For clone mode, struct weston_output gains head_list member, which is
      the list of attached heads that will all show the same framebuffer.
      Since heads are growing out of weston_output, management functions are
      added.
      
      Detaching a head from an enabled output is allowed to accommodate
      disappearing heads. Attaching a head to an enabled output is disallowed
      because it may need hardware reconfiguration and testing, and so
      requires a weston_output_enable() call.
      
      As a temporary measure, we have one weston_head embedded in
      weston_output, so that backends can be migrated individually to the new
      allocation scheme.
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      0015a413
    • Pekka Paalanen's avatar
      libweston: refactor weston_mode_switch_finish · 772687c9
      Pekka Paalanen authored
      
      Split out a new function. This is a pure refactoring, no change in
      behaviour.
      
      This helps a following patch that adds a loop over output->head_list.
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      Reviewed-by: default avatarQuentin Glidic <sardemff7+git@sardemff7.net>
      772687c9
    • Pekka Paalanen's avatar
      libweston: make wl_output point to weston_head · 5cf73d05
      Pekka Paalanen authored
      
      The user data of a wl_resource representing a wl_output protocol object
      used to be a pointer to weston_output. Now that weston_output is being
      split, wl_output more accurately refers to weston_head which is a single
      monitor.
      
      Change the wl_output user data to point to weston_head.
      weston_output_from_resource() is replaced with
      weston_head_from_resource().
      
      This change is not strictly necessary, but architecturally it is the
      right thing to do. In the future there might appear the need to refer to
      a specific head of a cloned pair, for instance.
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      5cf73d05
    • Pekka Paalanen's avatar
      libweston: use head in wl_output global · 8930229f
      Pekka Paalanen authored
      
      As a wl_output represents weston_head, use a weston_head pointer as the
      wl_output global's user data.
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      8930229f
    • Pekka Paalanen's avatar
      libweston: move wl_output to weston_head · 2d79cf90
      Pekka Paalanen authored
      
      The wl_output protocol interface exposes things like monitor make,
      model, sub-pixel layout and physical dimensions. Obviously wl_output is
      meant to represent a monitor.
      
      The abstraction of a monitor is weston_head. Therefore move the wl_output
      global and the bound resources list into weston_head.
      
      When clone mode gets implemented in the future, this means that monitors
      driven by the same CRTC will still be represented as separate wl_output
      globals. This allows to accurately represent the hardware.
      
      Clone mode that used separate, not frame-locked, CRTCs to drive two
      monitors as clones would necessarily also be exposed as separate
      wl_output since they have different timings.
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      2d79cf90
    • Pekka Paalanen's avatar
      libweston: introduce weston_head · f5d9e53e
      Pekka Paalanen authored
      
      In order to support clone modes, libweston needs the concept of a head
      that is separate from weston_output. While weston_output manages buffers
      and the repaint state machine, weston_head will represent a single
      monitor. In the future it will be possible to have a single
      weston_output drive one or more weston_heads for a clone mode that
      shares the framebuffers between all cloned heads.
      
      All the fields that are obviously properties of the monitor are moved
      from weston_output into weston_head.
      
      As moving the fields requires one to touch all the backends for all the
      assingments, introduce setter functions for them while we are here. The
      setters are identical to the old assignments, for now.
      
      As a temporary measure, weston_output embeds a single head. Also the
      ugly casts in weston_head_set_monitor_strings() will be removed by a
      follow-up patch.
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      f5d9e53e
  2. Dec 12, 2017
  3. Dec 11, 2017
Loading