Commit b8b5342b authored by Daniel Vetter's avatar Daniel Vetter

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: default avatarMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1464818821-5736-11-git-send-email-daniel.vetter@ffwll.ch
parent 63e83c1d
...@@ -47,7 +47,6 @@ void drm_atomic_state_default_release(struct drm_atomic_state *state) ...@@ -47,7 +47,6 @@ void drm_atomic_state_default_release(struct drm_atomic_state *state)
kfree(state->crtcs); kfree(state->crtcs);
kfree(state->crtc_states); kfree(state->crtc_states);
kfree(state->planes); kfree(state->planes);
kfree(state->plane_states);
} }
EXPORT_SYMBOL(drm_atomic_state_default_release); EXPORT_SYMBOL(drm_atomic_state_default_release);
...@@ -79,10 +78,6 @@ drm_atomic_state_init(struct drm_device *dev, struct drm_atomic_state *state) ...@@ -79,10 +78,6 @@ drm_atomic_state_init(struct drm_device *dev, struct drm_atomic_state *state)
sizeof(*state->planes), GFP_KERNEL); sizeof(*state->planes), GFP_KERNEL);
if (!state->planes) if (!state->planes)
goto fail; goto fail;
state->plane_states = kcalloc(dev->mode_config.num_total_plane,
sizeof(*state->plane_states), GFP_KERNEL);
if (!state->plane_states)
goto fail;
state->dev = dev; state->dev = dev;
...@@ -163,15 +158,15 @@ void drm_atomic_state_default_clear(struct drm_atomic_state *state) ...@@ -163,15 +158,15 @@ void drm_atomic_state_default_clear(struct drm_atomic_state *state)
} }
for (i = 0; i < config->num_total_plane; i++) { for (i = 0; i < config->num_total_plane; i++) {
struct drm_plane *plane = state->planes[i]; struct drm_plane *plane = state->planes[i].ptr;
if (!plane) if (!plane)
continue; continue;
plane->funcs->atomic_destroy_state(plane, plane->funcs->atomic_destroy_state(plane,
state->plane_states[i]); state->planes[i].state);
state->planes[i] = NULL; state->planes[i].ptr = NULL;
state->plane_states[i] = NULL; state->planes[i].state = NULL;
} }
} }
EXPORT_SYMBOL(drm_atomic_state_default_clear); EXPORT_SYMBOL(drm_atomic_state_default_clear);
...@@ -630,8 +625,8 @@ drm_atomic_get_plane_state(struct drm_atomic_state *state, ...@@ -630,8 +625,8 @@ drm_atomic_get_plane_state(struct drm_atomic_state *state,
if (!plane_state) if (!plane_state)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
state->plane_states[index] = plane_state; state->planes[index].state = plane_state;
state->planes[index] = plane; state->planes[index].ptr = plane;
plane_state->state = state; plane_state->state = state;
DRM_DEBUG_ATOMIC("Added [PLANE:%d:%s] %p state to %p\n", DRM_DEBUG_ATOMIC("Added [PLANE:%d:%s] %p state to %p\n",
......
...@@ -1584,7 +1584,7 @@ void drm_atomic_helper_swap_state(struct drm_device *dev, ...@@ -1584,7 +1584,7 @@ void drm_atomic_helper_swap_state(struct drm_device *dev,
for_each_plane_in_state(state, plane, plane_state, i) { for_each_plane_in_state(state, plane, plane_state, i) {
plane->state->state = state; plane->state->state = state;
swap(state->plane_states[i], plane->state); swap(state->planes[i].state, plane->state);
plane->state->state = NULL; plane->state->state = NULL;
} }
} }
......
...@@ -191,7 +191,7 @@ int intel_atomic_setup_scalers(struct drm_device *dev, ...@@ -191,7 +191,7 @@ int intel_atomic_setup_scalers(struct drm_device *dev,
/* plane scaler case: assign as a plane scaler */ /* plane scaler case: assign as a plane scaler */
/* find the plane that set the bit as scaler_user */ /* find the plane that set the bit as scaler_user */
plane = drm_state->planes[i]; plane = drm_state->planes[i].ptr;
/* /*
* to enable/disable hq mode, add planes that are using scaler * to enable/disable hq mode, add planes that are using scaler
......
...@@ -86,7 +86,7 @@ static inline struct drm_plane_state * ...@@ -86,7 +86,7 @@ static inline struct drm_plane_state *
drm_atomic_get_existing_plane_state(struct drm_atomic_state *state, drm_atomic_get_existing_plane_state(struct drm_atomic_state *state,
struct drm_plane *plane) struct drm_plane *plane)
{ {
return state->plane_states[drm_plane_index(plane)]; return state->planes[drm_plane_index(plane)].state;
} }
/** /**
...@@ -139,8 +139,8 @@ static inline const struct drm_plane_state * ...@@ -139,8 +139,8 @@ static inline const struct drm_plane_state *
__drm_atomic_get_current_plane_state(struct drm_atomic_state *state, __drm_atomic_get_current_plane_state(struct drm_atomic_state *state,
struct drm_plane *plane) struct drm_plane *plane)
{ {
if (state->plane_states[drm_plane_index(plane)]) if (state->planes[drm_plane_index(plane)].state)
return state->plane_states[drm_plane_index(plane)]; return state->planes[drm_plane_index(plane)].state;
return plane->state; return plane->state;
} }
...@@ -191,11 +191,11 @@ int __must_check drm_atomic_nonblocking_commit(struct drm_atomic_state *state); ...@@ -191,11 +191,11 @@ int __must_check drm_atomic_nonblocking_commit(struct drm_atomic_state *state);
(__i)++) \ (__i)++) \
for_each_if (crtc_state) for_each_if (crtc_state)
#define for_each_plane_in_state(state, plane, plane_state, __i) \ #define for_each_plane_in_state(__state, plane, plane_state, __i) \
for ((__i) = 0; \ for ((__i) = 0; \
(__i) < (state)->dev->mode_config.num_total_plane && \ (__i) < (__state)->dev->mode_config.num_total_plane && \
((plane) = (state)->planes[__i], \ ((plane) = (__state)->planes[__i].ptr, \
(plane_state) = (state)->plane_states[__i], 1); \ (plane_state) = (__state)->planes[__i].state, 1); \
(__i)++) \ (__i)++) \
for_each_if (plane_state) for_each_if (plane_state)
static inline bool static inline bool
......
...@@ -1693,6 +1693,11 @@ struct drm_bridge { ...@@ -1693,6 +1693,11 @@ struct drm_bridge {
void *driver_private; void *driver_private;
}; };
struct __drm_planes_state {
struct drm_plane *ptr;
struct drm_plane_state *state;
};
struct __drm_connnectors_state { struct __drm_connnectors_state {
struct drm_connector *ptr; struct drm_connector *ptr;
struct drm_connector_state *state; struct drm_connector_state *state;
...@@ -1704,8 +1709,7 @@ struct __drm_connnectors_state { ...@@ -1704,8 +1709,7 @@ struct __drm_connnectors_state {
* @allow_modeset: allow full modeset * @allow_modeset: allow full modeset
* @legacy_cursor_update: hint to enforce legacy cursor IOCTL semantics * @legacy_cursor_update: hint to enforce legacy cursor IOCTL semantics
* @legacy_set_config: Disable conflicting encoders instead of failing with -EINVAL. * @legacy_set_config: Disable conflicting encoders instead of failing with -EINVAL.
* @planes: pointer to array of plane pointers * @planes: pointer to array of structures with per-plane data
* @plane_states: pointer to array of plane states pointers
* @crtcs: pointer to array of CRTC pointers * @crtcs: pointer to array of CRTC pointers
* @crtc_states: pointer to array of CRTC states pointers * @crtc_states: pointer to array of CRTC states pointers
* @num_connector: size of the @connectors and @connector_states arrays * @num_connector: size of the @connectors and @connector_states arrays
...@@ -1717,8 +1721,7 @@ struct drm_atomic_state { ...@@ -1717,8 +1721,7 @@ struct drm_atomic_state {
bool allow_modeset : 1; bool allow_modeset : 1;
bool legacy_cursor_update : 1; bool legacy_cursor_update : 1;
bool legacy_set_config : 1; bool legacy_set_config : 1;
struct drm_plane **planes; struct __drm_planes_state *planes;
struct drm_plane_state **plane_states;
struct drm_crtc **crtcs; struct drm_crtc **crtcs;
struct drm_crtc_state **crtc_states; struct drm_crtc_state **crtc_states;
int num_connector; int num_connector;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment