aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/armada/armada_output.h2
-rw-r--r--drivers/gpu/drm/drm_atomic.c66
-rw-r--r--drivers/gpu/drm/drm_atomic_helper.c253
-rw-r--r--drivers/gpu/drm/drm_crtc.c22
-rw-r--r--drivers/gpu/drm/drm_crtc_helper.c24
-rw-r--r--drivers/gpu/drm/drm_fb_helper.c8
-rw-r--r--drivers/gpu/drm/drm_plane_helper.c4
-rw-r--r--drivers/gpu/drm/drm_probe_helper.c2
-rw-r--r--drivers/gpu/drm/exynos/exynos_hdmi.c2
-rw-r--r--drivers/gpu/drm/gma500/cdv_intel_display.c2
-rw-r--r--drivers/gpu/drm/gma500/cdv_intel_hdmi.c2
-rw-r--r--drivers/gpu/drm/gma500/cdv_intel_lvds.c2
-rw-r--r--drivers/gpu/drm/gma500/gma_display.c10
-rw-r--r--drivers/gpu/drm/gma500/mdfld_dsi_output.c2
-rw-r--r--drivers/gpu/drm/gma500/mdfld_intel_display.c2
-rw-r--r--drivers/gpu/drm/gma500/oaktrail_crtc.c2
-rw-r--r--drivers/gpu/drm/gma500/oaktrail_hdmi.c2
-rw-r--r--drivers/gpu/drm/gma500/psb_intel_display.c2
-rw-r--r--drivers/gpu/drm/gma500/psb_intel_lvds.c2
-rw-r--r--drivers/gpu/drm/mgag200/mgag200_mode.c2
-rw-r--r--drivers/gpu/drm/nouveau/dispnv04/crtc.c4
-rw-r--r--drivers/gpu/drm/nouveau/dispnv04/dac.c4
-rw-r--r--drivers/gpu/drm/nouveau/dispnv04/dfp.c4
-rw-r--r--drivers/gpu/drm/nouveau/dispnv04/disp.c6
-rw-r--r--drivers/gpu/drm/nouveau/dispnv04/tvnv04.c4
-rw-r--r--drivers/gpu/drm/nouveau/dispnv04/tvnv17.c4
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_connector.c4
-rw-r--r--drivers/gpu/drm/qxl/qxl_drv.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon_connectors.c20
-rw-r--r--drivers/gpu/drm/radeon/radeon_dp_mst.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon_legacy_encoders.c2
31 files changed, 170 insertions, 299 deletions
diff --git a/drivers/gpu/drm/armada/armada_output.h b/drivers/gpu/drm/armada/armada_output.h
index 4126d43b5057..3c4023e142d0 100644
--- a/drivers/gpu/drm/armada/armada_output.h
+++ b/drivers/gpu/drm/armada/armada_output.h
@@ -9,7 +9,7 @@
9#define ARMADA_CONNETOR_H 9#define ARMADA_CONNETOR_H
10 10
11#define encoder_helper_funcs(encoder) \ 11#define encoder_helper_funcs(encoder) \
12 ((struct drm_encoder_helper_funcs *)encoder->helper_private) 12 ((const struct drm_encoder_helper_funcs *)encoder->helper_private)
13 13
14struct armada_output_type { 14struct armada_output_type {
15 int connector_type; 15 int connector_type;
diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index 57efdbeff008..6e3b78ee7d16 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -780,7 +780,7 @@ drm_atomic_set_crtc_for_plane(struct drm_plane_state *plane_state,
780EXPORT_SYMBOL(drm_atomic_set_crtc_for_plane); 780EXPORT_SYMBOL(drm_atomic_set_crtc_for_plane);
781 781
782/** 782/**
783 * drm_atomic_set_fb_for_plane - set crtc for plane 783 * drm_atomic_set_fb_for_plane - set framebuffer for plane
784 * @plane_state: atomic state object for the plane 784 * @plane_state: atomic state object for the plane
785 * @fb: fb to use for the plane 785 * @fb: fb to use for the plane
786 * 786 *
@@ -909,14 +909,13 @@ int
909drm_atomic_connectors_for_crtc(struct drm_atomic_state *state, 909drm_atomic_connectors_for_crtc(struct drm_atomic_state *state,
910 struct drm_crtc *crtc) 910 struct drm_crtc *crtc)
911{ 911{
912 int i, num_connected_connectors = 0; 912 struct drm_connector *connector;
913 913 struct drm_connector_state *conn_state;
914 for (i = 0; i < state->num_connector; i++) {
915 struct drm_connector_state *conn_state;
916 914
917 conn_state = state->connector_states[i]; 915 int i, num_connected_connectors = 0;
918 916
919 if (conn_state && conn_state->crtc == crtc) 917 for_each_connector_in_state(state, connector, conn_state, i) {
918 if (conn_state->crtc == crtc)
920 num_connected_connectors++; 919 num_connected_connectors++;
921 } 920 }
922 921
@@ -933,7 +932,7 @@ EXPORT_SYMBOL(drm_atomic_connectors_for_crtc);
933 * 932 *
934 * This function should be used by legacy entry points which don't understand 933 * This function should be used by legacy entry points which don't understand
935 * -EDEADLK semantics. For simplicity this one will grab all modeset locks after 934 * -EDEADLK semantics. For simplicity this one will grab all modeset locks after
936 * the slowpath completed. 935 * the slowpath completed.
937 */ 936 */
938void drm_atomic_legacy_backoff(struct drm_atomic_state *state) 937void drm_atomic_legacy_backoff(struct drm_atomic_state *state)
939{ 938{
@@ -968,19 +967,16 @@ int drm_atomic_check_only(struct drm_atomic_state *state)
968{ 967{
969 struct drm_device *dev = state->dev; 968 struct drm_device *dev = state->dev;
970 struct drm_mode_config *config = &dev->mode_config; 969 struct drm_mode_config *config = &dev->mode_config;
971 int nplanes = config->num_total_plane; 970 struct drm_plane *plane;
972 int ncrtcs = config->num_crtc; 971 struct drm_plane_state *plane_state;
972 struct drm_crtc *crtc;
973 struct drm_crtc_state *crtc_state;
973 int i, ret = 0; 974 int i, ret = 0;
974 975
975 DRM_DEBUG_ATOMIC("checking %p\n", state); 976 DRM_DEBUG_ATOMIC("checking %p\n", state);
976 977
977 for (i = 0; i < nplanes; i++) { 978 for_each_plane_in_state(state, plane, plane_state, i) {
978 struct drm_plane *plane = state->planes[i]; 979 ret = drm_atomic_plane_check(plane, plane_state);
979
980 if (!plane)
981 continue;
982
983 ret = drm_atomic_plane_check(plane, state->plane_states[i]);
984 if (ret) { 980 if (ret) {
985 DRM_DEBUG_ATOMIC("[PLANE:%d] atomic core check failed\n", 981 DRM_DEBUG_ATOMIC("[PLANE:%d] atomic core check failed\n",
986 plane->base.id); 982 plane->base.id);
@@ -988,13 +984,8 @@ int drm_atomic_check_only(struct drm_atomic_state *state)
988 } 984 }
989 } 985 }
990 986
991 for (i = 0; i < ncrtcs; i++) { 987 for_each_crtc_in_state(state, crtc, crtc_state, i) {
992 struct drm_crtc *crtc = state->crtcs[i]; 988 ret = drm_atomic_crtc_check(crtc, crtc_state);
993
994 if (!crtc)
995 continue;
996
997 ret = drm_atomic_crtc_check(crtc, state->crtc_states[i]);
998 if (ret) { 989 if (ret) {
999 DRM_DEBUG_ATOMIC("[CRTC:%d] atomic core check failed\n", 990 DRM_DEBUG_ATOMIC("[CRTC:%d] atomic core check failed\n",
1000 crtc->base.id); 991 crtc->base.id);
@@ -1006,13 +997,7 @@ int drm_atomic_check_only(struct drm_atomic_state *state)
1006 ret = config->funcs->atomic_check(state->dev, state); 997 ret = config->funcs->atomic_check(state->dev, state);
1007 998
1008 if (!state->allow_modeset) { 999 if (!state->allow_modeset) {
1009 for (i = 0; i < ncrtcs; i++) { 1000 for_each_crtc_in_state(state, crtc, crtc_state, i) {
1010 struct drm_crtc *crtc = state->crtcs[i];
1011 struct drm_crtc_state *crtc_state = state->crtc_states[i];
1012
1013 if (!crtc)
1014 continue;
1015
1016 if (crtc_state->mode_changed || 1001 if (crtc_state->mode_changed ||
1017 crtc_state->active_changed) { 1002 crtc_state->active_changed) {
1018 DRM_DEBUG_ATOMIC("[CRTC:%d] requires full modeset\n", 1003 DRM_DEBUG_ATOMIC("[CRTC:%d] requires full modeset\n",
@@ -1210,6 +1195,8 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,
1210 struct drm_atomic_state *state; 1195 struct drm_atomic_state *state;
1211 struct drm_modeset_acquire_ctx ctx; 1196 struct drm_modeset_acquire_ctx ctx;
1212 struct drm_plane *plane; 1197 struct drm_plane *plane;
1198 struct drm_crtc *crtc;
1199 struct drm_crtc_state *crtc_state;
1213 unsigned plane_mask = 0; 1200 unsigned plane_mask = 0;
1214 int ret = 0; 1201 int ret = 0;
1215 unsigned int i, j; 1202 unsigned int i, j;
@@ -1313,15 +1300,9 @@ retry:
1313 } 1300 }
1314 1301
1315 if (arg->flags & DRM_MODE_PAGE_FLIP_EVENT) { 1302 if (arg->flags & DRM_MODE_PAGE_FLIP_EVENT) {
1316 int ncrtcs = dev->mode_config.num_crtc; 1303 for_each_crtc_in_state(state, crtc, crtc_state, i) {
1317
1318 for (i = 0; i < ncrtcs; i++) {
1319 struct drm_crtc_state *crtc_state = state->crtc_states[i];
1320 struct drm_pending_vblank_event *e; 1304 struct drm_pending_vblank_event *e;
1321 1305
1322 if (!crtc_state)
1323 continue;
1324
1325 e = create_vblank_event(dev, file_priv, arg->user_data); 1306 e = create_vblank_event(dev, file_priv, arg->user_data);
1326 if (!e) { 1307 if (!e) {
1327 ret = -ENOMEM; 1308 ret = -ENOMEM;
@@ -1373,14 +1354,7 @@ fail:
1373 goto backoff; 1354 goto backoff;
1374 1355
1375 if (arg->flags & DRM_MODE_PAGE_FLIP_EVENT) { 1356 if (arg->flags & DRM_MODE_PAGE_FLIP_EVENT) {
1376 int ncrtcs = dev->mode_config.num_crtc; 1357 for_each_crtc_in_state(state, crtc, crtc_state, i) {
1377
1378 for (i = 0; i < ncrtcs; i++) {
1379 struct drm_crtc_state *crtc_state = state->crtc_states[i];
1380
1381 if (!crtc_state)
1382 continue;
1383
1384 destroy_vblank_event(dev, file_priv, crtc_state->event); 1358 destroy_vblank_event(dev, file_priv, crtc_state->event);
1385 crtc_state->event = NULL; 1359 crtc_state->event = NULL;
1386 } 1360 }
diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index 41c38edade74..1d2ca52530d5 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -248,30 +248,24 @@ update_connector_routing(struct drm_atomic_state *state, int conn_idx)
248static int 248static int
249mode_fixup(struct drm_atomic_state *state) 249mode_fixup(struct drm_atomic_state *state)
250{ 250{
251 int ncrtcs = state->dev->mode_config.num_crtc; 251 struct drm_crtc *crtc;
252 struct drm_crtc_state *crtc_state; 252 struct drm_crtc_state *crtc_state;
253 struct drm_connector *connector;
253 struct drm_connector_state *conn_state; 254 struct drm_connector_state *conn_state;
254 int i; 255 int i;
255 bool ret; 256 bool ret;
256 257
257 for (i = 0; i < ncrtcs; i++) { 258 for_each_crtc_in_state(state, crtc, crtc_state, i) {
258 crtc_state = state->crtc_states[i]; 259 if (!crtc_state->mode_changed)
259
260 if (!crtc_state || !crtc_state->mode_changed)
261 continue; 260 continue;
262 261
263 drm_mode_copy(&crtc_state->adjusted_mode, &crtc_state->mode); 262 drm_mode_copy(&crtc_state->adjusted_mode, &crtc_state->mode);
264 } 263 }
265 264
266 for (i = 0; i < state->num_connector; i++) { 265 for_each_connector_in_state(state, connector, conn_state, i) {
267 const struct drm_encoder_helper_funcs *funcs; 266 const struct drm_encoder_helper_funcs *funcs;
268 struct drm_encoder *encoder; 267 struct drm_encoder *encoder;
269 268
270 conn_state = state->connector_states[i];
271
272 if (!conn_state)
273 continue;
274
275 WARN_ON(!!conn_state->best_encoder != !!conn_state->crtc); 269 WARN_ON(!!conn_state->best_encoder != !!conn_state->crtc);
276 270
277 if (!conn_state->crtc || !conn_state->best_encoder) 271 if (!conn_state->crtc || !conn_state->best_encoder)
@@ -316,14 +310,10 @@ mode_fixup(struct drm_atomic_state *state)
316 } 310 }
317 } 311 }
318 312
319 for (i = 0; i < ncrtcs; i++) { 313 for_each_crtc_in_state(state, crtc, crtc_state, i) {
320 const struct drm_crtc_helper_funcs *funcs; 314 const struct drm_crtc_helper_funcs *funcs;
321 struct drm_crtc *crtc;
322 315
323 crtc_state = state->crtc_states[i]; 316 if (!crtc_state->mode_changed)
324 crtc = state->crtcs[i];
325
326 if (!crtc_state || !crtc_state->mode_changed)
327 continue; 317 continue;
328 318
329 funcs = crtc->helper_private; 319 funcs = crtc->helper_private;
@@ -371,18 +361,13 @@ int
371drm_atomic_helper_check_modeset(struct drm_device *dev, 361drm_atomic_helper_check_modeset(struct drm_device *dev,
372 struct drm_atomic_state *state) 362 struct drm_atomic_state *state)
373{ 363{
374 int ncrtcs = dev->mode_config.num_crtc;
375 struct drm_crtc *crtc; 364 struct drm_crtc *crtc;
376 struct drm_crtc_state *crtc_state; 365 struct drm_crtc_state *crtc_state;
366 struct drm_connector *connector;
367 struct drm_connector_state *connector_state;
377 int i, ret; 368 int i, ret;
378 369
379 for (i = 0; i < ncrtcs; i++) { 370 for_each_crtc_in_state(state, crtc, crtc_state, i) {
380 crtc = state->crtcs[i];
381 crtc_state = state->crtc_states[i];
382
383 if (!crtc)
384 continue;
385
386 if (!drm_mode_equal(&crtc->state->mode, &crtc_state->mode)) { 371 if (!drm_mode_equal(&crtc->state->mode, &crtc_state->mode)) {
387 DRM_DEBUG_ATOMIC("[CRTC:%d] mode changed\n", 372 DRM_DEBUG_ATOMIC("[CRTC:%d] mode changed\n",
388 crtc->base.id); 373 crtc->base.id);
@@ -396,7 +381,7 @@ drm_atomic_helper_check_modeset(struct drm_device *dev,
396 } 381 }
397 } 382 }
398 383
399 for (i = 0; i < state->num_connector; i++) { 384 for_each_connector_in_state(state, connector, connector_state, i) {
400 /* 385 /*
401 * This only sets crtc->mode_changed for routing changes, 386 * This only sets crtc->mode_changed for routing changes,
402 * drivers must set crtc->mode_changed themselves when connector 387 * drivers must set crtc->mode_changed themselves when connector
@@ -413,15 +398,9 @@ drm_atomic_helper_check_modeset(struct drm_device *dev,
413 * configuration. This must be done before calling mode_fixup in case a 398 * configuration. This must be done before calling mode_fixup in case a
414 * crtc only changed its mode but has the same set of connectors. 399 * crtc only changed its mode but has the same set of connectors.
415 */ 400 */
416 for (i = 0; i < ncrtcs; i++) { 401 for_each_crtc_in_state(state, crtc, crtc_state, i) {
417 int num_connectors; 402 int num_connectors;
418 403
419 crtc = state->crtcs[i];
420 crtc_state = state->crtc_states[i];
421
422 if (!crtc)
423 continue;
424
425 /* 404 /*
426 * We must set ->active_changed after walking connectors for 405 * We must set ->active_changed after walking connectors for
427 * otherwise an update that only changes active would result in 406 * otherwise an update that only changes active would result in
@@ -476,17 +455,14 @@ int
476drm_atomic_helper_check_planes(struct drm_device *dev, 455drm_atomic_helper_check_planes(struct drm_device *dev,
477 struct drm_atomic_state *state) 456 struct drm_atomic_state *state)
478{ 457{
479 int nplanes = dev->mode_config.num_total_plane; 458 struct drm_crtc *crtc;
480 int ncrtcs = dev->mode_config.num_crtc; 459 struct drm_crtc_state *crtc_state;
460 struct drm_plane *plane;
461 struct drm_plane_state *plane_state;
481 int i, ret = 0; 462 int i, ret = 0;
482 463
483 for (i = 0; i < nplanes; i++) { 464 for_each_plane_in_state(state, plane, plane_state, i) {
484 const struct drm_plane_helper_funcs *funcs; 465 const struct drm_plane_helper_funcs *funcs;
485 struct drm_plane *plane = state->planes[i];
486 struct drm_plane_state *plane_state = state->plane_states[i];
487
488 if (!plane)
489 continue;
490 466
491 funcs = plane->helper_private; 467 funcs = plane->helper_private;
492 468
@@ -503,12 +479,8 @@ drm_atomic_helper_check_planes(struct drm_device *dev,
503 } 479 }
504 } 480 }
505 481
506 for (i = 0; i < ncrtcs; i++) { 482 for_each_crtc_in_state(state, crtc, crtc_state, i) {
507 const struct drm_crtc_helper_funcs *funcs; 483 const struct drm_crtc_helper_funcs *funcs;
508 struct drm_crtc *crtc = state->crtcs[i];
509
510 if (!crtc)
511 continue;
512 484
513 funcs = crtc->helper_private; 485 funcs = crtc->helper_private;
514 486
@@ -567,22 +539,20 @@ EXPORT_SYMBOL(drm_atomic_helper_check);
567static void 539static void
568disable_outputs(struct drm_device *dev, struct drm_atomic_state *old_state) 540disable_outputs(struct drm_device *dev, struct drm_atomic_state *old_state)
569{ 541{
570 int ncrtcs = old_state->dev->mode_config.num_crtc; 542 struct drm_connector *connector;
543 struct drm_connector_state *old_conn_state;
544 struct drm_crtc *crtc;
545 struct drm_crtc_state *old_crtc_state;
571 int i; 546 int i;
572 547
573 for (i = 0; i < old_state->num_connector; i++) { 548 for_each_connector_in_state(old_state, connector, old_conn_state, i) {
574 const struct drm_encoder_helper_funcs *funcs; 549 const struct drm_encoder_helper_funcs *funcs;
575 struct drm_connector_state *old_conn_state;
576 struct drm_connector *connector;
577 struct drm_encoder *encoder; 550 struct drm_encoder *encoder;
578 struct drm_crtc_state *old_crtc_state; 551 struct drm_crtc_state *old_crtc_state;
579 552
580 old_conn_state = old_state->connector_states[i];
581 connector = old_state->connectors[i];
582
583 /* Shut down everything that's in the changeset and currently 553 /* Shut down everything that's in the changeset and currently
584 * still on. So need to check the old, saved state. */ 554 * still on. So need to check the old, saved state. */
585 if (!old_conn_state || !old_conn_state->crtc) 555 if (!old_conn_state->crtc)
586 continue; 556 continue;
587 557
588 old_crtc_state = old_state->crtc_states[drm_crtc_index(old_conn_state->crtc)]; 558 old_crtc_state = old_state->crtc_states[drm_crtc_index(old_conn_state->crtc)];
@@ -623,16 +593,11 @@ disable_outputs(struct drm_device *dev, struct drm_atomic_state *old_state)
623 encoder->bridge->funcs->post_disable(encoder->bridge); 593 encoder->bridge->funcs->post_disable(encoder->bridge);
624 } 594 }
625 595
626 for (i = 0; i < ncrtcs; i++) { 596 for_each_crtc_in_state(old_state, crtc, old_crtc_state, i) {
627 const struct drm_crtc_helper_funcs *funcs; 597 const struct drm_crtc_helper_funcs *funcs;
628 struct drm_crtc *crtc;
629 struct drm_crtc_state *old_crtc_state;
630
631 crtc = old_state->crtcs[i];
632 old_crtc_state = old_state->crtc_states[i];
633 598
634 /* Shut down everything that needs a full modeset. */ 599 /* Shut down everything that needs a full modeset. */
635 if (!crtc || !needs_modeset(crtc->state)) 600 if (!needs_modeset(crtc->state))
636 continue; 601 continue;
637 602
638 if (!old_crtc_state->active) 603 if (!old_crtc_state->active)
@@ -657,16 +622,15 @@ disable_outputs(struct drm_device *dev, struct drm_atomic_state *old_state)
657static void 622static void
658set_routing_links(struct drm_device *dev, struct drm_atomic_state *old_state) 623set_routing_links(struct drm_device *dev, struct drm_atomic_state *old_state)
659{ 624{
660 int ncrtcs = old_state->dev->mode_config.num_crtc; 625 struct drm_connector *connector;
626 struct drm_connector_state *old_conn_state;
627 struct drm_crtc *crtc;
628 struct drm_crtc_state *old_crtc_state;
661 int i; 629 int i;
662 630
663 /* clear out existing links */ 631 /* clear out existing links */
664 for (i = 0; i < old_state->num_connector; i++) { 632 for_each_connector_in_state(old_state, connector, old_conn_state, i) {
665 struct drm_connector *connector; 633 if (!connector->encoder)
666
667 connector = old_state->connectors[i];
668
669 if (!connector || !connector->encoder)
670 continue; 634 continue;
671 635
672 WARN_ON(!connector->encoder->crtc); 636 WARN_ON(!connector->encoder->crtc);
@@ -676,12 +640,8 @@ set_routing_links(struct drm_device *dev, struct drm_atomic_state *old_state)
676 } 640 }
677 641
678 /* set new links */ 642 /* set new links */
679 for (i = 0; i < old_state->num_connector; i++) { 643 for_each_connector_in_state(old_state, connector, old_conn_state, i) {
680 struct drm_connector *connector; 644 if (!connector->state->crtc)
681
682 connector = old_state->connectors[i];
683
684 if (!connector || !connector->state->crtc)
685 continue; 645 continue;
686 646
687 if (WARN_ON(!connector->state->best_encoder)) 647 if (WARN_ON(!connector->state->best_encoder))
@@ -692,14 +652,7 @@ set_routing_links(struct drm_device *dev, struct drm_atomic_state *old_state)
692 } 652 }
693 653
694 /* set legacy state in the crtc structure */ 654 /* set legacy state in the crtc structure */
695 for (i = 0; i < ncrtcs; i++) { 655 for_each_crtc_in_state(old_state, crtc, old_crtc_state, i) {
696 struct drm_crtc *crtc;
697
698 crtc = old_state->crtcs[i];
699
700 if (!crtc)
701 continue;
702
703 crtc->mode = crtc->state->mode; 656 crtc->mode = crtc->state->mode;
704 crtc->enabled = crtc->state->enable; 657 crtc->enabled = crtc->state->enable;
705 crtc->x = crtc->primary->state->src_x >> 16; 658 crtc->x = crtc->primary->state->src_x >> 16;
@@ -710,16 +663,16 @@ set_routing_links(struct drm_device *dev, struct drm_atomic_state *old_state)
710static void 663static void
711crtc_set_mode(struct drm_device *dev, struct drm_atomic_state *old_state) 664crtc_set_mode(struct drm_device *dev, struct drm_atomic_state *old_state)
712{ 665{
713 int ncrtcs = old_state->dev->mode_config.num_crtc; 666 struct drm_crtc *crtc;
667 struct drm_crtc_state *old_crtc_state;
668 struct drm_connector *connector;
669 struct drm_connector_state *old_conn_state;
714 int i; 670 int i;
715 671
716 for (i = 0; i < ncrtcs; i++) { 672 for_each_crtc_in_state(old_state, crtc, old_crtc_state, i) {
717 const struct drm_crtc_helper_funcs *funcs; 673 const struct drm_crtc_helper_funcs *funcs;
718 struct drm_crtc *crtc;
719
720 crtc = old_state->crtcs[i];
721 674
722 if (!crtc || !crtc->state->mode_changed) 675 if (!crtc->state->mode_changed)
723 continue; 676 continue;
724 677
725 funcs = crtc->helper_private; 678 funcs = crtc->helper_private;
@@ -732,16 +685,13 @@ crtc_set_mode(struct drm_device *dev, struct drm_atomic_state *old_state)
732 } 685 }
733 } 686 }
734 687
735 for (i = 0; i < old_state->num_connector; i++) { 688 for_each_connector_in_state(old_state, connector, old_conn_state, i) {
736 const struct drm_encoder_helper_funcs *funcs; 689 const struct drm_encoder_helper_funcs *funcs;
737 struct drm_connector *connector;
738 struct drm_crtc_state *new_crtc_state; 690 struct drm_crtc_state *new_crtc_state;
739 struct drm_encoder *encoder; 691 struct drm_encoder *encoder;
740 struct drm_display_mode *mode, *adjusted_mode; 692 struct drm_display_mode *mode, *adjusted_mode;
741 693
742 connector = old_state->connectors[i]; 694 if (!connector->state->best_encoder)
743
744 if (!connector || !connector->state->best_encoder)
745 continue; 695 continue;
746 696
747 encoder = connector->state->best_encoder; 697 encoder = connector->state->best_encoder;
@@ -809,17 +759,17 @@ EXPORT_SYMBOL(drm_atomic_helper_commit_modeset_disables);
809void drm_atomic_helper_commit_modeset_enables(struct drm_device *dev, 759void drm_atomic_helper_commit_modeset_enables(struct drm_device *dev,
810 struct drm_atomic_state *old_state) 760 struct drm_atomic_state *old_state)
811{ 761{
812 int ncrtcs = old_state->dev->mode_config.num_crtc; 762 struct drm_crtc *crtc;
763 struct drm_crtc_state *old_crtc_state;
764 struct drm_connector *connector;
765 struct drm_connector_state *old_conn_state;
813 int i; 766 int i;
814 767
815 for (i = 0; i < ncrtcs; i++) { 768 for_each_crtc_in_state(old_state, crtc, old_crtc_state, i) {
816 const struct drm_crtc_helper_funcs *funcs; 769 const struct drm_crtc_helper_funcs *funcs;
817 struct drm_crtc *crtc;
818
819 crtc = old_state->crtcs[i];
820 770
821 /* Need to filter out CRTCs where only planes change. */ 771 /* Need to filter out CRTCs where only planes change. */
822 if (!crtc || !needs_modeset(crtc->state)) 772 if (!needs_modeset(crtc->state))
823 continue; 773 continue;
824 774
825 if (!crtc->state->active) 775 if (!crtc->state->active)
@@ -838,14 +788,11 @@ void drm_atomic_helper_commit_modeset_enables(struct drm_device *dev,
838 } 788 }
839 } 789 }
840 790
841 for (i = 0; i < old_state->num_connector; i++) { 791 for_each_connector_in_state(old_state, connector, old_conn_state, i) {
842 const struct drm_encoder_helper_funcs *funcs; 792 const struct drm_encoder_helper_funcs *funcs;
843 struct drm_connector *connector;
844 struct drm_encoder *encoder; 793 struct drm_encoder *encoder;
845 794
846 connector = old_state->connectors[i]; 795 if (!connector->state->best_encoder)
847
848 if (!connector || !connector->state->best_encoder)
849 continue; 796 continue;
850 797
851 if (!connector->state->crtc->state->active || 798 if (!connector->state->crtc->state->active ||
@@ -879,13 +826,12 @@ EXPORT_SYMBOL(drm_atomic_helper_commit_modeset_enables);
879static void wait_for_fences(struct drm_device *dev, 826static void wait_for_fences(struct drm_device *dev,
880 struct drm_atomic_state *state) 827 struct drm_atomic_state *state)
881{ 828{
882 int nplanes = dev->mode_config.num_total_plane; 829 struct drm_plane *plane;
830 struct drm_plane_state *plane_state;
883 int i; 831 int i;
884 832
885 for (i = 0; i < nplanes; i++) { 833 for_each_plane_in_state(state, plane, plane_state, i) {
886 struct drm_plane *plane = state->planes[i]; 834 if (!plane->state->fence)
887
888 if (!plane || !plane->state->fence)
889 continue; 835 continue;
890 836
891 WARN_ON(!plane->state->fb); 837 WARN_ON(!plane->state->fb);
@@ -902,16 +848,9 @@ static bool framebuffer_changed(struct drm_device *dev,
902{ 848{
903 struct drm_plane *plane; 849 struct drm_plane *plane;
904 struct drm_plane_state *old_plane_state; 850 struct drm_plane_state *old_plane_state;
905 int nplanes = old_state->dev->mode_config.num_total_plane;
906 int i; 851 int i;
907 852
908 for (i = 0; i < nplanes; i++) { 853 for_each_plane_in_state(old_state, plane, old_plane_state, i) {
909 plane = old_state->planes[i];
910 old_plane_state = old_state->plane_states[i];
911
912 if (!plane)
913 continue;
914
915 if (plane->state->crtc != crtc && 854 if (plane->state->crtc != crtc &&
916 old_plane_state->crtc != crtc) 855 old_plane_state->crtc != crtc)
917 continue; 856 continue;
@@ -940,16 +879,9 @@ drm_atomic_helper_wait_for_vblanks(struct drm_device *dev,
940{ 879{
941 struct drm_crtc *crtc; 880 struct drm_crtc *crtc;
942 struct drm_crtc_state *old_crtc_state; 881 struct drm_crtc_state *old_crtc_state;
943 int ncrtcs = old_state->dev->mode_config.num_crtc;
944 int i, ret; 882 int i, ret;
945 883
946 for (i = 0; i < ncrtcs; i++) { 884 for_each_crtc_in_state(old_state, crtc, old_crtc_state, i) {
947 crtc = old_state->crtcs[i];
948 old_crtc_state = old_state->crtc_states[i];
949
950 if (!crtc)
951 continue;
952
953 /* No one cares about the old state, so abuse it for tracking 885 /* No one cares about the old state, so abuse it for tracking
954 * and store whether we hold a vblank reference (and should do a 886 * and store whether we hold a vblank reference (and should do a
955 * vblank wait) in the ->enable boolean. */ 887 * vblank wait) in the ->enable boolean. */
@@ -974,11 +906,8 @@ drm_atomic_helper_wait_for_vblanks(struct drm_device *dev,
974 old_crtc_state->last_vblank_count = drm_vblank_count(dev, i); 906 old_crtc_state->last_vblank_count = drm_vblank_count(dev, i);
975 } 907 }
976 908
977 for (i = 0; i < ncrtcs; i++) { 909 for_each_crtc_in_state(old_state, crtc, old_crtc_state, i) {
978 crtc = old_state->crtcs[i]; 910 if (!old_crtc_state->enable)
979 old_crtc_state = old_state->crtc_states[i];
980
981 if (!crtc || !old_crtc_state->enable)
982 continue; 911 continue;
983 912
984 ret = wait_event_timeout(dev->vblank[i].queue, 913 ret = wait_event_timeout(dev->vblank[i].queue,
@@ -1176,16 +1105,14 @@ EXPORT_SYMBOL(drm_atomic_helper_prepare_planes);
1176void drm_atomic_helper_commit_planes(struct drm_device *dev, 1105void drm_atomic_helper_commit_planes(struct drm_device *dev,
1177 struct drm_atomic_state *old_state) 1106 struct drm_atomic_state *old_state)
1178{ 1107{
1179 int nplanes = dev->mode_config.num_total_plane; 1108 struct drm_crtc *crtc;
1180 int ncrtcs = dev->mode_config.num_crtc; 1109 struct drm_crtc_state *old_crtc_state;
1110 struct drm_plane *plane;
1111 struct drm_plane_state *old_plane_state;
1181 int i; 1112 int i;
1182 1113
1183 for (i = 0; i < ncrtcs; i++) { 1114 for_each_crtc_in_state(old_state, crtc, old_crtc_state, i) {
1184 const struct drm_crtc_helper_funcs *funcs; 1115 const struct drm_crtc_helper_funcs *funcs;
1185 struct drm_crtc *crtc = old_state->crtcs[i];
1186
1187 if (!crtc)
1188 continue;
1189 1116
1190 funcs = crtc->helper_private; 1117 funcs = crtc->helper_private;
1191 1118
@@ -1195,13 +1122,8 @@ void drm_atomic_helper_commit_planes(struct drm_device *dev,
1195 funcs->atomic_begin(crtc); 1122 funcs->atomic_begin(crtc);
1196 } 1123 }
1197 1124
1198 for (i = 0; i < nplanes; i++) { 1125 for_each_plane_in_state(old_state, plane, old_plane_state, i) {
1199 const struct drm_plane_helper_funcs *funcs; 1126 const struct drm_plane_helper_funcs *funcs;
1200 struct drm_plane *plane = old_state->planes[i];
1201 struct drm_plane_state *old_plane_state;
1202
1203 if (!plane)
1204 continue;
1205 1127
1206 funcs = plane->helper_private; 1128 funcs = plane->helper_private;
1207 1129
@@ -1220,12 +1142,8 @@ void drm_atomic_helper_commit_planes(struct drm_device *dev,
1220 funcs->atomic_update(plane, old_plane_state); 1142 funcs->atomic_update(plane, old_plane_state);
1221 } 1143 }
1222 1144
1223 for (i = 0; i < ncrtcs; i++) { 1145 for_each_crtc_in_state(old_state, crtc, old_crtc_state, i) {
1224 const struct drm_crtc_helper_funcs *funcs; 1146 const struct drm_crtc_helper_funcs *funcs;
1225 struct drm_crtc *crtc = old_state->crtcs[i];
1226
1227 if (!crtc)
1228 continue;
1229 1147
1230 funcs = crtc->helper_private; 1148 funcs = crtc->helper_private;
1231 1149
@@ -1252,18 +1170,14 @@ EXPORT_SYMBOL(drm_atomic_helper_commit_planes);
1252void drm_atomic_helper_cleanup_planes(struct drm_device *dev, 1170void drm_atomic_helper_cleanup_planes(struct drm_device *dev,
1253 struct drm_atomic_state *old_state) 1171 struct drm_atomic_state *old_state)
1254{ 1172{
1255 int nplanes = dev->mode_config.num_total_plane; 1173 struct drm_plane *plane;
1174 struct drm_plane_state *plane_state;
1256 int i; 1175 int i;
1257 1176
1258 for (i = 0; i < nplanes; i++) { 1177 for_each_plane_in_state(old_state, plane, plane_state, i) {
1259 const struct drm_plane_helper_funcs *funcs; 1178 const struct drm_plane_helper_funcs *funcs;
1260 struct drm_plane *plane = old_state->planes[i];
1261 struct drm_plane_state *plane_state = old_state->plane_states[i];
1262 struct drm_framebuffer *old_fb; 1179 struct drm_framebuffer *old_fb;
1263 1180
1264 if (!plane)
1265 continue;
1266
1267 funcs = plane->helper_private; 1181 funcs = plane->helper_private;
1268 1182
1269 old_fb = plane_state->fb; 1183 old_fb = plane_state->fb;
@@ -1512,8 +1426,10 @@ static int update_output_state(struct drm_atomic_state *state,
1512 struct drm_mode_set *set) 1426 struct drm_mode_set *set)
1513{ 1427{
1514 struct drm_device *dev = set->crtc->dev; 1428 struct drm_device *dev = set->crtc->dev;
1429 struct drm_crtc *crtc;
1430 struct drm_crtc_state *crtc_state;
1431 struct drm_connector *connector;
1515 struct drm_connector_state *conn_state; 1432 struct drm_connector_state *conn_state;
1516 int ncrtcs = state->dev->mode_config.num_crtc;
1517 int ret, i, j; 1433 int ret, i, j;
1518 1434
1519 ret = drm_modeset_lock(&dev->mode_config.connection_mutex, 1435 ret = drm_modeset_lock(&dev->mode_config.connection_mutex,
@@ -1529,27 +1445,14 @@ static int update_output_state(struct drm_atomic_state *state,
1529 return PTR_ERR(conn_state); 1445 return PTR_ERR(conn_state);
1530 } 1446 }
1531 1447
1532 for (i = 0; i < ncrtcs; i++) { 1448 for_each_crtc_in_state(state, crtc, crtc_state, i) {
1533 struct drm_crtc *crtc = state->crtcs[i];
1534
1535 if (!crtc)
1536 continue;
1537
1538 ret = drm_atomic_add_affected_connectors(state, crtc); 1449 ret = drm_atomic_add_affected_connectors(state, crtc);
1539 if (ret) 1450 if (ret)
1540 return ret; 1451 return ret;
1541 } 1452 }
1542 1453
1543 /* Then recompute connector->crtc links and crtc enabling state. */ 1454 /* Then recompute connector->crtc links and crtc enabling state. */
1544 for (i = 0; i < state->num_connector; i++) { 1455 for_each_connector_in_state(state, connector, conn_state, i) {
1545 struct drm_connector *connector;
1546
1547 connector = state->connectors[i];
1548 conn_state = state->connector_states[i];
1549
1550 if (!connector)
1551 continue;
1552
1553 if (conn_state->crtc == set->crtc) { 1456 if (conn_state->crtc == set->crtc) {
1554 ret = drm_atomic_set_crtc_for_connector(conn_state, 1457 ret = drm_atomic_set_crtc_for_connector(conn_state,
1555 NULL); 1458 NULL);
@@ -1568,13 +1471,7 @@ static int update_output_state(struct drm_atomic_state *state,
1568 } 1471 }
1569 } 1472 }
1570 1473
1571 for (i = 0; i < ncrtcs; i++) { 1474 for_each_crtc_in_state(state, crtc, crtc_state, i) {
1572 struct drm_crtc *crtc = state->crtcs[i];
1573 struct drm_crtc_state *crtc_state = state->crtc_states[i];
1574
1575 if (!crtc)
1576 continue;
1577
1578 /* Don't update ->enable for the CRTC in the set_config request, 1475 /* Don't update ->enable for the CRTC in the set_config request,
1579 * since a mismatch would indicate a bug in the upper layers. 1476 * since a mismatch would indicate a bug in the upper layers.
1580 * The actual modeset code later on will catch any 1477 * The actual modeset code later on will catch any
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index b3989e23195e..3403edea9076 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -2482,6 +2482,17 @@ static int __setplane_internal(struct drm_plane *plane,
2482 goto out; 2482 goto out;
2483 } 2483 }
2484 2484
2485 /* Give drivers some help against integer overflows */
2486 if (crtc_w > INT_MAX ||
2487 crtc_x > INT_MAX - (int32_t) crtc_w ||
2488 crtc_h > INT_MAX ||
2489 crtc_y > INT_MAX - (int32_t) crtc_h) {
2490 DRM_DEBUG_KMS("Invalid CRTC coordinates %ux%u+%d+%d\n",
2491 crtc_w, crtc_h, crtc_x, crtc_y);
2492 return -ERANGE;
2493 }
2494
2495
2485 fb_width = fb->width << 16; 2496 fb_width = fb->width << 16;
2486 fb_height = fb->height << 16; 2497 fb_height = fb->height << 16;
2487 2498
@@ -2566,17 +2577,6 @@ int drm_mode_setplane(struct drm_device *dev, void *data,
2566 if (!drm_core_check_feature(dev, DRIVER_MODESET)) 2577 if (!drm_core_check_feature(dev, DRIVER_MODESET))
2567 return -EINVAL; 2578 return -EINVAL;
2568 2579
2569 /* Give drivers some help against integer overflows */
2570 if (plane_req->crtc_w > INT_MAX ||
2571 plane_req->crtc_x > INT_MAX - (int32_t) plane_req->crtc_w ||
2572 plane_req->crtc_h > INT_MAX ||
2573 plane_req->crtc_y > INT_MAX - (int32_t) plane_req->crtc_h) {
2574 DRM_DEBUG_KMS("Invalid CRTC coordinates %ux%u+%d+%d\n",
2575 plane_req->crtc_w, plane_req->crtc_h,
2576 plane_req->crtc_x, plane_req->crtc_y);
2577 return -ERANGE;
2578 }
2579
2580 /* 2580 /*
2581 * First, find the plane, crtc, and fb objects. If not available, 2581 * First, find the plane, crtc, and fb objects. If not available,
2582 * we don't bother to call the driver. 2582 * we don't bother to call the driver.
diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
index dd895c409ca3..ab00286aec93 100644
--- a/drivers/gpu/drm/drm_crtc_helper.c
+++ b/drivers/gpu/drm/drm_crtc_helper.c
@@ -161,7 +161,7 @@ EXPORT_SYMBOL(drm_helper_crtc_in_use);
161static void 161static void
162drm_encoder_disable(struct drm_encoder *encoder) 162drm_encoder_disable(struct drm_encoder *encoder)
163{ 163{
164 struct drm_encoder_helper_funcs *encoder_funcs = encoder->helper_private; 164 const struct drm_encoder_helper_funcs *encoder_funcs = encoder->helper_private;
165 165
166 if (encoder->bridge) 166 if (encoder->bridge)
167 encoder->bridge->funcs->disable(encoder->bridge); 167 encoder->bridge->funcs->disable(encoder->bridge);
@@ -191,7 +191,7 @@ static void __drm_helper_disable_unused_functions(struct drm_device *dev)
191 } 191 }
192 192
193 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { 193 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
194 struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private; 194 const struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
195 crtc->enabled = drm_helper_crtc_in_use(crtc); 195 crtc->enabled = drm_helper_crtc_in_use(crtc);
196 if (!crtc->enabled) { 196 if (!crtc->enabled) {
197 if (crtc_funcs->disable) 197 if (crtc_funcs->disable)
@@ -229,7 +229,7 @@ EXPORT_SYMBOL(drm_helper_disable_unused_functions);
229static void 229static void
230drm_crtc_prepare_encoders(struct drm_device *dev) 230drm_crtc_prepare_encoders(struct drm_device *dev)
231{ 231{
232 struct drm_encoder_helper_funcs *encoder_funcs; 232 const struct drm_encoder_helper_funcs *encoder_funcs;
233 struct drm_encoder *encoder; 233 struct drm_encoder *encoder;
234 234
235 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { 235 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
@@ -271,8 +271,8 @@ bool drm_crtc_helper_set_mode(struct drm_crtc *crtc,
271{ 271{
272 struct drm_device *dev = crtc->dev; 272 struct drm_device *dev = crtc->dev;
273 struct drm_display_mode *adjusted_mode, saved_mode, saved_hwmode; 273 struct drm_display_mode *adjusted_mode, saved_mode, saved_hwmode;
274 struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private; 274 const struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
275 struct drm_encoder_helper_funcs *encoder_funcs; 275 const struct drm_encoder_helper_funcs *encoder_funcs;
276 int saved_x, saved_y; 276 int saved_x, saved_y;
277 bool saved_enabled; 277 bool saved_enabled;
278 struct drm_encoder *encoder; 278 struct drm_encoder *encoder;
@@ -473,7 +473,7 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set)
473 bool fb_changed = false; /* if true and !mode_changed just do a flip */ 473 bool fb_changed = false; /* if true and !mode_changed just do a flip */
474 struct drm_connector *save_connectors, *connector; 474 struct drm_connector *save_connectors, *connector;
475 int count = 0, ro, fail = 0; 475 int count = 0, ro, fail = 0;
476 struct drm_crtc_helper_funcs *crtc_funcs; 476 const struct drm_crtc_helper_funcs *crtc_funcs;
477 struct drm_mode_set save_set; 477 struct drm_mode_set save_set;
478 int ret; 478 int ret;
479 int i; 479 int i;
@@ -573,7 +573,7 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set)
573 /* a) traverse passed in connector list and get encoders for them */ 573 /* a) traverse passed in connector list and get encoders for them */
574 count = 0; 574 count = 0;
575 list_for_each_entry(connector, &dev->mode_config.connector_list, head) { 575 list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
576 struct drm_connector_helper_funcs *connector_funcs = 576 const struct drm_connector_helper_funcs *connector_funcs =
577 connector->helper_private; 577 connector->helper_private;
578 new_encoder = connector->encoder; 578 new_encoder = connector->encoder;
579 for (ro = 0; ro < set->num_connectors; ro++) { 579 for (ro = 0; ro < set->num_connectors; ro++) {
@@ -733,7 +733,7 @@ static int drm_helper_choose_encoder_dpms(struct drm_encoder *encoder)
733static void drm_helper_encoder_dpms(struct drm_encoder *encoder, int mode) 733static void drm_helper_encoder_dpms(struct drm_encoder *encoder, int mode)
734{ 734{
735 struct drm_bridge *bridge = encoder->bridge; 735 struct drm_bridge *bridge = encoder->bridge;
736 struct drm_encoder_helper_funcs *encoder_funcs; 736 const struct drm_encoder_helper_funcs *encoder_funcs;
737 737
738 if (bridge) { 738 if (bridge) {
739 if (mode == DRM_MODE_DPMS_ON) 739 if (mode == DRM_MODE_DPMS_ON)
@@ -795,7 +795,7 @@ void drm_helper_connector_dpms(struct drm_connector *connector, int mode)
795 /* from off to on, do crtc then encoder */ 795 /* from off to on, do crtc then encoder */
796 if (mode < old_dpms) { 796 if (mode < old_dpms) {
797 if (crtc) { 797 if (crtc) {
798 struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private; 798 const struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
799 if (crtc_funcs->dpms) 799 if (crtc_funcs->dpms)
800 (*crtc_funcs->dpms) (crtc, 800 (*crtc_funcs->dpms) (crtc,
801 drm_helper_choose_crtc_dpms(crtc)); 801 drm_helper_choose_crtc_dpms(crtc));
@@ -809,7 +809,7 @@ void drm_helper_connector_dpms(struct drm_connector *connector, int mode)
809 if (encoder) 809 if (encoder)
810 drm_helper_encoder_dpms(encoder, encoder_dpms); 810 drm_helper_encoder_dpms(encoder, encoder_dpms);
811 if (crtc) { 811 if (crtc) {
812 struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private; 812 const struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
813 if (crtc_funcs->dpms) 813 if (crtc_funcs->dpms)
814 (*crtc_funcs->dpms) (crtc, 814 (*crtc_funcs->dpms) (crtc,
815 drm_helper_choose_crtc_dpms(crtc)); 815 drm_helper_choose_crtc_dpms(crtc));
@@ -871,7 +871,7 @@ void drm_helper_resume_force_mode(struct drm_device *dev)
871{ 871{
872 struct drm_crtc *crtc; 872 struct drm_crtc *crtc;
873 struct drm_encoder *encoder; 873 struct drm_encoder *encoder;
874 struct drm_crtc_helper_funcs *crtc_funcs; 874 const struct drm_crtc_helper_funcs *crtc_funcs;
875 int encoder_dpms; 875 int encoder_dpms;
876 bool ret; 876 bool ret;
877 877
@@ -936,7 +936,7 @@ int drm_helper_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mod
936 struct drm_framebuffer *old_fb) 936 struct drm_framebuffer *old_fb)
937{ 937{
938 struct drm_crtc_state *crtc_state; 938 struct drm_crtc_state *crtc_state;
939 struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private; 939 const struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
940 int ret; 940 int ret;
941 941
942 if (crtc->funcs->atomic_duplicate_state) 942 if (crtc->funcs->atomic_duplicate_state)
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 309b9476fe96..cac422916c7a 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -238,7 +238,7 @@ static void drm_fb_helper_restore_lut_atomic(struct drm_crtc *crtc)
238int drm_fb_helper_debug_enter(struct fb_info *info) 238int drm_fb_helper_debug_enter(struct fb_info *info)
239{ 239{
240 struct drm_fb_helper *helper = info->par; 240 struct drm_fb_helper *helper = info->par;
241 struct drm_crtc_helper_funcs *funcs; 241 const struct drm_crtc_helper_funcs *funcs;
242 int i; 242 int i;
243 243
244 list_for_each_entry(helper, &kernel_fb_helper_list, kernel_fb_list) { 244 list_for_each_entry(helper, &kernel_fb_helper_list, kernel_fb_list) {
@@ -285,7 +285,7 @@ int drm_fb_helper_debug_leave(struct fb_info *info)
285{ 285{
286 struct drm_fb_helper *helper = info->par; 286 struct drm_fb_helper *helper = info->par;
287 struct drm_crtc *crtc; 287 struct drm_crtc *crtc;
288 struct drm_crtc_helper_funcs *funcs; 288 const struct drm_crtc_helper_funcs *funcs;
289 struct drm_framebuffer *fb; 289 struct drm_framebuffer *fb;
290 int i; 290 int i;
291 291
@@ -765,7 +765,7 @@ int drm_fb_helper_setcmap(struct fb_cmap *cmap, struct fb_info *info)
765{ 765{
766 struct drm_fb_helper *fb_helper = info->par; 766 struct drm_fb_helper *fb_helper = info->par;
767 struct drm_device *dev = fb_helper->dev; 767 struct drm_device *dev = fb_helper->dev;
768 struct drm_crtc_helper_funcs *crtc_funcs; 768 const struct drm_crtc_helper_funcs *crtc_funcs;
769 u16 *red, *green, *blue, *transp; 769 u16 *red, *green, *blue, *transp;
770 struct drm_crtc *crtc; 770 struct drm_crtc *crtc;
771 int i, j, rc = 0; 771 int i, j, rc = 0;
@@ -1551,7 +1551,7 @@ static int drm_pick_crtcs(struct drm_fb_helper *fb_helper,
1551 int c, o; 1551 int c, o;
1552 struct drm_device *dev = fb_helper->dev; 1552 struct drm_device *dev = fb_helper->dev;
1553 struct drm_connector *connector; 1553 struct drm_connector *connector;
1554 struct drm_connector_helper_funcs *connector_funcs; 1554 const struct drm_connector_helper_funcs *connector_funcs;
1555 struct drm_encoder *encoder; 1555 struct drm_encoder *encoder;
1556 int my_score, best_score, score; 1556 int my_score, best_score, score;
1557 struct drm_fb_helper_crtc **crtcs, *crtc; 1557 struct drm_fb_helper_crtc **crtcs, *crtc;
diff --git a/drivers/gpu/drm/drm_plane_helper.c b/drivers/gpu/drm/drm_plane_helper.c
index 33807e0adac7..40c1db9ad7c3 100644
--- a/drivers/gpu/drm/drm_plane_helper.c
+++ b/drivers/gpu/drm/drm_plane_helper.c
@@ -401,9 +401,9 @@ int drm_plane_helper_commit(struct drm_plane *plane,
401 struct drm_plane_state *plane_state, 401 struct drm_plane_state *plane_state,
402 struct drm_framebuffer *old_fb) 402 struct drm_framebuffer *old_fb)
403{ 403{
404 struct drm_plane_helper_funcs *plane_funcs; 404 const struct drm_plane_helper_funcs *plane_funcs;
405 struct drm_crtc *crtc[2]; 405 struct drm_crtc *crtc[2];
406 struct drm_crtc_helper_funcs *crtc_funcs[2]; 406 const struct drm_crtc_helper_funcs *crtc_funcs[2];
407 int i, ret = 0; 407 int i, ret = 0;
408 408
409 plane_funcs = plane->helper_private; 409 plane_funcs = plane->helper_private;
diff --git a/drivers/gpu/drm/drm_probe_helper.c b/drivers/gpu/drm/drm_probe_helper.c
index 3fee587bc284..63503879a676 100644
--- a/drivers/gpu/drm/drm_probe_helper.c
+++ b/drivers/gpu/drm/drm_probe_helper.c
@@ -98,7 +98,7 @@ static int drm_helper_probe_single_connector_modes_merge_bits(struct drm_connect
98{ 98{
99 struct drm_device *dev = connector->dev; 99 struct drm_device *dev = connector->dev;
100 struct drm_display_mode *mode; 100 struct drm_display_mode *mode;
101 struct drm_connector_helper_funcs *connector_funcs = 101 const struct drm_connector_helper_funcs *connector_funcs =
102 connector->helper_private; 102 connector->helper_private;
103 int count = 0; 103 int count = 0;
104 int mode_flags = 0; 104 int mode_flags = 0;
diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c b/drivers/gpu/drm/exynos/exynos_hdmi.c
index 722cbf32192a..5eba971f394a 100644
--- a/drivers/gpu/drm/exynos/exynos_hdmi.c
+++ b/drivers/gpu/drm/exynos/exynos_hdmi.c
@@ -2101,7 +2101,7 @@ static void hdmi_dpms(struct exynos_drm_display *display, int mode)
2101 struct hdmi_context *hdata = display_to_hdmi(display); 2101 struct hdmi_context *hdata = display_to_hdmi(display);
2102 struct drm_encoder *encoder = hdata->encoder; 2102 struct drm_encoder *encoder = hdata->encoder;
2103 struct drm_crtc *crtc = encoder->crtc; 2103 struct drm_crtc *crtc = encoder->crtc;
2104 struct drm_crtc_helper_funcs *funcs = NULL; 2104 const struct drm_crtc_helper_funcs *funcs = NULL;
2105 2105
2106 DRM_DEBUG_KMS("mode %d\n", mode); 2106 DRM_DEBUG_KMS("mode %d\n", mode);
2107 2107
diff --git a/drivers/gpu/drm/gma500/cdv_intel_display.c b/drivers/gpu/drm/gma500/cdv_intel_display.c
index 66727328832d..7d47b3d5cc0d 100644
--- a/drivers/gpu/drm/gma500/cdv_intel_display.c
+++ b/drivers/gpu/drm/gma500/cdv_intel_display.c
@@ -823,7 +823,7 @@ static int cdv_intel_crtc_mode_set(struct drm_crtc *crtc,
823 823
824 /* Flush the plane changes */ 824 /* Flush the plane changes */
825 { 825 {
826 struct drm_crtc_helper_funcs *crtc_funcs = 826 const struct drm_crtc_helper_funcs *crtc_funcs =
827 crtc->helper_private; 827 crtc->helper_private;
828 crtc_funcs->mode_set_base(crtc, x, y, old_fb); 828 crtc_funcs->mode_set_base(crtc, x, y, old_fb);
829 } 829 }
diff --git a/drivers/gpu/drm/gma500/cdv_intel_hdmi.c b/drivers/gpu/drm/gma500/cdv_intel_hdmi.c
index 4268bf210034..6b1d3340ba14 100644
--- a/drivers/gpu/drm/gma500/cdv_intel_hdmi.c
+++ b/drivers/gpu/drm/gma500/cdv_intel_hdmi.c
@@ -195,7 +195,7 @@ static int cdv_hdmi_set_property(struct drm_connector *connector,
195 encoder->crtc->x, encoder->crtc->y, encoder->crtc->primary->fb)) 195 encoder->crtc->x, encoder->crtc->y, encoder->crtc->primary->fb))
196 return -1; 196 return -1;
197 } else { 197 } else {
198 struct drm_encoder_helper_funcs *helpers 198 const struct drm_encoder_helper_funcs *helpers
199 = encoder->helper_private; 199 = encoder->helper_private;
200 helpers->mode_set(encoder, &crtc->saved_mode, 200 helpers->mode_set(encoder, &crtc->saved_mode,
201 &crtc->saved_adjusted_mode); 201 &crtc->saved_adjusted_mode);
diff --git a/drivers/gpu/drm/gma500/cdv_intel_lvds.c b/drivers/gpu/drm/gma500/cdv_intel_lvds.c
index 0b770396548c..211069b2b951 100644
--- a/drivers/gpu/drm/gma500/cdv_intel_lvds.c
+++ b/drivers/gpu/drm/gma500/cdv_intel_lvds.c
@@ -505,7 +505,7 @@ static int cdv_intel_lvds_set_property(struct drm_connector *connector,
505 else 505 else
506 gma_backlight_set(encoder->dev, value); 506 gma_backlight_set(encoder->dev, value);
507 } else if (!strcmp(property->name, "DPMS") && encoder) { 507 } else if (!strcmp(property->name, "DPMS") && encoder) {
508 struct drm_encoder_helper_funcs *helpers = 508 const struct drm_encoder_helper_funcs *helpers =
509 encoder->helper_private; 509 encoder->helper_private;
510 helpers->dpms(encoder, value); 510 helpers->dpms(encoder, value);
511 } 511 }
diff --git a/drivers/gpu/drm/gma500/gma_display.c b/drivers/gpu/drm/gma500/gma_display.c
index 9bb9bddd881a..001b450b27b3 100644
--- a/drivers/gpu/drm/gma500/gma_display.c
+++ b/drivers/gpu/drm/gma500/gma_display.c
@@ -501,20 +501,20 @@ bool gma_crtc_mode_fixup(struct drm_crtc *crtc,
501 501
502void gma_crtc_prepare(struct drm_crtc *crtc) 502void gma_crtc_prepare(struct drm_crtc *crtc)
503{ 503{
504 struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private; 504 const struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
505 crtc_funcs->dpms(crtc, DRM_MODE_DPMS_OFF); 505 crtc_funcs->dpms(crtc, DRM_MODE_DPMS_OFF);
506} 506}
507 507
508void gma_crtc_commit(struct drm_crtc *crtc) 508void gma_crtc_commit(struct drm_crtc *crtc)
509{ 509{
510 struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private; 510 const struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
511 crtc_funcs->dpms(crtc, DRM_MODE_DPMS_ON); 511 crtc_funcs->dpms(crtc, DRM_MODE_DPMS_ON);
512} 512}
513 513
514void gma_crtc_disable(struct drm_crtc *crtc) 514void gma_crtc_disable(struct drm_crtc *crtc)
515{ 515{
516 struct gtt_range *gt; 516 struct gtt_range *gt;
517 struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private; 517 const struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
518 518
519 crtc_funcs->dpms(crtc, DRM_MODE_DPMS_OFF); 519 crtc_funcs->dpms(crtc, DRM_MODE_DPMS_OFF);
520 520
@@ -656,7 +656,7 @@ void gma_crtc_restore(struct drm_crtc *crtc)
656 656
657void gma_encoder_prepare(struct drm_encoder *encoder) 657void gma_encoder_prepare(struct drm_encoder *encoder)
658{ 658{
659 struct drm_encoder_helper_funcs *encoder_funcs = 659 const struct drm_encoder_helper_funcs *encoder_funcs =
660 encoder->helper_private; 660 encoder->helper_private;
661 /* lvds has its own version of prepare see psb_intel_lvds_prepare */ 661 /* lvds has its own version of prepare see psb_intel_lvds_prepare */
662 encoder_funcs->dpms(encoder, DRM_MODE_DPMS_OFF); 662 encoder_funcs->dpms(encoder, DRM_MODE_DPMS_OFF);
@@ -664,7 +664,7 @@ void gma_encoder_prepare(struct drm_encoder *encoder)
664 664
665void gma_encoder_commit(struct drm_encoder *encoder) 665void gma_encoder_commit(struct drm_encoder *encoder)
666{ 666{
667 struct drm_encoder_helper_funcs *encoder_funcs = 667 const struct drm_encoder_helper_funcs *encoder_funcs =
668 encoder->helper_private; 668 encoder->helper_private;
669 /* lvds has its own version of commit see psb_intel_lvds_commit */ 669 /* lvds has its own version of commit see psb_intel_lvds_commit */
670 encoder_funcs->dpms(encoder, DRM_MODE_DPMS_ON); 670 encoder_funcs->dpms(encoder, DRM_MODE_DPMS_ON);
diff --git a/drivers/gpu/drm/gma500/mdfld_dsi_output.c b/drivers/gpu/drm/gma500/mdfld_dsi_output.c
index abf2248da61e..89f705c3a5eb 100644
--- a/drivers/gpu/drm/gma500/mdfld_dsi_output.c
+++ b/drivers/gpu/drm/gma500/mdfld_dsi_output.c
@@ -290,7 +290,7 @@ static int mdfld_dsi_connector_set_property(struct drm_connector *connector,
290 encoder->crtc->primary->fb)) 290 encoder->crtc->primary->fb))
291 goto set_prop_error; 291 goto set_prop_error;
292 } else { 292 } else {
293 struct drm_encoder_helper_funcs *funcs = 293 const struct drm_encoder_helper_funcs *funcs =
294 encoder->helper_private; 294 encoder->helper_private;
295 funcs->mode_set(encoder, 295 funcs->mode_set(encoder,
296 &gma_crtc->saved_mode, 296 &gma_crtc->saved_mode,
diff --git a/drivers/gpu/drm/gma500/mdfld_intel_display.c b/drivers/gpu/drm/gma500/mdfld_intel_display.c
index 8cc8a5abbc7b..acd38344b302 100644
--- a/drivers/gpu/drm/gma500/mdfld_intel_display.c
+++ b/drivers/gpu/drm/gma500/mdfld_intel_display.c
@@ -849,7 +849,7 @@ static int mdfld_crtc_mode_set(struct drm_crtc *crtc,
849 849
850 /* Flush the plane changes */ 850 /* Flush the plane changes */
851 { 851 {
852 struct drm_crtc_helper_funcs *crtc_funcs = 852 const struct drm_crtc_helper_funcs *crtc_funcs =
853 crtc->helper_private; 853 crtc->helper_private;
854 crtc_funcs->mode_set_base(crtc, x, y, old_fb); 854 crtc_funcs->mode_set_base(crtc, x, y, old_fb);
855 } 855 }
diff --git a/drivers/gpu/drm/gma500/oaktrail_crtc.c b/drivers/gpu/drm/gma500/oaktrail_crtc.c
index 2de216c2374f..1048f0c7c6ce 100644
--- a/drivers/gpu/drm/gma500/oaktrail_crtc.c
+++ b/drivers/gpu/drm/gma500/oaktrail_crtc.c
@@ -483,7 +483,7 @@ static int oaktrail_crtc_mode_set(struct drm_crtc *crtc,
483 483
484 /* Flush the plane changes */ 484 /* Flush the plane changes */
485 { 485 {
486 struct drm_crtc_helper_funcs *crtc_funcs = 486 const struct drm_crtc_helper_funcs *crtc_funcs =
487 crtc->helper_private; 487 crtc->helper_private;
488 crtc_funcs->mode_set_base(crtc, x, y, old_fb); 488 crtc_funcs->mode_set_base(crtc, x, y, old_fb);
489 } 489 }
diff --git a/drivers/gpu/drm/gma500/oaktrail_hdmi.c b/drivers/gpu/drm/gma500/oaktrail_hdmi.c
index 54f73f50571a..2310d879cdc2 100644
--- a/drivers/gpu/drm/gma500/oaktrail_hdmi.c
+++ b/drivers/gpu/drm/gma500/oaktrail_hdmi.c
@@ -347,7 +347,7 @@ int oaktrail_crtc_hdmi_mode_set(struct drm_crtc *crtc,
347 347
348 /* Flush the plane changes */ 348 /* Flush the plane changes */
349 { 349 {
350 struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private; 350 const struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
351 crtc_funcs->mode_set_base(crtc, x, y, old_fb); 351 crtc_funcs->mode_set_base(crtc, x, y, old_fb);
352 } 352 }
353 353
diff --git a/drivers/gpu/drm/gma500/psb_intel_display.c b/drivers/gpu/drm/gma500/psb_intel_display.c
index b21a09451d1d..6659da88fe5b 100644
--- a/drivers/gpu/drm/gma500/psb_intel_display.c
+++ b/drivers/gpu/drm/gma500/psb_intel_display.c
@@ -108,7 +108,7 @@ static int psb_intel_crtc_mode_set(struct drm_crtc *crtc,
108 struct drm_device *dev = crtc->dev; 108 struct drm_device *dev = crtc->dev;
109 struct drm_psb_private *dev_priv = dev->dev_private; 109 struct drm_psb_private *dev_priv = dev->dev_private;
110 struct gma_crtc *gma_crtc = to_gma_crtc(crtc); 110 struct gma_crtc *gma_crtc = to_gma_crtc(crtc);
111 struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private; 111 const struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
112 int pipe = gma_crtc->pipe; 112 int pipe = gma_crtc->pipe;
113 const struct psb_offset *map = &dev_priv->regmap[pipe]; 113 const struct psb_offset *map = &dev_priv->regmap[pipe];
114 int refclk; 114 int refclk;
diff --git a/drivers/gpu/drm/gma500/psb_intel_lvds.c b/drivers/gpu/drm/gma500/psb_intel_lvds.c
index 88aad95bde09..ce0645d0c1e5 100644
--- a/drivers/gpu/drm/gma500/psb_intel_lvds.c
+++ b/drivers/gpu/drm/gma500/psb_intel_lvds.c
@@ -625,7 +625,7 @@ int psb_intel_lvds_set_property(struct drm_connector *connector,
625 else 625 else
626 gma_backlight_set(encoder->dev, value); 626 gma_backlight_set(encoder->dev, value);
627 } else if (!strcmp(property->name, "DPMS")) { 627 } else if (!strcmp(property->name, "DPMS")) {
628 struct drm_encoder_helper_funcs *hfuncs 628 const struct drm_encoder_helper_funcs *hfuncs
629 = encoder->helper_private; 629 = encoder->helper_private;
630 hfuncs->dpms(encoder, value); 630 hfuncs->dpms(encoder, value);
631 } 631 }
diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c
index 9872ba9abf1a..6e84df9369a6 100644
--- a/drivers/gpu/drm/mgag200/mgag200_mode.c
+++ b/drivers/gpu/drm/mgag200/mgag200_mode.c
@@ -1222,7 +1222,7 @@ static void mga_crtc_commit(struct drm_crtc *crtc)
1222{ 1222{
1223 struct drm_device *dev = crtc->dev; 1223 struct drm_device *dev = crtc->dev;
1224 struct mga_device *mdev = dev->dev_private; 1224 struct mga_device *mdev = dev->dev_private;
1225 struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private; 1225 const struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
1226 u8 tmp; 1226 u8 tmp;
1227 1227
1228 if (mdev->type == G200_WB) 1228 if (mdev->type == G200_WB)
diff --git a/drivers/gpu/drm/nouveau/dispnv04/crtc.c b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
index 542bb266a0ab..3d96b49fe662 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/crtc.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
@@ -703,7 +703,7 @@ static void nv_crtc_prepare(struct drm_crtc *crtc)
703 struct drm_device *dev = crtc->dev; 703 struct drm_device *dev = crtc->dev;
704 struct nouveau_drm *drm = nouveau_drm(dev); 704 struct nouveau_drm *drm = nouveau_drm(dev);
705 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); 705 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
706 struct drm_crtc_helper_funcs *funcs = crtc->helper_private; 706 const struct drm_crtc_helper_funcs *funcs = crtc->helper_private;
707 707
708 if (nv_two_heads(dev)) 708 if (nv_two_heads(dev))
709 NVSetOwner(dev, nv_crtc->index); 709 NVSetOwner(dev, nv_crtc->index);
@@ -724,7 +724,7 @@ static void nv_crtc_prepare(struct drm_crtc *crtc)
724static void nv_crtc_commit(struct drm_crtc *crtc) 724static void nv_crtc_commit(struct drm_crtc *crtc)
725{ 725{
726 struct drm_device *dev = crtc->dev; 726 struct drm_device *dev = crtc->dev;
727 struct drm_crtc_helper_funcs *funcs = crtc->helper_private; 727 const struct drm_crtc_helper_funcs *funcs = crtc->helper_private;
728 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); 728 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
729 729
730 nouveau_hw_load_state(dev, nv_crtc->index, &nv04_display(dev)->mode_reg); 730 nouveau_hw_load_state(dev, nv_crtc->index, &nv04_display(dev)->mode_reg);
diff --git a/drivers/gpu/drm/nouveau/dispnv04/dac.c b/drivers/gpu/drm/nouveau/dispnv04/dac.c
index d7b495a5f30c..af7249ca0f4b 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/dac.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/dac.c
@@ -358,7 +358,7 @@ static bool nv04_dac_mode_fixup(struct drm_encoder *encoder,
358 358
359static void nv04_dac_prepare(struct drm_encoder *encoder) 359static void nv04_dac_prepare(struct drm_encoder *encoder)
360{ 360{
361 struct drm_encoder_helper_funcs *helper = encoder->helper_private; 361 const struct drm_encoder_helper_funcs *helper = encoder->helper_private;
362 struct drm_device *dev = encoder->dev; 362 struct drm_device *dev = encoder->dev;
363 int head = nouveau_crtc(encoder->crtc)->index; 363 int head = nouveau_crtc(encoder->crtc)->index;
364 364
@@ -409,7 +409,7 @@ static void nv04_dac_commit(struct drm_encoder *encoder)
409 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); 409 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
410 struct nouveau_drm *drm = nouveau_drm(encoder->dev); 410 struct nouveau_drm *drm = nouveau_drm(encoder->dev);
411 struct nouveau_crtc *nv_crtc = nouveau_crtc(encoder->crtc); 411 struct nouveau_crtc *nv_crtc = nouveau_crtc(encoder->crtc);
412 struct drm_encoder_helper_funcs *helper = encoder->helper_private; 412 const struct drm_encoder_helper_funcs *helper = encoder->helper_private;
413 413
414 helper->dpms(encoder, DRM_MODE_DPMS_ON); 414 helper->dpms(encoder, DRM_MODE_DPMS_ON);
415 415
diff --git a/drivers/gpu/drm/nouveau/dispnv04/dfp.c b/drivers/gpu/drm/nouveau/dispnv04/dfp.c
index f6ca343fd34a..7cfb0cbc9b6e 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/dfp.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/dfp.c
@@ -244,7 +244,7 @@ static void nv04_dfp_prepare_sel_clk(struct drm_device *dev,
244static void nv04_dfp_prepare(struct drm_encoder *encoder) 244static void nv04_dfp_prepare(struct drm_encoder *encoder)
245{ 245{
246 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); 246 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
247 struct drm_encoder_helper_funcs *helper = encoder->helper_private; 247 const struct drm_encoder_helper_funcs *helper = encoder->helper_private;
248 struct drm_device *dev = encoder->dev; 248 struct drm_device *dev = encoder->dev;
249 int head = nouveau_crtc(encoder->crtc)->index; 249 int head = nouveau_crtc(encoder->crtc)->index;
250 struct nv04_crtc_reg *crtcstate = nv04_display(dev)->mode_reg.crtc_reg; 250 struct nv04_crtc_reg *crtcstate = nv04_display(dev)->mode_reg.crtc_reg;
@@ -445,7 +445,7 @@ static void nv04_dfp_commit(struct drm_encoder *encoder)
445{ 445{
446 struct drm_device *dev = encoder->dev; 446 struct drm_device *dev = encoder->dev;
447 struct nouveau_drm *drm = nouveau_drm(dev); 447 struct nouveau_drm *drm = nouveau_drm(dev);
448 struct drm_encoder_helper_funcs *helper = encoder->helper_private; 448 const struct drm_encoder_helper_funcs *helper = encoder->helper_private;
449 struct nouveau_crtc *nv_crtc = nouveau_crtc(encoder->crtc); 449 struct nouveau_crtc *nv_crtc = nouveau_crtc(encoder->crtc);
450 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); 450 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
451 struct dcb_output *dcbe = nv_encoder->dcb; 451 struct dcb_output *dcbe = nv_encoder->dcb;
diff --git a/drivers/gpu/drm/nouveau/dispnv04/disp.c b/drivers/gpu/drm/nouveau/dispnv04/disp.c
index f96237ef2a6b..4131be5507ab 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/disp.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/disp.c
@@ -109,7 +109,7 @@ nv04_display_create(struct drm_device *dev)
109 crtc->funcs->save(crtc); 109 crtc->funcs->save(crtc);
110 110
111 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { 111 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
112 struct drm_encoder_helper_funcs *func = encoder->helper_private; 112 const struct drm_encoder_helper_funcs *func = encoder->helper_private;
113 113
114 func->save(encoder); 114 func->save(encoder);
115 } 115 }
@@ -138,7 +138,7 @@ nv04_display_destroy(struct drm_device *dev)
138 138
139 /* Restore state */ 139 /* Restore state */
140 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { 140 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
141 struct drm_encoder_helper_funcs *func = encoder->helper_private; 141 const struct drm_encoder_helper_funcs *func = encoder->helper_private;
142 142
143 func->restore(encoder); 143 func->restore(encoder);
144 } 144 }
@@ -169,7 +169,7 @@ nv04_display_init(struct drm_device *dev)
169 * on suspend too. 169 * on suspend too.
170 */ 170 */
171 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { 171 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
172 struct drm_encoder_helper_funcs *func = encoder->helper_private; 172 const struct drm_encoder_helper_funcs *func = encoder->helper_private;
173 173
174 func->restore(encoder); 174 func->restore(encoder);
175 } 175 }
diff --git a/drivers/gpu/drm/nouveau/dispnv04/tvnv04.c b/drivers/gpu/drm/nouveau/dispnv04/tvnv04.c
index d9664b37def1..70e95cf6fd19 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/tvnv04.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/tvnv04.c
@@ -122,7 +122,7 @@ static void nv04_tv_prepare(struct drm_encoder *encoder)
122{ 122{
123 struct drm_device *dev = encoder->dev; 123 struct drm_device *dev = encoder->dev;
124 int head = nouveau_crtc(encoder->crtc)->index; 124 int head = nouveau_crtc(encoder->crtc)->index;
125 struct drm_encoder_helper_funcs *helper = encoder->helper_private; 125 const struct drm_encoder_helper_funcs *helper = encoder->helper_private;
126 126
127 helper->dpms(encoder, DRM_MODE_DPMS_OFF); 127 helper->dpms(encoder, DRM_MODE_DPMS_OFF);
128 128
@@ -164,7 +164,7 @@ static void nv04_tv_commit(struct drm_encoder *encoder)
164 struct drm_device *dev = encoder->dev; 164 struct drm_device *dev = encoder->dev;
165 struct nouveau_drm *drm = nouveau_drm(dev); 165 struct nouveau_drm *drm = nouveau_drm(dev);
166 struct nouveau_crtc *nv_crtc = nouveau_crtc(encoder->crtc); 166 struct nouveau_crtc *nv_crtc = nouveau_crtc(encoder->crtc);
167 struct drm_encoder_helper_funcs *helper = encoder->helper_private; 167 const struct drm_encoder_helper_funcs *helper = encoder->helper_private;
168 168
169 helper->dpms(encoder, DRM_MODE_DPMS_ON); 169 helper->dpms(encoder, DRM_MODE_DPMS_ON);
170 170
diff --git a/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c b/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c
index 731d74efc1e5..d9720dda8385 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c
@@ -405,7 +405,7 @@ static void nv17_tv_prepare(struct drm_encoder *encoder)
405{ 405{
406 struct drm_device *dev = encoder->dev; 406 struct drm_device *dev = encoder->dev;
407 struct nouveau_drm *drm = nouveau_drm(dev); 407 struct nouveau_drm *drm = nouveau_drm(dev);
408 struct drm_encoder_helper_funcs *helper = encoder->helper_private; 408 const struct drm_encoder_helper_funcs *helper = encoder->helper_private;
409 struct nv17_tv_norm_params *tv_norm = get_tv_norm(encoder); 409 struct nv17_tv_norm_params *tv_norm = get_tv_norm(encoder);
410 int head = nouveau_crtc(encoder->crtc)->index; 410 int head = nouveau_crtc(encoder->crtc)->index;
411 uint8_t *cr_lcd = &nv04_display(dev)->mode_reg.crtc_reg[head].CRTC[ 411 uint8_t *cr_lcd = &nv04_display(dev)->mode_reg.crtc_reg[head].CRTC[
@@ -583,7 +583,7 @@ static void nv17_tv_commit(struct drm_encoder *encoder)
583 struct nouveau_drm *drm = nouveau_drm(dev); 583 struct nouveau_drm *drm = nouveau_drm(dev);
584 struct nouveau_crtc *nv_crtc = nouveau_crtc(encoder->crtc); 584 struct nouveau_crtc *nv_crtc = nouveau_crtc(encoder->crtc);
585 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); 585 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
586 struct drm_encoder_helper_funcs *helper = encoder->helper_private; 586 const struct drm_encoder_helper_funcs *helper = encoder->helper_private;
587 587
588 if (get_tv_norm(encoder)->kind == TV_ENC_MODE) { 588 if (get_tv_norm(encoder)->kind == TV_ENC_MODE) {
589 nv17_tv_update_rescaler(encoder); 589 nv17_tv_update_rescaler(encoder);
diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c b/drivers/gpu/drm/nouveau/nouveau_connector.c
index db7095ae4ebb..3162040bc314 100644
--- a/drivers/gpu/drm/nouveau/nouveau_connector.c
+++ b/drivers/gpu/drm/nouveau/nouveau_connector.c
@@ -309,7 +309,7 @@ detect_analog:
309 nv_encoder = find_encoder(connector, DCB_OUTPUT_TV); 309 nv_encoder = find_encoder(connector, DCB_OUTPUT_TV);
310 if (nv_encoder && force) { 310 if (nv_encoder && force) {
311 struct drm_encoder *encoder = to_drm_encoder(nv_encoder); 311 struct drm_encoder *encoder = to_drm_encoder(nv_encoder);
312 struct drm_encoder_helper_funcs *helper = 312 const struct drm_encoder_helper_funcs *helper =
313 encoder->helper_private; 313 encoder->helper_private;
314 314
315 if (helper->detect(encoder, connector) == 315 if (helper->detect(encoder, connector) ==
@@ -592,7 +592,7 @@ nouveau_connector_set_property(struct drm_connector *connector,
592static struct drm_display_mode * 592static struct drm_display_mode *
593nouveau_connector_native_mode(struct drm_connector *connector) 593nouveau_connector_native_mode(struct drm_connector *connector)
594{ 594{
595 struct drm_connector_helper_funcs *helper = connector->helper_private; 595 const struct drm_connector_helper_funcs *helper = connector->helper_private;
596 struct nouveau_drm *drm = nouveau_drm(connector->dev); 596 struct nouveau_drm *drm = nouveau_drm(connector->dev);
597 struct nouveau_connector *nv_connector = nouveau_connector(connector); 597 struct nouveau_connector *nv_connector = nouveau_connector(connector);
598 struct drm_device *dev = connector->dev; 598 struct drm_device *dev = connector->dev;
diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c
index 1d9b80c91a15..e2d07085b6a5 100644
--- a/drivers/gpu/drm/qxl/qxl_drv.c
+++ b/drivers/gpu/drm/qxl/qxl_drv.c
@@ -102,7 +102,7 @@ static int qxl_drm_freeze(struct drm_device *dev)
102 102
103 /* unpin the front buffers */ 103 /* unpin the front buffers */
104 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { 104 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
105 struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private; 105 const struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
106 if (crtc->enabled) 106 if (crtc->enabled)
107 (*crtc_funcs->disable)(crtc); 107 (*crtc_funcs->disable)(crtc);
108 } 108 }
diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c
index 7ffa7d5563b9..cebb65e07e1d 100644
--- a/drivers/gpu/drm/radeon/radeon_connectors.c
+++ b/drivers/gpu/drm/radeon/radeon_connectors.c
@@ -157,7 +157,7 @@ int radeon_get_monitor_bpc(struct drm_connector *connector)
157 if (connector->display_info.bpc) 157 if (connector->display_info.bpc)
158 bpc = connector->display_info.bpc; 158 bpc = connector->display_info.bpc;
159 else if (ASIC_IS_DCE41(rdev) || ASIC_IS_DCE5(rdev)) { 159 else if (ASIC_IS_DCE41(rdev) || ASIC_IS_DCE5(rdev)) {
160 struct drm_connector_helper_funcs *connector_funcs = 160 const struct drm_connector_helper_funcs *connector_funcs =
161 connector->helper_private; 161 connector->helper_private;
162 struct drm_encoder *encoder = connector_funcs->best_encoder(connector); 162 struct drm_encoder *encoder = connector_funcs->best_encoder(connector);
163 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 163 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
@@ -247,7 +247,7 @@ radeon_connector_update_scratch_regs(struct drm_connector *connector, enum drm_c
247 struct radeon_device *rdev = dev->dev_private; 247 struct radeon_device *rdev = dev->dev_private;
248 struct drm_encoder *best_encoder = NULL; 248 struct drm_encoder *best_encoder = NULL;
249 struct drm_encoder *encoder = NULL; 249 struct drm_encoder *encoder = NULL;
250 struct drm_connector_helper_funcs *connector_funcs = connector->helper_private; 250 const struct drm_connector_helper_funcs *connector_funcs = connector->helper_private;
251 bool connected; 251 bool connected;
252 int i; 252 int i;
253 253
@@ -724,7 +724,7 @@ static int radeon_connector_set_property(struct drm_connector *connector, struct
724 if (connector->encoder) 724 if (connector->encoder)
725 radeon_encoder = to_radeon_encoder(connector->encoder); 725 radeon_encoder = to_radeon_encoder(connector->encoder);
726 else { 726 else {
727 struct drm_connector_helper_funcs *connector_funcs = connector->helper_private; 727 const struct drm_connector_helper_funcs *connector_funcs = connector->helper_private;
728 radeon_encoder = to_radeon_encoder(connector_funcs->best_encoder(connector)); 728 radeon_encoder = to_radeon_encoder(connector_funcs->best_encoder(connector));
729 } 729 }
730 730
@@ -751,7 +751,7 @@ static int radeon_connector_set_property(struct drm_connector *connector, struct
751 if (connector->encoder) 751 if (connector->encoder)
752 radeon_encoder = to_radeon_encoder(connector->encoder); 752 radeon_encoder = to_radeon_encoder(connector->encoder);
753 else { 753 else {
754 struct drm_connector_helper_funcs *connector_funcs = connector->helper_private; 754 const struct drm_connector_helper_funcs *connector_funcs = connector->helper_private;
755 radeon_encoder = to_radeon_encoder(connector_funcs->best_encoder(connector)); 755 radeon_encoder = to_radeon_encoder(connector_funcs->best_encoder(connector));
756 } 756 }
757 757
@@ -762,7 +762,7 @@ static int radeon_connector_set_property(struct drm_connector *connector, struct
762 762
763 if (connector->encoder->crtc) { 763 if (connector->encoder->crtc) {
764 struct drm_crtc *crtc = connector->encoder->crtc; 764 struct drm_crtc *crtc = connector->encoder->crtc;
765 struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private; 765 const struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
766 struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); 766 struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
767 767
768 radeon_crtc->output_csc = radeon_encoder->output_csc; 768 radeon_crtc->output_csc = radeon_encoder->output_csc;
@@ -942,7 +942,7 @@ static int radeon_lvds_set_property(struct drm_connector *connector,
942 if (connector->encoder) 942 if (connector->encoder)
943 radeon_encoder = to_radeon_encoder(connector->encoder); 943 radeon_encoder = to_radeon_encoder(connector->encoder);
944 else { 944 else {
945 struct drm_connector_helper_funcs *connector_funcs = connector->helper_private; 945 const struct drm_connector_helper_funcs *connector_funcs = connector->helper_private;
946 radeon_encoder = to_radeon_encoder(connector_funcs->best_encoder(connector)); 946 radeon_encoder = to_radeon_encoder(connector_funcs->best_encoder(connector));
947 } 947 }
948 948
@@ -1010,7 +1010,7 @@ radeon_vga_detect(struct drm_connector *connector, bool force)
1010 struct radeon_device *rdev = dev->dev_private; 1010 struct radeon_device *rdev = dev->dev_private;
1011 struct radeon_connector *radeon_connector = to_radeon_connector(connector); 1011 struct radeon_connector *radeon_connector = to_radeon_connector(connector);
1012 struct drm_encoder *encoder; 1012 struct drm_encoder *encoder;
1013 struct drm_encoder_helper_funcs *encoder_funcs; 1013 const struct drm_encoder_helper_funcs *encoder_funcs;
1014 bool dret = false; 1014 bool dret = false;
1015 enum drm_connector_status ret = connector_status_disconnected; 1015 enum drm_connector_status ret = connector_status_disconnected;
1016 int r; 1016 int r;
@@ -1140,7 +1140,7 @@ static enum drm_connector_status
1140radeon_tv_detect(struct drm_connector *connector, bool force) 1140radeon_tv_detect(struct drm_connector *connector, bool force)
1141{ 1141{
1142 struct drm_encoder *encoder; 1142 struct drm_encoder *encoder;
1143 struct drm_encoder_helper_funcs *encoder_funcs; 1143 const struct drm_encoder_helper_funcs *encoder_funcs;
1144 struct radeon_connector *radeon_connector = to_radeon_connector(connector); 1144 struct radeon_connector *radeon_connector = to_radeon_connector(connector);
1145 enum drm_connector_status ret = connector_status_disconnected; 1145 enum drm_connector_status ret = connector_status_disconnected;
1146 int r; 1146 int r;
@@ -1220,7 +1220,7 @@ radeon_dvi_detect(struct drm_connector *connector, bool force)
1220 struct radeon_device *rdev = dev->dev_private; 1220 struct radeon_device *rdev = dev->dev_private;
1221 struct radeon_connector *radeon_connector = to_radeon_connector(connector); 1221 struct radeon_connector *radeon_connector = to_radeon_connector(connector);
1222 struct drm_encoder *encoder = NULL; 1222 struct drm_encoder *encoder = NULL;
1223 struct drm_encoder_helper_funcs *encoder_funcs; 1223 const struct drm_encoder_helper_funcs *encoder_funcs;
1224 int i, r; 1224 int i, r;
1225 enum drm_connector_status ret = connector_status_disconnected; 1225 enum drm_connector_status ret = connector_status_disconnected;
1226 bool dret = false, broken_edid = false; 1226 bool dret = false, broken_edid = false;
@@ -1684,7 +1684,7 @@ radeon_dp_detect(struct drm_connector *connector, bool force)
1684 if (radeon_ddc_probe(radeon_connector, true)) /* try DDC */ 1684 if (radeon_ddc_probe(radeon_connector, true)) /* try DDC */
1685 ret = connector_status_connected; 1685 ret = connector_status_connected;
1686 else if (radeon_connector->dac_load_detect) { /* try load detection */ 1686 else if (radeon_connector->dac_load_detect) { /* try load detection */
1687 struct drm_encoder_helper_funcs *encoder_funcs = encoder->helper_private; 1687 const struct drm_encoder_helper_funcs *encoder_funcs = encoder->helper_private;
1688 ret = encoder_funcs->detect(encoder, connector); 1688 ret = encoder_funcs->detect(encoder, connector);
1689 } 1689 }
1690 } 1690 }
diff --git a/drivers/gpu/drm/radeon/radeon_dp_mst.c b/drivers/gpu/drm/radeon/radeon_dp_mst.c
index 5952ff2bb647..1017338a49d9 100644
--- a/drivers/gpu/drm/radeon/radeon_dp_mst.c
+++ b/drivers/gpu/drm/radeon/radeon_dp_mst.c
@@ -604,7 +604,7 @@ radeon_dp_create_fake_mst_encoder(struct radeon_connector *connector)
604 struct radeon_encoder *radeon_encoder; 604 struct radeon_encoder *radeon_encoder;
605 struct radeon_encoder_mst *mst_enc; 605 struct radeon_encoder_mst *mst_enc;
606 struct drm_encoder *encoder; 606 struct drm_encoder *encoder;
607 struct drm_connector_helper_funcs *connector_funcs = connector->base.helper_private; 607 const struct drm_connector_helper_funcs *connector_funcs = connector->base.helper_private;
608 struct drm_encoder *enc_master = connector_funcs->best_encoder(&connector->base); 608 struct drm_encoder *enc_master = connector_funcs->best_encoder(&connector->base);
609 609
610 DRM_DEBUG_KMS("enc master is %p\n", enc_master); 610 DRM_DEBUG_KMS("enc master is %p\n", enc_master);
diff --git a/drivers/gpu/drm/radeon/radeon_legacy_encoders.c b/drivers/gpu/drm/radeon/radeon_legacy_encoders.c
index c89971d904c3..45715307db71 100644
--- a/drivers/gpu/drm/radeon/radeon_legacy_encoders.c
+++ b/drivers/gpu/drm/radeon/radeon_legacy_encoders.c
@@ -36,7 +36,7 @@
36static void radeon_legacy_encoder_disable(struct drm_encoder *encoder) 36static void radeon_legacy_encoder_disable(struct drm_encoder *encoder)
37{ 37{
38 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 38 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
39 struct drm_encoder_helper_funcs *encoder_funcs; 39 const struct drm_encoder_helper_funcs *encoder_funcs;
40 40
41 encoder_funcs = encoder->helper_private; 41 encoder_funcs = encoder->helper_private;
42 encoder_funcs->dpms(encoder, DRM_MODE_DPMS_OFF); 42 encoder_funcs->dpms(encoder, DRM_MODE_DPMS_OFF);