drm/amd/display: Add DP-HDMI FRL PCON SST Support in DM
authorFangzhi Zuo <Jerry.Zuo@amd.com>
Wed, 24 Nov 2021 16:43:06 +0000 (11:43 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 1 Dec 2021 21:04:30 +0000 (16:04 -0500)
1. Parse DSC caps from PCON DPCD
2. Policy determins if DSC is decoded at PCON
3. Enable/disable DSC at PCON

Signed-off-by: Fangzhi Zuo <Jerry.Zuo@amd.com>
Reviewed-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c

index 4b76eb1..a3c0f2e 100644 (file)
@@ -6056,10 +6056,12 @@ static void update_dsc_caps(struct amdgpu_dm_connector *aconnector,
 
        if (aconnector->dc_link && (sink->sink_signal == SIGNAL_TYPE_DISPLAY_PORT ||
                sink->sink_signal == SIGNAL_TYPE_EDP)) {
-               dc_dsc_parse_dsc_dpcd(aconnector->dc_link->ctx->dc,
-                                     aconnector->dc_link->dpcd_caps.dsc_caps.dsc_basic_caps.raw,
-                                     aconnector->dc_link->dpcd_caps.dsc_caps.dsc_branch_decoder_caps.raw,
-                                     dsc_caps);
+               if (sink->link->dpcd_caps.dongle_type == DISPLAY_DONGLE_NONE ||
+                       sink->link->dpcd_caps.dongle_type == DISPLAY_DONGLE_DP_HDMI_CONVERTER)
+                       dc_dsc_parse_dsc_dpcd(aconnector->dc_link->ctx->dc,
+                               aconnector->dc_link->dpcd_caps.dsc_caps.dsc_basic_caps.raw,
+                               aconnector->dc_link->dpcd_caps.dsc_caps.dsc_branch_decoder_caps.raw,
+                               dsc_caps);
        }
 }
 
@@ -6129,6 +6131,8 @@ static void apply_dsc_policy_for_stream(struct amdgpu_dm_connector *aconnector,
        uint32_t link_bandwidth_kbps;
        uint32_t max_dsc_target_bpp_limit_override = 0;
        struct dc *dc = sink->ctx->dc;
+       uint32_t max_supported_bw_in_kbps, timing_bw_in_kbps;
+       uint32_t dsc_max_supported_bw_in_kbps;
 
        link_bandwidth_kbps = dc_link_bandwidth_kbps(aconnector->dc_link,
                                                        dc_link_get_link_cap(aconnector->dc_link));
@@ -6147,16 +6151,37 @@ static void apply_dsc_policy_for_stream(struct amdgpu_dm_connector *aconnector,
                apply_dsc_policy_for_edp(aconnector, sink, stream, dsc_caps, max_dsc_target_bpp_limit_override);
 
        } else if (aconnector->dc_link && sink->sink_signal == SIGNAL_TYPE_DISPLAY_PORT) {
-
-               if (dc_dsc_compute_config(aconnector->dc_link->ctx->dc->res_pool->dscs[0],
+               if (sink->link->dpcd_caps.dongle_type == DISPLAY_DONGLE_NONE) {
+                       if (dc_dsc_compute_config(aconnector->dc_link->ctx->dc->res_pool->dscs[0],
                                                dsc_caps,
                                                aconnector->dc_link->ctx->dc->debug.dsc_min_slice_height_override,
                                                max_dsc_target_bpp_limit_override,
                                                link_bandwidth_kbps,
                                                &stream->timing,
                                                &stream->timing.dsc_cfg)) {
-                       stream->timing.flags.DSC = 1;
-                       DRM_DEBUG_DRIVER("%s: [%s] DSC is selected from SST RX\n", __func__, drm_connector->name);
+                               stream->timing.flags.DSC = 1;
+                               DRM_DEBUG_DRIVER("%s: [%s] DSC is selected from SST RX\n",
+                                                                __func__, drm_connector->name);
+                       }
+               } else if (sink->link->dpcd_caps.dongle_type == DISPLAY_DONGLE_DP_HDMI_CONVERTER) {
+                       timing_bw_in_kbps = dc_bandwidth_in_kbps_from_timing(&stream->timing);
+                       max_supported_bw_in_kbps = link_bandwidth_kbps;
+                       dsc_max_supported_bw_in_kbps = link_bandwidth_kbps;
+
+                       if (timing_bw_in_kbps > max_supported_bw_in_kbps &&
+                                       max_supported_bw_in_kbps > 0 &&
+                                       dsc_max_supported_bw_in_kbps > 0)
+                               if (dc_dsc_compute_config(aconnector->dc_link->ctx->dc->res_pool->dscs[0],
+                                               dsc_caps,
+                                               aconnector->dc_link->ctx->dc->debug.dsc_min_slice_height_override,
+                                               max_dsc_target_bpp_limit_override,
+                                               dsc_max_supported_bw_in_kbps,
+                                               &stream->timing,
+                                               &stream->timing.dsc_cfg)) {
+                                       stream->timing.flags.DSC = 1;
+                                       DRM_DEBUG_DRIVER("%s: [%s] DSC is selected from DP-HDMI PCON\n",
+                                                                        __func__, drm_connector->name);
+                               }
                }
        }
 
index 72a2e84..1410f5d 100644 (file)
@@ -585,8 +585,17 @@ bool dm_helpers_dp_write_dsc_enable(
        }
 
        if (stream->signal == SIGNAL_TYPE_DISPLAY_PORT || stream->signal == SIGNAL_TYPE_EDP) {
-               ret = dm_helpers_dp_write_dpcd(ctx, stream->link, DP_DSC_ENABLE, &enable_dsc, 1);
-               DC_LOG_DC("Send DSC %s to sst display\n", enable_dsc ? "enable" : "disable");
+#if defined(CONFIG_DRM_AMD_DC_DCN)
+               if (stream->sink->link->dpcd_caps.dongle_type == DISPLAY_DONGLE_NONE) {
+#endif
+                       ret = dm_helpers_dp_write_dpcd(ctx, stream->link, DP_DSC_ENABLE, &enable_dsc, 1);
+                       DC_LOG_DC("Send DSC %s to SST RX\n", enable_dsc ? "enable" : "disable");
+#if defined(CONFIG_DRM_AMD_DC_DCN)
+               } else if (stream->sink->link->dpcd_caps.dongle_type == DISPLAY_DONGLE_DP_HDMI_CONVERTER) {
+                       ret = dm_helpers_dp_write_dpcd(ctx, stream->link, DP_DSC_ENABLE, &enable_dsc, 1);
+                       DC_LOG_DC("Send DSC %s to DP-HDMI PCON\n", enable_dsc ? "enable" : "disable");
+               }
+#endif
        }
 
        return (ret > 0);