Commit Graph

7482 Commits

Author SHA1 Message Date
Jon Turney
2a79be9e4d hw/xwin: Update BlockHandler function signature
Update for removal of fdset from Block/Wakeup handler API in 9d15912a

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
Reviewed-by: Keith Packard <keithp@keithp.com>
2016-07-19 08:10:11 -07:00
Jon Turney
60a91031d1 hw/xwin: Update for removal of AddEnabledDevice
Update for removal of AddEnabledDevice in be5a513f. Use SetNotifyFd instead.

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
Reviewed-by: Keith Packard <keithp@keithp.com>
2016-07-19 08:10:03 -07:00
Peter Hutterer
7f2d690725 xfree86: if ATTR_KEYBOARD is set, match for keyboards
ATTR_KEY maps to ID_INPUT_KEY which is set for any device with keys.
ID_INPUT_KEYBOARD and thus ATTR_KEYBOARD is set for devices that are actual
keyboards (and have a set of expected keys).

Hand-written match rules may only apply ID_INPUT_KEYBOARD, so make sure we
match on that too.

Arguably we should've been matching on ATTR_KEYBOARD only all along but
changing that likely introduces regressions.

Reported-by: Marty Plummer <netz.kernel@gmail.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-07-18 16:40:46 -04:00
Adam Jackson
4b311d23e8 modesetting: resubmit dirty rects on EINVAL (v2)
This error code can mean we're submitting more rects at once than the
driver can handle. If that happens, resubmit one at a time.

v2: Make the rect submit loop more error-proof (Walter Harms)

Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Michael Thayer <michael.thayer@oracle.com>
2016-07-18 16:35:16 -04:00
Keith Packard
4af00242ef Bump ABI versions to reflect block/wakeup handler API changes
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-07-18 15:27:51 -04:00
Keith Packard
9d15912aa4 Remove fd_set from Block/Wakeup handler API
This removes the last uses of fd_set from the server interfaces
outside of the OS layer itself.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-07-18 15:27:51 -04:00
Keith Packard
fb0802113b Remove readmask from screen block/wakeup handler
With no users of the interface needing the readmask anymore, we can
remove it from the argument passed to these functions.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-07-18 15:27:51 -04:00
Keith Packard
410bc04748 dmx: Eliminate use of AddEnabledDevice [v2]
Use SetNotifyFd instead, with the hope that someday someone will come
fix this to be more efficient -- right now, the wakeup handler is
doing the event reading, instead of the notify callback.

v2: no need to patch dmxsigio.c as it has been removed.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2016-07-18 15:27:42 -04:00
Keith Packard
6299ef3d74 modesetting: Use passed-in fd for drm event monitoring NotifyFd callback
This is a cleanup, proposed by Adam Jackson, but wasn't merged with
the original NotifyFD changes.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-07-18 15:25:59 -04:00
Keith Packard
6bf7b49f67 hw/kdrive: Use passed-in fd for kdrive/linux APM monitoring [v2]
This is a cleanup, proposed by Adam Jackson, but wasn't merged with
the original NotifyFD changes.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-07-18 15:25:59 -04:00
Keith Packard
55c2e1a3aa xnest: Use SetNotifyFd to receive events
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-07-18 15:25:59 -04:00
Keith Packard
24e65bf0db hw/xfree86: Use NotifyFd for other input fd wakeups
Remove code in xf86Wakeup for dealing with other input and switch to
using the new NotifyFd interface.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-07-18 15:25:59 -04:00
Keith Packard
559aac2d71 dmx: Switch from select(2) to poll(2) for input
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-07-18 15:25:59 -04:00
Keith Packard
aa6717ce21 xfree86: Switch from select(2) to poll(2)
xf86WaitForInput and the xf86 SIGIO handling code.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-07-18 15:25:59 -04:00
Keith Packard
81135991a5 kdrive: switch from select(2) to poll(2)
This avoids fd limits

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-07-18 15:25:59 -04:00
Keith Packard
05a793f5b3 dix: Switch to the libXfont2 API (v2)
This new libXfont API eliminates exposing internal X server symbols to
the font library, replacing those with a struct full of the entire API
needed to use that library.

v2: Use libXfont2 instead of libXfont_2

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-07-18 15:25:59 -04:00
Adam Jackson
32a9504c69 xfree86: Fix fallback driver sort order for Xorg -configure (v2)
The intent here was that fallback drivers would be at the end of the
list in order, but if a fallback driver happened to be at the end of the
list already that's not what would happen. Rather than open-code
something smarter, just use qsort.

