diff options
author | Jesse Barnes <jbarnes@virtuousgeek.org> | 2014-02-07 15:10:38 -0500 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2014-02-12 12:52:55 -0500 |
commit | 8bcd45534ddf68ab71aeed709dacd9cf65dc0f75 (patch) | |
tree | a70584ebcef73813dba47693530af6b87098fe4f | |
parent | bd9b6a4ec5b963378d22d4ba41b5e61e0ecec9aa (diff) |
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: Jesse Barnes <jbarnes@virtuousgeek.org>
[danvet: WARN_ON if there's no backing storage attached to an fb,
that's a bug.]
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
-rw-r--r-- | drivers/gpu/drm/i915/intel_display.c | 4 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/intel_drv.h | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/intel_fbdev.c | 27 |
3 files changed, 22 insertions, 11 deletions
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index 807e815503d0..ac0f6b5cfdfa 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c | |||
@@ -7769,11 +7769,11 @@ mode_fits_in_fbdev(struct drm_device *dev, | |||
7769 | if (dev_priv->fbdev == NULL) | 7769 | if (dev_priv->fbdev == NULL) |
7770 | return NULL; | 7770 | return NULL; |
7771 | 7771 | ||
7772 | obj = dev_priv->fbdev->ifb.obj; | 7772 | obj = dev_priv->fbdev->fb->obj; |
7773 | if (obj == NULL) | 7773 | if (obj == NULL) |
7774 | return NULL; | 7774 | return NULL; |
7775 | 7775 | ||
7776 | fb = &dev_priv->fbdev->ifb.base; | 7776 | fb = &dev_priv->fbdev->fb->base; |
7777 | if (fb->pitches[0] < intel_framebuffer_pitch_for_width(mode->hdisplay, | 7777 | if (fb->pitches[0] < intel_framebuffer_pitch_for_width(mode->hdisplay, |
7778 | fb->bits_per_pixel)) | 7778 | fb->bits_per_pixel)) |
7779 | return NULL; | 7779 | return NULL; |
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h index 44067bce5e04..4386faf34a9b 100644 --- a/drivers/gpu/drm/i915/intel_drv.h +++ b/drivers/gpu/drm/i915/intel_drv.h | |||
@@ -110,7 +110,7 @@ struct intel_framebuffer { | |||
110 | 110 | ||
111 | struct intel_fbdev { | 111 | struct intel_fbdev { |
112 | struct drm_fb_helper helper; | 112 | struct drm_fb_helper helper; |
113 | struct intel_framebuffer ifb; | 113 | struct intel_framebuffer *fb; |
114 | struct list_head fbdev_list; | 114 | struct list_head fbdev_list; |
115 | struct drm_display_mode *our_mode; | 115 | struct drm_display_mode *our_mode; |
116 | }; | 116 | }; |
diff --git a/drivers/gpu/drm/i915/intel_fbdev.c b/drivers/gpu/drm/i915/intel_fbdev.c index d6a8a716018d..cd969c3c301e 100644 --- a/drivers/gpu/drm/i915/intel_fbdev.c +++ b/drivers/gpu/drm/i915/intel_fbdev.c | |||
@@ -62,11 +62,20 @@ static int intelfb_alloc(struct drm_fb_helper *helper, | |||
62 | { | 62 | { |
63 | struct intel_fbdev *ifbdev = | 63 | struct intel_fbdev *ifbdev = |
64 | container_of(helper, struct intel_fbdev, helper); | 64 | container_of(helper, struct intel_fbdev, helper); |
65 | struct intel_framebuffer *fb; | ||
65 | struct drm_device *dev = helper->dev; | 66 | struct drm_device *dev = helper->dev; |
66 | struct drm_mode_fb_cmd2 mode_cmd = {}; | 67 | struct drm_mode_fb_cmd2 mode_cmd = {}; |
67 | struct drm_i915_gem_object *obj; | 68 | struct drm_i915_gem_object *obj; |
68 | int size, ret; | 69 | int size, ret; |
69 | 70 | ||
71 | fb = kzalloc(sizeof(*fb), GFP_KERNEL); | ||
72 | if (!fb) { | ||
73 | ret = -ENOMEM; | ||
74 | goto out; | ||
75 | } | ||
76 | |||
77 | ifbdev->fb = fb; | ||
78 | |||
70 | /* we don't do packed 24bpp */ | 79 | /* we don't do packed 24bpp */ |
71 | if (sizes->surface_bpp == 24) | 80 | if (sizes->surface_bpp == 24) |
72 | sizes->surface_bpp = 32; | 81 | sizes->surface_bpp = 32; |
@@ -97,7 +106,7 @@ static int intelfb_alloc(struct drm_fb_helper *helper, | |||
97 | goto out_unref; | 106 | goto out_unref; |
98 | } | 107 | } |
99 | 108 | ||
100 | ret = intel_framebuffer_init(dev, &ifbdev->ifb, &mode_cmd, obj); | 109 | ret = intel_framebuffer_init(dev, ifbdev->fb, &mode_cmd, obj); |
101 | if (ret) | 110 | if (ret) |
102 | goto out_unpin; | 111 | goto out_unpin; |
103 | 112 | ||
@@ -116,7 +125,7 @@ static int intelfb_create(struct drm_fb_helper *helper, | |||
116 | { | 125 | { |
117 | struct intel_fbdev *ifbdev = | 126 | struct intel_fbdev *ifbdev = |
118 | container_of(helper, struct intel_fbdev, helper); | 127 | container_of(helper, struct intel_fbdev, helper); |
119 | struct intel_framebuffer *intel_fb = &ifbdev->ifb; | 128 | struct intel_framebuffer *intel_fb = ifbdev->fb; |
120 | struct drm_device *dev = helper->dev; | 129 | struct drm_device *dev = helper->dev; |
121 | struct drm_i915_private *dev_priv = dev->dev_private; | 130 | struct drm_i915_private *dev_priv = dev->dev_private; |
122 | struct fb_info *info; | 131 | struct fb_info *info; |
@@ -126,11 +135,12 @@ static int intelfb_create(struct drm_fb_helper *helper, | |||
126 | 135 | ||
127 | mutex_lock(&dev->struct_mutex); | 136 | mutex_lock(&dev->struct_mutex); |
128 | 137 | ||
129 | if (!intel_fb->obj) { | 138 | if (!intel_fb || WARN_ON(!intel_fb->obj)) { |
130 | DRM_DEBUG_KMS("no BIOS fb, allocating a new one\n"); | 139 | DRM_DEBUG_KMS("no BIOS fb, allocating a new one\n"); |
131 | ret = intelfb_alloc(helper, sizes); | 140 | ret = intelfb_alloc(helper, sizes); |
132 | if (ret) | 141 | if (ret) |
133 | goto out_unlock; | 142 | goto out_unlock; |
143 | intel_fb = ifbdev->fb; | ||
134 | } else { | 144 | } else { |
135 | DRM_DEBUG_KMS("re-using BIOS fb\n"); | 145 | DRM_DEBUG_KMS("re-using BIOS fb\n"); |
136 | sizes->fb_width = intel_fb->base.width; | 146 | sizes->fb_width = intel_fb->base.width; |
@@ -148,7 +158,7 @@ static int intelfb_create(struct drm_fb_helper *helper, | |||
148 | 158 | ||
149 | info->par = helper; | 159 | info->par = helper; |
150 | 160 | ||
151 | fb = &ifbdev->ifb.base; | 161 | fb = &ifbdev->fb->base; |
152 | 162 | ||
153 | ifbdev->helper.fb = fb; | 163 | ifbdev->helper.fb = fb; |
154 | ifbdev->helper.fbdev = info; | 164 | ifbdev->helper.fbdev = info; |
@@ -194,7 +204,7 @@ static int intelfb_create(struct drm_fb_helper *helper, | |||
194 | * If the object is stolen however, it will be full of whatever | 204 | * If the object is stolen however, it will be full of whatever |
195 | * garbage was left in there. | 205 | * garbage was left in there. |
196 | */ | 206 | */ |
197 | if (ifbdev->ifb.obj->stolen) | 207 | if (ifbdev->fb->obj->stolen) |
198 | memset_io(info->screen_base, 0, info->screen_size); | 208 | memset_io(info->screen_base, 0, info->screen_size); |
199 | 209 | ||
200 | /* Use default scratch pixmap (info->pixmap.flags = FB_PIXMAP_SYSTEM) */ | 210 | /* Use default scratch pixmap (info->pixmap.flags = FB_PIXMAP_SYSTEM) */ |
@@ -258,8 +268,9 @@ static void intel_fbdev_destroy(struct drm_device *dev, | |||
258 | 268 | ||
259 | drm_fb_helper_fini(&ifbdev->helper); | 269 | drm_fb_helper_fini(&ifbdev->helper); |
260 | 270 | ||
261 | drm_framebuffer_unregister_private(&ifbdev->ifb.base); | 271 | drm_framebuffer_unregister_private(&ifbdev->fb->base); |
262 | intel_framebuffer_fini(&ifbdev->ifb); | 272 | intel_framebuffer_fini(ifbdev->fb); |
273 | kfree(ifbdev->fb); | ||
263 | } | 274 | } |
264 | 275 | ||
265 | int intel_fbdev_init(struct drm_device *dev) | 276 | int intel_fbdev_init(struct drm_device *dev) |
@@ -322,7 +333,7 @@ void intel_fbdev_set_suspend(struct drm_device *dev, int state) | |||
322 | * been restored from swap. If the object is stolen however, it will be | 333 | * been restored from swap. If the object is stolen however, it will be |
323 | * full of whatever garbage was left in there. | 334 | * full of whatever garbage was left in there. |
324 | */ | 335 | */ |
325 | if (state == FBINFO_STATE_RUNNING && ifbdev->ifb.obj->stolen) | 336 | if (state == FBINFO_STATE_RUNNING && ifbdev->fb->obj->stolen) |
326 | memset_io(info->screen_base, 0, info->screen_size); | 337 | memset_io(info->screen_base, 0, info->screen_size); |
327 | 338 | ||
328 | fb_set_suspend(info, state); | 339 | fb_set_suspend(info, state); |