Skip to content
Snippets Groups Projects
  1. Oct 30, 2017
    • Pekka Paalanen's avatar
      compositor-wayland: migrate to head-based output API · 56116fe6
      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>
      56116fe6
    • Pekka Paalanen's avatar
      compositor-wayland: strict surface create/destroy · 70157e69
      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>
      70157e69
    • Pekka Paalanen's avatar
      compositor-x11: migrate to head-based output API · f19a0a33
      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>
      f19a0a33
    • Pekka Paalanen's avatar
      compositor-fbdev: migrate to head-based output API · 99a5bf77
      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>
      99a5bf77
    • Pekka Paalanen's avatar
      compositor-fbdev: make re-enable less drastic · 99f69e7a
      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>
      99f69e7a
    • Pekka Paalanen's avatar
      compositor-rdp: migrate to head-based output API · 6013bd1a
      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>
      6013bd1a
    • Pekka Paalanen's avatar
      compositor-headless: migrate to head-based output API · 27c1fef5
      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>
      27c1fef5
    • Pekka Paalanen's avatar
      libweston: cancel idle_repaint on output destroy · 36230c31
      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>
      36230c31
    • Pekka Paalanen's avatar
      libweston: assert current_mode in weston_output_enable() · 9cf0fbcc
      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>
      9cf0fbcc
    • Pekka Paalanen's avatar
      libweston: assert make/model in weston_output_enable() · 8ae2bac9
      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>
      8ae2bac9
    • Pekka Paalanen's avatar
      libweston: stop auto-adding the implicit head · 51b10745
      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>
      51b10745
    • Pekka Paalanen's avatar
      libweston: remove output_pending_signal · 4a64975b
      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>
      4a64975b
    • Pekka Paalanen's avatar
      libweston: change windowed_output_api output_create to create_head · 9c4ad8d9
      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>
      9c4ad8d9
    • Pekka Paalanen's avatar
      weston: migrate DRM to head-based output API · 0dce94a8
      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>
      0dce94a8
    • Pekka Paalanen's avatar
      weston: migrate RDP to head-based output API · 3f447237
      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>
      3f447237
    • Pekka Paalanen's avatar
      weston: migrate fbdev to head-based output API · 99ce1196
      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>
      99ce1196
    • Pekka Paalanen's avatar
      weston: migrate wayland to head-based output API · e6edaeea
      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>
      e6edaeea
    • Pekka Paalanen's avatar
      weston: migrate x11 to head-based output API · 18fc7cc8
      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>
      18fc7cc8
    • Pekka Paalanen's avatar
      weston: migrate headless to head-based output API · dc9b8fb2
      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.
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      dc9b8fb2
    • Pekka Paalanen's avatar
      weston: move weston_output_enable() into callers · c02e03ed
      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>
      c02e03ed
    • Pekka Paalanen's avatar
      libweston: add weston_head_is_device_changed() API · 14e30e3a
      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>
      14e30e3a
    • Pekka Paalanen's avatar
      libweston: add weston_head destroy signal · 32be86c0
      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>
      32be86c0
    • Pekka Paalanen's avatar
      libweston: new head-based output management API · dce9144e
      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.
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      dce9144e
    • Pekka Paalanen's avatar
      libweston: add heads_changed hook · 9551bfc0
      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>
      9551bfc0
    • Pekka Paalanen's avatar
      libweston: add compositor list of heads · e907c24a
      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>
      e907c24a
    • Pekka Paalanen's avatar
      libweston: add weston_head::connected · 88745065
      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>
      88745065
    • Pekka Paalanen's avatar
      libweston: add name to weston_head · 83e6100b
      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>
      83e6100b
    • Pekka Paalanen's avatar
      cms-colord: find a good head · 219da4d9
      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>
      219da4d9
    • Pekka Paalanen's avatar
      libweston: strdup head make, model, serial_number · 312b09e1
      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>
      312b09e1
    • Pekka Paalanen's avatar
      libweston: introduce weston_output::head_list · 5c9a0d68
      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>
      5c9a0d68
    • Pekka Paalanen's avatar
      libweston: refactor weston_mode_switch_finish · cb1dd829
      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>
      cb1dd829
    • Pekka Paalanen's avatar
      libweston: make wl_output point to weston_head · 07da0128
      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>
      07da0128
    • Pekka Paalanen's avatar
      libweston: use head in wl_output global · 884bf1ca
      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>
      884bf1ca
    • Pekka Paalanen's avatar
      libweston: move wl_output to weston_head · f46882c3
      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>
      f46882c3
    • Pekka Paalanen's avatar
      libweston: introduce weston_head · edd9b81f
      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>
      edd9b81f
    • Pekka Paalanen's avatar
      weston: arm SEGV handler earlier · cf967358
      Pekka Paalanen authored
      
      It is useful to print the backtrace regardless of whether we have a
      compositor and a backend initialized yet. Move catch_signals() to the
      earliest point in main() and protect the SEGV handler from dereferencing
      NULL when we don't yet have a compositor or a backend.
      
      The SEGV handler uses weston_log(), so cannot move catch_signals() any
      earlier.
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      cf967358
  2. Oct 24, 2017
Loading