Note that qsort puts things in ascending order, so somewhat backwardsly
fallbacks are greater than native drivers, and vesa is greater than
modesetting.

v2: Use strcmp to compare non-fallback drivers so we get a predictable
result if your libc's qsort isn't stable (Keith Packard)

Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2016-07-15 11:08:01 -04:00
Adam Jackson
9fcb554e9b xwayland: Only force monotonic clock once
Otherwise on regeneration we get:

(EE) BUG: triggered 'if (clockid)'
(EE) BUG: utils.c:440 in ForceClockId()
(EE)
(EE) Backtrace:
(EE) 0: ./hw/xwayland/Xwayland (ForceClockId+0x5c) [0x47713c]
(EE) 1: ./hw/xwayland/Xwayland (OsInit+0x25) [0x4763d5]
(EE) 2: ./hw/xwayland/Xwayland (dix_main+0x11c) [0x43e60c]
(EE) 3: /lib64/libc.so.6 (__libc_start_main+0xf1) [0x7f627b2f9731]
(EE) 4: ./hw/xwayland/Xwayland (_start+0x29) [0x4238e9]
(EE) 5: ? (?+0x29) [0x29]

Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
2016-07-15 10:09:24 -04:00
Rui Matos
cf6730c503 xwayland: Update RR state on wl_output.done instead of wl_output.mode
Otherwise if the geometry changes but the mode doesn't we end up with
the previous geometry from RR's point of view.

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=768710

Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
Signed-off-by: Rui Matos <tiagomatos@gmail.com>
2016-07-15 10:03:16 -04:00
Hans De Goede
033888e776 linux: Do not try to open /dev/vc/0, fix error msg when /dev/tty0 open fails
/dev/vc/0 is a devfs thing which is long dead, so stop trying to open
/dev/vc/0, besides being a (small) code cleanup this will also fix the
"parse_vt_settings: Cannot open /dev/tty0 (%s)\n" error message to
display the actual error, rather then the -ENOENT from also trying
/dev/vc/0.

BugLink: https://patchwork.freedesktop.org/patch/8768/
Reported-by: Chad Versace <chad.versace@linux.intel.com>
Suggested-by: Julien Cristau <jcristau@debian.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Julien Cristau <jcristau@debian.org>
Reviewed-by: Chad Versace <chad.versace@intel.com>
2016-07-08 13:43:25 -04:00
Alex Goins
ce24f3aa58 modesetting: NULL assignment for drmmode_set_target_scanout_target_cpu
Commit 80e64dae: "modesetting: Implement PRIME syncing as a sink" originally was
supposed to have this line, but it was dropped as part of the merge process.

Foregoing the NULL assignment causes a ton of problems with dereferencing
uninitialized memory.

Signed-off-by: Alex Goins <agoins@nvidia.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
2016-07-08 13:40:15 -04:00
Hans de Goede
60ad701a6a modesetting: Load on GPU-s with 0 outputs
In newer laptops with switchable graphics, the GPU may have 0 outputs,
in this case the modesetting driver should still load if the GPU is
SourceOffload capable, so that it can be used as an offload source provider.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
2016-07-02 09:54:07 +02:00
Hans de Goede
94a1c77259 modesetting: Fix swapping of provider sink / source capabilities
When a card has import capability it can be an offload _sink_, not
a source and vice versa for export capability.

This commit fixes the modesetting driver to properly set these
capabilities, this went unnoticed sofar because most gpus have both
import and export capability.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
2016-07-02 09:54:07 +02:00
Adam Jackson
fcbafdfd79 modesetting: Implement a double-buffered shadow mode
Server GPUs often have a VNC feature attached to allow remote console.
The controller implementing this feature is usually not very powerful,
and we can easily swamp it with work.  This is made somewhat worse by
damage over-reporting the size of the dirty region, and a whole lot
worse by applications (or shells) that update the screen with identical
pixel content as was already there.

Fix this by double-buffering the shadow fb, using memcmp to identify
dirty tiles on each update pass.  Since both shadows are in host memory
the memcmp is cheap, and worth it given the win in network bandwidth.
The tile size is somewhat arbitrarily chosen to be one cacheline wide at
32bpp on Intel Core.

By default we enable this behaviour for (a subset of) known server GPUs;
the heuristic could use work.

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:54:07 +02:00
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
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
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
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
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
Hans de Goede
4313122dea modesetting: Only add main fb if necessary
If we're doing reverse-prime; or doing rotation the main fb is not used,
and there is no reason to add it in this case.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
2016-06-17 11:38:13 +02:00
Hans de Goede
8774532121 modesetting: Remove unnecessary fb addition from drmmode_xf86crtc_resize
drmmode_set_mode_major() is the only user of drmmode->fb_id and will
create it if necessary.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
2016-06-17 11:38:13 +02:00
Hans de Goede
210d83ad49 modesetting: Set ppix->fb_id to 0 after removing the fb
This ensures the fb gets re-added when a shared pixmap is re-used for
a second drmmode_set_scanout_pixmap_cpu call.

Note currently the xserver never re-uses a shared pixmap in this way,
so this is mostly a sanity fix.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
2016-06-17 11:38:13 +02:00
Hans de Goede
b8ef71fb07 modesetting: Properly cleanup fb for reverse-prime-offload
drmmode_set_scanout_pixmap_gpu(pix) adds drmmod->fb_id through a call
to drmmode_xf86crtc_resize(), but on a subsequent
drmmode_set_scanout_pixmap_gpu(NULL) it would not remove the fb.

This keeps the crtc marked as busy, which causes the dgpu to not
being able to runtime suspend, after an output attached to the dgpu
has been used once. Which causes burning through an additional 10W
of power and the laptop to run quite hot.

This commit adds the missing remove fb call, allowing the dgpu to runtime
suspend after an external monitor has been plugged into the laptop.

Note this also makes drmmode_set_scanout_pixmap_gpu(NULL) match the
behavior of drmmode_set_scanout_pixmap_cpu(NULL) which was already
removing the fb.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
2016-06-17 11:38:13 +02:00
Hans de Goede
5c7af02b10 xrandrprovider: Do not use separate lists for unbound / source / offload slaves
A single provider can be both a offload and source slave at the same time,
the use of seperate lists breaks in this case e.g. :

xrandr --listproviders
Providers: number : 2
Provider 0: id: 0x7b cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 3 outputs: 2 associated providers: 0 name:modesetting
Provider 1: id: 0x46 cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 2 outputs: 5 associated providers: 0 name:modesetting

xrandr --setprovideroutputsource 1 0x7b
xrandr --listproviders
Providers: number : 2
Provider 0: id: 0x7b cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 3 outputs: 2 associated providers: 1 name:modesetting
Provider 1: id: 0x46 cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 2 outputs: 5 associated providers: 1 name:modesetting

xrandr --setprovideroffloadsink 1 0x7b
xrandr --listproviders
Providers: number : 3
Provider 0: id: 0x7b cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 3 outputs: 2 associated providers: 2 name:modesetting
Provider 1: id: 0x46 cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 2 outputs: 5 associated providers: 2 name:modesetting
Provider 2: id: 0x46 cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 2 outputs: 5 associated providers: 2 name:modesetting

Not good. The problem is that the provider with id 0x46 now is on both
the output_slave_list and the offload_slave_list of the master screen.

This commit fixes this by unifying all 3 lists into a single slaves list.

Note that this does change the struct _Screen definition, so this is an ABI
break. I do not expect any of the drivers to actually use the removed / changed
fields so a recompile should suffice.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
2016-06-17 11:35:58 +02:00
Olivier Fourdan
edd24aa50b wayland: clear resource for pixmap on unrealize
On cursor unrealize, the associated pixmap is destroyed, make sure we
clear the pointer from the private resource and check for the value
being non-null when setting or destroying the cursor.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=96246
2016-06-13 16:07:25 -04:00
Olivier Fourdan
6a6bbc3b75 xwayland: Restore wl_display_roundtrip() in InitInput
This partially revert commit 984be78

The rountrip in Xwayland's InitInput() is unlikely the culprit for the
crash reported in bug 95337, even though it's triggered from
InitInput().

Startup goes like this:

  xwl_screen_init()
    xwl_output_create()
    wl_display_roundtrip()
  InitInput()
    wl_display_roundtrip()
  ConnectionInfo initialized

What happens in bug 95337 is that some output data is already available
when we reach InitInput()'s wl_display_roundtrip() and therefore we end
up trying to update the ConnectionInfo's data from RR routines before
ConnectionInfo is actually initialized.

Removing the wl_display_roundtrip() from InitInput() will not fix the
issue (although it would make it less lileky to happen), because
xwl_screen_init() also does a wl_display_roundtrip() after creating the
output, so the race that led to bug 95337 remains.

However, re-setting the xwl_screen->expecting_event to 0 again in
InitInput() still doesn't seem right. so this part is not restored
(thus a partial revert).

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=95337
2016-06-13 16:05:00 -04:00
Eric Biggers
da9fec4edd Allow ConstantDeceleration < 1.0
As documented in xorg.conf(5), a value of ConstantDeceleration between 0
and 1 will speed up the pointer.  However, values less than 1 actually
had no effect.  Fix this.

Note that this bug only affected "ConstantDeceleration" as configured
through xorg.conf, not "Device Accel Constant Deceleration" as configured
through xinput.  The property handler AccelSetDecelProperty() also did
not need to be changed, as it did not limit the values of the property.

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

Signed-off-by: Eric Biggers <ebiggers3@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-06-10 10:54:48 +10:00
Adam Jackson
7cf80b9714 xfree86: Don't swallow ±iglx command line flag
We want to notice that it's set, but still pass it through to dix.
Return 0 to indicate this.

Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-06-08 13:15:57 -04:00
Olivier Fourdan
4653793de3 wayland: Remove unused field in xwl_screen
Can't find any reference of pointer_limbo_window in the code, let's
remove it.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
2016-06-08 13:11:45 -04:00
Peter Hutterer
c69bd15e00 Allow compile-time selection of a fallback input driver
A new --with-fallback-input-driver=foo option allows selecting a
fallback driver for the server if the driver configured for the device
is not found.  Note that this only applies when the device has a driver
assigned and that module fails to load, devices without a driver are
ignored as usual.

This avoids the situation where a configuration assigns e.g. the
synaptics driver but that driver is not available on the system,
resulting in a dead device. A fallback driver can at least provides some
functionality.

This becomes more important as we move towards making other driver true
leaf nodes that can be installed/uninstalled as requested. Specifically,
wacom and synaptics, a config that assigns either driver should be
viable even when the driver itself is not (yet) installed on the system.

It is up to the distributions to make sure that the fallback driver is
always installed. The fallback driver can be disabled with
--without-fallback-input-driver and is disabled by default on non-Linux
systems because we don't have generic drivers on those platforms.
Default driver on Linux is libinput, evdev is the only other serious
candidate here.

Sample log output:
[  3274.421] (II) config/udev: Adding input device SynPS/2 Synaptics TouchPad (/dev/input/event4)
[  3274.421] (**) SynPS/2 Synaptics TouchPad: Applying InputClass "touchpad weird driver"
[  3274.421] (II) LoadModule: "banana"
[  3274.422] (WW) Warning, couldn't open module banana
[  3274.422] (II) UnloadModule: "banana"
[  3274.422] (II) Unloading banana
[  3274.422] (EE) Failed to load module "banana" (module does not exist, 0)
[  3274.422] (EE) No input driver matching `banana'
[  3274.422] (II) Falling back to input driver `libinput'
.. server proceeds to assign libinput, init the device, world peace and rainbows
everywhere, truly what a sight. Shame about the banana though.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-06-08 13:08:32 -04:00
Dave Airlie
a6b6e8ba02 prime: clean up slave bo properly. (v3)
This is an ABI break, in that we now pass NULL to a function that hasn't
accepted it before.

Alex Goins had a different patch for this but it wasn't symmetrical, it
freed something in a very different place than it allocated it, this
attempts to retain symmetry in the releasing of the backing bo.

v2: use a new toplevel API, though it still passes NULL to something
that wasn't expecting it.
v3: pass -1 instead of 0.

Signed-off-by: Dave Airlie <airlied@redhat.com>
Tested-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Alex Goins <agoins at nvidia.com>
2016-06-08 12:51:51 -04:00
Adam Jackson
aa5390aa83 xfree86: Remove redundant parse of AIGLX server flag
Not visible in the patch, but the same stanza is repeated below inside
the #ifdef GLXEXT. There's no reason to bother with checking it if we
built without GLXEXT so remove the unconditional one.

Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2016-06-08 12:43:02 -04:00
Michel Dänzer
166d4c8178 xwayland: Call eglBindAPI after eglInitialize
Current Mesa Git master checks that the EGL display actually supports
the API passed to eglBindAPI, which can only succeed after
eglInitialize.

Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2016-06-08 11:51:21 -04:00
Adam Jackson
5bcdd1cc75 dix: Update some comments to reflect the new non-SIGIO input model
Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
2016-06-08 11:36:32 -04:00
Adam Jackson
48a9b29b0a xfree86: Undocument UseSIGIO in xorg.conf
The doc text is wrong at this point, input processing isn't going to
vary based on this, so we shouldn't say it does. The only thing this
_does_ get used for is DRI1 SwapBuffers (on everything but savage), and
if you disable it you're not going to get DRI1 at all, so we really
shouldn't even mention it.

Still, leave the option wired up to the parser so we don't break any
DRI1-driver-using setup relying on it being disabled, and so we don't
complain about unused options elsewhere.

Signed-off-by: Adam Jackson <ajax@redhat.com>
Acked-by: Keith Packard <keithp@keithp.com>
2016-06-08 11:36:32 -04:00
Adam Jackson
2725dd024d dri1: Hide the SIGIO details from drivers
Not being used, and not likely to be useful.

Signed-off-by: Adam Jackson <ajax@redhat.com>
Acked-by: Keith Packard <keithp@keithp.com>
2016-06-08 11:36:31 -04:00
Adam Jackson
95ce2bccdc dmx: Remove SIGIO input support here too
This code was broken anyway. Note that DEVICE_OFF would make dmx think
_no_ devices were using SIGIO anymore, which means 'xinput disable' on
your mouse would probably do weird things to your keyboard too. Rather
than try to repair that and keep SIGIO working on this one niche DDX,
just rip it out and use the thread model like everyone else.

Signed-off-by: Adam Jackson <ajax@redhat.com>
Acked-by: Keith Packard <keithp@keithp.com>
2016-06-08 11:36:31 -04:00
Adam Jackson
6178b1c91c dix: Use OsSignal() not signal()
As the man page for the latter states:

    The effects of signal() in a multithreaded process are unspecified.

We already have an interface to call sigaction() instead, use it.

Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
2016-06-08 11:36:31 -04:00
Olivier Fourdan
88e981e708 xwayland: sync event queue to check compositor reply
Read and dispatch pending Wayland events to make sure we do not miss a
possible reply from the compositor prior to discard a key repeat.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-06-03 09:44:09 +02:00
Olivier Fourdan
26ad25a0ed xwayland: refactor Wayland event handling
To be able to reuse some code.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-06-03 09:43:04 +02:00
Olivier Fourdan
239705a6fe xwayland: add a server sync before repeating keys
Key repeat is handled by the X server, but input events need to be
processed and forwarded by the Wayland compositor first.

Make sure the Wayland compositor is actually processing events, to
avoid repeating keys in Xwayland while the Wayland compositor cannot
deal with input events for whatever reason, thus not dispatching key
release events, leading to repeated keys while the user has already
released the key.

Bugzilla: https://bugzilla.gnome.org/show_bug.cgi?id=762618
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-06-03 09:42:56 +02:00
Keith Packard
3735ab965a Merge remote-tracking branch 'daenzer/for-master' 2016-06-02 07:47:16 -07:00
Jonas Ådahl
a779fda224 xwayland: Use the CLOCK_MONOTONIC clock
By default the X server will try CLOCK_MONOTONIC_COARSE before
CLOCK_MONOTONIC, while A Wayland compositor may only support getting
their timestamps from the CLOCK_MONOTONIC clock. This causes various
issues since it may happen that a timestamp from CLOCK_MONOTONIC
retrieved before a sending an X request will still be "later" than the
timestamp the X server than gets after receiving the request, due to the
fact that CLOCK_MONOTONIC_COARSE has a lower resolution.

To avoid these issues, make Xwayland always use CLOCK_MONOTONIC, so
that it becomes possible for Wayland compositor only supporting
CLOCK_MONOTONIC and X server to use the same clock.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Acked-by: Daniel Stone <daniels@collabora.com>
Tested-by: Olivier Fourdan <ofourdan@redhat.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-05-31 08:44:38 +10:00
Michel Dänzer
43dbc556f3 xfree86/modes: Remove xf86_reload_cursors v2
No longer needed now that xf86CursorResetCursor is getting called for
each CRTC configuration change.

