Separate fbdev bo creation into a separate function
intel_fbdev_fb_bo_create().

Signed-off-by: Jani Nikula <jani.nik...@intel.com>
---
 drivers/gpu/drm/xe/display/intel_fbdev_fb.c | 33 ++++++++++++++-------
 1 file changed, 23 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/xe/display/intel_fbdev_fb.c 
b/drivers/gpu/drm/xe/display/intel_fbdev_fb.c
index 8e2f338d36fa..9a5d14d5781a 100644
--- a/drivers/gpu/drm/xe/display/intel_fbdev_fb.c
+++ b/drivers/gpu/drm/xe/display/intel_fbdev_fb.c
@@ -20,16 +20,11 @@ u32 intel_fbdev_fb_pitch_align(u32 stride)
        return ALIGN(stride, XE_PAGE_SIZE);
 }
 
-struct intel_framebuffer *intel_fbdev_fb_alloc(struct drm_device *drm,
-                                              struct drm_mode_fb_cmd2 
*mode_cmd)
+struct drm_gem_object *intel_fbdev_fb_bo_create(struct drm_device *drm, int 
size)
 {
-       struct drm_framebuffer *fb;
        struct xe_device *xe = to_xe_device(drm);
        struct xe_bo *obj;
-       int size;
 
-       size = mode_cmd->pitches[0] * mode_cmd->height;
-       size = PAGE_ALIGN(size);
        obj = ERR_PTR(-ENODEV);
 
        if (!IS_DGFX(xe) && !XE_GT_WA(xe_root_mmio_gt(xe), 
22019338487_display)) {
@@ -53,21 +48,39 @@ struct intel_framebuffer *intel_fbdev_fb_alloc(struct 
drm_device *drm,
 
        if (IS_ERR(obj)) {
                drm_err(&xe->drm, "failed to allocate framebuffer (%pe)\n", 
obj);
-               fb = ERR_PTR(-ENOMEM);
+               return ERR_PTR(-ENOMEM);
+       }
+
+       return &obj->ttm.base;
+}
+
+struct intel_framebuffer *intel_fbdev_fb_alloc(struct drm_device *drm,
+                                              struct drm_mode_fb_cmd2 
*mode_cmd)
+{
+       struct drm_framebuffer *fb;
+       struct drm_gem_object *obj;
+       int size;
+
+       size = mode_cmd->pitches[0] * mode_cmd->height;
+       size = PAGE_ALIGN(size);
+
+       obj = intel_fbdev_fb_bo_create(drm, size);
+       if (IS_ERR(obj)) {
+               fb = ERR_CAST(obj);
                goto err;
        }
 
-       fb = intel_framebuffer_create(&obj->ttm.base,
+       fb = intel_framebuffer_create(obj,
                                      drm_get_format_info(drm,
                                                          
mode_cmd->pixel_format,
                                                          
mode_cmd->modifier[0]),
                                      mode_cmd);
        if (IS_ERR(fb)) {
-               xe_bo_unpin_map_no_vm(obj);
+               xe_bo_unpin_map_no_vm(gem_to_xe_bo(obj));
                goto err;
        }
 
-       drm_gem_object_put(&obj->ttm.base);
+       drm_gem_object_put(obj);
 
        return to_intel_framebuffer(fb);
 
-- 
2.47.2

Reply via email to