Commit 7bfab1ec authored by Russell King's avatar Russell King

drm/armada: use drm_plane_helper_check_state()

Use drm_plane_helper_check_state() to check the overlay plane state
rather than drm_plane_helper_check_update(), as:

(1) using drm_plane_helper_check_state() provides a better migration
    path to atomic modeset
(2) it avoids needless copies of drm rectangle structures, and so is
    more efficient.
Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
parent 73c51abd
...@@ -87,17 +87,19 @@ armada_ovl_plane_update(struct drm_plane *plane, struct drm_crtc *crtc, ...@@ -87,17 +87,19 @@ armada_ovl_plane_update(struct drm_plane *plane, struct drm_crtc *crtc,
struct armada_crtc *dcrtc = drm_to_armada_crtc(crtc); struct armada_crtc *dcrtc = drm_to_armada_crtc(crtc);
struct armada_plane_work *work = &dplane->work; struct armada_plane_work *work = &dplane->work;
const struct drm_format_info *format; const struct drm_format_info *format;
struct drm_rect src = { struct drm_plane_state state = {
.x1 = src_x, .plane = plane,
.y1 = src_y, .crtc = crtc,
.x2 = src_x + src_w, .fb = fb,
.y2 = src_y + src_h, .src_x = src_x,
}; .src_y = src_y,
struct drm_rect dest = { .src_w = src_w,
.x1 = crtc_x, .src_h = src_h,
.y1 = crtc_y, .crtc_x = crtc_x,
.x2 = crtc_x + crtc_w, .crtc_y = crtc_y,
.y2 = crtc_y + crtc_h, .crtc_w = crtc_w,
.crtc_h = crtc_h,
.rotation = DRM_MODE_ROTATE_0,
}; };
const struct drm_rect clip = { const struct drm_rect clip = {
.x2 = crtc->mode.hdisplay, .x2 = crtc->mode.hdisplay,
...@@ -105,25 +107,24 @@ armada_ovl_plane_update(struct drm_plane *plane, struct drm_crtc *crtc, ...@@ -105,25 +107,24 @@ armada_ovl_plane_update(struct drm_plane *plane, struct drm_crtc *crtc,
}; };
uint32_t val, ctrl0; uint32_t val, ctrl0;
unsigned idx = 0; unsigned idx = 0;
bool visible, fb_changed; bool fb_changed;
int ret; int ret;
trace_armada_ovl_plane_update(plane, crtc, fb, trace_armada_ovl_plane_update(plane, crtc, fb,
crtc_x, crtc_y, crtc_w, crtc_h, crtc_x, crtc_y, crtc_w, crtc_h,
src_x, src_y, src_w, src_h); src_x, src_y, src_w, src_h);
ret = drm_plane_helper_check_update(plane, crtc, fb, &src, &dest, &clip, ret = drm_plane_helper_check_state(&state, &clip, 0, INT_MAX, true,
DRM_MODE_ROTATE_0, false);
0, INT_MAX, true, false, &visible);
if (ret) if (ret)
return ret; return ret;
ctrl0 = CFG_DMA_FMT(drm_fb_to_armada_fb(fb)->fmt) | ctrl0 = CFG_DMA_FMT(drm_fb_to_armada_fb(fb)->fmt) |
CFG_DMA_MOD(drm_fb_to_armada_fb(fb)->mod) | CFG_DMA_MOD(drm_fb_to_armada_fb(fb)->mod) |
CFG_CBSH_ENA; CFG_CBSH_ENA;
if (visible) if (state.visible)
ctrl0 |= CFG_DMA_ENA; ctrl0 |= CFG_DMA_ENA;
if (drm_rect_width(&src) >> 16 != drm_rect_width(&dest)) if (drm_rect_width(&state.src) >> 16 != drm_rect_width(&state.dst))
ctrl0 |= CFG_DMA_HSMOOTH; ctrl0 |= CFG_DMA_HSMOOTH;
/* /*
...@@ -131,12 +132,12 @@ armada_ovl_plane_update(struct drm_plane *plane, struct drm_crtc *crtc, ...@@ -131,12 +132,12 @@ armada_ovl_plane_update(struct drm_plane *plane, struct drm_crtc *crtc,
* planes to swap. Compensate for it by also toggling the UV swap. * planes to swap. Compensate for it by also toggling the UV swap.
*/ */
format = fb->format; format = fb->format;
if (format->num_planes == 1 && src.x1 >> 16 & (format->hsub - 1)) if (format->num_planes == 1 && state.src.x1 >> 16 & (format->hsub - 1))
ctrl0 ^= CFG_DMA_MOD(CFG_SWAPUV); ctrl0 ^= CFG_DMA_MOD(CFG_SWAPUV);
fb_changed = plane->fb != fb || fb_changed = plane->fb != fb ||
dplane->base.state.src_x != src.x1 >> 16 || dplane->base.state.src_x != state.src.x1 >> 16 ||
dplane->base.state.src_y != src.y1 >> 16; dplane->base.state.src_y != state.src.y1 >> 16;
if (!dcrtc->plane) { if (!dcrtc->plane) {
dcrtc->plane = plane; dcrtc->plane = plane;
...@@ -146,16 +147,17 @@ armada_ovl_plane_update(struct drm_plane *plane, struct drm_crtc *crtc, ...@@ -146,16 +147,17 @@ armada_ovl_plane_update(struct drm_plane *plane, struct drm_crtc *crtc,
/* FIXME: overlay on an interlaced display */ /* FIXME: overlay on an interlaced display */
/* Just updating the position/size? */ /* Just updating the position/size? */
if (!fb_changed && dplane->base.state.ctrl0 == ctrl0) { if (!fb_changed && dplane->base.state.ctrl0 == ctrl0) {
val = (drm_rect_height(&src) & 0xffff0000) | val = (drm_rect_height(&state.src) & 0xffff0000) |
drm_rect_width(&src) >> 16; drm_rect_width(&state.src) >> 16;
dplane->base.state.src_hw = val; dplane->base.state.src_hw = val;
writel_relaxed(val, dcrtc->base + LCD_SPU_DMA_HPXL_VLN); writel_relaxed(val, dcrtc->base + LCD_SPU_DMA_HPXL_VLN);
val = drm_rect_height(&dest) << 16 | drm_rect_width(&dest); val = drm_rect_height(&state.dst) << 16 |
drm_rect_width(&state.dst);
dplane->base.state.dst_hw = val; dplane->base.state.dst_hw = val;
writel_relaxed(val, dcrtc->base + LCD_SPU_DZM_HPXL_VLN); writel_relaxed(val, dcrtc->base + LCD_SPU_DZM_HPXL_VLN);
val = dest.y1 << 16 | dest.x1; val = state.dst.y1 << 16 | state.dst.x1;
dplane->base.state.dst_yx = val; dplane->base.state.dst_yx = val;
writel_relaxed(val, dcrtc->base + LCD_SPU_DMA_OVSA_HPXL_VLN); writel_relaxed(val, dcrtc->base + LCD_SPU_DMA_OVSA_HPXL_VLN);
...@@ -181,8 +183,8 @@ armada_ovl_plane_update(struct drm_plane *plane, struct drm_crtc *crtc, ...@@ -181,8 +183,8 @@ armada_ovl_plane_update(struct drm_plane *plane, struct drm_crtc *crtc,
work->old_fb = plane->fb; work->old_fb = plane->fb;
dplane->base.state.src_y = src_y = src.y1 >> 16; dplane->base.state.src_y = src_y = state.src.y1 >> 16;
dplane->base.state.src_x = src_x = src.x1 >> 16; dplane->base.state.src_x = src_x = state.src.x1 >> 16;
armada_drm_plane_calc_addrs(addrs, fb, src_x, src_y); armada_drm_plane_calc_addrs(addrs, fb, src_x, src_y);
...@@ -209,21 +211,22 @@ armada_ovl_plane_update(struct drm_plane *plane, struct drm_crtc *crtc, ...@@ -209,21 +211,22 @@ armada_ovl_plane_update(struct drm_plane *plane, struct drm_crtc *crtc,
work->old_fb = NULL; work->old_fb = NULL;
} }
val = (drm_rect_height(&src) & 0xffff0000) | drm_rect_width(&src) >> 16; val = (drm_rect_height(&state.src) & 0xffff0000) |
drm_rect_width(&state.src) >> 16;
if (dplane->base.state.src_hw != val) { if (dplane->base.state.src_hw != val) {
dplane->base.state.src_hw = val; dplane->base.state.src_hw = val;
armada_reg_queue_set(work->regs, idx, val, armada_reg_queue_set(work->regs, idx, val,
LCD_SPU_DMA_HPXL_VLN); LCD_SPU_DMA_HPXL_VLN);
} }
val = drm_rect_height(&dest) << 16 | drm_rect_width(&dest); val = drm_rect_height(&state.dst) << 16 | drm_rect_width(&state.dst);
if (dplane->base.state.dst_hw != val) { if (dplane->base.state.dst_hw != val) {
dplane->base.state.dst_hw = val; dplane->base.state.dst_hw = val;
armada_reg_queue_set(work->regs, idx, val, armada_reg_queue_set(work->regs, idx, val,
LCD_SPU_DZM_HPXL_VLN); LCD_SPU_DZM_HPXL_VLN);
} }
val = dest.y1 << 16 | dest.x1; val = state.dst.y1 << 16 | state.dst.x1;
if (dplane->base.state.dst_yx != val) { if (dplane->base.state.dst_yx != val) {
dplane->base.state.dst_yx = val; dplane->base.state.dst_yx = val;
armada_reg_queue_set(work->regs, idx, val, armada_reg_queue_set(work->regs, idx, val,
......
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