Commit ec4dae5e authored by Jani Nikula's avatar Jani Nikula
Browse files

drm/xe/fbdev: abstract bo creation



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

Reviewed-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Link: https://lore.kernel.org/r/74dfb9f3e6e05a93d54a8ab534e4384145b52571.1758184771.git.jani.nikula@intel.com


Signed-off-by: default avatarJani Nikula <jani.nikula@intel.com>
parent 7326099d
Loading
Loading
Loading
Loading
+23 −10
Original line number Diff line number Diff line
@@ -15,16 +15,11 @@

#include <generated/xe_wa_oob.h>

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)) {
@@ -48,21 +43,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);