drm: Consolidate connector arrays in drm_atomic_state
It's kinda pointless to have 2 separate mallocs for these. And when we add more per-connector 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 connectors, 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-10-git-send-email-daniel.vetter@ffwll.ch
This commit is contained in:
parent
2f196b7c4b
commit
63e83c1dba
|
@ -44,7 +44,6 @@
|
||||||
void drm_atomic_state_default_release(struct drm_atomic_state *state)
|
void drm_atomic_state_default_release(struct drm_atomic_state *state)
|
||||||
{
|
{
|
||||||
kfree(state->connectors);
|
kfree(state->connectors);
|
||||||
kfree(state->connector_states);
|
|
||||||
kfree(state->crtcs);
|
kfree(state->crtcs);
|
||||||
kfree(state->crtc_states);
|
kfree(state->crtc_states);
|
||||||
kfree(state->planes);
|
kfree(state->planes);
|
||||||
|
@ -139,15 +138,15 @@ void drm_atomic_state_default_clear(struct drm_atomic_state *state)
|
||||||
DRM_DEBUG_ATOMIC("Clearing atomic state %p\n", state);
|
DRM_DEBUG_ATOMIC("Clearing atomic state %p\n", state);
|
||||||
|
|
||||||
for (i = 0; i < state->num_connector; i++) {
|
for (i = 0; i < state->num_connector; i++) {
|
||||||
struct drm_connector *connector = state->connectors[i];
|
struct drm_connector *connector = state->connectors[i].ptr;
|
||||||
|
|
||||||
if (!connector)
|
if (!connector)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
connector->funcs->atomic_destroy_state(connector,
|
connector->funcs->atomic_destroy_state(connector,
|
||||||
state->connector_states[i]);
|
state->connectors[i].state);
|
||||||
state->connectors[i] = NULL;
|
state->connectors[i].ptr = NULL;
|
||||||
state->connector_states[i] = NULL;
|
state->connectors[i].state = NULL;
|
||||||
drm_connector_unreference(connector);
|
drm_connector_unreference(connector);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -896,8 +895,7 @@ drm_atomic_get_connector_state(struct drm_atomic_state *state,
|
||||||
index = drm_connector_index(connector);
|
index = drm_connector_index(connector);
|
||||||
|
|
||||||
if (index >= state->num_connector) {
|
if (index >= state->num_connector) {
|
||||||
struct drm_connector **c;
|
struct __drm_connnectors_state *c;
|
||||||
struct drm_connector_state **cs;
|
|
||||||
int alloc = max(index + 1, config->num_connector);
|
int alloc = max(index + 1, config->num_connector);
|
||||||
|
|
||||||
c = krealloc(state->connectors, alloc * sizeof(*state->connectors), GFP_KERNEL);
|
c = krealloc(state->connectors, alloc * sizeof(*state->connectors), GFP_KERNEL);
|
||||||
|
@ -908,26 +906,19 @@ drm_atomic_get_connector_state(struct drm_atomic_state *state,
|
||||||
memset(&state->connectors[state->num_connector], 0,
|
memset(&state->connectors[state->num_connector], 0,
|
||||||
sizeof(*state->connectors) * (alloc - state->num_connector));
|
sizeof(*state->connectors) * (alloc - state->num_connector));
|
||||||
|
|
||||||
cs = krealloc(state->connector_states, alloc * sizeof(*state->connector_states), GFP_KERNEL);
|
|
||||||
if (!cs)
|
|
||||||
return ERR_PTR(-ENOMEM);
|
|
||||||
|
|
||||||
state->connector_states = cs;
|
|
||||||
memset(&state->connector_states[state->num_connector], 0,
|
|
||||||
sizeof(*state->connector_states) * (alloc - state->num_connector));
|
|
||||||
state->num_connector = alloc;
|
state->num_connector = alloc;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state->connector_states[index])
|
if (state->connectors[index].state)
|
||||||
return state->connector_states[index];
|
return state->connectors[index].state;
|
||||||
|
|
||||||
connector_state = connector->funcs->atomic_duplicate_state(connector);
|
connector_state = connector->funcs->atomic_duplicate_state(connector);
|
||||||
if (!connector_state)
|
if (!connector_state)
|
||||||
return ERR_PTR(-ENOMEM);
|
return ERR_PTR(-ENOMEM);
|
||||||
|
|
||||||
drm_connector_reference(connector);
|
drm_connector_reference(connector);
|
||||||
state->connector_states[index] = connector_state;
|
state->connectors[index].state = connector_state;
|
||||||
state->connectors[index] = connector;
|
state->connectors[index].ptr = connector;
|
||||||
connector_state->state = state;
|
connector_state->state = state;
|
||||||
|
|
||||||
DRM_DEBUG_ATOMIC("Added [CONNECTOR:%d] %p state to %p\n",
|
DRM_DEBUG_ATOMIC("Added [CONNECTOR:%d] %p state to %p\n",
|
||||||
|
|
|
@ -1572,7 +1572,7 @@ void drm_atomic_helper_swap_state(struct drm_device *dev,
|
||||||
|
|
||||||
for_each_connector_in_state(state, connector, conn_state, i) {
|
for_each_connector_in_state(state, connector, conn_state, i) {
|
||||||
connector->state->state = state;
|
connector->state->state = state;
|
||||||
swap(state->connector_states[i], connector->state);
|
swap(state->connectors[i].state, connector->state);
|
||||||
connector->state->state = NULL;
|
connector->state->state = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -106,7 +106,7 @@ drm_atomic_get_existing_connector_state(struct drm_atomic_state *state,
|
||||||
if (index >= state->num_connector)
|
if (index >= state->num_connector)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return state->connector_states[index];
|
return state->connectors[index].state;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -175,11 +175,11 @@ int __must_check drm_atomic_check_only(struct drm_atomic_state *state);
|
||||||
int __must_check drm_atomic_commit(struct drm_atomic_state *state);
|
int __must_check drm_atomic_commit(struct drm_atomic_state *state);
|
||||||
int __must_check drm_atomic_nonblocking_commit(struct drm_atomic_state *state);
|
int __must_check drm_atomic_nonblocking_commit(struct drm_atomic_state *state);
|
||||||
|
|
||||||
#define for_each_connector_in_state(state, connector, connector_state, __i) \
|
#define for_each_connector_in_state(__state, connector, connector_state, __i) \
|
||||||
for ((__i) = 0; \
|
for ((__i) = 0; \
|
||||||
(__i) < (state)->num_connector && \
|
(__i) < (__state)->num_connector && \
|
||||||
((connector) = (state)->connectors[__i], \
|
((connector) = (__state)->connectors[__i].ptr, \
|
||||||
(connector_state) = (state)->connector_states[__i], 1); \
|
(connector_state) = (__state)->connectors[__i].state, 1); \
|
||||||
(__i)++) \
|
(__i)++) \
|
||||||
for_each_if (connector)
|
for_each_if (connector)
|
||||||
|
|
||||||
|
|
|
@ -1693,6 +1693,11 @@ struct drm_bridge {
|
||||||
void *driver_private;
|
void *driver_private;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct __drm_connnectors_state {
|
||||||
|
struct drm_connector *ptr;
|
||||||
|
struct drm_connector_state *state;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* struct drm_atomic_state - the global state object for atomic updates
|
* struct drm_atomic_state - the global state object for atomic updates
|
||||||
* @dev: parent DRM device
|
* @dev: parent DRM device
|
||||||
|
@ -1704,8 +1709,7 @@ struct drm_bridge {
|
||||||
* @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
|
||||||
* @connectors: pointer to array of connector pointers
|
* @connectors: pointer to array of structures with per-connector data
|
||||||
* @connector_states: pointer to array of connector states pointers
|
|
||||||
* @acquire_ctx: acquire context for this atomic modeset state update
|
* @acquire_ctx: acquire context for this atomic modeset state update
|
||||||
*/
|
*/
|
||||||
struct drm_atomic_state {
|
struct drm_atomic_state {
|
||||||
|
@ -1718,8 +1722,7 @@ struct drm_atomic_state {
|
||||||
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;
|
||||||
struct drm_connector **connectors;
|
struct __drm_connnectors_state *connectors;
|
||||||
struct drm_connector_state **connector_states;
|
|
||||||
|
|
||||||
struct drm_modeset_acquire_ctx *acquire_ctx;
|
struct drm_modeset_acquire_ctx *acquire_ctx;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue