Commit Graph

16594 Commits

Author SHA1 Message Date
Adam Jackson
fc25bceb51 dix: Allow an extension to disable itself
GLX registers an extension before we know if there are any screens that
can actually do it. It's inconvenient to shrink the extension list, so
instead allow the extension to simply zero out its base opcode to
indicate that it needed to panic and disable itself.

Signed-off-by: Adam Jackson <ajax@redhat.com>
2018-04-24 14:36:04 -04:00
Adam Jackson
73a1cb9c92 dix: Factor out extension availability check
Signed-off-by: Adam Jackson <ajax@redhat.com>
2018-04-24 14:36:03 -04:00
Adam Jackson
9d5af632fd animcur: Fix crash when removing a master device
Reproducer:

$ Xvfb -ac -noreset :1 &
$ DISPLAY=:1 xinput create-master touch1
$ DISPLAY=:1 xinput remove-master "touch1 pointer"

Bugzilla: https://bugs.freedesktop.org/105761
Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-24 14:28:27 -04:00
Thomas Klausner
8275903956 sdksyms: Cope with __pid_t and __uint32_t
Kludge sdksyms.c generator to not fail on GetClientPid.
It returns pid_t which on NetBSD is #define pid_t __pid_t
This slightly alters the GCC preprocessor output which this fragile
code could not deal with when using GCC 5+

Signed-off-by: Adam Jackson <ajax@redhat.com>
2018-04-23 14:56:17 -04:00
Mario Kleiner
e29d783278 modesetting: Only use modifiers on kms drivers which do support them.
Use the DRM_CAP_ADDFB2_MODIFIERS query to make sure the kms
driver supports modifiers in the addfb2 ioctl, and fall back
to addfb ioctl without modifiers if modifiers are unsupported.

