diff options
Diffstat (limited to 'drivers/gpu/drm/imx/ipuv3-plane.c')
-rw-r--r-- | drivers/gpu/drm/imx/ipuv3-plane.c | 92 |
1 files changed, 50 insertions, 42 deletions
diff --git a/drivers/gpu/drm/imx/ipuv3-plane.c b/drivers/gpu/drm/imx/ipuv3-plane.c index 075508051b5f..fa5009705365 100644 --- a/drivers/gpu/drm/imx/ipuv3-plane.c +++ b/drivers/gpu/drm/imx/ipuv3-plane.c @@ -9,8 +9,8 @@ #include <drm/drm_atomic_helper.h> #include <drm/drm_fb_cma_helper.h> #include <drm/drm_fourcc.h> +#include <drm/drm_gem_atomic_helper.h> #include <drm/drm_gem_cma_helper.h> -#include <drm/drm_gem_framebuffer_helper.h> #include <drm/drm_managed.h> #include <drm/drm_plane_helper.h> @@ -337,12 +337,15 @@ static const struct drm_plane_funcs ipu_plane_funcs = { }; static int ipu_plane_atomic_check(struct drm_plane *plane, - struct drm_plane_state *state) + struct drm_atomic_state *state) { - struct drm_plane_state *old_state = plane->state; + struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state, + plane); + struct drm_plane_state *old_state = drm_atomic_get_old_plane_state(state, + plane); struct drm_crtc_state *crtc_state; struct device *dev = plane->dev->dev; - struct drm_framebuffer *fb = state->fb; + struct drm_framebuffer *fb = new_state->fb; struct drm_framebuffer *old_fb = old_state->fb; unsigned long eba, ubo, vbo, old_ubo, old_vbo, alpha_eba; bool can_position = (plane->type == DRM_PLANE_TYPE_OVERLAY); @@ -352,15 +355,16 @@ static int ipu_plane_atomic_check(struct drm_plane *plane, if (!fb) return 0; - if (WARN_ON(!state->crtc)) + if (WARN_ON(!new_state->crtc)) return -EINVAL; crtc_state = - drm_atomic_get_existing_crtc_state(state->state, state->crtc); + drm_atomic_get_existing_crtc_state(state, + new_state->crtc); if (WARN_ON(!crtc_state)) return -EINVAL; - ret = drm_atomic_helper_check_plane_state(state, crtc_state, + ret = drm_atomic_helper_check_plane_state(new_state, crtc_state, DRM_PLANE_HELPER_NO_SCALING, DRM_PLANE_HELPER_NO_SCALING, can_position, true); @@ -374,7 +378,7 @@ static int ipu_plane_atomic_check(struct drm_plane *plane, switch (plane->type) { case DRM_PLANE_TYPE_PRIMARY: /* full plane minimum width is 13 pixels */ - if (drm_rect_width(&state->dst) < 13) + if (drm_rect_width(&new_state->dst) < 13) return -EINVAL; break; case DRM_PLANE_TYPE_OVERLAY: @@ -384,7 +388,7 @@ static int ipu_plane_atomic_check(struct drm_plane *plane, return -EINVAL; } - if (drm_rect_height(&state->dst) < 2) + if (drm_rect_height(&new_state->dst) < 2) return -EINVAL; /* @@ -395,12 +399,12 @@ static int ipu_plane_atomic_check(struct drm_plane *plane, * callback. */ if (old_fb && - (drm_rect_width(&state->dst) != drm_rect_width(&old_state->dst) || - drm_rect_height(&state->dst) != drm_rect_height(&old_state->dst) || + (drm_rect_width(&new_state->dst) != drm_rect_width(&old_state->dst) || + drm_rect_height(&new_state->dst) != drm_rect_height(&old_state->dst) || fb->format != old_fb->format)) crtc_state->mode_changed = true; - eba = drm_plane_state_to_eba(state, 0); + eba = drm_plane_state_to_eba(new_state, 0); if (eba & 0x7) return -EINVAL; @@ -426,7 +430,7 @@ static int ipu_plane_atomic_check(struct drm_plane *plane, * - Only EBA may be changed while scanout is active * - The strides of U and V planes must be identical. */ - vbo = drm_plane_state_to_vbo(state); + vbo = drm_plane_state_to_vbo(new_state); if (vbo & 0x7 || vbo > 0xfffff8) return -EINVAL; @@ -443,7 +447,7 @@ static int ipu_plane_atomic_check(struct drm_plane *plane, fallthrough; case DRM_FORMAT_NV12: case DRM_FORMAT_NV16: - ubo = drm_plane_state_to_ubo(state); + ubo = drm_plane_state_to_ubo(new_state); if (ubo & 0x7 || ubo > 0xfffff8) return -EINVAL; @@ -464,8 +468,8 @@ static int ipu_plane_atomic_check(struct drm_plane *plane, * The x/y offsets must be even in case of horizontal/vertical * chroma subsampling. */ - if (((state->src.x1 >> 16) & (fb->format->hsub - 1)) || - ((state->src.y1 >> 16) & (fb->format->vsub - 1))) + if (((new_state->src.x1 >> 16) & (fb->format->hsub - 1)) || + ((new_state->src.y1 >> 16) & (fb->format->vsub - 1))) return -EINVAL; break; case DRM_FORMAT_RGB565_A8: @@ -474,7 +478,7 @@ static int ipu_plane_atomic_check(struct drm_plane *plane, case DRM_FORMAT_BGR888_A8: case DRM_FORMAT_RGBX8888_A8: case DRM_FORMAT_BGRX8888_A8: - alpha_eba = drm_plane_state_to_eba(state, 1); + alpha_eba = drm_plane_state_to_eba(new_state, 1); if (alpha_eba & 0x7) return -EINVAL; @@ -490,7 +494,7 @@ static int ipu_plane_atomic_check(struct drm_plane *plane, } static void ipu_plane_atomic_disable(struct drm_plane *plane, - struct drm_plane_state *old_state) + struct drm_atomic_state *state) { struct ipu_plane *ipu_plane = to_ipu_plane(plane); @@ -535,14 +539,17 @@ static void ipu_calculate_bursts(u32 width, u32 cpp, u32 stride, } static void ipu_plane_atomic_update(struct drm_plane *plane, - struct drm_plane_state *old_state) + struct drm_atomic_state *state) { + struct drm_plane_state *old_state = drm_atomic_get_old_plane_state(state, + plane); struct ipu_plane *ipu_plane = to_ipu_plane(plane); - struct drm_plane_state *state = plane->state; - struct ipu_plane_state *ipu_state = to_ipu_plane_state(state); - struct drm_crtc_state *crtc_state = state->crtc->state; - struct drm_framebuffer *fb = state->fb; - struct drm_rect *dst = &state->dst; + struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state, + plane); + struct ipu_plane_state *ipu_state = to_ipu_plane_state(new_state); + struct drm_crtc_state *crtc_state = new_state->crtc->state; + struct drm_framebuffer *fb = new_state->fb; + struct drm_rect *dst = &new_state->dst; unsigned long eba, ubo, vbo; unsigned long alpha_eba = 0; enum ipu_color_space ics; @@ -557,7 +564,7 @@ static void ipu_plane_atomic_update(struct drm_plane *plane, switch (ipu_plane->dp_flow) { case IPU_DP_FLOW_SYNC_BG: - if (state->normalized_zpos == 1) { + if (new_state->normalized_zpos == 1) { ipu_dp_set_global_alpha(ipu_plane->dp, !fb->format->has_alpha, 0xff, true); @@ -566,7 +573,7 @@ static void ipu_plane_atomic_update(struct drm_plane *plane, } break; case IPU_DP_FLOW_SYNC_FG: - if (state->normalized_zpos == 1) { + if (new_state->normalized_zpos == 1) { ipu_dp_set_global_alpha(ipu_plane->dp, !fb->format->has_alpha, 0xff, false); @@ -574,7 +581,7 @@ static void ipu_plane_atomic_update(struct drm_plane *plane, break; } - eba = drm_plane_state_to_eba(state, 0); + eba = drm_plane_state_to_eba(new_state, 0); /* * Configure PRG channel and attached PRE, this changes the EBA to an @@ -583,8 +590,8 @@ static void ipu_plane_atomic_update(struct drm_plane *plane, if (ipu_state->use_pre) { axi_id = ipu_chan_assign_axi_id(ipu_plane->dma); ipu_prg_channel_configure(ipu_plane->ipu_ch, axi_id, - drm_rect_width(&state->src) >> 16, - drm_rect_height(&state->src) >> 16, + drm_rect_width(&new_state->src) >> 16, + drm_rect_height(&new_state->src) >> 16, fb->pitches[0], fb->format->format, fb->modifier, &eba); } @@ -618,8 +625,8 @@ static void ipu_plane_atomic_update(struct drm_plane *plane, ipu_dmfc_config_wait4eot(ipu_plane->dmfc, drm_rect_width(dst)); - width = drm_rect_width(&state->src) >> 16; - height = drm_rect_height(&state->src) >> 16; + width = drm_rect_width(&new_state->src) >> 16; + height = drm_rect_height(&new_state->src) >> 16; info = drm_format_info(fb->format->format); ipu_calculate_bursts(width, info->cpp[0], fb->pitches[0], &burstsize, &num_bursts); @@ -641,8 +648,8 @@ static void ipu_plane_atomic_update(struct drm_plane *plane, case DRM_FORMAT_YVU422: case DRM_FORMAT_YUV444: case DRM_FORMAT_YVU444: - ubo = drm_plane_state_to_ubo(state); - vbo = drm_plane_state_to_vbo(state); + ubo = drm_plane_state_to_ubo(new_state); + vbo = drm_plane_state_to_vbo(new_state); if (fb->format->format == DRM_FORMAT_YVU420 || fb->format->format == DRM_FORMAT_YVU422 || fb->format->format == DRM_FORMAT_YVU444) @@ -653,18 +660,18 @@ static void ipu_plane_atomic_update(struct drm_plane *plane, dev_dbg(ipu_plane->base.dev->dev, "phy = %lu %lu %lu, x = %d, y = %d", eba, ubo, vbo, - state->src.x1 >> 16, state->src.y1 >> 16); + new_state->src.x1 >> 16, new_state->src.y1 >> 16); break; case DRM_FORMAT_NV12: case DRM_FORMAT_NV16: - ubo = drm_plane_state_to_ubo(state); + ubo = drm_plane_state_to_ubo(new_state); ipu_cpmem_set_yuv_planar_full(ipu_plane->ipu_ch, fb->pitches[1], ubo, ubo); dev_dbg(ipu_plane->base.dev->dev, "phy = %lu %lu, x = %d, y = %d", eba, ubo, - state->src.x1 >> 16, state->src.y1 >> 16); + new_state->src.x1 >> 16, new_state->src.y1 >> 16); break; case DRM_FORMAT_RGB565_A8: case DRM_FORMAT_BGR565_A8: @@ -672,18 +679,19 @@ static void ipu_plane_atomic_update(struct drm_plane *plane, case DRM_FORMAT_BGR888_A8: case DRM_FORMAT_RGBX8888_A8: case DRM_FORMAT_BGRX8888_A8: - alpha_eba = drm_plane_state_to_eba(state, 1); + alpha_eba = drm_plane_state_to_eba(new_state, 1); num_bursts = 0; dev_dbg(ipu_plane->base.dev->dev, "phys = %lu %lu, x = %d, y = %d", - eba, alpha_eba, state->src.x1 >> 16, state->src.y1 >> 16); + eba, alpha_eba, new_state->src.x1 >> 16, + new_state->src.y1 >> 16); ipu_cpmem_set_burstsize(ipu_plane->ipu_ch, 16); ipu_cpmem_zero(ipu_plane->alpha_ch); ipu_cpmem_set_resolution(ipu_plane->alpha_ch, - drm_rect_width(&state->src) >> 16, - drm_rect_height(&state->src) >> 16); + drm_rect_width(&new_state->src) >> 16, + drm_rect_height(&new_state->src) >> 16); ipu_cpmem_set_format_passthrough(ipu_plane->alpha_ch, 8); ipu_cpmem_set_high_priority(ipu_plane->alpha_ch); ipu_idmac_set_double_buffer(ipu_plane->alpha_ch, 1); @@ -694,7 +702,7 @@ static void ipu_plane_atomic_update(struct drm_plane *plane, break; default: dev_dbg(ipu_plane->base.dev->dev, "phys = %lu, x = %d, y = %d", - eba, state->src.x1 >> 16, state->src.y1 >> 16); + eba, new_state->src.x1 >> 16, new_state->src.y1 >> 16); break; } ipu_cpmem_set_buffer(ipu_plane->ipu_ch, 0, eba); @@ -704,7 +712,7 @@ static void ipu_plane_atomic_update(struct drm_plane *plane, } static const struct drm_plane_helper_funcs ipu_plane_helper_funcs = { - .prepare_fb = drm_gem_fb_prepare_fb, + .prepare_fb = drm_gem_plane_helper_prepare_fb, .atomic_check = ipu_plane_atomic_check, .atomic_disable = ipu_plane_atomic_disable, .atomic_update = ipu_plane_atomic_update, |