Commit Graph

3664 Commits

Author SHA1 Message Date
Michel Dänzer
f87acdbfb1 Create drmmode_crtc_wait_pending_event helper macro
Preparation for following change, no functional change intended yet.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-08-17 15:38:21 +09:00
Michel Dänzer
99f1d7a474 Create drmmode_wait_vblank helper
Allows cleaning up the code considerably.

v2:
* Fix "drmWaiVBlank" typo, add blank line for readability (Slava Abramov)
* Rename in/out sequence parameters to "target_seq" and "result_seq",
  hopefully that will be clearer.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com> # v1
2017-08-17 15:24:22 +09:00
Michel Dänzer
49cc61ab97 Pass reference CRTC to radeon_do_pageflip directly
Simplifies the code slightly.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-08-17 15:23:34 +09:00
Michel Dänzer
3f120fa1d5 Remove drmmode_crtc->scanout_destroy[] array
No longer necessary since we're reference counting framebuffers.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com
2017-08-15 17:31:31 +09:00
Michel Dänzer
01b040b4a8 Adapt to PixmapDirtyUpdateRec::src being a DrawablePtr 2017-08-15 17:15:27 +09:00
Michel Dänzer
5309bde0c4 Allow DRI page flipping when some CRTCs use separate scanout buffers
As long as the CRTC we're synchronizing to doesn't.

v2:
* Remove redundant checks from can_exchange which still prevented DRI2
  page flipping

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-08-02 18:55:23 +09:00
Michel Dänzer
9bc3eef744 Add drmmode_crtc_can_flip helper
To reduce code duplication between DRI2 and Present. No functional
change intended yet.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-08-02 18:54:54 +09:00
Michel Dänzer
c2d2689069 Use root window (pixmap) instead of screen pixmap for scanout updates
Preparation for following changes, no functional change intended yet.

v2:
* Add drmmode_screen_damage_destroy callback to prevent use-after-free
  on server shutdown

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-07-28 12:00:35 +09:00
Michel Dänzer
377c9dc7e5 autogen.sh: Pass -f to autoreconf
To ensure that any existing copies of autotools files will be replaced
with the current versions.

(Cherry picked from amdgpu commit a47c0093338d80d84e7033ad15d051925d542ca0)
Acked-by: Alex Deucher <alexander.deucher@amd.com>
2017-07-28 11:57:41 +09:00
Michel Dänzer
bf0a759e3b Makefile.am: Set ACLOCAL_AMFLAGS = -I m4
Suggested by one of the tools called by autoreconf.

(Cherry picked from amdgpu commit 842bad4b951296ca25f47b50cb358e502bf30ebb)
Acked-by: Alex Deucher <alexander.deucher@amd.com>
2017-07-28 11:57:27 +09:00
Michel Dänzer
e628f604d0 Add AC_CONFIG_MACRO_DIRS([m4]) to configure.ac
Suggested by one of the tools called by autoreconf.

(Cherry picked from amdgpu commit 227b399badaad9bbef0be5a776ce008d0d243449)
Acked-by: Alex Deucher <alexander.deucher@amd.com>
2017-07-27 15:24:37 +09:00
Michel Dänzer
7d7abf99b5 Only handle reflection in the driver with Xorg < 1.16
Xorg doesn't handle the hardware cursor correctly in that case for
rotation and general transforms, and we can't force the SW cursor.

