Move the parent interface at one step lower level, allowing
deduplication.

Signed-off-by: Jani Nikula <[email protected]>
---
 .../drm/i915/display/intel_initial_plane.c    | 48 ++++++++++++++++++-
 drivers/gpu/drm/i915/i915_initial_plane.c     | 47 +++---------------
 drivers/gpu/drm/xe/display/xe_initial_plane.c | 47 +++---------------
 include/drm/intel/display_parent_interface.h  |  4 +-
 4 files changed, 62 insertions(+), 84 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_initial_plane.c 
b/drivers/gpu/drm/i915/display/intel_initial_plane.c
index c68d7555aee5..561a2ba2a486 100644
--- a/drivers/gpu/drm/i915/display/intel_initial_plane.c
+++ b/drivers/gpu/drm/i915/display/intel_initial_plane.c
@@ -14,7 +14,53 @@ void intel_initial_plane_vblank_wait(struct intel_crtc *crtc)
        display->parent->initial_plane->vblank_wait(&crtc->base);
 }
 
+static void
+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);
+}
+
+static void plane_config_fini(struct intel_display *display,
+                             struct intel_initial_plane_config *plane_config)
+{
+       display->parent->initial_plane->config_fini(plane_config);
+}
+
 void intel_initial_plane_config(struct intel_display *display)
 {
-       display->parent->initial_plane->config(display->drm);
+       struct intel_initial_plane_config plane_configs[I915_MAX_PIPES] = {};
+       struct intel_crtc *crtc;
+
+       for_each_intel_crtc(display->drm, crtc) {
+               const struct intel_crtc_state *crtc_state =
+                       to_intel_crtc_state(crtc->base.state);
+               struct intel_initial_plane_config *plane_config =
+                       &plane_configs[crtc->pipe];
+
+               if (!crtc_state->hw.active)
+                       continue;
+
+               /*
+                * Note that reserving the BIOS fb up front prevents us
+                * from stuffing other stolen allocations like the ring
+                * on top.  This prevents some ugliness at boot time, and
+                * can even allow for smooth boot transitions if the BIOS
+                * fb is large enough for the active pipe configuration.
+                */
+               display->funcs.display->get_initial_plane_config(crtc, 
plane_config);
+
+               /*
+                * If the fb is shared between multiple heads, we'll
+                * just get the first one.
+                */
+               intel_find_initial_plane_obj(crtc, plane_configs);
+
+               if (display->funcs.display->fixup_initial_plane_config(crtc, 
plane_config))
+                       intel_initial_plane_vblank_wait(crtc);
+
+               plane_config_fini(display, plane_config);
+       }
 }
diff --git a/drivers/gpu/drm/i915/i915_initial_plane.c 
b/drivers/gpu/drm/i915/i915_initial_plane.c
index f26563eed9ba..68cf2499855a 100644
--- a/drivers/gpu/drm/i915/i915_initial_plane.c
+++ b/drivers/gpu/drm/i915/i915_initial_plane.c
@@ -312,9 +312,10 @@ intel_alloc_initial_plane_obj(struct intel_crtc *crtc,
 }
 
 static void
