1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
|
From 27a4cd3c9986626cc731282e2e4887121f72f5f7 Mon Sep 17 00:00:00 2001
From: Maxime Ripard <maxime@cerno.tech>
Date: Wed, 28 Oct 2020 13:32:21 +0100
Subject: [PATCH] drm/atomic: Pass the full state to CRTC atomic_check
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Commit 29b77ad7b9ca8c87152a1a9e8188970fb2a93df4 upstream.
The current atomic helpers have either their object state being passed as
an argument or the full atomic state.
The former is the pattern that was done at first, before switching to the
latter for new hooks or when it was needed.
Let's start convert all the remaining helpers to provide a consistent
interface, starting with the CRTC's atomic_check.
The conversion was done using the coccinelle script below,
built tested on all the drivers and actually tested on vc4.
virtual report
@@
struct drm_crtc_helper_funcs *FUNCS;
struct drm_crtc *crtc;
struct drm_crtc_state *crtc_state;
identifier dev, state;
identifier ret, f;
@@
f(struct drm_device *dev, struct drm_atomic_state *state)
{
<...
- ret = FUNCS->atomic_check(crtc, crtc_state);
+ ret = FUNCS->atomic_check(crtc, state);
...>
}
@@
identifier crtc, new_state;
@@
struct drm_crtc_helper_funcs {
...
- int (*atomic_check)(struct drm_crtc *crtc, struct drm_crtc_state *new_state);
+ int (*atomic_check)(struct drm_crtc *crtc, struct drm_atomic_state *state);
...
}
@ crtc_atomic_func @
identifier helpers;
identifier func;
@@
static struct drm_crtc_helper_funcs helpers = {
...,
.atomic_check = func,
...,
};
@ ignores_new_state @
identifier crtc_atomic_func.func;
identifier crtc, new_state;
@@
int func(struct drm_crtc *crtc,
struct drm_crtc_state *new_state)
{
... when != new_state
}
@ adds_new_state depends on crtc_atomic_func && !ignores_new_state @
identifier crtc_atomic_func.func;
identifier crtc, new_state;
@@
int func(struct drm_crtc *crtc, struct drm_crtc_state *new_state)
{
+ struct drm_crtc_state *new_state = drm_atomic_get_new_crtc_state(state, crtc);
...
}
@ depends on crtc_atomic_func @
identifier crtc_atomic_func.func;
expression E;
type T;
@@
int func(...)
{
...
- T state = E;
+ T crtc_state = E;
<+...
- state
+ crtc_state
...+>
}
@ depends on crtc_atomic_func @
identifier crtc_atomic_func.func;
type T;
@@
int func(...)
{
...
- T state;
+ T crtc_state;
<+...
- state
+ crtc_state
...+>
}
@ depends on crtc_atomic_func @
identifier crtc_atomic_func.func;
identifier new_state;
identifier crtc;
@@
int func(struct drm_crtc *crtc,
- struct drm_crtc_state *new_state
+ struct drm_atomic_state *state
)
{ ... }
@@
identifier new_state;
identifier crtc;
@@
int vmw_du_crtc_atomic_check(struct drm_crtc *crtc,
- struct drm_crtc_state *new_state
+ struct drm_atomic_state *state
)
{
+ struct drm_crtc_state *new_state = drm_atomic_get_new_crtc_state(state, crtc);
...
}
@@
identifier new_state;
identifier crtc;
@@
int vmw_du_crtc_atomic_check(struct drm_crtc *crtc,
- struct drm_crtc_state *new_state
+ struct drm_atomic_state *state
);
@ include depends on adds_new_state @
@@
#include <drm/drm_atomic.h>
@ no_include depends on !include && adds_new_state @
@@
+ #include <drm/drm_atomic.h>
#include <drm/...>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20201028123222.1732139-1-maxime@cerno.tech
---
.../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 14 ++++++-----
.../gpu/drm/arm/display/komeda/komeda_crtc.c | 10 ++++----
drivers/gpu/drm/arm/malidp_crtc.c | 20 ++++++++--------
drivers/gpu/drm/armada/armada_crtc.c | 10 ++++----
drivers/gpu/drm/ast/ast_mode.c | 12 ++++++----
.../gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c | 3 ++-
drivers/gpu/drm/drm_atomic_helper.c | 2 +-
drivers/gpu/drm/drm_simple_kms_helper.c | 10 ++++----
drivers/gpu/drm/exynos/exynos_drm_crtc.c | 8 ++++---
drivers/gpu/drm/imx/ipuv3-crtc.c | 6 +++--
drivers/gpu/drm/ingenic/ingenic-drm-drv.c | 15 ++++++++----
drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 23 +++++++++++--------
drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c | 2 +-
drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c | 13 +++++++----
drivers/gpu/drm/mxsfb/mxsfb_kms.c | 10 ++++----
drivers/gpu/drm/nouveau/dispnv50/head.c | 7 ++++--
drivers/gpu/drm/omapdrm/omap_crtc.c | 13 +++++++----
drivers/gpu/drm/rcar-du/rcar_du_crtc.c | 11 +++++----
drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 4 +++-
drivers/gpu/drm/sun4i/sun4i_crtc.c | 7 ++++--
drivers/gpu/drm/tidss/tidss_crtc.c | 10 ++++----
drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 12 ++++++----
drivers/gpu/drm/vc4/vc4_crtc.c | 11 +++++----
drivers/gpu/drm/vc4/vc4_txp.c | 10 ++++----
drivers/gpu/drm/virtio/virtgpu_display.c | 2 +-
drivers/gpu/drm/vkms/vkms_crtc.c | 16 +++++++------
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 4 +++-
drivers/gpu/drm/vmwgfx/vmwgfx_kms.h | 2 +-
drivers/gpu/drm/xlnx/zynqmp_disp.c | 6 +++--
include/drm/drm_modeset_helper_vtables.h | 5 ++--
30 files changed, 168 insertions(+), 110 deletions(-)
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -5605,17 +5605,19 @@ static void dm_update_crtc_active_planes
}
static int dm_crtc_helper_atomic_check(struct drm_crtc *crtc,
- struct drm_crtc_state *state)
+ struct drm_atomic_state *state)
{
+ struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
+ crtc);
struct amdgpu_device *adev = drm_to_adev(crtc->dev);
struct dc *dc = adev->dm.dc;
- struct dm_crtc_state *dm_crtc_state = to_dm_crtc_state(state);
+ struct dm_crtc_state *dm_crtc_state = to_dm_crtc_state(crtc_state);
int ret = -EINVAL;
- dm_update_crtc_active_planes(crtc, state);
+ dm_update_crtc_active_planes(crtc, crtc_state);
if (unlikely(!dm_crtc_state->stream &&
- modeset_required(state, NULL, dm_crtc_state->stream))) {
+ modeset_required(crtc_state, NULL, dm_crtc_state->stream))) {
WARN_ON(1);
return ret;
}
@@ -5626,8 +5628,8 @@ static int dm_crtc_helper_atomic_check(s
* planes are disabled, which is not supported by the hardware. And there is legacy
* userspace which stops using the HW cursor altogether in response to the resulting EINVAL.
*/
- if (state->enable &&
- !(state->plane_mask & drm_plane_mask(crtc->primary)))
+ if (crtc_state->enable &&
+ !(crtc_state->plane_mask & drm_plane_mask(crtc->primary)))
return -EINVAL;
/* In some use cases, like reset, no stream is attached */
--- a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
@@ -74,16 +74,18 @@ static void komeda_crtc_update_clock_rat
*/
static int
komeda_crtc_atomic_check(struct drm_crtc *crtc,
- struct drm_crtc_state *state)
+ struct drm_atomic_state *state)
{
+ struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
+ crtc);
struct komeda_crtc *kcrtc = to_kcrtc(crtc);
- struct komeda_crtc_state *kcrtc_st = to_kcrtc_st(state);
+ struct komeda_crtc_state *kcrtc_st = to_kcrtc_st(crtc_state);
int err;
- if (drm_atomic_crtc_needs_modeset(state))
+ if (drm_atomic_crtc_needs_modeset(crtc_state))
komeda_crtc_update_clock_ratio(kcrtc_st);
- if (state->active) {
+ if (crtc_state->active) {
err = komeda_build_display_data_flow(kcrtc, kcrtc_st);
if (err)
return err;
--- a/drivers/gpu/drm/arm/malidp_crtc.c
+++ b/drivers/gpu/drm/arm/malidp_crtc.c
@@ -337,8 +337,10 @@ mclk_calc:
}
static int malidp_crtc_atomic_check(struct drm_crtc *crtc,
- struct drm_crtc_state *state)
+ struct drm_atomic_state *state)
{
+ struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
+ crtc);
struct malidp_drm *malidp = crtc_to_malidp_device(crtc);
struct malidp_hw_device *hwdev = malidp->dev;
struct drm_plane *plane;
@@ -373,7 +375,7 @@ static int malidp_crtc_atomic_check(stru
*/
/* first count the number of rotated planes */
- drm_atomic_crtc_state_for_each_plane_state(plane, pstate, state) {
+ drm_atomic_crtc_state_for_each_plane_state(plane, pstate, crtc_state) {
struct drm_framebuffer *fb = pstate->fb;
if ((pstate->rotation & MALIDP_ROTATED_MASK) || fb->modifier)
@@ -389,7 +391,7 @@ static int malidp_crtc_atomic_check(stru
rot_mem_free += hwdev->rotation_memory[1];
/* now validate the rotation memory requirements */
- drm_atomic_crtc_state_for_each_plane_state(plane, pstate, state) {
+ drm_atomic_crtc_state_for_each_plane_state(plane, pstate, crtc_state) {
struct malidp_plane *mp = to_malidp_plane(plane);
struct malidp_plane_state *ms = to_malidp_plane_state(pstate);
struct drm_framebuffer *fb = pstate->fb;
@@ -417,18 +419,18 @@ static int malidp_crtc_atomic_check(stru
}
/* If only the writeback routing has changed, we don't need a modeset */
- if (state->connectors_changed) {
+ if (crtc_state->connectors_changed) {
u32 old_mask = crtc->state->connector_mask;
- u32 new_mask = state->connector_mask;
+ u32 new_mask = crtc_state->connector_mask;
if ((old_mask ^ new_mask) ==
(1 << drm_connector_index(&malidp->mw_connector.base)))
- state->connectors_changed = false;
+ crtc_state->connectors_changed = false;
}
- ret = malidp_crtc_atomic_check_gamma(crtc, state);
- ret = ret ? ret : malidp_crtc_atomic_check_ctm(crtc, state);
- ret = ret ? ret : malidp_crtc_atomic_check_scaling(crtc, state);
+ ret = malidp_crtc_atomic_check_gamma(crtc, crtc_state);
+ ret = ret ? ret : malidp_crtc_atomic_check_ctm(crtc, crtc_state);
+ ret = ret ? ret : malidp_crtc_atomic_check_scaling(crtc, crtc_state);
return ret;
}
--- a/drivers/gpu/drm/armada/armada_crtc.c
+++ b/drivers/gpu/drm/armada/armada_crtc.c
@@ -413,15 +413,17 @@ static void armada_drm_crtc_mode_set_nof
}
static int armada_drm_crtc_atomic_check(struct drm_crtc *crtc,
- struct drm_crtc_state *state)
+ struct drm_atomic_state *state)
{
+ struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
+ crtc);
DRM_DEBUG_KMS("[CRTC:%d:%s]\n", crtc->base.id, crtc->name);
- if (state->gamma_lut && drm_color_lut_size(state->gamma_lut) != 256)
+ if (crtc_state->gamma_lut && drm_color_lut_size(crtc_state->gamma_lut) != 256)
return -EINVAL;
- if (state->color_mgmt_changed)
- state->planes_changed = true;
+ if (crtc_state->color_mgmt_changed)
+ crtc_state->planes_changed = true;
return 0;
}
--- a/drivers/gpu/drm/ast/ast_mode.c
+++ b/drivers/gpu/drm/ast/ast_mode.c
@@ -751,24 +751,26 @@ static void ast_crtc_dpms(struct drm_crt
}
static int ast_crtc_helper_atomic_check(struct drm_crtc *crtc,
- struct drm_crtc_state *state)
+ struct drm_atomic_state *state)
{
+ struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
+ crtc);
struct drm_device *dev = crtc->dev;
struct ast_crtc_state *ast_state;
const struct drm_format_info *format;
bool succ;
- if (!state->enable)
+ if (!crtc_state->enable)
return 0; /* no mode checks if CRTC is being disabled */
- ast_state = to_ast_crtc_state(state);
+ ast_state = to_ast_crtc_state(crtc_state);
format = ast_state->format;
if (drm_WARN_ON_ONCE(dev, !format))
return -EINVAL; /* BUG: We didn't set format in primary check(). */
- succ = ast_get_vbios_mode_info(format, &state->mode,
- &state->adjusted_mode,
+ succ = ast_get_vbios_mode_info(format, &crtc_state->mode,
+ &crtc_state->adjusted_mode,
&ast_state->vbios_mode_info);
if (!succ)
return -EINVAL;
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
@@ -325,8 +325,9 @@ static int atmel_hlcdc_crtc_select_outpu
}
static int atmel_hlcdc_crtc_atomic_check(struct drm_crtc *c,
- struct drm_crtc_state *s)
+ struct drm_atomic_state *state)
{
+ struct drm_crtc_state *s = drm_atomic_get_new_crtc_state(state, c);
int ret;
ret = atmel_hlcdc_crtc_select_output_mode(s);
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -918,7 +918,7 @@ drm_atomic_helper_check_planes(struct dr
if (!funcs || !funcs->atomic_check)
continue;
- ret = funcs->atomic_check(crtc, new_crtc_state);
+ ret = funcs->atomic_check(crtc, state);
if (ret) {
DRM_DEBUG_ATOMIC("[CRTC:%d:%s] atomic driver check failed\n",
crtc->base.id, crtc->name);
--- a/drivers/gpu/drm/drm_simple_kms_helper.c
+++ b/drivers/gpu/drm/drm_simple_kms_helper.c
@@ -86,16 +86,18 @@ drm_simple_kms_crtc_mode_valid(struct dr
}
static int drm_simple_kms_crtc_check(struct drm_crtc *crtc,
- struct drm_crtc_state *state)
+ struct drm_atomic_state *state)
{
- bool has_primary = state->plane_mask &
+ struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
+ crtc);
+ bool has_primary = crtc_state->plane_mask &
drm_plane_mask(crtc->primary);
/* We always want to have an active plane with an active CRTC */
- if (has_primary != state->enable)
+ if (has_primary != crtc_state->enable)
return -EINVAL;
- return drm_atomic_add_affected_planes(state->state, crtc);
+ return drm_atomic_add_affected_planes(crtc_state->state, crtc);
}
static void drm_simple_kms_crtc_enable(struct drm_crtc *crtc,
--- a/drivers/gpu/drm/exynos/exynos_drm_crtc.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
@@ -49,15 +49,17 @@ static void exynos_drm_crtc_atomic_disab
}
static int exynos_crtc_atomic_check(struct drm_crtc *crtc,
- struct drm_crtc_state *state)
+ struct drm_atomic_state *state)
{
+ struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
+ crtc);
struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);
- if (!state->enable)
+ if (!crtc_state->enable)
return 0;
if (exynos_crtc->ops->atomic_check)
- return exynos_crtc->ops->atomic_check(exynos_crtc, state);
+ return exynos_crtc->ops->atomic_check(exynos_crtc, crtc_state);
return 0;
}
--- a/drivers/gpu/drm/imx/ipuv3-crtc.c
+++ b/drivers/gpu/drm/imx/ipuv3-crtc.c
@@ -227,11 +227,13 @@ static bool ipu_crtc_mode_fixup(struct d
}
static int ipu_crtc_atomic_check(struct drm_crtc *crtc,
- struct drm_crtc_state *state)
+ struct drm_atomic_state *state)
{
+ struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
+ crtc);
u32 primary_plane_mask = drm_plane_mask(crtc->primary);
- if (state->active && (primary_plane_mask & state->plane_mask) == 0)
+ if (crtc_state->active && (primary_plane_mask & crtc_state->plane_mask) == 0)
return -EINVAL;
return 0;
--- a/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
+++ b/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
@@ -195,22 +195,27 @@ static void ingenic_drm_crtc_update_timi
}
static int ingenic_drm_crtc_atomic_check(struct drm_crtc *crtc,
- struct drm_crtc_state *state)
+ struct drm_atomic_state *state)
{
+ struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
+ crtc);
struct ingenic_drm *priv = drm_crtc_get_priv(crtc);
struct drm_plane_state *f1_state, *f0_state, *ipu_state = NULL;
- if (drm_atomic_crtc_needs_modeset(state) && priv->soc_info->has_osd) {
- f1_state = drm_atomic_get_plane_state(state->state, &priv->f1);
+ if (drm_atomic_crtc_needs_modeset(crtc_state) && priv->soc_info->has_osd) {
+ f1_state = drm_atomic_get_plane_state(crtc_state->state,
+ &priv->f1);
if (IS_ERR(f1_state))
return PTR_ERR(f1_state);
- f0_state = drm_atomic_get_plane_state(state->state, &priv->f0);
+ f0_state = drm_atomic_get_plane_state(crtc_state->state,
+ &priv->f0);
if (IS_ERR(f0_state))
return PTR_ERR(f0_state);
if (IS_ENABLED(CONFIG_DRM_INGENIC_IPU) && priv->ipu_plane) {
- ipu_state = drm_atomic_get_plane_state(state->state, priv->ipu_plane);
+ ipu_state = drm_atomic_get_plane_state(crtc_state->state,
+ priv->ipu_plane);
if (IS_ERR(ipu_state))
return PTR_ERR(ipu_state);
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
@@ -815,10 +815,12 @@ struct plane_state {
};
static int dpu_crtc_atomic_check(struct drm_crtc *crtc,
- struct drm_crtc_state *state)
+ struct drm_atomic_state *state)
{
+ struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
+ crtc);
struct dpu_crtc *dpu_crtc = to_dpu_crtc(crtc);
- struct dpu_crtc_state *cstate = to_dpu_crtc_state(state);
+ struct dpu_crtc_state *cstate = to_dpu_crtc_state(crtc_state);
struct plane_state *pstates;
const struct drm_plane_state *pstate;
@@ -835,32 +837,33 @@ static int dpu_crtc_atomic_check(struct
pstates = kzalloc(sizeof(*pstates) * DPU_STAGE_MAX * 4, GFP_KERNEL);
- if (!state->enable || !state->active) {
+ if (!crtc_state->enable || !crtc_state->active) {
DPU_DEBUG("crtc%d -> enable %d, active %d, skip atomic_check\n",
- crtc->base.id, state->enable, state->active);
+ crtc->base.id, crtc_state->enable,
+ crtc_state->active);
goto end;
}
- mode = &state->adjusted_mode;
+ mode = &crtc_state->adjusted_mode;
DPU_DEBUG("%s: check", dpu_crtc->name);
/* force a full mode set if active state changed */
- if (state->active_changed)
- state->mode_changed = true;
+ if (crtc_state->active_changed)
+ crtc_state->mode_changed = true;
memset(pipe_staged, 0, sizeof(pipe_staged));
if (cstate->num_mixers) {
mixer_width = mode->hdisplay / cstate->num_mixers;
- _dpu_crtc_setup_lm_bounds(crtc, state);
+ _dpu_crtc_setup_lm_bounds(crtc, crtc_state);
}
crtc_rect.x2 = mode->hdisplay;
crtc_rect.y2 = mode->vdisplay;
/* get plane state for all drm planes associated with crtc state */
- drm_atomic_crtc_state_for_each_plane_state(plane, pstate, state) {
+ drm_atomic_crtc_state_for_each_plane_state(plane, pstate, crtc_state) {
struct drm_rect dst, clip = crtc_rect;
if (IS_ERR_OR_NULL(pstate)) {
@@ -966,7 +969,7 @@ static int dpu_crtc_atomic_check(struct
atomic_inc(&_dpu_crtc_get_kms(crtc)->bandwidth_ref);
- rc = dpu_core_perf_crtc_check(crtc, state);
+ rc = dpu_core_perf_crtc_check(crtc, crtc_state);
if (rc) {
DPU_ERROR("crtc%d failed performance check %d\n",
crtc->base.id, rc);
--- a/drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c
+++ b/drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c
@@ -307,7 +307,7 @@ static void mdp4_crtc_atomic_enable(stru
}
static int mdp4_crtc_atomic_check(struct drm_crtc *crtc,
- struct drm_crtc_state *state)
+ struct drm_atomic_state *state)
{
struct mdp4_crtc *mdp4_crtc = to_mdp4_crtc(crtc);
DBG("%s: check", mdp4_crtc->name);
--- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c
+++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c
@@ -7,6 +7,7 @@
#include <linux/sort.h>
+#include <drm/drm_atomic.h>
#include <drm/drm_mode.h>
#include <drm/drm_crtc.h>
#include <drm/drm_flip_work.h>
@@ -682,15 +683,17 @@ static enum mdp_mixer_stage_id get_start
}
static int mdp5_crtc_atomic_check(struct drm_crtc *crtc,
- struct drm_crtc_state *state)
+ struct drm_atomic_state *state)
{
+ struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
+ crtc);
struct mdp5_kms *mdp5_kms = get_kms(crtc);
struct drm_plane *plane;
struct drm_device *dev = crtc->dev;
struct plane_state pstates[STAGE_MAX + 1];
const struct mdp5_cfg_hw *hw_cfg;
const struct drm_plane_state *pstate;
- const struct drm_display_mode *mode = &state->adjusted_mode;
+ const struct drm_display_mode *mode = &crtc_state->adjusted_mode;
bool cursor_plane = false;
bool need_right_mixer = false;
int cnt = 0, i;
@@ -699,7 +702,7 @@ static int mdp5_crtc_atomic_check(struct
DBG("%s: check", crtc->name);
- drm_atomic_crtc_state_for_each_plane_state(plane, pstate, state) {
+ drm_atomic_crtc_state_for_each_plane_state(plane, pstate, crtc_state) {
if (!pstate->visible)
continue;
@@ -731,7 +734,7 @@ static int mdp5_crtc_atomic_check(struct
if (mode->hdisplay > hw_cfg->lm.max_width)
need_right_mixer = true;
- ret = mdp5_crtc_setup_pipeline(crtc, state, need_right_mixer);
+ ret = mdp5_crtc_setup_pipeline(crtc, crtc_state, need_right_mixer);
if (ret) {
DRM_DEV_ERROR(dev->dev, "couldn't assign mixers %d\n", ret);
return ret;
@@ -744,7 +747,7 @@ static int mdp5_crtc_atomic_check(struct
WARN_ON(cursor_plane &&
(pstates[cnt - 1].plane->type != DRM_PLANE_TYPE_CURSOR));
- start = get_start_stage(crtc, state, &pstates[0].state->base);
+ start = get_start_stage(crtc, crtc_state, &pstates[0].state->base);
/* verify that there are not too many planes attached to crtc
* and that we don't have conflicting mixer stages:
--- a/drivers/gpu/drm/mxsfb/mxsfb_kms.c
+++ b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
@@ -310,17 +310,19 @@ static void mxsfb_crtc_mode_set_nofb(str
}
static int mxsfb_crtc_atomic_check(struct drm_crtc *crtc,
- struct drm_crtc_state *state)
+ struct drm_atomic_state *state)
{
- bool has_primary = state->plane_mask &
+ struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
+ crtc);
+ bool has_primary = crtc_state->plane_mask &
drm_plane_mask(crtc->primary);
/* The primary plane has to be enabled when the CRTC is active. */
- if (state->active && !has_primary)
+ if (crtc_state->active && !has_primary)
return -EINVAL;
/* TODO: Is this needed ? */
- return drm_atomic_add_affected_planes(state->state, crtc);
+ return drm_atomic_add_affected_planes(crtc_state->state, crtc);
}
static void mxsfb_crtc_atomic_flush(struct drm_crtc *crtc,
--- a/drivers/gpu/drm/nouveau/dispnv50/head.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/head.c
@@ -30,6 +30,7 @@
#include <nvif/event.h>
#include <nvif/cl0046.h>
+#include <drm/drm_atomic.h>
#include <drm/drm_atomic_helper.h>
#include <drm/drm_crtc_helper.h>
#include <drm/drm_vblank.h>
@@ -315,12 +316,14 @@ nv50_head_atomic_check_mode(struct nv50_
}
static int
-nv50_head_atomic_check(struct drm_crtc *crtc, struct drm_crtc_state *state)
+nv50_head_atomic_check(struct drm_crtc *crtc, struct drm_atomic_state *state)
{
+ struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
+ crtc);
struct nouveau_drm *drm = nouveau_drm(crtc->dev);
struct nv50_head *head = nv50_head(crtc);
struct nv50_head_atom *armh = nv50_head_atom(crtc->state);
- struct nv50_head_atom *asyh = nv50_head_atom(state);
+ struct nv50_head_atom *asyh = nv50_head_atom(crtc_state);
struct nouveau_conn_atom *asyc = NULL;
struct drm_connector_state *conns;
struct drm_connector *conn;
--- a/drivers/gpu/drm/omapdrm/omap_crtc.c
+++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
@@ -569,22 +569,25 @@ static bool omap_crtc_is_manually_update
}
static int omap_crtc_atomic_check(struct drm_crtc *crtc,
- struct drm_crtc_state *state)
+ struct drm_atomic_state *state)
{
+ struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
+ crtc);
struct drm_plane_state *pri_state;
- if (state->color_mgmt_changed && state->gamma_lut) {
- unsigned int length = state->gamma_lut->length /
+ if (crtc_state->color_mgmt_changed && crtc_state->gamma_lut) {
+ unsigned int length = crtc_state->gamma_lut->length /
sizeof(struct drm_color_lut);
if (length < 2)
return -EINVAL;
}
- pri_state = drm_atomic_get_new_plane_state(state->state, crtc->primary);
+ pri_state = drm_atomic_get_new_plane_state(crtc_state->state,
+ crtc->primary);
if (pri_state) {
struct omap_crtc_state *omap_crtc_state =
- to_omap_crtc_state(state);
+ to_omap_crtc_state(crtc_state);
/* Mirror new values for zpos and rotation in omap_crtc_state */
omap_crtc_state->zpos = pri_state->zpos;
--- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
@@ -688,20 +688,23 @@ static void rcar_du_crtc_stop(struct rca
*/
static int rcar_du_crtc_atomic_check(struct drm_crtc *crtc,
- struct drm_crtc_state *state)
+ struct drm_atomic_state *state)
{
- struct rcar_du_crtc_state *rstate = to_rcar_crtc_state(state);
+ struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
+ crtc);
+ struct rcar_du_crtc_state *rstate = to_rcar_crtc_state(crtc_state);
struct drm_encoder *encoder;
int ret;
- ret = rcar_du_cmm_check(crtc, state);
+ ret = rcar_du_cmm_check(crtc, crtc_state);
if (ret)
return ret;
/* Store the routes from the CRTC output to the DU outputs. */
rstate->outputs = 0;
- drm_for_each_encoder_mask(encoder, crtc->dev, state->encoder_mask) {
+ drm_for_each_encoder_mask(encoder, crtc->dev,
+ crtc_state->encoder_mask) {
struct rcar_du_encoder *renc;
/* Skip the writeback encoder. */
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
@@ -1416,8 +1416,10 @@ static void vop_wait_for_irq_handler(str
}
static int vop_crtc_atomic_check(struct drm_crtc *crtc,
- struct drm_crtc_state *crtc_state)
+ struct drm_atomic_state *state)
{
+ struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
+ crtc);
struct vop *vop = to_vop(crtc);
struct drm_plane *plane;
struct drm_plane_state *plane_state;
--- a/drivers/gpu/drm/sun4i/sun4i_crtc.c
+++ b/drivers/gpu/drm/sun4i/sun4i_crtc.c
@@ -15,6 +15,7 @@
#include <video/videomode.h>
+#include <drm/drm_atomic.h>
#include <drm/drm_atomic_helper.h>
#include <drm/drm_crtc.h>
#include <drm/drm_modes.h>
@@ -45,14 +46,16 @@ static struct drm_encoder *sun4i_crtc_ge
}
static int sun4i_crtc_atomic_check(struct drm_crtc *crtc,
- struct drm_crtc_state *state)
+ struct drm_atomic_state *state)
{
+ struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
+ crtc);
struct sun4i_crtc *scrtc = drm_crtc_to_sun4i_crtc(crtc);
struct sunxi_engine *engine = scrtc->engine;
int ret = 0;
if (engine && engine->ops && engine->ops->atomic_check)
- ret = engine->ops->atomic_check(engine, state);
+ ret = engine->ops->atomic_check(engine, crtc_state);
return ret;
}
--- a/drivers/gpu/drm/tidss/tidss_crtc.c
+++ b/drivers/gpu/drm/tidss/tidss_crtc.c
@@ -85,8 +85,10 @@ void tidss_crtc_error_irq(struct drm_crt
/* drm_crtc_helper_funcs */
static int tidss_crtc_atomic_check(struct drm_crtc *crtc,
- struct drm_crtc_state *state)
+ struct drm_atomic_state *state)
{
+ struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
+ crtc);
struct drm_device *ddev = crtc->dev;
struct tidss_device *tidss = to_tidss(ddev);
struct dispc_device *dispc = tidss->dispc;
@@ -97,10 +99,10 @@ static int tidss_crtc_atomic_check(struc
dev_dbg(ddev->dev, "%s\n", __func__);
- if (!state->enable)
+ if (!crtc_state->enable)
return 0;
- mode = &state->adjusted_mode;
+ mode = &crtc_state->adjusted_mode;
ok = dispc_vp_mode_valid(dispc, hw_videoport, mode);
if (ok != MODE_OK) {
@@ -109,7 +111,7 @@ static int tidss_crtc_atomic_check(struc
return -EINVAL;
}
- return dispc_vp_bus_check(dispc, hw_videoport, state);
+ return dispc_vp_bus_check(dispc, hw_videoport, crtc_state);
}
/*
--- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
@@ -669,15 +669,17 @@ static bool tilcdc_crtc_mode_fixup(struc
}
static int tilcdc_crtc_atomic_check(struct drm_crtc *crtc,
- struct drm_crtc_state *state)
+ struct drm_atomic_state *state)
{
+ struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
+ crtc);
/* If we are not active we don't care */
- if (!state->active)
+ if (!crtc_state->active)
return 0;
- if (state->state->planes[0].ptr != crtc->primary ||
- state->state->planes[0].state == NULL ||
- state->state->planes[0].state->crtc != crtc) {
+ if (crtc_state->state->planes[0].ptr != crtc->primary ||
+ crtc_state->state->planes[0].state == NULL ||
+ crtc_state->state->planes[0].state->crtc != crtc) {
dev_dbg(crtc->dev->dev, "CRTC primary plane must be present");
return -EINVAL;
}
--- a/drivers/gpu/drm/vc4/vc4_crtc.c
+++ b/drivers/gpu/drm/vc4/vc4_crtc.c
@@ -601,18 +601,21 @@ void vc4_crtc_get_margins(struct drm_crt
}
static int vc4_crtc_atomic_check(struct drm_crtc *crtc,
- struct drm_crtc_state *state)
+ struct drm_atomic_state *state)
{
- struct vc4_crtc_state *vc4_state = to_vc4_crtc_state(state);
+ struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
+ crtc);
+ struct vc4_crtc_state *vc4_state = to_vc4_crtc_state(crtc_state);
struct drm_connector *conn;
struct drm_connector_state *conn_state;
int ret, i;
- ret = vc4_hvs_atomic_check(crtc, state);
+ ret = vc4_hvs_atomic_check(crtc, crtc_state);
if (ret)
return ret;
- for_each_new_connector_in_state(state->state, conn, conn_state, i) {
+ for_each_new_connector_in_state(crtc_state->state, conn, conn_state,
+ i) {
if (conn_state->crtc != crtc)
continue;
--- a/drivers/gpu/drm/vc4/vc4_txp.c
+++ b/drivers/gpu/drm/vc4/vc4_txp.c
@@ -386,16 +386,18 @@ static const struct drm_crtc_funcs vc4_t
};
static int vc4_txp_atomic_check(struct drm_crtc *crtc,
- struct drm_crtc_state *state)
+ struct drm_atomic_state *state)
{
- struct vc4_crtc_state *vc4_state = to_vc4_crtc_state(state);
+ struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
+ crtc);
+ struct vc4_crtc_state *vc4_state = to_vc4_crtc_state(crtc_state);
int ret;
- ret = vc4_hvs_atomic_check(crtc, state);
+ ret = vc4_hvs_atomic_check(crtc, crtc_state);
if (ret)
return ret;
- state->no_vblank = true;
+ crtc_state->no_vblank = true;
vc4_state->feed_txp = true;
return 0;
--- a/drivers/gpu/drm/virtio/virtgpu_display.c
+++ b/drivers/gpu/drm/virtio/virtgpu_display.c
@@ -111,7 +111,7 @@ static void virtio_gpu_crtc_atomic_disab
}
static int virtio_gpu_crtc_atomic_check(struct drm_crtc *crtc,
- struct drm_crtc_state *state)
+ struct drm_atomic_state *state)
{
return 0;
}
--- a/drivers/gpu/drm/vkms/vkms_crtc.c
+++ b/drivers/gpu/drm/vkms/vkms_crtc.c
@@ -169,9 +169,11 @@ static const struct drm_crtc_funcs vkms_
};
static int vkms_crtc_atomic_check(struct drm_crtc *crtc,
- struct drm_crtc_state *state)
+ struct drm_atomic_state *state)
{
- struct vkms_crtc_state *vkms_state = to_vkms_crtc_state(state);
+ struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
+ crtc);
+ struct vkms_crtc_state *vkms_state = to_vkms_crtc_state(crtc_state);
struct drm_plane *plane;
struct drm_plane_state *plane_state;
int i = 0, ret;
@@ -179,12 +181,12 @@ static int vkms_crtc_atomic_check(struct
if (vkms_state->active_planes)
return 0;
- ret = drm_atomic_add_affected_planes(state->state, crtc);
+ ret = drm_atomic_add_affected_planes(crtc_state->state, crtc);
if (ret < 0)
return ret;
- drm_for_each_plane_mask(plane, crtc->dev, state->plane_mask) {
- plane_state = drm_atomic_get_existing_plane_state(state->state,
+ drm_for_each_plane_mask(plane, crtc->dev, crtc_state->plane_mask) {
+ plane_state = drm_atomic_get_existing_plane_state(crtc_state->state,
plane);
WARN_ON(!plane_state);
@@ -200,8 +202,8 @@ static int vkms_crtc_atomic_check(struct
vkms_state->num_active_planes = i;
i = 0;
- drm_for_each_plane_mask(plane, crtc->dev, state->plane_mask) {
- plane_state = drm_atomic_get_existing_plane_state(state->state,
+ drm_for_each_plane_mask(plane, crtc->dev, crtc_state->plane_mask) {
+ plane_state = drm_atomic_get_existing_plane_state(crtc_state->state,
plane);
if (!plane_state->visible)
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
@@ -522,8 +522,10 @@ int vmw_du_cursor_plane_atomic_check(str
int vmw_du_crtc_atomic_check(struct drm_crtc *crtc,
- struct drm_crtc_state *new_state)
+ struct drm_atomic_state *state)
{
+ struct drm_crtc_state *new_state = drm_atomic_get_new_crtc_state(state,
+ crtc);
struct vmw_display_unit *du = vmw_crtc_to_du(new_state->crtc);
int connector_mask = drm_connector_mask(&du->connector);
bool has_primary = new_state->plane_mask &
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h
@@ -473,7 +473,7 @@ void vmw_du_plane_unpin_surf(struct vmw_
bool unreference);
int vmw_du_crtc_atomic_check(struct drm_crtc *crtc,
- struct drm_crtc_state *state);
+ struct drm_atomic_state *state);
void vmw_du_crtc_atomic_begin(struct drm_crtc *crtc,
struct drm_crtc_state *old_crtc_state);
void vmw_du_crtc_atomic_flush(struct drm_crtc *crtc,
--- a/drivers/gpu/drm/xlnx/zynqmp_disp.c
+++ b/drivers/gpu/drm/xlnx/zynqmp_disp.c
@@ -1506,9 +1506,11 @@ zynqmp_disp_crtc_atomic_disable(struct d
}
static int zynqmp_disp_crtc_atomic_check(struct drm_crtc *crtc,
- struct drm_crtc_state *state)
+ struct drm_atomic_state *state)
{
- return drm_atomic_add_affected_planes(state->state, crtc);
+ struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
+ crtc);
+ return drm_atomic_add_affected_planes(crtc_state->state, crtc);
}
static void
--- a/include/drm/drm_modeset_helper_vtables.h
+++ b/include/drm/drm_modeset_helper_vtables.h
@@ -336,8 +336,7 @@ struct drm_crtc_helper_funcs {
*
* This function is called in the check phase of an atomic update. The
* driver is not allowed to change anything outside of the free-standing
- * state objects passed-in or assembled in the overall &drm_atomic_state
- * update tracking structure.
+ * state object passed-in.
*
* Also beware that userspace can request its own custom modes, neither
* core nor helpers filter modes to the list of probe modes reported by
@@ -353,7 +352,7 @@ struct drm_crtc_helper_funcs {
* deadlock.
*/
int (*atomic_check)(struct drm_crtc *crtc,
- struct drm_crtc_state *state);
+ struct drm_atomic_state *state);
/**
* @atomic_begin:
|