Commit Graph

145 Commits

Author SHA1 Message Date
Alex Goins
a90f33721e randr: rrCheckPixmapBounding should only increase screen size
The purpose of rrCheckPixmapBounding() is to make sure that the fb is large
enough to accommodate the region scanned out by a GPU screen. Currently, however,
it will actually shrink the fb if it's larger than it needs to be.

This is a problem when combining PRIME output slaving with arbitrary transforms
with xrandr.

Although arbitrary transforms are not supposed to constrain the size of the fb
(https://lists.freedesktop.org/archives/xorg-devel/2018-January/055563.html),
xrandr will use RRSetScreenSize to resize the desktop to accommodate scaling
transforms, e.g. scaling a 1920x1080 display to 3840x2160 will result in a
desktop size of 3840x2160.

In the case of PRIME, rrCheckPixmapBounding() will be called after
RRSetScreenSize() and it will resize the fb back down to what it would be
without the scaling transform, e.g. 1920x1080. This represents divergence in
behavior between PRIME and non-PRIME outputs.

I had originally made rrCheckPixmapBounding() account for arbitrary transforms,
but realized that the fb being large enough to accommodate arbitrary transforms
is not a hard requirement enforced in the server. Instead, this change simply
makes it so that rrCheckPixmapBounding() will only resize the fb to be larger
than it already is, preventing it from stepping on prior requests to increase
the size of the fb.

Signed-off-by: Alex Goins <agoins@nvidia.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2018-08-24 09:55:48 +02:00
Keith Packard
1ef7aed3e2 During reset/shutdown, clean up leases in DIX instead of each driver
Instead of having every video driver loop over any pending leases to
free them during CloseScreen, do this up in the DIX layer by
terminating leases when a leased CRTC or Output is destroyed and
(just to make sure), also terminating leases in RRCloseScreen. The
latter should "never" get invoked as any lease should be associated
with a resource which was destroyed.

This is required as by the time the driver's CloseScreen function is
invoked, we've already freed all of the DIX randr structures and no
longer have any way to reference the leases

Signed-off-by: Keith Packard <keithp@keithp.com>
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=106960
Cc: Thomas Hellstrom <thellstrom@vmware.com>
2018-08-02 10:15:26 -04:00
Lyude Paul
dc90b1c3c3 randr: Scream when creating a shared pixmap fails
This seems like a problem worth screaming about.

Signed-off-by: Lyude Paul <lyude@redhat.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
2018-06-27 15:08:55 -04:00
Chris Wilson
d7297b0044 randr: Account for panning and transforms when constraining the cursor
commit 56c90e29f0 [1.10.99.901]
Author: Adam Jackson <ajax@redhat.com>
Date:   Mon Nov 15 14:29:14 2010 -0500

    randr: Add RRConstrainCursorHarder

introduced a regression as it ignored the effect of panning and
transforms upon the crtc bounds. The result was that the cursor would be
constrained to the visible area even though the panning arena was much
bigger, or the cursor was constrained to a region that did not even
match the visible area when the output was transformed or reflected.

This supercedes the hack introduced by
commit 1bf81af4a6 [1.12.99.904]
Author: Rui Matos <tiagomatos@gmail.com>
Date:   Mon Jul 30 14:32:12 2012 -0400

    xf86RandR12: Don't call ConstrainCursorHarder() if panning is enabled
which disabled the cursor constraints if a panning mode was active, but
did not fix the regression with arbitrary output transforms.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=39949
Reviewed-by: Adam Jackson <ajax@redhat.com>
Cc: Rui Matos <tiagomatos@gmail.com>
2018-05-02 12:20:01 -04:00
Keith Packard
e4e3447603 Add RandR leases with modesetting driver support [v6]
This adds support for RandR CRTC/Output leases through the modesetting
driver, creating a lease using new kernel infrastructure and returning
that to a client through an fd which will have access to only those
resources.

v2:	Restore CRTC mode when leases terminate

	When a lease terminates for a crtc we have saved data for, go
	ahead and restore the saved mode.

v3:	Report RR_Rotate_0 rotations for leased crtcs.

	Ignore leased CRTCs when selecting screen size.

	Stop leasing encoders, the kernel doesn't do that anymore.

	Turn off crtc->enabled while leased so that modesetting
	ignores them.

	Check lease status before calling any driver mode functions

	When starting a lease, mark leased CRTCs as disabled and hide
	their cursors. Also, check to see if there are other
	non-leased CRTCs which are driving leased Outputs and mark
	them as disabled as well. Sometimes an application will lease
	an idle crtc instead of the one already associated with the
	leased output.

	When terminating a lease, reset any CRTCs which are driving
	outputs that are no longer leased so that they start working
	again.

	This required splitting the DIX level lease termination code
	into two pieces, one to remove the lease from the system
	(RRLeaseTerminated) and a new function that frees the lease
	data structure (RRLeaseFree).

v4:	Report RR_Rotate_0 rotation for leased crtcs.

v5: Terminate all leases on server reset.

	Leases hang around after the associated client exits so that
	the client doesn't need to occupy an X server client slot and
	consume a file descriptor once it has gotten the output
	resources necessary.

	Any leases still hanging around when the X server resets or
	shuts down need to be cleaned up by calling the kernel to
	terminate the lease and freeing any DIX structures.

	Note that we cannot simply use the existing
	drmmode_terminate_lease function on each lease as that wants
	to also reset the video mode, and during server shut down that

   modesetting: Validate leases on VT enter

	The kernel doesn't allow any master ioctls to run when another
	VT is active, including simple things like listing the active
	leases. To deal with that, we check the list of leases
	whenever the X server VT is activated.

   xfree86: hide disabled cursors when resetting after lease termination

	The lessee may well have played with cursors and left one
	active on our screen. Just tell the kernel to turn it off.

v6:	Add meson build infrastructure

[Also bumped libdrm requirement - ajax]

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-02-27 12:39:50 -05:00
Giuseppe Bilotta
fc7fb5bbe1 randr: free crtc->outputs on destroy
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
2017-11-20 16:13:28 -05:00
Giuseppe Bilotta
16381d186e randr: always realloc crtcs and outputs
When the last crtc (resp. output) is destroyed, the rrScrPriv crtcs
(resp. outputs) fields do not get cleared, which can lead to a situation
where the private's numCrtcs (resp. numOutputs) field is zero, but the
associated memory is still allocated. Just checking if numCrtcs (resp.
numOutputs) is zero is thus not a good criteria to determine whetehr to
use a realloc or a malloc.

Since crtcs (resp. outputs) are NULL-initialized anyway, relying on
numCrtcs (resp. numOutputs) is actually unnecessary, because
reallocation of a NULL ptr is equivalent to a malloc anyway.

Therefore, just use realloc() unconditionally, and ensure that the
fields are properly initialized.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
2017-11-20 16:13:20 -05:00
Michel Dänzer
8e3b26ceaa Make PixmapDirtyUpdateRec::src a DrawablePtr
This allows making the master screen's pixmap_dirty_list entries
explicitly reflect that we're now tracking the root window instead of
the screen pixmap, in order to allow Present page flipping on master
outputs while there are active slave outputs.

Define HAS_DIRTYTRACKING_DRAWABLE_SRC for drivers to check, but leave
HAS_DIRTYTRACKING_ROTATION defined as well to make things slightly
easier for drivers.

Reviewed-by: Adam Jackson <ajax@redhat.com>
2017-08-15 17:01:39 +09:00
Aaron Plattner
091af80be4 randr: Use RRTransformEqual in RRCrtcPendingTransform
Currently, RRCrtcPendingTransform returns false unless the
transformation matrix itself is changing. This makes RRCrtcSet skip
doing anything if the only thing that is changing is the transform
filter.

There's already a function for comparing RRTransformPtrs, so use that
instead.

Tested by running

  xrandr --output DP-1 --mode 1920x1080 --rate 144 --scale 0.5x0.5 --filter nearest

follwed by

  xrandr --output DP-1 --mode 1920x1080 --rate 144 --scale 0.5x0.5 --filter bilinear

Signed-off-by: Aaron Plattner <aplattner@nvidia.com>
Reviewed-and-Tested-by: Michel Dänzer <michel.daenzer@amd.com>
2017-06-19 17:49:41 +09:00
Hans de Goede
a46afee84d randr: rrCheckPixmapBounding: do not shrink the screen_pixmap
The purpose of rrCheckPixmapBounding is to make sure that the
screen_pixmap is *large* enough for the slave-output which crtc is
being configured.

However until now rrCheckPixmapBounding would also shrink the
screen_pixmap in certain scenarios leading to various problems.

For example: Take a laptop with its internalscreen on a slave-output and
currently disabled and an external monitor at 1920x1080+0+0.
Now lets say that we want to drive the external monitor at its native
resolution of 2560x1440 and have the internal screen mirror the top left
part of the external monitor, so we run:

  $ xrandr --output eDP --mode 1920x1080 --pos 0x0 --output HDMI \
  --mode 2560x1440 --pos 0x0

Here xrandr utility first calls RRSetScreenSize to 2560x1440, then it
calls RRSetCrtc 1920x1080+0+0 on the eDP, since this is a slave output,
rrCheckPixmapBounding gets called and resizes the screen_pixmap to
1920x1080, undoing the RRSetScreenSize. Then RRSetCrtc 2560x1440+0+0
gets called on the HDMI, depending on crtc->transforms this will
either result in a BadValue error from ProcRRSetCrtcConfig; or
it will succeed, but the monitor ends up running at 2560x1440
while showing a 1920x1080 screen_pixmap + black borders on the right
and bottom. Neither of which is what we want.

This commit removes the troublesome shrinking behavior, fixing this.

Note:

1) One could argue that this will leave us with a too large screen_pixmap
in some cases, but rrCheckPixmapBounding only gets called for slave
outputs, so xrandr clients already must manually shrink the screen_pixmap
after disabling crtcs in normal setups.

