Commit Graph

145 Commits

Author SHA1 Message Date
Michel Dänzer
da4e0c66fc Consolidate pScreen usage in drmmode_set_mode_major
We were already relying on pScrn->pScreen being non-NULL in some cases,
which is supposedly always true ever since this function is no longer
getting called from ScreenInit.

(Ported from radeon commit eb611a2e4ecce7a1ab85fd72b9b78e3269311dd5)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-03-23 18:58:54 +09:00
Michel Dänzer
0bbf09dd7e Remove check for XF86_CRTC_VERSION 3
We require xserver >= 1.8, which was already at version 3.

(Ported from radeon commit 06602171386e538081c298645fb7ca1a70fe80cc)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-03-23 18:58:44 +09:00
Michel Dänzer
3485ca0051 Deal with modesets and page flips crossing on a CRTC
If we set a mode while a flip is pending, the kernel driver may program
the flip to the hardware after the modeset. If that happens, the hardware
will display the BO from the flip, whereas we will assume it displays the
BO from the modeset. In other words, the display will most likely freeze,
at least until another modeset.

Prevent this condition by waiting for a pending flip to finish before
setting a mode.

Fixes display freezing when setting rotation or a transform with
TearFree enabled.

(Ported from radeon commit a88985f5d1e39caca49ceb65678aaa9cb622a0d2)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-03-23 18:58:35 +09:00
Michel Dänzer
b9d00fa7aa Make DRM event queue xf86CrtcPtr based instead of ScrnInfoPtr based
This allows for a minor simplification of the code.

(Ported from radeon commit f5d968cbba3c9b7ec202161f2157d8d64778c817)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-03-23 18:58:26 +09:00
Michel Dänzer
e0ed26151b Remove amdgpu_scanout_flip_handler
No longer necessary now that amdgpu_drm_queue_handler can handle
e->handler == NULL.

(Ported from radeon commit d5dbb07db22d5420c81dfebc060f0dd86e7b8a20)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-03-23 18:58:19 +09:00
Michel Dänzer
acd5da56f5 DRI2: Also clear dri2_flipping when client disconnects before event
Fixes the following problem:

With DRI3 enabled, run glxgears with LIBGL_DRI3_DISABLE=1, make it
fullscreen and press Escape while it's still fullscreen. This could
result in dri2_flipping not getting cleared, spuriously preventing apps
using DRI3 from flipping.

(Ported from radeon commit e87365117acbd80b7d80fbb5eb30890ef7153291)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-03-23 18:58:12 +09:00
Michel Dänzer
a58bfa9820 drm_queue: Don't abort events immediately from amdgpu_drm_abort_client
Keep them around until the DRM event arrives, but then call the abort
functions instead of the handler functions.

This is a prerequisite for the following fix.

(Ported from radeon commit 3989766edde85d1abe7024577b98fc9b007bc02a)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-03-23 18:58:05 +09:00
Michel Dänzer
e4888df6e3 Fix RandR CRTC transforms
Currently, Xorg will only transform the cursor as of the first time the
cursor image changes after a transform is set.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=80678

(Ported from radeon commit 9483a3d777919b224f70c3b4d01e4b320a57db31)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-03-23 18:57:57 +09:00
Michel Dänzer
43af92ede0 Build RandR 1.4 provider name from chipset name and bus ID
Instead of just "amdgpu", it's now e.g. "TONGA @ pci:0000:01:00.0".

(Ported from radeon commit c7cf00487cd6d4a5d0f39d5b92ff04f6420d6a32)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-03-18 16:58:07 +09:00
Michel Dänzer
5ec1797a28 DRI2: Use amdgpu_pixmap_get_handle
Now we can share pixmaps with no struct amdgpu_buffer via DRI2.

Fixes VDPAU video playback freezing when using an OpenGL compositor with
DRI3 enabled and mpv VAAPI hardware decoding with OpenGL output.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89755
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=93804

(ported from radeon commit f8b0f23e9f4af9f9097ee5e72d53b45173163c41)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-02-27 15:25:58 +09:00
Michel Dänzer
df60c635e1 glamor: Avoid generating GEM flink names for BOs shared via DRI3 (v2)
We can't create our own struct amdgpu_buffer representation in this case
because destroying that would make the GEM handle inaccessible to glamor
as well. So just get the handle directly via dma-buf.

