Move some easy common parts to display. Initially, the intel_find_initial_plane_obj() error path seems silly, but it'll be more helpful this way for later changes.
Signed-off-by: Jani Nikula <[email protected]> --- .../drm/i915/display/intel_initial_plane.c | 29 ++++++++++++++-- drivers/gpu/drm/i915/i915_initial_plane.c | 34 +++---------------- drivers/gpu/drm/xe/display/xe_initial_plane.c | 27 +++------------ include/drm/intel/display_parent_interface.h | 2 +- 4 files changed, 38 insertions(+), 54 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_initial_plane.c b/drivers/gpu/drm/i915/display/intel_initial_plane.c index 62f4fb3be9f0..9e67da94ac02 100644 --- a/drivers/gpu/drm/i915/display/intel_initial_plane.c +++ b/drivers/gpu/drm/i915/display/intel_initial_plane.c @@ -19,8 +19,33 @@ intel_find_initial_plane_obj(struct intel_crtc *crtc, struct intel_initial_plane_config plane_configs[]) { struct intel_display *display = to_intel_display(crtc); - - display->parent->initial_plane->find_obj(&crtc->base, plane_configs); + struct intel_initial_plane_config *plane_config = &plane_configs[crtc->pipe]; + struct intel_plane *plane = to_intel_plane(crtc->base.primary); + int ret; + + /* + * TODO: + * Disable planes if get_initial_plane_config() failed. + * Make sure things work if the surface base is not page aligned. + */ + if (!plane_config->fb) + return; + + ret = display->parent->initial_plane->find_obj(&crtc->base, plane_configs); + if (ret) + goto nofb; + + return; + +nofb: + /* + * We've failed to reconstruct the BIOS FB. Current display state + * indicates that the primary plane is visible, but has a NULL FB, + * which will lead to problems later if we don't fix it up. The + * simplest solution is to just disable the primary plane now and + * pretend the BIOS never had it enabled. + */ + intel_plane_disable_noatomic(crtc, plane); } static void plane_config_fini(struct intel_display *display, diff --git a/drivers/gpu/drm/i915/i915_initial_plane.c b/drivers/gpu/drm/i915/i915_initial_plane.c index d8f2a2a11dd0..57afe6e29ce3 100644 --- a/drivers/gpu/drm/i915/i915_initial_plane.c +++ b/drivers/gpu/drm/i915/i915_initial_plane.c @@ -311,7 +311,7 @@ intel_alloc_initial_plane_obj(struct intel_crtc *crtc, return false; } -static void +static int i915_find_initial_plane_obj(struct drm_crtc *_crtc, struct intel_initial_plane_config plane_configs[]) { @@ -326,39 +326,13 @@ i915_find_initial_plane_obj(struct drm_crtc *_crtc, struct drm_framebuffer *fb; struct i915_vma *vma; - /* - * TODO: - * Disable planes if get_initial_plane_config() failed. - * Make sure things work if the surface base is not page aligned. - */ - if (!plane_config->fb) - return; - if (intel_alloc_initial_plane_obj(crtc, plane_config)) { fb = &plane_config->fb->base; vma = plane_config->vma; - goto valid_fb; + } else if (!intel_reuse_initial_plane_obj(crtc, plane_configs, &fb, &vma)) { + return -EINVAL; } - /* - * Failed to alloc the obj, check to see if we should share - * an fb with another CRTC instead - */ - if (intel_reuse_initial_plane_obj(crtc, plane_configs, &fb, &vma)) - goto valid_fb; - - /* - * We've failed to reconstruct the BIOS FB. Current display state - * indicates that the primary plane is visible, but has a NULL FB, - * which will lead to problems later if we don't fix it up. The - * simplest solution is to just disable the primary plane now and - * pretend the BIOS never had it enabled. - */ - intel_plane_disable_noatomic(crtc, plane); - - return; - -valid_fb: plane_state->uapi.rotation = plane_config->rotation; intel_fb_fill_view(to_intel_framebuffer(fb), plane_state->uapi.rotation, &plane_state->view); @@ -391,6 +365,8 @@ i915_find_initial_plane_obj(struct drm_crtc *_crtc, intel_plane_copy_uapi_to_hw_state(plane_state, plane_state, crtc); atomic_or(plane->frontbuffer_bit, &to_intel_frontbuffer(fb)->bits); + + return 0; } static void i915_plane_config_fini(struct intel_initial_plane_config *plane_config) diff --git a/drivers/gpu/drm/xe/display/xe_initial_plane.c b/drivers/gpu/drm/xe/display/xe_initial_plane.c index 95000f8b0662..ddf22631240e 100644 --- a/drivers/gpu/drm/xe/display/xe_initial_plane.c +++ b/drivers/gpu/drm/xe/display/xe_initial_plane.c @@ -203,7 +203,7 @@ intel_alloc_initial_plane_obj(struct intel_crtc *crtc, return false; } -static void +static int xe_find_initial_plane_obj(struct drm_crtc *_crtc, struct intel_initial_plane_config plane_configs[]) { @@ -217,18 +217,10 @@ xe_find_initial_plane_obj(struct drm_crtc *_crtc, struct drm_framebuffer *fb; struct i915_vma *vma; - /* - * TODO: - * Disable planes if get_initial_plane_config() failed. - * Make sure things work if the surface base is not page aligned. - */ - if (!plane_config->fb) - return; - if (intel_alloc_initial_plane_obj(crtc, plane_config)) fb = &plane_config->fb->base; else if (!intel_reuse_initial_plane_obj(crtc, plane_configs, &fb)) - goto nofb; + return -EINVAL; plane_state->uapi.rotation = plane_config->rotation; intel_fb_fill_view(to_intel_framebuffer(fb), @@ -237,7 +229,7 @@ xe_find_initial_plane_obj(struct drm_crtc *_crtc, vma = intel_fb_pin_to_ggtt(fb, &plane_state->view.gtt, 0, 0, 0, false, &plane_state->flags); if (IS_ERR(vma)) - goto nofb; + return PTR_ERR(vma); plane_state->ggtt_vma = vma; @@ -262,17 +254,8 @@ xe_find_initial_plane_obj(struct drm_crtc *_crtc, atomic_or(plane->frontbuffer_bit, &to_intel_frontbuffer(fb)->bits); plane_config->vma = vma; - return; - -nofb: - /* - * We've failed to reconstruct the BIOS FB. Current display state - * indicates that the primary plane is visible, but has a NULL FB, - * which will lead to problems later if we don't fix it up. The - * simplest solution is to just disable the primary plane now and - * pretend the BIOS never had it enabled. - */ - intel_plane_disable_noatomic(crtc, plane); + + return 0; } static void xe_plane_config_fini(struct intel_initial_plane_config *plane_config) diff --git a/include/drm/intel/display_parent_interface.h b/include/drm/intel/display_parent_interface.h index b6559fe22d1c..1be6320a5fc4 100644 --- a/include/drm/intel/display_parent_interface.h +++ b/include/drm/intel/display_parent_interface.h @@ -29,7 +29,7 @@ struct intel_display_hdcp_interface { struct intel_display_initial_plane_interface { void (*vblank_wait)(struct drm_crtc *crtc); - void (*find_obj)(struct drm_crtc *crtc, struct intel_initial_plane_config *plane_configs); + int (*find_obj)(struct drm_crtc *crtc, struct intel_initial_plane_config *plane_configs); void (*config_fini)(struct intel_initial_plane_config *plane_configs); }; -- 2.47.3