2) An alternative approach would be to also call rrCheckPixmapBounding
on RRSetCrtc on normal (non-slave) outputs, but that would result in
2 unnecessary resizes of the screen_pixmap in the above example, which
seems undesirable.

Cc: Nikhil Mahale <nmahale@nvidia.com>
Cc: Dave Airlie <airlied@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
2016-12-05 11:21:49 +01:00
Hans de Goede
3b624aa9a9 randr: rrCheckPixmapBounding: Do not substract crtc non 0 x,y from screen size
The purpose of rrCheckPixmapBounding is to make sure that the
screen_pixmap is large enough for the slave-output which crtc is
being configured.

This should include crtc->x and crtc->y, otherwise the crtc might
still end up scanning out an area outside of the screen-pixmap.

For example: Take a laptop with an external monitor on a slave-output at
1920x1080+0+0 and its internal-screen at 3840x2160+1920+0 and in
gnome-settings-daemon move the external monitor to be on the ri ght of
the internal screen rather then on the left. First g-s-d will do a
RRSetScreenSize to 5760*2160 (which is a nop), then it calls RRSetCrtc
to move the slave output to 1920x1080+3840+0, since this is a slave
output, rrCheckPixmapBounding gets called, since the 2 crtcs now overlap
the code before this commit would shrinks the screen_pixmap to 3180*2160.
Then g-s-d calls RRSetCrtc to move the internal screen to 3180*2160+0+0.

