aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
diff options
context:
space:
mode:
authorArchit Taneja <architt@codeaurora.org>2015-07-31 06:52:00 -0400
committerDaniel Vetter <daniel.vetter@ffwll.ch>2015-08-06 08:13:06 -0400
commit2dbaf392d27e8072268595fba557cbe4f4d43f01 (patch)
treee3f3d1978ceee98cd793269e422e56e760b8ca4b /drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
parent6a752972a33f7763453134a09ed8091bbeea55fc (diff)
drm/amdgpu: Use new drm_fb_helper functions
Use the newly created wrapper drm_fb_helper functions instead of calling core fbdev functions directly. They also simplify the fb_info creation. v3: - Don't touch remove_conflicting_framebuffers v2: - Fixed PTR_ERR issue mentioned by kbuild bot Cc: Fengguang Wu <fengguang.wu@intel.com> Cc: Alex Deucher <alexander.deucher@amd.com> Cc: Oded Gabbay <oded.gabbay@gmail.com> Cc: "Christian König" <christian.koenig@amd.com> Signed-off-by: Archit Taneja <architt@codeaurora.org> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c45
1 files changed, 14 insertions, 31 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
index c1645d21f8e2..81b821247dde 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
@@ -53,9 +53,9 @@ static struct fb_ops amdgpufb_ops = {
53 .owner = THIS_MODULE, 53 .owner = THIS_MODULE,
54 .fb_check_var = drm_fb_helper_check_var, 54 .fb_check_var = drm_fb_helper_check_var,
55 .fb_set_par = drm_fb_helper_set_par, 55 .fb_set_par = drm_fb_helper_set_par,
56 .fb_fillrect = cfb_fillrect, 56 .fb_fillrect = drm_fb_helper_cfb_fillrect,
57 .fb_copyarea = cfb_copyarea, 57 .fb_copyarea = drm_fb_helper_cfb_copyarea,
58 .fb_imageblit = cfb_imageblit, 58 .fb_imageblit = drm_fb_helper_cfb_imageblit,
59 .fb_pan_display = drm_fb_helper_pan_display, 59 .fb_pan_display = drm_fb_helper_pan_display,
60 .fb_blank = drm_fb_helper_blank, 60 .fb_blank = drm_fb_helper_blank,
61 .fb_setcmap = drm_fb_helper_setcmap, 61 .fb_setcmap = drm_fb_helper_setcmap,
@@ -179,7 +179,6 @@ static int amdgpufb_create(struct drm_fb_helper *helper,
179 struct drm_mode_fb_cmd2 mode_cmd; 179 struct drm_mode_fb_cmd2 mode_cmd;
180 struct drm_gem_object *gobj = NULL; 180 struct drm_gem_object *gobj = NULL;
181 struct amdgpu_bo *rbo = NULL; 181 struct amdgpu_bo *rbo = NULL;
182 struct device *device = &adev->pdev->dev;
183 int ret; 182 int ret;
184 unsigned long tmp; 183 unsigned long tmp;
185 184
@@ -201,9 +200,9 @@ static int amdgpufb_create(struct drm_fb_helper *helper,
201 rbo = gem_to_amdgpu_bo(gobj); 200 rbo = gem_to_amdgpu_bo(gobj);
202 201
203 /* okay we have an object now allocate the framebuffer */ 202 /* okay we have an object now allocate the framebuffer */
204 info = framebuffer_alloc(0, device); 203 info = drm_fb_helper_alloc_fbi(helper);
205 if (info == NULL) { 204 if (IS_ERR(info)) {
206 ret = -ENOMEM; 205 ret = PTR_ERR(info);
207 goto out_unref; 206 goto out_unref;
208 } 207 }
209 208
@@ -212,14 +211,13 @@ static int amdgpufb_create(struct drm_fb_helper *helper,
212 ret = amdgpu_framebuffer_init(adev->ddev, &rfbdev->rfb, &mode_cmd, gobj); 211 ret = amdgpu_framebuffer_init(adev->ddev, &rfbdev->rfb, &mode_cmd, gobj);
213 if (ret) { 212 if (ret) {
214 DRM_ERROR("failed to initialize framebuffer %d\n", ret); 213 DRM_ERROR("failed to initialize framebuffer %d\n", ret);
215 goto out_unref; 214 goto out_destroy_fbi;
216 } 215 }
217 216
218 fb = &rfbdev->rfb.base; 217 fb = &rfbdev->rfb.base;
219 218
220 /* setup helper */ 219 /* setup helper */
221 rfbdev->helper.fb = fb; 220 rfbdev->helper.fb = fb;
222 rfbdev->helper.fbdev = info;
223 221
224 memset_io(rbo->kptr, 0x0, amdgpu_bo_size(rbo)); 222 memset_io(rbo->kptr, 0x0, amdgpu_bo_size(rbo));
225 223
@@ -239,11 +237,6 @@ static int amdgpufb_create(struct drm_fb_helper *helper,
239 drm_fb_helper_fill_var(info, &rfbdev->helper, sizes->fb_width, sizes->fb_height); 237 drm_fb_helper_fill_var(info, &rfbdev->helper, sizes->fb_width, sizes->fb_height);
240 238
241 /* setup aperture base/size for vesafb takeover */ 239 /* setup aperture base/size for vesafb takeover */
242 info->apertures = alloc_apertures(1);
243 if (!info->apertures) {
244 ret = -ENOMEM;
245 goto out_unref;
246 }
247 info->apertures->ranges[0].base = adev->ddev->mode_config.fb_base; 240 info->apertures->ranges[0].base = adev->ddev->mode_config.fb_base;
248 info->apertures->ranges[0].size = adev->mc.aper_size; 241 info->apertures->ranges[0].size = adev->mc.aper_size;
249 242
@@ -251,13 +244,7 @@ static int amdgpufb_create(struct drm_fb_helper *helper,
251 244
252 if (info->screen_base == NULL) { 245 if (info->screen_base == NULL) {
253 ret = -ENOSPC; 246 ret = -ENOSPC;
254 goto out_unref; 247 goto out_destroy_fbi;
255 }
256
257 ret = fb_alloc_cmap(&info->cmap, 256, 0);
258 if (ret) {
259 ret = -ENOMEM;
260 goto out_unref;
261 } 248 }
262 249
263 DRM_INFO("fb mappable at 0x%lX\n", info->fix.smem_start); 250 DRM_INFO("fb mappable at 0x%lX\n", info->fix.smem_start);
@@ -269,6 +256,8 @@ static int amdgpufb_create(struct drm_fb_helper *helper,
269 vga_switcheroo_client_fb_set(adev->ddev->pdev, info); 256 vga_switcheroo_client_fb_set(adev->ddev->pdev, info);
270 return 0; 257 return 0;
271 258
259out_destroy_fbi:
260 drm_fb_helper_release_fbi(helper);
272out_unref: 261out_unref:
273 if (rbo) { 262 if (rbo) {
274 263
@@ -290,17 +279,10 @@ void amdgpu_fb_output_poll_changed(struct amdgpu_device *adev)
290 279
291static int amdgpu_fbdev_destroy(struct drm_device *dev, struct amdgpu_fbdev *rfbdev) 280static int amdgpu_fbdev_destroy(struct drm_device *dev, struct amdgpu_fbdev *rfbdev)
292{ 281{
293 struct fb_info *info;
294 struct amdgpu_framebuffer *rfb = &rfbdev->rfb; 282 struct amdgpu_framebuffer *rfb = &rfbdev->rfb;
295 283
296 if (rfbdev->helper.fbdev) { 284 drm_fb_helper_unregister_fbi(&rfbdev->helper);
297 info = rfbdev->helper.fbdev; 285 drm_fb_helper_release_fbi(&rfbdev->helper);
298
299 unregister_framebuffer(info);
300 if (info->cmap.len)
301 fb_dealloc_cmap(&info->cmap);
302 framebuffer_release(info);
303 }
304 286
305 if (rfb->obj) { 287 if (rfb->obj) {
306 amdgpufb_destroy_pinned_object(rfb->obj); 288 amdgpufb_destroy_pinned_object(rfb->obj);
@@ -395,7 +377,8 @@ void amdgpu_fbdev_fini(struct amdgpu_device *adev)
395void amdgpu_fbdev_set_suspend(struct amdgpu_device *adev, int state) 377void amdgpu_fbdev_set_suspend(struct amdgpu_device *adev, int state)
396{ 378{
397 if (adev->mode_info.rfbdev) 379 if (adev->mode_info.rfbdev)
398 fb_set_suspend(adev->mode_info.rfbdev->helper.fbdev, state); 380 drm_fb_helper_set_suspend(&adev->mode_info.rfbdev->helper,
381 state);
399} 382}
400 383
401int amdgpu_fbdev_total_size(struct amdgpu_device *adev) 384int amdgpu_fbdev_total_size(struct amdgpu_device *adev)