Skip to content

Commit

Permalink
drm/amdkcl: [5.0] Add kcl for upstream DRM VRR properties(v2)
Browse files Browse the repository at this point in the history
[Why]
Some userspace now expects to use vrr_capable and vrr_enabled
properties for kernels < 5.0, but the DKMS build only exposes support
for the legacy IOCTL for those kernels.

[How]
Expose the DRM properties for the connector and CRTC. The DRM functions
and interface can't really be stubbed directly since they deal with
state on the connector and CRTC that aren't available.

Tested as passing the igt@kms_vrr tests for 4.16, and for 4.15 with
a modified debugfs entry for vrr_range.

4.21 kernel doesn't exist,so it need to replace DRM_VERSION(4, 21,0)
with DRM_VERSION(5, 0, 0)

Change-Id: I32544ba087c09024738adf8f1297ce580c6aabb3
Cc: Liang, Prike <Prike.Liang@amd.com>
Cc: Yin, Tianci (Rico) <Tianci.Yin@amd.com>
Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
Tested-by: Flora Cui <flora.cui@amd.com>
Reviewed-by: changzhu <Changfeng.Zhu@amd.com>
  • Loading branch information
Nicholas Kazlauskas authored and changzhu committed Mar 14, 2019
1 parent 0c9be1f commit 4bd9f83
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 19 deletions.
2 changes: 1 addition & 1 deletion drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,7 @@ int amdgpu_display_modeset_create_props(struct amdgpu_device *adev)
"freesync_capable");
if (!adev->mode_info.freesync_capable_property)
return -ENOMEM;
#if DRM_VERSION_CODE < DRM_VERSION(4, 21, 0)
#if DRM_VERSION_CODE < DRM_VERSION(5, 0, 0)
adev->mode_info.vrr_capable_property =
drm_property_create_bool(adev->ddev,
DRM_MODE_PROP_IMMUTABLE,
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ struct amdgpu_mode_info {
struct drm_property *freesync_property;
/* it is used to know about display capability of freesync mode */
struct drm_property *freesync_capable_property;
#if DRM_VERSION_CODE < DRM_VERSION(4, 21, 0)
#if DRM_VERSION_CODE < DRM_VERSION(5, 0, 0)
/* Support for upstream vrr_capable connector property */
struct drm_property *vrr_capable_property;
/* Support for upstream vrr_enabled CRTC property */
Expand Down
26 changes: 10 additions & 16 deletions drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2326,7 +2326,7 @@ static int amdgpu_notify_freesync(struct drm_device *dev, void *data,
new_crtc_state = kcl_drm_atomic_get_new_crtc_state_before_commit(state, &acrtc->base);
dm_new_crtc_state = to_dm_crtc_state(new_crtc_state);

#if DRM_VERSION_CODE < DRM_VERSION(4, 21, 0)
#if DRM_VERSION_CODE < DRM_VERSION(5, 0, 0)
dm_new_crtc_state->base_vrr_enabled =
#else
dm_new_crtc_state->base.vrr_enabled =
Expand Down Expand Up @@ -3551,18 +3551,16 @@ static void amdgpu_dm_atomic_crtc_gamma_set(
drm_atomic_helper_crtc_set_property(crtc, prop, 0);
}
#endif
#if DRM_VERSION_CODE < DRM_VERSION(4, 21, 0)
#if DRM_VERSION_CODE < DRM_VERSION(5, 0, 0)
static int dm_crtc_funcs_atomic_set_property(
struct drm_crtc *crtc,
struct drm_crtc_state *crtc_state,
struct drm_property *property,
uint64_t val)
{
#if DRM_VERSION_CODE < DRM_VERSION(4, 21, 0)
struct drm_device *dev = crtc->dev;
struct amdgpu_device *adev = dev->dev_private;
struct dm_crtc_state *dm_state = to_dm_crtc_state(crtc_state);
#endif
#if DRM_VERSION_CODE < DRM_VERSION(4, 6, 0)
struct drm_plane_state *plane_state;

Expand All @@ -3576,17 +3574,13 @@ static int dm_crtc_funcs_atomic_set_property(
if (!plane_state)
return -EINVAL;
#endif
#if DRM_VERSION_CODE < DRM_VERSION(4, 21, 0)
if (property == adev->mode_info.vrr_enabled_property) {
dm_state->base_vrr_enabled = val;
}
#endif

return 0;
}
#endif

#if DRM_VERSION_CODE < DRM_VERSION(4, 21, 0)
static int dm_crtc_funcs_atomic_get_property(struct drm_crtc *crtc,
const struct drm_crtc_state *state,
struct drm_property *property,
Expand Down Expand Up @@ -3741,7 +3735,7 @@ dm_crtc_duplicate_state(struct drm_crtc *crtc)
state->stream = cur->stream;
dc_stream_retain(state->stream);
}
#if DRM_VERSION_CODE < DRM_VERSION(4, 21, 0)
#if DRM_VERSION_CODE < DRM_VERSION(5, 0, 0)
state->base_vrr_enabled = cur->base_vrr_enabled;
#endif
state->vrr_params = cur->vrr_params;
Expand Down Expand Up @@ -3789,7 +3783,7 @@ static const struct drm_crtc_funcs amdgpu_dm_crtc_funcs = {
.gamma_set = amdgpu_dm_atomic_crtc_gamma_set,
.atomic_set_property = dm_crtc_funcs_atomic_set_property,
#endif
#if DRM_VERSION_CODE < DRM_VERSION(4, 21, 0)
#if DRM_VERSION_CODE < DRM_VERSION(5, 0, 0)
.atomic_set_property = dm_crtc_funcs_atomic_set_property,
.atomic_get_property = dm_crtc_funcs_atomic_get_property,
#endif
Expand Down Expand Up @@ -4611,7 +4605,7 @@ static int amdgpu_dm_crtc_init(struct amdgpu_display_manager *dm,
if (res)
goto fail;

#if DRM_VERSION_CODE < DRM_VERSION(4, 21, 0)
#if DRM_VERSION_CODE < DRM_VERSION(5, 0, 0)
drm_object_attach_property(&acrtc->base.base,
dm->adev->mode_info.vrr_enabled_property,
0);
Expand Down Expand Up @@ -4902,7 +4896,7 @@ void amdgpu_dm_connector_init_helper(struct amdgpu_display_manager *dm,
if (connector_type == DRM_MODE_CONNECTOR_HDMIA ||
connector_type == DRM_MODE_CONNECTOR_DisplayPort ||
connector_type == DRM_MODE_CONNECTOR_eDP) {
#if DRM_VERSION_CODE >= DRM_VERSION(4, 21, 0)
#if DRM_VERSION_CODE >= DRM_VERSION(5, 0, 0)
drm_connector_attach_vrr_capable_property(
&aconnector->base);
#else
Expand Down Expand Up @@ -5331,7 +5325,7 @@ static void update_freesync_state_on_stream(
if (new_crtc_state->vrr_supported &&
config.min_refresh_in_uhz &&
config.max_refresh_in_uhz) {
#if DRM_VERSION_CODE < DRM_VERSION(4, 21, 0)
#if DRM_VERSION_CODE < DRM_VERSION(5, 0, 0)
config.state = new_crtc_state->base_vrr_enabled ?
#else
config.state = new_crtc_state->base.vrr_enabled ?
Expand Down Expand Up @@ -5382,7 +5376,7 @@ static void update_freesync_state_on_stream(
if (new_crtc_state->freesync_vrr_info_changed)
DRM_DEBUG_KMS("VRR packet update: crtc=%u enabled=%d state=%d",
new_crtc_state->base.crtc->base.id,
#if DRM_VERSION_CODE >= DRM_VERSION(4, 21, 0)
#if DRM_VERSION_CODE >= DRM_VERSION(5, 0, 0)
(int)new_crtc_state->base.vrr_enabled,
#else
(int)new_crtc_state->base_vrr_enabled,
Expand Down Expand Up @@ -6306,7 +6300,7 @@ static void get_freesync_config_for_crtc(

if (new_crtc_state->vrr_supported) {
new_crtc_state->stream->ignore_msa_timing_param = true;
#if DRM_VERSION_CODE < DRM_VERSION(4, 21, 0)
#if DRM_VERSION_CODE < DRM_VERSION(5, 0, 0)
config.state = new_crtc_state->base_vrr_enabled ?
#else
config.state = new_crtc_state->base.vrr_enabled ?
Expand Down Expand Up @@ -7278,7 +7272,7 @@ void amdgpu_dm_update_freesync_caps(struct drm_connector *connector,
update:
if (dm_con_state)
dm_con_state->freesync_capable = freesync_capable;
#if DRM_VERSION_CODE >= DRM_VERSION(4, 21, 0)
#if DRM_VERSION_CODE >= DRM_VERSION(5, 0, 0)
if (connector->vrr_capable_property)
drm_connector_set_vrr_capable_property(connector,
freesync_capable);
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ struct dm_crtc_state {
int crc_skip_count;
bool crc_enabled;

#if DRM_VERSION_CODE < DRM_VERSION(4, 21, 0)
#if DRM_VERSION_CODE < DRM_VERSION(5, 0, 0)
bool base_vrr_enabled;
#endif

Expand Down

0 comments on commit 4bd9f83

Please sign in to comment.