@@ -432,7 +432,7 @@ static void vc4_hdmi_set_avi_infoframe(struct drm_encoder *encoder)
432432 struct vc4_hdmi_encoder * vc4_encoder = to_vc4_hdmi_encoder (encoder );
433433 struct drm_connector * connector = & vc4_hdmi -> connector ;
434434 struct drm_connector_state * cstate = connector -> state ;
435- struct drm_crtc * crtc = encoder -> crtc ;
435+ struct drm_crtc * crtc = cstate -> crtc ;
436436 const struct drm_display_mode * mode = & crtc -> state -> adjusted_mode ;
437437 union hdmi_infoframe frame ;
438438 int ret ;
@@ -537,8 +537,11 @@ static bool vc4_hdmi_supports_scrambling(struct drm_encoder *encoder,
537537
538538static void vc4_hdmi_enable_scrambling (struct drm_encoder * encoder )
539539{
540- struct drm_display_mode * mode = & encoder -> crtc -> state -> adjusted_mode ;
541540 struct vc4_hdmi * vc4_hdmi = encoder_to_vc4_hdmi (encoder );
541+ struct drm_connector * connector = & vc4_hdmi -> connector ;
542+ struct drm_connector_state * cstate = connector -> state ;
543+ struct drm_crtc * crtc = cstate -> crtc ;
544+ struct drm_display_mode * mode = & crtc -> state -> adjusted_mode ;
542545
543546 if (!vc4_hdmi_supports_scrambling (encoder , mode ))
544547 return ;
@@ -559,17 +562,18 @@ static void vc4_hdmi_enable_scrambling(struct drm_encoder *encoder)
559562static void vc4_hdmi_disable_scrambling (struct drm_encoder * encoder )
560563{
561564 struct vc4_hdmi * vc4_hdmi = encoder_to_vc4_hdmi (encoder );
562- struct drm_crtc * crtc = encoder -> crtc ;
565+ struct drm_connector * connector = & vc4_hdmi -> connector ;
566+ struct drm_connector_state * cstate = connector -> state ;
563567
564568 /*
565- * At boot, encoder->crtc will be NULL. Since we don't know the
569+ * At boot, connector->state will be NULL. Since we don't know the
566570 * state of the scrambler and in order to avoid any
567571 * inconsistency, let's disable it all the time.
568572 */
569- if (crtc && !vc4_hdmi_supports_scrambling (encoder , & crtc -> mode ))
573+ if (cstate && !vc4_hdmi_supports_scrambling (encoder , & cstate -> crtc -> mode ))
570574 return ;
571575
572- if (crtc && !vc4_hdmi_mode_needs_scrambling (& crtc -> mode ))
576+ if (cstate && !vc4_hdmi_mode_needs_scrambling (& cstate -> crtc -> mode ))
573577 return ;
574578
575579 if (delayed_work_pending (& vc4_hdmi -> scrambling_work ))
@@ -891,7 +895,9 @@ static void vc4_hdmi_encoder_pre_crtc_configure(struct drm_encoder *encoder,
891895 vc4_hdmi_encoder_get_connector_state (encoder , state );
892896 struct vc4_hdmi_connector_state * vc4_conn_state =
893897 conn_state_to_vc4_hdmi_conn_state (conn_state );
894- struct drm_display_mode * mode = & encoder -> crtc -> state -> adjusted_mode ;
898+ struct drm_crtc_state * crtc_state =
899+ drm_atomic_get_new_crtc_state (state , conn_state -> crtc );
900+ struct drm_display_mode * mode = & crtc_state -> adjusted_mode ;
895901 struct vc4_hdmi * vc4_hdmi = encoder_to_vc4_hdmi (encoder );
896902 unsigned long bvb_rate , pixel_rate , hsm_rate ;
897903 int ret ;
@@ -985,7 +991,11 @@ static void vc4_hdmi_encoder_pre_crtc_configure(struct drm_encoder *encoder,
985991static void vc4_hdmi_encoder_pre_crtc_enable (struct drm_encoder * encoder ,
986992 struct drm_atomic_state * state )
987993{
988- struct drm_display_mode * mode = & encoder -> crtc -> state -> adjusted_mode ;
994+ struct drm_connector_state * conn_state =
995+ vc4_hdmi_encoder_get_connector_state (encoder , state );
996+ struct drm_crtc_state * crtc_state =
997+ drm_atomic_get_new_crtc_state (state , conn_state -> crtc );
998+ struct drm_display_mode * mode = & crtc_state -> adjusted_mode ;
989999 struct vc4_hdmi_encoder * vc4_encoder = to_vc4_hdmi_encoder (encoder );
9901000 struct vc4_hdmi * vc4_hdmi = encoder_to_vc4_hdmi (encoder );
9911001
@@ -1008,7 +1018,11 @@ static void vc4_hdmi_encoder_pre_crtc_enable(struct drm_encoder *encoder,
10081018static void vc4_hdmi_encoder_post_crtc_enable (struct drm_encoder * encoder ,
10091019 struct drm_atomic_state * state )
10101020{
1011- struct drm_display_mode * mode = & encoder -> crtc -> state -> adjusted_mode ;
1021+ struct drm_connector_state * conn_state =
1022+ vc4_hdmi_encoder_get_connector_state (encoder , state );
1023+ struct drm_crtc_state * crtc_state =
1024+ drm_atomic_get_new_crtc_state (state , conn_state -> crtc );
1025+ struct drm_display_mode * mode = & crtc_state -> adjusted_mode ;
10121026 struct vc4_hdmi * vc4_hdmi = encoder_to_vc4_hdmi (encoder );
10131027 struct vc4_hdmi_encoder * vc4_encoder = to_vc4_hdmi_encoder (encoder );
10141028 bool hsync_pos = mode -> flags & DRM_MODE_FLAG_PHSYNC ;
@@ -1195,8 +1209,8 @@ static void vc4_hdmi_audio_set_mai_clock(struct vc4_hdmi *vc4_hdmi)
11951209
11961210static void vc4_hdmi_set_n_cts (struct vc4_hdmi * vc4_hdmi )
11971211{
1198- struct drm_encoder * encoder = & vc4_hdmi -> encoder . base . base ;
1199- struct drm_crtc * crtc = encoder -> crtc ;
1212+ struct drm_connector * connector = & vc4_hdmi -> connector ;
1213+ struct drm_crtc * crtc = connector -> state -> crtc ;
12001214 const struct drm_display_mode * mode = & crtc -> state -> adjusted_mode ;
12011215 u32 samplerate = vc4_hdmi -> audio .samplerate ;
12021216 u32 n , cts ;
@@ -1230,13 +1244,13 @@ static inline struct vc4_hdmi *dai_to_hdmi(struct snd_soc_dai *dai)
12301244static int vc4_hdmi_audio_startup (struct device * dev , void * data )
12311245{
12321246 struct vc4_hdmi * vc4_hdmi = dev_get_drvdata (dev );
1233- struct drm_encoder * encoder = & vc4_hdmi -> encoder . base . base ;
1247+ struct drm_connector * connector = & vc4_hdmi -> connector ;
12341248
12351249 /*
12361250 * If the HDMI encoder hasn't probed, or the encoder is
12371251 * currently in DVI mode, treat the codec dai as missing.
12381252 */
1239- if (!encoder -> crtc || !(HDMI_READ (HDMI_RAM_PACKET_CONFIG ) &
1253+ if (!connector -> state || !(HDMI_READ (HDMI_RAM_PACKET_CONFIG ) &
12401254 VC4_HDMI_RAM_PACKET_ENABLE ))
12411255 return - ENODEV ;
12421256
0 commit comments