Fix build without --enable-glamor.
Caught by the arm tinderbox.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Mark Kettenis <kettenis@openbsd.org>
Tested-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This moves the capabilites setting to after glamor is initialised, and
enables the offload caps in cases where they work. This enables DRI2
PRIME support with modesetting.
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Otherwise ms_ent_priv will return NULL and things will fall apart.
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
For some reason a couple of the dirty functions in driver.c used 8
spaces per tab instead of 4 like the rest of the file. Fix this to make
it more consistent and give me more room to work in ms_dirty_update in
subsequent commits.
v1: N/A
v2: N/A
v3: N/A
v4: Initial commit
Signed-off-by: Alex Goins <agoins@nvidia.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Both radeon and amdgpu don't set the mode until the first blockhandler,
this means everything should be rendered on the screen correctly by
then.
This ports this code, it also removes the tail call of EnterVT from
ScreenInit, it really isn't necessary and causes us to set a dirty mode
with -modesetting always anyways.
v2: reorder set desired modes vs block handler as done for amdgpu.
Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
This adds support using glamor for background None.
loosely based off the amdgpu code. relies on the glamor_finish code.
Acked-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Setting crtc->transformPresent to FALSE was preventing the transform
from actually taking effect and putting RandR into a confused state.
Now that the RandR 1.2 cursor code handles transforms correctly, we can
allow them to properly take effect.
Reviewed-by: Keith Packard <keithp@keithp.com>
Fixes build errors of:
present.c: In function 'ms_do_pageflip':
present.c:410:17: error: 'drmmode_bo' has no member named 'gbm'
new_front_bo.gbm = glamor_gbm_bo_from_pixmap(screen, new_front);
^
present.c:412:22: error: 'drmmode_bo' has no member named 'gbm'
if (!new_front_bo.gbm) {
^
present.c: In function 'ms_present_check_flip':
present.c:536:36: error: 'drmmode_bo' has no member named 'gbm'
if (drmmode_crtc->rotate_bo.gbm)
^
Introduced by commit 13c7d53d
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
This moves the code from the platform case into
a common function, and calls that from the
other two.
v2: Emil convinced me we don't need to lookup pEnt
here, so let's not bother.
Reported-by: Mark Kettenis <mark.kettenis@xs4all.nl>
Reviewed-by: Mark Kettenis <kettenis@openbsd.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
This isn't used anywhere, so no point storing it until we need it.
Reviewed-by: Mark Kettenis <kettenis@openbsd.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Replace the block/wakeup handlers with a NotifyFd callback.
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
DestroyPixmap handles that just fine. This also lets us drop our use
of the manual image destruction function (Note that the radeon driver
still uses it in a similar fashion, though).
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
The ifdef checks for XF86_CRTC_VERSION >= 3/5 are remnants from the
out-of-tree driver. Within the tree, we can rely on:
xf86Crtc.h:#define XF86_CRTC_VERSION 6
Signed-off-by: Daniel Martin <consume.noise@gmail.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
We calloc() output_ids. Let's free() it, too.
Signed-off-by: Daniel Martin <consume.noise@gmail.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
This fixes a bug where running the card out of PPLL's when hotplugging
another monitor would result in all of the displays going blank and
failing to work properly until X was restarted or the user switched to
another VT.
[Michel Dänzer: Pass errno instead of -ret to strerror()]
[Daniel Martin: Add \n to log message]
Picked from xf86-video-ati
7186a87 Handle failures in setting a CRTC to a DRM mode properly
Signed-off-by: Daniel Martin <consume.noise@gmail.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
A user on a nouveau-driven card ran into a problem where DVI-D-1 and
DVI-I-1 were aliasing. The simplest fix is to provide the full connector
names. While we're at it, rename the output names to match what is in
the kernel, and start counting the connectors from 1 rather than 0. The
only deviation is HDMI vs HDMI-A, which kept its original name.
This will break backwards compatibility with existing xorg.conf's that
reference output names, but the alternative is to create a separate
counting system, further disconnecting from the kernel names.
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Descriptions for Options PageFlip and SWCursor.
Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
This adds zaphod and ZaphodHeads support
to the the in-server modesetting driver.
this is based on a request from Mario,
and on the current radeon driver, along
with some patches from Mario to bring things
up to the state of the art in Zaphod.
v2: fixup vblank fd registring.
v3: squash Mario's fixes.
modesetting: Allow/Fix use of multiple ZaphodHead outputs per x-screen.
modesetting: Take shift in crtc positions for ZaphodHeads configs into account.
modesetting: Add ZaphodHeads description to man page.
small cleanups (airlied).
Reviewed-and-tested-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
glamor_name_from_pixmap and glamor_fd_from_pixmap return CARD16 and
CARD32 values via pointers. The current code uses uint16_t and
uint32_t which will probably be the same but it's safer to use the
datatypes as specified by the function.
Signed-off-by: Robert Ancell <robert.ancell@canonical.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
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>
This fixes modesetting when glamor is disabled.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Based on code by Keith Packard, Eric Anholt, and Jason Ekstrand.
v2:
- Fix double free and flip_count underrun (caught by Mario Kleiner).
- Don't leak flip_vblank_event on the error_out path (Mario).
- Use the updated ms_flush_drm_events API (Mario, Ken).
v3: Hack around DPMS shenanigans. If all monitors are DPMS off, then
there is no active framebuffer; attempting to pageflip will hit the
error_undo paths, causing us to drmModeRmFB with no framebuffer,
which confuses the kernel into doing full modesets and generally
breaks things. To avoid this, make ms_present_check_flip check that
some CRTCs are enabled and DPMS on. This is an ugly hack that would
get better with atomic modesetting, or some core Present work.
v4:
- Don't do pageflipping if CRTCs are rotated (caught by Jason Ekstrand).
- Make pageflipping optional (Option "PageFlip" in xorg.conf.d), but
enabled by default.
v5: Initialize num_crtcs_on to 0 (caught by Michel Dänzer).
[airlied: took over]
v6: merge async flip support from Mario Kleiner
free sequence after failed vblank queue
handle unflip while DPMS'ed off (Michel)
move flip tracking into its own structure, and
fix up reference counting issues, and add comments.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Acked-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Since we are shipped with the server and the server has it built-in,
don't bother trying to load it.
Don't remove or invert the if statement on purpose as a later
patch adds stuff in here.
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Dave Airlie <airlied@redhat.com>
This is a specialization of ms_drm_abort that matches based on the drm
event queue's sequence number.
Based on code by Keith Packard.
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
I want to use this in present.c.
Reviewed-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Previously, ms_flush_drm_events() returned a boolean value, and it was
very easy to interpret the meaning incorrectly. Now, we return an
integer value.
The possible outcomes of this call are:
- poll() raised an error (formerly TRUE, now -1 - poll's return value)
- poll() said there are no events (formerly TRUE, now 0).
- drmHandleEvent() raised an error (formerly FALSE, now the negative
value returned by drmHandleEvent).
- An event was successfully handled (formerly TRUE, now 1).
The nice part is that this allows you to distinguish errors (< 0),
nothing to do (= 0), and success (1). We no longer conflate errors
with success.
v2: Change ms_present_queue_vblank to < 0 instead of <= 0, fixing an
unintentional behavior change. libdrm may return EBUSY if it's
received EINTR for more than a second straight; just keep retrying
in that case. Suggested by Jasper St. Pierre.
Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
This adds support for reverse prime to the modesetting driver.
Reverse prime is where we have two GPUs in the display chain,
but the second GPU can't scanout from the shared pixmap, so needs
an extra copy to the on screen pixmap.
This allows modesetting to support this scenario while still
supporting the USB offload one.
v1.1:
fix comment + ret = bits (Eric)
Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Dave Airlie <airlied@redhat.com>
This allows a glamor enabled master device to have
slave USB devices attached.
Tested with modesetting on SNB + USB.
It relies on the previous patch to export linear
buffers from glamor.
Acked-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Fixes mmap failures with 32-bit builds.
Signed-off-by: Michel Dänzer <michel@daenzer.net>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
The code in drmmode_set_cursor does not properly handle the case where
drmModeSetCursor2 returns any other error than EINVAL and silently fails to set
a cursor.
So only return when the drmModeSetCursor2 succeeds (i.e returns 0) and disable
the cursor2 usage on EINVAL.
References: https://bugzilla.redhat.com/show_bug.cgi?id=1205725
Signed-off-by: Adel Gadllah <adel.gadllah@gmail.com>
Reviewed-by: Michel Dänzer <michel@daenzer.net>
Reviewed-by: Rob Clark <robdclark@gmail.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
This adds tiling support to the server modesetting driver,
it retrieves the tile info from the kernel and translates
it into the server format and exposes the property.
v2.1: fix resetting tile property (Chris)
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Dave Airlie <airlied@redhat.com>
This is ported from the same code in the ati and intel drivers,
It uses the same option name as nvidia and the other DDXes to
disable tearing down outputs as it is hard to avoid racing with clients.
v2: address two issues with DeleteUnusedDP12 enabled, reported
by Daniel Martin,
a) check we have a mode_output before destroying it
b) only delete *unused* displays (thanks Aaron for clarifying)
so we check if the output has a crtc and if it does we don't
delete it.
v3: drop the option to delete unused displays, just encode
behaviour into the randr spec.
Signed-off-by: Dave Airlie <airlied@redhat.com>
There is no need to cache the mode resources and with dynamic
connectors for mst support we don't want to. So first clean that
up before adding dynamic connector support.
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Remove these defines as we start to remove support for non-standard
glamor layering as used by the intel driver.
v2: Rebase on the blockhandler change and the Xephyr init failure
change (by anholt), fix stray NO_DRI3 addition to xwayland.
Signed-off-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
All of our checks for what crtc we are on take rotation into account so we
select the correct crtc. The only problem is that we weren't returning it
we were rotated. This caused X to think DRI3 apps were not on any crtc and
limit them to 1 FPS.
Signed-off-by: Jason Ekstrand <jason.ekstrand@intel.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
This replaces the stubs for shadow buffer creation/allocation with actual
functions and adds a shadow_destroy function. With this, we actually get
shadow buffers and RandR now works properly. Most of this is copied from
the xf86-video-intel driver and modified for modesetting.
v2 Jason Ekstrand <jason.ekstrand@intel.com>:
- Fix build with --disable-glamor
- Set the pixel data pointer in the pixmap header for dumb shadow bo's
- Call drmmode_create_bo with the right bpp
v2 Jason Ekstrand <jason.ekstrand@intel.com>:
- Make shadow buffers per-crtc and leave shadow_enable alone
Signed-off-by: Jason Ekstrand <jason.ekstrand@intel.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Jason Ekstrand <jason.ekstrand@intel.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
The original drmmode_glamor_new_screen_pixmap function was specific to the
primary screen pixmap. This commit pulls the guts out into a new, more
general, drmmode_set_pixmap_bo function for setting a buffer on a pixmap.
The new function also properly tears down the glamor bits if the buffer
being set is NULL. The drmmode_glamor_new_screen_pixmap function is now
just a 3-line wrapper around drmmode_set_pixmap_bo.
v2 Jason Ekstrand <jason.ekstrand@intel.com>:
- Re-arranged code in drmmode_set_pixmap_bo and
drmmode_glamor_handle_new_screen_pixmap so that glamor_set_screen_pixmap
only gets called for the screen pixmap
- Guard the call to glamor_set_screen_pixmapa with a drmmode->glamor check
Signed-off-by: Jason Ekstrand <jason.ekstrand@intel.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
If the BlockHandler chain is modified while it is active, we need to
re-fetch the current value and store it in our private for use the
next time through.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
In the new KMS APIs, the legacy drmModeSetCursor ioctl actually waits
for a vblank after changing the cursor image before returning, meaning
that the X server, in attempting to hide the cursor before updating
its image, actually makes that hide *visible* for a full vblank.
It's unknown why the X server does this by default, but turn it off.
If we're with a legacy driver that doesn't support the modern
drmModeSetCursor by waiting for a vblank before returning, we're going
to get a tiny bit of tearing on the cursor plane. But between tearing
with a new cursor image and tearing with a blank cursor image, I'd
rather the former.
The only proper solution to this is an atomic ioctl that page flips
all planes, including the cursor plane, at vblank time and at the same
time.
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
present.c: In function 'ms_present_flush':
present.c:204:9: error: implicit declaration of function
'glamor_block_handler'
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=87858
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Jasper St. Pierre <jstpierre@mecheye.net>
Reviewed-by: Rob Clark <robdclark@gmail.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
modesetting hooked up vblank support for DRI2, but was missing support
for vblanks in Present.
This is mostly copy and pasted from Keith's code in the intel driver.
v2: Use ms_crtc_msc_to_kernel_msc in ms_present_queue_vblank to hook
up the vblank_offset workaround for bogus MSC values (which the
DRI2 code already did).
Also simplify the ms_present_get_crtc function. vblank.c already
implements the functionality; we just need to convert types.
v3: Fix ms_flush_drm_events return code. I'd copied code where 0 meant
success into a function that returned a boolean, so the return code
was always backwards.
Also add DebugPresent calls in ms_present_vblank_{handler,abort}.
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Keith Packard <keithp@keithp.com>
Tested-by: Jason Ekstrand <jason.ekstrand@intel.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
We basically want it throughout the driver.
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Keith Packard <keithp@keithp.com>
Tested-by: Jason Ekstrand <jason.ekstrand@intel.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
crtc->enabled is insufficient; we should also make sure DPMS is on.
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Keith Packard <keithp@keithp.com>
Tested-by: Jason Ekstrand <jason.ekstrand@intel.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
We don't want to try to vblank synchronize to monitors which are off.
In order to handle that properly, we need to know the CRTC's DPMS mode.
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Keith Packard <keithp@keithp.com>
Tested-by: Jason Ekstrand <jason.ekstrand@intel.com>
Signed-off-by: Keith Packard <keithp@keithp.com>