E.g., as of Linux 4.17, nouveau-kms so far does not suppport
modifiers and gets angry if drmModeAddFB2WithModifiers() is
called (-> failure to set a video mode -> blank screen), but
Mesa's nvc0+ gallium driver causes gbm_bo_get_modifier() to
return a valid modifier by translating the default tiling of
bo's created via gbm_bo_create() into a modifier other than
DRM_FORMAT_MOD_INVALID (see Mesa's nvc0_miptree_get_modifier()).

Testing for != DRM_FORMAT_MOD_INVALID is apparently not
sufficient for safe use of drmModeAddFB2WithModifiers.

Bonus: Handle potential failure of populate_format_modifiers().

The required DRM_CAP is defined since libdrm v2.4.65, and we
require v2.4.89+ for the server, so we can use it unconditionally.

Tested on intel-kms, radeon-kms, nouveau-kms. Fixes failure on
NVidia Pascal.

Fixes: 2f807c2324 ("modesetting: Add support for multi-plane pixmaps when page-flipping")
Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Cc: Daniel Stone <daniels@collabora.com>
Cc: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Reviewed-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
2018-04-23 14:05:43 -04:00
Lyude Paul
fe4d1876b4 meson: Fix indenting in glx/meson.build
No functional changes, just fixing a tabs vs. space error I noticed

Signed-off-by: Lyude Paul <lyude@redhat.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-04-19 16:20:27 -04:00
Lyude Paul
4e28a6a223 meson: Ensure we always build Xext/hashtable.c for glx
Seems that while glxvnd relies on some of the hashtable functions in
Xext, we only build hashtable support for Xext if we're also building
the res extension. This leads to some errors if you try to build glx
without res enabled:

glx/liblibglxvnd.a(vndcmds.c.o): In function `LookupVendorPrivDispatch':
/home/lyudess/Projects/xserver/glx/vndcmds.c:65: undefined reference to `ht_find'
/home/lyudess/Projects/xserver/glx/vndcmds.c:67: undefined reference to `ht_add'
glx/liblibglxvnd.a(vndcmds.c.o): In function `GlxDispatchInit':
/home/lyudess/Projects/xserver/glx/vndcmds.c:405: undefined reference to `ht_generic_compare'
/home/lyudess/Projects/xserver/glx/vndcmds.c:405: undefined reference to `ht_generic_hash'
/home/lyudess/Projects/xserver/glx/vndcmds.c:405: undefined reference to `ht_create'
glx/liblibglxvnd.a(vndcmds.c.o): In function `GlxDispatchReset':
/home/lyudess/Projects/xserver/glx/vndcmds.c:468: undefined reference to `ht_destroy'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

So, make sure that hashtable.c gets both for both glx and res

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Lyude Paul <lyude@redhat.com>
2018-04-19 16:20:22 -04:00
Olivier Fourdan
3b4671f9e9 xwayland: Clean up all frame callbacks
Regardless of the order we un-realize windows.

Suggested-by: Roman Gilg <subdiff@gmail.com>
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Roman Gilg <subdiff@gmail.com>
2018-04-19 16:15:44 -04:00
Olivier Fourdan
8b8f9007cc xwayland: avoid using freed xwl_window on unrealize
xwl_unrealize_window() would use freed xwl_window which can lead to
various memory corruption and crashes, as reported by valgrind:

 Invalid read of size 8
    at 0x42C802: xwl_present_cleanup (xwayland-present.c:84)
    by 0x42BA67: xwl_unrealize_window (xwayland.c:601)
    by 0x541EE9: compUnrealizeWindow (compwindow.c:285)
    by 0x57E1FA: UnrealizeTree (window.c:2816)
    by 0x581189: UnmapWindow (window.c:2874)
    by 0x54EB26: ProcUnmapWindow (dispatch.c:879)
    by 0x554B7D: Dispatch (dispatch.c:479)
    by 0x558BE5: dix_main (main.c:276)
    by 0x7C4B1BA: (below main) (libc-start.c:308)
  Address 0xf520f60 is 96 bytes inside a block of size 184 free'd
    at 0x4C2EDAC: free (vg_replace_malloc.c:530)
    by 0x42B9FB: xwl_unrealize_window (xwayland.c:624)
    by 0x541EE9: compUnrealizeWindow (compwindow.c:285)
    by 0x57E1FA: UnrealizeTree (window.c:2816)
    by 0x581189: UnmapWindow (window.c:2874)
    by 0x54EB26: ProcUnmapWindow (dispatch.c:879)
    by 0x554B7D: Dispatch (dispatch.c:479)
    by 0x558BE5: dix_main (main.c:276)
    by 0x7C4B1BA: (below main) (libc-start.c:308)
  Block was alloc'd at
    at 0x4C2FB06: calloc (vg_replace_malloc.c:711)
    by 0x42B307: xwl_realize_window (xwayland.c:488)
    by 0x541E59: compRealizeWindow (compwindow.c:268)
    by 0x57DA40: RealizeTree (window.c:2617)
    by 0x580B28: MapWindow (window.c:2694)
    by 0x54EA2A: ProcMapWindow (dispatch.c:845)
    by 0x554B7D: Dispatch (dispatch.c:479)
    by 0x558BE5: dix_main (main.c:276)
    by 0x7C4B1BA: (below main) (libc-start.c:308)

This is because UnrealizeTree() traverses the tree from top to bottom,
which invalidates the assumption that if the Window doesn't feature an
xwl_window on its own, it's the xwl_window of its first ancestor with
one.

This reverts commit 82df2ce3

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
2018-04-18 10:47:15 -04:00
David Woodhouse
12a6b189fb glamor: fix glamor_xv_query_image_attributes() for odd-width images
Images which are one pixel wider than a multiple of 8 are being handled
incorrectly. Other drivers round up the width to a multiple of two
before they start calculating. Do the same.

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

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2018-04-17 17:30:16 -04:00
Chris Wilson
ac7a4bf44c os/WaitFor: Check timers on every iteration
Currently we only check timer expiry if there are no client fd (or
other input) waiting to be serviced. This makes it very easy to starve
the timers with long request queues, and so miss critical timestamps.

The timer subsystem is just another input waiting to be serviced, so
evaluate it on every loop like all the others, at the cost of calling
GetTimeInMillis() slightly more frequently. (A more invasive and likely
OS specific alternative would be to move the timer wheel to the local
equivalent of timerfd, and treat it as an input fd to the event loop
exactly equivalent to all the others, and so also serviced on every
pass. The trade-off being that the kernel timer wheel is likely more
efficiently integrated with epoll, but individual updates to each timer
would then require syscalls.)

Reviewed-by: Peter Harris <pharris@opentext.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2018-04-17 16:30:36 -04:00
Adam Jackson
78b6f94021 modesetting: Fix inverted check in dri2 WaitMSC
ms_queue_vblank() returns false on failure.

Reported-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Frank Binns <frank.binns@imgtec.com>
Tested-by: Mike Lothian <mike@fireburn.co.uk>
2018-04-17 10:26:25 -04:00
Mario Kleiner
4e92c51ce4 dri3: Fix dri3_buffers_from_pixmap request.
Sending pixmap depth and bpp was omitted, so the Mesa
X11 + EGL + DRI3 side of things always failed to
dri3_create_image_khr_pixmap_from_buffers(), which led
to failure of X11 + EGL compositing under DRI3 under,
e.g., KDE Plasma 5.

Fixes: 6e7c40f62d ("dri3: Add multi-planar/modifier buffer requests")
Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Cc: Daniel Stone <daniels@collabora.com>
Cc: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Reviewed-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Tested-by: Mike Lothian <mike@fireburn.co.uk>
2018-04-17 10:24:42 -04:00
Matt Turner
a98a95b798 modesetting: Move GBM code inside #ifdef GLAMOR_HAS_GBM
Fixes a compilation error without Glamor.

Bugzilla: https://bugs.gentoo.org/653288
Signed-off-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Olivier Fourdan <ofourdan@redhat.com>
2018-04-16 14:10:58 -04:00
Olivier Fourdan
c3ae963a7b xwayland: Fix build without glamor
Present support in Xwayland relies on glamor, make sure Xwayland can
be built without glamor by moving references to Present code inside
the conditional GLAMOR_HAS_GBM.

Reported-by: Matt Turner <mattst88@gmail.com>
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Roman Gilg <subdiff@gmail.com>
2018-04-16 12:06:51 -04:00
Adam Jackson
bf147f67b2 xwayland: Don't crash on WarpPointer(dest_w = None)
Turns out that's legal, and xts exercises it, and we crash:

    Thread 1 "Xwayland" received signal SIGSEGV, Segmentation fault.
    dixGetPrivate (key=0x813660 <xwl_window_private_key>, privates=0x20) at ../../include/privates.h:122
    122	    return (char *) (*privates) + key->offset;
    (gdb) bt
    #0  dixGetPrivate (key=0x813660 <xwl_window_private_key>, privates=0x20) at ../../include/privates.h:122
    #1  dixLookupPrivate (key=0x813660 <xwl_window_private_key>, privates=0x20) at ../../include/privates.h:166
    #2  xwl_window_of_top (window=0x0) at xwayland.c:128
    #3  xwl_cursor_warped_to (device=<optimized out>, screen=0x268b6e0, client=<optimized out>, window=0x0, sprite=0x300bb30,
        x=2400, y=1350) at xwayland.c:292
    #4  0x00000000005622ec in ProcWarpPointer (client=0x32755d0) at events.c:3618

In this case, x/y are the screen-space coordinates where the pointer
ends up, and we need to look up the (X) window there.

Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-13 10:49:56 -04:00
Emil Velikov
d7269b49c3 configure.ac: make use of wayland-scanner.pc
Replace the current (incorrect) assumption that wayland-scanner is
located in the wayland-client prefix. Make use of the wayland_scanner
variable in wayland-scanner.pc

It was introduced back in 2013 and we already require newer wayland bits

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
2018-04-12 17:17:43 -04:00
Adam Jackson
0031bbad84 sdksyms: Skip empty symbols
Apparently on NetBSD we can hit failures like this:

sdksyms.c:1773:15: error: expected expression before ',' token
     (void *) &,                                                  /* ../../dri3/dri3.h:110 */

I've been unable to reproduce that locally (even in a NetBSD vm), but
an obvious workaround might be to just notice empty symbol names and
ignore them rather than emit invalid C code.

Tested-by: Thomas Klausner <wiz@netbsd.org>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2018-04-12 17:15:15 -04:00
Adam Jackson
d61e516c84 xserver 1.20 RC4
Signed-off-by: Adam Jackson <ajax@redhat.com>
2018-04-10 15:45:02 -04:00
Emil Velikov
a42992a4cc dri3: rework format/modifier caching
Cut down the unnecessary malloc/memcpy/free by utilising the explicit
copy provided by the client.

But above all: do so, after ensuring we get valid data from the
implementation.

Fixes: cef12efc15 ("glamor: Implement GetSupportedModifiers")
Cc: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Cc: Daniel Stone <daniels@collabora.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
2018-04-10 15:42:40 -04:00
Emil Velikov
71a069fd7f glamor: zero num_formats from the start
The caller may ignore the return value (will be addressed with later
commit) so simply zero the count from the get-go. We're pretty much do
so, in all cases but one :-\

Fixes: cef12efc15 ("glamor: Implement GetSupportedModifiers")
Cc: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Cc: Daniel Stone <daniels@collabora.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
2018-04-10 15:42:40 -04:00
Emil Velikov
ac48724639 xwayland: zero num_formats from the start
The caller may ignore the return value (will be addressed with later
commit) so simply zero the count from the get-go. We're pretty much do
so, in all cases but one :-\

Fixes: cef12efc15 ("glamor: Implement GetSupportedModifiers")
Cc: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Cc: Daniel Stone <daniels@collabora.com>

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
2018-04-10 15:42:40 -04:00
Emil Velikov
e2f45002fc dri3: check for ::get_drawable_modifiers failure
Currently if the function fails, we'll fall into two false assumptions:
 - the the count is zero
 - that the storage pointer is safe for free()

I've just fixed the former (in glamor + xwayland) and have no
plans on adding yet another workaround for the latter.

Simply zero both variables. Regardless if the implementation is missing
the callback or it foobars with output variables (normally a bad idea).

Bonus points - this fixes a bug where we feed garbage to free() further
down ;-)

Fixes: cef12efc15 ("glamor: Implement GetSupportedModifiers")
Cc: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Cc: Daniel Stone <daniels@collabora.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
2018-04-10 15:42:40 -04:00
Emil Velikov
150e4b12ad glamor: zero num_modifiers from the start
The caller may ignore the return value (will be addressed with later
commit) so simply zero the count from the get-go. We're pretty much do
so, in all cases but one :-\

Fixes: cef12efc15 ("glamor: Implement GetSupportedModifiers")
Cc: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Cc: Daniel Stone <daniels@collabora.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
2018-04-10 15:42:40 -04:00
Emil Velikov
b36a14c0b0 xwayland: zero num_modifiers from the start
The caller may ignore the return value (will be addressed with later
commit) so simply zero the count from the get-go. We're pretty much do
so, in all cases but one :-\

Fixes: cef12efc15 ("glamor: Implement GetSupportedModifiers")
Cc: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Cc: Daniel Stone <daniels@collabora.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
2018-04-10 15:42:40 -04:00
Emil Velikov
a83ceec868 dri3: simplify dri3_open() implementation
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
2018-04-10 15:42:40 -04:00
Emil Velikov
9a159f37e0 dri3: annotate fds/strides/offsets arrays as const
It makes it perfectly clear that we should not be modifying them.
Should help highlight issues like the one fixed with previous commit.

Fixes: cef12efc15 ("glamor: Implement GetSupportedModifiers")
Cc: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Cc: Daniel Stone <daniels@collabora.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
2018-04-10 15:42:40 -04:00
Emil Velikov
877fa0c664 xwayland: don't close() fds we don't own
The glamor_pixmap_from_fds error path erroneously closes the fds.
We don't own them, plus the caller closes them after the function in
called.

Fixes: cef12efc15 ("glamor: Implement GetSupportedModifiers")
Cc: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Cc: Daniel Stone <daniels@collabora.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
2018-04-10 15:42:40 -04:00
Emil Velikov
66b632bb06 dri3: annotate the dri3_screen_info data as const
dri3_screen_info is the user provide dispatch. Something that we do
not and should not change.

When using the _ptr typecast + const the compiler barfs at us
(rightfully so), so use the _rec one.

[Silence a new const mismatch warning too - ajax]

Fixes: 5631382988 ("dri3: Add DRI3 extension")
Cc: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
2018-04-10 15:42:23 -04:00
Samuel Thibault
c67f2eac56 dix: always send focus event on grab change
Focus events are useless when 'from' and 'to' are the same.  But when
this is the result of a (Un)GrabKeyboard request, we should always send
them, including when the window manager had previously used XSetInputFocus
to specify the focus on a window which happens to be now taking a grab.

This is notably needed for window manager using XI to always get keyboard
events even during grabs, so they can determine exactly when grabbing is
active.

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-10 14:50:08 -04:00
Michal Srb
14be894b3f Xext: Fix memory leaks in hashtable.
Do not forget to delete key and value of every item and the hashtable itself.
2018-04-10 14:41:29 -04:00
Michal Srb
1326ee0bc5 glx: Do not call into Composite if it is disabled.
Otherwise X server crashes if GLX is enabled and Composite disabled. For
example the compIsAlternateVisual function will try to lookup CompScreenPtr
using the CompScreenPrivateKey, but that was never initialized if Composite is
disabled.

Fixes: f84e59a4f4. ("glx: Duplicate relevant fbconfigs for compositing visuals")
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104993
Signed-off-by: Michal Srb <msrb@suse.com>
2018-04-10 14:37:47 -04:00
Jon Turney
b9764b8489 hw/xwin/glx: Allocate fbconfigs correctly
4b0a3cba fixed leaking of GLX fbconfigs, so now xwin needs to allocate them
correctly (individually, rather than all at once), so they can be freed
successfully.

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
2018-04-09 17:07:05 -04:00
Kyle Brenneman
e0a137ce5d GLX: Fix a use after free error with the GLVND vendor handle.
The GLVND layer will destroy all of the vendor handles at the end of each
server generation, but the GLX module then tries to re-use the same (now-freed)
handle in xorgGlxServerInit at the start of the next generation.

In xorgGlxCloseExtension, explicitly destroy the vendor handle and set it to
NULL so that the next call to xorgGlxServerInit will recreate it.

Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-04-09 17:05:25 -04:00
Peter Hutterer
31c1489eeb xfree86: drop KDSKBMUTE handling
This was never merged upstream. It was a Fedora kernel patch but dropped from
Fedora in 2013 with kernel 3.12.

The reason for the KDSKBMUTE proposal has been fixed in systemd in Feb 2013,
systemd 198.
https://lists.freedesktop.org/archives/systemd-devel/2013-February/008795.html

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-04-06 13:21:00 -04:00
Adam Jackson
74aef564a7 xwayland: Silence a build warning if we can
[735/786] Generating 'hw/xwayland/Xwayland@exe/relative-pointer-unstable-v1-protocol.c'.
Using "code" is deprecated - use private-code or public-code.
See the help page for details.

Use private-code if wayland-scanner is new enough.

Signed-off-by: Adam Jackson <ajax@redhat.com>
2018-04-05 15:50:02 -04:00
Adam Jackson
6f0903ddc9 dix: Hush an almost certainly bogus warning
../dix/getevents.c: In function ‘transformAbsolute’:
../dix/getevents.c:1195:28: warning: ‘oy’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     struct pixman_f_vector p = {.v = {*x, *y, 1} };
                            ^
../dix/getevents.c🔢22: note: ‘oy’ was declared here
     double x, y, ox, oy;
                      ^~

This one is truly special. Even though both ox and oy are set and read
along the same paths, only oy is marked for this warning! Initializing
just oy = 0.0 fixes it entirely, but let's not make a weird thing
weirder.

Signed-off-by: Adam Jackson <ajax@redhat.com>
Acked-by: Keith Packard <keithp@keithp.com>
2018-04-05 14:18:52 -04:00
Adam Jackson
57e872301f mi: Hush an almost certainly bogus warning
In file included from ../mi/miexpose.c:83:
../mi/miexpose.c: In function ‘miHandleExposures’:
../include/regionstr.h:174:22: warning: ‘expBox.y2’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     (_pReg)->extents = *(_pBox);
     ~~~~~~~~~~~~~~~~~^~~~~~~~~~
../mi/miexpose.c:139:12: note: ‘expBox.y2’ was declared here
     BoxRec expBox;
            ^~~~~~

etc. It's initialized if (extents), and then only read if (extents),
but gcc doesn't seem to figure that out. Whatever, bzero it to be
explicit.

Signed-off-by: Adam Jackson <ajax@redhat.com>
Acked-by: Keith Packard <keithp@keithp.com>
2018-04-05 14:18:49 -04:00
Adam Jackson
83913de25d xkb: Silence some compiler warnings
Of the form:

../xkb/XKBGAlloc.c: In function ‘SrvXkbAddGeomKeyAlias’:
../xkb/XKBGAlloc.c:591:13: warning: ‘strncpy’ specified bound 4 equals destination size [-Wstringop-truncation]
             strncpy(alias->real, realStr, XkbKeyNameLength);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This is intentional; the code that reads from these fields never reads
more than 4 bytes anyway. Rephrase things in terms of memcpy so that's
clear. Obviously this is awful but in XKB awful is par.

Signed-off-by: Adam Jackson <ajax@redhat.com>
Acked-by: Keith Packard <keithp@keithp.com>
2018-04-05 14:18:47 -04:00
Adam Jackson
d13cd3862e dmx: Silence a string truncation warning.
../hw/dmx/config/dmxparse.c: In function ‘dmxConfigCreateOption’:
../hw/dmx/config/dmxparse.c:385:13: warning: ‘strncpy’ output truncated before terminating nul copying as many bytes from a string as its length [-Wstringop-truncation]
             strncpy(option->string + offset, p->string, len);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../hw/dmx/config/dmxparse.c:383:23: note: length computed here
             int len = strlen(p->string);
                       ^~~~~~~~~~~~~~~~~

The thing it's warning about is intentional, the surrounding code does
its own nul-termination. Make that obvious by using memcpy instead.

Signed-off-by: Adam Jackson <ajax@redhat.com>
Acked-by: Keith Packard <keithp@keithp.com>
2018-04-05 14:18:44 -04:00
Adam Jackson
176f26e96a dmx: Clean up some argument parsing code
This threw:

../hw/dmx/input/dmxarg.c: In function ‘dmxArgParse’:
../hw/dmx/input/dmxarg.c:128:5: warning: ‘strncpy’ specified bound depends on the length of the source argument [-Wstringop-overflow=]
     strncpy(tmp, string, len);
     ^~~~~~~~~~~~~~~~~~~~~~~~~
../hw/dmx/input/dmxarg.c:126:11: note: length computed here
     len = strlen(string) + 2;
           ^~~~~~~~~~~~~~

This code predates xstrtokenize, but that's no excuse.

Signed-off-by: Adam Jackson <ajax@redhat.com>
Acked-by: Keith Packard <keithp@keithp.com>
2018-04-05 14:18:41 -04:00
Adam Jackson
be99072a1a dmx: Fix a read-from-uninitialized warning
../hw/dmx/dmxpixmap.c: In function ‘dmxBitmapToRegion’:
../include/regionstr.h:174:22: warning: ‘Box.x1’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     (_pReg)->extents = *(_pBox);
     ~~~~~~~~~~~~~~~~~^~~~~~~~~~
../hw/dmx/dmxpixmap.c:208:12: note: ‘Box.x1’ was declared here
     BoxRec Box;
            ^~~

Signed-off-by: Adam Jackson <ajax@redhat.com>
Acked-by: Keith Packard <keithp@keithp.com>
2018-04-05 14:18:36 -04:00
Adam Jackson
c3b190f9da dmx: Fix some snprintf warnings.
snprintf doesn't terminate the string if it truncates, so things like
this are lurking crashers:

../hw/dmx/dmxprop.c: In function ‘dmxPropertyIdentifier.part.0’:
../hw/dmx/dmxprop.c:94:36: warning: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size 123 [-Wformat-truncation=]
     snprintf(buf, sizeof(buf), "%s:%s:%s", DMX_IDENT, hostname, display);
                                    ^~                 ~~~~~~~~
../hw/dmx/dmxprop.c:94:5: note: ‘snprintf’ output 7 or more bytes (assuming 262) into a destination of size 128
     snprintf(buf, sizeof(buf), "%s:%s:%s", DMX_IDENT, hostname, display);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../hw/dmx/dmxprop.c: In function ‘dmxPropertyWindow’:
../hw/dmx/dmxprop.c:372:36: warning: ‘%d’ directive output may be truncated writing between 1 and 11 bytes into a region of size between 0 and 127 [-Wformat-truncation=]
     snprintf(buf, sizeof(buf), "%s,%d", id, dmxScreen->index);
                                    ^~
../hw/dmx/dmxprop.c:372:5: note: ‘snprintf’ output between 3 and 140 bytes into a destination of size 128
     snprintf(buf, sizeof(buf), "%s,%d", id, dmxScreen->index);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

We could be more precise about termination, but meh.

Signed-off-by: Adam Jackson <ajax@redhat.com>
Acked-by: Keith Packard <keithp@keithp.com>
2018-04-05 14:18:31 -04:00
Adam Jackson
4c1453393f gtf: Warning fix
../hw/xfree86/utils/gtf/gtf.c: In function ‘print_fb_mode’:
../hw/xfree86/utils/gtf/gtf.c:241:50: warning: cast from function call of type ‘double’ to non-matching type ‘int’ [-Wbad-function-cast]
     printf("    timings %d %d %d %d %d %d %d\n", (int) rint(1000000.0 / m->pclk),       /* pixclock in picoseconds */

That's pretty nitpicky of you, gcc, but at least it's easy to fix.

Signed-off-by: Adam Jackson <ajax@redhat.com>
Acked-by: Keith Packard <keithp@keithp.com>
2018-04-05 14:18:16 -04:00
Daniel Stone
99f9b077c6 modesetting: Actually get framebuffer ID
We would fail to get the FB ID if it wasn't already imported, since we
were checking to see if the pointer was NULL (it never was) rather than
if the content of the pointer was 0.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reported-by: Olivier Fourdan <ofourdan@redhat.com>
Tested-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Olivier Fourdan <ofourdan@redhat.com>
2018-04-05 12:03:57 -04:00
Daniel Stone
8ff1cdb2bf dri3: Set stride and size for old clients
For old clients using the fd_from_pixmap entrypoint, make sure we set
stride and size correctly.

Noticed by inspection.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2018-04-05 10:51:38 -04:00
Daniel Stone
78574a66b5 modesetting: Don't reuse iterator in nested loop
drmmode_crtc_set_mode has a loop nested inside another loop, where both
of them were using 'i' as the loop iterator. Rename it to avoid an
infinite loop.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reported-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-and-Tested-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-04-05 10:48:10 -04:00
Mario Kleiner
ce2a4313dd modesetting: Fix page flipping harder under DRI 3.2.
Non-atomic kms drivers like radeon-kms (or nouveau-kms with
default setting of "atomic ioctl disabled") don't export
any formats, so num_formats == 0.

Some atomic drivers (nouveau-kms with boot param nouveau.atomic=1,
or intel-kms on, e.g., Linux 4.13) expose num_formats == 0, or
don't expose any modifiers, so num_modifiers == 0.

Let the drmmode_is_format_supported() check pass in these cases
to allow page flipping, as it works just fine.

Tested on NV-96 for nouveau, HD-5770 for radeon, Intel Ivybridge
with Linux 4.13 and drm-next to fix page flipping.

Fixes: 9d147305b4 ("modesetting: Check if buffer format is supported when flipping")
Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2018-04-04 14:10:23 -04:00
Louis-Francis Ratté-Boulianne
44e7098367 modesetting: Have consistent state when using atomic modesetting
We need to make sure that the atomic commit are consistent
or else the kernel will reject it. For example, when moving
a CRTC from one output to another one, the first output CRTC_ID
property needs to be reset. Also if the second output was using
another CRTC beforehands, it needs to be disabled to avoid an
inconsistent state.

Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Tested-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-04-04 14:01:51 -04:00
Louis-Francis Ratté-Boulianne
bc4d278132 modesetting: Use atomic modesetting to set DPMS mode
CRTCs and outputs needs to be enabled/disabled when the current
DPMS mode is changed. We also try to do it in an atomic commit
when possible.

Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Tested-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-04-04 14:01:48 -04:00