Commit Graph

337 Commits

Author SHA1 Message Date
Dave Airlie
90db5edf11 prime: add rotation support for offloaded outputs (v2)
One of the lacking features with output offloading was
that screen rotation didn't work at all.

This patch makes 0/90/180/270 rotation work with USB output
and GPU outputs.

When it allocates the shared pixmap it allocates it rotated,
and any updates to the shared pixmap are done using a composite
path that does the rotation. The slave GPU then doesn't need
to know about the rotation and just displays the pixmap.

v2:
rewrite the sync dirty helper to use the dst pixmap, and
avoid any strange hobbits and rotations.

This breaks ABI in two places.

Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2015-07-08 11:13:09 -07:00
Keith Packard
0409b6e6d6 Merge remote-tracking branch 'evelikov/master' 2015-05-11 16:50:43 -07:00
Keith Packard
d7091a21d9 Merge remote-tracking branch 'airlied/for-keithp' 2015-05-11 15:49:34 -07:00
Dave Airlie
a9ac02f694 xf86Crtc/monitors: create initial monitors for tiled outputs
This creates an automatic monitor for a tiled monitor at startup.

Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2015-04-27 13:40:41 +10:00
Alan Coopersmith
1c56ac63c0 Convert top level extensions to new *allocarray functions
v2: remove now useless parentheses

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
2015-04-21 16:57:08 -07:00
Keith Packard
5de1383070 randr: Use Monitor list for Xinerama
This replaces the CRTC-based Xinerama implementation with one which
uses Monitors instead, allowing clients to manipulate the Xinerama
configuration through the RandR Monitor list.

Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2015-03-31 12:32:04 +10:00
Keith Packard
7e1f86d42b randr: Add Monitor support (v1.1)
Store the user-defined monitors in the RandR screen private.

Generate a list of monitors from both the user-defined ones and from
any outputs not mentioned in one of the user-defined monitors. This list
covers both the outputs in the main screen as well as any slaves.

v1.1: airlied: fix up primary skipping bug,
fix wrong height initialiser
add get_active flag from updated protocol.

Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2015-03-31 12:32:04 +10:00
Emil Velikov
23702dd268 randr: coding style fixes
In most of xserver code-base we define new functions at column 0, with
their return type provided on the previous line. Two functions did not
follow this rule so update them, and get them wrapped up to 80 as an
added bonus.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2015-03-24 17:21:26 +00:00
Emil Velikov
739e8fac0e randr: wrap long line
Also make use of total_name_len variable for consistency.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2015-03-24 17:21:23 +00:00
Emil Velikov
363cd0e0b4 randr: use local variables where possible
This will allow us to make the code more readable, and the lines will
fit within 80 columns.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2015-03-24 17:21:19 +00:00
Emil Velikov
93ef0e580e randr: use randr: prefix in ErrorF()
To provide some information about the origin of the message.

Cc: Dave Airlie <airlied@redhat.com>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2015-03-24 17:21:15 +00:00
Emil Velikov
a08ee77398 randr: remove chatty error messages
All of these seem like left over from developments stage. Remove them as
they can cause excessive flood in the logs.

Cc: Dave Airlie <airlied@redhat.com>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2015-03-24 17:20:54 +00:00
Jon TURNEY
95e83ff87a Don't allow both RandR XINERAMA and pseudoramiX XINERAMA extensions to register
Prevent RRXinerama from activating if PseudoramiX is, so we don't get XINERAMA
listed twice in the list of extensions.  I think this is otherwise benign, as
the PseudoramiX XINERAMA gets registered first and thus handles all requests.

Perhaps AddExtension() ought to warn us if the extension name is already
registered?

This appears to be a long-standing bug seen in XQuartz, and now in XWin as well.

Future work: Perhaps since RRXinerama isn't actually doing anything useful but
faking it when we have one screen, it seems that the PseudoramiX code could be
also used in that case.

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
2015-03-24 14:46:39 +00:00
Dave Airlie
df1b401f57 randr: attempt to fix primary on slave output (v2)
If the user wants to set one of the slave devices as
the primary output, we shouldn't fail to do so,
we were returning BadMatch which was tripping up
gnome-settings-daemon and bad things ensues.

Fix all the places we use primaryOutput to work
out primaryCrtc and take it into a/c when slave
gpus are in use.

v2: review from Aaron, fix indent, unhide has_primary from
macro. I left the int vs Bool alone to be consistent with
code below, a future patch could fix both.

Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Aaron Plattner <aplattner@nvidia.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2015-01-26 16:23:10 -08:00
Carlos Sánchez de La Lama
437d2ec5f2 randr: swap num-preferred field on RRGetOutputInfo reply
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=88614
Signed-off-by: Carlos Sánchez de La Lama <csanchezdll@gmail.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2015-01-23 10:01:42 -08:00
Alan Coopersmith
3df2fcf124 randr: unvalidated lengths in RandR extension swapped procs [CVE-2014-8101]
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-12-08 18:09:48 -08:00
Peter Hutterer
732fd7e571 Drop trailing whitespaces
sed -i "s/[ ]\+$//g" **/*.(c|h)

happy reviewing...
git diff -w is an empty diff.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-11-12 10:25:00 +10:00
David Ung
b063a185ab randr: Fix logic in RRPointerToNearestCrtc
RRPointerToNearestCrtc is suppose to snap to the nearest Crtc,
but best_x and best_y is always positive, hence when calling
SetCursorPosition it will make the cursor even further away.
Correct delta x/y to allow negative values and also use
"width/height -1" in the calculation.  Also choose the closest
Crtc by setting the "best" value.

Signed-off-by: David Ung <davidu@nvidia.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2014-07-30 14:40:17 -07:00
Dave Airlie
01e18af17f rrcrtc: brackets are hard, lets go shopping.
Slaving two outputs on a secondary GPU to a primary GPU testing
picked this up, in that we'd try to resize to the totally the
wrong thing, then as usual segfault in the rotation code.

Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Aaron Plattner <aplattner@nvidia.com>
2014-05-12 14:55:04 -07:00
Robert Morell
6d892ad112 randr: Implement RandR 1.4 request swapping
The protocol handlers all have support for swapping variable data and
replies, but the top-level dispatch plumbing was missing.

Signed-off-by: Robert Morell <rmorell@nvidia.com>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2014-04-21 11:44:38 -07:00
Robert Morell
ed4ee7c34a randr: Fix size checks for SetProvider* reqs
Both xRRSetProviderOutputSourceReq and xRRSetProviderOffloadSinkReq are
fixed-size requests, so the length on the wire should match exactly.

Signed-off-by: Robert Morell <rmorell@nvidia.com>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2014-04-21 11:44:31 -07:00
Robert Morell
668321e7e5 randr: Fix crash for NULL swap dispatch procs
The previous code was checking the wrong table for function pointers.

Signed-off-by: Robert Morell <rmorell@nvidia.com>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2014-04-21 11:44:02 -07:00
David Sodman
caf1dec2a7 V2: Add check for link from output to crtc before optimizing out a CrtcSet call
The function RRCrtcSet call checks to see if the config being set is
already configured, but, doesn't check that the selected outputs are
connected to the crtc before skipping.  This means that the following
sequence will omit the final CrtcSet call to the driver:

    CRTC c1 connect to output o
    CRTC c2 connect to output o
    CRTC c1 connect to output o

This change adds the check to ensure that each of the calls are made to
the driver.

Signed-off-by: David Sodman <dsodman@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
Signed-off-by: Keith Packard <keithp@keithp.com>
2014-02-24 16:33:35 -08:00
Keith Packard
9888770654 randr: Eliminate -Wshadow warnings
Don't use rrScrPriv for nested screen private fetching.

Eliminate a duplicate fetch of the randr screen private in rrCheckPixmapBounding.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
2014-01-22 19:56:32 -08:00
Keith Packard
60014a4a98 Replace 'pointer' type with 'void *'
This lets us stop using the 'pointer' typedef in Xdefs.h as 'pointer'
is used throughout the X server for other things, and having duplicate
names generates compiler warnings.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
2014-01-12 10:24:11 -08:00
Michal Srb
85ae44f07f randr: deliver Output and Crtc events of attached output providers.
Consider all attached output providers when looking for changed outputs and
crtcs.

Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Michal Srb <msrb@suse.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2013-10-30 08:09:31 -07:00
Michal Srb
a9ca93dcf9 randr: send RRResourceChangeNotify event
Send RRResourceChangeNotify event when provider, output or crtc was created or
destroyed. I.e. when the list of resources returned by RRGetScreenResources and
RRGetProviders changes.

Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Michal Srb <msrb@suse.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2013-10-30 08:09:27 -07:00
Michal Srb
4b39ea8a91 randr: send RRProviderChangeNotify event
Send RRProviderChangeNotify event when a provider becomes output source or
offload sink.

Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Michal Srb <msrb@suse.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2013-10-30 08:09:25 -07:00
Adam Jackson
1c8beedfe4 randr: Fix a copypasta bug in CRTC confinement
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2013-09-10 13:26:25 -04:00
Dave Airlie
b724324252 randr: only respected changed on the protocol screen
We don't want to know about changes on the non-protocol screen,
we will fix up setchanged to make sure non-protocol screens update
the protocol screens when they have a change.

Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2013-04-30 10:08:43 +10:00
Dave Airlie
b3f70f38ed randr: make SetChanged modify the main protocol screen not the gpu screen
When SetChanged is called we now modify the main protocol screen,
not the the gpu screen. Since changed stuff should work at the protocol level.

Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2013-04-30 10:08:43 +10:00
Dave Airlie
f9c8248b83 randr: don't directly set changed bits in randr screen
Introduce a wrapper interface so we can fix things up for multi-gpu
situations later.

This just introduces the API for now.

Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2013-04-30 10:08:43 +10:00
Keith Packard
116f020102 Merge remote-tracking branch 'whot/next' 2013-03-18 11:18:58 -07:00
Dave Airlie
8f4640bdb9 randr: cleanup provider properly
So in the cold plug server shutdown case, we reap the resources
before we call CloseScreen handlers, so the config->randr_provider
is a dangling pointer when the xf86CrtcCloseScreen handler is called,

however in the hot screen unplug case, we can't rely on automatically
reaped resources, so we need to clean up the provider in the xf86CrtcCloseScreen
case.

This patch provides a cleanup callback from the randr provider removal
into the DDX so it can cleanup properly, this then gets called by the automatic
code for cold plug, or if hot unplug it gets called explicitly.

Fixes a number of random server crashes on shutdown
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=58174
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=891140

Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2013-03-01 18:14:28 +10:00
Peter Hutterer
592d35aef0 randr: fix "set but unused" warnings
rrcrtc.c: In function 'RRCrtcDetachScanoutPixmap':
rrcrtc.c:366:9: warning: variable 'ret' set but not used
[-Wunused-but-set-variable]
rrcrtc.c: In function 'rrCheckPixmapBounding':
rrcrtc.c:505:13: warning: variable 'ret' set but not used
[-Wunused-but-set-variable]
rrcrtc.c:445:9: warning: unused variable 'i' [-Wunused-variable]

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Mark Kettenis <kettenis@openbsd.org>
2013-02-15 11:58:14 +10:00
Aaron Plattner
7115f6c709 randr: unref the provider shared pixmap the appropriate number of times
When an RandR shared pixmap is created in rrCreateSharedPixmap, it has a refcnt
of 1.  Then, PixmapShareToSlave bumps the refcnt to 2.  However, there's no
corresponding PixmapUnshareFromSlave where the refcnt can be decreased again,
and there's no convenient common place where the refcnt can be decremented when
the slave pixmap is destroyed.

Fix this by just unreffing the pixmap twice in RRCrtcDetachScanoutPixmap.

Signed-off-by: Aaron Plattner <aplattner@nvidia.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2013-02-11 22:28:24 -08:00
Dave Airlie
c1602d1c17 randr: bump advertised RandR version to 1.4
Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Aaron Plattner <aplattner@nvidia.com>
Tested-by: Aaron Plattner <aplattner@nvidia.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2013-02-08 09:09:54 -08:00
Dave Airlie
e9ea96d6a8 randr: call RRProviderInit in the proper place.
No idea where this got lost across development cycles, but its
definitely missing.

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

Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2012-11-30 07:25:54 -08:00
Yaakov Selkowitz
8e86123998 randr: export more provider property symbols
These were added as part of commit 66d92afeae
but never declared or exported.  Fixes warnings:

rrproviderproperty.c:255:1: warning: no previous prototype for 'RRPostProviderPendingProperties'
rrproviderproperty.c:327:1: warning: no previous prototype for 'RRConfigureProviderProperty'

Signed-off-by: Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-11-05 13:25:03 -06:00
Keith Packard
2100e72388 Merge remote-tracking branch 'alanc/master' 2012-08-06 16:40:54 -07:00
Dave Airlie
454d0e3a1b randr: fix xinerama output for output slaves
This fixes the xinerama geometry when output slaves are enabled.

Tested with xdpyinfo -ext XINERAMA before after slave added.

Signed-off-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2012-08-06 15:42:39 -07:00
Alan Coopersmith
c7b7abfaa0 RRModeCreate: plug memory leak of newModes if AddResource fails
Reported by parfait 1.0:

Error: Memory leak (CWE 401)
   Memory leak of pointer 'newModes' allocated with realloc(((char*)modes), ((num_modes + 1) * 8))
        at line 93 of randr/rrmode.c in function 'RRModeCreate'.
          pointer allocated at line 82 with realloc(((char*)modes), ((num_modes + 1) * 8)).
Error: Memory leak (CWE 401)
   Memory leak of pointer 'newModes' allocated with malloc(8)
        at line 93 of randr/rrmode.c in function 'RRModeCreate'.
          pointer allocated at line 84 with malloc(8).

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
2012-08-06 15:22:53 -07:00
Alan Coopersmith
1eb7be8633 rrproperty.c: free newly allocated prop in more error paths
Reported by parfait 1.0:

Error: Memory leak (CWE 401)
   Memory leak of pointer 'prop' allocated with RRCreateOutputProperty(property)
        at line 220 of randr/rrproperty.c in function 'RRChangeOutputProperty'.
          'prop' allocated at line 154 with RRCreateOutputProperty(property).
          prop leaks when pending != 0 at line 160.
Error: Memory leak (CWE 401)
   Memory leak of pointer 'prop' allocated with RRCreateOutputProperty(property)
        at line 346 of randr/rrproperty.c in function 'RRConfigureOutputProperty'.
          'prop' allocated at line 334 with RRCreateOutputProperty(property).
        at line 350 of randr/rrproperty.c in function 'RRConfigureOutputProperty'.
          'prop' allocated at line 334 with RRCreateOutputProperty(property).

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
2012-08-06 15:22:53 -07:00
Alan Coopersmith
42e655de4d rrproviderproperty.c: free newly allocated prop in more error paths
Reported by parfait 1.0:

Error: Memory leak (CWE 401)
   Memory leak of pointer 'prop' allocated with RRCreateProviderProperty(property)
        at line 221 of randr/rrproviderproperty.c in function 'RRChangeProviderProperty'.
          'prop' allocated at line 155 with RRCreateProviderProperty(property).
          prop leaks when pending != 0 at line 161.

Error: Memory leak (CWE 401)
   Memory leak of pointer 'prop' allocated with RRCreateProviderProperty(property)
        at line 345 of randr/rrproviderproperty.c in function 'RRConfigureProviderProperty'.
          'prop' allocated at line 333 with RRCreateProviderProperty(property).
        at line 349 of randr/rrproviderproperty.c in function 'RRConfigureProviderProperty'.
          'prop' allocated at line 333 with RRCreateProviderProperty(property).

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
2012-08-06 15:22:53 -07:00
Alan Coopersmith
a6c5b8d3ee Use C99 designated initializers in RandR 1.4 extension Events
RandR 1.4 was going through review in parallel with main batch of
C99 initialization changes - sync up now that both have landed.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
2012-07-16 21:25:07 -07:00
Alan Coopersmith
ada04ef0ca Use C99 designated initializers in RandR 1.4 extension Replies
RandR 1.4 was going through review in parallel with main batch of
C99 initialization changes - sync up now that both have landed.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
2012-07-16 21:25:07 -07:00
Daniel Stone
a1d41e311c Move extension initialisation prototypes into extinit.h
Create extinit.h (and xf86Extensions.h, for Xorg-specific extensions) to
hold all our extension initialisation prototypes, rather than
duplicating them everywhere.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Keith Packard <keithp@keithp.com>
2012-07-09 23:06:41 -07:00
Alan Coopersmith
ad4092cf7d Replace padlength tables with inline functions from misc.h
Adds new function padding_for_int32() and uses existing pad_to_int32()
depending on required results.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Tested-by: Daniel Stone <daniel@fooishbar.org>
2012-07-09 22:52:30 -07:00
Alan Coopersmith
9805cedf7b Use C99 designated initializers in extension Events
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Tested-by: Daniel Stone <daniel@fooishbar.org>
2012-07-09 22:52:30 -07:00
Alan Coopersmith
bd6f948c41 Use C99 designated initializers in randr Replies
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Tested-by: Daniel Stone <daniel@fooishbar.org>
2012-07-09 19:58:30 -07:00