drm/i915: Decouple i915_gem_dumb_create() from the display a bit
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Thu, 6 Feb 2025 18:55:23 +0000 (20:55 +0200)
committerVille Syrjälä <ville.syrjala@linux.intel.com>
Mon, 10 Feb 2025 20:59:27 +0000 (22:59 +0200)
Pass the device argument as drm_device to intel_plane_fb_max_stride()
to decouple i915_gem_dumb_create() vs. the display code a bit.

xe currently doesn't even call this, but it probably should...

v2: s/dev/drm/ (Jani)

Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250206185533.32306-3-ville.syrjala@linux.intel.com
drivers/gpu/drm/i915/display/intel_display.c
drivers/gpu/drm/i915/display/intel_display.h
drivers/gpu/drm/i915/display/intel_fb.c
drivers/gpu/drm/i915/gem/i915_gem_create.c

index 993ffd2187405140ae92dc3a1d4876df282a4dcb..397fc4581b4a3228a267ed0e1cc345a5f31bac35 100644 (file)
@@ -713,13 +713,15 @@ void intel_add_fb_offsets(int *x, int *y,
        *y += state->view.color_plane[color_plane].y;
 }
 
-u32 intel_plane_fb_max_stride(struct drm_i915_private *dev_priv,
+u32 intel_plane_fb_max_stride(struct drm_device *drm,
                              u32 pixel_format, u64 modifier)
 {
+       struct intel_display *display = to_intel_display(drm);
+       struct drm_i915_private *dev_priv = to_i915(drm);
        struct intel_crtc *crtc;
        struct intel_plane *plane;
 
-       if (!HAS_DISPLAY(dev_priv))
+       if (!HAS_DISPLAY(display))
                return 0;
 
        /*
index 793c9d30c582c0bf51f9fca26939862bef9b8a47..e594492bade71606611c56aa02f98ccfc626cdb2 100644 (file)
@@ -421,7 +421,7 @@ void intel_link_compute_m_n(u16 bpp, int nlanes,
                            int pixel_clock, int link_clock,
                            int bw_overhead,
                            struct intel_link_m_n *m_n);
-u32 intel_plane_fb_max_stride(struct drm_i915_private *dev_priv,
+u32 intel_plane_fb_max_stride(struct drm_device *drm,
                              u32 pixel_format, u64 modifier);
 enum drm_mode_status
 intel_mode_valid_max_plane_size(struct drm_i915_private *dev_priv,
index d9328877cc6db49a3a33481699817415031adb4e..42c46376daae0334fdf0eaddb492da5d88f69e83 100644 (file)
@@ -1895,7 +1895,7 @@ u32 intel_fb_max_stride(struct drm_i915_private *dev_priv,
         */
        if (DISPLAY_VER(dev_priv) < 4 || intel_fb_is_ccs_modifier(modifier) ||
            intel_fb_modifier_uses_dpt(dev_priv, modifier))
-               return intel_plane_fb_max_stride(dev_priv, pixel_format, modifier);
+               return intel_plane_fb_max_stride(&dev_priv->drm, pixel_format, modifier);
        else if (DISPLAY_VER(dev_priv) >= 7)
                return 256 * 1024;
        else
@@ -1909,7 +1909,7 @@ intel_fb_stride_alignment(const struct drm_framebuffer *fb, int color_plane)
        unsigned int tile_width;
 
        if (is_surface_linear(fb, color_plane)) {
-               unsigned int max_stride = intel_plane_fb_max_stride(dev_priv,
+               unsigned int max_stride = intel_plane_fb_max_stride(&dev_priv->drm,
                                                                    fb->format->format,
                                                                    fb->modifier);
 
index 19156ba4b9ef404e8944b94b0dbf87534dcad952..c3e6a325872d54b9b790b044297398fb2041c1eb 100644 (file)
@@ -193,7 +193,7 @@ i915_gem_dumb_create(struct drm_file *file,
        args->pitch = ALIGN(args->width * cpp, 64);
 
        /* align stride to page size so that we can remap */
-       if (args->pitch > intel_plane_fb_max_stride(to_i915(dev), format,
+       if (args->pitch > intel_plane_fb_max_stride(dev, format,
                                                    DRM_FORMAT_MOD_LINEAR))
                args->pitch = ALIGN(args->pitch, 4096);