aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2014-11-27 09:49:39 -0500
committerDaniel Vetter <daniel.vetter@ffwll.ch>2014-12-17 14:23:23 -0500
commit07cc0ef67fa873c8d21e0b626d57753bfd190095 (patch)
tree44beb89d906d8ad625b222f3b7ea4feb87666b67
parentb4274fbee6fc7ca3dd1cc786456ec6fbc14f864d (diff)
drm/atomic: Introduce state->obj backpointers
Useful since this way we can pass around just the state objects and will get ther real object, too. Specifically this allows us to again simplify the parameters for set_crtc_for_plane. v2: msm already has it's own specific plane_reset hook, don't forget that one! v3: Fixup kerneldoc, reported by 0-day builder. Cc: Rob Clark <robdclark@gmail.com> Reviewed-by: Rob Clark <robdclark@gmail.com> (v2) Tested-by: Rob Clark <robdclark@gmail.com> (v2) Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
-rw-r--r--drivers/gpu/drm/drm_atomic.c13
-rw-r--r--drivers/gpu/drm/drm_atomic_helper.c19
-rw-r--r--drivers/gpu/drm/drm_crtc_helper.c2
-rw-r--r--drivers/gpu/drm/drm_plane_helper.c2
-rw-r--r--drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c1
-rw-r--r--include/drm/drm_atomic.h4
-rw-r--r--include/drm/drm_crtc.h9
7 files changed, 34 insertions, 16 deletions
diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index ff5f034cc405..cbd5e7240b6b 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -344,8 +344,7 @@ EXPORT_SYMBOL(drm_atomic_get_connector_state);
344 344
345/** 345/**
346 * drm_atomic_set_crtc_for_plane - set crtc for plane 346 * drm_atomic_set_crtc_for_plane - set crtc for plane
347 * @state: the incoming atomic state 347 * @plane_state: the plane whose incoming state to update
348 * @plane: the plane whose incoming state to update
349 * @crtc: crtc to use for the plane 348 * @crtc: crtc to use for the plane
350 * 349 *
351 * Changing the assigned crtc for a plane requires us to grab the lock and state 350 * Changing the assigned crtc for a plane requires us to grab the lock and state
@@ -358,16 +357,12 @@ EXPORT_SYMBOL(drm_atomic_get_connector_state);
358 * sequence must be restarted. All other errors are fatal. 357 * sequence must be restarted. All other errors are fatal.
359 */ 358 */
360int 359int
361drm_atomic_set_crtc_for_plane(struct drm_atomic_state *state, 360drm_atomic_set_crtc_for_plane(struct drm_plane_state *plane_state,
362 struct drm_plane *plane, struct drm_crtc *crtc) 361 struct drm_crtc *crtc)
363{ 362{
364 struct drm_plane_state *plane_state = 363 struct drm_plane *plane = plane_state->plane;
365 drm_atomic_get_plane_state(state, plane);
366 struct drm_crtc_state *crtc_state; 364 struct drm_crtc_state *crtc_state;
367 365
368 if (WARN_ON(IS_ERR(plane_state)))
369 return PTR_ERR(plane_state);
370
371 if (plane_state->crtc) { 366 if (plane_state->crtc) {
372 crtc_state = drm_atomic_get_crtc_state(plane_state->state, 367 crtc_state = drm_atomic_get_crtc_state(plane_state->state,
373 plane_state->crtc); 368 plane_state->crtc);
diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index eb380ee2dc58..379d37acd5b5 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -1277,7 +1277,7 @@ retry:
1277 goto fail; 1277 goto fail;
1278 } 1278 }
1279 1279
1280 ret = drm_atomic_set_crtc_for_plane(state, plane, crtc); 1280 ret = drm_atomic_set_crtc_for_plane(plane_state, crtc);
1281 if (ret != 0) 1281 if (ret != 0)
1282 goto fail; 1282 goto fail;
1283 drm_atomic_set_fb_for_plane(plane_state, fb); 1283 drm_atomic_set_fb_for_plane(plane_state, fb);
@@ -1356,7 +1356,7 @@ retry:
1356 goto fail; 1356 goto fail;
1357 } 1357 }
1358 1358
1359 ret = drm_atomic_set_crtc_for_plane(state, plane, NULL); 1359 ret = drm_atomic_set_crtc_for_plane(plane_state, NULL);
1360 if (ret != 0) 1360 if (ret != 0)
1361 goto fail; 1361 goto fail;
1362 drm_atomic_set_fb_for_plane(plane_state, NULL); 1362 drm_atomic_set_fb_for_plane(plane_state, NULL);
@@ -1519,7 +1519,7 @@ retry:
1519 1519
1520 crtc_state->enable = false; 1520 crtc_state->enable = false;
1521 1521
1522 ret = drm_atomic_set_crtc_for_plane(state, crtc->primary, NULL); 1522 ret = drm_atomic_set_crtc_for_plane(primary_state, NULL);
1523 if (ret != 0) 1523 if (ret != 0)
1524 goto fail; 1524 goto fail;
1525 1525
@@ -1534,7 +1534,7 @@ retry:
1534 crtc_state->enable = true; 1534 crtc_state->enable = true;
1535 drm_mode_copy(&crtc_state->mode, set->mode); 1535 drm_mode_copy(&crtc_state->mode, set->mode);
1536 1536
1537 ret = drm_atomic_set_crtc_for_plane(state, crtc->primary, crtc); 1537 ret = drm_atomic_set_crtc_for_plane(primary_state, crtc);
1538 if (ret != 0) 1538 if (ret != 0)
1539 goto fail; 1539 goto fail;
1540 drm_atomic_set_fb_for_plane(primary_state, set->fb); 1540 drm_atomic_set_fb_for_plane(primary_state, set->fb);
@@ -1806,7 +1806,7 @@ retry:
1806 goto fail; 1806 goto fail;
1807 } 1807 }
1808 1808
1809 ret = drm_atomic_set_crtc_for_plane(state, plane, crtc); 1809 ret = drm_atomic_set_crtc_for_plane(plane_state, crtc);
1810 if (ret != 0) 1810 if (ret != 0)
1811 goto fail; 1811 goto fail;
1812 drm_atomic_set_fb_for_plane(plane_state, fb); 1812 drm_atomic_set_fb_for_plane(plane_state, fb);
@@ -1869,6 +1869,9 @@ void drm_atomic_helper_crtc_reset(struct drm_crtc *crtc)
1869{ 1869{
1870 kfree(crtc->state); 1870 kfree(crtc->state);
1871 crtc->state = kzalloc(sizeof(*crtc->state), GFP_KERNEL); 1871 crtc->state = kzalloc(sizeof(*crtc->state), GFP_KERNEL);
1872
1873 if (crtc->state)
1874 crtc->state->crtc = crtc;
1872} 1875}
1873EXPORT_SYMBOL(drm_atomic_helper_crtc_reset); 1876EXPORT_SYMBOL(drm_atomic_helper_crtc_reset);
1874 1877
@@ -1928,6 +1931,9 @@ void drm_atomic_helper_plane_reset(struct drm_plane *plane)
1928 1931
1929 kfree(plane->state); 1932 kfree(plane->state);
1930 plane->state = kzalloc(sizeof(*plane->state), GFP_KERNEL); 1933 plane->state = kzalloc(sizeof(*plane->state), GFP_KERNEL);
1934
1935 if (plane->state)
1936 plane->state->plane = plane;
1931} 1937}
1932EXPORT_SYMBOL(drm_atomic_helper_plane_reset); 1938EXPORT_SYMBOL(drm_atomic_helper_plane_reset);
1933 1939
@@ -1985,6 +1991,9 @@ void drm_atomic_helper_connector_reset(struct drm_connector *connector)
1985{ 1991{
1986 kfree(connector->state); 1992 kfree(connector->state);
1987 connector->state = kzalloc(sizeof(*connector->state), GFP_KERNEL); 1993 connector->state = kzalloc(sizeof(*connector->state), GFP_KERNEL);
1994
1995 if (connector->state)
1996 connector->state->connector = connector;
1988} 1997}
1989EXPORT_SYMBOL(drm_atomic_helper_connector_reset); 1998EXPORT_SYMBOL(drm_atomic_helper_connector_reset);
1990 1999
diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
index d552708409de..b1979e7bdc88 100644
--- a/drivers/gpu/drm/drm_crtc_helper.c
+++ b/drivers/gpu/drm/drm_crtc_helper.c
@@ -946,6 +946,7 @@ int drm_helper_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mod
946 crtc_state = kzalloc(sizeof(*crtc_state), GFP_KERNEL); 946 crtc_state = kzalloc(sizeof(*crtc_state), GFP_KERNEL);
947 if (!crtc_state) 947 if (!crtc_state)
948 return -ENOMEM; 948 return -ENOMEM;
949 crtc_state->crtc = crtc;
949 950
950 crtc_state->enable = true; 951 crtc_state->enable = true;
951 crtc_state->planes_changed = true; 952 crtc_state->planes_changed = true;
@@ -1005,6 +1006,7 @@ int drm_helper_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y,
1005 plane_state = kzalloc(sizeof(*plane_state), GFP_KERNEL); 1006 plane_state = kzalloc(sizeof(*plane_state), GFP_KERNEL);
1006 if (!plane_state) 1007 if (!plane_state)
1007 return -ENOMEM; 1008 return -ENOMEM;
1009 plane_state->plane = plane;
1008 1010
1009 plane_state->crtc = crtc; 1011 plane_state->crtc = crtc;
1010 drm_atomic_set_fb_for_plane(plane_state, crtc->primary->fb); 1012 drm_atomic_set_fb_for_plane(plane_state, crtc->primary->fb);
diff --git a/drivers/gpu/drm/drm_plane_helper.c b/drivers/gpu/drm/drm_plane_helper.c
index 18a1ac6ac22f..ae61fb21ea86 100644
--- a/drivers/gpu/drm/drm_plane_helper.c
+++ b/drivers/gpu/drm/drm_plane_helper.c
@@ -517,6 +517,7 @@ int drm_plane_helper_update(struct drm_plane *plane, struct drm_crtc *crtc,
517 plane_state = kzalloc(sizeof(*plane_state), GFP_KERNEL); 517 plane_state = kzalloc(sizeof(*plane_state), GFP_KERNEL);
518 if (!plane_state) 518 if (!plane_state)
519 return -ENOMEM; 519 return -ENOMEM;
520 plane_state->plane = plane;
520 521
521 plane_state->crtc = crtc; 522 plane_state->crtc = crtc;
522 drm_atomic_set_fb_for_plane(plane_state, fb); 523 drm_atomic_set_fb_for_plane(plane_state, fb);
@@ -563,6 +564,7 @@ int drm_plane_helper_disable(struct drm_plane *plane)
563 plane_state = kzalloc(sizeof(*plane_state), GFP_KERNEL); 564 plane_state = kzalloc(sizeof(*plane_state), GFP_KERNEL);
564 if (!plane_state) 565 if (!plane_state)
565 return -ENOMEM; 566 return -ENOMEM;
567 plane_state->plane = plane;
566 568
567 plane_state->crtc = NULL; 569 plane_state->crtc = NULL;
568 drm_atomic_set_fb_for_plane(plane_state, NULL); 570 drm_atomic_set_fb_for_plane(plane_state, NULL);
diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
index 26e5fdea6594..fc76f630e5b1 100644
--- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
+++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
@@ -113,6 +113,7 @@ static void mdp5_plane_reset(struct drm_plane *plane)
113 } else { 113 } else {
114 mdp5_state->zpos = 1 + drm_plane_index(plane); 114 mdp5_state->zpos = 1 + drm_plane_index(plane);
115 } 115 }
116 mdp5_state->base.plane = plane;
116 117
117 plane->state = &mdp5_state->base; 118 plane->state = &mdp5_state->base;
118} 119}
diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h
index ad2229574dd9..e224ccfa11ca 100644
--- a/include/drm/drm_atomic.h
+++ b/include/drm/drm_atomic.h
@@ -46,8 +46,8 @@ drm_atomic_get_connector_state(struct drm_atomic_state *state,
46 struct drm_connector *connector); 46 struct drm_connector *connector);
47 47
48int __must_check 48int __must_check
49drm_atomic_set_crtc_for_plane(struct drm_atomic_state *state, 49drm_atomic_set_crtc_for_plane(struct drm_plane_state *plane_state,
50 struct drm_plane *plane, struct drm_crtc *crtc); 50 struct drm_crtc *crtc);
51void drm_atomic_set_fb_for_plane(struct drm_plane_state *plane_state, 51void drm_atomic_set_fb_for_plane(struct drm_plane_state *plane_state,
52 struct drm_framebuffer *fb); 52 struct drm_framebuffer *fb);
53int __must_check 53int __must_check
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index 4ee78212f8bf..fd8139ca629a 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -237,6 +237,7 @@ struct drm_atomic_state;
237 237
238/** 238/**
239 * struct drm_crtc_state - mutable CRTC state 239 * struct drm_crtc_state - mutable CRTC state
240 * @crtc: backpointer to the CRTC
240 * @enable: whether the CRTC should be enabled, gates all other state 241 * @enable: whether the CRTC should be enabled, gates all other state
241 * @active: whether the CRTC is actively displaying (used for DPMS) 242 * @active: whether the CRTC is actively displaying (used for DPMS)
242 * @mode_changed: for use by helpers and drivers when computing state updates 243 * @mode_changed: for use by helpers and drivers when computing state updates
@@ -257,6 +258,8 @@ struct drm_atomic_state;
257 * assignment, @active controls the actual hardware state. 258 * assignment, @active controls the actual hardware state.
258 */ 259 */
259struct drm_crtc_state { 260struct drm_crtc_state {
261 struct drm_crtc *crtc;
262
260 bool enable; 263 bool enable;
261 bool active; 264 bool active;
262 265
@@ -457,11 +460,14 @@ struct drm_crtc {
457 460
458/** 461/**
459 * struct drm_connector_state - mutable connector state 462 * struct drm_connector_state - mutable connector state
463 * @connector: backpointer to the connector
460 * @crtc: CRTC to connect connector to, NULL if disabled 464 * @crtc: CRTC to connect connector to, NULL if disabled
461 * @best_encoder: can be used by helpers and drivers to select the encoder 465 * @best_encoder: can be used by helpers and drivers to select the encoder
462 * @state: backpointer to global drm_atomic_state 466 * @state: backpointer to global drm_atomic_state
463 */ 467 */
464struct drm_connector_state { 468struct drm_connector_state {
469 struct drm_connector *connector;
470
465 struct drm_crtc *crtc; /* do not write directly, use drm_atomic_set_crtc_for_connector() */ 471 struct drm_crtc *crtc; /* do not write directly, use drm_atomic_set_crtc_for_connector() */
466 472
467 struct drm_encoder *best_encoder; 473 struct drm_encoder *best_encoder;
@@ -701,6 +707,7 @@ struct drm_connector {
701 707
702/** 708/**
703 * struct drm_plane_state - mutable plane state 709 * struct drm_plane_state - mutable plane state
710 * @plane: backpointer to the plane
704 * @crtc: currently bound CRTC, NULL if disabled 711 * @crtc: currently bound CRTC, NULL if disabled
705 * @fb: currently bound framebuffer 712 * @fb: currently bound framebuffer
706 * @fence: optional fence to wait for before scanning out @fb 713 * @fence: optional fence to wait for before scanning out @fb
@@ -717,6 +724,8 @@ struct drm_connector {
717 * @state: backpointer to global drm_atomic_state 724 * @state: backpointer to global drm_atomic_state
718 */ 725 */
719struct drm_plane_state { 726struct drm_plane_state {
727 struct drm_plane *plane;
728
720 struct drm_crtc *crtc; /* do not write directly, use drm_atomic_set_crtc_for_plane() */ 729 struct drm_crtc *crtc; /* do not write directly, use drm_atomic_set_crtc_for_plane() */
721 struct drm_framebuffer *fb; /* do not write directly, use drm_atomic_set_fb_for_plane() */ 730 struct drm_framebuffer *fb; /* do not write directly, use drm_atomic_set_fb_for_plane() */
722 struct fence *fence; 731 struct fence *fence;