(ported from radeon commit 391900a670addec39515f924265bfa9f8bfa9ec0,
 extended to cache BO handles in the private for non-DRI3 pixmaps as
 well)

v2: Swap whole pixmap privates instead of just BOs in
    amdgpu_dri2_exchange_buffers to avoid invalidating cached BO handles

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-02-27 15:24:51 +09:00
Michel Dänzer
e463b849f3 Make amdgpu_do_pageflip take a pixmap instead of a BO
(inspired by radeon commit 7b4fc4a677d252d01c2bf80d162bc35814059eaa)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-02-27 15:24:25 +09:00
Michel Dänzer
1ee341f9d9 Add amdgpu_pixmap_get_handle helper
(inspired by radeon commits dfad91fffb5bd013785223b42d78886df839eacf
 and ccbda955ebae1d457d35293833f12791e0f9fb0b)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-02-24 18:09:18 +09:00
Michel Dänzer
a36bbfd98b HAS_DIRTYTRACKING_ROTATION also supports multiple CRTCs
(ported from radeon commit ff9a6b6f079a8419f4e6fadfee778060618bf735)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-02-16 16:33:48 +09:00
Michel Dänzer
a37746ffce Load fb module before glamoregl/shadow modules
Fixes unresolved symbols on some systems.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=93105
(ported from radeon commit 78fbca095ae9887a2d3de48bb07975e2d1126e68)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-02-16 16:33:14 +09:00
Michel Dänzer
59c0a68071 Don't advertise any PRIME offloading capabilities without acceleration
Acceleration is required even for display offloading. Trying to enable
display offloading without acceleration resulted in a crash.

(ported from radeon commit b19417e2fddf4df725951aea5ad5e9558338f59e)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-02-15 18:28:13 +09:00
Michel Dänzer
a3eac85d81 Only map front buffer if glamor acceleration is disabled (v2)
Otherwise the front buffer may not be accessible by the CPU, because Mesa
sets the AMDGPU_GEM_CREATE_NO_CPU_ACCESS flag for tiled buffers, because
accessing tiled buffers with the CPU makes little sense.

v2: Also handle Option "AccelMethod" "none"

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-01-29 16:05:08 +09:00
jimqu
2fcb7dadd3 glamor: Return NullPixmap on failure to create shareable pixmap
If we were asked to create a shareable pixmap, it doesn't make sense
to return a pixmap which isn't shareable. Doing so caused trouble down
the line such as a crash with older versions of glamor when trying to
use GLX pixmaps of bpp < 32 via DRI2.

Signed-off-by: JimQu <jim.qu@amd.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2016-01-28 18:15:45 +09:00
jimqu
5269a2228b Move amdgpu_glamor_destroy_pixmap before amdgpu_glamor_create_pixmap
The next commit will call the former from the latter. No functional
change.

Signed-off-by: JimQu <jim.qu@amd.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2016-01-28 18:06:33 +09:00
Tom St Denis
54c959c163 Move memset() after variable declarations
To make the code more "C" like move the function calls
after the variable declarations.

Signed-off-by: Tom St Denis <tom.stdenis@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2016-01-21 12:54:11 +09:00
Michel Dänzer
8853b07ae8 Set the RandR primary output on startup if Xorg hasn't
Fixes xrandr (XRRGetOutputPrimary) not reporting any output as primary
after startup.

(Ported from radeon commit b16856b25086ffb27365ac2249b8da921066ce62)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-01-19 17:35:11 +09:00
Michel Dänzer
bd5c65dace Only call amdgpu_bus_id once in each probe path (v2)
Instead of up to twice as before.

v2: Remove free(busIdString) call from amdgpu_kernel_mode_enabled, the
    bus ID string is now managed by its callers.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com> (v1)
2016-01-13 18:48:02 +09:00
Michel Dänzer
6e42c58375 Remove pci_dev test from amdgpu_get_scrninfo
The pci_dev parameter can never be NULL since we only support KMS.

