summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2018-07-06Add RandR leases with modesetting driver support [v7]HEADmasterKeith Packard3-1/+159
This adds support for RandR CRTC/Output leases through the modesetting driver, creating a lease using new kernel infrastructure and returning that to a client through an fd which will have access to only those resources. v2: Restore CRTC mode when leases terminate When a lease terminates for a crtc we have saved data for, go ahead and restore the saved mode. v3: Report RR_Rotate_0 rotations for leased crtcs. Ignore leased CRTCs when selecting screen size. Stop leasing encoders, the kernel doesn't do that anymore. Turn off crtc->enabled while leased so that modesetting ignores them. Check lease status before calling any driver mode functions When starting a lease, mark leased CRTCs as disabled and hide their cursors. Also, check to see if there are other non-leased CRTCs which are driving leased Outputs and mark them as disabled as well. Sometimes an application will lease an idle crtc instead of the one already associated with the leased output. When terminating a lease, reset any CRTCs which are driving outputs that are no longer leased so that they start working again. This required splitting the DIX level lease termination code into two pieces, one to remove the lease from the system (RRLeaseTerminated) and a new function that frees the lease data structure (RRLeaseFree). v4: Report RR_Rotate_0 rotation for leased crtcs. v5: Terminate all leases on server reset. Leases hang around after the associated client exits so that the client doesn't need to occupy an X server client slot and consume a file descriptor once it has gotten the output resources necessary. Any leases still hanging around when the X server resets or shuts down need to be cleaned up by calling the kernel to terminate the lease and freeing any DIX structures. Note that we cannot simply use the existing drmmode_terminate_lease function on each lease as that wants to also reset the video mode, and during server shut down that modesetting: Validate leases on VT enter The kernel doesn't allow any master ioctls to run when another VT is active, including simple things like listing the active leases. To deal with that, we check the list of leases whenever the X server VT is activated. xfree86: hide disabled cursors when resetting after lease termination The lessee may well have played with cursors and left one active on our screen. Just tell the kernel to turn it off. v6: Add meson build infrastructure v7: Make it build on X server 1.13 Remove drmmode_terminate_leases Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-07-06xf86-video-modesetting: Create CONNECTOR_ID properties for outputs [v2]Keith Packard1-0/+23
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> Reviewed-by: Adam Jackson <ajax@nwnk.net>
2018-07-06xf86-video-modesetting: Record non-desktop kernel property at PreInit time [v2]Keith Packard2-1/+20
Save any value of the kernel non-desktop property in the xf86Output structure to avoid non-desktop outputs in the default configuration. v2: Support X server 1.13 Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Adam Jackson <ajax@nwnk.net>
2018-06-28Call drmmode_crtc_gamma_do_set from drmmode_setup_colormapMichel Dänzer1-12/+17
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. Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-06-28Remove #if 0'd codeMichel Dänzer1-12/+0
This has always been disabled, no need to keep it. Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Reviewed-by: Slava Abramov <slava.abramov@amd.com>
2018-06-26Don't apply gamma to HW cursor data if colour management is enabledMichel Dänzer1-6/+19
In that case (with DC as of 4.17 kernels), the display hardware applies gamma to the HW cursor. v2: * Also use all 0s when alpha == 0 in the gamma passthrough case. Bugzilla: https://bugs.freedesktop.org/106578 Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-06-26Also compose LUT when setting legacy gammaLeo Li (Sunpeng)1-2/+14
We compose the two LUTs when pushing non-legacy gamma changes, and the same needs to be done when setting legacy gamma. To do so, we just call push_cm_prop() on the gamma LUT. It will compose the LUTs for us, and fall back to using legacy LUT (upscaled to non- legacy size) if non-legacy is unavailable. It's also possible that the Kernel has no support support for non- legacy color. In which case, we fall back to legacy gamma. v2: Remove per-CRTC check for color management support. Signed-off-by: Leo (Sunpeng) Li <sunpeng.li@amd.com> Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
2018-06-26Compose non-legacy with legacy regamma LUTLeo Li (Sunpeng)1-1/+186
Frequently, a user may have non-legacy gamma enabled for monitor correction, while using legacy gamma for things like redshift/nightlight. To do so, we compose the two LUTs. Legacy gamma will be applied first, then non-legacy. i.e. non-legacy_LUT(legacy_LUT(in_color)). Note that the staged gamma LUT within the driver-private CRTC will always contain the non-legacy LUT. This is to ensure that we have a cached copy for future compositions. v2: Don't compose LUTs if legacy gamma is disabled (which is the case for deep 30bpp color). The legacy LUT won't be computed here, causing composition to spit out something invalid. v3: Use LUT sizes that are now cached in drmmode. Signed-off-by: Leo (Sunpeng) Li <sunpeng.li@amd.com> [ Michel Dänzer: Replace "crtc->funcs->gamma_set == NULL" with !crtc->funcs->gamma_set ] Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
2018-06-26Enable setting of color properties via RandRLeo Li (Sunpeng)1-0/+95
Setting a color property involves: 1. Staging the property onto the driver-private CRTC object 2. Pushing the staged property into kernel DRM, for HW programming Add a function to do the staging, and execute the above steps in output_property_set. v2: - Remove per-CRTC check for color management support in stage_cm_prop. - Use switch statement instead of if statements. Signed-off-by: Leo (Sunpeng) Li <sunpeng.li@amd.com> Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
2018-06-26Update color properties on output_get_propertyLeo Li (Sunpeng)1-0/+21
Notify RandR of any updated color properties on the output's CRTC when its get_property() hook is called. v2: Remove per-CRTC check for color management support. Signed-off-by: Leo (Sunpeng) Li <sunpeng.li@amd.com> Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
2018-06-26Configure color properties when creating output resourcesLeo Li (Sunpeng)1-0/+131
List color management properties on outputs if there is kernel support. Otherwise, don't list them at all. v2: - Use switch statement in configure_and_change - Also configure LUT sizes for outputs that don't have an attached CRTC. We can do this since LUT sizes are now cached on the drmmode object. Signed-off-by: Leo (Sunpeng) Li <sunpeng.li@amd.com> [ Michel Dänzer: Drop const from data pointer declaration in rr_configure_and_change_cm_property, to avoid warning when building against xserver 1.13 ] Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
2018-06-26Initialize color properties on CRTC during CRTC initLeo Li (Sunpeng)2-1/+149
And destroy them on the CRTC destroy hook. When initializing color management properties on the private drmmode_crtc, we want to: 1. Default its color transform matrix (CTM) to identity 2. Program hardware with default color management values (SRGB for de/regamma, identity for CTM) It's possible that cm initialization fails due to memory error or DRM error. In which case, the RandR state may not reflect the actual hardware state. v2: - Use switch statement in push_cm_prop - Get rid of per-CRTC cm support checks. Keep it simple and only check the first CRTC, since kernel will always report all or nothing for AMD hardware. - Remove per-CRTC LUT size caching, drmmode now holds that. Update commit message to reflect this. Signed-off-by: Leo (Sunpeng) Li <sunpeng.li@amd.com> [ Michel Dänzer: Replace "drmmode_crtc->ctm == NULL" with !drmmode_crtc->ctm ] Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
2018-06-26Cache color property IDs and LUT sizes during pre-initLeo Li (Sunpeng)2-0/+120
DRM creates property types with unique IDs during kernel driver init. Cache the color property IDs on DDX init for use later, when we need to modify these properties. Also cache the (de)gamma LUT sizes, since they are the same for all CRTCs on AMD hardware. Since these values are the same regardless of the CRTC, they can be cached within the private drmmode_rec object. We can also use any color- management-enabled CRTC to initially fetch them. Also introduce an enumeration of possible color management properties, to provide a easy and unified way of referring to them. v2: - Reorder cm property enum so that LUT sizes are at the end. This allows us to use DEGAMMA_LUT_SIZE as an anchor for iterating over mutable cm properties. - Cache (de)gamma LUT sizes within drmmode, since it's the same for all CRTCs on AMD hardware. Update commit message to reflect this. Signed-off-by: Leo (Sunpeng) Li <sunpeng.li@amd.com> Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
2018-06-12Check dimensions passed to drmmode_xf86crtc_resizeMichel Dänzer1-0/+8
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.
2018-05-24Use drmmode_crtc_dpms in drmmode_set_desired_modesMichel Dänzer1-8/+1
Simplifies the latter slightly. Reviewed-by: Leo (Sunpeng) Li <sunpeng.li@amd.com>
2018-05-18Call drmmode_do_crtc_dpms from drmmode_crtc_dpms as wellMichel Dänzer1-2/+1
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> Reviewed-by: Leo (Sunpeng) Li <sunpeng.li@amd.com>
2018-05-16Replace 'foo == NULL' with '!foo'Michel Dänzer9-24/+22
Shorter and sweeter. :) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-04-30Include xf86platformBus.h unconditionallySlava Grigorev1-4/+2
Compilation failed with XSERVER_PLATFORM_BUS undefined: ../../src/amdgpu_probe.c: In function ‘amdgpu_kernel_open_fd’: ../../src/amdgpu_probe.c:133:21: error: dereferencing pointer to incomplete type ‘struct xf86_platform_device’ dev = platform_dev->pdev; ^~ Signed-off-by: Slava Grigorev <slava.grigorev@amd.com> [ Michel Dänzer: * Fixed remaining preprocessor guards to work with xserver 1.13 * Touched up commit log ]
2018-04-27Wait for pending flips in drmmode_output_set_tear_freeMichel Dänzer1-0/+9
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. Reviewed-by: Samuel Li <Samuel.Li@amd.com>
2018-04-26Refactor drmmode_output_set_tear_free helperMichel Dänzer1-12/+19
Preparation for the following fix, no functional change intended. Reviewed-by: Samuel Li <Samuel.Li@amd.com>
2018-04-25Set drmmode_crtc->scanout_id = 0 when TearFree is disabledMichel Dänzer1-0/+2
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. Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-04-25Simplify drmmode_handle_transformMichel Dänzer1-5/+1
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. Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-04-23Don't call scanout_flip/update with a legacy RandR scanout bufferMichel Dänzer1-0/+3
It means we are not using our own scanout buffers. Fixes crash when TearFree is supposed to be enabled, but drmmode_handle_transform doesn't set crtc->driverIsPerformingTransform. Bugzilla: https://bugs.freedesktop.org/105736 Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-04-23Simplify drmmode_crtc_scanout_updateMichel Dänzer1-12/+4
Use our own BoxRec for the extents, and RegionEmpty for clearing the scanout damage region.
2018-04-20Update RandR CRTC state if set_mode_major fails in set_desired_modesMichel Dänzer1-0/+2
Without this, RandR would report the CRTC and its outputs as enabled, even though they were actually off due to the failure.
2018-04-20Abort scanout_update_pending event when possibleMichel Dänzer1-4/+8
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.
2018-04-20Track DRM event queue sequence number in scanout_update_pendingMichel Dänzer2-9/+9
Preparation for next change, no behaviour change intended.
2018-04-20Ignore AMDGPU_DRM_QUEUE_ERROR (0) in amdgpu_drm_abort_entryMichel Dänzer1-0/+3
This allows a following change to be slightly simpler.
2018-04-20Remove set but unused amdgpu_dri2::pKernelDRMVersionEmil Velikov2-7/+0
Signed-off-by: Emil Velikov <emil.velikov@collabora.com> Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2018-04-20Do not export the DriverRec AMDGPUEmil Velikov1-1/+1
Unused externally and should not be exported. Signed-off-by: Emil Velikov <emil.velikov@collabora.com> Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2018-04-20Move amdgpu_bus_id/amgpu_kernel_mode within amdgpu_kernel_open_fdEmil Velikov1-22/+23
Small step towards unifying the code paths and removing a handful of duplication. Signed-off-by: Emil Velikov <emil.velikov@collabora.com> Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2018-04-18Wait for pending scanout update before calling drmmode_crtc_scanout_freeJim Qu1-2/+4
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>
2018-04-18Post-release version bumpMichel Dänzer1-1/+1
2018-03-15Bump version for 18.0.1 releaseMichel Dänzer1-1/+1
2018-03-08Pass extents to amdgpu_scanout_do_update by valueMichel Dänzer3-15/+15
amdgpu_scanout_extents_intersect could leave the scanout damage region in an invalid state, triggering debugging checks in pixman: *** BUG *** In pixman_region_append_non_o: The expression r->x1 < r->x2 was false Set a breakpoint on '_pixman_log_error' to debug
2018-03-07Wrap the whole miPointerScreenFuncRec, instead of only Set/MoveCursorMichel Dänzer4-23/+63
We were clobbering entries in mi's global miSpritePointerFuncs struct, which cannot work correctly with multiple primary screens. Instead, assign a pointer to our own wrapper struct to PointPriv->spriteFuncs. Fixes crashes with multiple primary screens. Fixes: 69e20839bfeb ("Keep track of how many SW cursors are visible on each screen") Reported-by: Mario Kleiner <mario.kleiner.de@gmail.com>
2018-03-06Only change Set/MoveCursor hooks from what we expectMichel Dänzer1-6/+10
Since xf86CursorCloseScreen runs after AMDGPUCloseScreen_KMS, PointPriv->spriteFuncs doesn't point to the same struct in the latter as in AMDGPUCursorInit_KMS. So we were restoring info->Set/MoveCursor to the wrong struct. Then in the next server generation, info->Set/MoveCursor would end up pointing to drmmode_sprite_set/move_cursor, resulting in an infinite loop if one of them was called. To avoid this, only change the Set/MoveCursor hooks if their values match our expectations, otherwise leave them as is. This is kind of a hack, but the alternative would be invasive and thus risky changes to the way we're wrapping CloseScreen, and it's not even clear that can work without changing xserver code. Fixes: 69e20839bfeb ("Keep track of how many SW cursors are visible on each screen") (Ported from radeon commit 504b8721b17a672caf1ed3eab087027c02458cab) Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-03-02Bump version for 18.0.0 releaseMichel Dänzer1-1/+1
2018-03-02modesetting: Update property values at detect and uevent timeKeith Packard1-18/+86
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 Martin1-1/+3
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 Martin1-58/+70
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-03-01fix include order for present.h configure testChristoph Haag1-2/+2
xorg-server.h defines _XSERVER64 which is used in X.h to choose the correct definition of XID this prevents a failure in the present.h configure test that disables DRI3 on X.Org 1.20 Reviewed-and-Tested-by: Michel Dänzer <michel.daenzer@amd.com>
2018-02-16Disable all unused CRTCs before setting desired modesMichel Dänzer1-12/+21
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änzer1-9/+25
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-15If glamor is too old for depth 30, fall back to ShadowFBMichel Dänzer1-7/+9
Instead of not starting up at all. Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-02-14Revert "Guard against pAMDGPUEnt == NULL in AMDGPUFreeRec"Michel Dänzer1-1/+1
This reverts commit a23d1ff700d486138c624c2023d8d251c73709af. pAMDGPUEnt cannot be NULL anymore here now that we no longer call AMDGPUFreeRec directly from AMDGPUPreInit_KMS. Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-02-14Don't call AMDGPUFreeRec from AMDGPUPreInit_KMSMichel Dänzer1-13/+9
If the latter fails, Xorg will call AMDGPUFreeScreen_KMS, which calls the former. Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-02-14Guard against pAMDGPUEnt == NULL in AMDGPUFreeRecMichel Dänzer1-1/+1
This can happen if PreInit fails early. Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-02-14Always use screen depth/bpp for KMS framebuffersMichel Dänzer2-10/+8
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-14Add 30bit RGB color format supportHawking Zhang4-1/+12
Signed-off-by: Hawking Zhang <Hawking.Zhang@amd.com> [ Michel Dänzer: * Require Xorg >= 1.19.99.1 for depth 30, otherwise it can't work with glamor * Update manpage, per radeon commit 574bfab4bf1fcd95163a8f33cea2889189429d30 ] Reviewed-by: Alex Deucher <alexander.deucher@amd.com>