And we end up with the slave-output configured to scan-out an area
which completely falls outside of the screen-pixmap (and end up with
a black display on the external monitor).

This commit fixes this by not substracting the x1 and y1 coordinates
of the union-ed region when determining the new screen_pixmap size.

Cc: Nikhil Mahale <nmahale@nvidia.com>
Cc: Dave Airlie <airlied@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
2016-12-05 11:21:48 +01:00
Hans de Goede
35c4e96ed1 randr: Fix crtc_bounds when using rotation combined with reflection
Before this commit crtc_bounds() did not take reflection into account,
when using reflection with 0 / 180 degree rotation this was not an
issue because of the default in the switch-case doing the right thing.

But when using 90 / 270 degree rotation we would also end up in the
default which is wrong in this case. This would lead to the cursor
being constrained to a height x height area of the monitor.

This commit masks out the reflection bits for the switch-case,
making crtc_bounds return the correct bounds and fixing the
problematic cursor constraining.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2016-09-13 10:27:30 +02:00
Hans de Goede
2eefb53f58 randr: Add RRHasScanoutPixmap helper function
This is a preparation patch for adding prime hw-cursor support.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2016-09-13 10:26:47 +02:00
agoins
df8e86931e randr: Add ability to turn PRIME sync off
Adds an output parameter to disable PRIME synchronization.

Output parameter is created when the user calls 'xrandr
--setprovideroutputsource <sink> <source>' to prevent polluting output
parameters of non-PRIME configurations.

