summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2016-08-02xfree86/modes: Handle no palette case better in xf86RandR12CrtcSetGammafor-masterMichel Dänzer1-1/+9
Just use the RandR gamma ramp directly. Fixes random on-monitor colours with drivers which don't call xf86HandleColormaps, e.g. modesetting. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97154 Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-07-30present: Handle event mask updates as specified v2Michel Dänzer2-5/+26
From the Present extension specification: An event context is associated with a specific window; using an existing event context with a different window generates a Match error. If eventContext specifies an existing event context, then if eventMask is empty, PresentSelectInput deletes the specified context, otherwise the specified event context is changed to select a different set of events. If eventContext is an unused XID, then if eventMask is empty no operation is performed. Otherwise, a new event context is created selecting the specified events. Without this change, there's no way for a client to explicitly change or destroy an existing event mask entry. Trying to do so as specified above would just result in a protocol error. v2: (Keith Packard) * Use dixLookupResourceByType instead of walking window_priv->events * Return BadMatch if the existing event context is associated with a different window or client * Call LEGAL_NEW_RESOURCE again when creating a new event context * Drop invalid "leak fix" Signed-off-by: Michel Dänzer <michel.daenzer@amd.com> Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Keith Packard <keithp@keithp.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2016-07-28present: Only call restore_screen_pixmap once from set_abort_flipMichel Dänzer1-3/+4
present_restore_screen_pixmap's work doesn't need to be done several times for the same pending flip. Fixes a crash if the X server quits while a flip is pending, in which case present_set_abort_flip may be called several times, including when screen->root is already cleared to NULL. Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-07-28xfree86: Hook up colormaps and RandR 1.2 gamma code v6Michel Dänzer4-122/+124
Instead of breaking the former when the driver supports the latter, hook them up so that the hardware LUTs reflect the combination of the current colourmap and gamma states. I.e. combine the colourmap, the global gamma value/ramp and the RandR 1.2 per-CRTC gamma ramps into one combined LUT per CRTC. Fixes e.g. gamma sliders not working in games. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=27222 v2: * Initialize palette_size and palette struct members, fixes crash on server startup. v3: * Free randrp->palette in xf86RandR12CloseScreen, fixes memory leak. v4: * Call CMapUnwrapScreen if xf86RandR12InitGamma fails (Emil Velikov). * Still allow xf86HandleColormaps to be called with a NULL loadPalette parameter in the xf86_crtc_supports_gamma case. v5: * Clean up inner loops in xf86RandR12CrtcComputeGamma (Keith Packard) * Move palette update out of per-CRTC loop in xf86RandR12LoadPalette (Keith Packard) v6: * Handle reallocarray failure in xf86RandR12LoadPalette (Keith Packard) Reviewed-by: Keith Packard <keithp@keithp.com>
2016-07-28xfree86/modes: Remove xf86RandR12CrtcGetGammaMichel Dänzer1-39/+0
This would normally return the same values the core RandR code passed to xf86RandR12CrtcSetGamma before, which is rather pointless. The only possible exception would be if a driver tried initializing crtc->gamma_red/green/blue to reflect the hardware LUT state on startup, but that can't work correctly if whatever set the LUT before the server started was running at a different depth. Even the pointless round-trip case will no longer work with the following change. Reviewed-by: Keith Packard <keithp@keithp.com>
2016-07-27xfree86/modes: Move gamma initialization to xf86RandR12Init12 v2Michel Dänzer2-114/+114
RRCrtcGammaSetSize cannot be used yet in xf86InitialConfiguration, because randr_crtc isn't allocated yet at that point, but a following change will require RRCrtcGammaSetSize to be called from xf86RandR12CrtcInitGamma. v2: * Bail from xf86RandR12CrtcInitGamma if !crtc->funcs->gamma_set (Keith Packard) Reviewed-by: Keith Packard <keithp@keithp.com>
2016-07-21os: Clean up WaitFor.cKeith Packard1-84/+41
Do all timer stuff before blocking, avoiding a bunch of duplicate code and merge common code in WaitForSomething. The WaitForSomething changes need a bit of explanation to show that the new code is effectively equivalent to the old. Eliding error checking and trivial bits we've got: Before: if (ready clients) timeout = 0 else compute timeout i = poll if (i <= 0) { if (ready clients) return TRUE; if (input) return FALSE; if (any ready timers) { run timers return FALSE; } } else { if (input) return FALSE; if (any ready timers) { run timers return FALSE; } if (ready clients) return TRUE; } After: if (ready clients) timeout = 0; else compute timeout run_timers poll if (input) return FALSE; if (ready clients) return TRUE; The old code would return TRUE if there were ready clients and input pending. Dispatch would then schedule that ready client, but before processing any requests, it would notice that there was input pending and go process it. The new code just checks for input first, which is effectively the same. If the poll timed out and there weren't clients ready, then timers would get run. If the poll didn't time out, then timers would get run, even if there were clients now ready. Now, if the timeout interval was zero, that means that the timers must have been ready *before* poll was invoked. In this case, we should simply run the timers before calling poll -- no sense calling poll just to discard any data that it generates. If the timeout interval was non-zero, and poll didn't timeout, then either there aren't any timers to run, or we got a surprise and hit a timer exactly as a client became ready to run. This is the one case where the new code is different from the old; the new code delays the timer call until the next time WaitForSomething is called. Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-07-21os: Use xorg_list for struct _OsTimerRecKeith Packard1-73/+84
No sense having an open-coded linked list here, plus the doubly linked list is more efficient Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-07-21os: Remove CheckConnectionsKeith Packard3-42/+2
poll provides per-fd notification of failure, so we don't need CheckConnections anymore. Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-07-21os: Leave stdin and stdout openKeith Packard1-11/+0
There's no reason to close these now that we don't care what file descriptors we use. Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-07-21Allow 1024 and 2048 for LimitClientsKeith Packard2-3/+5
There's no reason not to offer ridiculous numbers of clients; only a few static data structures are arrays of this length. Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-07-21os: eliminate fd value limits for clientsKeith Packard2-100/+23
With no code depending on the range of file descriptors, checking for that can be eliminated. Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-07-21os: Use ospoll for input thread [v2]Keith Packard1-38/+82
Replace use of select(2) to avoid fd limits. Note that InputThreadFillPipe used select as well, but none of the files passed were non-blocking, so there was no need for that code at all. v2: Keep ospoll API usage single threaded to avoid re-entrancy issues Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-07-21os: Switch server to poll(2) [v3]Keith Packard8-444/+218
Eliminates all of the fd_set mangling in the server main thread v2: Listen for POLLOUT while writes are blocked. v3: Only mark client not ready on EAGAIN return from read Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-07-21dix: Use list for ready clientsKeith Packard6-55/+118
This converts the dispatch loop into using a list of ready clients instead of an array. This changes the WaitForSomething API so that it notifies DIX when a client becomes ready to read, instead of returning the set of ready clients. Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-07-21os: Add ospoll interface [v2]Keith Packard5-1/+589
This provides a wrapper around poll or epoll providing a callback-based interface for monitoring activity on a large set of file descriptors. v2: use xserver_poll API instead of poll. Don't use WSAPoll as that is broken. Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-07-21Switch poll() users to xserver_poll()Keith Packard10-22/+21
This uses the wrapper in case we need to emulate poll with select as we do on Windows. Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Keith Packard <keithp@keithp.com>
2016-07-19os: Add poll emulation for mingw [v2]Brian M. Clapper5-1/+344
v2: rename as 'xserver_poll' to avoid potential library name collisions. Provide 'xserver_poll.h' which uses the system poll where available and falls back to this emulation otherwise. Autodetects when this is required, building the emulation only then Source: https://github.com/bmc/poll Signed-off-by: Adam Jackson <ajax@redhat.com>
2016-07-19hw/xwin: Update BlockHandler function signatureJon Turney2-4/+2
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-19hw/xwin: Update for removal of AddEnabledDeviceJon Turney1-1/+13
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-18xfree86: if ATTR_KEYBOARD is set, match for keyboardsPeter Hutterer1-1/+1
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-18modesetting: resubmit dirty rects on EINVAL (v2)Adam Jackson1-0/+9
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-18os: InputThreadFillPipe doesn't need select or pollKeith Packard1-16/+2
The file descriptors passed to InputThreadFillPipe are always blocking, so there's no need to use Select (or poll). Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-07-18os: Move ETEST macro from io.c to osdep.hKeith Packard2-14/+14
This lets other code share this functionality Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-07-18os: Add X_NOTIFY_ERROR valueKeith Packard1-3/+4
This provides a way to report errors on file descriptors that is better defined than "any bits which are not READ or WRITE". Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-07-18os: Compute timeout in milliseconds instead of struct timevalKeith Packard3-33/+23
The timeout resolution offered in the AdjustWaitForDelay call is only milliseconds, so passing around the timeout as a pointer to a struct timeval is not helpful. Doing everything in milliseconds up to the point of the select call simplifies the code without affecting functionality at all. Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-07-18dix: Intermediate GrabServer state 'GrabKickout' not neededKeith Packard1-7/+1
The intermediate grabState, "GrabKickout", was used to trigger dispatch into going back to WaitForSomething after doing a GrabServer so that the set of ready clients would be recomputed to match what the server should be processing. As we only process one client per WaitForSomething call, we will always hit WaitForSomething after finishing the current client, and so don't need any special case here. Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-07-18dix/os: Merge priority computation into SmartScheduleClientKeith Packard2-41/+14
Instead of having scheduling done in two places (one in WaitForSomething, and the other in SmartScheduleClient), just stick all of the scheduling in SmartScheduleClient. Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-07-18Bump ABI versions to reflect block/wakeup handler API changesKeith Packard1-2/+2
Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-07-18Remove AddEnabledDevice and AddGeneralSocket APIsKeith Packard3-46/+9
All uses of these interfaces should instead be using the NotifyFd API instead. Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-07-18Remove fd_set from Block/Wakeup handler APIKeith Packard18-69/+62
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-18Remove readmask from screen block/wakeup handlerKeith Packard22-131/+77
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-18dmx: Eliminate use of AddEnabledDevice [v2]Keith Packard1-4/+13
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-18modesetting: Use passed-in fd for drm event monitoring NotifyFd callbackKeith Packard1-1/+1
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-18hw/kdrive: Use passed-in fd for kdrive/linux APM monitoring [v2]Keith Packard1-33/+31
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-18xnest: Use SetNotifyFd to receive eventsKeith Packard1-1/+8
Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-07-18hw/xfree86: Use NotifyFd for other input fd wakeupsKeith Packard1-26/+22
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-18os: Use NotifyFd for ErrorConnMaxKeith Packard1-22/+19
Instead of open-coding a single FD wait, use NotifyFd to wait for the FD to become readable before returning the error message. Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-07-18dmx: Switch from select(2) to poll(2) for inputKeith Packard2-16/+15
Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-07-18xfree86: Switch from select(2) to poll(2)Keith Packard3-45/+53
xf86WaitForInput and the xf86 SIGIO handling code. Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-07-18kdrive: switch from select(2) to poll(2)Keith Packard6-48/+28
This avoids fd limits Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-07-18dix: Switch to the libXfont2 API (v2)Keith Packard17-212/+231
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-18glamor: Remove the FBO cache.Eric Anholt3-275/+6
It is a modest performance improvement (2.7% on Intel), with the significant downside that it keeps extra pixmap contents laying around for 1000 BlockHandlers without the ability for the system to purge them when under memory pressure, and tiled renderers don't know that we could avoid reading their current contents when beginning to render again. We could use the FB invalidate functions, but they aren't always available, aren't hooked up well in Mesa, and would eat into the performance gains of having the cache. [ajax: rebased to master] Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-07-15glamor: Translate solid text background region after clippingMichel Dänzer1-6/+7
Fixes incorrect clipping for redirected windows which don't happen to be located at the top left corner of the screen. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=96742 Signed-off-by: Michel Dänzer <michel.daenzer@amd.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-07-15xfree86: Fix fallback driver sort order for Xorg -configure (v2)Adam Jackson1-19/+40
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-15shm: Also censor images returned by ShmGetImageAndrew Eikum1-0/+17
We currently censor images from dix's GetImage, but not from ShmGetImage. This is a method to bypass XACE, creating a potential leak. We should censor in both methods. Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Andrew Eikum <aeikum@codeweavers.com>
2016-07-15xwayland: Only force monotonic clock onceAdam Jackson1-1/+2
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-15xwayland: Update RR state on wl_output.done instead of wl_output.modeRui Matos2-9/+10
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-15dix: Work around non-premultiplied ARGB cursor dataMichel Dänzer1-0/+23
Some games incorrectly use non-premultiplied ARGB cursor data, presumably because that's what Windows uses. On some hardware (and with SWcursor), this breaks areas of the cursor which are supposed to be transparent (and presumably also translucent areas, but that's less noticeable). This change checks for pixels with alpha == 0 and any non-alpha component != 0. If any such pixel is found, the data is assumed to be non-premultiplied and fixed up by multiplying the RGB components with the alpha component. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=92309 Signed-off-by: Michel Dänzer <michel.daenzer@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-07-08linux: Do not try to open /dev/vc/0, fix error msg when /dev/tty0 open failsHans De Goede1-9/+1
/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>