clip.x2 = crtc_state->adjusted_mode.hdisplay;
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,
false, true);
clip.x2 = crtc_state->adjusted_mode.hdisplay;
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)
return ret;
/**
* 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
* @min_scale: minimum @src:@dest scaling factor in 16.16 fixed point
* @max_scale: maximum @src:@dest scaling factor in 16.16 fixed point
* RETURNS:
* 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,
int min_scale,
int max_scale,
bool can_position,
bool can_update_disabled)
{
- struct drm_crtc *crtc = state->crtc;
- struct drm_framebuffer *fb = state->fb;
- struct drm_rect *src = &state->src;
- struct drm_rect *dst = &state->dst;
- unsigned int rotation = state->rotation;
+ struct drm_framebuffer *fb = plane_state->fb;
+ struct drm_rect *src = &plane_state->src;
+ struct drm_rect *dst = &plane_state->dst;
+ unsigned int rotation = plane_state->rotation;
int hscale, vscale;
- *src = drm_plane_state_src(state);
- *dst = drm_plane_state_dest(state);
+ WARN_ON(plane_state->crtc && plane_state->crtc != crtc_state->crtc);
+
+ *src = drm_plane_state_src(plane_state);
+ *dst = drm_plane_state_dest(plane_state);
if (!fb) {
- state->visible = false;
+ plane_state->visible = false;
return 0;
}
/* crtc should only be NULL when disabling (i.e., !fb) */
- if (WARN_ON(!crtc)) {
- state->visible = false;
+ if (WARN_ON(!plane_state->crtc)) {
+ plane_state->visible = false;
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");
return -EINVAL;
}
vscale = drm_rect_calc_vscale(src, dst, min_scale, max_scale);
if (hscale < 0 || vscale < 0) {
DRM_DEBUG_KMS("Invalid scaling of plane\n");
- drm_rect_debug_print("src: ", &state->src, true);
- drm_rect_debug_print("dst: ", &state->dst, false);
+ drm_rect_debug_print("src: ", &plane_state->src, true);
+ drm_rect_debug_print("dst: ", &plane_state->dst, false);
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);
- if (!state->visible)
+ if (!plane_state->visible)
/*
* Plane isn't visible; some drivers can handle this
* so we just return success here. Drivers that can't
bool can_update_disabled,
bool *visible)
{
- struct drm_plane_state state = {
+ struct drm_plane_state plane_state = {
.plane = plane,
.crtc = crtc,
.fb = fb,
.rotation = rotation,
.visible = *visible,
};
+ struct drm_crtc_state crtc_state = {
+ .crtc = crtc,
+ .enable = crtc->enabled,
+ };
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,
can_position,
can_update_disabled);
if (ret)
return ret;
- *src = state.src;
- *dst = state.dst;
- *visible = state.visible;
+ *src = plane_state.src;
+ *dst = plane_state.dst;
+ *visible = plane_state.visible;
return 0;
}
clip.x2 = crtc_state->adjusted_mode.hdisplay;
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,
false, true);
int ret;
ret = drm_plane_helper_check_state(&plane_state->base,
+ &crtc_state->base,
&plane_state->clip,
DRM_PLANE_HELPER_NO_SCALING,
DRM_PLANE_HELPER_NO_SCALING,
}
ret = drm_plane_helper_check_state(&state->base,
+ &crtc_state->base,
&state->clip,
min_scale, max_scale,
can_position, true);
clip.y1 = 0;
clip.x2 = crtc_state->adjusted_mode.hdisplay;
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,
can_position, true);
clip.x2 = crtc_state->mode.hdisplay;
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,
true, true);
clip.x2 = crtc_state->mode.hdisplay;
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,
true, true);
min_scale = FRAC_16_16(1, 8);
max_scale = FRAC_16_16(8, 1);
- ret = drm_plane_helper_check_state(state, &clip, min_scale,
- max_scale, true, true);
+ ret = drm_plane_helper_check_state(state, crtc_state, &clip,
+ min_scale, max_scale, true, true);
if (ret)
return 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,
true, true);
if (!fb->format->depth)
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,
false, true);
clip.x2 = crtc_state->adjusted_mode.hdisplay;
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,
true, true);
if (ret)
clip.y2 = crtc_state->mode.vdisplay;
/* Check plane state for visibility and calculate clipping bounds */
- err = drm_plane_helper_check_state(state, &clip, 0, INT_MAX,
- true, true);
+ err = drm_plane_helper_check_state(state, crtc_state, &clip,
+ 0, INT_MAX, true, true);
if (err < 0)
return err;
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,
false, true);
clip.x2 = crtc_state->adjusted_mode.hdisplay;
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,
true, true);
}
clip.x2 = crtc_state->adjusted_mode.hdisplay;
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,
false, true);
*/
#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,
int min_scale, int max_scale,
bool can_position,