Skip to content
Snippets Groups Projects
  1. Oct 31, 2017
    • Pekka Paalanen's avatar
      libweston: remove weston_output::head · 8d63fd8c
      Pekka Paalanen authored
      
      Remove the scaffolding that allowed backends to be converted one by one
      to the head-based API. Nothing is using these members anymore.
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      8d63fd8c
    • Pekka Paalanen's avatar
      compositor-drm: drm_set_backlight heads · 0b806037
      Pekka Paalanen authored
      
      Fix this function to support more than one head per output.
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      0b806037
    • Pekka Paalanen's avatar
      compositor-drm: drm_output_apply_state_atomic heads · 8553dbdb
      Pekka Paalanen authored
      
      Fix this function to support more than one head per output.
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      8553dbdb
    • Pekka Paalanen's avatar
      compositor-drm: drm_output_apply_state_legacy heads · fc517e84
      Pekka Paalanen authored
      
      Fix this function to support more than one head per output.
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      fc517e84
    • Pekka Paalanen's avatar
      compositor-drm: create heads for all connectors · d0216b51
      Pekka Paalanen authored
      
      In previous patches, all the appropriate fields from drm_output have
      been moved into drm_head, and resource allocation has been moved away
      from drm_output creation. It is time to throw the switch: this patch
      disconnects the drm_output and drm_head lifetimes.
      
      Previously a drm_output was created for a connected connector and
      destroyed on disconnection. A drm_head was tied to the drm_output
      lifetime just to accommodate the head-based output configuration API
      temporarily.
      
      Now all connectors will get a head created regardless of their
      connection status. Heads are created and destroyed as connectors appear
      and disappear (MST), not when they get connected or disconnected. This
      should allow the compositor to force-enable a disconnected connector.
      
      An "empty" drm_output is created with weston_backend::create_output()
      hook. This now follows the intent of the head-based output configuration
      API.
      
      On hotplug events, all connectors' information is updated regardless of
      their connection status changes. It is theoretically possible for a
      monitor to change without going through a disconnected state in between.
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      d0216b51
    • Pekka Paalanen's avatar
      compositor-drm: drm_property_info_free() must reset · 75bf4a08
      Pekka Paalanen authored
      
      This function needs to reset the structures to NULL, otherwise it is not
      possible to re-use a once "freed" property info array.
      
      Being able to re-use an array is useful when the memory allocation and
      array lifetimes do not match. A specific example is drm_output that is
      changed to allocate the CRTC on enable() and deallocate it on disable().
      A drm_output might be enabled and disabled multiple times.
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      75bf4a08
    • Pekka Paalanen's avatar
      compositor-drm: remove unused_connectors array · 94e14764
      Pekka Paalanen authored
      
      Replace the unused_connectors array by iterating through the head list
      instead. A head that is not enabled (attached to an enabled output) is
      basically an unused connector.
      
      The primary motivation here is to remove a user of
      drm_output_find_by_connector() so that a following patch can remove the
      function.
      
      This fixes some confusion on which connectors should have been in
      unused_connectors array. When an output was created due to hotplug, even
      before taking it into use, it would count as a used connector because of
      drm_output_find_by_connector() used in drm_backend_update_outputs().
      OTOH, drm_output_enable() removed the connector from unused_connectors
      while drm_output_disable() puts the connector into unused_connectors. A
      connector can be both unused or not when a non-enabled output exists for
      it.
      
      A second hotplug event would cause drm_backend_update_outputs() to
      override any previous enable/disable setup. So we also relied on hotplug
      events to not occur before the compositor configured the new outputs.
      
      Now I realize it was meant to avoid flicker. After hotplug, if weston
      repaints before the compositor explicitly configures the output, this
      "confusion" avoids automatically turning off the connector. If the
      compositor chooses to drive the connector, we might flicker.
      
      However, in what circumstances can a connector be hotplugged while
      already active? That should only happen on compositor start-up, because
      later we have already disabled all connectors and CRTCs we are not
      using.
      
      Therefore removing the "confusion" is harmless. On compositor start-up,
      we detect all connected connectors and create outputs for them, and then
      the explicit call to weston_compositor_flush_heads_changed() will
      guarantee all connectors will be set up before Weston goes into the
      first repaint that will disable all unused connectors.
      
      What about VT-switch in?
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      94e14764
    • Pekka Paalanen's avatar
      compositor-drm: move mode list to set_mode() · 31d12792
      Pekka Paalanen authored
      
      Move the initialization of the drm_output mode list to
      drm_output_set_mode() time.
      
      Once we stop creating the drm_head with the drm_output, there will not
      be a head to get the mode list from at drm_output creation time.
      
      Furthermore, once DRM-backend starts supporting more than one head per
      output, the combined mode list to be exposed to clients (and the
      compositor?) must be constructed with all heads attached.
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      31d12792
    • Pekka Paalanen's avatar
      compositor-drm: refactor into drm_mode_list_destroy() · 6e25da5c
      Pekka Paalanen authored
      
      I need to destroy the list from more places, so factor out the common
      bits. No functional changes.
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      6e25da5c
    • Pekka Paalanen's avatar
      compositor-drm: get current mode on head discovery · 849595cf
      Pekka Paalanen authored
      
      The inherited mode is the video mode on the connector when we have not
      yet reconfigured the connector, if set.
      
      Get the inherited mode the moment we create a drm_head, not when we
      determine the mode for a drm_output. This way we are sure to read all
      inherited modes before we reconfigure a single CRTC. Enabling one output
      may grab the CRTC from another connector, overwriting whatever mode that
      connector might have had.
      
      The inherited mode is stored in drm_head, where we can keep it for the
      lifetime of the head, rather than relying on re-loading it from the
      kernel at set_mode() time.
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      849595cf
    • Pekka Paalanen's avatar
      compositor-drm: simplify drm_output_find_special_plane() · be198d8e
      Pekka Paalanen authored
      
      As these planes are allocated on output enable and freed on output
      disable, there cannot be a match in the pending_output_list.
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      be198d8e
    • Pekka Paalanen's avatar
      compositor-drm: simplify drm_output_find_by_crtc() · d69d750f
      Pekka Paalanen authored
      
      As CRTC is allocated on output enable and deallocated on output disable,
      there cannot be any matches in find-by-crtc from the
      pending_output_list.
      
      Remove the loop over pending_output_list as never finding anything by
      definition.
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      d69d750f
    • Pekka Paalanen's avatar
      compositor-drm: allocate CRTC on enable() · 809e75a6
      Pekka Paalanen authored
      
      A drm_output needs a CRTC only when it is in use. Allocating a CRTC on
      creation of drm_output will reserve the CRTC regardless of whether the
      output is actually used or not. This may cause creating other
      drm_outputs to fail if there are not enough CRTCs.
      
      Instead, allocate the CRTC on drm_output enable() time. A drm_output
      will have a valid CRTC only while it is enabled.
      
      This allows us to create drm_output objects arbitrarily and without a
      head assignment, which is required by the head-based output API for the
      backends. The assigned heads will be known only at enable() time.
      
      Now drm_output_enable() has to call drmModeGetResources() to be able to
      find a suitable CRTC. We might want to cache the resources somewhere,
      but that is it topic for another patch.
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      809e75a6
    • Pekka Paalanen's avatar
      compositor-drm: factor out drm_output_init_crtc() · 1cc417a0
      Pekka Paalanen authored
      
      Factor out drm_output_init_crtc() and drm_output_fini_crtc(), so that
      the call sites can later be moved easily.
      
      In the fini path scanout_plane can be NULL if drm_output_init_crtc()
      fails. create_ouput_for_connector() will then call drm_output() which
      calls fini.
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      1cc417a0
    • Pekka Paalanen's avatar
      compositor-drm: factor out drm_output_init_gamma_size() · f62032c6
      Pekka Paalanen authored
      
      Move this bit of code into its own function. The caller of this already
      cluttered and origcrtc is not used for anything else.
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      f62032c6
    • Pekka Paalanen's avatar
      compositor-drm: move connector fields into drm_head · 62cd7cec
      Pekka Paalanen authored
      
      Move the connector related fields from drm_output to the drm_head. A
      drm_head represents a connector for now.
      
      The code in drm_head_create() to update connector data, monitor
      information, etc. is moved into a new function. This will be useful when
      DRM-backend starts creating heads for all connectors regardless of their
      connection status and will need to update them on hotplug events.
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      62cd7cec
    • Pekka Paalanen's avatar
    • Pekka Paalanen's avatar
      compositor-drm: move backlight into drm_head · 5b3998bb
      Pekka Paalanen authored
      
      Backlight is driven per connector, hence it belongs in struct drm_head.
      
      weston_output::set_backlight() API is remains per output so far. There
      is no UI to control backlights per head and adding one would be
      difficult for an output that has multiple cloned heads.
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      5b3998bb
    • Pekka Paalanen's avatar
      compositor-drm: find disconnects from head_list · 331ca8e2
      Pekka Paalanen authored
      
      Instead of iterating output_list and pending_output_list, iterate
      head_list to find outputs whose connectors have been disconnected.
      
      This helps a following patch to move connector fields from drm_output to
      drm_head.
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      331ca8e2
    • Pekka Paalanen's avatar
      compositor-drm: drm_output_find_by_connector from head_list · 48cb343c
      Pekka Paalanen authored
      
      Switch drm_output_find_by_connector() to search for the output by
      iterating the compositor's head_list. drm_head_find_by_connector() will
      be useful later on its own.
      
      As of "compositor-drm: start migration to head-based output API" the
      head list is guaranteed to contain all created drm_outputs through the
      automatically created drm_head.
      
      Note: drm_backend_update_unused_outputs() seems to conflict with
      drm_output_enable()/drm_output_disable() on when a connector ID belongs
      in the unused_connectors array. This patch is preserving the old
      semantics and confusion.
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      48cb343c
    • Pekka Paalanen's avatar
      compositor-drm: start migration to head-based output API · c93595c7
      Pekka Paalanen authored
      
      Hook up the libweston facing head-based output API by introducing struct
      drm_head, but leave it as a fake so that members can be migrated in
      pieces in follow-up patches.
      
      The DRM backend continues to create an output for each connected
      connector only, and during output creation it also creates a drm_head
      for it. This allows it to pretend it supports the head-based output API
      as long as there is only one head per output ever attached.
      
      create_output callback is fake, it will only look up the existing
      drm_output by the head name.
      
      Clones are not yet supported, hence max is defined to 1.
      
      This unfortunately introduces some temporary code that will be revomed
      later, but seems to be necessary to avoid a single big patch.
      
      Signed-off-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
      c93595c7
    • Pekka Paalanen's avatar
      compositor-wayland: migrate to head-based output API · 142f30c0
      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>
      142f30c0
    • Pekka Paalanen's avatar
      compositor-wayland: strict surface create/destroy · 7b04b980
      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>
      7b04b980
    • Pekka Paalanen's avatar
      compositor-x11: migrate to head-based output API · 4b005e0f
      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>
      4b005e0f
    • Pekka Paalanen's avatar
      compositor-fbdev: migrate to head-based output API · 4c1f89bd
      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>
      4c1f89bd
    • Pekka Paalanen's avatar
      compositor-fbdev: make re-enable less drastic · cc5eed22
      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>
      cc5eed22
    • Pekka Paalanen's avatar
      compositor-rdp: migrate to head-based output API · aebb9003
      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>
      aebb9003
    • Pekka Paalanen's avatar
      compositor-headless: migrate to head-based output API · e6ab1336
      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>
      e6ab1336
    • Pekka Paalanen's avatar
      libweston: cancel idle_repaint on output destroy · d0bac75b
      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>
      d0bac75b
    • Pekka Paalanen's avatar
      libweston: assert current_mode in weston_output_enable() · 3974e810
      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>
      3974e810
    • Pekka Paalanen's avatar
      libweston: assert make/model in weston_output_enable() · cc8d107d
      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>
      cc8d107d
    • Pekka Paalanen's avatar
      libweston: stop auto-adding the implicit head · 316d0dee
      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>
      316d0dee
    • Pekka Paalanen's avatar
      libweston: remove output_pending_signal · eda8f9fe
      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>
      eda8f9fe
    • Pekka Paalanen's avatar
      libweston: change windowed_output_api output_create to create_head · 5ae50cea
      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>
      5ae50cea
    • Pekka Paalanen's avatar
      weston: migrate DRM to head-based output API · d75a2653
      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>
      d75a2653
    • Pekka Paalanen's avatar
      weston: migrate RDP to head-based output API · c2e01414
      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>
      c2e01414
    • Pekka Paalanen's avatar
      weston: migrate fbdev to head-based output API · 9f2ff255
      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>
      9f2ff255
    • Pekka Paalanen's avatar
      weston: migrate wayland to head-based output API · 00cf8164
      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>
      00cf8164
    • Pekka Paalanen's avatar
      weston: migrate x11 to head-based output API · e153fccd
      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>
      e153fccd
    • Pekka Paalanen's avatar
      weston: migrate headless to head-based output API · 40be9536
      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>
      40be9536
Loading