summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJani Nikula <jani.nikula@intel.com>2025-12-15 18:28:21 +0300
committerJani Nikula <jani.nikula@intel.com>2025-12-22 16:09:22 +0300
commit1b3cc68df363820537d6c837069db4c303ee58a9 (patch)
treee84639c89efb2d84123ac8712a128a0a856743cf
parent6bb14ea387fee901b62a29af568f39eeac23e451 (diff)
downloadlinux-1b3cc68df363820537d6c837069db4c303ee58a9.tar.xz
drm/{i915, xe}: start deduplicating intel_find_initial_plane_obj() between i915 and xe
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. Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Link: https://patch.msgid.link/950d308172443d5bae975aa1ab72111720134219.1765812266.git.jani.nikula@intel.com Signed-off-by: Jani Nikula <jani.nikula@intel.com>
-rw-r--r--drivers/gpu/drm/i915/display/intel_initial_plane.c29
-rw-r--r--drivers/gpu/drm/i915/i915_initial_plane.c34
-rw-r--r--drivers/gpu/drm/xe/display/xe_initial_plane.c27
-rw-r--r--include/drm/intel/display_parent_interface.h2
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 @@ err_vma:
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 @@ valid_fb:
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 @@ err_bo:
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 87cd3c5e1055..997a9746dc83 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);
};