v2: Keep xf86_reload_cursors as a deprecated empty inline function
    until all drivers stop calling it. (Adam Jackson)

Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-05-30 17:54:51 +09:00
Michel Dänzer
84e0d5d63c xfree86/modes: Assign xf86_config->cursor in xf86_load_cursor_image v2
Fixes a crash on startup in the radeon driver's drmmode_show_cursor()
due to xf86_config->cursor == NULL, because no CRTC was enabled yet, so
xf86_crtc_load_cursor_image was never called.

(Also use scrn->pScreen instead of xf86ScrnToScreen(scrn))

v2: Set xf86_config->cursor at the beginning of xf86_load_cursor_image
    instead of at the end.

Reviewed-by: Keith Packard <keithp@keithp.com>
2016-05-30 16:30:43 +09:00
Keith Packard
28b2c880a9 xfree86: Provide xf86BlockSIGIO and xf86ReleaseSIGIO as wrappers for input mutex
Threaded input doesn't use SIGIO anymore, but existing drivers using
xf86BlockSIGIO and xf86ReleaseSIGIO probably want to lock the input
mutex during those operations. Provide inline functions to do this
which are marked as 'deprecated' so that drivers will get warnings
until they are changed.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-05-30 00:17:34 -07:00
Keith Packard
de36200659 xfree86: Remove event reading code from xf86Wakeup
Oops. This didn't get removed when xfree86 was converted over to use
the input thread.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-05-29 19:21:06 -07:00
Keith Packard
c07b796b47 xfree86: Bump ABI versions
threaded input can affect drivers that use OsBlockSIGIO when dealing
with cursors.

Signed-off-by: Keith Packard <keithp@keithp.com>
Requested-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-05-29 18:44:37 -07:00
Keith Packard
714736124f modesetting: Use new xf86CurrentCursor API
Use this instead of the (now deprecated) cursor pointer in the
xf86CrtcConfigRec.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2016-05-27 10:11:16 -07:00
Keith Packard
e69061e605 kdrive: Use threaded input
Signed-off-by: Keith Packard <keithp@keithp.com>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-05-26 16:07:54 -07:00
Keith Packard
a977c9c4d0 xfree86: Use threaded input mechanism [v2]
Switch the XFree86 DDX over to threaded input

v2: Rewrite comment in xf86Helper about silken mouse

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-05-26 16:07:54 -07:00
Keith Packard
30ac756798 Create a threaded mechanism for input [v7]
The current SIGIO signal handler method, used at generation of input events,
has a bunch of oddities. This patch introduces an alternative way using a
thread, which is used to select() all input device file descriptors.

A mutex was used to control the access to input structures by the main and input
threads. Two pipes to emit alert events (such hotplug ones) and guarantee the
proper communication between them was also used.

Co-authored-by: Fernando Carrijo <fcarrijo@freedesktop.org>
Signed-off-by: Tiago Vignatti <tiago.vignatti@nokia.com>

v2: Fix non-Xorg link. Enable where supported by default.

    This also splits out the actual enabling of input threads to
    DDX-specific patches which follow

v3: Make the input lock recursive

v4: Use regular RECURSIVE_MUTEXes instead of rolling our own
    Respect the --disable-input-thread configuration option by
    providing stubs that expose the same API/ABI.

    Respond to style comments from Peter Hutterer.

v5: use __func__ in inputthread debug and error mesages.

    Respond to style comments from Peter Hutterer.

v6: use AX_PTHREAD instead of inlining pthread tests.

    Suggested by Emil Velikov <emil.l.velikov@gmail.com>

v7: Use pthread_sigmask instead of sigprocmask when using threads

    Suggested by Adam Jackson <ajax@redhat.com>

Signed-off-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-05-26 16:07:54 -07:00
Keith Packard
05d549d604 xfree86: Remove unnecessary errno save/restore in xf86ReadInput
When this code was called from SIGIO, saving and restoring errno could
possibly have made sense in some strange environment. Now that this
will not be called from a signal handler, there is no reason to do that.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-05-26 16:07:54 -07:00
Keith Packard
0bbb5aabf7 kdrive: Don't lock input across read in KdNotifyFd
We won't need these locks with the new threaded input code as it holds
the input lock across all of the input device I/O operations.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-05-26 16:07:54 -07:00