summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)AuthorFilesLines
2018-12-13Drop AMDGPUInfoRec::cursor_buffer arrayMichel Dänzer4-24/+9
Not needed or even useful for anything. Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-12-13Don't use GBM for allocating HW cursor BOsMichel Dänzer2-54/+14
GBM doesn't really buy us anything for the cursor BOs. This simplifies the code and following changes. Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-12-13Automatically try re-enabling TearFree after a flip failedMichel Dänzer2-11/+71
Specifically, after both the page flip and vblank ioctls failed, but then the vblank ioctl started working again. This can happen intermittently e.g. when hotplugging a DP display. Previously, TearFree would stay disabled in that case until a modeset was triggered somehow. Bugzilla: https://bugs.freedesktop.org/103791 Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-12-13Cancel pending scanout update in drmmode_crtc_scanout_updateMichel Dänzer1-5/+11
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. Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-12-13Perform scanout buffer update immediately if drmmode_wait_vblank failsMichel Dänzer1-10/+19
Otherwise the damaged screen contents may never be displayed in that case. Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-11-30Support CRTC variable refresh for windows using Present flipsNicholas Kazlauskas5-0/+181
This patch adds support for setting the CRTC variable refresh property for suitable windows flipping via the Present extension. The "VariableRefresh" Option is added to AMDGPU in this patch. This option defaults to false, and must be set to "true" in an X conf file for variable refresh support in the driver. In order for a window to be suitable for variable refresh it must have the _VARIABLE_REFRESH property with a 32-bit CARDINAL value of 1. Then the window must pass the checks required to be suitable for Present extension flips - it must cover the entire X screen and no other window may already be flipping. With these conditions met every CRTC for the X screen will have their variable refresh property set to true. Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
2018-11-30Check last flip window instead of screen root before flippingNicholas Kazlauskas2-2/+6
A significant amount of time can pass between the X call into check_flip for a window and when amdgpu_present_flip actually occurs. To ensure that flipping is still possible there was an additional check performed on screen->root in amdgpu_present_flip - but what should be checked instead is the window itself. This only really worked before because X ensures that the window has the same dimensions as the screen to allow for present extension flipping. This patch tracks the flip window between calls to check_flip and flip and uses that window instead of screen->root. Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
2018-11-20Skip gamma correction of cursor data if premultiplied R/G/B > alphaMichel Dänzer1-13/+21
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
2018-11-16Move deferred vblank events to separate drm_vblank_deferred listMichel Dänzer1-11/+46
It was still possible for nested xorg_list_for_each_entry_safe loops to occur over the drm_vblank_signalled list, which could mess up that list. Moving deferred events to a separate list allows processing the drm_vblank_signalled list without xorg_list_for_each_entry_safe. v2: * Refactor drm_handle_vblank_signalled helper function, less code duplication => better readability (Alex Deucher) Bugzilla: https://bugs.freedesktop.org/108600 Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-11-16Explicitly keep track of whether a DRM event is for a flip or notMichel Dänzer6-37/+25
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. Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-11-16Use drm_abort_one in drm_queue_handlerMichel Dänzer1-14/+14
At this point, we've already established that e->handler is NULL, no need to check again in drm_queue_handle_one. This also makes it clearer what's happening. Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-11-15Relax detection of non-premultiplied alpha cursor dataMichel Dänzer1-2/+2
The stricter detection broke the cursor in some games. Apparently those use cursor data with premultiplied alpha, but with some pixels having r/g/b values larger than the alpha value (which corresponds to original r/g/b values > 1.0), triggering the workaround. Relax the detection to match what's in the X server since 1.18.4, but keep the workaround for older versions. Bugzilla: https://bugs.freedesktop.org/108650 Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-10-29glamor: Can work at depth >= 15 with current xserver Git masterMichel Dänzer2-1/+9
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-10-25Detect and fix up non-premultiplied cursor dataMichel Dänzer1-31/+60
X server >= 1.18 already had code for this, but it only caught cases where some pixels have 0 for alpha and non-0 for a non-alpha component. Turns out some apps (e.g. the Civilization VI game) use non-premultiplied cursor data which doesn't have such pixels, but can still result in visual artifacts. This uses the method suggested by Kamil in https://bugs.freedesktop.org/92309#c19: check for pixels where any colour component value is larger than the alpha value, which isn't possible with premultiplied alpha. There can still be non-premultiplied data which won't be caught by this, but that should result in slightly incorrect colours and/or blending at the worst, not wildly incorrect colours such as shown in the bug report below. v2: * Disable the check with current xserver Git master, which already does the same check now. Bugzilla: https://bugs.freedesktop.org/108355 Suggested-by: Kamil Páral <kamil.paral@gmail.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-10-11Allow up to six instances in Zaphod modeMichel Dänzer5-39/+59
Corresponding to up to six CRTCs being available in the hardware. v2: * Move instance overflow check from PreInit to the probe hooks, in order to further minimize wasted effort. Reviewed-by: Alex Deucher <alexander.deucher@amd.com> # v1
2018-10-10Fix condition for calling set_pixmap_bo in drmmode_xf86crtc_resizeMichel Dänzer1-2/+1
This matches CreateScreenResources_KMS. Fixes crash when resizing the screen (e.g. using xrandr) with depth < 24. Bugzilla: https://bugs.freedesktop.org/104914 Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-10-02Fix --disable-glamor buildMichel Dänzer4-4/+44
We were still relying on the glamor.h header being picked up implicitly.
2018-10-02Cast return value of amdgpu_get_marketing_name to char*Michel Dänzer1-1/+1
Avoids compiler warning with xserver < 1.16: ../../src/amdgpu_kms.c: In function ‘AMDGPUPreInitChipType_KMS’: ../../src/amdgpu_kms.c:1203:17: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers] pScrn->chipset = amdgpu_get_marketing_name(pAMDGPUEnt->pDev); ^
2018-09-26Make wait_pending_flip / handle_deferred symmetric in set_mode_majorMichel Dänzer1-1/+5
We were always calling the latter, but not always the former, which could result in handling deferred DRM events prematurely. Acked-by: Slava Abramov <slava.abramov@amd.com> Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-09-26Handle pending scanout update in drmmode_crtc_scanout_freeMichel Dänzer3-11/+18
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. Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-09-13Bail from drmmode_cm_init if there's no CRTCMichel Dänzer1-0/+3
We would crash due to dereferencing the NULL mode_res->crtc pointer. Bugzilla: https://bugs.freedesktop.org/107913 Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-09-05Bail early from drm_wait_pending_flip if there's no pending flipMichel Dänzer1-1/+2
No need to process any events in that case. v2: * Re-check drmmode_crtc->flip_pending after processing each event
2018-09-05Do not push the CM_GAMMA_LUT property values in drmmode_crtc_cm_initMichel Dänzer1-1/+1
The crtc->gamma_lut values aren't initialized yet at this point, and the property values are pushed again from drmmode_setup_colormap anyway. Fixes intermittent flicker due to random gamma LUT values during server startup. Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-08-31Don't use xorg_list_for_each_entry_safe for signalled flipsMichel Dänzer1-3/+9
drm_wait_pending_flip can get called from drm_handle_event, in which case xorg_list_for_each_entry_safe can end up processing the same entry in both. To avoid this, just process the first list entry until the list is empty.
2018-08-31Always delete entry from list in drm_queue_handlerMichel Dänzer1-1/+1
We left entries without a handler hook in the list, so the list could keep taking longer to process and use up more memory.
2018-08-30glamor: Handle ihandle == -1 in amdgpu_glamor_set_shared_pixmap_backingMichel Dänzer1-1/+3
(Ported from radeon commit de88ea2755611bdcb18d91d8234d2ab5be8ff2e9) Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-08-29Handle ihandle == -1 in amdgpu_set_shared_pixmap_backingMichel Dänzer1-0/+3
It means to stop using the shared pixmap backing. (Ported from radeon commit 1799680f7bd84e0618f34f4c7486799521ddaf83) Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-08-16Use correct FB handle in amdgpu_do_pageflipMichel Dänzer1-2/+2
We were always using the handle of the client provided FB, which prevented RandR transforms from working, and could result in a black screen. Fixes: 9b6782c821e0 "Store FB for each CRTC in drmmode_flipdata_rec" Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-08-16Remove drmmode_crtc_private_rec::present_vblank_* related codeMichel Dänzer3-47/+3
Not needed anymore with the more robust mechanisms for preventing nested drmHandleEvent calls introduced in the previous changes. Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-08-16Defer vblank event handling while waiting for a pending flipMichel Dänzer4-8/+56
This is to avoid submitting more flips while we are waiting for pending ones to complete. Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-08-16Add amdgpu_drm_handle_event wrapper for drmHandleEventMichel Dänzer4-18/+83
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.
2018-08-16Add amdgpu_drm_wait_pending_flip functionMichel Dänzer3-18/+18
Replacing the drmmode_crtc_wait_pending_event macro. Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-08-16Move DRM event queue related initialization to amdgpu_drm_queue_initMichel Dänzer5-17/+19
And make amdgpu_drm_queue_handler not directly accessible outside of amdgpu_drm_queue.c. Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-08-16glamor: Check glamor module version for depth 30 supportMichel Dänzer2-12/+16
Instead of the Xorg version. This should allow glamor backported from xserver >= 1.20 to work with older Xorg versions. Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-08-02glamor: Use glamor_egl_create_textured_pixmap_from_gbm_bo when possibleMichel Dänzer1-14/+18
Inspired by the modesetting driver. (Ported from radeon commit db28d35ce9fd07a2a4703f3df0633d4c8291ff9b) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-27Store FB for each CRTC in drmmode_flipdata_recMichel Dänzer2-22/+27
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. Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-25glamor: Set AMDGPU_CREATE_PIXMAP_DRI2 for DRI3 pixmapsMichel Dänzer1-0/+1
Not doing this resulted in falling back to software for DRI3 client presentation operations with ShadowPrimary. Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-23Use strcpy for RandR output property namesMichel Dänzer1-4/+4
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); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Reviewed-by: Slava Abramov <slava.abramov@amd.com>
2018-07-23Remove drmmode_terminate_leasesMichel Dänzer3-23/+0
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.
2018-07-20Remove AMDGPUInfoRec::fbcon_pixmapMichel Dänzer3-15/+2
We always destroy the fbcon pixmap in drmmode_copy_fb anyway. Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-20Don't use DRM_IOCTL_GEM_FLINK in create_pixmap_for_fbconMichel Dänzer1-27/+10
We don't need it.
2018-07-20Free previous xf86CrtcRec gamma LUT memoryMichel Dänzer1-1/+6
We were leaking it. Also, don't bother allocating new memory if it's already the expected size. Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-18Hardcode "non-desktop" RandR property nameMichel Dänzer1-1/+1
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> Reviewed-by: Qiang Yu <Qiang.Yu@amd.com>
2018-07-13Support gamma correction & colormaps at depth 30 as wellMichel Dänzer1-16/+34
Only supported with the advanced colour management properties available with DC as of kernel 4.17. Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-11Move flush from radeon_scanout_do_update to its callersMichel Dänzer2-3/+6
No functional change intended. (Ported from radeon commit 90b94d40449f665f2d12874598062a5e5e5b64cd) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-11glamor: Bail CreatePixmap on unsupported pixmap depthMichel Dänzer1-0/+3
Fixes crash in that case. Bugzilla: https://bugs.freedesktop.org/106293 (Ported from radeon commit 65c9dfea4e841b7d6f795c7489fede58c5e9631f) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-10Bail from dri2_create_buffer2 if we can't get a pixmapMichel Dänzer1-14/+12
We would store the NULL pointer and continue, which would lead to a crash down the road. Bugzilla: https://bugs.freedesktop.org/106293 (Ported from radeon commit 3dcfce8d0f495d09d7836caf98ef30d625b78a13) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-10Add RandR leases supportKeith Packard3-1/+165
Signed-off-by: Keith Packard <keithp@keithp.com> (Ported from xserver commit e4e3447603b5fd3a38a92c3f972396d1f81168ad) Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
2018-07-10modesetting: Create CONNECTOR_ID properties for outputs [v2]Keith Packard1-0/+22
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) Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
2018-07-06modesetting: Record non-desktop kernel property at PreInit timeKeith Packard1-0/+16
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) Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>