summaryrefslogtreecommitdiff
path: root/include
AgeCommit message (Collapse)AuthorFilesLines
2017-12-13modesetting: Fix potential buffer overflowDaniel Martin1-1/+1
If one misconfigures a ZaphodHeads value (more than 20 characters without a delimiter), we get an overflow of our buffer. Use xstrtokenize() instead of writing/fixing our own tokenizer. Signed-off-by: Daniel Martin <consume.noise@gmail.com> Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com> (cherry picked from commit 04a305121fbc08ecc2ef345ee7155d6087a43fd1)
2017-09-25xfree86: Silence a new glibc warningAdam Jackson1-0/+3
glibc would like to stop declaring major()/minor() macros in <sys/types.h> because that header gets included absolutely everywhere and unix device major/minor is perhaps usually not what's expected. Fair enough. If one includes <sys/sysmacros.h> as well then glibc knows we meant it and doesn't warn, so do that if it exists. Signed-off-by: Adam Jackson <ajax@redhat.com> (cherry picked from commit d732c36597fab2e9bc4f2aa72cf1110997697557)
2017-02-28Use arc4random_buf(3) if available to generate cookies.Matthieu Herrb1-0/+6
Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Matthieu Herrb <matthieu@herrb.eu> (cherry picked from commit 957e8db38f27932d353e86e9aa69cf16778b18f1)
2017-02-28Use timingsafe_memcmp() to compare MIT-MAGIC-COOKIES CVE-2017-2624Matthieu Herrb2-0/+8
Provide the function definition for systems that don't have it. Signed-off-by: Matthieu Herrb <matthieu@herrb.eu> Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> (cherry picked from commit d7ac755f0b618eb1259d93c8a16ec6e39a18627c)
2017-02-28os: log a bug whenever WriteToClient is called from the input threadPeter Hutterer1-0/+1
The input thread should generate events, not send them. Make it easier to find the instances where it's doing so. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Tested-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Olivier Fourdan <ofourdan@redhat.com> (cherry picked from commit 1b12249fd6d4d3b566043d556503f3f625b9b4ba)
2017-01-11AttendClient of grab-pervious client must queue to saved_ready_clients [v2]Keith Packard1-0/+6
A client which is attended while a grab is blocking execution of its requests needs to be placed in the saved_ready_clients list so that it will get scheduled once the grab terminates. Otherwise, if the client never sends another request, there is no way for it to be placed in the ready_clients list. v2: Wrap comment above mark_client_saved_ready. Remove test for OS_COMM_IGNORED which will always be true. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99333 Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Keith Packard <keithp@keithp.com> (cherry picked from commit 785053d033e73d2deb0ded4b97eabfd881991978)
2016-11-15dix: Make sure client is not in output_pending chain after closed (RH 1382444)Keith Packard1-1/+1
I think it is possible that output could get queued to a client during CloseDownClient. After it is removed from the pending queue, active grabs are released, the client is awoken if sleeping and any work queue entries related to the client are processed. To fix this, move the call removing it from the output_pending chain until after clientGone has been set and then check clientGone in output_pending_mark. Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1382444 Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-10-26ddx: add new call to purge input devices that weren't addedPeter Hutterer1-0/+1
Special case for the systemd-logind case in xfree86: when we're vt-switched away and a device is plugged in, we get a paused fd from logind. Since we can't probe the device or do anything with it, we store that device in the xfree86 and handle it later when we vt-switch back. The device is not added to inputInfo.devices until that time. When the device is removed while still vt-switched away, the the config system never notifies the DDX. It only runs through inputInfo.devices and our device was never added to that. When a device is plugged in, removed, and plugged in again while vt-switched away, we have two entries in the xfree86-specific list that refer to the same device node, both pending for addition later. On VT switch back, the first one (the already removed one) will be added successfully, the second one (the still plugged-in one) fails. Since the fd is correct, the device works until it is removed again. The removed devices' config_info (i.e. the syspath) doesn't match the actual device we addded tough (the input number increases with each plug), it doesn't get removed, the fd remains open and we lose track of the fd count. Plugging the device in again leads to a dead device. Fix this by adding a call to notify the DDX to purge any remainders of devices with the given config_info, that's the only identifiable bit we have at this point. https://bugs.freedesktop.org/show_bug.cgi?id=97928 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-10-05dix: Add valuator_mask_set_absolute_unacceleratedJonas Ådahl1-1/+4
Add a valuator mask setter for setting absolute coordinate combined with unaccelerated motion deltas. This will later be used by Xwayland to combine a wl_pointer.motion() event with the unaccelerated delta of a wp_relative_pointer.relative_motion() event. Signed-off-by: Jonas Ådahl <jadahl@gmail.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-09-22dix: Silence TSan warnings when checking for pending inputJeremy Huddleston Sequoia1-0/+6
V2: Moves InputCheckPending() into dix.h Bumps required version of xproto to 7.0.30 ================== WARNING: ThreadSanitizer: data race (pid=4943) Read of size 4 at 0x00010c4e3854 by thread T8: #0 WaitForSomething WaitFor.c:237 (X11.bin+0x00010049216c) #1 Dispatch dispatch.c:413 (X11.bin+0x000100352ed9) #2 dix_main main.c:287 (X11.bin+0x00010036e894) #3 server_thread quartzStartup.c:66 (X11.bin+0x000100039e63) Previous write of size 4 at 0x00010c4e3854 by thread T12 (mutexes: write M856, write M1976): #0 mieqEnqueue mieq.c:263 (X11.bin+0x000100448d14) #1 DarwinSendDDXEvent darwinEvents.c:641 (X11.bin+0x000100033613) #2 DarwinProcessFDAdditionQueue_thread darwinEvents.c:338 (X11.bin+0x000100032039) Location is global 'miEventQueue' at 0x00010c4e3850 (X11.bin+0x0001005ab854) Mutex M856 (0x00010c4c8c80) created at: #0 pthread_mutex_lock <null>:144 (libclang_rt.tsan_osx_dynamic.dylib+0x0000000321fe) #1 DarwinListenOnOpenFD darwinEvents.c:300 (X11.bin+0x000100031607) #2 socket_handoff bundle-main.c:288 (X11.bin+0x000100002b40) #3 __do_request_fd_handoff_socket_block_invoke bundle-main.c:379 (X11.bin+0x0001000029ba) #4 __tsan::invoke_and_release_block(void*) <null>:144 (libclang_rt.tsan_osx_dynamic.dylib+0x00000005d97b) #5 _dispatch_client_callout <null>:33 (libdispatch.dylib+0x0000000020ef) Mutex M1976 (0x00010c4e3d68) created at: #0 pthread_mutex_init <null>:144 (libclang_rt.tsan_osx_dynamic.dylib+0x0000000253c3) #1 input_lock inputthread.c:103 (X11.bin+0x00010049fd10) #2 TimerSet WaitFor.c:343 (X11.bin+0x0001004926c2) #3 RootlessQueueRedisplay rootlessScreen.c:594 (X11.bin+0x000100065d7f) #4 RootlessInstallColormap rootlessScreen.c:514 (X11.bin+0x000100069f1a) #5 miSpriteInstallColormap misprite.c:562 (X11.bin+0x000100467095) #6 miCreateDefColormap micmap.c:270 (X11.bin+0x000100440399) #7 DarwinScreenInit darwin.c:285 (X11.bin+0x0001000303bb) #8 AddScreen dispatch.c:3908 (X11.bin+0x00010036c417) #9 InitOutput darwin.c:671 (X11.bin+0x00010002fdeb) #10 dix_main main.c:197 (X11.bin+0x00010036e228) #11 server_thread quartzStartup.c:66 (X11.bin+0x000100039e63) Thread T8 (tid=4198779, running) created by main thread at: #0 pthread_create <null>:144 (libclang_rt.tsan_osx_dynamic.dylib+0x000000024490) #1 create_thread quartzStartup.c:78 (X11.bin+0x000100039dad) #2 QuartzInitServer quartzStartup.c:95 (X11.bin+0x000100039c16) #3 X11ApplicationMain X11Application.m:1238 (X11.bin+0x00010001cde4) #4 X11ControllerMain X11Controller.m:984 (X11.bin+0x00010002a642) #5 server_main quartzStartup.c:136 (X11.bin+0x00010003a03b) #6 do_start_x11_server bundle-main.c:436 (X11.bin+0x000100002eb5) #7 _Xstart_x11_server mach_startupServer.c:189 (X11.bin+0x000100004e99) #8 mach_startup_server mach_startupServer.c:399 (X11.bin+0x000100005734) #9 mach_msg_server mach_msg.c:563 (libsystem_kernel.dylib+0x000000012186) #10 start <null>:29 (libdyld.dylib+0x000000005254) Thread T12 (tid=4198797, running) created by thread T8 at: #0 pthread_create <null>:144 (libclang_rt.tsan_osx_dynamic.dylib+0x000000024490) #1 create_thread darwinEvents.c:121 (X11.bin+0x000100031ecf) #2 DarwinEQInit darwinEvents.c:365 (X11.bin+0x000100031860) #3 InitInput darwin.c:571 (X11.bin+0x00010002ea09) #4 dix_main main.c:261 (X11.bin+0x00010036e7ce) #5 server_thread quartzStartup.c:66 (X11.bin+0x000100039e63) SUMMARY: ThreadSanitizer: data race WaitFor.c:237 in WaitForSomething ================== ================== WARNING: ThreadSanitizer: data race (pid=22841) Write of size 4 at 0x000105bbd864 by main thread (mutexes: write M1945): #0 mieqEnqueue mieq.c:263 (X11.bin+0x000100448cf4) #1 DarwinSendDDXEvent darwinEvents.c:642 (X11.bin+0x000100033693) #2 -[X11Controller set_window_menu:] X11Controller.m:275 (X11.bin+0x0001000222fd) #3 -[X11Application set_window_menu:] X11Application.m:486 (X11.bin+0x000100018b44) #4 -[X11Application handleMachMessage:] X11Application.m:177 (X11.bin+0x000100016678) #5 __NSFireMachPort <null>:69 (Foundation+0x00000009b62b) #6 X11ControllerMain X11Controller.m:984 (X11.bin+0x00010002a5f2) #7 server_main quartzStartup.c:136 (X11.bin+0x000100039ffb) #8 do_start_x11_server bundle-main.c:436 (X11.bin+0x000100002e65) #9 _Xstart_x11_server mach_startupServer.c:189 (X11.bin+0x000100004e49) #10 mach_startup_server mach_startupServer.c:399 (X11.bin+0x0001000056e4) #11 mach_msg_server mach_msg.c:563 (libsystem_kernel.dylib+0x000000012186) #12 start <null>:29 (libdyld.dylib+0x000000005254) Previous read of size 4 at 0x000105bbd864 by thread T7: #0 Dispatch dispatch.c:434 (X11.bin+0x000100352fc8) #1 dix_main main.c:287 (X11.bin+0x00010036e874) #2 server_thread quartzStartup.c:66 (X11.bin+0x000100039e23) Location is global 'miEventQueue' at 0x000105bbd860 (X11.bin+0x0001005ab864) Mutex M1945 (0x000105bbdd78) created at: #0 pthread_mutex_init <null>:144 (libclang_rt.tsan_osx_dynamic.dylib+0x0000000253c3) #1 input_lock inputthread.c:103 (X11.bin+0x00010049fd10) #2 TimerSet WaitFor.c:348 (X11.bin+0x0001004926c2) #3 RootlessQueueRedisplay rootlessScreen.c:594 (X11.bin+0x000100065d3f) #4 RootlessInstallColormap rootlessScreen.c:514 (X11.bin+0x000100069eda) #5 miSpriteInstallColormap misprite.c:562 (X11.bin+0x000100467075) #6 miCreateDefColormap micmap.c:270 (X11.bin+0x000100440379) #7 DarwinScreenInit darwin.c:285 (X11.bin+0x00010003036b) #8 AddScreen dispatch.c:3914 (X11.bin+0x00010036c3f7) #9 InitOutput darwin.c:671 (X11.bin+0x00010002fd9b) #10 dix_main main.c:197 (X11.bin+0x00010036e208) #11 server_thread quartzStartup.c:66 (X11.bin+0x000100039e23) Thread T7 (tid=4257217, running) created by main thread at: #0 pthread_create <null>:144 (libclang_rt.tsan_osx_dynamic.dylib+0x000000024490) #1 create_thread quartzStartup.c:78 (X11.bin+0x000100039d6d) #2 QuartzInitServer quartzStartup.c:95 (X11.bin+0x000100039bd6) #3 X11ApplicationMain X11Application.m:1238 (X11.bin+0x00010001cd94) #4 X11ControllerMain X11Controller.m:984 (X11.bin+0x00010002a5f2) #5 server_main quartzStartup.c:136 (X11.bin+0x000100039ffb) #6 do_start_x11_server bundle-main.c:436 (X11.bin+0x000100002e65) #7 _Xstart_x11_server mach_startupServer.c:189 (X11.bin+0x000100004e49) #8 mach_startup_server mach_startupServer.c:399 (X11.bin+0x0001000056e4) #9 mach_msg_server mach_msg.c:563 (libsystem_kernel.dylib+0x000000012186) #10 start <null>:29 (libdyld.dylib+0x000000005254) SUMMARY: ThreadSanitizer: data race mieq.c:263 in mieqEnqueue ================== Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com> Reviewed-by: Keith Packard <keithp@keithp.com>
2016-09-19dix: Incroduce CursorConfinedTo vfunc in ScreenJonas Ådahl1-0/+5
This function will be called when a pointer is grabbed non-root window set as the 'confineTo'. This will enable the ddx to handle the confinement their own way. Signed-off-by: Jonas Ådahl <jadahl@gmail.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Keith Packard <keithp@keithp.com>
2016-09-19dix: Introduce CursorWarpedTo vfunc in ScreenJonas Ådahl1-0/+9
This new vfunc will be called, if set, after a client has issued a WarpPointer request. This is necessary for implementing pointer warp emulation in Xwayland. Signed-off-by: Jonas Ådahl <jadahl@gmail.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Keith Packard <keithp@keithp.com>
2016-09-16include: Add 'xserver_poll.h' to Makefile.amKeith Packard1-0/+1
Make sure this file is included in the tarball. Signed-off-by: Keith Packard <keithp@keithp.com>
2016-09-16Remove 'dixfontstubs.h' from include EXTRA_DISTKeith Packard1-1/+1
This file was removed when moving to the new libXfont API, but accidentally left in EXTRA_DIST. Signed-off-by: Keith Packard <keithp@keithp.com>
2016-09-16Add SyncSharedPixmap ScreenRec hookMichel Dänzer1-0/+19
Signed-off-by: Michel Dänzer <michel.daenzer@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Keith Packard <keithp@keithp.com>
2016-09-15Add Windows-DRI extensionJon Turney1-0/+5
If windowsdriproto headers are available, build a Windows-DRI extension, which supports requests to enable local clients to directly render GL to a Windows drawable: - a query to check if WGL is being used on a screen - a query to map a fbconfigID to a native pixelformatindex - a query to map a drawable to a native handle Windows-DRI can only be useful if we are using WGL, so make an note if WGL is active on a screen. Make validGlxDrawable() public Adjust glxWinSetPixelFormat() so it doesn't require a context, just a screen and config. That enables factoring out the deferred drawable creation code as glxWinDeferredCreateDrawable() Enhance glxWinDeferredCreateDrawable(), so that pixmaps are placed into a file mapping, so they exist in memory which can be shared with the direct rendering process. Currently, this file mapping is accessed by a name generated from the XID. This will not be unique across multiple server instances. It would perhaps be better, although more complicated, to use an anonymous file mapping, and then duplicate the handle for the direct rendering process. Use glxWinDeferredCreateDrawable() to ensure the native handle exists for the Windows-DRI query to map a drawable to native handle. v2: Various printf format warning fixes v3: Fix format warnings on x86 Move some uninteresting windows-dri output to debug log level v4: check for windowsdriproto when --enable-windowsdri use windowsdriproto_CFLAGS Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk> Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
2016-09-13os: Use pthread_setname_np to set thread names if availableAlan Coopersmith1-0/+6
Autoconf logic borrowed from glib Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com> Tested-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
2016-09-13dix: Add dixPrivatesCreated helper functionDave Airlie1-0/+3
This is a preparation patch for adding prime hw-cursor support. Signed-off-by: Dave Airlie <airlied@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Keith Packard <keithp@keithp.com> Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2016-07-21os: Remove CheckConnectionsKeith Packard1-2/+0
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-21Allow 1024 and 2048 for LimitClientsKeith Packard1-1/+1
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: Switch server to poll(2) [v3]Keith Packard1-0/+20
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 Packard2-2/+16
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 Packard1-0/+3
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-19os: Add poll emulation for mingw [v2]Brian M. Clapper2-0/+58
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-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 Packard1-2/+1
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-18Remove AddEnabledDevice and AddGeneralSocket APIsKeith Packard1-8/+0
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 Packard1-13/+13
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 Packard1-4/+7
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-18dix: Switch to the libXfont2 API (v2)Keith Packard3-55/+7
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-06-28xf86: Add PRIME flipping functions to ScreenAlex Goins1-0/+14
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-17xrandrprovider: Do not use separate lists for unbound / source / offload slavesHans de Goede1-8/+7
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-08Allow compile-time selection of a fallback input driverPeter Hutterer1-0/+3
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-08prime: clean up slave bo properly. (v3)Dave Airlie1-0/+3
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-08dix: Use OsSignal() not signal()Adam Jackson1-2/+0
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-03xkb: add hook to allow/deny AccessX key repeatOlivier Fourdan1-0/+6
The xserver generates the key repeat by itself. But when used with another server processing inputs first (e.g. a Wayland compositor), the other server may be busy dealing with some other things and not queue up key release events in time. Add a vfunc in XkbSrvInfo to possibly add a check before re-emitting a keypress event in the AccessX timer handler, so that the key repeat has a chance to be denied if the server processing the input is not ready. Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-05-31xwayland: Use the CLOCK_MONOTONIC clockJonas Ådahl1-0/+7
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-26Create a threaded mechanism for input [v7]Keith Packard4-6/+23
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-26Remove SIGIO support for input [v5]Keith Packard3-9/+9
This removes all of the SIGIO handling support used for input throughout the X server, preparing the way for using threads for input handling instead. Places calling OsBlockSIGIO and OsReleaseSIGIO are marked with calls to stub functions input_lock/input_unlock so that we don't lose this information. xfree86 SIGIO support is reworked to use internal versions of OsBlockSIGIO and OsReleaseSIGIO. v2: Don't change locking order (Peter Hutterer) v3: Comment weird && FALSE in xf86Helper.c Leave errno save/restore in xf86ReadInput Squash with stub adding patch (Peter Hutterer) v4: Leave UseSIGIO config parameter so that existing config files don't break (Peter Hutterer) v5: Split a couple of independent patch bits out of kinput.c (Peter Hutterer) Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-05-04xkb: after changing the keymap, force an indicator updatePeter Hutterer1-0/+4
When NumLock is on and a new keymap is applied, the next modifier state change will turn off that LED (but leave the state enabled). The cause for this is a bit convoluted: * the SLI explicitState is copied from the current state in ProcXkbGetKbdByName. Thus, if NumLock is on, that state is 0x2. * on the next modifier key press (e.g. Shift), XkbApplyState() calls into XkbUpdateIndicators() -> XkbUpdateLedAutoState() to update SLIs (if any) for the currently changed modifier. But it does so with a mask only for the changed modifier (i.e. for Shift). * XkbUpdateLedAutoState() calculates the state based on this mask and ends up with 0 because we don't have a Shift LED and we masked out the others. * XkbUpdateLedAutoState() compares that state with the previous state (which is still 0x2) and then proceeds to turn the LED off This doesn't happen in the normal case because either the mask encompasses all modifiers or the state matches of the masked-out modifiers matches the old state. Avoid this issue by forcing an SLI update after changing the keymap. This updates the sli->effectiveState and thus restores everything to happy working order. https://bugzilla.redhat.com/show_bug.cgi?id=1047151 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Daniel Stone <daniels@collabora.com>
2016-05-03xfree86: add support for MatchIsTabletPadPeter Hutterer1-0/+1
The tablet pads have been separate kernel devices for a while now and libwacom has labelled them with the udev ID_INPUT_TABLET_PAD for over a year now. Add a new MatchIsTabletPad directive to apply configuration options specifically to the Pad part of a tablet. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-04-18dix: Add RootWindowFinalizeCallbackAdam Jackson1-0/+2
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com> Signed-off-by: Adam Jackson <ajax@redhat.com>
2016-03-08xwayland: Correctly detect whether posix_fallocate existsJonas Ådahl1-0/+3
We had HAVE_POSIX_FALLOCATE checks, but no such macros were ever defined anywhere. This commit makes it so that this macro is defined if the posix_fallocate is detected during configure. Signed-off-by: Jonas Ådahl <jadahl@gmail.com> Reviewed-by: Julien Cristau <jcristau@debian.org>
2016-03-01vidmode: build without xf86vidmodeprotoOlivier Fourdan1-0/+2
git commit f175cf45: vidmode: move to a separate library of its own introduced a regression where the xserver would not build when xf86vidmodeproto is not installed even if the configure option "--disable-xf86vidmode" is specified. Fix build failure when xf86vidmodeproto is not installed. Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
2016-03-01config/udev: distinguish between real keyboards and other key devicesLaércio de Sousa1-0/+1
This patch introduces a new flag ATTR_KEY for hotplugged input devices, so we can better distinguish between real keyboards (i.e. devices with udev property ID_INPUT_KEYBOARD="1") and other key input devices like lid switches, power buttons, etc. All supported hotplug backends (udev, hal, and wscons) will set both flags ATTR_KEY and ATTR_KEYBOARD for real keyboards, but udev backend will set ATTR_KEY, but not ATTR_KEYBOARD, for non-keyboard key input devices (hal and wscons will set both flags in any case). With this distinction, kdrive input hotplugging mechanism will be allowed to only grab real keyboards, as other key input devices are currently not supported. In order to don't break current behaviour, this patch will replace all ATTR_KEYBOARD occurrences with ATTR_KEY in hw/xfree86/common/xf86Xinput.c. [ajax: Just add ATTR_KEY, don't re-number the other attributes] Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Laércio de Sousa <laerciosousa@sme-mogidascruzes.sp.gov.br>
2016-02-29vidmode: move to a separate library of its ownOlivier Fourdan2-0/+141
XVidMode extension might be useful to non hardware servers as well (e.g. Xwayand) so that applications that rely on it (e.g. lot of older games) can at least have read access to XVidMode. But the implementation is very XFree86 centric, so the idea is to add a bunch of vfunc that other non-XFree86 servers can hook up into to provide a similar functionality. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=87806 Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
2016-02-29vidmode: move display mode definitionsOlivier Fourdan2-0/+103
To be able to reuse the VidMode extension in a non-hardware server, the display mode definitions need to be accessible from DIX. Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
2016-02-29dix: Add ClientSignalAll()Chris Wilson1-0/+8
This is a variant of ClientSignal() that signals all clients with an optional matching sleeping client, function and closure. Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-02-22dix: Add hybrid full-size/empty-clip mode to SetRootClipDaniel Stone1-1/+7
216bdbc735 removed the SetRootClip call in the XWayland output-hotplug handler when running rootless (e.g. as a part of Weston/Mutter), since the root window has no storage, so generating exposures will result in writes to invalid memory. Unfortunately, preventing the segfault also breaks sprite confinement. SetRootClip updates winSize and borderSize for the root window, which when combined with RRScreenSizeChanged calling ScreenRestructured, generates a new sprite-confinment area to update it to the whole screen. Removing this call results in the window geometry being reported correctly, but winSize/borderSize never changing from their values at startup, i.e. out of sync with the root window geometry / screen information in the connection info / XRandR. This patch introduces a hybrid mode, where we update winSize and borderSize for the root window, enabling sprite confinement to work correctly, but keep the clip emptied so exposures are never generated. Signed-off-by: Daniel Stone <daniels@collabora.com> Tested-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-01-06Fix uninitialized variable warnings reported by clangThomas Klausner1-3/+5
v2: Move initializing pos into the first clause of the for statement. We have to keep this macro equivalent to a plain for statement from the user's perspective, otherwise callers need to {} things to keep control flow correct. [ajax] Signed-off-by: Thomas Klausner <wiz@NetBSD.org> Acked-by: Michel Dänzer <michel.daenzer@amd.com>