summaryrefslogtreecommitdiff
path: root/src/drmmode_display.c
AgeCommit message (Collapse)Author
2021-05-10Only include dri.h with older versions of xserverMichel Dänzer
Not needed anymore with current versions.
2020-07-13ati: cleanup terminology to use primary/secondaryDave Airlie
The X server changed some API/ABIs here. Based on amdgpu patch by Michel
2020-04-14Fix return value check of drmIoctl()Niclas Zeising
When the drmModeSetCursor2() call was replaced with bare drmIoctl() call in 92df7097, a bug was introduced. With the use of drmModeSetCursor2(), the return value from drmIoctl() (which calls ioctl()) were mangled, if they were negative, they were replaced by -errno by a wrapper function in xf86drMode.c in libdrm. After replacing drmModeSetCursor2() with the call to drmIoctl(), this mangling no longer happens, and we need to explicitly check if the call to drmIoctl() fails, which is indicated by returning -1, and then why it failed, by checking errno. If the error indicated by errno is EINVAL, then we can't use the DRM_IOCTL_MODE_CURSOR2 ioctl(), and need to fall back to the DRM_IOCTL_MODE_CURSOR ioctl(). This bug can manifest itself by an invisible hw cursor on systems where the DRM_IOCTL_MODE_CURSOR2 is not implemented by the graphics driver. Credit also to Alexey Dokuchaev for help with developing the fix and testing. This fixes #190 Signed-off-by: Niclas Zeising <zeising@daemonic.se> Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2019-03-15modesetting: add tile property supportDave Airlie
This adds tiling support to the driver, it retrieves the tile info from the kernel and translates it into the server format and exposes the property. (Ported from xserver commits 8fb8bbb3062f1a06621ab7030a9e89d5e8367b35 and 6abdb54a11dac4e8854ff94ecdcb90a14321ab31) (Ported from amdgpu commit 6ee857726166f495abcd68e4ff60e3a09593d079) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2019-03-14Use radeon_finish in drmmode_crtc_scanout_updateMichel Dänzer
radeon_glamor_finish only works if we're using glamor, otherwise it'll crash. Fixes: ce7db51020d3 "Cancel pending scanout update in drmmode_crtc_scanout_update" Bug: https://bugs.debian.org/924540 Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2019-01-28Only update drmmode_crtc->flip_pending after actually submitting a flipMichel Dänzer
And only clear it if it matches the framebuffer of the completed flip being processed. Fixes (WW) RADEON(0): flip queue failed: Device or resource busy (WW) RADEON(0): Page flip failed: Device or resource busy (EE) RADEON(0): present flip failed due to clobbering drmmode_crtc->flip_pending. Reproducer: Enable TearFree, run warzone2100 fullscreen, toggle Vertical sync on/off under Video Options. Discovered while investigating https://bugs.freedesktop.org/109364 . (Ported from amdgpu commit e72a02ba1d35743fefd939458b9d8cddce86e7f5)
2019-01-09Only call drmmode_validate_leases if RandR is enabledMichel Dänzer
It would crash if RandR is disabled, e.g. because Xinerama is enabled. Bugzilla: https://bugs.freedesktop.org/109230 Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2019-01-09Only call drmmode_uevent_init if RandR is enabledMichel Dänzer
There's no point in listening for hotplug events if RandR is disabled, as there's no other mechanism for them to be propagated. We were already mostly ignoring them in that case. Inspired by https://gitlab.freedesktop.org/xorg/driver/xf86-video-intel/commit/1a489142c8e6a4828348cc9afbd0f430d3b1e2d8 (via https://bugs.freedesktop.org/109230#c11). Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-12-28Use two HW cursor buffers per CRTCMichel Dänzer
Switch to the other buffer when xf86_config->cursor changes. Avoids these issues possible when re-using the same buffer: * The HW may intermittently display a mix of the old and new cursor images. * If the hotspot changes, the HW may intermittently display the new cursor image at the location corresponding to the old image's hotspot. Bugzilla: https://bugs.freedesktop.org/108832 (Ported from amdgpu commit 0d60233d26ec70d4e1faa343b438e33829c6d5e4)
2018-12-28Update cursor position in drmmode_show_cursor if hotspot changedMichel Dänzer
The cursor position is updated to be consistent with the new hotspot in the same ioctl call. (Ported from amdgpu commit b04697de5270e8e45744a7025c24df1f454a4cf0)
2018-12-28Use drmIoctl in drmmode_show_cursorMichel Dänzer
This should be functionally equivalent to what drmModeSetCursor(2) do behind the scenes, but allows for new tricks in following changes. (Ported from amdgpu commit b344e1559e936046ef02c777fc4f6bcefa3830bc)
2018-12-28Drop RADEONInfoRec::cursor_bo arrayMichel Dänzer
Not needed or even useful for anything. (Ported from amdgpu commit e95044e45350870fa7e237860e89ade91ac03550)
2018-12-28Cancel pending scanout update in drmmode_crtc_scanout_updateMichel Dänzer
drmmode_crtc_scanout_update does the equivalent of a scanout update, so no need to do it again. This might also avoid issues if there's a pending scanout update at this point. (Ported from amdgpu commit 4e7a24ac5a64e402146953ec5850d13c05742116)
2018-12-28Explicitly keep track of whether a DRM event is for a flip or notMichel Dänzer
When an async flip is performed, and TearFree is enabled on the CRTC used for timing, we schedule a vblank event for completing the page flip. The DRM event queuing code treated this event like a vblank event, but it needs to be treated like a page flip event. (Ported from amdgpu commit e2c7369cae65069aa93eed1c0b678f975ce5c274)
2018-12-28Skip gamma correction of cursor data if premultiplied R/G/B > alphaMichel Dänzer
The un-premultiplied R/G/B values would overflow the gamma LUT, so just pass through the data unchanged, and leave it up to the HW how to interpret such weird premultiplied alpha pixels. Bugzilla: https://bugs.freedesktop.org/108355 (Ported from amdgpu commit 13c94a373b4858a2d2aa14c22b5f98d53c84c0d9)
2018-12-20Detect and fix up non-premultiplied cursor dataMichel Dänzer
X server >= 1.18 already has code for this, but handle it with older X servers as well. (Ported from amdgpu commits ad6dfb0124860cf67730bde85867f81d9258c84d & 426f9a49655f01863cf4d898f525e5f95984e0c4)
2018-12-18Fix crash when page flipping in multi-X-Screen/Zaphod modeMario Kleiner
radeon_do_pageflip() indexed the flipdata->fb[] array indexing over config->num_crtc, but the flip completion routines, e.g., drmmode_flip_handler(), index that array via the crtc hw id from drmmode_get_crtc_id(crtc). This is mismatched and causes indexing into the wrong array slot at flip completion -> Server crash. Always use drmmode_get_crtc_id(crtc) for indexing into the array to fix this. Tested on a dual-X-Screen setup with one video output assigned to each X-Screen, page-flipping an OpenGL app on either of both X-Screens. This used to crash when flipping on X-Screen 1, now it doesn't anymore. Fixes: 740f0850f1e4 "Store FB for each CRTC in drmmode_flipdata_rec" Reviewed-by: Michel Dänzer <michel.daenzer@amd.com> Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
2018-10-24Allow up to six instances in Zaphod modeMichel Dänzer
Corresponding to up to six CRTCs being available in the hardware. (Ported from amdgpu commit c9d43c1deb9a9cfc41a8d6439caf46d12d220853)
2018-10-24Make wait_pending_flip / handle_deferred symmetric in set_mode_majorMichel Dänzer
We were always calling the latter, but not always the former, which could result in handling deferred DRM events prematurely. (Ported from amdgpu commit 955373a3e69baa241a1f267e96d04ddb902f689f)
2018-10-24Handle pending scanout update in drmmode_crtc_scanout_freeMichel Dänzer
We have to wait for a pending scanout flip or abort a pending scanout update, otherwise the corresponding event handler will likely crash after drmmode_crtc_scanout_free cleaned up the data structures. Fixes crash after VT switch while dedicated scanout pixmaps are enabled for any CRTC. (Ported from amdgpu commit 0cd2c337d2c02b8ec2bd994d6124b4aaaad10741)
2018-08-17Defer vblank event handling while waiting for a pending flipMichel Dänzer
This is to avoid submitting more flips while we are waiting for pending ones to complete. (Ported from amdgpu commit e52872da69ecc84dafb3355839e35b0383f0d228) Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-08-17Add radeon_drm_handle_event wrapper for drmHandleEventMichel Dänzer
Instead of processing DRM events directly from drmHandleEvent's callbacks, there are three phases: 1. drmHandleEvent is called, and signalled events are re-queued to _signalled lists from its callbacks. 2. Signalled page flip completion events are processed. 3. Signalled vblank events are processed. This should make sure that we never call drmHandleEvent from one of its callbacks, which would usually result in blocking forever. (Ported from amdgpu commit 739181c8d3334ff14b5a607895dfdeb29b0d9020) Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-08-17Add radeon_drm_wait_pending_flip functionMichel Dänzer
Replacing the drmmode_crtc_wait_pending_event macro. (Ported from amdgpu commit 6029794e8a35417faf825491a89b85f713c77fc1) Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-08-17Move DRM event queue related initialization to radeon_drm_queue_initMichel Dänzer
And make radeon_drm_queue_handler not directly accessible outside of radeon_drm_queue.c. (Ported from amdgpu commit 0148283984c77f7a6e97026edc3093497547e0a4) Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-08-16Use correct FB handle in radeon_do_pageflipMichel Dänzer
We were always using the handle of the client provided FB, which prevented RandR transforms from working, and could result in a black screen. Bugzilla: https://bugs.freedesktop.org/107519 Fixes: 740f0850f1e4 "Store FB for each CRTC in drmmode_flipdata_rec" (Ported from amdgpu commit f6cd72e64e85896b6d155bee0930e59771dcb701) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-08-03Store FB for each CRTC in drmmode_flipdata_recMichel Dänzer
We were only storing the FB provided by the client, but on CRTCs with TearFree enabled, we use a separate FB. This could cause drmmode_flip_handler to fail to clear drmmode_crtc->flip_pending, which could result in a hang when waiting for the pending flip to complete. We were trying to avoid that by always clearing drmmode_crtc->flip_pending when TearFree is enabled, but that wasn't reliable, because drmmode_crtc->tear_free can already be FALSE at this point when disabling TearFree. Now that we're keeping track of each CRTC's flip FB separately, drmmode_flip_handler can reliably clear flip_pending, and we no longer need the TearFree hack. (Ported from amdgpu commit 9b6782c821e0bdc53336d98f87ddde752faf7902) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-24Use strcpy for RandR output property namesMichel Dänzer
Instead of strncpy with the string length. Avoids new warnings with GCC 8: ../../src/drmmode_display.c: In function ‘drmmode_output_create_resources’: ../../src/drmmode_display.c:2240:2: warning: ‘strncpy’ output truncated before terminating nul copying 8 bytes from a string of the same length [-Wstringop-truncation] strncpy(tearfree_prop->name, "TearFree", 8); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../src/drmmode_display.c:2244:2: warning: ‘strncpy’ output truncated before terminating nul copying 3 bytes from a string of the same length [-Wstringop-truncation] strncpy(tearfree_prop->enums[0].name, "off", 3); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../src/drmmode_display.c:2245:2: warning: ‘strncpy’ output truncated before terminating nul copying 2 bytes from a string of the same length [-Wstringop-truncation] strncpy(tearfree_prop->enums[1].name, "on", 2); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../src/drmmode_display.c:2247:2: warning: ‘strncpy’ output truncated before terminating nul copying 4 bytes from a string of the same length [-Wstringop-truncation] strncpy(tearfree_prop->enums[2].name, "auto", 4); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ (Ported from amdgpu commit f3b2ed37d683f8616a0a31ff63133ddb8fe1a4a3) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-23Remove drmmode_terminate_leasesMichel Dänzer
The RandR screen private is already freed when our CloseScreen runs, so this can't do anything useful. This cleanup has to be done by the X server itself. (Ported from amdgpu commit 5f06d6b8ba570b500956ad26fee711d5ac427818) Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-23Hardcode "non-desktop" RandR property nameMichel Dänzer
It's a bit silly to require current randrproto just for this definition, which can't really change anyway. Suggested-by: Qiang Yu <qiang.yu@amd.com> (Ported from amdgpu commit ae8e02c6fc4ef5d5340b8cd4739e66b19b9e3386) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-19Don't allocate drmmode_output->props twiceMichel Dänzer
This was accidentally duplicated when porting RandR lease support from amdgpu. Trivial.
2018-07-12Add RandR leases supportKeith Packard
Signed-off-by: Keith Packard <keithp@keithp.com> (Ported from xserver commit e4e3447603b5fd3a38a92c3f972396d1f81168ad) Signed-off-by: Michel Dänzer <michel.daenzer@amd.com> (Ported from amdgpu commit 61040bdfa360975614fb47aa7ea1b3a1abac3427) Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-12modesetting: Create CONNECTOR_ID properties for outputs [v2]Keith Packard
This lets a DRM client map between X outputs and kernel connectors. v2: Change CONNECTOR_ID to enum -- Adam Jackson <ajax@nwnk.net> Signed-off-by: Keith Packard <keithp@keithp.com> (Ported from xserver commit 023d4aba8d45e9e3630b944ecfb650c081799b96) Signed-off-by: Michel Dänzer <michel.daenzer@amd.com> (Ported from amdgpu commit ab7e39c5a03e24c3ce3ee2f22ada7572bc2d9aa7) Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-12modesetting: Record non-desktop kernel property at PreInit timeKeith Packard
Save any value of the kernel non-desktop property in the xf86Output structure to avoid non-desktop outputs in the default configuration. [Also bump randrproto requirement to a version that defines RR_PROPERTY_NON_DESKTOP - ajax] Signed-off-by: Keith Packard <keithp@keithp.com> (Ported from xserver commit b91c787c4cd2d20685db69426c539938c556128a) Signed-off-by: Michel Dänzer <michel.daenzer@amd.com> (Ported from amdgpu commit 14db71a606128c4a207f43298809af279b77e2a8) Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-12Call drmmode_crtc_gamma_do_set from drmmode_setup_colormapMichel Dänzer
Instead of from drmmode_set_mode_major. There's no need to re-set the gamma LUT on every modeset, the kernel should preserve it. (Ported from amdgpu commit baea4fa492f635cdfe746a84be2e337d9aeae8a9) Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-12Remove #if 0'd codeMichel Dänzer
This has always been disabled, no need to keep it. (Ported from amdgpu commit 19a40758be04e1d451a030f452efb49e8aaad541) Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-12Check dimensions passed to drmmode_xf86crtc_resizeMichel Dänzer
When enabling a secondary GPU output, Xorg can try resizing the screen beyond the limit advertised by the driver, leading to drmModeAddFB failing and primary GPU outputs turning off. Check for this and bail instead. (Ported from amdgpu commit 940c8b39f79789d4d5ddb8ab8d25a8ae05932756) Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-12Use drmmode_crtc_dpms in drmmode_set_desired_modesMichel Dänzer
Simplifies the latter slightly. (Ported from amdgpu commit 74124f2c17dbb4b752707bb7eee398ae099e8a2c) Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-12Call drmmode_do_crtc_dpms from drmmode_crtc_dpms as wellMichel Dänzer
Leo pointed out that drmmode_do_crtc_dpms wasn't getting called when turning off an output with xrandr --output <output> --off This meant that the vblank sequence number and timestamp wouldn't be saved before turning off the CRTC in this case. Reported-by: Leo (Sunpeng) Li <sunpeng.li@amd.com> (Ported from amdgpu commit ceeacb455cd058492a493aac954deab8455804b5) Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-12Replace 'foo == NULL' with '!foo'Michel Dänzer
Shorter and sweeter. :) (Ported from amdgpu commit e8e688f3852fb06b0c34ed5bce47c9493bcd1613) Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-12Wait for pending flips in drmmode_output_set_tear_freeMichel Dänzer
This prevents a nested call to drmHandleEvent, which would hang. Fixes hangs when disabling TearFree on a CRTC while a DRI3 client is page flipping. (Ported from amdgpu commit 04947b83cce3a7782e59dece2c7797cc396c1e05) Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-12Refactor drmmode_output_set_tear_free helperMichel Dänzer
Preparation for the following fix, no functional change intended. (Ported from amdgpu commit fa30f4601de7a44edfb4a95873bd648946fd4292) Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-12Set drmmode_crtc->scanout_id = 0 when TearFree is disabledMichel Dänzer
When disabling TearFree, drmmode_crtc->scanout_id could remain as 1, but drmmode_set_mode_major would destroy drmmode_crtc->scanout[1], so scanout_do_update() would keep bailing, and the scanout buffer would stop being updated. Fixes freeze after disabling TearFree on a CRTC with active RandR rotation or other transform. (Ported from amdgpu commit 7db0c8e9d7586cff4312d4b93684d35de3e6376f) Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-12Simplify drmmode_handle_transformMichel Dänzer
Set crtc->driverIsPerformingTransform for any case we can handle before calling xf86CrtcRotate. We already clear it afterwards when the latter clears crtc->transform_in_use. This should allow our separate scanout buffer mechanism to be used in more cases. (Cherry picked from amdgpu commit 8e544b4a0de6717feb4abf00052d57c5b726b5ce) Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-12Simplify drmmode_crtc_scanout_updateMichel Dänzer
Use our own BoxRec for the extents, and RegionEmpty for clearing the scanout damage region. (Ported from amdgpu commit 72c3e9c7308fbcdf85708b72f9be14a5f2f8e7b5) Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-12Update RandR CRTC state if set_mode_major fails in set_desired_modesMichel Dänzer
Without this, RandR would report the CRTC and its outputs as enabled, even though they were actually off due to the failure. (Cherry picked from amdgpu commit 4dcda0b48d62944c841cd9540f4ad4c7ac8dee47) Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-12Abort scanout_update_pending event when possibleMichel Dänzer
We don't need to wait for a non-TearFree scanout update before scanning out from the screen pixmap or before flipping, as the scanout update won't be visible anyway. Instead, just abort it. (Ported from amdgpu commit 36d01989cd842588f12fdae5b2cba5fdcf9c91dd) Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-11Wait for pending scanout update before calling drmmode_crtc_scanout_freeJim Qu
There is a case that when set screen from reverse to normal, the old scanout damage is freed in modesetting before scanout update handler, so it causes segment fault issue. Signed-off-by: Jim Qu <Jim.Qu@amd.com> [ Michel Dänzer: Only call drmmode_crtc_wait_pending_event before drmmode_crtc_scanout_free is actually called, slightly tweak commit message ] Signed-off-by: Michel Dänzer <michel.daenzer@amd.com> (Ported from amdgpu commit 9f6a8905611b5b1d8fcd31bebbc9af7ca1355cc3) Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-09glamor: Use GBM for BO allocation when possibleMichel Dänzer
Inspired by amdgpu. This avoids various issues due to a GEM handle lifetime conflict between us and Mesa with current glamor. Bugzilla: https://bugs.freedesktop.org/105381 Tested-by: Konstantin Kharlamov <hi-angel@yandex.ru> Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-09Add struct radeon_bufferMichel Dänzer
Inspired by amdgpu, preparation for the following change. For now, this is mostly a wrapper around struct radeon_bo, no functional change intended. Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-09Refactor radeon_finish helperMichel Dänzer
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>