@@ -1594,171 +1594,109 @@ static bool is_dsc_common_config_possible(struct dc_stream_state *stream,
15941594 return bw_range -> max_target_bpp_x16 && bw_range -> min_target_bpp_x16 ;
15951595}
15961596
1597- #if defined(CONFIG_DRM_AMD_DC_FP )
1598- static bool dp_get_link_current_set_bw (struct drm_dp_aux * aux , uint32_t * cur_link_bw )
1599- {
1600- uint32_t total_data_bw_efficiency_x10000 = 0 ;
1601- uint32_t link_rate_per_lane_kbps = 0 ;
1602- enum dc_link_rate link_rate ;
1603- union lane_count_set lane_count ;
1604- u8 dp_link_encoding ;
1605- u8 link_bw_set = 0 ;
1606-
1607- * cur_link_bw = 0 ;
1608-
1609- if (drm_dp_dpcd_read (aux , DP_MAIN_LINK_CHANNEL_CODING_SET , & dp_link_encoding , 1 ) != 1 ||
1610- drm_dp_dpcd_read (aux , DP_LANE_COUNT_SET , & lane_count .raw , 1 ) != 1 ||
1611- drm_dp_dpcd_read (aux , DP_LINK_BW_SET , & link_bw_set , 1 ) != 1 )
1612- return false;
1613-
1614- switch (dp_link_encoding ) {
1615- case DP_8b_10b_ENCODING :
1616- link_rate = link_bw_set ;
1617- link_rate_per_lane_kbps = link_rate * LINK_RATE_REF_FREQ_IN_KHZ * BITS_PER_DP_BYTE ;
1618- total_data_bw_efficiency_x10000 = DATA_EFFICIENCY_8b_10b_x10000 ;
1619- total_data_bw_efficiency_x10000 /= 100 ;
1620- total_data_bw_efficiency_x10000 *= DATA_EFFICIENCY_8b_10b_FEC_EFFICIENCY_x100 ;
1621- break ;
1622- case DP_128b_132b_ENCODING :
1623- switch (link_bw_set ) {
1624- case DP_LINK_BW_10 :
1625- link_rate = LINK_RATE_UHBR10 ;
1626- break ;
1627- case DP_LINK_BW_13_5 :
1628- link_rate = LINK_RATE_UHBR13_5 ;
1629- break ;
1630- case DP_LINK_BW_20 :
1631- link_rate = LINK_RATE_UHBR20 ;
1632- break ;
1633- default :
1634- return false;
1635- }
1636-
1637- link_rate_per_lane_kbps = link_rate * 10000 ;
1638- total_data_bw_efficiency_x10000 = DATA_EFFICIENCY_128b_132b_x10000 ;
1639- break ;
1640- default :
1641- return false;
1642- }
1643-
1644- * cur_link_bw = link_rate_per_lane_kbps * lane_count .bits .LANE_COUNT_SET / 10000 * total_data_bw_efficiency_x10000 ;
1645- return true;
1646- }
1647- #endif
1648-
16491597enum dc_status dm_dp_mst_is_port_support_mode (
16501598 struct amdgpu_dm_connector * aconnector ,
16511599 struct dc_stream_state * stream )
16521600{
1653- #if defined(CONFIG_DRM_AMD_DC_FP )
1654- int branch_max_throughput_mps = 0 ;
1601+ int pbn , branch_max_throughput_mps = 0 ;
16551602 struct dc_link_settings cur_link_settings ;
1656- uint32_t end_to_end_bw_in_kbps = 0 ;
1657- uint32_t root_link_bw_in_kbps = 0 ;
1658- uint32_t virtual_channel_bw_in_kbps = 0 ;
1603+ unsigned int end_to_end_bw_in_kbps = 0 ;
1604+ unsigned int upper_link_bw_in_kbps = 0 , down_link_bw_in_kbps = 0 ;
16591605 struct dc_dsc_bw_range bw_range = {0 };
16601606 struct dc_dsc_config_options dsc_options = {0 };
1661- uint32_t stream_kbps ;
16621607
1663- /* DSC unnecessary case
1664- * Check if timing could be supported within end-to-end BW
1608+ /*
1609+ * Consider the case with the depth of the mst topology tree is equal or less than 2
1610+ * A. When dsc bitstream can be transmitted along the entire path
1611+ * 1. dsc is possible between source and branch/leaf device (common dsc params is possible), AND
1612+ * 2. dsc passthrough supported at MST branch, or
1613+ * 3. dsc decoding supported at leaf MST device
1614+ * Use maximum dsc compression as bw constraint
1615+ * B. When dsc bitstream cannot be transmitted along the entire path
1616+ * Use native bw as bw constraint
16651617 */
1666- stream_kbps =
1667- dc_bandwidth_in_kbps_from_timing (& stream -> timing ,
1668- dc_link_get_highest_encoding_format (stream -> link ));
1669- cur_link_settings = stream -> link -> verified_link_cap ;
1670- root_link_bw_in_kbps = dc_link_bandwidth_kbps (aconnector -> dc_link , & cur_link_settings );
1671- virtual_channel_bw_in_kbps = kbps_from_pbn (aconnector -> mst_output_port -> full_pbn );
1672-
1673- /* pick the end to end bw bottleneck */
1674- end_to_end_bw_in_kbps = min (root_link_bw_in_kbps , virtual_channel_bw_in_kbps );
1675-
1676- if (stream_kbps <= end_to_end_bw_in_kbps ) {
1677- DRM_DEBUG_DRIVER ("No DSC needed. End-to-end bw sufficient." );
1678- return DC_OK ;
1679- }
1680-
1681- /*DSC necessary case*/
1682- if (!aconnector -> dsc_aux )
1683- return DC_FAIL_BANDWIDTH_VALIDATE ;
1684-
1685- if (is_dsc_common_config_possible (stream , & bw_range )) {
1686-
1687- /*capable of dsc passthough. dsc bitstream along the entire path*/
1688- if (aconnector -> mst_output_port -> passthrough_aux ) {
1689- if (bw_range .min_kbps > end_to_end_bw_in_kbps ) {
1690- DRM_DEBUG_DRIVER ("DSC passthrough. Max dsc compression can't fit into end-to-end bw\n" );
1618+ if (is_dsc_common_config_possible (stream , & bw_range ) &&
1619+ (aconnector -> mst_output_port -> passthrough_aux ||
1620+ aconnector -> dsc_aux == & aconnector -> mst_output_port -> aux )) {
1621+ cur_link_settings = stream -> link -> verified_link_cap ;
1622+ upper_link_bw_in_kbps = dc_link_bandwidth_kbps (aconnector -> dc_link , & cur_link_settings );
1623+ down_link_bw_in_kbps = kbps_from_pbn (aconnector -> mst_output_port -> full_pbn );
1624+
1625+ /* pick the end to end bw bottleneck */
1626+ end_to_end_bw_in_kbps = min (upper_link_bw_in_kbps , down_link_bw_in_kbps );
1627+
1628+ if (end_to_end_bw_in_kbps < bw_range .min_kbps ) {
1629+ DRM_DEBUG_DRIVER ("maximum dsc compression cannot fit into end-to-end bandwidth\n" );
16911630 return DC_FAIL_BANDWIDTH_VALIDATE ;
1692- }
1693- } else {
1694- /*dsc bitstream decoded at the dp last link*/
1695- struct drm_dp_mst_port * immediate_upstream_port = NULL ;
1696- uint32_t end_link_bw = 0 ;
1697-
1698- /*Get last DP link BW capability*/
1699- if (dp_get_link_current_set_bw (& aconnector -> mst_output_port -> aux , & end_link_bw )) {
1700- if (stream_kbps > end_link_bw ) {
1701- DRM_DEBUG_DRIVER ("DSC decode at last link. Mode required bw can't fit into available bw\n" );
1702- return DC_FAIL_BANDWIDTH_VALIDATE ;
1703- }
1704- }
1705-
1706- /*Get virtual channel bandwidth between source and the link before the last link*/
1707- if (aconnector -> mst_output_port -> parent -> port_parent )
1708- immediate_upstream_port = aconnector -> mst_output_port -> parent -> port_parent ;
1631+ }
17091632
1710- if (immediate_upstream_port ) {
1711- virtual_channel_bw_in_kbps = kbps_from_pbn (immediate_upstream_port -> full_pbn );
1712- virtual_channel_bw_in_kbps = min (root_link_bw_in_kbps , virtual_channel_bw_in_kbps );
1713- if (bw_range .min_kbps > virtual_channel_bw_in_kbps ) {
1714- DRM_DEBUG_DRIVER ("DSC decode at last link. Max dsc compression can't fit into MST available bw\n" );
1715- return DC_FAIL_BANDWIDTH_VALIDATE ;
1716- }
1633+ if (end_to_end_bw_in_kbps < bw_range .stream_kbps ) {
1634+ dc_dsc_get_default_config_option (stream -> link -> dc , & dsc_options );
1635+ dsc_options .max_target_bpp_limit_override_x16 = aconnector -> base .display_info .max_dsc_bpp * 16 ;
1636+ if (dc_dsc_compute_config (stream -> sink -> ctx -> dc -> res_pool -> dscs [0 ],
1637+ & stream -> sink -> dsc_caps .dsc_dec_caps ,
1638+ & dsc_options ,
1639+ end_to_end_bw_in_kbps ,
1640+ & stream -> timing ,
1641+ dc_link_get_highest_encoding_format (stream -> link ),
1642+ & stream -> timing .dsc_cfg )) {
1643+ stream -> timing .flags .DSC = 1 ;
1644+ DRM_DEBUG_DRIVER ("end-to-end bandwidth require dsc and dsc config found\n" );
1645+ } else {
1646+ DRM_DEBUG_DRIVER ("end-to-end bandwidth require dsc but dsc config not found\n" );
1647+ return DC_FAIL_BANDWIDTH_VALIDATE ;
17171648 }
17181649 }
1719-
1720- /*Confirm if we can obtain dsc config*/
1721- dc_dsc_get_default_config_option (stream -> link -> dc , & dsc_options );
1722- dsc_options .max_target_bpp_limit_override_x16 = aconnector -> base .display_info .max_dsc_bpp * 16 ;
1723- if (dc_dsc_compute_config (stream -> sink -> ctx -> dc -> res_pool -> dscs [0 ],
1724- & stream -> sink -> dsc_caps .dsc_dec_caps ,
1725- & dsc_options ,
1726- end_to_end_bw_in_kbps ,
1727- & stream -> timing ,
1728- dc_link_get_highest_encoding_format (stream -> link ),
1729- & stream -> timing .dsc_cfg )) {
1730- stream -> timing .flags .DSC = 1 ;
1731- DRM_DEBUG_DRIVER ("Require dsc and dsc config found\n" );
1732- } else {
1733- DRM_DEBUG_DRIVER ("Require dsc but can't find appropriate dsc config\n" );
1650+ } else {
1651+ /* Check if mode could be supported within max slot
1652+ * number of current mst link and full_pbn of mst links.
1653+ */
1654+ int pbn_div , slot_num , max_slot_num ;
1655+ enum dc_link_encoding_format link_encoding ;
1656+ uint32_t stream_kbps =
1657+ dc_bandwidth_in_kbps_from_timing (& stream -> timing ,
1658+ dc_link_get_highest_encoding_format (stream -> link ));
1659+
1660+ pbn = kbps_to_peak_pbn (stream_kbps );
1661+ pbn_div = dm_mst_get_pbn_divider (stream -> link );
1662+ slot_num = DIV_ROUND_UP (pbn , pbn_div );
1663+
1664+ link_encoding = dc_link_get_highest_encoding_format (stream -> link );
1665+ if (link_encoding == DC_LINK_ENCODING_DP_8b_10b )
1666+ max_slot_num = 63 ;
1667+ else if (link_encoding == DC_LINK_ENCODING_DP_128b_132b )
1668+ max_slot_num = 64 ;
1669+ else {
1670+ DRM_DEBUG_DRIVER ("Invalid link encoding format\n" );
17341671 return DC_FAIL_BANDWIDTH_VALIDATE ;
17351672 }
17361673
1737- /* check is mst dsc output bandwidth branch_overall_throughput_0_mps */
1738- switch (stream -> timing .pixel_encoding ) {
1739- case PIXEL_ENCODING_RGB :
1740- case PIXEL_ENCODING_YCBCR444 :
1741- branch_max_throughput_mps =
1742- aconnector -> dc_sink -> dsc_caps .dsc_dec_caps .branch_overall_throughput_0_mps ;
1743- break ;
1744- case PIXEL_ENCODING_YCBCR422 :
1745- case PIXEL_ENCODING_YCBCR420 :
1746- branch_max_throughput_mps =
1747- aconnector -> dc_sink -> dsc_caps .dsc_dec_caps .branch_overall_throughput_1_mps ;
1748- break ;
1749- default :
1750- break ;
1674+ if (slot_num > max_slot_num ||
1675+ pbn > aconnector -> mst_output_port -> full_pbn ) {
1676+ DRM_DEBUG_DRIVER ("Mode can not be supported within mst links!" );
1677+ return DC_FAIL_BANDWIDTH_VALIDATE ;
17511678 }
1679+ }
17521680
1753- if (branch_max_throughput_mps != 0 &&
1754- ((stream -> timing .pix_clk_100hz / 10 ) > branch_max_throughput_mps * 1000 )) {
1755- DRM_DEBUG_DRIVER ("DSC is required but max throughput mps fails" );
1756- return DC_FAIL_BANDWIDTH_VALIDATE ;
1757- }
1758- } else {
1759- DRM_DEBUG_DRIVER ("DSC is required but can't find common dsc config." );
1760- return DC_FAIL_BANDWIDTH_VALIDATE ;
1681+ /* check is mst dsc output bandwidth branch_overall_throughput_0_mps */
1682+ switch (stream -> timing .pixel_encoding ) {
1683+ case PIXEL_ENCODING_RGB :
1684+ case PIXEL_ENCODING_YCBCR444 :
1685+ branch_max_throughput_mps =
1686+ aconnector -> dc_sink -> dsc_caps .dsc_dec_caps .branch_overall_throughput_0_mps ;
1687+ break ;
1688+ case PIXEL_ENCODING_YCBCR422 :
1689+ case PIXEL_ENCODING_YCBCR420 :
1690+ branch_max_throughput_mps =
1691+ aconnector -> dc_sink -> dsc_caps .dsc_dec_caps .branch_overall_throughput_1_mps ;
1692+ break ;
1693+ default :
1694+ break ;
17611695 }
1762- #endif
1696+
1697+ if (branch_max_throughput_mps != 0 &&
1698+ ((stream -> timing .pix_clk_100hz / 10 ) > branch_max_throughput_mps * 1000 ))
1699+ return DC_FAIL_BANDWIDTH_VALIDATE ;
1700+
17631701 return DC_OK ;
17641702}
0 commit comments