1. 31 Jul, 2020 1 commit
    • Jian-Hong Pan's avatar
      xfree86: Detect the primary device by checking outputs · 04f104e8
      Jian-Hong Pan authored
      Before this patch, X server detects/sets the primary device by:
      1. The "PrimaryGPU" option in extra X configuration
      2. pci_device_is_boot_vga() for PCI devices
      3. Set the first (0 index) device as the primary device, if it is not
         found yet.
      
      However, the other display controllers like Amlogic's meson cannot be
      detected as the primary device by pci_device_is_boot_vga(). Thus, it has
      to set the extra X configuration for the "PrimaryGPU" option.
      Otherwise, X server will set the first (0 index) device as the primary
      device. But it may not be the correct one, because it has no output.
      For example, Amlogic puts the GPU and display controller as different
      devices:
      
      (II) xfree86: Adding drm device (/dev/dri/card0)
      (II) Platform probe for /sys/devices/platform/soc/d0000000.apb/d00c0000.gpu/drm/card0
      (II) xfree86: Adding drm device (/dev/dri/card1)
      (II) Platform probe for /sys/devices/platform/soc/d0100000.vpu/drm/card1
      
      This patch introduces a new member num_connectors into OdevAttributes to
      hold the number of display connectors for each DRM device. It gets the
      number of the device's connectors by detecting the output connecters of
      devices in platform dev driver, that refers to the check_outputs()
      function in modesetting driver.
      Then, adds a new way to set the primary device by checking the number of
      display connectors for drm devices, before use the first platform device
      as a fallback.
      
      Buglink: xorg/xserver#1023
      
      Signed-off-by: default avatarJian-Hong Pan <jian-hong@endlessm.com>
      04f104e8
  2. 30 Jul, 2020 1 commit
  3. 29 Jul, 2020 2 commits
  4. 28 Jul, 2020 1 commit
    • Huacai Chen's avatar
      linux: Fix platform device probe for DT-based PCI · 9fbd3e43
      Huacai Chen authored
      
      
      On a DT-base PCI platform, the sysfs path of vga device is like this:
      /sys/devices/platform/bus@10000000/1a000000.pci/pci0000:00/0000:00:11.0/0000:04:00.0.
      
      Then the ID_PATH from udev is platform-1a000000.pci-pci-0000:04:00.0 and
      the BusID will be pci-0000:04:00.0, which causes Xorg start fail. This
      is because config_udev_odev_setup_attribs() use strstr() to search the
      first "pci-" in ID_PATH. To fix this, we implement a strrstr() function
      and use it to search the last "pci-" in ID_PATH, which can get a correct
      BusID.
      Signed-off-by: default avatarHuacai Chen <chenhc@lemote.com>
      9fbd3e43
  5. 24 Jul, 2020 1 commit
    • Roman Gilg's avatar
      present: Check valid region in window mode flips · 591916ea
      Roman Gilg authored
      
      
      For Pixmap flips to have well defined outcomes the window must be contained by
      the valid region if such region was specified.
      
      The valid region is inserted as an argument to the check in window mode.
      Setting this argument is missing in screen mode as well but we ignore it for now
      and only add it to window mode.
      
      It seems there are none or only very few clients actually making use of valid
      regions at the moment. For simplicity we therefore just check if a valid region
      was set by the client and in this case do never flip, independently of the
      window being contained by the region or not.
      Signed-off-by: Roman Gilg's avatarRoman Gilg <subdiff@gmail.com>
      591916ea
  6. 22 Jul, 2020 5 commits
    • Roman Gilg's avatar
      present: Remove superfluous set abort flip function in window mode · bf794bd7
      Roman Gilg authored
      
      
      The function is never called from present_screen.c in contrast to the behavior
      in screen mode.
      
      In present_wnmd.c we can simply remove the function which does an unnecessary
      check of the property before setting it and directly set the property at the
      two locations the function was called previously.
      Signed-off-by: Roman Gilg's avatarRoman Gilg <subdiff@gmail.com>
      bf794bd7
    • Roman Gilg's avatar
      present: Idle vblanks any time in window mode · ab880b8b
      Roman Gilg authored
      
      
      With the newly introduced separate API method for idling a presented Pixmap in
      window mode we can simplify the logic by allowing calls to it at any point in
      time.
      
      This is done by setting the flip_idler flag if the Pixmap was idled before
      being presented.
      Signed-off-by: Roman Gilg's avatarRoman Gilg <subdiff@gmail.com>
      ab880b8b
    • Roman Gilg's avatar
      present: Notify via distinct API functions in window mode · 932c6bac
      Roman Gilg authored
      
      
      Notifying Present about events' states was done prior with the single function
      present_wnmd_event_notify just like in screen mode. But it is more intelligible
      if at least in window mode we make use of three different functions with names
      that directly indicate what their purpose is:
      
      * present_wnmd_event_notify only for queued events feedback.
      * present_wnmd_flip_notify for when a presentation occured (flip).
      * present_wnmd_idle_notify for when the Pixmap of the event can be reused.
      
      This is an API-breaking change in regards to window mode. DDX written against
      the previous version won't work anymore. It is assumed that there only exists
      the XWayland DDX at the moment using the window mode such that this is not an
      issue for the overall ecosystem.
      Signed-off-by: Roman Gilg's avatarRoman Gilg <subdiff@gmail.com>
      932c6bac
    • Roman Gilg's avatar
      xwayland: Rename present event lists · f8211095
      Roman Gilg authored
      
      
      Rename the lists release_queue to release_list and event_list to
      wait_list.
      
      The prior names release_queue and event_list were ambiguous: in both are event-
      like vblanks which can be removed from the lists in random order. In the
      release_queue can be flips that are already released but still wait for the
      sync or frame callback but normally the release comes later. In the event_list
      are queued events waiting for a later msc.
      Signed-off-by: Roman Gilg's avatarRoman Gilg <subdiff@gmail.com>
      f8211095
    • Roman Gilg's avatar
      xwayland: Remove unused xwl_screen entry · 0db326e5
      Roman Gilg authored
      
      
      In xwl_present_window an xwl_screen entry was declared but never actually used.
      Signed-off-by: Roman Gilg's avatarRoman Gilg <subdiff@gmail.com>
      0db326e5
  7. 21 Jul, 2020 4 commits
    • Alex Goins's avatar
      randr: Re-add removed NULL checks to xf86RandR12.c · 495bf63a
      Alex Goins authored
      Commit 1e3f9ea1 removed some NULL checks from xf86RandR12.c, on the premise that
      they can't be reached unless RandR has already been initialized. For threesuch
      calls, that's not true:
      
      xf86Crtc.c::xf86CrtcScreenInit():
      
          if (c == config->num_crtc) {
              xf86RandR12SetRotations(screen, RR_Rotate_0 | RR_Rotate_90 |
                                      RR_Rotate_180 | RR_Rotate_270 |
                                      RR_Reflect_X | RR_Reflect_Y);
              xf86RandR12SetTransformSupport(screen, TRUE);
          }
          else {
              xf86RandR12SetRotations(screen, RR_Rotate_0);
              xf86RandR12SetTransformSupport(screen, FALSE);
          }
      
      xf86Crtc.c::xf86CrtcCloseScreen():
      
          xf86RandR12CloseScreen(screen);
      
      This change adds checks back to xf86RandR12Set{Rotations,TransformSupport}() and
      xf86RandR12CloseScreen(), checking that xf86RandR12KeyRec has been registered.
      Without this, X will hit an assert that causes it to abort.
      
      Signed-off-by: Alex Goins <agoins@nvidia...
      495bf63a
    • Alex Goins's avatar
      randr: Check rrPrivKey in RRHasScanoutPixmap() · 8eeff5d7
      Alex Goins authored
      RRHasScanoutPixmap() is called from xf86CheckHWCursor(), regardless of whether
      or not RandR has been initialized.
      
      As mentioned in commit 4226c6d0, it's possible that RandR has not been
      initialized if the server is configured with Xinerama and there is more than one
      X screen. Calling rrGetScrPriv when RandR isn't initialized causes an assertion
      failure that aborts the server:
      
            Xorg: ../include/privates.h:121: dixGetPrivateAddr: Assertion
            key->initialized' failed.
      
      Just as in commit 4226c6d0
      
      , fix the problem by checking
      dixPrivateKeyRegistered(rrPrivKey) before calling rrGetScrPriv.
      Signed-off-by: Alex Goins's avatarAlex Goins <agoins@nvidia.com>
      8eeff5d7
    • Alex Goins's avatar
      randr: Check rrPrivKey before autobinding GPU screens · 6172bd2b
      Alex Goins authored
      RRProviderAutoConfigGpuScreen() is called from outside RandR, so there is no
      guarantee that RandR has been initialized when it is called.
      
      As mentioned in commit 4226c6d0, it's possible that RandR has not been
      initialized if the server is configured with Xinerama and there is more than one
      X screen. Calling rrGetScrPriv when RandR isn't initialized causes an assertion
      failure that aborts the server:
      
        Xorg: ../include/privates.h:121: dixGetPrivateAddr: Assertion
        key->initialized' failed.
      
      Just as in commit 4226c6d0
      
      , fix the problem by checking
      dixPrivateKeyRegistered(rrPrivKey) before calling rrGetScrPriv.
      Signed-off-by: Alex Goins's avatarAlex Goins <agoins@nvidia.com>
      6172bd2b
    • Michel Dänzer's avatar
      xwayland: Handle NULL xwl_seat in xwl_seat_can_emulate_pointer_warp · e33453f9
      Michel Dänzer authored
      
      
      This can happen e.g. with weston's headless backend.
      Reviewed-by: default avatarOlivier Fourdan <ofourdan@redhat.com>
      e33453f9
  8. 20 Jul, 2020 2 commits
  9. 16 Jul, 2020 1 commit
    • Lyude Paul's avatar
      xwayland: Store xwl_tablet_pad in its own private key · ba0e789b
      Lyude Paul authored
      
      
      When a slave device causes the master virtual pointer device to change
      device types, the device's private data pointer
      (device->public.devicePrivate) is also changed to match the type of the
      slave device. This can be a problem though, as tablet pad devices will
      set the device's private data pointer to their own xwl_tablet_pad
      struct. This can cause us to dereference the pointer as the wrong type,
      and result in a segfault:
      
      Thread 1 "Xwayland" received signal SIGSEGV, Segmentation fault.
      wl_proxy_marshal (proxy=0x51, opcode=opcode@entry=0) at src/wayland-client.c:792
      792             va_start(ap, opcode);
      (gdb) bt
      0  wl_proxy_marshal (proxy=0x51, opcode=opcode@entry=0) at
        src/wayland-client.c:792
      1  0x00005610b27b6c55 in wl_pointer_set_cursor (hotspot_y=0,
        hotspot_x=0, surface=0x0, serial=<optimized out>, wl_pointer=<optimized
        out>) at /usr/include/wayland-client-protocol.h:4610
      2  xwl_seat_set_cursor (xwl_seat=xwl_seat@entry=0x5610b46d5d10) at
        xwayland-cursor.c:137
      3  0x00005610b27b6ecd in xwl_set_cursor (device=<optimized out>,
        screen=<optimized out>, cursor=<optimized out>, x=<optimized out>,
        y=<optimized out>) at xwayland-cursor.c:249
      4  0x00005610b2800b46 in miPointerUpdateSprite (pDev=0x5610b4501a30) at
        mipointer.c:468
      5  miPointerUpdateSprite (pDev=0x5610b4501a30) at mipointer.c:410
      6  0x00005610b2800e56 in miPointerDisplayCursor (pCursor=0x5610b4b35740,
        pScreen=0x5610b3d54410, pDev=0x5610b4501a30) at mipointer.c:206
      7  miPointerDisplayCursor (pDev=0x5610b4501a30, pScreen=0x5610b3d54410,
        pCursor=0x5610b4b35740) at mipointer.c:194
      8  0x00005610b27ed62b in CursorDisplayCursor (pDev=<optimized out>,
        pScreen=0x5610b3d54410, pCursor=0x5610b4b35740) at cursor.c:168
      9  0x00005610b28773ee in AnimCurDisplayCursor (pDev=0x5610b4501a30,
        pScreen=0x5610b3d54410, pCursor=0x5610b4b35740) at animcur.c:197
      10 0x00005610b28eb4ca in ChangeToCursor (pDev=0x5610b4501a30,
        cursor=0x5610b4b35740) at events.c:938
      11 0x00005610b28ec99f in WindowHasNewCursor
        (pWin=pWin@entry=0x5610b4b2e0c0) at events.c:3362
      12 0x00005610b291102d in ChangeWindowAttributes (pWin=0x5610b4b2e0c0,
        vmask=<optimized out>, vlist=vlist@entry=0x5610b4c41dcc,
        client=client@entry=0x5610b4b2c900) at window.c:1561
      13 0x00005610b28db8e3 in ProcChangeWindowAttributes (client=0x5610b4b2c900)
        at dispatch.c:746
      14 0x00005610b28e1e5b in Dispatch () at dispatch.c:497
      15 0x00005610b28e5f34 in dix_main (argc=16, argv=0x7ffc7a601b68,
        envp=<optimized out>) at main.c:276
      16 0x00007f8828cde042 in __libc_start_main (main=0x5610b27ae930 <main>,
        argc=16, argv=0x7ffc7a601b68, init=<optimized out>, fini=<optimized
        out>, rtld_fini=<optimized out>, stack_end=0x7ffc7a601b58) at
        ../csu/libc-start.c:308
      17 0x00005610b27ae96e in _start () at cursor.c:1064
      
      Simple reproducer in gnome-shell: open up an Xwayland window, press some
      tablet buttons, lock and unlock the screen. Repeat if it doesn't crash
      the first time.
      
      So, let's fix this by registering our own device-specific private key
      for storing a backpointer to xwl_tablet_pad, so that all input devices
      have their private data pointers set to their respective xwl_seat.
      Reviewed-by: Peter Hutterer's avatarPeter Hutterer <peter.hutterer@who-t.net>
      Signed-off-by: Lyude Paul's avatarLyude Paul <lyude@redhat.com>
      ba0e789b
  10. 14 Jul, 2020 1 commit
  11. 12 Jul, 2020 1 commit
  12. 09 Jul, 2020 2 commits
  13. 08 Jul, 2020 1 commit
    • Olivier Fourdan's avatar
      xwayland: Add a pkg-config file for Xwayland · 5188603f
      Olivier Fourdan authored
      
      
      Xwayland is usually spawned by the Wayland compositor which sets the
      command line options.
      
      If a command line option is not supported, Xwayland will fail to start.
      
      That somehow makes the Xwayland command line option sort of ABI, the
      Wayland compositor need to know if a particular option is supported by
      Xwayland at build time.
      
      Also, currently, Xwayland is being installed along with the rest of the
      common executable programs that users may run, which is sub-optimal
      because, well, Xwayland is not a common executable program, it's meant
      to be a proxy between the Wayland compositor and the legacy X11 clients
      which wouldn't be able to run on Wayland otherwise.
      
      Xwayland would be better installed in `libexec` but that directory is
      (purposedly) not in the user `PATH` and therefore the Wayland compositor
      may not be able to find Xwayland in that case.
      
      To solve both problems (which options are supported by Xwayland and
      where to look for it), add a `pkg-config` file specifically for Xwayland
      which gives the full path to Xwayland (`xwayland`) and which options it
      supports (using `pkg-config` variables).
      
      The `pkg-config` file also provides the `Version` so the build scripts
      can check for a particular version if necessary.
      
      Obviously, Wayland compositors are not required to use the `pkg-config`
      file and can continue to use whatever mechanism they deem preferable.
      Signed-off-by: default avatarOlivier Fourdan <ofourdan@redhat.com>
      Reviewed-by: Michel Dänzer's avatarMichel Dänzer <mdaenzer@redhat.com>
      5188603f
  14. 07 Jul, 2020 4 commits
  15. 05 Jul, 2020 2 commits
  16. 03 Jul, 2020 2 commits
    • Olivier Fourdan's avatar
      xwayland: Use a fixed DPI value for core protocol · b0413b6e
      Olivier Fourdan authored
      
      
      The way Xwayland works (like all Wayland clients), it first queries the
      Wayland registry, set up all relevant protocols and then initializes its
      own structures.
      
      That means Xwayland will get the Wayland outputs from the Wayland
      compositor, compute the physical size of the combined outputs and set
      the corresponding Xwayland screen properties accordingly.
      
      Then it creates the X11 screen using fbScreenInit() but does so by using
      a default DPI value of 96. That value is used to set the physical size
      of the X11 screen, hence overriding the value computed from the actual
      physical size provided by the Wayland compositor.
      
      As a result, the DPI computed by tools such as xdpyinfo will always be
      96 regardless of the actual screen size and resolution.
      
      However, if the Wayland outputs get reconfigured, or new outputs added,
      or existing outputs removed, Xwayland will recompute and update the
      physical size of the screen, leading to an unexpected change of DPI.
      
      To avoid that discrepancy, use a fixed size DPI (defaults to 96, and can
      be set using the standard command lime option "-dpi") and compute a
      physical screen size to match that DPI setting.
      
      Note that only affects legacy core protocols, X11 clients can still get
      the actual physical output size as reported by the Wayland compositor
      using the RandR protocol, which also allows for the size to be 0 if the
      size is unknown or meaningless.
      Signed-off-by: default avatarOlivier Fourdan <ofourdan@redhat.com>
      Reviewed-by: Simon Ser's avatarSimon Ser <contact@emersion.fr>
      Closes: #731
      b0413b6e
    • SimonPilkington's avatar
      xwayland: Initialise values in xwlVidModeGetGamma() · 6748a409
      SimonPilkington authored
      ProcVidModeGetGamma() relies on GetGamma() to initialise values if it
      returns TRUE. Without this, we're sending uninitialised values to
      clients.
      
      Fixes: xorg/xserver#1040
      6748a409
  17. 02 Jul, 2020 1 commit
  18. 27 Jun, 2020 1 commit
  19. 25 Jun, 2020 4 commits
  20. 24 Jun, 2020 1 commit
    • Martin Weber's avatar
      hw/xfree86: Avoid cursor use after free · 7ae221ad
      Martin Weber authored
      
      
      During a VT-Switch a raw pointer to the shared cursor object
      is saved which is then freed (in case of low refcount) by a call to
      xf86CursorSetCursor with argument pCurs = NullCursor.
      This leads to a dangling pointer which can follow in a use after free.
      
      This fix ensures that there is a shared handle saved for the VT-Switch cycle.
      Reviewed-by: Michel Dänzer's avatarMichel Dänzer <mdaenzer@redhat.com>
      7ae221ad
  21. 23 Jun, 2020 1 commit
  22. 19 Jun, 2020 1 commit
    • Simon Ser's avatar
      xwayland: allow using linux-dmabuf with DRM_FORMAT_MOD_INVALID · d6558477
      Simon Ser authored
      When the linux-dmabuf protocol is available, prefer it over the old
      wl_drm protocol. Previously wl_drm was used when modifiers aren't
      supported, however linux-dmabuf supports formats without modifiers too.
      In this case, linux-dmabuf will send a DRM_FORMAT_MOD_INVALID modifier
      for each supported format [1].
      
      This allows compositors to better handle these buffers, getting a
      DMA-BUF and implementing features like direct scan-out.
      
      A similar logic has been implemented for EGL [2].
      
      DRM_FORMAT_MOD_INVALID is now stored in the xwl_screen->formats list.
      glamor_get_modifiers still returns FALSE with zero modifiers if the
      only advertised modifier is DRM_FORMAT_MOD_INVALID.
      
      [1]: wayland/wayland-protocols@fb9b2a87
      [2]: mesa/mesa@c376865f
      
      Signed-off-by: Simon Ser's avatarSimon Ser <contact@emersion.fr>
      Reviewed-by: Michel Dänzer's avatarMichel Dänzer <mdaenzer@redhat.com>
      d6558477