@@ -616,7 +616,7 @@ static int
616
616
vc4_atomic_check (struct drm_device * dev , struct drm_atomic_state * state )
617
617
{
618
618
unsigned long unassigned_channels = GENMASK (NUM_CHANNELS - 1 , 0 );
619
- struct drm_crtc_state * crtc_state ;
619
+ struct drm_crtc_state * old_crtc_state , * new_crtc_state ;
620
620
struct drm_crtc * crtc ;
621
621
int i , ret ;
622
622
@@ -629,6 +629,8 @@ vc4_atomic_check(struct drm_device *dev, struct drm_atomic_state *state)
629
629
* modified.
630
630
*/
631
631
list_for_each_entry (crtc , & dev -> mode_config .crtc_list , head ) {
632
+ struct drm_crtc_state * crtc_state ;
633
+
632
634
if (!crtc -> state -> enable )
633
635
continue ;
634
636
@@ -637,15 +639,23 @@ vc4_atomic_check(struct drm_device *dev, struct drm_atomic_state *state)
637
639
return PTR_ERR (crtc_state );
638
640
}
639
641
640
- for_each_new_crtc_in_state (state , crtc , crtc_state , i ) {
641
- struct vc4_crtc_state * vc4_crtc_state =
642
- to_vc4_crtc_state (crtc_state );
642
+ for_each_oldnew_crtc_in_state (state , crtc , old_crtc_state , new_crtc_state , i ) {
643
+ struct vc4_crtc_state * new_vc4_crtc_state =
644
+ to_vc4_crtc_state (new_crtc_state );
643
645
struct vc4_crtc * vc4_crtc = to_vc4_crtc (crtc );
644
646
unsigned int matching_channels ;
645
647
646
- if (!crtc_state -> active )
648
+ if (old_crtc_state -> enable && !new_crtc_state -> enable )
649
+ new_vc4_crtc_state -> assigned_channel = VC4_HVS_CHANNEL_DISABLED ;
650
+
651
+ if (!new_crtc_state -> enable )
647
652
continue ;
648
653
654
+ if (new_vc4_crtc_state -> assigned_channel != VC4_HVS_CHANNEL_DISABLED ) {
655
+ unassigned_channels &= ~BIT (new_vc4_crtc_state -> assigned_channel );
656
+ continue ;
657
+ }
658
+
649
659
/*
650
660
* The problem we have to solve here is that we have
651
661
* up to 7 encoders, connected to up to 6 CRTCs.
@@ -674,7 +684,7 @@ vc4_atomic_check(struct drm_device *dev, struct drm_atomic_state *state)
674
684
if (matching_channels ) {
675
685
unsigned int channel = ffs (matching_channels ) - 1 ;
676
686
677
- vc4_crtc_state -> assigned_channel = channel ;
687
+ new_vc4_crtc_state -> assigned_channel = channel ;
678
688
unassigned_channels &= ~BIT (channel );
679
689
} else {
680
690
return - EINVAL ;
0 commit comments