Commit 10b47ee0 authored by Ville Syrjälä's avatar Ville Syrjälä

drm: Check crtc_state->enable rather than crtc->enabled in drm_plane_helper_check_state()

drm_plane_helper_check_state() is supposed to do things the atomic way,
so it should not be inspecting crtc->enabled. Rather we should be
looking at crtc_state->enable.

We have a slight complication due to drm_plane_helper_check_update()
reusing drm_plane_helper_check_state() for non-atomic drivers. Thus
we'll have to pass the crtc_state in manally and construct a fake
crtc_state in drm_plane_helper_check_update().

v2: Fix the WARNs about plane_state->crtc matching crtc_state->crtc
Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20171101201558.6059-1-ville.syrjala@linux.intel.comReviewed-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent 58a275aa
...@@ -252,7 +252,7 @@ static int hdlcd_plane_atomic_check(struct drm_plane *plane, ...@@ -252,7 +252,7 @@ static int hdlcd_plane_atomic_check(struct drm_plane *plane,
clip.x2 = crtc_state->adjusted_mode.hdisplay; clip.x2 = crtc_state->adjusted_mode.hdisplay;
clip.y2 = crtc_state->adjusted_mode.vdisplay; clip.y2 = crtc_state->adjusted_mode.vdisplay;
return drm_plane_helper_check_state(state, &clip, return drm_plane_helper_check_state(state, crtc_state, &clip,
DRM_PLANE_HELPER_NO_SCALING, DRM_PLANE_HELPER_NO_SCALING,
DRM_PLANE_HELPER_NO_SCALING, DRM_PLANE_HELPER_NO_SCALING,
false, true); false, true);
......
...@@ -150,7 +150,8 @@ static int malidp_se_check_scaling(struct malidp_plane *mp, ...@@ -150,7 +150,8 @@ static int malidp_se_check_scaling(struct malidp_plane *mp,
clip.x2 = crtc_state->adjusted_mode.hdisplay; clip.x2 = crtc_state->adjusted_mode.hdisplay;
clip.y2 = crtc_state->adjusted_mode.vdisplay; clip.y2 = crtc_state->adjusted_mode.vdisplay;
ret = drm_plane_helper_check_state(state, &clip, 0, INT_MAX, true, true); ret = drm_plane_helper_check_state(state, crtc_state, &clip,
0, INT_MAX, true, true);
if (ret) if (ret)
return ret; return ret;
......
...@@ -101,7 +101,8 @@ static int get_connectors_for_crtc(struct drm_crtc *crtc, ...@@ -101,7 +101,8 @@ static int get_connectors_for_crtc(struct drm_crtc *crtc,
/** /**
* drm_plane_helper_check_state() - Check plane state for validity * drm_plane_helper_check_state() - Check plane state for validity
* @state: plane state to check * @plane_state: plane state to check
* @crtc_state: crtc state to check
* @clip: integer clipping coordinates * @clip: integer clipping coordinates
* @min_scale: minimum @src:@dest scaling factor in 16.16 fixed point * @min_scale: minimum @src:@dest scaling factor in 16.16 fixed point
* @max_scale: maximum @src:@dest scaling factor in 16.16 fixed point * @max_scale: maximum @src:@dest scaling factor in 16.16 fixed point
...@@ -120,35 +121,37 @@ static int get_connectors_for_crtc(struct drm_crtc *crtc, ...@@ -120,35 +121,37 @@ static int get_connectors_for_crtc(struct drm_crtc *crtc,
* RETURNS: * RETURNS:
* Zero if update appears valid, error code on failure * Zero if update appears valid, error code on failure
*/ */
int drm_plane_helper_check_state(struct drm_plane_state *state, int drm_plane_helper_check_state(struct drm_plane_state *plane_state,
const struct drm_crtc_state *crtc_state,
const struct drm_rect *clip, const struct drm_rect *clip,
int min_scale, int min_scale,
int max_scale, int max_scale,
bool can_position, bool can_position,
bool can_update_disabled) bool can_update_disabled)
{ {
struct drm_crtc *crtc = state->crtc; struct drm_framebuffer *fb = plane_state->fb;
struct drm_framebuffer *fb = state->fb; struct drm_rect *src = &plane_state->src;
struct drm_rect *src = &state->src; struct drm_rect *dst = &plane_state->dst;
struct drm_rect *dst = &state->dst; unsigned int rotation = plane_state->rotation;
unsigned int rotation = state->rotation;
int hscale, vscale; int hscale, vscale;
*src = drm_plane_state_src(state); WARN_ON(plane_state->crtc && plane_state->crtc != crtc_state->crtc);
*dst = drm_plane_state_dest(state);
*src = drm_plane_state_src(plane_state);
*dst = drm_plane_state_dest(plane_state);
if (!fb) { if (!fb) {
state->visible = false; plane_state->visible = false;
return 0; return 0;
} }
/* crtc should only be NULL when disabling (i.e., !fb) */ /* crtc should only be NULL when disabling (i.e., !fb) */
if (WARN_ON(!crtc)) { if (WARN_ON(!plane_state->crtc)) {
state->visible = false; plane_state->visible = false;
return 0; return 0;
} }
if (!crtc->enabled && !can_update_disabled) { if (!crtc_state->enable && !can_update_disabled) {
DRM_DEBUG_KMS("Cannot update plane of a disabled CRTC.\n"); DRM_DEBUG_KMS("Cannot update plane of a disabled CRTC.\n");
return -EINVAL; return -EINVAL;
} }
...@@ -160,16 +163,16 @@ int drm_plane_helper_check_state(struct drm_plane_state *state, ...@@ -160,16 +163,16 @@ int drm_plane_helper_check_state(struct drm_plane_state *state,
vscale = drm_rect_calc_vscale(src, dst, min_scale, max_scale); vscale = drm_rect_calc_vscale(src, dst, min_scale, max_scale);
if (hscale < 0 || vscale < 0) { if (hscale < 0 || vscale < 0) {
DRM_DEBUG_KMS("Invalid scaling of plane\n"); DRM_DEBUG_KMS("Invalid scaling of plane\n");
drm_rect_debug_print("src: ", &state->src, true); drm_rect_debug_print("src: ", &plane_state->src, true);
drm_rect_debug_print("dst: ", &state->dst, false); drm_rect_debug_print("dst: ", &plane_state->dst, false);
return -ERANGE; return -ERANGE;
} }
state->visible = drm_rect_clip_scaled(src, dst, clip, hscale, vscale); plane_state->visible = drm_rect_clip_scaled(src, dst, clip, hscale, vscale);
drm_rect_rotate_inv(src, fb->width << 16, fb->height << 16, rotation); drm_rect_rotate_inv(src, fb->width << 16, fb->height << 16, rotation);
if (!state->visible) if (!plane_state->visible)
/* /*
* Plane isn't visible; some drivers can handle this * Plane isn't visible; some drivers can handle this
* so we just return success here. Drivers that can't * so we just return success here. Drivers that can't
...@@ -230,7 +233,7 @@ int drm_plane_helper_check_update(struct drm_plane *plane, ...@@ -230,7 +233,7 @@ int drm_plane_helper_check_update(struct drm_plane *plane,
bool can_update_disabled, bool can_update_disabled,
bool *visible) bool *visible)
{ {
struct drm_plane_state state = { struct drm_plane_state plane_state = {
.plane = plane, .plane = plane,
.crtc = crtc, .crtc = crtc,
.fb = fb, .fb = fb,
...@@ -245,18 +248,22 @@ int drm_plane_helper_check_update(struct drm_plane *plane, ...@@ -245,18 +248,22 @@ int drm_plane_helper_check_update(struct drm_plane *plane,
.rotation = rotation, .rotation = rotation,
.visible = *visible, .visible = *visible,
}; };
struct drm_crtc_state crtc_state = {
.crtc = crtc,
.enable = crtc->enabled,
};
int ret; int ret;
ret = drm_plane_helper_check_state(&state, clip, ret = drm_plane_helper_check_state(&plane_state, &crtc_state, clip,
min_scale, max_scale, min_scale, max_scale,
can_position, can_position,
can_update_disabled); can_update_disabled);
if (ret) if (ret)
return ret; return ret;
*src = state.src; *src = plane_state.src;
*dst = state.dst; *dst = plane_state.dst;
*visible = state.visible; *visible = plane_state.visible;
return 0; return 0;
} }
......
...@@ -103,7 +103,7 @@ static int drm_simple_kms_plane_atomic_check(struct drm_plane *plane, ...@@ -103,7 +103,7 @@ static int drm_simple_kms_plane_atomic_check(struct drm_plane *plane,
clip.x2 = crtc_state->adjusted_mode.hdisplay; clip.x2 = crtc_state->adjusted_mode.hdisplay;
clip.y2 = crtc_state->adjusted_mode.vdisplay; clip.y2 = crtc_state->adjusted_mode.vdisplay;
ret = drm_plane_helper_check_state(plane_state, &clip, ret = drm_plane_helper_check_state(plane_state, crtc_state, &clip,
DRM_PLANE_HELPER_NO_SCALING, DRM_PLANE_HELPER_NO_SCALING,
DRM_PLANE_HELPER_NO_SCALING, DRM_PLANE_HELPER_NO_SCALING,
false, true); false, true);
......
...@@ -9419,6 +9419,7 @@ static int intel_check_cursor(struct intel_crtc_state *crtc_state, ...@@ -9419,6 +9419,7 @@ static int intel_check_cursor(struct intel_crtc_state *crtc_state,
int ret; int ret;
ret = drm_plane_helper_check_state(&plane_state->base, ret = drm_plane_helper_check_state(&plane_state->base,
&crtc_state->base,
&plane_state->clip, &plane_state->clip,
DRM_PLANE_HELPER_NO_SCALING, DRM_PLANE_HELPER_NO_SCALING,
DRM_PLANE_HELPER_NO_SCALING, DRM_PLANE_HELPER_NO_SCALING,
...@@ -12842,6 +12843,7 @@ intel_check_primary_plane(struct intel_plane *plane, ...@@ -12842,6 +12843,7 @@ intel_check_primary_plane(struct intel_plane *plane,
} }
ret = drm_plane_helper_check_state(&state->base, ret = drm_plane_helper_check_state(&state->base,
&crtc_state->base,
&state->clip, &state->clip,
min_scale, max_scale, min_scale, max_scale,
can_position, true); can_position, true);
......
...@@ -342,7 +342,7 @@ static int ipu_plane_atomic_check(struct drm_plane *plane, ...@@ -342,7 +342,7 @@ static int ipu_plane_atomic_check(struct drm_plane *plane,
clip.y1 = 0; clip.y1 = 0;
clip.x2 = crtc_state->adjusted_mode.hdisplay; clip.x2 = crtc_state->adjusted_mode.hdisplay;
clip.y2 = crtc_state->adjusted_mode.vdisplay; clip.y2 = crtc_state->adjusted_mode.vdisplay;
ret = drm_plane_helper_check_state(state, &clip, ret = drm_plane_helper_check_state(state, crtc_state, &clip,
DRM_PLANE_HELPER_NO_SCALING, DRM_PLANE_HELPER_NO_SCALING,
DRM_PLANE_HELPER_NO_SCALING, DRM_PLANE_HELPER_NO_SCALING,
can_position, true); can_position, true);
......
...@@ -111,7 +111,7 @@ static int mtk_plane_atomic_check(struct drm_plane *plane, ...@@ -111,7 +111,7 @@ static int mtk_plane_atomic_check(struct drm_plane *plane,
clip.x2 = crtc_state->mode.hdisplay; clip.x2 = crtc_state->mode.hdisplay;
clip.y2 = crtc_state->mode.vdisplay; clip.y2 = crtc_state->mode.vdisplay;
return drm_plane_helper_check_state(state, &clip, return drm_plane_helper_check_state(state, crtc_state, &clip,
DRM_PLANE_HELPER_NO_SCALING, DRM_PLANE_HELPER_NO_SCALING,
DRM_PLANE_HELPER_NO_SCALING, DRM_PLANE_HELPER_NO_SCALING,
true, true); true, true);
......
...@@ -61,7 +61,7 @@ static int meson_plane_atomic_check(struct drm_plane *plane, ...@@ -61,7 +61,7 @@ static int meson_plane_atomic_check(struct drm_plane *plane,
clip.x2 = crtc_state->mode.hdisplay; clip.x2 = crtc_state->mode.hdisplay;
clip.y2 = crtc_state->mode.vdisplay; clip.y2 = crtc_state->mode.vdisplay;
return drm_plane_helper_check_state(state, &clip, return drm_plane_helper_check_state(state, crtc_state, &clip,
DRM_PLANE_HELPER_NO_SCALING, DRM_PLANE_HELPER_NO_SCALING,
DRM_PLANE_HELPER_NO_SCALING, DRM_PLANE_HELPER_NO_SCALING,
true, true); true, true);
......
...@@ -348,8 +348,8 @@ static int mdp5_plane_atomic_check_with_state(struct drm_crtc_state *crtc_state, ...@@ -348,8 +348,8 @@ static int mdp5_plane_atomic_check_with_state(struct drm_crtc_state *crtc_state,
min_scale = FRAC_16_16(1, 8); min_scale = FRAC_16_16(1, 8);
max_scale = FRAC_16_16(8, 1); max_scale = FRAC_16_16(8, 1);
ret = drm_plane_helper_check_state(state, &clip, min_scale, ret = drm_plane_helper_check_state(state, crtc_state, &clip,
max_scale, true, true); min_scale, max_scale, true, true);
if (ret) if (ret)
return ret; return ret;
......
...@@ -1143,7 +1143,8 @@ nv50_curs_acquire(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw, ...@@ -1143,7 +1143,8 @@ nv50_curs_acquire(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw,
{ {
int ret; int ret;
ret = drm_plane_helper_check_state(&asyw->state, &asyw->clip, ret = drm_plane_helper_check_state(&asyw->state, &asyh->state,
&asyw->clip,
DRM_PLANE_HELPER_NO_SCALING, DRM_PLANE_HELPER_NO_SCALING,
DRM_PLANE_HELPER_NO_SCALING, DRM_PLANE_HELPER_NO_SCALING,
true, true); true, true);
...@@ -1432,7 +1433,8 @@ nv50_base_acquire(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw, ...@@ -1432,7 +1433,8 @@ nv50_base_acquire(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw,
if (!fb->format->depth) if (!fb->format->depth)
return -EINVAL; return -EINVAL;
ret = drm_plane_helper_check_state(&asyw->state, &asyw->clip, ret = drm_plane_helper_check_state(&asyw->state, &asyh->state,
&asyw->clip,
DRM_PLANE_HELPER_NO_SCALING, DRM_PLANE_HELPER_NO_SCALING,
DRM_PLANE_HELPER_NO_SCALING, DRM_PLANE_HELPER_NO_SCALING,
false, true); false, true);
......
...@@ -659,7 +659,7 @@ static int vop_plane_atomic_check(struct drm_plane *plane, ...@@ -659,7 +659,7 @@ static int vop_plane_atomic_check(struct drm_plane *plane,
clip.x2 = crtc_state->adjusted_mode.hdisplay; clip.x2 = crtc_state->adjusted_mode.hdisplay;
clip.y2 = crtc_state->adjusted_mode.vdisplay; clip.y2 = crtc_state->adjusted_mode.vdisplay;
ret = drm_plane_helper_check_state(state, &clip, ret = drm_plane_helper_check_state(state, crtc_state, &clip,
min_scale, max_scale, min_scale, max_scale,
true, true); true, true);
if (ret) if (ret)
......
...@@ -500,8 +500,8 @@ static int tegra_plane_state_add(struct tegra_plane *plane, ...@@ -500,8 +500,8 @@ static int tegra_plane_state_add(struct tegra_plane *plane,
clip.y2 = crtc_state->mode.vdisplay; clip.y2 = crtc_state->mode.vdisplay;
/* Check plane state for visibility and calculate clipping bounds */ /* Check plane state for visibility and calculate clipping bounds */
err = drm_plane_helper_check_state(state, &clip, 0, INT_MAX, err = drm_plane_helper_check_state(state, crtc_state, &clip,
true, true); 0, INT_MAX, true, true);
if (err < 0) if (err < 0)
return err; return err;
......
...@@ -454,7 +454,7 @@ int vmw_du_primary_plane_atomic_check(struct drm_plane *plane, ...@@ -454,7 +454,7 @@ int vmw_du_primary_plane_atomic_check(struct drm_plane *plane,
clip.y2 = crtc_state->adjusted_mode.vdisplay; clip.y2 = crtc_state->adjusted_mode.vdisplay;
} }
ret = drm_plane_helper_check_state(state, &clip, ret = drm_plane_helper_check_state(state, crtc_state, &clip,
DRM_PLANE_HELPER_NO_SCALING, DRM_PLANE_HELPER_NO_SCALING,
DRM_PLANE_HELPER_NO_SCALING, DRM_PLANE_HELPER_NO_SCALING,
false, true); false, true);
......
...@@ -80,7 +80,7 @@ static int zx_vl_plane_atomic_check(struct drm_plane *plane, ...@@ -80,7 +80,7 @@ static int zx_vl_plane_atomic_check(struct drm_plane *plane,
clip.x2 = crtc_state->adjusted_mode.hdisplay; clip.x2 = crtc_state->adjusted_mode.hdisplay;
clip.y2 = crtc_state->adjusted_mode.vdisplay; clip.y2 = crtc_state->adjusted_mode.vdisplay;
return drm_plane_helper_check_state(plane_state, &clip, return drm_plane_helper_check_state(plane_state, crtc_state, &clip,
min_scale, max_scale, min_scale, max_scale,
true, true); true, true);
} }
...@@ -315,7 +315,7 @@ static int zx_gl_plane_atomic_check(struct drm_plane *plane, ...@@ -315,7 +315,7 @@ static int zx_gl_plane_atomic_check(struct drm_plane *plane,
clip.x2 = crtc_state->adjusted_mode.hdisplay; clip.x2 = crtc_state->adjusted_mode.hdisplay;
clip.y2 = crtc_state->adjusted_mode.vdisplay; clip.y2 = crtc_state->adjusted_mode.vdisplay;
return drm_plane_helper_check_state(plane_state, &clip, return drm_plane_helper_check_state(plane_state, crtc_state, &clip,
DRM_PLANE_HELPER_NO_SCALING, DRM_PLANE_HELPER_NO_SCALING,
DRM_PLANE_HELPER_NO_SCALING, DRM_PLANE_HELPER_NO_SCALING,
false, true); false, true);
......
...@@ -38,7 +38,8 @@ ...@@ -38,7 +38,8 @@
*/ */
#define DRM_PLANE_HELPER_NO_SCALING (1<<16) #define DRM_PLANE_HELPER_NO_SCALING (1<<16)
int drm_plane_helper_check_state(struct drm_plane_state *state, int drm_plane_helper_check_state(struct drm_plane_state *plane_state,
const struct drm_crtc_state *crtc_state,
const struct drm_rect *clip, const struct drm_rect *clip,
int min_scale, int max_scale, int min_scale, int max_scale,
bool can_position, bool can_position,
......
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