drm/atomic: add drm_atomic_get_existing_*_state helpers
Subsystems (2)
Maarten Lankhorst
maintainerPATCH 1/1 drm/atomic: add drm_atomic_get_existing_*_state helpers
There are cases where we want to test if a given object is part of the state, but don't want to add them if they're not.
Signed-off-by Maarten Lankhorst <[email protected]>
--- drivers/gpu/drm/drm_atomic.c | 18 +++++++--------- include/drm/drm_atomic.h | 50 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 10 deletions(-)
drivers/gpu/drm/drm_atomic.c +8 -10
@@ -263,13 +263,12 @@ struct drm_crtc_state * drm_atomic_get_crtc_state(struct drm_atomic_state *state, struct drm_crtc *crtc) { - int ret, index; + int ret, index = drm_crtc_index(crtc);struct drm_crtc_state *crtc_state; - index =drm_crtc_index (crtc); - -if (state->crtc_states[index]) -return state->crtc_states[index]; + crtc_state =drm_atomic_get_existing_crtc_state (state, crtc); +if (crtc_state) +return crtc_state; ret =drm_modeset_lock (&crtc->mutex, state->acquire_ctx);if (ret)
@@ -397,13 +396,12 @@ struct drm_plane_state * drm_atomic_get_plane_state(struct drm_atomic_state *state, struct drm_plane *plane) { - int ret, index; + int ret, index = drm_plane_index(plane);struct drm_plane_state *plane_state; - index =drm_plane_index (plane); - -if (state->plane_states[index]) -return state->plane_states[index]; + plane_state =drm_atomic_get_existing_plane_state (state, plane); +if (plane_state) +return plane_state; ret =drm_modeset_lock (&plane->mutex, state->acquire_ctx);if (ret)
include/drm/drm_atomic.h +50 -0
56 lines not on this page · raw message
Signature · 6 lines
2.1.0 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 4 lines · Maarten Lankhorst
There are cases where we want to test if a given object is part of the state, but don't want to add them if they're not.
Signed-off-by Maarten Lankhorst <[email protected]>
Yeah makes sense to wrap these. Applied to topic/drm-misc, thanks. -Daniel
Quoted 113 lines
--- drivers/gpu/drm/drm_atomic.c | 18 +++++++--------- include/drm/drm_atomic.h | 50 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 10 deletions(-)drivers/gpu/drm/drm_atomic.c +8
-10@@ -263,13 +263,12 @@ struct drm_crtc_state * drm_atomic_get_crtc_state(struct drm_atomic_state *state, struct drm_crtc *crtc) { - int ret, index; + int ret, index = drm_crtc_index(crtc);struct drm_crtc_state *crtc_state; - index =drm_crtc_index (crtc); - -if (state->crtc_states[index]) -return state->crtc_states[index]; + crtc_state =drm_atomic_get_existing_crtc_state (state, crtc); +if (crtc_state) +return crtc_state; ret =drm_modeset_lock (&crtc->mutex, state->acquire_ctx);if (ret)@@ -397,13 +396,12 @@ struct drm_plane_state * drm_atomic_get_plane_state(struct drm_atomic_state *state, struct drm_plane *plane) { - int ret, index; + int ret, index = drm_plane_index(plane);struct drm_plane_state *plane_state; - index =drm_plane_index (plane); - -if (state->plane_states[index]) -return state->plane_states[index]; + plane_state =drm_atomic_get_existing_plane_state (state, plane); +if (plane_state) +return plane_state; ret =drm_modeset_lock (&plane->mutex, state->acquire_ctx);if (ret)include/drm/drm_atomic.h +50
-0@@ -59,6 +59,56 @@ int drm_atomic_connector_set_property(struct drm_connector *connector, struct drm_connector_state *state, struct drm_property *property, uint64_t val); +/** +* drm_atomic_get_existing_crtc_state - get crtc state, if it exists +* @state: global atomic state object +* @crtc: crtc to grab +* +* This function returns the crtc state for the given crtc, or NULL +* if the crtc is not part of the global atomic state. +*/ +static inline struct drm_crtc_state * +drm_atomic_get_existing_crtc_state (struct drm_atomic_state *state, +struct drm_crtc *crtc) +{ +return state->crtc_states[drm_crtc_index (crtc)]; +} + +/** +* drm_atomic_get_existing_plane_state - get plane state, if it exists +* @state: global atomic state object +* @plane: plane to grab +* +* This function returns the plane state for the given plane, or NULL +* if the plane is not part of the global atomic state. +*/ +static inline struct drm_plane_state * +drm_atomic_get_existing_plane_state (struct drm_atomic_state *state, +struct drm_plane *plane) +{ +return state->plane_states[drm_plane_index (plane)]; +} + +/** +* drm_atomic_get_existing_connector_state - get connector state, if it exists +* @state: global atomic state object +* @connector: connector to grab +* +* This function returns the connector state for the given connector, +* or NULL if the connector is not part of the global atomic state. +*/ +static inline struct drm_connector_state * +drm_atomic_get_existing_connector_state (struct drm_atomic_state *state, +struct drm_connector *connector) +{ +int index =drm_connector_index (connector); + +if (index >= state->num_connector) +return NULL ; + +return state->connector_states[index]; +} +int __must_check drm_atomic_set_crtc_for_plane (struct drm_plane_state *plane_state,struct drm_crtc *crtc);Signature · 6 lines
2.1.0 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx