@@ -4933,12 +4933,13 @@ static int dm_encoder_helper_atomic_check(struct drm_encoder *encoder,
4933
4933
is_y420 );
4934
4934
bpp = convert_dc_color_depth_into_bpc (color_depth ) * 3 ;
4935
4935
clock = adjusted_mode -> clock ;
4936
- dm_new_connector_state -> pbn = drm_dp_calc_pbn_mode (clock , bpp );
4936
+ dm_new_connector_state -> pbn = drm_dp_calc_pbn_mode (clock , bpp , false );
4937
4937
}
4938
4938
dm_new_connector_state -> vcpi_slots = drm_dp_atomic_find_vcpi_slots (state ,
4939
4939
mst_mgr ,
4940
4940
mst_port ,
4941
- dm_new_connector_state -> pbn );
4941
+ dm_new_connector_state -> pbn ,
4942
+ 0 );
4942
4943
if (dm_new_connector_state -> vcpi_slots < 0 ) {
4943
4944
DRM_DEBUG_ATOMIC ("failed finding vcpi slots: %d\n" , (int )dm_new_connector_state -> vcpi_slots );
4944
4945
return dm_new_connector_state -> vcpi_slots ;
@@ -4951,6 +4952,71 @@ const struct drm_encoder_helper_funcs amdgpu_dm_encoder_helper_funcs = {
4951
4952
.atomic_check = dm_encoder_helper_atomic_check
4952
4953
};
4953
4954
4955
+ #if defined(CONFIG_DRM_AMD_DC_DCN )
4956
+ static int dm_update_mst_vcpi_slots_for_dsc (struct drm_atomic_state * state ,
4957
+ struct dc_state * dc_state )
4958
+ {
4959
+ struct dc_stream_state * stream = NULL ;
4960
+ struct drm_connector * connector ;
4961
+ struct drm_connector_state * new_con_state , * old_con_state ;
4962
+ struct amdgpu_dm_connector * aconnector ;
4963
+ struct dm_connector_state * dm_conn_state ;
4964
+ int i , j , clock , bpp ;
4965
+ int vcpi , pbn_div , pbn = 0 ;
4966
+
4967
+ for_each_oldnew_connector_in_state (state , connector , old_con_state , new_con_state , i ) {
4968
+
4969
+ aconnector = to_amdgpu_dm_connector (connector );
4970
+
4971
+ if (!aconnector -> port )
4972
+ continue ;
4973
+
4974
+ if (!new_con_state || !new_con_state -> crtc )
4975
+ continue ;
4976
+
4977
+ dm_conn_state = to_dm_connector_state (new_con_state );
4978
+
4979
+ for (j = 0 ; j < dc_state -> stream_count ; j ++ ) {
4980
+ stream = dc_state -> streams [j ];
4981
+ if (!stream )
4982
+ continue ;
4983
+
4984
+ if ((struct amdgpu_dm_connector * )stream -> dm_stream_context == aconnector )
4985
+ break ;
4986
+
4987
+ stream = NULL ;
4988
+ }
4989
+
4990
+ if (!stream )
4991
+ continue ;
4992
+
4993
+ if (stream -> timing .flags .DSC != 1 ) {
4994
+ drm_dp_mst_atomic_enable_dsc (state ,
4995
+ aconnector -> port ,
4996
+ dm_conn_state -> pbn ,
4997
+ 0 ,
4998
+ false);
4999
+ continue ;
5000
+ }
5001
+
5002
+ pbn_div = dm_mst_get_pbn_divider (stream -> link );
5003
+ bpp = stream -> timing .dsc_cfg .bits_per_pixel ;
5004
+ clock = stream -> timing .pix_clk_100hz / 10 ;
5005
+ pbn = drm_dp_calc_pbn_mode (clock , bpp , true);
5006
+ vcpi = drm_dp_mst_atomic_enable_dsc (state ,
5007
+ aconnector -> port ,
5008
+ pbn , pbn_div ,
5009
+ true);
5010
+ if (vcpi < 0 )
5011
+ return vcpi ;
5012
+
5013
+ dm_conn_state -> pbn = pbn ;
5014
+ dm_conn_state -> vcpi_slots = vcpi ;
5015
+ }
5016
+ return 0 ;
5017
+ }
5018
+ #endif
5019
+
4954
5020
static void dm_drm_plane_reset (struct drm_plane * plane )
4955
5021
{
4956
5022
struct dm_plane_state * amdgpu_state = NULL ;
@@ -7829,6 +7895,29 @@ dm_determine_update_type_for_commit(struct amdgpu_display_manager *dm,
7829
7895
return ret ;
7830
7896
}
7831
7897
7898
+ static int add_affected_mst_dsc_crtcs (struct drm_atomic_state * state , struct drm_crtc * crtc )
7899
+ {
7900
+ struct drm_connector * connector ;
7901
+ struct drm_connector_state * conn_state ;
7902
+ struct amdgpu_dm_connector * aconnector = NULL ;
7903
+ int i ;
7904
+ for_each_new_connector_in_state (state , connector , conn_state , i ) {
7905
+ if (conn_state -> crtc != crtc )
7906
+ continue ;
7907
+
7908
+ aconnector = to_amdgpu_dm_connector (connector );
7909
+ if (!aconnector -> port || !aconnector -> mst_port )
7910
+ aconnector = NULL ;
7911
+ else
7912
+ break ;
7913
+ }
7914
+
7915
+ if (!aconnector )
7916
+ return 0 ;
7917
+
7918
+ return drm_dp_mst_add_affected_dsc_crtcs (state , & aconnector -> mst_port -> mst_mgr );
7919
+ }
7920
+
7832
7921
/**
7833
7922
* amdgpu_dm_atomic_check() - Atomic check implementation for AMDgpu DM.
7834
7923
* @dev: The DRM device
@@ -7881,6 +7970,16 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,
7881
7970
if (ret )
7882
7971
goto fail ;
7883
7972
7973
+ if (adev -> asic_type >= CHIP_NAVI10 ) {
7974
+ for_each_oldnew_crtc_in_state (state , crtc , old_crtc_state , new_crtc_state , i ) {
7975
+ if (drm_atomic_crtc_needs_modeset (new_crtc_state )) {
7976
+ ret = add_affected_mst_dsc_crtcs (state , crtc );
7977
+ if (ret )
7978
+ goto fail ;
7979
+ }
7980
+ }
7981
+ }
7982
+
7884
7983
for_each_oldnew_crtc_in_state (state , crtc , old_crtc_state , new_crtc_state , i ) {
7885
7984
if (!drm_atomic_crtc_needs_modeset (new_crtc_state ) &&
7886
7985
!new_crtc_state -> color_mgmt_changed &&
@@ -7984,11 +8083,6 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,
7984
8083
if (ret )
7985
8084
goto fail ;
7986
8085
7987
- /* Perform validation of MST topology in the state*/
7988
- ret = drm_dp_mst_atomic_check (state );
7989
- if (ret )
7990
- goto fail ;
7991
-
7992
8086
if (state -> legacy_cursor_update ) {
7993
8087
/*
7994
8088
* This is a fast cursor update coming from the plane update
@@ -8057,6 +8151,15 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,
8057
8151
if (ret )
8058
8152
goto fail ;
8059
8153
8154
+ #if defined(CONFIG_DRM_AMD_DC_DCN )
8155
+ if (!compute_mst_dsc_configs_for_state (state , dm_state -> context ))
8156
+ goto fail ;
8157
+
8158
+ ret = dm_update_mst_vcpi_slots_for_dsc (state , dm_state -> context );
8159
+ if (ret )
8160
+ goto fail ;
8161
+ #endif
8162
+
8060
8163
if (dc_validate_global_state (dc , dm_state -> context , false) != DC_OK ) {
8061
8164
ret = - EINVAL ;
8062
8165
goto fail ;
@@ -8085,6 +8188,10 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,
8085
8188
dc_retain_state (old_dm_state -> context );
8086
8189
}
8087
8190
}
8191
+ /* Perform validation of MST topology in the state*/
8192
+ ret = drm_dp_mst_atomic_check (state );
8193
+ if (ret )
8194
+ goto fail ;
8088
8195
8089
8196
/* Store the overall update type for use later in atomic check. */
8090
8197
for_each_new_crtc_in_state (state , crtc , new_crtc_state , i ) {
0 commit comments