Skip to contentSkip to conversation

drm/amd/display: signal PQ EOTF in FreeSync infopacket for DP HDR

PATCH In review Melissa Wen 2 participants 2 messages Oct 21 – Oct 31

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amd/display: signal PQ EOTF in FreeSync infopacket for DP HDR

Commit c2791297013e ("drm/amd/display: Add color bit info to freesync infoframe") created the app_tf interface for FreeSync HDR and commit c21a764a98cb ("drm/amd/display: Send PQ bit in AMD VSIF") used it to set PB9 bit 5 (PQ EOTF) in v2/v3 AMD Freesync infopacket. However, Linux never made use of this interface: DM ignores what userspace sets regarding HDR and always passes TRANSFER_FUNC_UNKNOWN as app_tf, so the PQ bit is never set in the infopacket received by the eDP panel.

Check the EOTF in the HDR static metadata and set the PQ bit in Freesync infopacket for DP accordingly. This fixes gray-washed HDR on KDE/GNOME on Framework 13 Pro AI 9 HX 370 (DCN 3.5) and may fix similar issues on other VRR-capable panels that advertise Replay in its AMD VSDB.

It doesn't affect color/EOTF bits on infopackets for SDR and native HDMI.

---
 .../display/amdgpu_dm/amdgpu_dm_freesync.c    | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_freesync.c +18 -1
index ab9cfbce8d73..322106d1cce7 100644
@@ -165,6 +165,18 @@ void amdgpu_dm_get_freesync_config_for_crtc(
 }
 EXPORT_IF_KUNIT(amdgpu_dm_get_freesync_config_for_crtc);
 
+#define DP_HDR_SDP_EOTF_IDX 2
+
+static bool dm_dp_in_hdr_mode(const struct dc_stream_state *stream)
+{
+	const struct dc_info_packet *hdr = &stream->hdr_static_metadata;
+
+	if (!dc_is_dp_signal(stream->signal) || !hdr->valid)
+		return false;
+
+	return hdr->sb[DP_HDR_SDP_EOTF_IDX] == HDMI_EOTF_SMPTE_ST2084;
+}
+
 void amdgpu_dm_update_freesync_state_on_stream(
 	struct amdgpu_display_manager *dm,
 	struct dm_crtc_state *new_crtc_state,
@@ -181,6 +193,7 @@ void amdgpu_dm_update_freesync_state_on_stream(
 	bool pack_sdp_v1_3 = false;
 	struct amdgpu_dm_connector *aconn;
 	enum vrr_packet_type packet_type = PACKET_TYPE_VRR;
+	enum color_transfer_func app_tf;
 
 	if (!new_stream)
 		return;
@@ -232,12 +245,16 @@ void amdgpu_dm_update_freesync_state_on_stream(
 					&new_stream->adaptive_sync_infopacket);
 	}
 
+	app_tf =  dm_dp_in_hdr_mode(new_stream) ?
+		  TRANSFER_FUNC_PQ2084 :
+		  TRANSFER_FUNC_UNKNOWN;
+
 	mod_freesync_build_vrr_infopacket(
 		dm->freesync_module,
 		new_stream,
 		&vrr_params,
 		packet_type,
-		TRANSFER_FUNC_UNKNOWN,
+		app_tf,
 		&vrr_infopacket,
 		pack_sdp_v1_3);
 
Signature · 1 line
2.53.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 72 lines · Melissa Wen

Commit c2791297013e ("drm/amd/display: Add color bit info to freesync infoframe") created the app_tf interface for FreeSync HDR and commit c21a764a98cb ("drm/amd/display: Send PQ bit in AMD VSIF") used it to set PB9 bit 5 (PQ EOTF) in v2/v3 AMD Freesync infopacket. However, Linux never made use of this interface: DM ignores what userspace sets regarding HDR and always passes TRANSFER_FUNC_UNKNOWN as app_tf, so the PQ bit is never set in the infopacket received by the eDP panel.

Check the EOTF in the HDR static metadata and set the PQ bit in Freesync infopacket for DP accordingly. This fixes gray-washed HDR on KDE/GNOME on Framework 13 Pro AI 9 HX 370 (DCN 3.5) and may fix similar issues on other VRR-capable panels that advertise Replay in its AMD VSDB.

It doesn't affect color/EOTF bits on infopackets for SDR and native HDMI.

---
  .../display/amdgpu_dm/amdgpu_dm_freesync.c    | 19 ++++++++++++++++++-
  1 file changed, 18 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_freesync.c +18 -1
index ab9cfbce8d73..322106d1cce7 100644
@@ -165,6 +165,18 @@ void amdgpu_dm_get_freesync_config_for_crtc(
  }
  EXPORT_IF_KUNIT(amdgpu_dm_get_freesync_config_for_crtc);
 
+#define DP_HDR_SDP_EOTF_IDX 2
+
+static bool dm_dp_in_hdr_mode(const struct dc_stream_state *stream)
+{
+	const struct dc_info_packet *hdr = &stream->hdr_static_metadata;
+
+	if (!dc_is_dp_signal(stream->signal) || !hdr->valid)
+		return false;
+
+	return hdr->sb[DP_HDR_SDP_EOTF_IDX] == HDMI_EOTF_SMPTE_ST2084;
+}
+
  void amdgpu_dm_update_freesync_state_on_stream(
  	struct amdgpu_display_manager *dm,
  	struct dm_crtc_state *new_crtc_state,
@@ -181,6 +193,7 @@ void amdgpu_dm_update_freesync_state_on_stream(
  	bool pack_sdp_v1_3 = false;
  	struct amdgpu_dm_connector *aconn;
  	enum vrr_packet_type packet_type = PACKET_TYPE_VRR;
+	enum color_transfer_func app_tf;
 
  	if (!new_stream)
  		return;
@@ -232,12 +245,16 @@ void amdgpu_dm_update_freesync_state_on_stream(
  					&new_stream->adaptive_sync_infopacket);
  	}
 
+	app_tf =  dm_dp_in_hdr_mode(new_stream) ?
+		  TRANSFER_FUNC_PQ2084 :
+		  TRANSFER_FUNC_UNKNOWN;
+
  	mod_freesync_build_vrr_infopacket(
  		dm->freesync_module,
  		new_stream,
  		&vrr_params,
  		packet_type,
-		TRANSFER_FUNC_UNKNOWN,
+		app_tf,
  		&vrr_infopacket,
  		pack_sdp_v1_3);