summaryrefslogtreecommitdiff
path: root/src/drmmode_display.c
AgeCommit message (Collapse)Author
2018-03-02modesetting: Update property values at detect and uevent timeKeith Packard
We were updating the link-status property when a uevent came in, but we also want to update the non-desktop property, and potentially others as well. We also want to check at detect time in case we don't get a hotplug event. This patch updates every property provided by the kernel, sending changes to DIX so it can track things as well. Signed-off-by: Keith Packard <keithp@keithp.com> (Ported from xserver commit a12485ed846b852ca14d17d1e58c8b0f2399e577, slightly modifying logic to reduce indentation depth) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-03-02modesetting: Reset output_id if drmModeGetConnector failedDaniel Martin
If drmModeGetConnector() fails in drmmode_output_detect(), we have to reset the output_id to -1 too. Yet another spot leading to a potential NULL dereference when handling the mode_output member as output_id was != -1. Though, this case should be very hard to hit. Signed-off-by: Daniel Martin <consume.noise@gmail.com> (Ported from xserver commit 6804875662363764683a86c1614e4cf3cc70a20a) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-03-02modesetting: Use helper to fetch drmModeProperty(Blob)sDaniel Martin
Replace the various loops to lookup drmModeProperty(Blob)s by introducing helper functions. Signed-off-by: Daniel Martin <consume.noise@gmail.com> (Ported from xserver commit f44935cdb7321af242ce9f242975f096807b97f7) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-02-16Disable all unused CRTCs before setting desired modesMichel Dänzer
This might avoid modeset failures in some cases where a CRTC which isn't used by Xorg was enabled before.
2018-02-15Don't bail from drmmode_set_desired_modes immediatelyMichel Dänzer
If we fail to find or set the mode for a CRTC, keep trying for the remaining CRTCs, and only return FALSE if we failed for all CRTCs that should be on. Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Acked-by: Harry Wentland <harry.wentland@amd.com>
2018-02-14Always use screen depth/bpp for KMS framebuffersMichel Dänzer
DRI clients can use depth 32 pixmaps while the screen is depth 24, in which case page flipping would fail. Reported-by: Mario Kleiner <mario.kleiner.de@gmail.com> (Ported from radeon commit 733f606dd6ca8350e6e7f0858bfff5454ddc98ed) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-02-14Disable gamma set when deep colorQiang Yu
gamma set is disabled in kernel driver when deep color. Enable it will confuse the user. Signed-off-by: Qiang Yu <Qiang.Yu@amd.com> [ Michel Dänzer: Align drmmode_pre_init change with radeon commit 1f1d4b1fa7d4b22dd8553f7e71251bf17ca7a7b1 ] Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-02-12Define per x-screen individual drmmode_crtc_funcsMario Kleiner
This allows to en-/disable some functions depending on individual screen settings. Prep work for more efficient depth 30 support. Suggested-by: Michel Dänzer <michel.daenzer@amd.com> Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com> (Ported from radeon commit 21f6753462464acfd3c452393328c977a375ce26) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-12-27Keep track of how many SW cursors are visible on each screenMichel Dänzer
And use this to determine when we cannot use page flipping for DRI clients. We previously did this based on whether the HW cursor cannot be used on at least one CRTC, which had at least two issues: * Even while the HW cursor cannot be used, no SW cursor may actually be visible (e.g. because all cursors are disabled), in which case we can use page flipping for DRI clients anyway * Even while the HW cursor can be used, there may be SW cursors visible from non-core pointer devices, in which case we cannot use page flipping for DRI clients anyway Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-11-01modesetting: Check crtc before searching link-status propertyDaniel Martin
No need to lookup the link-status property if we don't have a crtc. Signed-off-by: Daniel Martin <consume.noise@gmail.com> (Ported from xserver commit 8d7f7e24261e68459e6f0a865e243473f65fe7ad) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-10-20modesetting: Skip no-longer-present connectors when resetting BAD linksKeith Packard
Outputs may have NULL mode_output (connector) pointers if the connector disappears while the server is running. Skip these when resetting outputs with BAD link status. (Ported from xserver commit 37f4e7651a2fd51efa613a08a1e705553be33e76) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-10-20Always call drmModeFreeProperty after drmModeGetPropertyMichel Dänzer
We were not doing so in all cases, leaking memory allocated by the latter. Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-08-31Require xserver >= 1.13Michel Dänzer
xserver 1.13.0 was released on September 6th, 2012, almost 5 years ago. This allows cleaning up a bunch of backwards compatibility code. (Ported from radeon commit 5cdd334b3402c2431deb3a87a8d04ef590da53ee) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-08-30Remove drmmode_scanout_freeMichel Dänzer
Not used anymore. (Cherry picked from radeon commit e4a3df19d588a4310fcb889ef34e205d0e92e4d7) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-08-30Make all active CRTCs scan out an all-black framebuffer in LeaveVTMichel Dänzer
And destroy all other FBs. This is so that other DRM masters can only get access to this all-black FB, not to any other FB we created, while we're switched away and not DRM master. Fixes: b09fde0d81e0 ("Use reference counting for tracking KMS framebuffer lifetimes") (Ported from radeon commit 06a465484101f21e99d3a0a62fb03440bcaff93e) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-08-30Create drmmode_set_mode helperMichel Dänzer
Preparatory, no functional change intended yet. (Ported from radeon commit 4bc992c31059eb50e22df4ebf5b92d08411f41ef) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-08-29Create amdgpu_pixmap_clear helperMichel Dänzer
Preparatory, no functional change intended yet. (Ported from radeon commit 3f6210ca2c8ef60d59efc8139151d3b9838bb875) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-08-22modesetting: re-set the crtc's mode when link-status goes BADMartin Peres
Despite all the careful planning of the kernel, a link may become insufficient to handle the currently-set mode. At this point, the kernel should mark this particular configuration as being broken and potentially prune the mode before setting the offending connector's link-status to BAD and send the userspace a hotplug event. This may happen right after a modeset or later on. Upon receiving a hot-plug event, we iterate through the connectors to re-apply the currently-set mode on all the connectors that have a link-status property set to BAD. The kernel may be able to get the link to work by dropping to using a lower link bpp (with the same display bpp). However, the modeset may fail if the kernel has pruned the mode, so to make users aware of this problem a warning is outputed in the logs to warn about having a potentially-black display. This patch does not modify the current behaviour of always propagating the events to the randr clients. This allows desktop environments to re-probe the connectors and select a new resolution based on the new (currated) mode list if a mode disapeared. This behaviour is expected in order to pass the Display Port compliance tests. (Ported from xserver commit bcee1b76aa0db8525b491485e90b8740763d7de6) [ Michel: Bump libdrm dependency to >= 2.4.78 for DRM_MODE_LINK_STATUS_BAD ] (Ported from radeon commit 0472a605e0ec8fec1892bbc3a84698b7ef9c5296) Acked-by: Harry Wentland <harry.wentland@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-08-22Make amdgpu_scanout_do_update take a PixmapPtr instead of a DrawablePtrMichel Dänzer
All callers were already passing in a pixmap. This allows simplifying the rotated scanout case slightly. (Ported from radeon commit d822a0f47070374ad0c1a97b559bae27724dc52a) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-08-22Always allow Present page flipping with TearFreeMichel Dänzer
Even if TearFree is active for the the CRTC we're synchronizing to. In that case, for Present flips synchronized to vertical blank, the other scanout buffer is immediately synchronized and flipped to during the target vertical blank period. For Present flips not synchronized to vertical blank, we simply use the MSC and timestamp values of the last vertical blank period for timing purposes, and let the normal TearFree mechanism handle display updates. (Ported from radeon commit 4445765af5b97d0cfd10889fe6d6f58f2ce85659) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-08-22Pass extents to amdgpu_scanout_do_updateMichel Dänzer
Preparation for following change, no functional change intended yet. (Ported from radeon commit 65e0c5ea1b4adff21d673dbf54af99704c429627) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-08-22Add source drawable parameter to amdgpu_scanout_do_updateMichel Dänzer
Preparation for following changes, no functional change intended yet. (Ported from radeon commit 1443270e52e8562bd8dc3603f301963bd4027cef) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-08-22Handle multiple "pending" Present flipsMichel Dänzer
The xserver Present code can submit a flip in response to notifying it that a vblank event arrived. This can happen before the completion event of the previous flip is processed. In that case, we were clearing the drmmode_crtc->flip_pending field prematurely. Prevent this by only clearing drmmode_crtc->flip_pending when it matches the framebuffer being scanned out since the flip whose completion event we're processing. (Ported from radeon commit 7c10ee9c88378d773c0bcf651fdc5d9f2c6dc5e5) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-08-22Wait for pending flips synchronously before turning off a CRTCMichel Dänzer
Allows removing drmmode_clear_pending_flip and the pending_dpms_mode field and cleaning up the code considerably. (Ported from radeon commit e6d7dc2070f4d21a6900916bb70a31839112882c) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-08-22Create drmmode_crtc_wait_pending_event helper macroMichel Dänzer
Preparation for following change, no functional change intended yet. (Ported from radeon commit f87acdbfb1b0b6d2769764772a52ea8b81675e20) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-08-22Create drmmode_wait_vblank helperMichel Dänzer
Allows cleaning up the code considerably. (Ported from radeon commit 99f1d7a474af3683fe1a66f50c0bb8935478ff0a) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-08-22Pass reference CRTC to amdgpu_do_pageflip directlyMichel Dänzer
Simplifies the code slightly. (Ported from radeon commit 49cc61ab970ee28d4509b4e2dd0a57165136889f) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-08-18Remove drmmode_crtc->scanout_destroy[] arrayMichel Dänzer
No longer necessary since we're reference counting framebuffers. (Ported from radeon commit 3f120fa1d5d921656a367751bc079e020e9ab105) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-08-15Adapt to PixmapDirtyUpdateRec::src being a DrawablePtrMichel Dänzer
2017-08-03Allow DRI page flipping when some CRTCs use separate scanout buffersMichel Dänzer
As long as the CRTC we're synchronizing to doesn't. (Ported from radeon commit 5309bde0c4e28adf2b167191c6d7011a19e31eed) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-08-02Use root window (pixmap) instead of screen pixmap for scanout updatesMichel Dänzer
Preparation for following changes, no functional change intended yet. (Ported from radeon commit c2d26890691ec105858f086b63170ad94c6f7f05) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-07-27Only handle reflection in the driver with Xorg < 1.16Michel Dänzer
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: ba2aa0a8c12a ("Handle rotation in the driver also with Xorg 1.12-1.18") (Cherry picked from radeon commit 7d7abf99b5441ddb04dbee99bc8fa7abc30d4c46) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-07-26If a TearFree flip fails, fall back to non-TearFree operationMichel Dänzer
In order to avoid possible freeze / log file spam in that case. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99769 (Ported from radeon commit 94dc2b80f3ef0b2c17c20501d824fb0447d52e7a) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-06-21Increase reference count of FB assigned to drmmode_crtc->flip_pendingMichel Dänzer
Otherwise, it could happen that we destroy the FB before the flip completes, resulting in use-after-free and most likely a crash. Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-06-15modesetting: Validate the atom for enum propertiesAdam Jackson
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-05-26Use reference counting for tracking KMS framebuffer lifetimesMichel Dänzer
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 (Ported from radeon commit 55e513b978b2afc52b7cafc5bfcb0d1dc78d75f6) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-05-24Simplify tracking of PRIME scanout pixmapMichel Dänzer
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. (Ported from radeon commit 7dc68e26755466f9056f8c72195ab8690660693d) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-05-10Remove unused struct members from drmmode_display.hMichel Dänzer
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-05-02Apply gamma correction to HW cursorMichel Dänzer
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. Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-04-17Don't set modes before AMDGPUWindowExposures_oneshot is calledMichel Dänzer
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: ad53635af150 ("Move DPMS check from amdgpu_scanout_do_update to amdgpu_scanout_flip") Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-04-10Set correct DRM event context versionDaniel Stone
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-03-07Don't call amdgpu_glamor_flush in drmmode_copy_fbMichel Dänzer
AMDGPUWindowExposures_oneshot takes care of it. (Ported from radeon commit d63881623f0686a66a2e3e3c1f84e496aa52ec6b) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-03-03Use drmmode_crtc_scanout_free in drmmode_finiMichel Dänzer
We were leaking drmmode_crtc->scanout_damage, which caused trouble on server reset. Fixes server reset with active separate scanout pixmaps. (Cherry picked from radeon commit 0c29deb5a97d9a57e994cc0053c49ddf7aca6ecb) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-03-03Allow toggling TearFree at runtime via output propertyMichel Dänzer
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. (Ported from radeon commit 58cd1600057e41aade0106d4acf78e23eac6e44f) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-03-03Factor out drmmode_crtc_scanout_update helperMichel Dänzer
Cleanup in preparation for following change, no functional change intended. (Ported from radeon commit 305e2cbf335837a2ab6a24e9ff65815afe038296) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-03-03Don't destroy current FB if drmModeAddFB failsMichel Dänzer
It would probably result in a black screen. (Ported from radeon commit 1351e48efe7a2c28eab447e16f36a00fbd02ae48) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-03-03Fix flip event data leak if calloc or drmModeAddFB failsMichel Dänzer
(Ported from radeon commit 481394e3c9f9f7d88bb66fe9ae8834c87952a8ab) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-03-03Handle rotation in the driver also with Xorg 1.12-1.18Michel Dänzer
We cannot use the HW cursor in that case, but in turn we get more efficient and less teary updates of rotated outputs. (Ported from radeon commit f2bc882f1c1082bed9f496cfab6c8f07a76bc122) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-03-03Fold drmmode_crtc_scanout_allocate into drmmode_crtc_scanout_createMichel Dänzer
Not used anywhere else anymore. (Ported from radeon commit ae921a3150f69c38b5b3c88a9e37d54fdf0d5093) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-03-02Call drmmode_crtc_scanout_create in drmmode_crtc_shadow_allocate as wellMichel Dänzer
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: 5f7123808833 ("Pass pitch from drmmode_crtc_scanout_allocate to drmmode_create_bo_pixmap") (Ported from radeon commit 987a34adb319923ad36e2b47a26837248f187c3e) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>