We might be willing to call intel_atomic_get_old_global_obj_state and intel_atomic_get_new_global_obj_state right away, however those are not initializing global obj state as intel_atomic_get_global_obj_state does. Extracted initializing part to separate function and now using this also in intel_atomic_get_old_global_obj_state and intel_atomic_get_new_global_obj_state Signed-off-by: Stanislav Lisovskiy <stanislav.lisovskiy@xxxxxxxxx> --- drivers/gpu/drm/i915/display/intel_bw.c | 28 ++++++++++++++++- drivers/gpu/drm/i915/display/intel_bw.h | 9 ++++++ .../gpu/drm/i915/display/intel_global_state.c | 30 +++++++++++++------ 3 files changed, 57 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_bw.c b/drivers/gpu/drm/i915/display/intel_bw.c index 26fa94329eda..c0168dfe8884 100644 --- a/drivers/gpu/drm/i915/display/intel_bw.c +++ b/drivers/gpu/drm/i915/display/intel_bw.c @@ -373,7 +373,33 @@ static unsigned int intel_bw_data_rate(struct drm_i915_private *dev_priv, return data_rate; } -static struct intel_bw_state * +struct intel_bw_state * +intel_atomic_get_old_bw_state(struct intel_atomic_state *state) +{ + struct drm_i915_private *dev_priv = to_i915(state->base.dev); + struct intel_global_state *bw_state; + + bw_state = intel_atomic_get_global_obj_state(state, &dev_priv->bw_obj); + if (IS_ERR(bw_state)) + return ERR_CAST(bw_state); + + return to_intel_bw_state(bw_state); +} + +struct intel_bw_state * +intel_atomic_get_new_bw_state(struct intel_atomic_state *state) +{ + struct drm_i915_private *dev_priv = to_i915(state->base.dev); + struct intel_global_state *bw_state; + bw_state = intel_atomic_get_new_global_obj_state(state, &dev_priv->bw_obj); + + if (IS_ERR(bw_state)) + return ERR_CAST(bw_state); + + return to_intel_bw_state(bw_state); +} + +struct intel_bw_state * intel_atomic_get_bw_state(struct intel_atomic_state *state) { struct drm_i915_private *dev_priv = to_i915(state->base.dev); diff --git a/drivers/gpu/drm/i915/display/intel_bw.h b/drivers/gpu/drm/i915/display/intel_bw.h index a8aa7624c5aa..ac004d6f4276 100644 --- a/drivers/gpu/drm/i915/display/intel_bw.h +++ b/drivers/gpu/drm/i915/display/intel_bw.h @@ -24,6 +24,15 @@ struct intel_bw_state { #define to_intel_bw_state(x) container_of((x), struct intel_bw_state, base) +struct intel_bw_state * +intel_atomic_get_old_bw_state(struct intel_atomic_state *state); + +struct intel_bw_state * +intel_atomic_get_new_bw_state(struct intel_atomic_state *state); + +struct intel_bw_state * +intel_atomic_get_bw_state(struct intel_atomic_state *state); + void intel_bw_init_hw(struct drm_i915_private *dev_priv); int intel_bw_init(struct drm_i915_private *dev_priv); int intel_bw_atomic_check(struct intel_atomic_state *state); diff --git a/drivers/gpu/drm/i915/display/intel_global_state.c b/drivers/gpu/drm/i915/display/intel_global_state.c index a0cc894c3868..89e85048329f 100644 --- a/drivers/gpu/drm/i915/display/intel_global_state.c +++ b/drivers/gpu/drm/i915/display/intel_global_state.c @@ -67,19 +67,15 @@ static void assert_global_state_read_locked(struct intel_atomic_state *state) WARN(1, "Global state not read locked\n"); } -struct intel_global_state * -intel_atomic_get_global_obj_state(struct intel_atomic_state *state, +static struct intel_global_state * +_intel_atomic_init_global_obj_state(struct intel_atomic_state *state, struct intel_global_obj *obj) { - int index, num_objs, i; + int index, num_objs; size_t size; struct __intel_global_objs_state *arr; struct intel_global_state *obj_state; - for (i = 0; i < state->num_global_objs; i++) - if (obj == state->global_objs[i].ptr) - return state->global_objs[i].state; - assert_global_state_read_locked(state); num_objs = state->num_global_objs + 1; @@ -112,6 +108,20 @@ intel_atomic_get_global_obj_state(struct intel_atomic_state *state, return obj_state; } + +struct intel_global_state * +intel_atomic_get_global_obj_state(struct intel_atomic_state *state, + struct intel_global_obj *obj) +{ + int i; + + for (i = 0; i < state->num_global_objs; i++) + if (obj == state->global_objs[i].ptr) + return state->global_objs[i].state; + + return _intel_atomic_init_global_obj_state(state, obj); +} + struct intel_global_state * intel_atomic_get_old_global_obj_state(struct intel_atomic_state *state, struct intel_global_obj *obj) @@ -122,7 +132,9 @@ intel_atomic_get_old_global_obj_state(struct intel_atomic_state *state, if (obj == state->global_objs[i].ptr) return state->global_objs[i].old_state; - return NULL; + _intel_atomic_init_global_obj_state(state, obj); + + return obj->state; } struct intel_global_state * @@ -135,7 +147,7 @@ intel_atomic_get_new_global_obj_state(struct intel_atomic_state *state, if (obj == state->global_objs[i].ptr) return state->global_objs[i].new_state; - return NULL; + return _intel_atomic_init_global_obj_state(state, obj); } void intel_atomic_swap_global_state(struct intel_atomic_state *state) -- 2.24.1.485.gad05a3d8e5 _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/intel-gfx