]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/{i915, xe}: deduplicate intel_initial_plane_config() between i915 and xe
authorJani Nikula <jani.nikula@intel.com>
Mon, 15 Dec 2025 15:28:19 +0000 (17:28 +0200)
committerJani Nikula <jani.nikula@intel.com>
Mon, 22 Dec 2025 13:09:22 +0000 (15:09 +0200)
Move the parent interface at one step lower level, allowing
deduplication.

Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patch.msgid.link/0cb4077a5a39274c7a2dae95d548d7b33365a518.1765812266.git.jani.nikula@intel.com
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
drivers/gpu/drm/i915/display/intel_initial_plane.c
drivers/gpu/drm/i915/i915_initial_plane.c
drivers/gpu/drm/xe/display/xe_initial_plane.c
include/drm/intel/display_parent_interface.h

index c68d7555aee58c87e69e519032f70c563263a2a6..561a2ba2a486e536c85f13a61f05ed5a378e850d 100644 (file)
@@ -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);
+       }
 }
index f26563eed9baaaf96280717e6e0264fdbb15fb3b..68cf2499855a3868b83f946660f4ede0951445e7 100644 (file)
@@ -312,9 +312,10 @@ err_vma:
 }
 
 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 @@ valid_fb:
        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,
 };
index dd69f1c65903d703d37eb0a70207f29b0f471e3c..0007337c60da08970973f5b44bbf59c23b2caf2c 100644 (file)
@@ -204,9 +204,10 @@ err_bo:
 }
 
 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 @@ nofb:
        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,
 };
index 48d52bee4ceecddbfed8278537911c0530de49c2..87cd3c5e10552a95d05fecf436534381960d7f0e 100644 (file)
@@ -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 {