Defaults to on, so if the user wants PRIME synchronization they don't need
to do anything.

If the user wishes to disable PRIME synchronization when they first set up
PRIME, they can run 'xrandr --output <output> --set "PRIME Synchronization"
0' after running 'xrandr --setprovideroutputsource <sink> <source>', but
before 'xrandr --auto'.

If the user wishes to enable or disable PRIME synchronization after PRIME has
already been set up, they can run 'xrandr --output <output> --set "PRIME
Synchronization" <0 or 1>' at any time, xrandr will trigger a modeset, which
will tear down and setup PRIME in the configuration they requested on CRTCs
associated with that output.

randrstr.h:
    Add central definition of the output property name.

rrcrtc.c:
    Add function rrGetPixmapSharingSyncProp() to query the status of the
    output property.

    Add function rrSetPixmapSharingSyncProp() to set the output property.

    Add 'sync' parameter to rrSetupPixmapSharing(), which when false will
    use single buffering even if the required ABI functions are supported.
    Changes rrSetupPixmapSharing() to only report an error if falling back
    to single buffering when the user requested synchronization.

    Change RRCrtcSet() to use rrPixmapSharingSyncProp() to query the status
    of the output property and feed it into rrSetupPixmapSharing() using
    the 'sync' parameter.

rrprovider.c:
    Add RR(Init/Fini)PrimeSyncProps(), functions to create and destroy the
    PRIME synchronization output property.

    Add a call to RRInitPrimeSyncProps() in
    ProcRRSetProviderOutputSource(), such that the output property is
    created when the user requests PRIME.

    Add a call to RRFiniPrimeSyncProps() in RRProviderDestroy().

v1: Initial commit
v2: Unchanged
v3: Add /* TODO */ for handling different sources with different outputs
    Make rrSetupPixmapSharing() set the output property to 0 if it has to fall
    back, to avoid user confusion.
    Make rr(Get)PixmapSharingSyncProp() check the current value if there isn't a
    pending value
v4: Unchanged
v5: Unchanged
v6: Rebase onto ToT
v7: Unchanged

Signed-off-by: Alex Goins <agoins@nvidia.com>
2016-07-05 14:30:27 -04:00
Alex Goins
1bdbc7e764 randr/xf86: Add PRIME Synchronization / Double Buffer
Changes PRIME to use double buffering and synchronization if all required
driver functions are available.

rrcrtc.c:
    Changes rrSetupPixmapSharing() to use double buffering and
    synchronization in the case that all required driver functions are
    available. Otherwise, falls back to unsynchronized single buffer.

    Changes RRCrtcDetachScanoutPixmap() to properly clean up in the case of
    double buffering.

    Moves StopPixmapTracking() from rrDestroySharedPixmap() to
    RRCrtcDetachScanoutPixmap().

    Changes RRReplaceScanoutPixmap() to fail if we are using double buffering,
    as it would need a second ppix parameter to function with double buffering,
    and AFAICT no driver I've implemented double buffered source support in uses
    RRReplaceScanoutPixmap().

randrstr.h:
    Adds scanout_pixmap_back to struct _rrCrtc to facilitate PRIME
    double buffering.

xf86Crtc.h:
    Adds current_scanout_back to _xf86Crtc to facilitate detection
    of changes to it in xf86RandR12CrtcSet().

xf86RandR12.c:
    Changes xf86RandR12CrtcSet() to detect changes in
    scanout_pixmap_back.

    Adds scanout_pixmap_back to struct _rrCrtc to facilitate PRIME double
    buffering.

v1: Initial commit
v2: Rename PresentTrackedFlippingPixmap to PresentSharedPixmap
v3: Refactor to accomodate moving (rr)StartFlippingPixmapTracking and
    (rr)(Enable/Disable)SharedPixmapFlipping to rrScrPrivRec from ScreenRec
    Add fallback if flipping funcs fail
v4: Detach scanout pixmap when destroying scanout_pixmap_back, to avoid
    dangling pointers in some drivers
v5: Disable RRReplaceScanoutPixmap for double-buffered PRIME, it would need an
    ABI change with support for 2 pixmaps if it were to be supported, but AFAICT
    no driver that actually supports double-buffered PRIME uses it.
    Refactor to use rrEnableSharedPixmapFlipping() as a substitute for
    rrCrtcSetScanoutPixmap() in the flipping case.
    Remove extraneous pSlaveScrPriv from DetachScanoutPixmap()
    Remove extraneous protopix and pScrPriv from rrSetupPixmapSharing()
v6: Rebase onto ToT
v7: Unchanged

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

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

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

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

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

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

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

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
2016-06-17 11:35:58 +02:00
Dave Airlie
a6b6e8ba02 prime: clean up slave bo properly. (v3)
This is an ABI break, in that we now pass NULL to a function that hasn't
accepted it before.

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

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

Signed-off-by: Dave Airlie <airlied@redhat.com>
Tested-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Alex Goins <agoins at nvidia.com>
2016-06-08 12:51:51 -04:00
Adam Jackson
e98b36bc69 randr: Silence unused variable warning
Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2015-12-09 09:33:56 -05:00
Michel Dänzer
5bccde749d randr: Stop dirty tracking for shared pixmap being destroyed
Otherwise, we leave a dangling reference to the destroyed pixmap in the
master screen's pixmap_dirty_list.

Fixes regression from commit cf5d6414 ("randr: Factor out shared pixmap
destruction").

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
2015-12-02 10:56:56 -05:00
agoins
c7f4aef8f4 randr: Cleanup rrSetupPixmapSharing()
protopix is completely redundant with mscreenpix. Get rid of it.

We don't need rrScrPriv, so remove it.

[ajax: also squash an unused variable in RRCrtcDetachScanoutPixmap,
though it'll come back when the rest of this series lands]

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Alex Goins <agoins@nvidia.com>
2015-12-01 13:44:31 -05:00
agoins
7006b4e7ff randr: Factor out shared pixmap creation
The old version of rrCreateSharedPixmap(), in addition to actually creating
a shared pixmap with scanout, also set up pixmap tracking on the source
driver.

I will be needing to create multiple shared pixmaps for PRIME double
buffering, so factor the part that does shared pixmap creation into its own
function, the new rrCreateSharedPixmap(). Rename the old
rrCreateSharedPixmap() to rrSetupPixmapSharing(), a function that
replicates the old functionality of rrCreateSharedPixmap() using the new
rrCreateSharedPixmap().

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Alex Goins <agoins@nvidia.com>
2015-12-01 13:15:01 -05:00
agoins
cf5d6414e0 randr: Factor out shared pixmap destruction
Shared pixmap destruction is done by unrefing the master pixmap twice: once
for the original reference, and once for the reference implicitly added by
PixmapShareToSlave. Then, unrefing the slave pixmap once.

When I add PRIME double buffering and synchronization, I will need to do
this in multiple places. To avoid duplication of code and comments
explaining it everywhere, factor it out into its own function and use that
in place of where it was before.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Alex Goins <agoins@nvidia.com>
2015-12-01 13:14:51 -05:00
Chris Wilson
245040f0d0 randr/prime: Don't stop on the first pipe when disabling ReplaceScanoutPixmap
As we define sizeFits based on whether a CRTC is active, and skip trying
to redirect the scanout on a disable pipe, we then attempt to undo it
later and fail because crtc->scanout_pixmap != DRI2_Pixmap and
!sizeFits. Paper over this failure by skipping unredirected CRTC when
disabling.

v2: Unwind upon failure

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=84653
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Dave Airlie <airlied@redhat.com>
Reported-by: Christoph Haag <haagch@frickel.club>
Tested-by: Christoph Haag <haagch@frickel.club>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2015-09-21 14:42:51 -04:00
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
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
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
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
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
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
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
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
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
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
Alan Coopersmith
cdf5bcd420 Use calloc to zero fill buffers being allocated for replies & events
Ensures padding bytes are zero-filled

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:29 -07:00
Alan Coopersmith
5b86c072d1 Use temporary variables instead of parts of reply structures
When passing variable pointers to functions or otherwise doing long
sequences to compute values for replies, create & use some new
temporary variables, to allow for simpler initialization of reply
structures in the following patches.

Move memsets & other initializations to group with the rest of the
filling in of the reply structure, now that they're not needed so
early in the code path.

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:14:50 -07:00
Alan Coopersmith
789d64e19a Remove unneccesary casts from WriteToClient calls
Casting return to (void) was used to tell lint that you intended
to ignore the return value, so it didn't warn you about it.

Casting the third argument to (char *) was used as the most generic
pointer type in the days before compilers supported C89 (void *)
(except for a couple places it's used for byte-sized pointer math).

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:12:56 -07:00
Dave Airlie
c41922940a dix/randr: add a hook into screen to replace scanout pixmap
For DRI2 in some offload cases we need to set a new pixmap on the crtc,
this hook allows dri2 to call into randr to do the necessary work to set
a pixmap as the scanout pixmap for the crtc the drawable is currently on.

This is really only to be used for unredirected full screen apps in composited
environments.

Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2012-07-07 10:39:09 +01:00
Dave Airlie
c5cc2a8243 randr: check the screen size bounds against the master
The master contains the complete screen size bounds, so check
the width/height against it.

Reviewed-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2012-07-07 10:37:11 +01:00
Dave Airlie
4bf0192d81 randr: fixup constrain to work with slave screens.
Current code constrains the cursor to the crtcs on the master
device, for slave outputs to work we have to include their crtcs
in the constrain calculations.

Reviewed-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2012-07-07 10:37:11 +01:00
Dave Airlie
f2da2c1204 randr: add initial scanout pixmap support (v3)
When randr notices a crtc configuration request for a slave device,
it checks if the slave allocated pixmap exists and is suitable,
if not it allocates a new shared pixmap from the master, shares
it to the slave, and starts the master tracking damage to it,
to keep it updated from the current front pixmap.

If the resize means the crtc is no longer used it will destroy
the slave pixmap.

This adds the concept of a scanout_pixmap to the randr_crtc object,
and also adds a master pixmap pointer to the pixmap object, along
with defining some pixmap helper functions for getting pixmap box/regions.

v2: split out pixmap sharing to a separate function.

v3: update for void *

Reviewed-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2012-07-07 10:37:10 +01:00
Keith Packard
4ba340cfaa randr: Clean up compiler warnings about unused and shadowing variables
set but not used variables
shadowing a previous local

A hidden problem was that the VERIFY_RR_* macros define local 'rc'
variables, any other local definitions for those would be shadowed and
generate warnings from gcc. I've renamed the other locals 'ret'
instead of 'rc'.

Signed-off-by: Keith Packard <keithp@keithp.com>
2012-06-21 18:42:46 -07:00
Keith Packard
9838b7032e Introduce a consistent coding style
This is strictly the application of the script 'x-indent-all.sh'
from util/modular. Compared to the patch that Daniel posted in
January, I've added a few indent flags:

	-bap
	-psl
	-T PrivatePtr
	-T pmWait
	-T _XFUNCPROTOBEGIN
	-T _XFUNCPROTOEND
	-T _X_EXPORT

The typedefs were needed to make the output of sdksyms.sh match the
previous output, otherwise, the code is formatted badly enough that
sdksyms.sh generates incorrect output.

The generated code was compared with the previous version and found to
be essentially identical -- "assert" line numbers and BUILD_TIME were
the only differences found.

The comparison was done with this script:

dir1=$1
dir2=$2

for dir in $dir1 $dir2; do
	(cd $dir && find . -name '*.o' | while read file; do
		dir=`dirname $file`
		base=`basename $file .o`
		dump=$dir/$base.dump
		objdump -d $file > $dump
	done)
done

find $dir1 -name '*.dump' | while read dump; do
	otherdump=`echo $dump | sed "s;$dir1;$dir2;"`
	diff -u $dump $otherdump
done

Signed-off-by: Keith Packard <keithp@keithp.com>
Acked-by: Daniel Stone <daniel@fooishbar.org>
Acked-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2012-03-21 13:54:42 -07:00
Rui Matos
9cc44b955b randr: Make the RRConstrainCursorHarder logic the same as miPointerSetPosition
The constraining logic in RRConstrainCursorHarder allows the cursor to reach
crtc positions of x = width and y = height while the constraining code in
miPointerSetPosition only allows it to reach x = width - 1 and y = height - 1
for the analogous screen case.

This patch makes the former's logic equivalent to the latter's which allows
applications to benefit from Fitts's law. E.g. a maximized application
adjacent to a crtc border wouldn't get pointer events if the user moved the
pointer all the way until it's contained.

Signed-off-by: Rui Matos <tiagomatos@gmail.com>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Keith Packard <keithp@keithp.com>
2011-11-03 14:12:21 -07:00