Commit 4e0b83a5 authored by Ville Syrjälä's avatar Ville Syrjälä

drm/i915: Extract per-platform plane->check() functions

Split up intel_check_primary_plane() and intel_check_sprite_plane()
into per-platform variants. This way we can get a unified behaviour
between the SKL universal planes, and we stop checking for non-SKL
specific scaling limits for the "sprite" planes. And we now get
a natural place where to add more plarform specific checks.

v2: Split the .check_plane() calling convention change out (José)
Reviewed-by: default avatarJosé Roberto de Souza <jose.souza@intel.com>
Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180907152413.15761-10-ville.syrjala@linux.intel.com
parent fd6e3c6c
...@@ -3355,6 +3355,36 @@ int i9xx_check_plane_surface(struct intel_plane_state *plane_state) ...@@ -3355,6 +3355,36 @@ int i9xx_check_plane_surface(struct intel_plane_state *plane_state)
return 0; return 0;
} }
static int
i9xx_plane_check(struct intel_crtc_state *crtc_state,
struct intel_plane_state *plane_state)
{
int ret;
ret = drm_atomic_helper_check_plane_state(&plane_state->base,
&crtc_state->base,
DRM_PLANE_HELPER_NO_SCALING,
DRM_PLANE_HELPER_NO_SCALING,
false, true);
if (ret)
return ret;
if (!plane_state->base.visible)
return 0;
ret = intel_plane_check_src_coordinates(plane_state);
if (ret)
return ret;
ret = i9xx_check_plane_surface(plane_state);
if (ret)
return ret;
plane_state->ctl = i9xx_plane_ctl(crtc_state, plane_state);
return 0;
}
static void i9xx_update_plane(struct intel_plane *plane, static void i9xx_update_plane(struct intel_plane *plane,
const struct intel_crtc_state *crtc_state, const struct intel_crtc_state *crtc_state,
const struct intel_plane_state *plane_state) const struct intel_plane_state *plane_state)
...@@ -9691,6 +9721,11 @@ static int intel_check_cursor(struct intel_crtc_state *crtc_state, ...@@ -9691,6 +9721,11 @@ static int intel_check_cursor(struct intel_crtc_state *crtc_state,
u32 offset; u32 offset;
int ret; int ret;
if (fb && fb->modifier != DRM_FORMAT_MOD_LINEAR) {
DRM_DEBUG_KMS("cursor cannot be tiled\n");
return -EINVAL;
}
ret = drm_atomic_helper_check_plane_state(&plane_state->base, ret = drm_atomic_helper_check_plane_state(&plane_state->base,
&crtc_state->base, &crtc_state->base,
DRM_PLANE_HELPER_NO_SCALING, DRM_PLANE_HELPER_NO_SCALING,
...@@ -9699,13 +9734,12 @@ static int intel_check_cursor(struct intel_crtc_state *crtc_state, ...@@ -9699,13 +9734,12 @@ static int intel_check_cursor(struct intel_crtc_state *crtc_state,
if (ret) if (ret)
return ret; return ret;
if (!fb) if (!plane_state->base.visible)
return 0; return 0;
if (fb->modifier != DRM_FORMAT_MOD_LINEAR) { ret = intel_plane_check_src_coordinates(plane_state);
DRM_DEBUG_KMS("cursor cannot be tiled\n"); if (ret)
return -EINVAL; return ret;
}
intel_fill_fb_ggtt_view(&plane_state->view, fb, rotation); intel_fill_fb_ggtt_view(&plane_state->view, fb, rotation);
plane_state->color_plane[0].stride = intel_fb_pitch(fb, 0, rotation); plane_state->color_plane[0].stride = intel_fb_pitch(fb, 0, rotation);
...@@ -13230,19 +13264,17 @@ intel_cleanup_plane_fb(struct drm_plane *plane, ...@@ -13230,19 +13264,17 @@ intel_cleanup_plane_fb(struct drm_plane *plane,
} }
int int
skl_max_scale(struct intel_crtc *intel_crtc, skl_max_scale(const struct intel_crtc_state *crtc_state,
struct intel_crtc_state *crtc_state, u32 pixel_format)
uint32_t pixel_format)
{ {
struct drm_i915_private *dev_priv; struct intel_crtc *crtc = to_intel_crtc(crtc_state->base.crtc);
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
int max_scale, mult; int max_scale, mult;
int crtc_clock, max_dotclk, tmpclk1, tmpclk2; int crtc_clock, max_dotclk, tmpclk1, tmpclk2;
if (!intel_crtc || !crtc_state->base.enable) if (!crtc_state->base.enable)
return DRM_PLANE_HELPER_NO_SCALING; return DRM_PLANE_HELPER_NO_SCALING;
dev_priv = to_i915(intel_crtc->base.dev);
crtc_clock = crtc_state->base.adjusted_mode.crtc_clock; crtc_clock = crtc_state->base.adjusted_mode.crtc_clock;
max_dotclk = to_intel_atomic_state(crtc_state->base.state)->cdclk.logical.cdclk; max_dotclk = to_intel_atomic_state(crtc_state->base.state)->cdclk.logical.cdclk;
...@@ -13266,61 +13298,6 @@ skl_max_scale(struct intel_crtc *intel_crtc, ...@@ -13266,61 +13298,6 @@ skl_max_scale(struct intel_crtc *intel_crtc,
return max_scale; return max_scale;
} }
static int
intel_check_primary_plane(struct intel_crtc_state *crtc_state,
struct intel_plane_state *state)
{
struct intel_plane *plane = to_intel_plane(state->base.plane);
struct drm_i915_private *dev_priv = to_i915(plane->base.dev);
struct drm_crtc *crtc = state->base.crtc;
int min_scale = DRM_PLANE_HELPER_NO_SCALING;
int max_scale = DRM_PLANE_HELPER_NO_SCALING;
bool can_position = false;
int ret;
uint32_t pixel_format = 0;
if (INTEL_GEN(dev_priv) >= 9) {
/* use scaler when colorkey is not required */
if (!state->ckey.flags) {
min_scale = 1;
if (state->base.fb)
pixel_format = state->base.fb->format->format;
max_scale = skl_max_scale(to_intel_crtc(crtc),
crtc_state, pixel_format);
}
can_position = true;
}
ret = drm_atomic_helper_check_plane_state(&state->base,
&crtc_state->base,
min_scale, max_scale,
can_position, true);
if (ret)
return ret;
if (!state->base.fb)
return 0;
if (INTEL_GEN(dev_priv) >= 9) {
ret = skl_check_plane_surface(crtc_state, state);
if (ret)
return ret;
state->ctl = skl_plane_ctl(crtc_state, state);
} else {
ret = i9xx_check_plane_surface(state);
if (ret)
return ret;
state->ctl = i9xx_plane_ctl(crtc_state, state);
}
if (INTEL_GEN(dev_priv) >= 10 || IS_GEMINILAKE(dev_priv))
state->color_ctl = glk_plane_color_ctl(crtc_state, state);
return 0;
}
static void intel_begin_crtc_commit(struct drm_crtc *crtc, static void intel_begin_crtc_commit(struct drm_crtc *crtc,
struct drm_crtc_state *old_crtc_state) struct drm_crtc_state *old_crtc_state)
{ {
...@@ -13770,8 +13747,6 @@ intel_primary_plane_create(struct drm_i915_private *dev_priv, enum pipe pipe) ...@@ -13770,8 +13747,6 @@ intel_primary_plane_create(struct drm_i915_private *dev_priv, enum pipe pipe)
fbc->possible_framebuffer_bits |= primary->frontbuffer_bit; fbc->possible_framebuffer_bits |= primary->frontbuffer_bit;
} }
primary->check_plane = intel_check_primary_plane;
if (INTEL_GEN(dev_priv) >= 9) { if (INTEL_GEN(dev_priv) >= 9) {
primary->has_ccs = skl_plane_has_ccs(dev_priv, pipe, primary->has_ccs = skl_plane_has_ccs(dev_priv, pipe,
PLANE_PRIMARY); PLANE_PRIMARY);
...@@ -13793,6 +13768,7 @@ intel_primary_plane_create(struct drm_i915_private *dev_priv, enum pipe pipe) ...@@ -13793,6 +13768,7 @@ intel_primary_plane_create(struct drm_i915_private *dev_priv, enum pipe pipe)
primary->update_plane = skl_update_plane; primary->update_plane = skl_update_plane;
primary->disable_plane = skl_disable_plane; primary->disable_plane = skl_disable_plane;
primary->get_hw_state = skl_plane_get_hw_state; primary->get_hw_state = skl_plane_get_hw_state;
primary->check_plane = skl_plane_check;
plane_funcs = &skl_plane_funcs; plane_funcs = &skl_plane_funcs;
} else if (INTEL_GEN(dev_priv) >= 4) { } else if (INTEL_GEN(dev_priv) >= 4) {
...@@ -13804,6 +13780,7 @@ intel_primary_plane_create(struct drm_i915_private *dev_priv, enum pipe pipe) ...@@ -13804,6 +13780,7 @@ intel_primary_plane_create(struct drm_i915_private *dev_priv, enum pipe pipe)
primary->update_plane = i9xx_update_plane; primary->update_plane = i9xx_update_plane;
primary->disable_plane = i9xx_disable_plane; primary->disable_plane = i9xx_disable_plane;
primary->get_hw_state = i9xx_plane_get_hw_state; primary->get_hw_state = i9xx_plane_get_hw_state;
primary->check_plane = i9xx_plane_check;
plane_funcs = &i965_plane_funcs; plane_funcs = &i965_plane_funcs;
} else { } else {
...@@ -13815,6 +13792,7 @@ intel_primary_plane_create(struct drm_i915_private *dev_priv, enum pipe pipe) ...@@ -13815,6 +13792,7 @@ intel_primary_plane_create(struct drm_i915_private *dev_priv, enum pipe pipe)
primary->update_plane = i9xx_update_plane; primary->update_plane = i9xx_update_plane;
primary->disable_plane = i9xx_disable_plane; primary->disable_plane = i9xx_disable_plane;
primary->get_hw_state = i9xx_plane_get_hw_state; primary->get_hw_state = i9xx_plane_get_hw_state;
primary->check_plane = i9xx_plane_check;
plane_funcs = &i8xx_plane_funcs; plane_funcs = &i8xx_plane_funcs;
} }
......
...@@ -1645,8 +1645,8 @@ void intel_crtc_arm_fifo_underrun(struct intel_crtc *crtc, ...@@ -1645,8 +1645,8 @@ void intel_crtc_arm_fifo_underrun(struct intel_crtc *crtc,
u16 skl_scaler_calc_phase(int sub, bool chroma_center); u16 skl_scaler_calc_phase(int sub, bool chroma_center);
int skl_update_scaler_crtc(struct intel_crtc_state *crtc_state); int skl_update_scaler_crtc(struct intel_crtc_state *crtc_state);
int skl_max_scale(struct intel_crtc *crtc, struct intel_crtc_state *crtc_state, int skl_max_scale(const struct intel_crtc_state *crtc_state,
uint32_t pixel_format); u32 pixel_format);
static inline u32 intel_plane_ggtt_offset(const struct intel_plane_state *state) static inline u32 intel_plane_ggtt_offset(const struct intel_plane_state *state)
{ {
...@@ -2137,7 +2137,9 @@ bool skl_plane_has_planar(struct drm_i915_private *dev_priv, ...@@ -2137,7 +2137,9 @@ bool skl_plane_has_planar(struct drm_i915_private *dev_priv,
unsigned int skl_plane_max_stride(struct intel_plane *plane, unsigned int skl_plane_max_stride(struct intel_plane *plane,
u32 pixel_format, u64 modifier, u32 pixel_format, u64 modifier,
unsigned int rotation); unsigned int rotation);
int skl_plane_check(struct intel_crtc_state *crtc_state,
struct intel_plane_state *plane_state);
int intel_plane_check_src_coordinates(struct intel_plane_state *plane_state);
/* intel_tv.c */ /* intel_tv.c */
void intel_tv_init(struct drm_i915_private *dev_priv); void intel_tv_init(struct drm_i915_private *dev_priv);
......
This diff is collapsed.
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