Skip to content

Commit 2d49855

Browse files
Lawstorant1Naim
authored andcommitted
drm/amd/display: Use ALLM properties in amdgpu
[Why] To enable ALLM when asked for by compositor [How] Attach properties to HDMI sinks, detect support and set allm_capable property, set allm_capable property for amdgpu_dm_connector Signed-off-by: Tomasz Pakuła <tomasz.pakula.oficjalny@gmail.com>
1 parent 40ba8a7 commit 2d49855

6 files changed

Lines changed: 64 additions & 4 deletions

File tree

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8978,6 +8978,7 @@ void amdgpu_dm_connector_init_helper(struct amdgpu_display_manager *dm,
89788978
aconnector->audio_inst = -1;
89798979
aconnector->pack_sdp_v1_3 = false;
89808980
aconnector->as_type = ADAPTIVE_SYNC_TYPE_NONE;
8981+
aconnector->hdmi_allm_capable = false;
89818982
memset(&aconnector->vsdb_info, 0, sizeof(aconnector->vsdb_info));
89828983
mutex_init(&aconnector->hpd_lock);
89838984
mutex_init(&aconnector->handle_mst_msg_ready);
@@ -9175,6 +9176,10 @@ int amdgpu_dm_initialize_hdmi_connector(struct amdgpu_dm_connector *aconnector)
91759176
struct drm_device *ddev = aconnector->base.dev;
91769177
struct device *hdmi_dev = ddev->dev;
91779178

9179+
/* ALLM */
9180+
drm_connector_attach_allm_capable_property(&aconnector->base);
9181+
drm_connector_attach_allm_mode_property(&aconnector->base);
9182+
91789183
if (amdgpu_dc_debug_mask & DC_DISABLE_HDMI_CEC) {
91799184
drm_info(ddev, "HDMI-CEC feature masked\n");
91809185
return -EINVAL;
@@ -10865,6 +10870,31 @@ static int amdgpu_dm_atomic_setup_commit(struct drm_atomic_state *state)
1086510870
return 0;
1086610871
}
1086710872

10873+
static void update_allm_state_on_crtc_stream(struct dm_crtc_state *new_crtc_state,
10874+
const struct drm_connector_state *new_conn)
10875+
{
10876+
struct mod_freesync_config *config = &new_crtc_state->freesync_config;
10877+
struct dc_stream_state *new_stream = new_crtc_state->stream;
10878+
bool allm_active = false;
10879+
10880+
switch (new_conn->allm_mode) {
10881+
case DRM_ALLM_MODE_ENABLED_DYNAMIC:
10882+
allm_active = config->state == VRR_STATE_ACTIVE_VARIABLE ||
10883+
new_stream->content_type == DISPLAY_CONTENT_TYPE_GAME;
10884+
break;
10885+
10886+
case DRM_ALLM_MODE_ENABLED_FORCED:
10887+
allm_active = true;
10888+
break;
10889+
10890+
case DRM_ALLM_MODE_DISABLED:
10891+
default:
10892+
allm_active = false;
10893+
}
10894+
10895+
new_stream->hdmi_allm_active = allm_active;
10896+
}
10897+
1086810898
/**
1086910899
* amdgpu_dm_atomic_commit_tail() - AMDgpu DM's commit tail implementation.
1087010900
* @state: The atomic state to commit
@@ -10907,12 +10937,14 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
1090710937
for_each_oldnew_connector_in_state(state, connector, old_con_state, new_con_state, i) {
1090810938
struct dm_connector_state *dm_new_con_state = to_dm_connector_state(new_con_state);
1090910939
struct dm_connector_state *dm_old_con_state = to_dm_connector_state(old_con_state);
10940+
struct amdgpu_dm_connector *dm_conn = to_amdgpu_dm_connector(connector);
1091010941
struct amdgpu_crtc *acrtc = to_amdgpu_crtc(dm_new_con_state->base.crtc);
1091110942
struct dc_surface_update *dummy_updates;
1091210943
struct dc_stream_update stream_update;
1091310944
struct dc_info_packet hdr_packet;
1091410945
struct dc_stream_status *status = NULL;
1091510946
bool abm_changed, hdr_changed, scaling_changed, output_color_space_changed = false;
10947+
bool allm_changed = false;
1091610948

1091710949
memset(&stream_update, 0, sizeof(stream_update));
1091810950

@@ -10942,7 +10974,11 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
1094210974
hdr_changed =
1094310975
!drm_connector_atomic_hdr_metadata_equal(old_con_state, new_con_state);
1094410976

10945-
if (!scaling_changed && !abm_changed && !hdr_changed && !output_color_space_changed)
10977+
allm_changed = dm_conn->hdmi_allm_capable &&
10978+
(new_con_state->allm_mode != old_con_state->allm_mode);
10979+
10980+
if (!scaling_changed && !abm_changed && !hdr_changed &&
10981+
!output_color_space_changed && !allm_changed)
1094610982
continue;
1094710983

1094810984
stream_update.stream = dm_new_crtc_state->stream;
@@ -10972,6 +11008,17 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
1097211008
stream_update.hdr_static_metadata = &hdr_packet;
1097311009
}
1097411010

11011+
if (allm_changed) {
11012+
update_allm_state_on_crtc_stream(dm_new_crtc_state, new_con_state);
11013+
mod_build_hf_vsif_infopacket(dm_new_crtc_state->stream,
11014+
&dm_new_crtc_state->stream->hfvsif_infopacket);
11015+
11016+
stream_update.hdmi_allm_active =
11017+
&dm_new_crtc_state->stream->hdmi_allm_active;
11018+
stream_update.hfvsif_infopacket =
11019+
&dm_new_crtc_state->stream->hfvsif_infopacket;
11020+
}
11021+
1097511022
status = dc_stream_get_status(dm_new_crtc_state->stream);
1097611023

1097711024
if (WARN_ON(!status))
@@ -13487,6 +13534,11 @@ void amdgpu_dm_update_freesync_caps(struct drm_connector *connector,
1348713534

1348813535
if (connector->passive_vrr_capable_property)
1348913536
drm_connector_set_passive_vrr_capable_property(connector, freesync_on_desktop);
13537+
13538+
amdgpu_dm_connector->hdmi_allm_capable = connector->display_info.hdmi.allm;
13539+
if (connector->allm_capable_property)
13540+
drm_connector_set_allm_capable_property(
13541+
connector, connector->display_info.hdmi.allm);
1349013542
}
1349113543

1349213544
void amdgpu_dm_trigger_timing_sync(struct drm_device *dev)

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -847,6 +847,9 @@ struct amdgpu_dm_connector {
847847
unsigned int hdmi_hpd_debounce_delay_ms;
848848
struct delayed_work hdmi_hpd_debounce_work;
849849
struct dc_sink *hdmi_prev_sink;
850+
851+
/* HDMI ALLM */
852+
bool hdmi_allm_capable;
850853
};
851854