-intel_find_initial_plane_obj(struct intel_crtc *crtc,
-                            struct intel_initial_plane_config plane_configs[])
+i915_find_initial_plane_obj(struct drm_crtc *_crtc,
+                           struct intel_initial_plane_config plane_configs[])
 {
+       struct intel_crtc *crtc = to_intel_crtc(_crtc);
        struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
        struct intel_initial_plane_config *plane_config =
                &plane_configs[crtc->pipe];
@@ -392,7 +393,7 @@ intel_find_initial_plane_obj(struct intel_crtc *crtc,
        atomic_or(plane->frontbuffer_bit, &to_intel_frontbuffer(fb)->bits);
 }
 
-static void plane_config_fini(struct intel_initial_plane_config *plane_config)
+static void i915_plane_config_fini(struct intel_initial_plane_config 
*plane_config)
 {
        if (plane_config->fb) {
                struct drm_framebuffer *fb = &plane_config->fb->base;
@@ -408,44 +409,8 @@ static void plane_config_fini(struct 
intel_initial_plane_config *plane_config)
                i915_vma_put(plane_config->vma);
 }
 
-static void i915_initial_plane_config(struct drm_device *drm)
-{
-       struct intel_display *display = to_intel_display(drm);
-       struct intel_initial_plane_config plane_configs[I915_MAX_PIPES] = {};
-       struct intel_crtc *crtc;
-
-       for_each_intel_crtc(display->drm, crtc) {
-               const struct intel_crtc_state *crtc_state =
-                       to_intel_crtc_state(crtc->base.state);
-               struct intel_initial_plane_config *plane_config =
-                       &plane_configs[crtc->pipe];
-
-               if (!crtc_state->hw.active)
-                       continue;
-
-               /*
-                * Note that reserving the BIOS fb up front prevents us
-                * from stuffing other stolen allocations like the ring
-                * on top.  This prevents some ugliness at boot time, and
-                * can even allow for smooth boot transitions if the BIOS
-                * fb is large enough for the active pipe configuration.
-                */
-               display->funcs.display->get_initial_plane_config(crtc, 
plane_config);
-
-               /*
-                * If the fb is shared between multiple heads, we'll
-                * just get the first one.
-                */
-               intel_find_initial_plane_obj(crtc, plane_configs);
-
-               if (display->funcs.display->fixup_initial_plane_config(crtc, 
plane_config))
-                       i915_initial_plane_vblank_wait(&crtc->base);
-
-               plane_config_fini(plane_config);
-       }
-}
-
 const struct intel_display_initial_plane_interface 
i915_display_initial_plane_interface = {
        .vblank_wait = i915_initial_plane_vblank_wait,
-       .config = i915_initial_plane_config,
+       .find_obj = i915_find_initial_plane_obj,
+       .config_fini = i915_plane_config_fini,
 };
diff --git a/drivers/gpu/drm/xe/display/xe_initial_plane.c 
b/drivers/gpu/drm/xe/display/xe_initial_plane.c
index dd69f1c65903..0007337c60da 100644
--- a/drivers/gpu/drm/xe/display/xe_initial_plane.c
+++ b/drivers/gpu/drm/xe/display/xe_initial_plane.c
@@ -204,9 +204,10 @@ intel_alloc_initial_plane_obj(struct intel_crtc *crtc,
 }
 
 static void
-intel_find_initial_plane_obj(struct intel_crtc *crtc,
-                            struct intel_initial_plane_config plane_configs[])
+xe_find_initial_plane_obj(struct drm_crtc *_crtc,
+                         struct intel_initial_plane_config plane_configs[])
 {
+       struct intel_crtc *crtc = to_intel_crtc(_crtc);
        struct intel_initial_plane_config *plane_config =
                &plane_configs[crtc->pipe];
        struct intel_plane *plane =
@@ -274,7 +275,7 @@ intel_find_initial_plane_obj(struct intel_crtc *crtc,
        intel_plane_disable_noatomic(crtc, plane);
 }
 
-static void plane_config_fini(struct intel_initial_plane_config *plane_config)
+static void xe_plane_config_fini(struct intel_initial_plane_config 
*plane_config)
 {
        if (plane_config->fb) {
                struct drm_framebuffer *fb = &plane_config->fb->base;
@@ -287,44 +288,8 @@ static void plane_config_fini(struct 
intel_initial_plane_config *plane_config)
        }
 }
 
-static void xe_initial_plane_config(struct drm_device *drm)
-{
-       struct intel_display *display = to_intel_display(drm);
-       struct intel_initial_plane_config plane_configs[I915_MAX_PIPES] = {};
-       struct intel_crtc *crtc;
-
-       for_each_intel_crtc(display->drm, crtc) {
-               const struct intel_crtc_state *crtc_state =
-                       to_intel_crtc_state(crtc->base.state);
-               struct intel_initial_plane_config *plane_config =
-                       &plane_configs[crtc->pipe];
-
-               if (!crtc_state->hw.active)
-                       continue;
-
-               /*
-                * Note that reserving the BIOS fb up front prevents us
-                * from stuffing other stolen allocations like the ring
-                * on top.  This prevents some ugliness at boot time, and
-                * can even allow for smooth boot transitions if the BIOS
-                * fb is large enough for the active pipe configuration.
-                */
-               display->funcs.display->get_initial_plane_config(crtc, 
plane_config);
-
-               /*
-                * If the fb is shared between multiple heads, we'll
-                * just get the first one.
-                */
-               intel_find_initial_plane_obj(crtc, plane_configs);
-
-               if (display->funcs.display->fixup_initial_plane_config(crtc, 
plane_config))
-                       xe_initial_plane_vblank_wait(&crtc->base);
-
-               plane_config_fini(plane_config);
-       }
-}
-
 const struct intel_display_initial_plane_interface 
xe_display_initial_plane_interface = {
        .vblank_wait = xe_initial_plane_vblank_wait,
-       .config = xe_initial_plane_config,
+       .find_obj = xe_find_initial_plane_obj,
+       .config_fini = xe_plane_config_fini,
 };
diff --git a/include/drm/intel/display_parent_interface.h 
b/include/drm/intel/display_parent_interface.h
index 76341b4b03f7..b6559fe22d1c 100644
--- a/include/drm/intel/display_parent_interface.h
+++ b/include/drm/intel/display_parent_interface.h
@@ -11,6 +11,7 @@ struct drm_crtc;
 struct drm_device;
 struct drm_scanout_buffer;
 struct intel_hdcp_gsc_context;
+struct intel_initial_plane_config;
 struct intel_panic;
 struct intel_stolen_node;
 struct ref_tracker;
@@ -28,7 +29,8 @@ struct intel_display_hdcp_interface {
 
 struct intel_display_initial_plane_interface {
        void (*vblank_wait)(struct drm_crtc *crtc);
-       void (*config)(struct drm_device *drm);
+       void (*find_obj)(struct drm_crtc *crtc, struct 
intel_initial_plane_config *plane_configs);
+       void (*config_fini)(struct intel_initial_plane_config *plane_configs);
 };
 
 struct intel_display_irq_interface {
-- 
2.47.3

Reply via email to