Reported-by: Tom St Denis <tom.stdenis@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-01-13 18:47:17 +09:00
Michel Dänzer
8e09180798 Re-use PCI bus ID code from kernel_open_fd in kernel_mode_enabled
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-01-13 18:46:46 +09:00
Mykola Lysenko
4eb9cedca0 Initialize drmmode_crtc dpms_mode to DPMSModeOff
This disables query of disabled pipes for drmWaitVBlank on X start

Signed-off-by: Mykola Lysenko <Mykola.Lysenko@amd.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2016-01-13 18:42:22 +09:00
Michel Dänzer
1d0b0c1794 sync: Check if miSyncShmScreenInit symbol is resolved at runtime
It may be disabled in the Xorg build, either explicitly or because the
xshmfence library isn't available.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-01-05 12:02:04 +09:00
Mykola Lysenko
f4107f67f1 Check for NULL koutput in drmmode_output_dpms
This situation happens whit start of usage of DRM DP MST framework,
when connectors created and destroyed dynamically.

Signed-off-by: Mykola Lysenko <Mykola.Lysenko@amd.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2015-12-24 10:17:13 +09:00
Jammy Zhou
ea558e6457 Use render node for DRI3 if available
Signed-off-by: Jammy Zhou <Jammy.Zhou@amd.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2015-11-20 17:44:55 +09:00
Michel Dänzer
43c2dc1aab glamor: Deal with glamor_egl_destroy_textured_pixmap being removed
When it's not available, it's safe to call down to the glamor
DestroyPixmap hook instead.

(ported from radeon commit 10b7c3def58bb34acc38f076bc230e25b454ab79)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2015-11-20 12:14:03 +09:00
Michel Dänzer
84cab5738a glamor: Restore all ScreenRec hooks during CloseScreen
(ported from radeon commit 535e5438b2c32f774b9c8c27ee0289b4749548ef)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2015-11-19 17:56:36 +09:00
Michel Dänzer
a00c050c2e Post 1.0.0 release version bump 2015-11-19 17:55:53 +09:00
Michel Dänzer
755e6ff233 Bump version for 1.0.0 release xf86-video-amdgpu-1.0.0 2015-11-19 17:28:19 +09:00
Michel Dänzer
49c7d2be99 Add amdgpu_pixmap.h to src/Makefile.am's EXTRA_DIST
Fixes make distcheck.
2015-11-19 17:20:39 +09:00
Stephen Chandler Paul
d069ec5d27 Handle failures in setting a CRTC to a DRM mode properly
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()]

Signed-off-by: Stephen Chandler Paul <cpaul@redhat.com>
(ported from radeon commit 7186a8713ba004de4991f21c1a9fc4abc62aeff4)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2015-11-19 17:20:23 +09:00
Michel Dänzer
c8bddcf6c9 Call xf86CrtcRotate from initial drmmode_set_desired_modes call
Fixes various problems when rotation is specified in xorg.conf.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=92475

(ported from radeon commit 548e97b3b7d1e94075a54ca2bb4eb683025098a7)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2015-11-19 17:20:07 +09:00
Emil Velikov
12815156f3 Do not link amdgpu_drv.so against libpciaccess
Not used directly.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
(ported from radeon commit fcb32231a38f9461d12720cbf72f63502197a711)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2015-11-19 17:19:42 +09:00
Michel Dänzer
a02982b0ae Skip disabled CRTCs in amdgpu_scanout_(do_)update
The vblank / page flip ioctls don't work as expected for a disabled CRTC.

(ported from radeon commit acc11877423ecd81a6e0a7f38466f80e43efee20)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2015-11-19 17:19:28 +09:00
Michel Dänzer
0ddd20600d Prefer drmModeSetCursor2 over drmModeSetCursor
The former includes information about the position of the hotspot within
the cursor image.

Copied from xf86-video-modesetting.

(ported from radeon commit c9f8f642fd495937400618a4fc25ecae3f8888fc)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2015-11-19 17:19:09 +09:00
Michel Dänzer
83a47c0ebe PRIME: Don't advertise offload capabilities when acceleration is disabled
Xorg tends to crash if the user tries to actually use the offload
capabilities with acceleration disabled.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=57200
(ported from radeon commit c74de9fec13fac2c836bb2a07ae6f90e1d61e667)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2015-11-19 17:18:40 +09:00
Michel Dänzer
560b7fe6dc Rename Option "NoAccel" to "Accel"
Removes the need for a double negation when forcing acceleration on.

