From: Ville Syrjälä <[email protected]>

Pull the gem/gt related bits of the overlay setup into
a separate function (i915_overlay_setup()) that will eventually
move to the i915 side of the parent vs. display driver split.

For now we'll also have to pass in the overlay struct, but
that will disappear once the i915 vs. display split is completed.

Signed-off-by: Ville Syrjälä <[email protected]>
---
 drivers/gpu/drm/i915/display/intel_overlay.c | 40 ++++++++++++--------
 1 file changed, 25 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_overlay.c 
b/drivers/gpu/drm/i915/display/intel_overlay.c
index 8c1ed540a8e3..5683bddf33b4 100644
--- a/drivers/gpu/drm/i915/display/intel_overlay.c
+++ b/drivers/gpu/drm/i915/display/intel_overlay.c
@@ -1430,39 +1430,49 @@ static int get_registers(struct intel_overlay *overlay, 
bool use_phys)
        return err;
 }
 
-void intel_overlay_setup(struct intel_display *display)
+static int i915_overlay_setup(struct drm_device *drm,
+                             struct intel_overlay *overlay,
+                             bool needs_physical)
 {
-       struct drm_i915_private *dev_priv = to_i915(display->drm);
-       struct intel_overlay *overlay;
+       struct drm_i915_private *dev_priv = to_i915(drm);
        struct intel_engine_cs *engine;
-       int ret;
-
-       if (!HAS_OVERLAY(display))
-               return;
 
        engine = to_gt(dev_priv)->engine[RCS0];
        if (!engine || !engine->kernel_context)
+               return -ENOENT;
+
+       overlay->context = engine->kernel_context;
+
+       i915_active_init(&overlay->last_flip,
+                        NULL, intel_overlay_last_flip_retire, 0);
+
+       return get_registers(overlay, needs_physical);
+}
+
+void intel_overlay_setup(struct intel_display *display)
+{
+       struct intel_overlay *overlay;
+       int ret;
+
+       if (!HAS_OVERLAY(display))
                return;
 
        overlay = kzalloc(sizeof(*overlay), GFP_KERNEL);
        if (!overlay)
                return;
 
+       ret = i915_overlay_setup(display->drm, overlay,
+                                OVERLAY_NEEDS_PHYSICAL(display));
+       if (ret)
+               goto out_free;
+
        overlay->display = display;
-       overlay->context = engine->kernel_context;
        overlay->color_key = 0x0101fe;
        overlay->color_key_enabled = true;
        overlay->brightness = -19;
        overlay->contrast = 75;
        overlay->saturation = 146;
 
-       i915_active_init(&overlay->last_flip,
-                        NULL, intel_overlay_last_flip_retire, 0);
-
-       ret = get_registers(overlay, OVERLAY_NEEDS_PHYSICAL(display));
-       if (ret)
-               goto out_free;
-
        memset_io(overlay->regs, 0, sizeof(struct overlay_registers));
        update_polyphase_filter(overlay->regs);
        update_reg_attrs(overlay, overlay->regs);
-- 
2.52.0

Reply via email to