Fixes: f2bc882f1c ("Handle rotation in the driver also with Xorg
                      1.12-1.18")
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-07-26 18:13:35 +09:00
Michel Dänzer
94dc2b80f3 If a TearFree flip fails, fall back to non-TearFree operation
In order to avoid possible freeze / log file spam in that case.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99769
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-07-13 17:29:24 +09:00
Michel Dänzer
aff267ee36 Use drmmode_crtc->scanout_id instead of 0 to check for scanout buffer
Preparation for following change, no functional change intended.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-07-11 15:39:05 +09:00
Michel Dänzer
df88d51c50 Use pRADEONEnt->fd exclusively for the DRM file descriptor
This brings us closer to amdgpu.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-06-30 17:40:12 +09:00
Michel Dänzer
19626bce4e Improve drmmode_fb_reference debugging code
If a reference count is <= 0, call FatalError with the call location
(in case it doesn't get resolved in the backtrace printed by
FatalError).

(Ported from amdgpu commit 1b6ff5fd9933c00ec1ec90dfc62e0b531927749b)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-06-30 17:39:53 +09:00
Michel Dänzer
bc46ffdf71 Increase reference count of FB assigned to drmmode_crtc->flip_pending
Otherwise, it could happen that we destroy the FB before the flip
completes, resulting in use-after-free and most likely a crash.

(Ported from amdgpu commit af7221e1c4d2dbdfd488eb0976a835584ea8441c)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-06-27 18:19:31 +09:00
Michel Dänzer
c9dd28cb0c Only call drmmode_scanout_free for non-GPU screens in LeaveVT
Destroying the scanout buffers of GPU screens resulted in a crash when
switching back to the Xorg VT.

Fixes: 4cfa4615f7 ("Use drmmode_crtc_scanout_* helpers for RandR 1.4
                      scanout pixmaps")
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-06-27 11:59:08 +09:00
Michel Dänzer
78fad9ca16 Include xf86Pci.h for DRICreatePCIBusID with xserver Git master
The declaration has been moved there from dri.h.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-06-26 18:58:30 +09:00
Adam Jackson
ef95e3a3cc modesetting: Validate the atom for enum properties
The client could have said anything here, and if what they said doesn't
actually name an atom NameForAtom() will return NULL, and strcmp() will
be unhappy about that.

[copied from xserver d4995a3936ae283b9080fdaa0905daa669ebacfc]

Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-and-Tested-by: Michel Dänzer <michel.daenzer@amd.com>
2017-06-15 12:22:30 +09:00
Michel Dänzer
d80d01a73c Update URLs
* Point to the amd-gfx mailing list
* Specify the component in all bugzilla URLs
* Use https:// for all HTML URLs

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-05-18 11:12:34 +09:00
Eric Anholt
2b7d77b901 Use plain glamor_egl_create_textured_screen().
Since 5064ffab631 (2014), glamor's implementation of _ext just drops the
back_pixmap arg, which we were passing NULL (the default) to anyway.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2017-05-17 16:06:31 +09:00
Michel Dänzer
3a9f7e87c3 Remove unused struct members from drmmode_display.h
(Ported from amdgpu commit 462ac3341e5bfbded9086d3d9043821d19352b3e)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-05-11 18:57:25 +09:00
Michel Dänzer
7dc68e2675 Simplify tracking of PRIME scanout pixmap
Remember the shared pixmap passed to drmmode_set_scanout_pixmap for each
CRTC, and just compare against that.

Fixes leaving stale entries in ScreenRec::pixmap_dirty_list under some
circumstances, which would usually result in use-after-free and a crash
down the line.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-05-11 18:52:43 +09:00
Michel Dänzer
55e513b978 Use reference counting for tracking KMS framebuffer lifetimes
References are held by the pixmaps corresponding to the FBs (so
the same KMS FB can be reused as long as the pixmap exists) and by the
CRTCs scanning out from them (so a KMS FB is only destroyed once it's
not being scanned out anymore, preventing intermittent black screens and
worse issues due to a CRTC turning off when it should be on).

v2:
* Only increase reference count in drmmode_fb_reference if it was sane
  before
* Make drmmode_fb_reference's indentation match the rest of
  drmmode_display.h

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-05-11 18:51:38 +09:00
Michel Dänzer
944391b005 Pass pixmap instead of handle to radeon_do_pageflip
This brings us in line with amdgpu and prepares for the following
change, no functional change intended.

(Ported from amdgpu commit e463b849f3e9d7b69e64a65619a22e00e78d297b)

v2:
* Be more consistent with the amdgpu code, which should make porting
  the following change to amdgpu easier

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-05-11 18:49:55 +09:00
Michel Dänzer
f32c45194a Apply gamma correction to HW cursor
The display hardware CLUT we're currently using for gamma correction
doesn't affect the HW cursor, so we have to apply it manually when
uploading the HW cursor data.

This currently only works in depth 24/32.

(Ported from amdgpu commit 82fa615f38137add75f9cd4bb49c48dd88de916f)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-05-09 11:18:00 +09:00
Michel Dänzer
4c91f36d30 Don't set modes before RADEONWindowExposures_oneshot is called
The root window contents may be undefined before that, so we don't want
to show anything yet.

Fixes a crash on startup with rotation and virtual resolution set in
xorg.conf.

Bugzilla: https://bugs.freedesktop.org/100276
Fixes: cc9d6b7db9 ("Move DPMS check from radeon_scanout_do_update to
                      radeon_scanout_flip")
(Ported from amdgpu commit 981bac185cfd74ae50dffc28f57cf34623a9595f)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-04-17 18:32:31 +09:00
Daniel Stone
d6c29250db Set correct DRM event context version
DRM_EVENT_CONTEXT_VERSION is the latest context version supported by
whatever version of libdrm is present. We were blindly asserting we
supported whatever version that may be, even if we actually didn't.

Set the version as 2, which should be bumped only with the appropriate
version checks.

Signed-off-by: Daniel Stone <daniels@collabora.com>
(Ported from xserver commit 0c8e6ed85810e96d84173a52d628863802a78d82)
v2: Remove second paragraph of commit log, we always initialize
    page_flip_handler2 = NULL (Emil Velikov)
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com> # v1
2017-04-10 17:30:14 +09:00
Michel Dänzer
23985d3ef3 manpage: Don't put "'" at the beginning of a line
It caused the whole line to be dropped.

Fixes: 58cd160005 ("Allow toggling TearFree at runtime via output
                      property")
Reported-by: Andy Furniss <adf.lists@gmail.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com> (amdgpu commit)
(Ported from amdgpu commit 165b51447643ce37f391f25ca6aecb8d76fabaa3)
2017-03-23 18:06:45 +09:00
Michel Dänzer
dc30f5e27e Post-release version bump 2017-03-23 18:06:23 +09:00
Michel Dänzer
6622706087 Bump version for 7.9.0 release xf86-video-ati-7.9.0 2017-03-16 16:38:15 +09:00
Michel Dänzer
9a71445094 Pass TRUE to drmmode_set_desired_modes the first time for GPU screens
This is the only place we call drmmode_set_desired_modes for GPU screens
during server startup. Without this change, the display outputs of
secondary GPUs may stay on even while Xorg isn't using them.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-03-09 15:37:39 +09:00
Michel Dänzer
67ae5e00a7 Skip some initialization steps for GPU screens
Xorg doesn't use the following functionality of GPU screens, so don't
bother initializing it:

* DRI page flipping
* DRI3 / Present / SYNC fences
* XVideo / XvMC
* Root window with background None

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-03-08 11:20:30 +09:00
Jochen Rollwagen
f0e7948e1c Fix build for XServer 1.13
Latest git build stops with the error message

radeon_kms.c: In function 'RADEONWindowExposures_oneshot':
radeon_kms.c:1644:45: error: expected expression before 'RegionPtr'
     pScreen->WindowExposures(pWin, pRegion, RegionPtr pBSRegion);

This patch fixes the build.

Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2017-03-06 10:35:26 +09:00
Michel Dänzer
d63881623f Don't call radeon_cs_flush_indirect & radeon_bo_wait in drmmode_copy_fb
RADEONWindowExposures_oneshot takes care of it.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-03-02 16:22:51 +09:00
Michel Dänzer
cc9d6b7db9 Move DPMS check from radeon_scanout_do_update to radeon_scanout_flip
When radeon_scanout_do_update is called from
drmmode_crtc_scanout_update, drmmode_crtc->pending_dpms_mode may still
be != DPMSModeOn, e.g. during server startup.

Fixes intermittently showing garbage with TearFree enabled.
2017-03-02 16:13:08 +09:00
Michel Dänzer
0a12bf1085 Call drmmode_set_desired_modes from a WindowExposures hook
This is the earliest opportunity where the root window contents are
guaranteed to be initialized, and prevents drmmode_set_mode_major from
getting called before drmmode_set_desired_modes via RADEONUnblank ->
drmmode_crtc_dpms. Also, in contrast to the BlockHandler hook, this is
called when running Xorg with -pogo.

Fixes intermittently showing garbage on server startup or after server
reset.

As a bonus, this avoids trouble due to higher layers (e.g. the tigervnc
Xorg module) calling RADEONBlockHandler_oneshot repeatedly even after
we set pScreen->BlockHandler = RADEONBlockHandler_KMS.

v2:
* Drop spaces between XORG_VERSION_NUMERIC arguments
* Call radeon_bo_wait after radeon_cs_flush_indirect

Bugzilla: https://bugs.freedesktop.org/99457
Reviewed-by: Alex Deucher <alexander.deucher@amd.com> (v1)
2017-03-02 16:05:55 +09:00
Michel Dänzer
df2d749a4d Fix bogus indentation
Trivial.

Fixes: 58cd160005 ("Allow toggling TearFree at runtime via output property")
2017-03-02 16:05:42 +09:00
Michel Dänzer
9035b6abea present: Flush before flipping
This isn't necessary for DRI clients, but the Present extension can also
be used for presenting normal pixmaps rendered to via the X11 protocol.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-03-01 16:58:03 +09:00
Michel Dänzer
0a4eb0e12f present: Use async flip for unflip if possible
In that case, unflip operations should finish faster in general.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-03-01 16:57:34 +09:00
Michel Dänzer
9a951a3e55 present: Also flush before using a flip to unflip
Not doing so might result in intermittently scanning out stale contents
of the screen pixmap.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-03-01 16:57:29 +09:00
Michel Dänzer
f2bc882f1c Handle rotation in the driver also with Xorg 1.12-1.18
We cannot use the HW cursor in that case, but in turn we get more
efficient and less teary updates of rotated outputs.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-03-01 16:57:13 +09:00
Michel Dänzer
ae921a3150 Fold drmmode_crtc_scanout_allocate into drmmode_crtc_scanout_create
Not used anywhere else anymore.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-03-01 16:56:53 +09:00
Michel Dänzer
987a34adb3 Call drmmode_crtc_scanout_create in drmmode_crtc_shadow_allocate as well
Calling drmmode_crtc_scanout_allocate in drmmode_crtc_shadow_allocate
resulted in drmmode_crtc_scanout_create called from
drmmode_crtc_shadow_create passing an uninitialized pitch value to
drmmode_create_bo_pixmap.

Fixes issues such as failure to allocate the scanout pixmap or visual
corruption and GPUVM faults when attempting to use rotation with Xorg
<1.19.

Bugzilla: https://bugs.freedesktop.org/99916
Fixes: ea30d856ba ("Pass pitch from drmmode_crtc_scanout_allocate to drmmode_create_bo_pixmap")
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-02-28 17:17:20 +09:00
Michel Dänzer
244d4bc7f8 present: Wait for screen pixmap BO idle before setting modes for unflip
To make sure the screen pixmap contents are up to date when it starts
being scanned out.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-02-22 18:30:12 +09:00
Michel Dänzer
3ff29e5a14 present: Only call drmModeRmFB after setting modes for unflip
Fixes display intermittently blanking when a modeset is used for unflip.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-02-22 18:29:53 +09:00
Michel Dänzer
0c29deb5a9 Use drmmode_crtc_scanout_free in drmmode_fini
We were leaking drmmode_crtc->scanout_damage, which caused trouble on
server reset. Fixes server reset with active separate scanout pixmaps.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-02-22 18:29:11 +09:00
Michel Dänzer
58cd160005 Allow toggling TearFree at runtime via output property
Option "TearFree" now sets the default value of the output property.
See the manpage update for details.

TearFree is now enabled by default for outputs using rotation or other
RandR transforms, and for RandR 1.4 slave outputs.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-02-22 18:27:37 +09:00
Michel Dänzer
305e2cbf33 Factor out drmmode_crtc_scanout_update helper
Cleanup in preparation for following change, no functional change
intended.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-02-22 18:27:19 +09:00