Commit 07cc0ef6 authored by Daniel Vetter's avatar Daniel Vetter

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: default avatarDaniel Vetter <daniel.vetter@intel.com>
parent b4274fbe
...@@ -344,8 +344,7 @@ EXPORT_SYMBOL(drm_atomic_get_connector_state); ...@@ -344,8 +344,7 @@ EXPORT_SYMBOL(drm_atomic_get_connector_state);
/** /**
* drm_atomic_set_crtc_for_plane - set crtc for plane * drm_atomic_set_crtc_for_plane - set crtc for plane
* @state: the incoming atomic state * @plane_state: the plane whose incoming state to update
* @plane: the plane whose incoming state to update
* @crtc: crtc to use for the plane * @crtc: crtc to use for the plane
* *
* Changing the assigned crtc for a plane requires us to grab the lock and state * 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,16 +357,12 @@ EXPORT_SYMBOL(drm_atomic_get_connector_state);
* sequence must be restarted. All other errors are fatal. * sequence must be restarted. All other errors are fatal.
*/ */
int int
drm_atomic_set_crtc_for_plane(struct drm_atomic_state *state, drm_atomic_set_crtc_for_plane(struct drm_plane_state *plane_state,
struct drm_plane *plane, struct drm_crtc *crtc) struct drm_crtc *crtc)
{ {
struct drm_plane_state *plane_state = struct drm_plane *plane = plane_state->plane;
drm_atomic_get_plane_state(state, plane);
struct drm_crtc_state *crtc_state; struct drm_crtc_state *crtc_state;
if (WARN_ON(IS_ERR(plane_state)))
return PTR_ERR(plane_state);
if (plane_state->crtc) { if (plane_state->crtc) {
crtc_state = drm_atomic_get_crtc_state(plane_state->state, crtc_state = drm_atomic_get_crtc_state(plane_state->state,
plane_state->crtc); plane_state->crtc);
......
...@@ -1277,7 +1277,7 @@ int drm_atomic_helper_update_plane(struct drm_plane *plane, ...@@ -1277,7 +1277,7 @@ int drm_atomic_helper_update_plane(struct drm_plane *plane,
goto fail; goto fail;
} }
ret = drm_atomic_set_crtc_for_plane(state, plane, crtc); ret = drm_atomic_set_crtc_for_plane(plane_state, crtc);
if (ret != 0) if (ret != 0)
goto fail; goto fail;
drm_atomic_set_fb_for_plane(plane_state, fb); drm_atomic_set_fb_for_plane(plane_state, fb);
...@@ -1356,7 +1356,7 @@ int drm_atomic_helper_disable_plane(struct drm_plane *plane) ...@@ -1356,7 +1356,7 @@ int drm_atomic_helper_disable_plane(struct drm_plane *plane)
goto fail; goto fail;
} }
ret = drm_atomic_set_crtc_for_plane(state, plane, NULL); ret = drm_atomic_set_crtc_for_plane(plane_state, NULL);
if (ret != 0) if (ret != 0)
goto fail; goto fail;
drm_atomic_set_fb_for_plane(plane_state, NULL); drm_atomic_set_fb_for_plane(plane_state, NULL);
...@@ -1519,7 +1519,7 @@ int drm_atomic_helper_set_config(struct drm_mode_set *set) ...@@ -1519,7 +1519,7 @@ int drm_atomic_helper_set_config(struct drm_mode_set *set)
crtc_state->enable = false; crtc_state->enable = false;
ret = drm_atomic_set_crtc_for_plane(state, crtc->primary, NULL); ret = drm_atomic_set_crtc_for_plane(primary_state, NULL);
if (ret != 0) if (ret != 0)
goto fail; goto fail;
...@@ -1534,7 +1534,7 @@ int drm_atomic_helper_set_config(struct drm_mode_set *set) ...@@ -1534,7 +1534,7 @@ int drm_atomic_helper_set_config(struct drm_mode_set *set)
crtc_state->enable = true; crtc_state->enable = true;
drm_mode_copy(&crtc_state->mode, set->mode); drm_mode_copy(&crtc_state->mode, set->mode);
ret = drm_atomic_set_crtc_for_plane(state, crtc->primary, crtc); ret = drm_atomic_set_crtc_for_plane(primary_state, crtc);
if (ret != 0) if (ret != 0)
goto fail; goto fail;
drm_atomic_set_fb_for_plane(primary_state, set->fb); drm_atomic_set_fb_for_plane(primary_state, set->fb);
...@@ -1806,7 +1806,7 @@ int drm_atomic_helper_page_flip(struct drm_crtc *crtc, ...@@ -1806,7 +1806,7 @@ int drm_atomic_helper_page_flip(struct drm_crtc *crtc,
goto fail; goto fail;
} }
ret = drm_atomic_set_crtc_for_plane(state, plane, crtc); ret = drm_atomic_set_crtc_for_plane(plane_state, crtc);
if (ret != 0) if (ret != 0)
goto fail; goto fail;
drm_atomic_set_fb_for_plane(plane_state, fb); drm_atomic_set_fb_for_plane(plane_state, fb);
...@@ -1869,6 +1869,9 @@ void drm_atomic_helper_crtc_reset(struct drm_crtc *crtc) ...@@ -1869,6 +1869,9 @@ void drm_atomic_helper_crtc_reset(struct drm_crtc *crtc)
{ {
kfree(crtc->state); kfree(crtc->state);
crtc->state = kzalloc(sizeof(*crtc->state), GFP_KERNEL); crtc->state = kzalloc(sizeof(*crtc->state), GFP_KERNEL);
if (crtc->state)
crtc->state->crtc = crtc;
} }
EXPORT_SYMBOL(drm_atomic_helper_crtc_reset); EXPORT_SYMBOL(drm_atomic_helper_crtc_reset);
...@@ -1928,6 +1931,9 @@ void drm_atomic_helper_plane_reset(struct drm_plane *plane) ...@@ -1928,6 +1931,9 @@ void drm_atomic_helper_plane_reset(struct drm_plane *plane)
kfree(plane->state); kfree(plane->state);
plane->state = kzalloc(sizeof(*plane->state), GFP_KERNEL); plane->state = kzalloc(sizeof(*plane->state), GFP_KERNEL);
if (plane->state)
plane->state->plane = plane;
} }
EXPORT_SYMBOL(drm_atomic_helper_plane_reset); EXPORT_SYMBOL(drm_atomic_helper_plane_reset);
...@@ -1985,6 +1991,9 @@ void drm_atomic_helper_connector_reset(struct drm_connector *connector) ...@@ -1985,6 +1991,9 @@ void drm_atomic_helper_connector_reset(struct drm_connector *connector)
{ {
kfree(connector->state); kfree(connector->state);
connector->state = kzalloc(sizeof(*connector->state), GFP_KERNEL); connector->state = kzalloc(sizeof(*connector->state), GFP_KERNEL);
if (connector->state)
connector->state->connector = connector;
} }
EXPORT_SYMBOL(drm_atomic_helper_connector_reset); EXPORT_SYMBOL(drm_atomic_helper_connector_reset);
......
...@@ -946,6 +946,7 @@ int drm_helper_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mod ...@@ -946,6 +946,7 @@ int drm_helper_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mod
crtc_state = kzalloc(sizeof(*crtc_state), GFP_KERNEL); crtc_state = kzalloc(sizeof(*crtc_state), GFP_KERNEL);
if (!crtc_state) if (!crtc_state)
return -ENOMEM; return -ENOMEM;
crtc_state->crtc = crtc;
crtc_state->enable = true; crtc_state->enable = true;
crtc_state->planes_changed = true; 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,6 +1006,7 @@ int drm_helper_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y,
plane_state = kzalloc(sizeof(*plane_state), GFP_KERNEL); plane_state = kzalloc(sizeof(*plane_state), GFP_KERNEL);
if (!plane_state) if (!plane_state)
return -ENOMEM; return -ENOMEM;
plane_state->plane = plane;
plane_state->crtc = crtc; plane_state->crtc = crtc;
drm_atomic_set_fb_for_plane(plane_state, crtc->primary->fb); drm_atomic_set_fb_for_plane(plane_state, crtc->primary->fb);
......
...@@ -517,6 +517,7 @@ int drm_plane_helper_update(struct drm_plane *plane, struct drm_crtc *crtc, ...@@ -517,6 +517,7 @@ int drm_plane_helper_update(struct drm_plane *plane, struct drm_crtc *crtc,
plane_state = kzalloc(sizeof(*plane_state), GFP_KERNEL); plane_state = kzalloc(sizeof(*plane_state), GFP_KERNEL);
if (!plane_state) if (!plane_state)
return -ENOMEM; return -ENOMEM;
plane_state->plane = plane;
plane_state->crtc = crtc; plane_state->crtc = crtc;
drm_atomic_set_fb_for_plane(plane_state, fb); drm_atomic_set_fb_for_plane(plane_state, fb);
...@@ -563,6 +564,7 @@ int drm_plane_helper_disable(struct drm_plane *plane) ...@@ -563,6 +564,7 @@ int drm_plane_helper_disable(struct drm_plane *plane)
plane_state = kzalloc(sizeof(*plane_state), GFP_KERNEL); plane_state = kzalloc(sizeof(*plane_state), GFP_KERNEL);
if (!plane_state) if (!plane_state)
return -ENOMEM; return -ENOMEM;
plane_state->plane = plane;
plane_state->crtc = NULL; plane_state->crtc = NULL;
drm_atomic_set_fb_for_plane(plane_state, NULL); drm_atomic_set_fb_for_plane(plane_state, NULL);
......
...@@ -113,6 +113,7 @@ static void mdp5_plane_reset(struct drm_plane *plane) ...@@ -113,6 +113,7 @@ static void mdp5_plane_reset(struct drm_plane *plane)
} else { } else {
mdp5_state->zpos = 1 + drm_plane_index(plane); mdp5_state->zpos = 1 + drm_plane_index(plane);
} }
mdp5_state->base.plane = plane;
plane->state = &mdp5_state->base; plane->state = &mdp5_state->base;
} }
......
...@@ -46,8 +46,8 @@ drm_atomic_get_connector_state(struct drm_atomic_state *state, ...@@ -46,8 +46,8 @@ drm_atomic_get_connector_state(struct drm_atomic_state *state,
struct drm_connector *connector); struct drm_connector *connector);
int __must_check int __must_check
drm_atomic_set_crtc_for_plane(struct drm_atomic_state *state, drm_atomic_set_crtc_for_plane(struct drm_plane_state *plane_state,
struct drm_plane *plane, struct drm_crtc *crtc); struct drm_crtc *crtc);
void drm_atomic_set_fb_for_plane(struct drm_plane_state *plane_state, void drm_atomic_set_fb_for_plane(struct drm_plane_state *plane_state,
struct drm_framebuffer *fb); struct drm_framebuffer *fb);
int __must_check int __must_check
......
...@@ -237,6 +237,7 @@ struct drm_atomic_state; ...@@ -237,6 +237,7 @@ struct drm_atomic_state;
/** /**
* struct drm_crtc_state - mutable CRTC state * struct drm_crtc_state - mutable CRTC state
* @crtc: backpointer to the CRTC
* @enable: whether the CRTC should be enabled, gates all other state * @enable: whether the CRTC should be enabled, gates all other state
* @active: whether the CRTC is actively displaying (used for DPMS) * @active: whether the CRTC is actively displaying (used for DPMS)
* @mode_changed: for use by helpers and drivers when computing state updates * @mode_changed: for use by helpers and drivers when computing state updates
...@@ -257,6 +258,8 @@ struct drm_atomic_state; ...@@ -257,6 +258,8 @@ struct drm_atomic_state;
* assignment, @active controls the actual hardware state. * assignment, @active controls the actual hardware state.
*/ */
struct drm_crtc_state { struct drm_crtc_state {
struct drm_crtc *crtc;
bool enable; bool enable;
bool active; bool active;
...@@ -457,11 +460,14 @@ struct drm_crtc { ...@@ -457,11 +460,14 @@ struct drm_crtc {
/** /**
* struct drm_connector_state - mutable connector state * struct drm_connector_state - mutable connector state
* @connector: backpointer to the connector
* @crtc: CRTC to connect connector to, NULL if disabled * @crtc: CRTC to connect connector to, NULL if disabled
* @best_encoder: can be used by helpers and drivers to select the encoder * @best_encoder: can be used by helpers and drivers to select the encoder
* @state: backpointer to global drm_atomic_state * @state: backpointer to global drm_atomic_state
*/ */
struct drm_connector_state { struct drm_connector_state {
struct drm_connector *connector;
struct drm_crtc *crtc; /* do not write directly, use drm_atomic_set_crtc_for_connector() */ struct drm_crtc *crtc; /* do not write directly, use drm_atomic_set_crtc_for_connector() */
struct drm_encoder *best_encoder; struct drm_encoder *best_encoder;
...@@ -701,6 +707,7 @@ struct drm_connector { ...@@ -701,6 +707,7 @@ struct drm_connector {
/** /**
* struct drm_plane_state - mutable plane state * struct drm_plane_state - mutable plane state
* @plane: backpointer to the plane
* @crtc: currently bound CRTC, NULL if disabled * @crtc: currently bound CRTC, NULL if disabled
* @fb: currently bound framebuffer * @fb: currently bound framebuffer
* @fence: optional fence to wait for before scanning out @fb * @fence: optional fence to wait for before scanning out @fb
...@@ -717,6 +724,8 @@ struct drm_connector { ...@@ -717,6 +724,8 @@ struct drm_connector {
* @state: backpointer to global drm_atomic_state * @state: backpointer to global drm_atomic_state
*/ */
struct drm_plane_state { struct drm_plane_state {
struct drm_plane *plane;
struct drm_crtc *crtc; /* do not write directly, use drm_atomic_set_crtc_for_plane() */ struct drm_crtc *crtc; /* do not write directly, use drm_atomic_set_crtc_for_plane() */
struct drm_framebuffer *fb; /* do not write directly, use drm_atomic_set_fb_for_plane() */ struct drm_framebuffer *fb; /* do not write directly, use drm_atomic_set_fb_for_plane() */
struct fence *fence; struct fence *fence;
......
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