@@ -316,7 +316,7 @@ static void amdgpu_dm_set_crc_window_default(struct drm_crtc *crtc, struct dc_st
316316 spin_unlock_irqrestore (& drm_dev -> event_lock , flags );
317317
318318 /* Disable secure_display if it was enabled */
319- if (was_activated ) {
319+ if (was_activated && dm -> secure_display_ctx . op_mode == LEGACY_MODE ) {
320320 /* stop ROI update on this crtc */
321321 flush_work (& dm -> secure_display_ctx .crtc_ctx [crtc -> index ].notify_ta_work );
322322 flush_work (& dm -> secure_display_ctx .crtc_ctx [crtc -> index ].forward_roi_work );
@@ -691,7 +691,8 @@ int amdgpu_dm_crtc_set_crc_source(struct drm_crtc *crtc, const char *src_name)
691691
692692#if defined(CONFIG_DRM_AMD_SECURE_DISPLAY )
693693 /* Initialize phy id mapping table for secure display*/
694- if (!dm -> secure_display_ctx .phy_mapping_updated )
694+ if (dm -> secure_display_ctx .op_mode == LEGACY_MODE &&
695+ !dm -> secure_display_ctx .phy_mapping_updated )
695696 update_phy_id_mapping (adev );
696697#endif
697698
@@ -774,6 +775,7 @@ void amdgpu_dm_crtc_handle_crc_window_irq(struct drm_crtc *crtc)
774775 bool forward_roi_change = false;
775776 bool notify_ta = false;
776777 bool all_crc_ready = true;
778+ struct dc_stream_state * stream_state ;
777779 int i ;
778780
779781 if (crtc == NULL )
@@ -782,6 +784,7 @@ void amdgpu_dm_crtc_handle_crc_window_irq(struct drm_crtc *crtc)
782784 acrtc = to_amdgpu_crtc (crtc );
783785 adev = drm_to_adev (crtc -> dev );
784786 drm_dev = crtc -> dev ;
787+ stream_state = to_dm_crtc_state (crtc -> state )-> stream ;
785788
786789 spin_lock_irqsave (& drm_dev -> event_lock , flags1 );
787790 cur_crc_src = acrtc -> dm_irq_params .crc_src ;
@@ -807,6 +810,17 @@ void amdgpu_dm_crtc_handle_crc_window_irq(struct drm_crtc *crtc)
807810 }
808811
809812 for (i = 0 ; i < MAX_CRC_WINDOW_NUM ; i ++ ) {
813+ struct crc_params crc_window = {
814+ .windowa_x_start = acrtc -> dm_irq_params .window_param [i ].x_start ,
815+ .windowa_y_start = acrtc -> dm_irq_params .window_param [i ].y_start ,
816+ .windowa_x_end = acrtc -> dm_irq_params .window_param [i ].x_end ,
817+ .windowa_y_end = acrtc -> dm_irq_params .window_param [i ].y_end ,
818+ .windowb_x_start = acrtc -> dm_irq_params .window_param [i ].x_start ,
819+ .windowb_y_start = acrtc -> dm_irq_params .window_param [i ].y_start ,
820+ .windowb_x_end = acrtc -> dm_irq_params .window_param [i ].x_end ,
821+ .windowb_y_end = acrtc -> dm_irq_params .window_param [i ].y_end ,
822+ };
823+
810824 crtc_ctx -> roi [i ].enable = acrtc -> dm_irq_params .window_param [i ].enable ;
811825
812826 if (!acrtc -> dm_irq_params .window_param [i ].enable ) {
@@ -821,15 +835,20 @@ void amdgpu_dm_crtc_handle_crc_window_irq(struct drm_crtc *crtc)
821835 }
822836
823837 if (acrtc -> dm_irq_params .window_param [i ].update_win ) {
824- /* prepare work for dmub to update ROI */
825- crtc_ctx -> roi [i ].rect .x = acrtc -> dm_irq_params .window_param [i ].x_start ;
826- crtc_ctx -> roi [i ].rect .y = acrtc -> dm_irq_params .window_param [i ].y_start ;
827- crtc_ctx -> roi [i ].rect .width = acrtc -> dm_irq_params .window_param [i ].x_end -
828- acrtc -> dm_irq_params .window_param [i ].x_start ;
829- crtc_ctx -> roi [i ].rect .height = acrtc -> dm_irq_params .window_param [i ].y_end -
830- acrtc -> dm_irq_params .window_param [i ].y_start ;
831-
832- forward_roi_change = true;
838+ crtc_ctx -> roi [i ].rect .x = crc_window .windowa_x_start ;
839+ crtc_ctx -> roi [i ].rect .y = crc_window .windowa_y_start ;
840+ crtc_ctx -> roi [i ].rect .width = crc_window .windowa_x_end -
841+ crc_window .windowa_x_start ;
842+ crtc_ctx -> roi [i ].rect .height = crc_window .windowa_y_end -
843+ crc_window .windowa_y_start ;
844+
845+ if (adev -> dm .secure_display_ctx .op_mode == LEGACY_MODE )
846+ /* forward task to dmub to update ROI */
847+ forward_roi_change = true;
848+ else if (adev -> dm .secure_display_ctx .op_mode == DISPLAY_CRC_MODE )
849+ /* update ROI via dm*/
850+ dc_stream_configure_crc (stream_state -> ctx -> dc , stream_state ,
851+ & crc_window , true, true, i , false);
833852
834853 reset_crc_frame_count [i ] = true;
835854
@@ -843,14 +862,18 @@ void amdgpu_dm_crtc_handle_crc_window_irq(struct drm_crtc *crtc)
843862 acrtc -> dm_irq_params .window_param [i ].skip_frame_cnt = 1 ;
844863 crtc_ctx -> crc_info .crc [i ].crc_ready = false;
845864 } else {
846- struct dc_stream_state * stream_state = to_dm_crtc_state (crtc -> state )-> stream ;
847-
848865 if (!dc_stream_get_crc (stream_state -> ctx -> dc , stream_state , i ,
849866 & crc_r [i ], & crc_g [i ], & crc_b [i ]))
850867 DRM_ERROR ("Secure Display: fail to get crc from engine %d\n" , i );
851868
852- /* prepare work for psp to read ROI/CRC and send to I2C */
853- notify_ta = true;
869+ if (adev -> dm .secure_display_ctx .op_mode == LEGACY_MODE )
870+ /* forward task to psp to read ROI/CRC and output via I2C */
871+ notify_ta = true;
872+ else if (adev -> dm .secure_display_ctx .op_mode == DISPLAY_CRC_MODE )
873+ /* Avoid ROI window get changed, keep overwriting. */
874+ dc_stream_configure_crc (stream_state -> ctx -> dc , stream_state ,
875+ & crc_window , true, true, i , false);
876+
854877 /* crc ready for psp to read out */
855878 crtc_ctx -> crc_info .crc [i ].crc_ready = true;
856879 }
@@ -914,6 +937,7 @@ void amdgpu_dm_crtc_secure_display_create_contexts(struct amdgpu_device *adev)
914937 }
915938
916939 adev -> dm .secure_display_ctx .crtc_ctx = crtc_ctx ;
917- return ;
940+
941+ adev -> dm .secure_display_ctx .op_mode = DISPLAY_CRC_MODE ;
918942}
919943#endif
0 commit comments