Commit 8bcd4553 authored by Jesse Barnes's avatar Jesse Barnes Committed by Daniel Vetter

drm/i915: alloc intel_fb in the intel_fbdev struct

Allocate this struct instead, so we can re-use another allocated
elsewhere if needed.
Signed-off-by: default avatarJesse Barnes <jbarnes@virtuousgeek.org>
[danvet: WARN_ON if there's no backing storage attached to an fb,
that's a bug.]
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent bd9b6a4e
...@@ -7769,11 +7769,11 @@ mode_fits_in_fbdev(struct drm_device *dev, ...@@ -7769,11 +7769,11 @@ mode_fits_in_fbdev(struct drm_device *dev,
if (dev_priv->fbdev == NULL) if (dev_priv->fbdev == NULL)
return NULL; return NULL;
obj = dev_priv->fbdev->ifb.obj; obj = dev_priv->fbdev->fb->obj;
if (obj == NULL) if (obj == NULL)
return NULL; return NULL;
fb = &dev_priv->fbdev->ifb.base; fb = &dev_priv->fbdev->fb->base;
if (fb->pitches[0] < intel_framebuffer_pitch_for_width(mode->hdisplay, if (fb->pitches[0] < intel_framebuffer_pitch_for_width(mode->hdisplay,
fb->bits_per_pixel)) fb->bits_per_pixel))
return NULL; return NULL;
......
...@@ -110,7 +110,7 @@ struct intel_framebuffer { ...@@ -110,7 +110,7 @@ struct intel_framebuffer {
struct intel_fbdev { struct intel_fbdev {
struct drm_fb_helper helper; struct drm_fb_helper helper;
struct intel_framebuffer ifb; struct intel_framebuffer *fb;
struct list_head fbdev_list; struct list_head fbdev_list;
struct drm_display_mode *our_mode; struct drm_display_mode *our_mode;
}; };
......
...@@ -62,11 +62,20 @@ static int intelfb_alloc(struct drm_fb_helper *helper, ...@@ -62,11 +62,20 @@ static int intelfb_alloc(struct drm_fb_helper *helper,
{ {
struct intel_fbdev *ifbdev = struct intel_fbdev *ifbdev =
container_of(helper, struct intel_fbdev, helper); container_of(helper, struct intel_fbdev, helper);
struct intel_framebuffer *fb;
struct drm_device *dev = helper->dev; struct drm_device *dev = helper->dev;
struct drm_mode_fb_cmd2 mode_cmd = {}; struct drm_mode_fb_cmd2 mode_cmd = {};
struct drm_i915_gem_object *obj; struct drm_i915_gem_object *obj;
int size, ret; int size, ret;
fb = kzalloc(sizeof(*fb), GFP_KERNEL);
if (!fb) {
ret = -ENOMEM;
goto out;
}
ifbdev->fb = fb;
/* we don't do packed 24bpp */ /* we don't do packed 24bpp */
if (sizes->surface_bpp == 24) if (sizes->surface_bpp == 24)
sizes->surface_bpp = 32; sizes->surface_bpp = 32;
...@@ -97,7 +106,7 @@ static int intelfb_alloc(struct drm_fb_helper *helper, ...@@ -97,7 +106,7 @@ static int intelfb_alloc(struct drm_fb_helper *helper,
goto out_unref; goto out_unref;
} }
ret = intel_framebuffer_init(dev, &ifbdev->ifb, &mode_cmd, obj); ret = intel_framebuffer_init(dev, ifbdev->fb, &mode_cmd, obj);
if (ret) if (ret)
goto out_unpin; goto out_unpin;
...@@ -116,7 +125,7 @@ static int intelfb_create(struct drm_fb_helper *helper, ...@@ -116,7 +125,7 @@ static int intelfb_create(struct drm_fb_helper *helper,
{ {
struct intel_fbdev *ifbdev = struct intel_fbdev *ifbdev =
container_of(helper, struct intel_fbdev, helper); container_of(helper, struct intel_fbdev, helper);
struct intel_framebuffer *intel_fb = &ifbdev->ifb; struct intel_framebuffer *intel_fb = ifbdev->fb;
struct drm_device *dev = helper->dev; struct drm_device *dev = helper->dev;
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
struct fb_info *info; struct fb_info *info;
...@@ -126,11 +135,12 @@ static int intelfb_create(struct drm_fb_helper *helper, ...@@ -126,11 +135,12 @@ static int intelfb_create(struct drm_fb_helper *helper,
mutex_lock(&dev->struct_mutex); mutex_lock(&dev->struct_mutex);
if (!intel_fb->obj) { if (!intel_fb || WARN_ON(!intel_fb->obj)) {
DRM_DEBUG_KMS("no BIOS fb, allocating a new one\n"); DRM_DEBUG_KMS("no BIOS fb, allocating a new one\n");
ret = intelfb_alloc(helper, sizes); ret = intelfb_alloc(helper, sizes);
if (ret) if (ret)
goto out_unlock; goto out_unlock;
intel_fb = ifbdev->fb;
} else { } else {
DRM_DEBUG_KMS("re-using BIOS fb\n"); DRM_DEBUG_KMS("re-using BIOS fb\n");
sizes->fb_width = intel_fb->base.width; sizes->fb_width = intel_fb->base.width;
...@@ -148,7 +158,7 @@ static int intelfb_create(struct drm_fb_helper *helper, ...@@ -148,7 +158,7 @@ static int intelfb_create(struct drm_fb_helper *helper,
info->par = helper; info->par = helper;
fb = &ifbdev->ifb.base; fb = &ifbdev->fb->base;
ifbdev->helper.fb = fb; ifbdev->helper.fb = fb;
ifbdev->helper.fbdev = info; ifbdev->helper.fbdev = info;
...@@ -194,7 +204,7 @@ static int intelfb_create(struct drm_fb_helper *helper, ...@@ -194,7 +204,7 @@ static int intelfb_create(struct drm_fb_helper *helper,
* If the object is stolen however, it will be full of whatever * If the object is stolen however, it will be full of whatever
* garbage was left in there. * garbage was left in there.
*/ */
if (ifbdev->ifb.obj->stolen) if (ifbdev->fb->obj->stolen)
memset_io(info->screen_base, 0, info->screen_size); memset_io(info->screen_base, 0, info->screen_size);
/* Use default scratch pixmap (info->pixmap.flags = FB_PIXMAP_SYSTEM) */ /* Use default scratch pixmap (info->pixmap.flags = FB_PIXMAP_SYSTEM) */
...@@ -258,8 +268,9 @@ static void intel_fbdev_destroy(struct drm_device *dev, ...@@ -258,8 +268,9 @@ static void intel_fbdev_destroy(struct drm_device *dev,
drm_fb_helper_fini(&ifbdev->helper); drm_fb_helper_fini(&ifbdev->helper);
drm_framebuffer_unregister_private(&ifbdev->ifb.base); drm_framebuffer_unregister_private(&ifbdev->fb->base);
intel_framebuffer_fini(&ifbdev->ifb); intel_framebuffer_fini(ifbdev->fb);
kfree(ifbdev->fb);
} }
int intel_fbdev_init(struct drm_device *dev) int intel_fbdev_init(struct drm_device *dev)
...@@ -322,7 +333,7 @@ void intel_fbdev_set_suspend(struct drm_device *dev, int state) ...@@ -322,7 +333,7 @@ void intel_fbdev_set_suspend(struct drm_device *dev, int state)
* been restored from swap. If the object is stolen however, it will be * been restored from swap. If the object is stolen however, it will be
* full of whatever garbage was left in there. * full of whatever garbage was left in there.
*/ */
if (state == FBINFO_STATE_RUNNING && ifbdev->ifb.obj->stolen) if (state == FBINFO_STATE_RUNNING && ifbdev->fb->obj->stolen)
memset_io(info->screen_base, 0, info->screen_size); memset_io(info->screen_base, 0, info->screen_size);
fb_set_suspend(info, state); fb_set_suspend(info, state);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment