Commit Graph

15633 Commits

Author SHA1 Message Date
Adam Jackson
75e660e379 modesetting: Drop some non-functional triple-buffering variables
Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2016-07-02 09:28:04 +02:00
Dave Airlie
21217d0216 modesetting: Implement 32->24 bpp conversion in shadow update
24bpp front buffers tend to be the least well tested path for client
rendering.  On the qemu cirrus emulation, and on some Matrox G200 server
chips, the hardware can't do 32bpp at all.  It's better to just allocate
a 32bpp shadow and downconvert in the upload hook than expose a funky
pixmap format to clients.

[ajax: Ported from RHEL and separate modesetting driver, lifted kbpp
into the drmmode struct, cleaned up commit message, fixed 16bpp]

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Dave Airlied <airlied@redhat.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
[hdegoede@redhat.com: rebase, also use kbpp for rotate shadow fb]
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2016-07-02 09:28:04 +02:00
Takashi Iwai
af916477c6 modesetting: Fix hw cursor check at the first call
With the previous patch, the modesetting driver can now return whether
the driver supports hw cursor.  However, it alone doesn't suffice,
unfortunately. drmmode_load_cursor_argb_check() is called in the
following chain:

  xf86CursorSetCursor()
    -> xf86SetCursor()
       -> xf86DriverLoadCursorARGB()
         -> xf86_load_cursor_argb()
           -> xf86_crtc_load_cursor_argb()
             -> drmmode_load_cursor_argb_check()

*but* at first with drmmode_crtc->cursor_up = FALSE.  Then the
function doesn't actually set the cursor but returns TRUE
unconditionally.  The actual call of drmmode_set_cursor() is done at
first via the show_cursor callback, and there is no check of sw cursor
fallback any longer at this place. Since it's called only once per
cursor setup, so the xserver still thinks as if the hw cursor is
supported.

This patch is an ad hoc fix to correct the behavior somehow: it does
call drmmode_set_cursor() at the very first time even if cursor_up is
FALSE, then quickly hides again.  In that way, whether the hw cursor
is supported is evaluated in the right place at the right time.

Of course, it might be more elegant if we have a more proper mechanism
to fall back to sw cursor at any call path.  But it'd need more
rework, so I leave this workaround as is for now.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2016-07-02 09:26:11 +02:00
Takashi Iwai
14c21ea1c9 modesetting: Use load_cursor_argb_check for sw cursor fallback
The modesetting driver still has an everlasting bug of invisible
cursor on cirrus and other KMS drivers where no hardware cursor is
supported.  This patch is a part of an attempt to address it.

This patch particularly converts the current load_cursor_argb callback
of modesetting driver to load_cursor_argb_check so that it can return
whether the driver handles the hw cursor or falls back to the sw
cursor.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
[hdegoede@redhat.com: Add extra comment suggested by Kenneth]
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2016-07-01 19:08:20 +02:00
Takashi Iwai
074cf58769 modesetting: Fix the error check from DRM_IOCTL_MODE_CURSOR2
The error value isn't always -EINVAL, e.g. the kernel drm core returns
-ENXIO when the corresponding ops doesn't exist.  Without this fix,
DRM_IOCTL_MODE_CURSOR2 would be dealt as success even if it
shouldn't.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2016-07-01 19:08:20 +02:00
Adam Jackson
3762edded8 configure: Tell AC_REPLACE_FUNCS where to find replacements
Fixes weird link errors of the form:

      CCLD     Xvfb
    ../../Xext/.libs/libXext.a(xvmc.o): In function `xf86XvMCRegisterDRInfo':
    /home/ajax/git/xserver/Xext/xvmc.c:828: undefined reference to `strlcpy'
    /home/ajax/git/xserver/Xext/xvmc.c:829: undefined reference to `strlcpy'
    ../../os/os.O: In function `siHostnameAddrMatch':
    /home/ajax/git/xserver/os/access.c:1821: undefined reference to `strlcpy'
    ../../os/os.O: In function `AuthAudit':
    /home/ajax/git/xserver/os/connection.c:555: undefined reference to `strlcpy'
    /home/ajax/git/xserver/os/connection.c:574: undefined reference to `strlcpy'
    ../../os/os.O:/home/ajax/git/xserver/os/log.c:972: more undefined references to `strlcpy' follow
    collect2: error: ld returned 1 exit status
    Makefile:688: recipe for target 'Xvfb' failed
    make[3]: *** [Xvfb] Error 1
    Makefile:749: recipe for target 'all-recursive' failed
    make[2]: *** [all-recursive] Error 1
    Makefile:608: recipe for target 'all-recursive' failed
    make[1]: *** [all-recursive] Error 1
    Makefile:776: recipe for target 'all-recursive' failed
    make: *** [all-recursive] Error 1

Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2016-06-30 13:12:08 -04:00
Peter Hutterer
d135100d6b xkb: add a cause to the xkb indicator update after a keymap change
Regression introduce by ac164e5887 which calls
XkbUpdateAllDeviceIndicators() with two NULL arguments. A few layers down into
the stack and we triggered a NULL-pointer dereference. In theory a NULL cause
is acceptable since we don't actually change modifier state here. Instead of
updating all places to check for NULL just set the cause to the client
request and go to the pub.

https://bugs.freedesktop.org/show_bug.cgi?id=96384

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Julien Cristau <jcristau@debian.org>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2016-06-29 19:20:17 +10:00
Alex Goins
b83dede9cb modesetting: Implement PRIME syncing as a source
Implements (Start/Stop)FlippingPixmapTracking, PresentSharedPixmap, and
RequestSharedPixmapNotifyDamage, the source functions for PRIME
synchronization and double buffering. Allows modesetting driver to be used
as a source with PRIME synchronization.

v1: N/A
v2: N/A
v3: N/A
v4: Initial commit
v5: Move disabling of reverse PRIME on sink to sink commit
v6: Rebase onto ToT
v7: Unchanged

Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Alex Goins <agoins@nvidia.com>
2016-06-28 12:56:45 -04:00
Alex Goins
44cb9578c0 modesetting: Disable Reverse PRIME for i915
Reverse PRIME seems to be designed with discrete graphics as a sink in
mind, designed to do an extra copy from sysmem to vidmem to prevent a
discrete chip from needing to scan out from sysmem.

The criteria it used to detect this case is if we are a GPU screen and
Glamor accelerated. It's possible for i915 to fulfill these conditions,
despite the fact that the additional copy doesn't make sense for i915.

Normally, you could just set AccelMethod = none as an option for the device
and call it a day. However, when running with modesetting as both the sink
and the source, Glamor must be enabled.

Ideally, you would be able to set AccelMethod individually for devices
using the same driver, but there seems to be a bug in X option parsing that
makes all devices on a driver inherit the options from the first detected
device. Thus, glamor needs to be enabled for all or for none until that bug
(if it's even a bug) is fixed.

Nonetheless, it probably doesn't make sense to do the extra copy on i915
even if Glamor is enabled for the device, so this is more user friendly by
not requiring users to disable acceleration for i915.

v1: N/A
v2: N/A
v3: N/A
v4: Initial commit
v5: Unchanged
v6: Rebase onto ToT
v7: NULL check and free drmVersionPtr

Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Alex Goins <agoins@nvidia.com>
2016-06-28 12:56:43 -04:00
Alex Goins
f6fef2a171 modesetting: Blacklist USB transport devices from PRIME sync
UDL (USB 2.0 DisplayLink DRM driver) and other drivers for USB transport devices
have strange semantics when it comes to vblank events, due to their inability to
get the actual vblank info.

When doing a page flip, UDL instantly raises a vblank event without waiting for
vblank. It also has no support for DRM_IOCTL_WAIT_VBLANK, and has some strange
behavior with how it handles damage when page flipping.

It's possible to get something semi-working by hacking around these issues,
but even then there isn't much value-add vs single buffered PRIME, and it
reduces maintainability and adds additional risks to the modesetting driver
when running with more well-behaved DRM drivers.

Work needs to be done on UDL in order to properly support synchronized
PRIME. For now, just blacklist it, causing RandR to fall back to
unsynchronized PRIME.

This patch originally blacklisted UDL by name, but it was pointed out that there
are other USB transport device drivers with similar limitations, so it was
expanded to blacklist all USB transport devices.

v1: N/A
v2: N/A
v3: Initial commit
v4: Move check to driver.c for consistency/visibility
v5: Refactor to accomodate earlier changes
v6: Rebase onto ToT
v7: Expand to blacklist all USB transport devices, not just UDL

Signed-off-by: Alex Goins <agoins@nvidia.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
2016-06-28 12:56:37 -04:00
Alex Goins
500853086d modesetting: Suspend and resume flipping with DPMS
DPMS would prevent page flip / vblank events from being raised, freezing
the screen until PRIME flipping was reinitialized. To handle DPMS cleanly,
suspend PRIME page flipping when DPMS mode is not on, and resume it when
DPMS mode is on.

v1: Initial commit
v2: Moved flipping_active check from previous commit to here
v3: Unchanged
v4: Unchanged
v5: Move flipping_active check to sink support commit
v6: Rebase onto ToT
v7: Unchanged

Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Alex Goins <agoins@nvidia.com>
2016-06-28 12:56:35 -04:00
Alex Goins
80e64dae8a modesetting: Implement PRIME syncing as a sink
Implements (Enable/Disable)SharedPixmapFlipping and
SharedPixmapNotifyDamage, the sink functions for PRIME synchronization and
double buffering. Allows modesetting driver to be used as a sink with PRIME
synchronization.

Changes dispatch_slave_dirty to flush damage from both scanout pixmaps.

Changes drmmode_set_scanout_pixmap*() functions to
drmmode_set_target_scanout_pixmap*() that take an additional parameter
PixmapPtr *target. Then, treat *target as it did prime_pixmap. This allows
me to use it to explicitly set both prime_pixmap and prime_pixmap_back
individually. drmmode_set_scanout_pixmap() without the extra parameter
remains to cover the single-buffered case, but only works if we aren't
already double buffered.

driver.c:
    Add plumbing for rr(Enable/Disable)SharedPixmapFlipping and
    SharedPixmapNotifyDamage.

    Change dispatch_dirty_crtc to dispatch_dirty_pixmap, which functions the
    same but flushes damage associated with a ppriv instead of the crtc, and
    chanage dispatch_slave_dirty to use it on both scanout pixmaps if
    applicable.

drmmode_display.h:
    Add flip_seq field to msPixmapPrivRec to keep track of the event handler
    associated with a given pixmap, if any.

    Add wait_for_damage field to msPixmapPrivRec to keep track if we have
    requested a damage notification from the source.

    Add enable_flipping field to drmmode_crtc_private_rec to keep track if
    flipping is enabled or disabled.

    Add prime_pixmap_back to drmmode_crtc_private_rec to keep track of back
    buffer internally.

    Add declarations for drmmode_SetupPageFlipFence(),
    drmmode_EnableSharedPixmapFlipping(),
    drmmode_DisableSharedPixmapFlipping, drmmode_SharedPixmapFlip(), and
    drmmode_SharedPixmapPresentOnVBlank().

    Move slave damage from crtc to ppriv.

drmmode_display.c:
    Change drmmode_set_scanout_pixmap*() functions to
    drmmode_set_target_scanout_pixmap*() that take an additional parameter
    PixmapPtr *target for explicitly setting different scanout pixmaps.

    Add definitions for functions drmmode_SharedPixmapFlip(),
    drmmode_SharedPixmapPresentOnVBlank(),
    drmmode_SharedPixmapPresent(),
    drmmode_SharedPixmapVBlankEventHandler(),
    drmmode_SharedPixmapVBlankEventAbort(),
    drmmode_EnableSharedPixmapFlipping(), and
    drmmode_DisableSharedPixmapFlipping,
    drmmode_InitSharedPixmapFlipping(), and
    drmmode_FiniSharedPixmapFlipping, along with struct
    vblank_event_args.

    The control flow is as follows:
        pScrPriv->rrEnableSharedPixmapFlipping() makes its way to
        drmmode_EnableSharedPixmapFlipping(), which sets enable_flipping to
        TRUE and sets both scanout pixmaps prime_pixmap and
        prime_pixmap_back.

        When setting a mode, if prime_pixmap is defined, modesetting
        driver will call drmmode_InitSharedPixmapFlipping(), which if
        flipping is enabled will call drmmode_SharedPixmapPresent() on
        scanout_pixmap_back.

        drmmode_SharedPixmapPresent() requests that for the source to
        present on the given buffer using master->PresentSharedPixmap(). If
        it succeeds, it will then attempt to flip to that buffer using
        drmmode_SharedPixmapFlip(). Flipping shouldn't fail, but if it
        does, it will raise a warning and try drmmode_SharedPixmapPresent()
        again on the next vblank using
        drmmode_SharedPixmapPresentOnVBlank().

        master->PresentSharedPixmap() could fail, in most cases because
        there is no outstanding damage on the mscreenpix tracked by the
        shared pixmap. In this case, drmmode_SharedPixmapPresent() will
        attempt to use master->RequestSharedPixmapNotifyDamage() to request
        for the source driver to call slave->SharedPixmapNotifyDamage() in
        response to damage on mscreenpix. This will ultimately call
        into drmmode_SharedPixmapPresentOnVBlank() to retry
        drmmode_SharedPixmapPresent() on the next vblank after
        accumulating damage.

        drmmode_SharedPixmapFlip() sets up page flip event handler by
        packing struct vblank_event_args with the necessary parameters, and
        registering drmmode_SharedPixmapVBlankEventHandler() and
        drmmode_SharedPixmapVBlankEventAbort() with the modesetting DRM
        event handler queue. Then, it uses the drmModePageFlip() to flip on
        the next vblank and raise an event.

        drmmode_SharedPixmapPresentOnVBlank() operates similarly to
        drmmode_SharedPixmapFlip(), but uses drmWaitVBlank() instead of
        drmModePageFlip() to raise the event without flipping.

        On the next vblank, DRM will raise an event that will ultimately be
        handled by drmmode_SharedPixmapVBlankEventHandler(). If we flipped,
        it will update prime_pixmap and prime_pixmap_back to reflect that
        frontTarget is now being displayed, and use
        drmmode_SharedPixmapPresent(backTarget) to start the process again
        on the now-hidden shared pixmap. If we didn't flip, it will just
        use drmmode_SharedPixmapPresent(frontTarget) to start the process
        again on the still-hidden shared pixmap.

        Note that presentation generally happens asynchronously, so with
        these changes alone tearing is reduced, but we can't always
        guarantee that the present will finish before the flip. These
        changes are meant to be paired with changes to the sink DRM driver
        that makes flips wait on fences attached to dmabuf backed buffers.
        The source driver is responsible for attaching the fences and
        signaling them when presentation is finished.

        Note that because presentation is requested in response to a
        vblank, PRIME sources will now conform to the sink's refresh rate.

        At teardown, pScrPriv->rrDisableSharedPixmapFlipping() will be
        called, making its way to drmmode_FiniSharedPixmapFlipping().
        There, the event handlers for prime_pixmap and prime_pixmap_back
        are aborted, freeing the left over parameter structure. Then,
        prime_pixmap and prime_pixmap back are unset as scanout pixmaps.

    Register and tear down slave damage per-scanout pixmap instead of
    per-crtc.

v1: Initial commit
v2: Renamed PresentTrackedFlippingPixmap to PresentSharedPixmap
    Renamed flipSeq to flip_seq
    Warn if flip failed
    Use SharedPixmapNotifyDamage to retry on next vblank after damage
v3: Refactor to accomodate moving (rr)StartFlippingPixmapTracking and
    (rr)(Enable/Disable)SharedPixmapFlipping to rrScrPrivRec from ScreenRec
    Do damage tracking on both scanout pixmaps
v4: Tweaks to commit message
v5: Revise for internal storage of prime pixmap ptrs
    Move disabling for reverse PRIME from source commit to here
    Use drmmode_set_target_scanout_pixmap*() to set scanout pixmaps
    internally to EnableSharedPixmapFlipping().
    Don't support flipping if ms->drmmode.pageflip == FALSE.
    Move flipping_active check to this commit
v6: Rebase onto ToT
v7: Unchanged

Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Alex Goins <agoins@nvidia.com>
2016-06-28 12:56:30 -04:00
Alex Goins
378c85a884 modesetting: Always load ms->drmmode.pageflip
ms->drmmode.pageflip was only loaded from options if ms->drmmode.glamor was
defined, otherwise it would always assume FALSE.

PRIME Synchronization requires ms->drmmode.pageflip even if we aren't using
glamor, so load it unconditionally.

v1: N/A
v2: N/A
v3: N/A
v4: N/A
v5: Initial commit
v6: Rebase onto ToT
v7: Unchanged

Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Alex Goins <agoins@nvidia.com>
2016-06-28 12:56:27 -04:00
Alex Goins
b773a9c812 modesetting: Always tear down scanout pixmap
drmmode_set_scanout_pixmap_(cpu/gpu) would only do teardown if ppix ==
NULL. This meant that if there were consecutive calls to
SetScanoutPixmap(ppix != NULL) without calls to SetScanoutPixmap(ppix ==
NULL) in between, earlier calls would be leaked.  RRReplaceScanoutPixmap()
does this today.

Instead, when setting a scanout pixmap, always do teardown of the existing
scanout pixmap before setting up the new one. Then, if there is no new one
to set up, stop there.

This maintains the previous behavior in all cases except those with
multiple consecutive calls to SetScanoutPixmap(ppix != NULL).

v1: N/A
v2: N/A
v3: N/A
v4: N/A
v5: Initial commit
v6: Rebase onto ToT
v7: Unchanged

Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Alex Goins <agoins@nvidia.com>
2016-06-28 12:56:25 -04:00
Alex Goins
f4c37eeee7 modesetting: Internal storage of scanout pixmaps
modesetting relied on randr_crtc->scanout_pixmap being consistent with
calls to SetScanoutPixmap, which is very fragile and makes a lot of
assumptions about the caller's behavior.

For example, RRReplaceScanoutPixmap(), when dropping off with !size_fits,
will set randr_crtc->scanout_pixmap = NULL and then call SetScanoutPixmap.
Without this patch, drmmode_set_scanout_pixmap_(cpu/gpu) will think that
there is no scanout pixmap to tear down, because it's already been set to
NULL.

By keeping track of the scanout pixmap in its internal state, modesetting
can avoid these types of bugs and reduce constraints on calling
conventions.

v1: N/A
v2: N/A
v3: N/A
v4: N/A
v5: Initial commit
v6: Rebase onto ToT
v7: Unchanged

Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Alex Goins <agoins@nvidia.com>
2016-06-28 12:56:21 -04:00
Alex Goins
1bdbc7e764 randr/xf86: Add PRIME Synchronization / Double Buffer
Changes PRIME to use double buffering and synchronization if all required
driver functions are available.

rrcrtc.c:
    Changes rrSetupPixmapSharing() to use double buffering and
    synchronization in the case that all required driver functions are
    available. Otherwise, falls back to unsynchronized single buffer.

    Changes RRCrtcDetachScanoutPixmap() to properly clean up in the case of
    double buffering.

    Moves StopPixmapTracking() from rrDestroySharedPixmap() to
    RRCrtcDetachScanoutPixmap().

    Changes RRReplaceScanoutPixmap() to fail if we are using double buffering,
    as it would need a second ppix parameter to function with double buffering,
    and AFAICT no driver I've implemented double buffered source support in uses
    RRReplaceScanoutPixmap().

randrstr.h:
    Adds scanout_pixmap_back to struct _rrCrtc to facilitate PRIME
    double buffering.

xf86Crtc.h:
    Adds current_scanout_back to _xf86Crtc to facilitate detection
    of changes to it in xf86RandR12CrtcSet().

xf86RandR12.c:
    Changes xf86RandR12CrtcSet() to detect changes in
    scanout_pixmap_back.

    Adds scanout_pixmap_back to struct _rrCrtc to facilitate PRIME double
    buffering.

v1: Initial commit
v2: Rename PresentTrackedFlippingPixmap to PresentSharedPixmap
v3: Refactor to accomodate moving (rr)StartFlippingPixmapTracking and
    (rr)(Enable/Disable)SharedPixmapFlipping to rrScrPrivRec from ScreenRec
    Add fallback if flipping funcs fail
v4: Detach scanout pixmap when destroying scanout_pixmap_back, to avoid
    dangling pointers in some drivers
v5: Disable RRReplaceScanoutPixmap for double-buffered PRIME, it would need an
    ABI change with support for 2 pixmaps if it were to be supported, but AFAICT
    no driver that actually supports double-buffered PRIME uses it.
    Refactor to use rrEnableSharedPixmapFlipping() as a substitute for
    rrCrtcSetScanoutPixmap() in the flipping case.
    Remove extraneous pSlaveScrPriv from DetachScanoutPixmap()
    Remove extraneous protopix and pScrPriv from rrSetupPixmapSharing()
v6: Rebase onto ToT
v7: Unchanged

Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Alex Goins <agoins@nvidia.com>
2016-06-28 12:56:17 -04:00
Alex Goins
b601f96a59 xf86: Add PRIME flipping functions to Screen
Adds typedefs for (*RRStartFlippingPixmapTrackingProcPtr),
(*RREnableSharedPixmapFlippingProcPtr),
and (*RRDisableSharedPixmapFlippingProcPtr) in randrstr.h.

Adds typedefs for (*PresentSharedPixmapProcPtr),
(*SharedPixmapNotifyDamageProcPtr),
(*RequestSharedPixmapNotifyDamageProcPtr), and
(*StopFlippingPixmapTrackingProcPtr) in scrnintstr.h.

Adds RR(Enable/Disable)SharedPixmapFlipping, and
RRStartFlippingPixmapTracking to rrScrnPrivRec.

Adds StopFlippingPixmapTracking, PresentSharedPixmap,
SharedPixmapNotifyDamage, and RequestSharedPixmapNotifyDamage to ScreenRec.

rrScrnPrivRec used for functions that use RandR-private data types, and
ScreenRec used for the rest.

RREnableSharedPixmapFlipping will allow the sink driver to setup for
flipping between two shared pixmaps.

RRDisableSharedPixmapFlipping will allow the sink driver to do teardown
associated with flipping between two shared pixmaps.

(RRStart/Stop)FlippingPixmapTracking are merely the double-buffered
equivalents of (Start/Stop)PixmapTracking, allowing the source driver to do
whatever setup and teardown necessary for presenting on the two shared
pixmaps.

PresentSharedPixmap is a function exposed by the source driver for the X
server or sink driver to call to request a present on a given shared
pixmap.  This way, presents can be driven by the sink's vblank instead of a
timer or similar mechanism.

SharedPixmapNotifyDamage and RequestSharedPixmapNotifyDamage are OPTIONAL
(even for double-buffered PRIME) functions exposed by the sink driver and
the source driver, respectively. By calling
master->RequestSharedPixmapNotifyDamage(ppix), the sink driver can request
for the source driver to call slave->SharedPixmapNotifyDamage(ppix) in
response to damage on the master screen pixmap tracked by ppix.

v1: Initial commit
v2: Rename PresentTrackedFlippingPixmap to PresentSharedPixmap
    Add SharedPixmapNotifyDamage / RequestSharedPixmapNotifyDamage
v3: Add RRCrtcPtr as a parameter to StartFlippingPixmapTracking
    Move functions that use RandR-private data types to rrScrnPrivRec.
v4: Unchanged
v5: Add front and back parameters to RREnableSharedPixmapFlippingProcPtr
v6: Rebase onto ToT
v7: Unchanged

Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Alex Goins <agoins@nvidia.com>
2016-06-28 12:55:56 -04:00
Jon Turney
ef1578e736 hw/xwin: Fix a typo in "Remove Shadow DirectDraw engine"
Commit 7a22912e "Remove Shadow DirectDraw engine" contained a typo, changing
the fullscreen && DirectDraw check in WM_DISPLAYCHANGE to fullscreen ||
DirectDraw

This causes disruptive depth changes to be improperly handled

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
2016-06-28 14:29:33 +01:00
Jon Turney
0a0c1bd932 hw/xwin: Fix a crash trying to reload window icons when not in multiwindow mode
ReloadEnumWindowsProc() accesses window privates, which are only valid in
multiwindow mode, but is called in all modes.

Fix this potential crash by not doing this unless in multiwindow mode.

Reproduction steps:
1/ XWin -mwextwm
2/ Run a client which creates an X window e.g. xterm
3/ Right click on notification area icon, and choose 'Reload .XWinrc' from the menu

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
2016-06-28 14:29:30 +01:00
Colin Harrison
91ae257145 hw/xwin: Fix a crash which occurs if focus returns to XWin after xkbcomp has failed
If WM_FOCUS is received while the "core devices failed" fatal error (due to
xkbcomp failing) is displayed, winRestoreModeKeyState() attempts to
dereference a NULL InputInfo.keyboard->key pointer.

Signed-off-by: Colin Harrison <colin.harrison@virgin.net>
Reviewed-by: Jon Turney <jon.turney@dronecode.org.uk>
2016-06-28 14:29:03 +01:00
Jon Turney
4b123e0f61 hw/xwin: Make window maximizable if a maximium size larger than virtual desktop size is specified
Firefox 38 has a WM_NORMAL_HINTS with a maximum size of 32767x32767.

Don't remove the maximize control from the window frame if the maximum size
is bigger than the virtual desktop size, as maximizing the window will not
exceed the maximium size.

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
2016-06-23 14:15:27 +01:00
Jon Turney
504bf495f9 hw/xwin: Detect invalid options in combination with -nodecoration
Detect invalid options in combination with -nodecoration

These are particularly problematic as -nodecoration implies a default of
-nomultimonitors, for some reason, which will gives rendering issues with
-multiwindow.

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
2016-06-23 14:15:27 +01:00
Jon Turney
e1b983b55e hw/xwin: Default to -noresize when -fullscreen is used
Currently, just using -fullscreen fails in winValidateArgs(), as the default
-resize=randr is incompatible with -fullscreen.

Set the default resize mode to -noresize if -fullscreen is used.

Also, rename enum value notAllowed -> resizeNotAllowed for clarity.

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
2016-06-23 14:15:27 +01:00
Jon Turney
42f7cd5d92 hw/xwin: Tell LogInit() to backup previous logfile as .old
Future work: Do we really need to call LogInit() in so many different
places?

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
2016-06-23 14:15:27 +01:00
Jon Turney
1974198382 hw/xwin: Downgrade some uninformative, always-emitted log output to debug
Downgrade from error to debug some uninformative, always-emitted log output
about thread synchronization during initialization

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
2016-06-23 14:15:27 +01:00
Jon Turney
17c8bf348e hw/xwin: Check for just the hostname in window title
When -hostintitle is enabled, only use the hostname, not a FQDN from
WM_CLIENT_MACHINE, when checking if the window title already contains it

Also restructure GetWindowName() to fix a potential memory leak.

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
2016-06-23 14:15:27 +01:00
Jon Turney
c05c4360ee hw/xwin: Use _NET_WM_NAME for window titles in multiwindow mode
Use _NET_WM_NAME in preference to WM_NAME for window title

Update window title when _NET_WM_NAME property changes

We should always have been doing this, but some qt5 examples only set
_NET_WM_NAME, so now it's become more important...

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
2016-06-23 14:15:27 +01:00
Jon Turney
866d8299ab hw/xwin: Remove decorations from _NET_WM_WINDOW_TYPE_SPLASH type windows
In multiwindow mode, remove decorations from _NET_WM_WINDOW_TYPE_SPLASH type
windows.

Some programs use _NET_WM_WINDOW_TYPE_SPLASH_SCREEN in error, so also accept
that as equivalent.

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
2016-06-23 14:15:27 +01:00
Jon Turney
356b912906 hw/xwin: Use Bool type in winShowWindowOnTaskbar() prototype
Use the Bool type from X11/Xdefs.h for winShowWindowOnTaskbar().

This is the boolean type we should be using inside the X server, rather than
BOOL, which evaluates to either the Win32 API type, or the Xlib API type,
depending on the context...

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
2016-06-23 14:15:27 +01:00
Olivier Fourdan
7397a2191f xwayland-input: Fake crossing to rootwin
This partially reverts commit c1565f3.

When the pointer moves from an X11 window to a Wayland native window,
no LeaveNotify event is emitted which can lead to various unexpected
behaviors like tooltips remaining visible after the pointer has left the
window.

Yet the pointer_handle_leave() is called and so is the DIX CheckMotion()
but since the pointer enters a Wayland native window with no other
Xwayland window matching, DoEnterLeaveEvents() does not get invoked and
therefore no LeaveNotify event is sent to the X11 client at the time the
pointer leaves the window for a Wayland native surface.

Restore the XYToWindow() handler in xwayland-input that was previously
removed with commit c1565f3 and use that handler to pretend that the
pointer entered the root window in this case so that the LeaveNotify
event is emitted.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=96437

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Acked-by: Daniel Stone <daniels@collabora.com>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-06-23 16:00:30 +10:00
Adam Jackson
111a045dcf Revert "XDMCP: For IPv6 add link local addresses to the end of the list"
This reverts commit fdd448cd39.
2016-06-21 11:45:17 -04:00
Reinhard Max
fdd448cd39 XDMCP: For IPv6 add link local addresses to the end of the list
For link local addresses the XDMCP server would need to either know the
interface thru a scope identifier or try all available interfaces.  If
they don't this address will fail in which case the XDMCP server could
still try the other addresses passed - however some only try the first
address and then give up.

Even if this seems to be the wrong place to fix this it seems to be
easier than fixing all display servers.

[ajax: Cleaned up commit message]

Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-06-21 11:43:09 -04:00
Adam Jackson
ce82ae1964 res: Account for GLXPixmap references too
GLX_EXT_tetxure_from_pixmap operates on a GLXPixmap, which takes a
reference on the backing pixmap; that GLXPixmap might be long-lived, so
we should account for it in ResQueryClientPixmapBytes.

Acked-by: Michel Dänzer <michel.daenzer@amd.com>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2016-06-21 11:11:54 -04:00
Adam Jackson
5d6ad0d3a7 res: Fix accounting of redirected window pixmaps for Composite
The previous change removed the special case that matched resources of
CompositeClientWindowType and walked back from that to the window
pixmap. That was intentional, since that logic was broken anyway. CCWTs
don't map 1:1 to references on the backing pixmap; a window redirected
by multiple clients (say, by the server since it's on the synthetic
visual, and then manually by a compositor) would have a window pixmap
refcount of 1, but would have those bytes accounted twice.

The right thing is to have Composite wrap window accounting, and add the
pixmap bytes once and only once for the redirection reference.

Note that the view from the client can still be non-intuitive in the
face of Composite.  xcompmgr, for example, holds _two_ references to
each window pixmap (one each from CompositeNameWindowPixmap and
RenderCreatePicture), so a synthetic-visual window will have its bytes
split 2/3 to xcompmgr and 1/3 to the server-client.  Nothing to be done
about that, and at least this way we're not over-accounting.

Acked-by: Michel Dänzer <michel.daenzer@amd.com>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2016-06-21 11:11:49 -04:00
Adam Jackson
4f8a72034c res: Simplify QueryClientPixmapBytes
I suspect this code predates the common resource hooks for computing
sizes.  It's ugly in any case since the Resource extension shouldn't
need to know which extensions can take a reference on pixmaps.  Instead,
let's just walk every resource for the client and sum up all the pixmap
bytes that way.

This might be slightly slower since we're calling the size func once for
every resource.  On the other hand, it might be slightly faster since we
only walk the resource table once instead of 3-5 times.  Probably a
wash, and not really a performance path in any case.

Acked-by: Michel Dänzer <michel.daenzer@amd.com>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2016-06-21 11:11:44 -04:00
Michel Dänzer
263c5333a5 xfree86/modes: Simplify in_range logic in xf86_crtc_set_cursor_position
Consolidate to a single if/else statement and eliminate the redundant
local variable in_range and assignments to x/y.

Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-06-21 10:40:05 +09:00
Michel Dänzer
a991b1ec30 xfree86/modes: Disambiguate driverIsPerformingTransform
The driver can now specify exactly which aspects of the transform it
wants to handle via XF86DriverTransform* flags.

Since the driver can now choose whether it wants to receive transformed
or untransformed cursor coordinates, xf86CrtcTransformCursorPos no
longer needs to be available to drivers, so make it static.

Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-06-21 10:39:13 +09:00
Michel Dänzer
aad96f8500 xfree86/modes: Fix HW cursor clipping for driverIsPerformingTransform (v2)
Even if the driver is handling the transform, we still need to transform
the cursor position for clipping, otherwise we may hide the HW cursor
when the cursor is actually inside the area covered by the CRTC.

v2: Use crtc_x/y local variables for clarity

Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-06-21 10:38:37 +09:00
Keith Packard
828887b6f4 ephyr: Process only the last expose or configure available from the server
Delay expose or configure processing until the event queue is empty so
that we don't end up processing a long series of events one at a
time. Expose events already have a check waiting for the last in a
series, this further improves that by discarding multiple
series of events.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-06-20 11:55:21 -07:00
Keith Packard
c17a417945 ephyr: Process queued X events before blocking [v2]
If we end up reading all pending X events in the course of other server
execution, then our notify FD callback won't get invoked and we won't
process them. Fix this by noting that there are queued events in the
block handler, setting the poll timeout to zero and queuing a work
proc to clear the event queue.

v2: use a work proc to clear the event queue rather than doing it in
    the block handler directly.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-06-20 11:55:15 -07:00
Keith Packard
f3248eba6e ephyr: Handle window resize when using glamor
Under glamor, we need to re-create the screen pixmap at the new size
so that we can ask glamor for the associated texture. Fortunately, we
can simply use ephyr_glamor_create_screen_resources to create the new
pixmap.

Because this is being done after the server has started, we need to
walk the window heirarchy and reset any windows pointing at the old
pixmap. I could easily be convinced that this TraverseTree should be
moved to miSetScreenPixmap.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-06-20 11:55:12 -07:00
Keith Packard
235d21670d ephyr: Don't configure window while responding to configure events
This leads to and endless sequence of window resizes.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-06-20 11:55:04 -07:00
Keith Packard
fb1edccf3c dix: Call screen block/wakeup handlers closest to blocking [v3]
The screen block and wakeup handlers are the only ones which provide a
well known ordering between the wrapping layers; placing these as
close as possible to the server blocking provides a way for the driver
to control the flow of execution correctly.

Switch the shadow code to run in the screen block handler so that it
now occurrs just before the server goes to sleep.

Switch glamor to call down to the driver after it has executed its own
block handler piece, in case the driver needs to perform additional
flushing work after glamor has called glFlush.

These changes ensure that the following modules update the screen in
the correct order:

animated cursors        (uses RegisterBlockAndWakeupHandlers dynamically)
composite               (dynamic wrapping)
misprite                (dynamic wrapping)
shadow                  (static wrapping)
glamor                  (static wrapping)
driver                  (static wrapping)

It looks like there's still a bit of confusion between composite and
misprite; if composite updates after misprite, then it's possible
you'd exit the block handler chain with the cursor left hidden. To fix
that, misprite should be wrapping during ScreenInit time and not
unwrapping. And composite might as well join in that fun, just to make
things consistent.

[v2] Unwrap BlockHandler in shadowCloseScreen (ajax)
[v3] ephyr: Use screen block handler for flushing changes

ephyr needs to make sure it calls glXSwapBuffers after glamor finishes
its rendering. As the screen block handler is now called last, we have
to use that instead of a registered block/wakeup handler to make sure
the GL rendering is done before we copy it to the front buffer.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-06-20 11:54:57 -07:00
Guilherme Quentel Melo
a134d1e7ea glx: avoid memory leak when using indirect rendering
When multiple processes are using GL with indirect rendering a race
condition can make drawables refcount never drop to zero.

This situation could happen when there are many X clients using indirect
GLX:

1 - client1: calls glXMakeCurrent

2 - client2: calls glXMakeCurrent
This is the first context switch for this client. So old_context_tag=0

3 - client1: calls glXRender
For the client, its context is already current.
For the server side lastGLContext points to client2's context.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Guilherme Quentel Melo <gqmelo@gmail.com>
2016-06-20 13:25:41 -04:00
Adam Jackson
266cf39a8f Merge remote-tracking branch 'hans/for-master' 2016-06-20 11:21:40 -04:00
Keith Packard
fa7b70a9b8 kdrive: Only enable threaded input if we have input devices
When there aren't any devices, the input thread is going to be pretty
lonely, so don't bother to even start it.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-06-20 15:47:06 +10:00
Jason Gerecke
6f2a5b8cdf xwayland: Expose all NBUTTONS buttons on the pointer
The call to 'InitButtonClassDeviceStruct' which initializes the pointer
buttons only results in the first three buttons being created due to a
hardcoded '3'. In order to expose all the buttons defined in the
btn_labels array, we subtitute 'NBUTTONS' in its place.

Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Reviewed-by: Olivier Fourdan <ofourdan@redhat.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-06-20 15:40:49 +10:00
Jason Gerecke
72df6e2a3a xwayland: Use correct labels when initializing pointer valuators
Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Reviewed-by: Olivier Fourdan <ofourdan@redhat.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-06-20 15:40:28 +10:00
Jason Gerecke
dab5b3922c xwayland: Fix whitespace errors
Substitute a few errant tab characters with eight spaces to conform to the
prevailing style.

Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-06-20 15:40:07 +10:00
Lyude Paul
848089e0dd modesetting: Clear drmmode->fb_id before unflipping
[fix copied from 40191d82370e in xf86-video-ati]

Without this, we end up setting rotated CRTCs back to their previous
framebuffer right after we perform a rotation. Reproducer:

- Have two monitors connected at the same resolution
- Rotate one monitor from normal straight to inverted
- Watch as the monitor you didn't rotate either freezes or shows intense
  flickering

Signed-off-by: Lyude <cpaul@redhat.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2016-06-17 11:38:13 +02:00