aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2016-06-01 18:06:33 -0400
committerDaniel Vetter <daniel.vetter@ffwll.ch>2016-06-02 11:20:25 -0400
commitb8b5342b699b9b3d1b3455861a68b96424146959 (patch)
treeed4b33b83374d67bd8f6f1822e8d179815db44a3
parent63e83c1dba5490de84c2d558a2425730db7fb134 (diff)
drm: Consolidate plane arrays in drm_atomic_state
It's kinda pointless to have 2 separate mallocs for these. And when we add more per-plane state in the future it's even more pointless. Right now there's no such thing planned, but both Gustavo's per-crtc fence patches, and some nonblocking commit helpers I'm playing around with will add more per-crtc stuff. It makes sense to also consolidate planes, just for consistency. In the future we can use this to store a pointer to the preceeding state, making an atomic update entirely free-standing. This will be needed to be able to queue them up with a depth > 1. Cc: Gustavo Padovan <gustavo@padovan.org> Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com> Link: http://patchwork.freedesktop.org/patch/msgid/1464818821-5736-11-git-send-email-daniel.vetter@ffwll.ch
-rw-r--r--drivers/gpu/drm/drm_atomic.c17
-rw-r--r--drivers/gpu/drm/drm_atomic_helper.c2
-rw-r--r--drivers/gpu/drm/i915/intel_atomic.c2
-rw-r--r--include/drm/drm_atomic.h14
-rw-r--r--include/drm/drm_crtc.h11
5 files changed, 22 insertions, 24 deletions
diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index a6395e9654af..68fd99d2fd01 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -47,7 +47,6 @@ void drm_atomic_state_default_release(struct drm_atomic_state *state)
47 kfree(state->crtcs); 47 kfree(state->crtcs);
48 kfree(state->crtc_states); 48 kfree(state->crtc_states);
49 kfree(state->planes); 49 kfree(state->planes);
50 kfree(state->plane_states);
51} 50}
52EXPORT_SYMBOL(drm_atomic_state_default_release); 51EXPORT_SYMBOL(drm_atomic_state_default_release);
53 52
@@ -79,10 +78,6 @@ drm_atomic_state_init(struct drm_device *dev, struct drm_atomic_state *state)
79 sizeof(*state->planes), GFP_KERNEL); 78 sizeof(*state->planes), GFP_KERNEL);
80 if (!state->planes) 79 if (!state->planes)
81 goto fail; 80 goto fail;
82 state->plane_states = kcalloc(dev->mode_config.num_total_plane,
83 sizeof(*state->plane_states), GFP_KERNEL);
84 if (!state->plane_states)
85 goto fail;
86 81
87 state->dev = dev; 82 state->dev = dev;
88 83
@@ -163,15 +158,15 @@ void drm_atomic_state_default_clear(struct drm_atomic_state *state)
163 } 158 }
164 159
165 for (i = 0; i < config->num_total_plane; i++) { 160 for (i = 0; i < config->num_total_plane; i++) {
166 struct drm_plane *plane = state->planes[i]; 161 struct drm_plane *plane = state->planes[i].ptr;
167 162
168 if (!plane) 163 if (!plane)
169 continue; 164 continue;
170 165
171 plane->funcs->atomic_destroy_state(plane, 166 plane->funcs->atomic_destroy_state(plane,
172 state->plane_states[i]); 167 state->planes[i].state);
173 state->planes[i] = NULL; 168 state->planes[i].ptr = NULL;
174 state->plane_states[i] = NULL; 169 state->planes[i].state = NULL;
175 } 170 }
176} 171}
177EXPORT_SYMBOL(drm_atomic_state_default_clear); 172EXPORT_SYMBOL(drm_atomic_state_default_clear);
@@ -630,8 +625,8 @@ drm_atomic_get_plane_state(struct drm_atomic_state *state,
630 if (!plane_state) 625 if (!plane_state)
631 return ERR_PTR(-ENOMEM); 626 return ERR_PTR(-ENOMEM);
632 627
633 state->plane_states[index] = plane_state; 628 state->planes[index].state = plane_state;
634 state->planes[index] = plane; 629 state->planes[index].ptr = plane;
635 plane_state->state = state; 630 plane_state->state = state;
636 631
637 DRM_DEBUG_ATOMIC("Added [PLANE:%d:%s] %p state to %p\n", 632 DRM_DEBUG_ATOMIC("Added [PLANE:%d:%s] %p state to %p\n",
diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index b4e2e988132f..c2ef42c8a947 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -1584,7 +1584,7 @@ void drm_atomic_helper_swap_state(struct drm_device *dev,
1584 1584
1585 for_each_plane_in_state(state, plane, plane_state, i) { 1585 for_each_plane_in_state(state, plane, plane_state, i) {
1586 plane->state->state = state; 1586 plane->state->state = state;
1587 swap(state->plane_states[i], plane->state); 1587 swap(state->planes[i].state, plane->state);
1588 plane->state->state = NULL; 1588 plane->state->state = NULL;
1589 } 1589 }
1590} 1590}
diff --git a/drivers/gpu/drm/i915/intel_atomic.c b/drivers/gpu/drm/i915/intel_atomic.c
index 8f0d006fe4a0..c5a166752eda 100644
--- a/drivers/gpu/drm/i915/intel_atomic.c
+++ b/drivers/gpu/drm/i915/intel_atomic.c
@@ -191,7 +191,7 @@ int intel_atomic_setup_scalers(struct drm_device *dev,
191 191
192 /* plane scaler case: assign as a plane scaler */ 192 /* plane scaler case: assign as a plane scaler */
193 /* find the plane that set the bit as scaler_user */ 193 /* find the plane that set the bit as scaler_user */
194 plane = drm_state->planes[i]; 194 plane = drm_state->planes[i].ptr;
195 195
196 /* 196 /*
197 * to enable/disable hq mode, add planes that are using scaler 197 * to enable/disable hq mode, add planes that are using scaler
diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h
index 37478adb6a16..8e616d39353b 100644
--- a/include/drm/drm_atomic.h
+++ b/include/drm/drm_atomic.h
@@ -86,7 +86,7 @@ static inline struct drm_plane_state *
86drm_atomic_get_existing_plane_state(struct drm_atomic_state *state, 86drm_atomic_get_existing_plane_state(struct drm_atomic_state *state,
87 struct drm_plane *plane) 87 struct drm_plane *plane)
88{ 88{
89 return state->plane_states[drm_plane_index(plane)]; 89 return state->planes[drm_plane_index(plane)].state;
90} 90}
91 91
92/** 92/**
@@ -139,8 +139,8 @@ static inline const struct drm_plane_state *
139__drm_atomic_get_current_plane_state(struct drm_atomic_state *state, 139__drm_atomic_get_current_plane_state(struct drm_atomic_state *state,
140 struct drm_plane *plane) 140 struct drm_plane *plane)
141{ 141{
142 if (state->plane_states[drm_plane_index(plane)]) 142 if (state->planes[drm_plane_index(plane)].state)
143 return state->plane_states[drm_plane_index(plane)]; 143 return state->planes[drm_plane_index(plane)].state;
144 144
145 return plane->state; 145 return plane->state;
146} 146}
@@ -191,11 +191,11 @@ int __must_check drm_atomic_nonblocking_commit(struct drm_atomic_state *state);
191 (__i)++) \ 191 (__i)++) \
192 for_each_if (crtc_state) 192 for_each_if (crtc_state)
193 193
194#define for_each_plane_in_state(state, plane, plane_state, __i) \ 194#define for_each_plane_in_state(__state, plane, plane_state, __i) \
195 for ((__i) = 0; \ 195 for ((__i) = 0; \
196 (__i) < (state)->dev->mode_config.num_total_plane && \ 196 (__i) < (__state)->dev->mode_config.num_total_plane && \
197 ((plane) = (state)->planes[__i], \ 197 ((plane) = (__state)->planes[__i].ptr, \
198 (plane_state) = (state)->plane_states[__i], 1); \ 198 (plane_state) = (__state)->planes[__i].state, 1); \
199 (__i)++) \ 199 (__i)++) \
200 for_each_if (plane_state) 200 for_each_if (plane_state)
201static inline bool 201static inline bool
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index 751990a3bc7a..821398ce52d0 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -1693,6 +1693,11 @@ struct drm_bridge {
1693 void *driver_private; 1693 void *driver_private;
1694}; 1694};
1695 1695
1696struct __drm_planes_state {
1697 struct drm_plane *ptr;
1698 struct drm_plane_state *state;
1699};
1700
1696struct __drm_connnectors_state { 1701struct __drm_connnectors_state {
1697 struct drm_connector *ptr; 1702 struct drm_connector *ptr;
1698 struct drm_connector_state *state; 1703 struct drm_connector_state *state;
@@ -1704,8 +1709,7 @@ struct __drm_connnectors_state {
1704 * @allow_modeset: allow full modeset 1709 * @allow_modeset: allow full modeset
1705 * @legacy_cursor_update: hint to enforce legacy cursor IOCTL semantics 1710 * @legacy_cursor_update: hint to enforce legacy cursor IOCTL semantics
1706 * @legacy_set_config: Disable conflicting encoders instead of failing with -EINVAL. 1711 * @legacy_set_config: Disable conflicting encoders instead of failing with -EINVAL.
1707 * @planes: pointer to array of plane pointers 1712 * @planes: pointer to array of structures with per-plane data
1708 * @plane_states: pointer to array of plane states pointers
1709 * @crtcs: pointer to array of CRTC pointers 1713 * @crtcs: pointer to array of CRTC pointers
1710 * @crtc_states: pointer to array of CRTC states pointers 1714 * @crtc_states: pointer to array of CRTC states pointers
1711 * @num_connector: size of the @connectors and @connector_states arrays 1715 * @num_connector: size of the @connectors and @connector_states arrays
@@ -1717,8 +1721,7 @@ struct drm_atomic_state {
1717 bool allow_modeset : 1; 1721 bool allow_modeset : 1;
1718 bool legacy_cursor_update : 1; 1722 bool legacy_cursor_update : 1;
1719 bool legacy_set_config : 1; 1723 bool legacy_set_config : 1;
1720 struct drm_plane **planes; 1724 struct __drm_planes_state *planes;
1721 struct drm_plane_state **plane_states;
1722 struct drm_crtc **crtcs; 1725 struct drm_crtc **crtcs;
1723 struct drm_crtc_state **crtc_states; 1726 struct drm_crtc_state **crtc_states;
1724 int num_connector; 1727 int num_connector;