852855
static inline void amdgpu_dm_set_mst_status(uint8_t *status,

drivers/gpu/drm/amd/display/dc/core/dc.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3293,6 +3293,9 @@ static void copy_stream_update_to_stream(struct dc *dc,
32933293
if (update->vrr_active_fixed)
32943294
stream->vrr_active_fixed = *update->vrr_active_fixed;
32953295

3296+
if (update->hdmi_allm_active)
3297+
stream->hdmi_allm_active = *update->hdmi_allm_active;
3298+
32963299
if (update->crtc_timing_adjust) {
32973300
if (stream->adjust.v_total_min != update->crtc_timing_adjust->v_total_min ||
32983301
stream->adjust.v_total_max != update->crtc_timing_adjust->v_total_max ||

drivers/gpu/drm/amd/display/dc/core/dc_resource.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4659,7 +4659,7 @@ static void set_avi_info_frame(
46594659
vic = 0;
46604660
format = stream->timing.timing_3d_format;
46614661
/*todo, add 3DStereo support*/
4662-
if (format != TIMING_3D_FORMAT_NONE) {
4662+
if (format != TIMING_3D_FORMAT_NONE || stream->hdmi_allm_active) {
46634663
// Based on HDMI specs hdmi vic needs to be converted to cea vic when 3D is enabled
46644664
switch (pipe_ctx->stream->timing.hdmi_vic) {
46654665
case 1:

drivers/gpu/drm/amd/display/dc/dc_stream.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ struct dc_stream_state {
247247
bool vrr_active_variable;
248248
bool freesync_on_desktop;
249249
bool vrr_active_fixed;
250+
bool hdmi_allm_active;
250251

251252
bool converter_disable_audio;
252253
uint8_t qs_bit;
@@ -352,6 +353,7 @@ struct dc_stream_update {
352353
bool *allow_freesync;
353354
bool *vrr_active_variable;
354355
bool *vrr_active_fixed;
356+
bool *hdmi_allm_active;
355357

356358
struct colorspace_transform *gamut_remap;
357359
enum dc_color_space *output_color_space;

drivers/gpu/drm/amd/display/modules/info_packet/info_packet.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ static bool is_hdmi_vic_mode(const struct dc_stream_state *stream)
500500
if (stream->view_format != VIEW_3D_FORMAT_NONE)
501501
return false;
502502

503-
if (stream->link->local_sink->edid_caps.allm)
503+
if (stream->hdmi_allm_active)
504504
return false;
505505

506506
return true;
@@ -529,7 +529,7 @@ void mod_build_hf_vsif_infopacket(const struct dc_stream_state *stream,
529529

530530
info_packet->valid = false;
531531

532-
allm = stream->link->local_sink->edid_caps.allm;
532+
allm = stream->hdmi_allm_active;
533533
format = stream->view_format == VIEW_3D_FORMAT_NONE ?
534534
TIMING_3D_FORMAT_NONE :
535535
stream->timing.timing_3d_format;

0 commit comments

Comments
 (0)