Note that this change is backwards compatible, as the option parser
automagically handles the 'No' prefix.

(ported from radeon commit cc615d06db0332fc6e673b55632bcc7bf957b44b)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2015-11-19 17:17:15 +09:00
Adam Jackson
ad77ad32c4 Use own thunk function instead of shadowUpdatePackedWeak
I plan to delete the Weak functions from a future server.

Signed-off-by: Adam Jackson <ajax@redhat.com>
(ported from radeon commit 851b2cf8714618843725f6d067915375485ade9d)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2015-11-19 17:16:53 +09:00
Michel Dänzer
f5ccea99c0 dri2: Handle PRIME for source buffer as well in amdgpu_dri2_copy_region2
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=77810

(ported from radeon commit c84230d686c078aac1dc98d82153f8b02521b2e1)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2015-11-11 17:16:58 +09:00
Michel Dänzer
92e7c93d2f Move scrn/info declaration inside USE_GLAMOR in amdgpu_dri3_fd_from_pixmap
Fixes warning when building with --disable-glamor:

../../src/amdgpu_dri3.c: In function 'amdgpu_dri3_fd_from_pixmap':
../../src/amdgpu_dri3.c:135:16: warning: unused variable 'info' [-Wunused-variable]
  AMDGPUInfoPtr info = AMDGPUPTR(scrn);
                ^

Reported-by: Jammy Zhou <Jammy.Zhou@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2015-11-04 12:23:37 +09:00
Michel Dänzer
c9bd1399a1 Call AMDGPUFreeRec from AMDGPUFreeScreen_KMS even if info == NULL
It's safe now.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2015-11-04 12:23:28 +09:00
Michel Dänzer
fb8444e731 Don't use AMDGPUEntPriv in AMDGPUFreeRec
It crashes if info == NULL.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2015-11-02 18:20:41 +09:00
Michel Dänzer
8e7ee03f55 Remove amdgpu_reference_drm_fd
Increase pAMDGPUEnt->fd_ref in the probe code instead when we're reusing
the existing fd.

The previous reference counting was imbalanced, so pAMDGPUEnt->fd_ref
could never go to 0.

Reviewed-by: Jammy Zhou <Jammy.Zhou@amd.com>
2015-10-30 18:33:22 +09:00
Michel Dänzer
6bab8fabb3 Remove info->dri2.drm_fd and info->drmmode->fd
Use pAMDGPUEnt->fd everywhere instead.

Reviewed-by: Jammy Zhou <Jammy.Zhou@amd.com>
2015-10-30 18:32:55 +09:00
Jammy Zhou
0530e39cc6 Pass struct pci_device *pci_dev directly to amdgpu_get_scrninfo
Instead of throwing away the type information by passing it as a void*.

Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2015-10-30 18:32:16 +09:00
Jammy Zhou
edf72afee3 Fix crash in PCI probe path (v4)
The crash is caused by the NULL value returned by AMDGPUPTR(pScrn),
because the driverPrivate is not allocated yet in PciProbe phase,
and it is usually done in the PreInit phase.

Use pAMDGPUEnt->fd instead of info->dri2.drm_fd to avoid AMDGPUInfoPtr
related code in amdgpu_open_drm_master, so that the crash can be fixed.

v4: (md) Remove unused parameter entity_num, split out logically
    separate changes
v3: some more cleanup
v2: switch to pAMDGPUEnt->fd, and update the commit message

Signed-off-by: Jammy Zhou <Jammy.Zhou@amd.com>
Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com> (v3)
2015-10-30 18:25:48 +09:00
Michel Dänzer
cef725121e Remove dead code from probe paths
amdgpu_get_scrninfo allocates the memory pointed to by pAMDGPUEnt just
before it calls amdgpu_open_drm_master, so pAMDGPUEnt->fd is always 0
in the latter.

Also, no need to clear pAMDGPUEnt->fd just before freeing the memory
it's stored in.

Reviewed-by: Jammy Zhou <Jammy.Zhou@amd.com>
2015-10-28 17:56:13 +09:00