1. 20 Jun, 2019 21 commits
    • Jonas Ådahl's avatar
      crtc/kms: Outsource CRTC state fetching to MetaKmsCrtc · 596376c4
      Jonas Ådahl authored
      Move reading state into a struct for MetaCrtcKms to use instead of
      querying KMS itself. The state is fetched in the impl context, but
      consists of only simple data types, so is made accessible publicly. As
      of this, MetaCrtcKms construction does not involve any manual KMS
      interaction outside of the MetaKms abstraction.
      
      GNOME/mutter#548
      GNOME/mutter!525
      596376c4
    • Jonas Ådahl's avatar
    • Jonas Ådahl's avatar
      kms: Add connector representation · f59d62bc
      Jonas Ådahl authored
      Represents drmModeConnector; both connected and disconnected. Currently
      only provides non-changing meta data. MetaOutputKms is changed to use
      MetaKmsConnector to get basic metadata, but variable metadata, those
      changing depending on what is connected (e.g. physical dimension, EDID,
      etc), are still manually retrieved by MetaOutputKms.
      
      GNOME/mutter#548
      GNOME/mutter!525
      f59d62bc
    • Jonas Ådahl's avatar
      gpu/kms: Fix connector id type in helper · 5d5d2965
      Jonas Ådahl authored
      It's a uint32_t, not a long.
      
      GNOME/mutter#548
      GNOME/mutter!525
      5d5d2965
    • Jonas Ådahl's avatar
      output/kms: Make drmModeEncoderPtr array local · 065bf752
      Jonas Ådahl authored
      It was only used within one function, where it was always created, but
      still was kept around indefinitely for no reason. Lets get rid of it
      from the MetaOutputKms struct.
      
      GNOME/mutter#548
      GNOME/mutter!525
      065bf752
    • Jonas Ådahl's avatar
      kms: Add plane representation · 4d3e8043
      Jonas Ådahl authored
      A plane is one of three possible: primary, overlay and cursor. Each
      plane can have various properties, such as possible rotations, formats
      etc. Each plane can also be used with a set of CRTCs.
      
      A primary plane is the "backdrop" of a CRTC, i.e. the primary output for
      the composited frame that covers the whole CRTC. In general, mutter
      composites to a stage view frame onto a framebuffer that is then put on
      the primary plane.
      
      An overlay plane is a rectangular area that can be displayed on top of
      the primary plane. Eventually it will be used to place non-fullscreen
      surfaces, potentially avoiding stage redraws.
      
      A cursor plane is a plane placed on top of all the other planes, usually
      used to put the mouse cursor sprite.
      
      Initially, we only fetch the rotation properties, and we so far
      blacklist all rotations except ones that ends up with the same
      dimensions as with no rotations. This is because non-180° rotations
      doesn't work yet due to incorrect buffer modifiers. To make it possible
      to use non-180° rotations, changes necessary include among other things
      finding compatible modifiers using atomic modesetting. Until then,
      simply blacklist the ones we know doesn't work.
      
      GNOME/mutter#548
      GNOME/mutter!525
      4d3e8043
    • Jonas Ådahl's avatar
      kms: Add CRTC representation · 15a2ccd2
      Jonas Ådahl authored
      Add MetaKmsCrtc to represent a CRTC on the associated device. Change
      MetaCrtcKms to use the ones discovered by the KMS abstraction. It still
      reads the resources handed over by MetaGpuKms, but eventually it will
      use only MetaKmsCrtc.
      
      MetaKmsCrtc is a type of object that is usable both from an impl task
      and from outside. All the API exposed via the non-private header is
      expected to be accessible from outside of the meta-kms namespace.
      
      GNOME/mutter#548
      GNOME/mutter!525
      15a2ccd2
    • Jonas Ådahl's avatar
      backends/native: Add basic KMS abstraction building blocks · fef5753a
      Jonas Ådahl authored
      The intention with KMS abstraction is to hide away accessing the drm
      functions behind an API that allows us to have different kind of KMS
      implementations, including legacy non-atomic and atomic. The intention
      is also that the code interacting with the drm device should be able to
      be run in a different thread than the main thread. This means that we
      need to make sure that all drm*() API usage must only occur from within
      tasks that eventually can be run in the dedicated thread.
      
      The idea here is that MetaKms provides a outward facing API other places
      of mutter can use (e.g. MetaGpuKms and friends), while MetaKmsImpl is
      an internal implementation that only gets interacted with via "tasks"
      posted via the MetaKms object. These tasks will in the future
      potentially be run on the dedicated KMS thread. Initially, we don't
      create any new threads.
      
      Likewise, MetaKmsDevice is a outward facing representation of a KMS
      device, while MetaKmsImplDevice is the corresponding implementation,
      which only runs from within the MetaKmsImpl tasks.
      
      This commit only moves opening and closing the device to this new API,
      while leaking the fd outside of the impl enclosure, effectively making
      the isolation for drm*() calls pointless. This, however, is necessary to
      allow gradual porting of drm interaction, and eventually the file
      descriptor in MetaGpuKms will be removed. For now, it's harmless, since
      everything still run in the main thread.
      
      #548
      !525
      fef5753a
    • Jonas Ådahl's avatar
      f3fd7cf9
    • Jonas Ådahl's avatar
      backend: Move GPU ownership from the monitor manager to the backend · 5c500ad4
      Jonas Ådahl authored
      Lets work towards making MetaMonitorManager about managing monitors, and
      not about managing GPUs. This changes other units to keep a pointer to
      the backend instead of a monitor manager, in case their ownership
      changed, or their main usage of the monitor manager was to look up GPUs.
      
      #548
      !525
      5c500ad4
    • Jonas Ådahl's avatar
      monitor-manager/kms: Use 'hotplug' event from MetaUdev · e7fd068a
      Jonas Ådahl authored
      Instead of dealing with udev details here, use the newly added 'hotplug'
      event emitted from MetaUdev.
      
      GNOME/mutter#548
      GNOME/mutter!525
      e7fd068a
    • Jonas Ådahl's avatar
      udev: Add 'hotplug' event · 171e5fc3
      Jonas Ådahl authored
      To be used my the monitor manager to handle hotplugs.
      
      GNOME/mutter#548
      GNOME/mutter!525
      171e5fc3
    • Jonas Ådahl's avatar
      udev: Add helpers to list DRM devices · 7b7d8813
      Jonas Ådahl authored
      Will be used to move out some udev related logic when adding GPUs.
      
      GNOME/mutter#548
      GNOME/mutter!525
      7b7d8813
    • Jonas Ådahl's avatar
      backends/native: Move some initialization from init() to initable_init() · 44905d96
      Jonas Ådahl authored
      This means we can report the errors properly, instead of logging a
      warning and calling exit(1).
      
      GNOME/mutter#548
      GNOME/mutter!525
      44905d96
    • Jonas Ådahl's avatar
      backends/native: Add udev abstraction layer · 73e8127d
      Jonas Ådahl authored
      To be used to signal devices added, hotplugs and other udev events.
      Currently the only event emitted is when a device is added.
      
      GNOME/mutter#548
      GNOME/mutter!525
      73e8127d
    • Jonas Ådahl's avatar
      backends/native: Remove instance private · 11e20055
      Jonas Ådahl authored
      The object struct definition itself is private, so the object instance
      private serves no purpose. Thus, move the fields into the object struct
      and remove the instance private struct.
      
      GNOME/mutter#548
      GNOME/mutter!525
      11e20055
    • Olivier Fourdan's avatar
      clutter/evdev: Implement togglekeys notification · 02fc0b45
      Olivier Fourdan authored
      Notify with a system sound when the modifiers lock state is changed.
      
      Closes: GNOME/mutter#637
      02fc0b45
    • Olivier Fourdan's avatar
      clutter/evdev: Do not reset timers on togglekeys · 36155f72
      Olivier Fourdan authored
      The “togglekeys” setting is to emit a sounds whenever the state of one
      of the modifiers keys (CAPS lock, NUM Lock, SCROLL lock) is changed, it
      has nothing to do with the rest of the accessibility settings.
      
      Therefore, there is no need to reset the various timers used by
      accessibility whenever the “togglekeys” setting is changed.
      
      GNOME/mutter!614
      36155f72
    • Olivier Fourdan's avatar
      xwayland: Fix build without <sys/random.h> · c63d0173
      Olivier Fourdan authored
      The include <sys/random.h> was added to glibc-2.25, previously was
      <linux/random.h>.
      
      Adjust meson build and code to accomodate both.
      
      Fixes: a8984a81 "xwayland: Generate a Xauth file and pass this to
                        Xwayland when starting it"
      
      !633
      c63d0173
    • Hans de Goede's avatar
      renderer-native: Fix compiler warning · 7fcdd60a
      Hans de Goede authored
      Fix the following compiler warning:
      ../src/backends/native/meta-renderer-native.c: In function ‘meta_renderer_native_create_view’:
      /usr/include/glib-2.0/glib/gmacros.h:523:17: warning: ‘formats’ may be used uninitialized in this function [-Wmaybe-uninitialized]
        523 |     { if (_ptr) (cleanup) ((ParentName *) _ptr); }                                                              \
            |                 ^
      ../src/backends/native/meta-renderer-native.c:773:22: note: ‘formats’ was declared here
        773 |   g_autoptr (GArray) formats;
            |                      ^~~~~~~
      
      GNOME/mutter!632
      7fcdd60a
    • Hans de Goede's avatar
      xwayland: Generate a Xauth file and pass this to Xwayland when starting it · a8984a81
      Hans de Goede authored
      Before this commit, sudo x11-app, e.g. sudo gvim /etc/some-file, fails
      when running a Wayland session. Where as doing this under a "GNOME on Xorg"
      session works fine. For a user switching from the Xorg session to the
      Wayland session, this is regression, which we want to avoid.
      
      This commit fixes this by creating and passing an xauth file to Xwayland when
      mutter starts it. Just like gdm or startx pass a xauth file to Xorg when they
      start Xorg.
      
      Fixes #643
      
      #643
      a8984a81
  2. 19 Jun, 2019 17 commits
  3. 18 Jun, 2019 2 commits
    • Jonas Ådahl's avatar
      renderer/native: Fix EGLSurface destruction order · d9fb11b0
      Jonas Ådahl authored
      Make sure to destroy the EGL surface after releasing held buffers,
      otherwise we'll get the following valgrind warnings:
      
      ==24016== Invalid read of size 8
      ==24016==    at 0x1739943F: release_buffer (platform_drm.c:73)
      ==24016==    by 0x49AC355: meta_drm_buffer_gbm_finalize (meta-drm-buffer-gbm.c:213)
      ==24016==    by 0x4B75B61: g_object_unref (gobject.c:3346)
      ==24016==    by 0x49B4B41: free_current_bo (meta-renderer-native.c:991)
      ==24016==    by 0x49B816F: meta_renderer_native_release_onscreen (meta-renderer-native.c:2971)
      ==24016==    by 0x5209441: _cogl_onscreen_free (cogl-onscreen.c:167)
      ==24016==    by 0x5208D81: _cogl_object_onscreen_indirect_free (cogl-onscreen.c:51)
      ==24016==    by 0x51C8066: _cogl_object_default_unref (cogl-object.c:103)
      ==24016==    by 0x5207989: _cogl_framebuffer_unref (cogl-framebuffer.c:1814)
      ==24016==    by 0x51C80B1: cogl_object_unref (cogl-object.c:115)
      ==24016==    by 0x53673C7: clutter_stage_view_dispose (clutter-stage-view.c:304)
      ==24016==    by 0x4B75AF2: g_object_unref (gobject.c:3309)
      ==24016==  Address 0x18e742a8 is 536 bytes inside a block of size 784 free'd
      ==24016==    at 0x4839A0C: free (vg_replace_malloc.c:540)
      ==24016==    by 0x17399764: dri2_drm_destroy_surface (platform_drm.c:231)
      ==24016==    by 0x1738550A: eglDestroySurface (eglapi.c:1145)
      ==24016==    by 0x5440286: eglDestroySurface (in /home/jonas/Dev/gnome/install/lib/libEGL.so.1.1.0)
      ==24016==    by 0x49613A5: meta_egl_destroy_surface (meta-egl.c:432)
      ==24016==    by 0x49B80F9: meta_renderer_native_release_onscreen (meta-renderer-native.c:2954)
      ==24016==    by 0x5209441: _cogl_onscreen_free (cogl-onscreen.c:167)
      ==24016==    by 0x5208D81: _cogl_object_onscreen_indirect_free (cogl-onscreen.c:51)
      ==24016==    by 0x51C8066: _cogl_object_default_unref (cogl-object.c:103)
      ==24016==    by 0x5207989: _cogl_framebuffer_unref (cogl-framebuffer.c:1814)
      ==24016==    by 0x51C80B1: cogl_object_unref (cogl-object.c:115)
      ==24016==    by 0x53673C7: clutter_stage_view_dispose (clutter-stage-view.c:304)
      ==24016==  Block was alloc'd at
      ==24016==    at 0x483AB1A: calloc (vg_replace_malloc.c:762)
      ==24016==    by 0x173997AE: dri2_drm_create_window_surface (platform_drm.c:145)
      ==24016==    by 0x17388906: _eglCreateWindowSurfaceCommon (eglapi.c:929)
      ==24016==    by 0x5440197: eglCreateWindowSurface (in /home/jonas/Dev/gnome/install/lib/libEGL.so.1.1.0)
      ==24016==    by 0x49612FF: meta_egl_create_window_surface (meta-egl.c:396)
      ==24016==    by 0x49B752E: meta_renderer_native_create_surface_gbm (meta-renderer-native.c:2538)
      ==24016==    by 0x49B7E6C: meta_onscreen_native_allocate (meta-renderer-native.c:2870)
      ==24016==    by 0x49B8BCF: meta_renderer_native_create_view (meta-renderer-native.c:3387)
      ==24016==    by 0x48D274B: meta_renderer_create_view (meta-renderer.c:78)
      ==24016==    by 0x48D27DE: meta_renderer_rebuild_views (meta-renderer.c:111)
      ==24016==    by 0x49BB4FB: meta_stage_native_rebuild_views (meta-stage-native.c:142)
      ==24016==    by 0x49A733C: meta_backend_native_update_screen_size (meta-backend-native.c:517)
      
      GNOME/mutter!622
      d9fb11b0
    • Jonas Ådahl's avatar
      renderer/native: Make sure we're not destroying an active EGLSurface · 56ddaaa3
      Jonas Ådahl authored
      When making a new surface/context pair current, mesa may want to flush
      the old context. Make sure we don't try to flush any freed memory by
      unmaking a surface/context pair current before freeing it.
      
      Not doing this results in the following valgrind warnings:
      
      ==15986== Invalid read of size 8
      ==15986==    at 0x69A6D80: dri_flush_front_buffer (gbm_dri.c:92)
      ==15986==    by 0x1750D458: intel_flush_front (brw_context.c:251)
      ==15986==    by 0x1750D4BB: intel_glFlush (brw_context.c:296)
      ==15986==    by 0x1739D8DD: dri2_make_current (egl_dri2.c:1461)
      ==15986==    by 0x17393A3A: eglMakeCurrent (eglapi.c:869)
      ==15986==    by 0x54381FB: InternalMakeCurrentVendor (in /home/jonas/Dev/gnome/install/lib/libEGL.so.1.1.0)
      ==15986==    by 0x5438515: eglMakeCurrent (in /home/jonas/Dev/gnome/install/lib/libEGL.so.1.1.0)
      ==15986==    by 0x522A782: _cogl_winsys_egl_make_current (cogl-winsys-egl.c:303)
      ==15986==    by 0x49B64C8: meta_renderer_native_create_view (meta-renderer-native.c:3076)
      ==15986==    by 0x48D26E7: meta_renderer_create_view (meta-renderer.c:78)
      ==15986==    by 0x48D277A: meta_renderer_rebuild_views (meta-renderer.c:111)
      ==15986==    by 0x49BF46E: meta_stage_native_rebuild_views (meta-stage-native.c:142)
      ==15986==  Address 0x1b076600 is 0 bytes inside a block of size 48 free'd
      ==15986==    at 0x4839A0C: free (vg_replace_malloc.c:540)
      ==15986==    by 0x49B59F3: meta_renderer_native_release_onscreen (meta-renderer-native.c:2651)
      ==15986==    by 0x5211441: _cogl_onscreen_free (cogl-onscreen.c:167)
      ==15986==    by 0x5210D81: _cogl_object_onscreen_indirect_free (cogl-onscreen.c:51)
      ==15986==    by 0x51D0066: _cogl_object_default_unref (cogl-object.c:103)
      ==15986==    by 0x520F989: _cogl_framebuffer_unref (cogl-framebuffer.c:1814)
      ==15986==    by 0x51D00B1: cogl_object_unref (cogl-object.c:115)
      ==15986==    by 0x536F3C7: clutter_stage_view_dispose (clutter-stage-view.c:304)
      ==15986==    by 0x4B7DAF2: g_object_unref (gobject.c:3309)
      ==15986==    by 0x4A9596C: g_list_foreach (glist.c:1013)
      ==15986==    by 0x4A9599A: g_list_free_full (glist.c:223)
      ==15986==    by 0x48D2737: meta_renderer_rebuild_views (meta-renderer.c:100)
      ==15986==  Block was alloc'd at
      ==15986==    at 0x483AB1A: calloc (vg_replace_malloc.c:762)
      ==15986==    by 0x69A76B2: gbm_dri_surface_create (gbm_dri.c:1252)
      ==15986==    by 0x69A6BFE: gbm_surface_create (gbm.c:600)
      ==15986==    by 0x49B4E29: meta_renderer_native_create_surface_gbm (meta-renderer-native.c:2221)
      ==15986==    by 0x49B57DB: meta_onscreen_native_allocate (meta-renderer-native.c:2569)
      ==15986==    by 0x49B6423: meta_renderer_native_create_view (meta-renderer-native.c:3062)
      ==15986==    by 0x48D26E7: meta_renderer_create_view (meta-renderer.c:78)
      ==15986==    by 0x48D277A: meta_renderer_rebuild_views (meta-renderer.c:111)
      ==15986==    by 0x49BF46E: meta_stage_native_rebuild_views (meta-stage-native.c:142)
      ==15986==    by 0x49A75B5: meta_backend_native_update_screen_size (meta-backend-native.c:520)
      ==15986==    by 0x48B01BB: meta_backend_sync_screen_size (meta-backend.c:224)
      ==15986==    by 0x48B09B7: meta_backend_real_post_init (meta-backend.c:501)
      
      GNOME/mutter!622
      56ddaaa3