@@ -82,7 +82,7 @@ static void i9xx_crtc_clock_get(struct intel_crtc *crtc,
82
82
static void ironlake_pch_clock_get (struct intel_crtc * crtc ,
83
83
struct intel_crtc_state * pipe_config );
84
84
85
- static int intel_set_mode (struct drm_crtc * crtc , struct drm_display_mode * mode ,
85
+ static int intel_set_mode (struct drm_crtc * crtc ,
86
86
struct drm_atomic_state * state );
87
87
static int intel_framebuffer_init (struct drm_device * dev ,
88
88
struct intel_framebuffer * ifb ,
@@ -9892,7 +9892,9 @@ bool intel_get_load_detect_pipe(struct drm_connector *connector,
9892
9892
if (ret )
9893
9893
goto fail ;
9894
9894
9895
- if (intel_set_mode (crtc , mode , state )) {
9895
+ drm_mode_copy (& crtc_state -> base .mode , mode );
9896
+
9897
+ if (intel_set_mode (crtc , state )) {
9896
9898
DRM_DEBUG_KMS ("failed to set mode on load-detect pipe\n" );
9897
9899
if (old -> release_fb )
9898
9900
old -> release_fb -> funcs -> destroy (old -> release_fb );
@@ -9966,7 +9968,7 @@ void intel_release_load_detect_pipe(struct drm_connector *connector,
9966
9968
if (ret )
9967
9969
goto fail ;
9968
9970
9969
- intel_set_mode (crtc , NULL , state );
9971
+ intel_set_mode (crtc , state );
9970
9972
9971
9973
drm_atomic_state_free (state );
9972
9974
@@ -11476,7 +11478,6 @@ clear_intel_crtc_state(struct intel_crtc_state *crtc_state)
11476
11478
11477
11479
static int
11478
11480
intel_modeset_pipe_config (struct drm_crtc * crtc ,
11479
- struct drm_display_mode * mode ,
11480
11481
struct drm_atomic_state * state ,
11481
11482
struct intel_crtc_state * pipe_config )
11482
11483
{
@@ -11499,10 +11500,6 @@ intel_modeset_pipe_config(struct drm_crtc *crtc,
11499
11500
11500
11501
clear_intel_crtc_state (pipe_config );
11501
11502
11502
- pipe_config -> base .crtc = crtc ;
11503
- drm_mode_copy (& pipe_config -> base .adjusted_mode , mode );
11504
- drm_mode_copy (& pipe_config -> base .mode , mode );
11505
-
11506
11503
pipe_config -> cpu_transcoder =
11507
11504
(enum transcoder ) to_intel_crtc (crtc )-> pipe ;
11508
11505
pipe_config -> shared_dpll = DPLL_ID_PRIVATE ;
@@ -12199,27 +12196,8 @@ static void update_scanline_offset(struct intel_crtc *crtc)
12199
12196
crtc -> scanline_offset = 1 ;
12200
12197
}
12201
12198
12202
- static void
12203
- intel_atomic_modeset_compute_changed_flags (struct drm_atomic_state * state ,
12204
- struct drm_crtc * modeset_crtc )
12205
- {
12206
- struct drm_crtc_state * crtc_state ;
12207
- struct drm_crtc * crtc ;
12208
- int i ;
12209
-
12210
- for_each_crtc_in_state (state , crtc , crtc_state , i ) {
12211
- if (crtc_state -> enable != crtc -> state -> enable )
12212
- crtc_state -> mode_changed = true;
12213
-
12214
- /* FIXME: Do we need to always set mode_changed for
12215
- * modeset_crtc if it is enabled? modeset_affect_pipes()
12216
- * did that. */
12217
- }
12218
- }
12219
-
12220
12199
static struct intel_crtc_state *
12221
12200
intel_modeset_compute_config (struct drm_crtc * crtc ,
12222
- struct drm_display_mode * mode ,
12223
12201
struct drm_atomic_state * state )
12224
12202
{
12225
12203
struct intel_crtc_state * pipe_config ;
@@ -12229,7 +12207,9 @@ intel_modeset_compute_config(struct drm_crtc *crtc,
12229
12207
if (ret )
12230
12208
return ERR_PTR (ret );
12231
12209
12232
- intel_atomic_modeset_compute_changed_flags (state , crtc );
12210
+ ret = drm_atomic_helper_check_modeset (state -> dev , state );
12211
+ if (ret )
12212
+ return ERR_PTR (ret );
12233
12213
12234
12214
/*
12235
12215
* Note this needs changes when we start tracking multiple modes
@@ -12244,7 +12224,7 @@ intel_modeset_compute_config(struct drm_crtc *crtc,
12244
12224
if (!pipe_config -> base .enable )
12245
12225
return pipe_config ;
12246
12226
12247
- ret = intel_modeset_pipe_config (crtc , mode , state , pipe_config );
12227
+ ret = intel_modeset_pipe_config (crtc , state , pipe_config );
12248
12228
if (ret )
12249
12229
return ERR_PTR (ret );
12250
12230
@@ -12262,6 +12242,10 @@ intel_modeset_compute_config(struct drm_crtc *crtc,
12262
12242
12263
12243
intel_dump_pipe_config (to_intel_crtc (crtc ), pipe_config ,"[modeset]" );
12264
12244
12245
+ ret = drm_atomic_helper_check_planes (state -> dev , state );
12246
+ if (ret )
12247
+ return ERR_PTR (ret );
12248
+
12265
12249
return pipe_config ;
12266
12250
}
12267
12251
@@ -12337,7 +12321,6 @@ static int __intel_set_mode_checks(struct drm_atomic_state *state)
12337
12321
}
12338
12322
12339
12323
static int __intel_set_mode (struct drm_crtc * modeset_crtc ,
12340
- struct drm_display_mode * mode ,
12341
12324
struct intel_crtc_state * pipe_config )
12342
12325
{
12343
12326
struct drm_device * dev = modeset_crtc -> dev ;
@@ -12380,7 +12363,7 @@ static int __intel_set_mode(struct drm_crtc *modeset_crtc,
12380
12363
* single crtc and mode.
12381
12364
*/
12382
12365
if (pipe_config -> base .enable && needs_modeset (& pipe_config -> base )) {
12383
- modeset_crtc -> mode = * mode ;
12366
+ modeset_crtc -> mode = pipe_config -> base . mode ;
12384
12367
/* mode_set/enable/disable functions rely on a correct pipe
12385
12368
* config. */
12386
12369
intel_crtc_set_state (to_intel_crtc (modeset_crtc ), pipe_config );
@@ -12446,12 +12429,11 @@ static int __intel_set_mode(struct drm_crtc *modeset_crtc,
12446
12429
}
12447
12430
12448
12431
static int intel_set_mode_with_config (struct drm_crtc * crtc ,
12449
- struct drm_display_mode * mode ,
12450
12432
struct intel_crtc_state * pipe_config )
12451
12433
{
12452
12434
int ret ;
12453
12435
12454
- ret = __intel_set_mode (crtc , mode , pipe_config );
12436
+ ret = __intel_set_mode (crtc , pipe_config );
12455
12437
12456
12438
if (ret == 0 )
12457
12439
intel_modeset_check_state (crtc -> dev );
@@ -12460,19 +12442,18 @@ static int intel_set_mode_with_config(struct drm_crtc *crtc,
12460
12442
}
12461
12443
12462
12444
static int intel_set_mode (struct drm_crtc * crtc ,
12463
- struct drm_display_mode * mode ,
12464
12445
struct drm_atomic_state * state )
12465
12446
{
12466
12447
struct intel_crtc_state * pipe_config ;
12467
12448
int ret = 0 ;
12468
12449
12469
- pipe_config = intel_modeset_compute_config (crtc , mode , state );
12450
+ pipe_config = intel_modeset_compute_config (crtc , state );
12470
12451
if (IS_ERR (pipe_config )) {
12471
12452
ret = PTR_ERR (pipe_config );
12472
12453
goto out ;
12473
12454
}
12474
12455
12475
- ret = intel_set_mode_with_config (crtc , mode , pipe_config );
12456
+ ret = intel_set_mode_with_config (crtc , pipe_config );
12476
12457
if (ret )
12477
12458
goto out ;
12478
12459
@@ -12539,125 +12520,21 @@ void intel_crtc_restore_mode(struct drm_crtc *crtc)
12539
12520
}
12540
12521
12541
12522
crtc_state -> base .enable = intel_crtc -> new_enabled ;
12523
+
12524
+ if (& intel_crtc -> base == crtc )
12525
+ drm_mode_copy (& crtc_state -> base .mode , & crtc -> mode );
12542
12526
}
12543
12527
12544
12528
intel_modeset_setup_plane_state (state , crtc , & crtc -> mode ,
12545
12529
crtc -> primary -> fb , crtc -> x , crtc -> y );
12546
12530
12547
- intel_set_mode (crtc , & crtc -> mode , state );
12531
+ intel_set_mode (crtc , state );
12548
12532
12549
12533
drm_atomic_state_free (state );
12550
12534
}
12551
12535
12552
12536
#undef for_each_intel_crtc_masked
12553
12537
12554
- static bool
12555
- is_crtc_connector_off (struct drm_mode_set * set )
12556
- {
12557
- int i ;
12558
-
12559
- if (set -> num_connectors == 0 )
12560
- return false;
12561
-
12562
- if (WARN_ON (set -> connectors == NULL ))
12563
- return false;
12564
-
12565
- for (i = 0 ; i < set -> num_connectors ; i ++ )
12566
- if (set -> connectors [i ]-> encoder &&
12567
- set -> connectors [i ]-> encoder -> crtc == set -> crtc &&
12568
- set -> connectors [i ]-> dpms != DRM_MODE_DPMS_ON )
12569
- return true;
12570
-
12571
- return false;
12572
- }
12573
-
12574
- static void
12575
- intel_set_config_compute_mode_changes (struct drm_mode_set * set ,
12576
- struct intel_crtc_state * pipe_config )
12577
- {
12578
- struct drm_atomic_state * state ;
12579
- struct drm_connector * connector ;
12580
- struct drm_connector_state * connector_state ;
12581
- struct drm_crtc * crtc ;
12582
- struct drm_crtc_state * crtc_state ;
12583
- int i ;
12584
-
12585
- /* We should be able to check here if the fb has the same properties
12586
- * and then just flip_or_move it */
12587
- if (is_crtc_connector_off (set )) {
12588
- pipe_config -> base .mode_changed = true;
12589
- } else if (set -> crtc -> primary -> fb != set -> fb ) {
12590
- /*
12591
- * If we have no fb, we can only flip as long as the crtc is
12592
- * active, otherwise we need a full mode set. The crtc may
12593
- * be active if we've only disabled the primary plane, or
12594
- * in fastboot situations.
12595
- */
12596
- if (set -> crtc -> primary -> fb == NULL ) {
12597
- struct intel_crtc * intel_crtc =
12598
- to_intel_crtc (set -> crtc );
12599
-
12600
- if (intel_crtc -> active ) {
12601
- DRM_DEBUG_KMS ("crtc has no fb, will flip\n" );
12602
- pipe_config -> base .planes_changed = true;
12603
- } else {
12604
- DRM_DEBUG_KMS ("inactive crtc, full mode set\n" );
12605
- pipe_config -> base .mode_changed = true;
12606
- }
12607
- } else if (set -> fb == NULL ) {
12608
- pipe_config -> base .mode_changed = true;
12609
- } else if (set -> fb -> pixel_format !=
12610
- set -> crtc -> primary -> fb -> pixel_format ) {
12611
- pipe_config -> base .mode_changed = true;
12612
- } else {
12613
- pipe_config -> base .planes_changed = true;
12614
- }
12615
- }
12616
-
12617
- if (set -> fb && (set -> x != set -> crtc -> x || set -> y != set -> crtc -> y ))
12618
- pipe_config -> base .planes_changed = true;
12619
-
12620
- if (set -> mode && !drm_mode_equal (set -> mode , & set -> crtc -> mode )) {
12621
- DRM_DEBUG_KMS ("modes are different, full mode set\n" );
12622
- drm_mode_debug_printmodeline (& set -> crtc -> mode );
12623
- drm_mode_debug_printmodeline (set -> mode );
12624
- pipe_config -> base .mode_changed = true;
12625
- }
12626
-
12627
- state = pipe_config -> base .state ;
12628
-
12629
- for_each_connector_in_state (state , connector , connector_state , i ) {
12630
- if (connector_state -> best_encoder !=
12631
- connector -> state -> best_encoder ) {
12632
- DRM_DEBUG_KMS ("[CONNECTOR:%d:%s] encoder changed, full mode switch\n" ,
12633
- connector -> base .id ,
12634
- connector -> name );
12635
- pipe_config -> base .mode_changed = true;
12636
- }
12637
-
12638
- if (connector_state -> crtc != connector -> state -> crtc ) {
12639
- DRM_DEBUG_KMS ("[CONNECTOR:%d:%s] crtc changed, full mode switch\n" ,
12640
- connector -> base .id ,
12641
- connector -> name );
12642
- pipe_config -> base .mode_changed = true;
12643
- }
12644
- }
12645
-
12646
- for_each_crtc_in_state (state , crtc , crtc_state , i ) {
12647
- if (crtc_state -> enable == crtc -> state -> enable )
12648
- continue ;
12649
-
12650
- DRM_DEBUG_KMS ("[CRTC:%d] %sabled, full mode switch\n" ,
12651
- crtc -> base .id ,
12652
- crtc_state -> enable ? "en" : "dis" );
12653
- pipe_config -> base .mode_changed = true;
12654
- }
12655
-
12656
- DRM_DEBUG_KMS ("computed changes for [CRTC:%d], mode_changed=%d, fb_changed=%d\n" ,
12657
- set -> crtc -> base .id , pipe_config -> base .mode_changed ,
12658
- pipe_config -> base .planes_changed );
12659
- }
12660
-
12661
12538
static bool intel_connector_in_mode_set (struct intel_connector * connector ,
12662
12539
struct drm_mode_set * set )
12663
12540
{
@@ -12774,6 +12651,21 @@ intel_modeset_stage_output_state(struct drm_device *dev,
12774
12651
crtc_state -> enable = drm_atomic_connectors_for_crtc (state , crtc );
12775
12652
}
12776
12653
12654
+ ret = intel_modeset_setup_plane_state (state , set -> crtc , set -> mode ,
12655
+ set -> fb , set -> x , set -> y );
12656
+ if (ret )
12657
+ return ret ;
12658
+
12659
+ crtc_state = drm_atomic_get_crtc_state (state , set -> crtc );
12660
+ if (IS_ERR (crtc_state ))
12661
+ return PTR_ERR (crtc_state );
12662
+
12663
+ if (set -> mode )
12664
+ drm_mode_copy (& crtc_state -> mode , set -> mode );
12665
+
12666
+ if (set -> num_connectors )
12667
+ crtc_state -> active = true;
12668
+
12777
12669
return 0 ;
12778
12670
}
12779
12671
@@ -12821,30 +12713,17 @@ static int intel_crtc_set_config(struct drm_mode_set *set)
12821
12713
if (ret )
12822
12714
goto out ;
12823
12715
12824
- ret = intel_modeset_setup_plane_state (state , set -> crtc , set -> mode ,
12825
- set -> fb , set -> x , set -> y );
12826
- if (ret )
12827
- goto out ;
12828
-
12829
- pipe_config = intel_modeset_compute_config (set -> crtc , set -> mode ,
12830
- state );
12716
+ pipe_config = intel_modeset_compute_config (set -> crtc , state );
12831
12717
if (IS_ERR (pipe_config )) {
12832
12718
ret = PTR_ERR (pipe_config );
12833
12719
goto out ;
12834
12720
}
12835
12721
12836
- /* Compute whether we need a full modeset, only an fb base update or no
12837
- * change at all. In the future we might also check whether only the
12838
- * mode changed, e.g. for LVDS where we only change the panel fitter in
12839
- * such cases. */
12840
- intel_set_config_compute_mode_changes (set , pipe_config );
12841
-
12842
12722
intel_update_pipe_size (to_intel_crtc (set -> crtc ));
12843
12723
12844
12724
primary_plane_was_visible = primary_plane_visible (set -> crtc );
12845
12725
12846
- ret = intel_set_mode_with_config (set -> crtc , set -> mode ,
12847
- pipe_config );
12726
+ ret = intel_set_mode_with_config (set -> crtc , pipe_config );
12848
12727
12849
12728
if (ret == 0 &&
12850
12729
pipe_config -> base .enable &&
0 commit comments