Commit Graph

441 Commits

Author SHA1 Message Date
Michel Dänzer
d5e17dc4c7 Bump version for the 18.1.0 release xf86-video-amdgpu-18.1.0 2018-09-14 17:00:17 +02:00
Michel Dänzer
6572be49b7 Bail from drmmode_cm_init if there's no CRTC
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-13 11:44:21 +02:00
Michel Dänzer
ca5eb9894f Bail early from drm_wait_pending_flip if there's no pending flip
No need to process any events in that case.

v2:
* Re-check drmmode_crtc->flip_pending after processing each event
2018-09-05 10:54:56 +02:00
Michel Dänzer
a923bedfd9 Do not push the CM_GAMMA_LUT property values in drmmode_crtc_cm_init
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-09-05 10:51:52 +02:00
Michel Dänzer
26770be44b Don't use xorg_list_for_each_entry_safe for signalled flips
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-31 17:52:22 +02:00
Michel Dänzer
7eea3e2cd7 Always delete entry from list in drm_queue_handler
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-31 17:51:43 +02:00
Michel Dänzer
b804d7f85d glamor: Handle ihandle == -1 in amdgpu_glamor_set_shared_pixmap_backing
(Ported from radeon commit de88ea2755611bdcb18d91d8234d2ab5be8ff2e9)
Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-08-30 09:45:48 +02:00
Michel Dänzer
ae2a450cb9 Handle ihandle == -1 in amdgpu_set_shared_pixmap_backing
It means to stop using the shared pixmap backing.

(Ported from radeon commit 1799680f7bd84e0618f34f4c7486799521ddaf83)
Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-08-29 17:31:49 +02:00
Michel Dänzer
34e851d1f2 Use AC_CONFIG_MACRO_DIR instead of AC_CONFIG_MACRO_DIRS
Older versions of autoconf only supported the former.

(Cherry picked from radeon commit cba8fe4d64819aaa8ba516aa68dbe6d2aa153046)
Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-08-24 18:22:15 +02:00
Michel Dänzer
afdfa2a1b6 Add m4 directory
Although normally it only warns about it, under some circumstances,
aclocal can error out if this directory doesn't exist.

Reported-by: John Lumby <johnlumby@hotmail.com>
(Cherry picked from radeon commit 7b01c10137aba24c8f61dd9b2a19ea257ad24371)
Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-08-24 17:17:43 +02:00
Michel Dänzer
f6cd72e64e Use correct FB handle in amdgpu_do_pageflip
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: 9b6782c821 "Store FB for each CRTC in drmmode_flipdata_rec"
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-08-16 18:20:06 +02:00
Michel Dänzer
85cd8eef0c Remove drmmode_crtc_private_rec::present_vblank_* related code
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-16 17:11:24 +02:00
Michel Dänzer
e52872da69 Defer vblank event handling while waiting for a pending flip
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-16 17:11:24 +02:00
Michel Dänzer
739181c8d3 Add amdgpu_drm_handle_event wrapper for drmHandleEvent
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-16 17:11:24 +02:00
Michel Dänzer
6029794e8a Add amdgpu_drm_wait_pending_flip function
Replacing the drmmode_crtc_wait_pending_event macro.

Acked-by: Alex Deucher <alexander.deucher@amd.com>
2018-08-16 17:11:23 +02:00
Michel Dänzer
0148283984 Move DRM event queue related initialization to amdgpu_drm_queue_init
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-16 17:11:23 +02:00
Michel Dänzer
7f65a8c9e0 glamor: Check glamor module version for depth 30 support
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-16 15:56:57 +02:00
Michel Dänzer
08c4d42f43 glamor: Use glamor_egl_create_textured_pixmap_from_gbm_bo when possible
Inspired by the modesetting driver.

(Ported from radeon commit db28d35ce9fd07a2a4703f3df0633d4c8291ff9b)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-08-02 18:41:04 +02:00
Michel Dänzer
9b6782c821 Store FB for each CRTC in drmmode_flipdata_rec
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-27 17:57:54 +02:00
Michel Dänzer
2989d40ef7 glamor: Set AMDGPU_CREATE_PIXMAP_DRI2 for DRI3 pixmaps
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-25 18:37:48 +02:00
Michel Dänzer
f3b2ed37d6 Use strcpy for RandR output property names
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-23 18:44:32 +02:00
Michel Dänzer
5f06d6b8ba Remove drmmode_terminate_leases
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-23 18:44:13 +02:00
Michel Dänzer
7cc2d4515a Remove AMDGPUInfoRec::fbcon_pixmap
We always destroy the fbcon pixmap in drmmode_copy_fb anyway.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-20 12:38:04 +02:00
Michel Dänzer
46d87187c6 Don't use DRM_IOCTL_GEM_FLINK in create_pixmap_for_fbcon
We don't need it.
2018-07-20 12:37:56 +02:00
Michel Dänzer
b8d8416792 Free previous xf86CrtcRec gamma LUT memory
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-20 11:30:00 +02:00
Michel Dänzer
ae8e02c6fc Hardcode "non-desktop" RandR property name
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-18 18:22:33 +02:00
Michel Dänzer
1247be2170 Support gamma correction & colormaps at depth 30 as well
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-13 18:30:04 +02:00
Michel Dänzer
9dfbae76b1 Move flush from radeon_scanout_do_update to its callers
No functional change intended.

(Ported from radeon commit 90b94d40449f665f2d12874598062a5e5e5b64cd)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-11 18:28:02 +02:00
Michel Dänzer
ace6ea016c glamor: Bail CreatePixmap on unsupported pixmap depth
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-11 18:27:50 +02:00
Michel Dänzer
c160302abc Bail from dri2_create_buffer2 if we can't get a pixmap
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-10 18:09:34 +02:00
Keith Packard
61040bdfa3 Add RandR leases support
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-10 11:43:33 +02:00
Keith Packard
ab7e39c5a0 modesetting: Create CONNECTOR_ID properties for outputs [v2]
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-10 11:43:23 +02:00
Keith Packard
14db71a606 modesetting: Record non-desktop kernel property at PreInit time
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>
2018-07-06 16:38:35 +02:00
Michel Dänzer
baea4fa492 Call drmmode_crtc_gamma_do_set from drmmode_setup_colormap
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-28 10:29:29 +02:00
Michel Dänzer
19a40758be Remove #if 0'd code
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-28 10:28:23 +02:00
Michel Dänzer
8e98195e58 Don't apply gamma to HW cursor data if colour management is enabled
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-26 18:40:23 +02:00
Leo Li (Sunpeng)
606075b852 Also compose LUT when setting legacy gamma
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-26 17:35:56 +02:00
Leo Li (Sunpeng)
e0a4c0e215 Compose non-legacy with legacy regamma LUT
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-26 17:33:40 +02:00
Leo Li (Sunpeng)
e1fe46013c Enable setting of color properties via RandR
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-26 17:32:42 +02:00
Leo Li (Sunpeng)
29de2859e2 Update color properties on output_get_property
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-26 17:31:37 +02:00
Leo Li (Sunpeng)
639acf54b4 Configure color properties when creating output resources
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-26 17:27:09 +02:00
Leo Li (Sunpeng)
3cf5a281d8 Initialize color properties on CRTC during CRTC init
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-26 17:27:07 +02:00
Leo Li (Sunpeng)
810ed133cd Cache color property IDs and LUT sizes during pre-init
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-26 17:21:24 +02:00
Michel Dänzer
940c8b39f7 Check dimensions passed to drmmode_xf86crtc_resize
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-06-12 18:45:08 +02:00
Michel Dänzer
74124f2c17 Use drmmode_crtc_dpms in drmmode_set_desired_modes
Simplifies the latter slightly.

Reviewed-by: Leo (Sunpeng) Li <sunpeng.li@amd.com>
2018-05-24 17:05:01 +02:00
Michel Dänzer
ceeacb455c Call drmmode_do_crtc_dpms from drmmode_crtc_dpms as well
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-18 12:13:23 +02:00
Michel Dänzer
e8e688f385 Replace 'foo == NULL' with '!foo'
Shorter and sweeter. :)

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2018-05-16 16:49:20 +02:00
Slava Grigorev
103bd6f44c Include xf86platformBus.h unconditionally
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-30 15:56:49 +02:00
Michel Dänzer
04947b83cc Wait for pending flips in drmmode_output_set_tear_free
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-27 15:11:34 +02:00
Michel Dänzer
fa30f4601d Refactor drmmode_output_set_tear_free helper
Preparation for the following fix, no functional change intended.

Reviewed-by: Samuel Li <Samuel.Li@amd.com>
2018-04-26 17:55:30 +02:00