Commit 04d4e167 authored by Ville Syrjälä's avatar Ville Syrjälä

drm/i915: Extract skl_allocate_plane_ddb()

Replace some copy-pasta with a function.
Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220118092354.11631-6-ville.syrjala@linux.intel.comReviewed-by: default avatarStanislav Lisovskiy <stanislav.lisovskiy@intel.com>
parent 63b81e60
...@@ -5109,9 +5109,24 @@ struct skl_plane_ddb_iter { ...@@ -5109,9 +5109,24 @@ struct skl_plane_ddb_iter {
u16 start, size; u16 start, size;
}; };
static u16
skl_allocate_plane_ddb(struct skl_plane_ddb_iter *iter,
const struct skl_wm_level *wm,
u64 data_rate)
{
u16 extra;
extra = min_t(u16, iter->size,
DIV64_U64_ROUND_UP(iter->size * data_rate, iter->data_rate));
iter->size -= extra;
iter->data_rate -= data_rate;
return wm->min_ddb_alloc + extra;
}
static int static int
skl_allocate_plane_ddb(struct intel_atomic_state *state, skl_crtc_allocate_plane_ddb(struct intel_atomic_state *state,
struct intel_crtc *crtc) struct intel_crtc *crtc)
{ {
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev); struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
struct intel_crtc_state *crtc_state = struct intel_crtc_state *crtc_state =
...@@ -5196,8 +5211,6 @@ skl_allocate_plane_ddb(struct intel_atomic_state *state, ...@@ -5196,8 +5211,6 @@ skl_allocate_plane_ddb(struct intel_atomic_state *state,
for_each_plane_id_on_crtc(crtc, plane_id) { for_each_plane_id_on_crtc(crtc, plane_id) {
const struct skl_plane_wm *wm = const struct skl_plane_wm *wm =
&crtc_state->wm.skl.optimal.planes[plane_id]; &crtc_state->wm.skl.optimal.planes[plane_id];
u64 data_rate;
u16 extra;
if (plane_id == PLANE_CURSOR) if (plane_id == PLANE_CURSOR)
continue; continue;
...@@ -5209,22 +5222,16 @@ skl_allocate_plane_ddb(struct intel_atomic_state *state, ...@@ -5209,22 +5222,16 @@ skl_allocate_plane_ddb(struct intel_atomic_state *state,
if (iter.data_rate == 0) if (iter.data_rate == 0)
break; break;
data_rate = crtc_state->plane_data_rate[plane_id]; iter.total[plane_id] =
extra = min_t(u16, iter.size, skl_allocate_plane_ddb(&iter, &wm->wm[level],
DIV64_U64_ROUND_UP(iter.size * data_rate, iter.data_rate)); crtc_state->plane_data_rate[plane_id]);
iter.total[plane_id] = wm->wm[level].min_ddb_alloc + extra;
iter.size -= extra;
iter.data_rate -= data_rate;
if (iter.data_rate == 0) if (iter.data_rate == 0)
break; break;
data_rate = crtc_state->uv_plane_data_rate[plane_id]; iter.uv_total[plane_id] =
extra = min_t(u16, iter.size, skl_allocate_plane_ddb(&iter, &wm->uv_wm[level],
DIV64_U64_ROUND_UP(iter.size * data_rate, iter.data_rate)); crtc_state->uv_plane_data_rate[plane_id]);
iter.uv_total[plane_id] = wm->uv_wm[level].min_ddb_alloc + extra;
iter.size -= extra;
iter.data_rate -= data_rate;
} }
drm_WARN_ON(&dev_priv->drm, iter.size != 0 || iter.data_rate != 0); drm_WARN_ON(&dev_priv->drm, iter.size != 0 || iter.data_rate != 0);
...@@ -6177,7 +6184,7 @@ skl_compute_ddb(struct intel_atomic_state *state) ...@@ -6177,7 +6184,7 @@ skl_compute_ddb(struct intel_atomic_state *state)
for_each_oldnew_intel_crtc_in_state(state, crtc, old_crtc_state, for_each_oldnew_intel_crtc_in_state(state, crtc, old_crtc_state,
new_crtc_state, i) { new_crtc_state, i) {
ret = skl_allocate_plane_ddb(state, crtc); ret = skl_crtc_allocate_plane_ddb(state, crtc);
if (ret) if (ret)
return ret; return ret;
......
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