Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/rockchip: 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.

This is an effort to create a top level drm fbdev emulation option.

Cc: Mark Yao <mark.yao@rock-chips.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Rob Clark <robdclark@gmail.com>
Cc: Daniel Kurtz <djkurtz@chromium.org>

Signed-off-by: Archit Taneja <architt@codeaurora.org>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>

authored by

Archit Taneja and committed by
Daniel Vetter
df3b031c fdefa58a

+12 -35
+12 -35
drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c
··· 37 37 static struct fb_ops rockchip_drm_fbdev_ops = { 38 38 .owner = THIS_MODULE, 39 39 .fb_mmap = rockchip_fbdev_mmap, 40 - .fb_fillrect = cfb_fillrect, 41 - .fb_copyarea = cfb_copyarea, 42 - .fb_imageblit = cfb_imageblit, 40 + .fb_fillrect = drm_fb_helper_cfb_fillrect, 41 + .fb_copyarea = drm_fb_helper_cfb_copyarea, 42 + .fb_imageblit = drm_fb_helper_cfb_imageblit, 43 43 .fb_check_var = drm_fb_helper_check_var, 44 44 .fb_set_par = drm_fb_helper_set_par, 45 45 .fb_blank = drm_fb_helper_blank, ··· 77 77 78 78 private->fbdev_bo = &rk_obj->base; 79 79 80 - fbi = framebuffer_alloc(0, dev->dev); 81 - if (!fbi) { 82 - dev_err(dev->dev, "Failed to allocate framebuffer info.\n"); 83 - ret = -ENOMEM; 80 + fbi = drm_fb_helper_alloc_fbi(helper); 81 + if (IS_ERR(fbi)) { 82 + dev_err(dev->dev, "Failed to create framebuffer info.\n"); 83 + ret = PTR_ERR(fbi); 84 84 goto err_rockchip_gem_free_object; 85 85 } 86 86 ··· 89 89 if (IS_ERR(helper->fb)) { 90 90 dev_err(dev->dev, "Failed to allocate DRM framebuffer.\n"); 91 91 ret = PTR_ERR(helper->fb); 92 - goto err_framebuffer_release; 92 + goto err_release_fbi; 93 93 } 94 - 95 - helper->fbdev = fbi; 96 94 97 95 fbi->par = helper; 98 96 fbi->flags = FBINFO_FLAG_DEFAULT; 99 97 fbi->fbops = &rockchip_drm_fbdev_ops; 100 - 101 - ret = fb_alloc_cmap(&fbi->cmap, 256, 0); 102 - if (ret) { 103 - dev_err(dev->dev, "Failed to allocate color map.\n"); 104 - goto err_drm_framebuffer_unref; 105 - } 106 98 107 99 fb = helper->fb; 108 100 drm_fb_helper_fill_fix(fbi, fb->pitches[0], fb->depth); ··· 116 124 117 125 return 0; 118 126 119 - err_drm_framebuffer_unref: 120 - drm_framebuffer_unreference(helper->fb); 121 - err_framebuffer_release: 122 - framebuffer_release(fbi); 127 + err_release_fbi: 128 + drm_fb_helper_release_fbi(helper); 123 129 err_rockchip_gem_free_object: 124 130 rockchip_gem_free_object(&rk_obj->base); 125 131 return ret; ··· 180 190 181 191 helper = &private->fbdev_helper; 182 192 183 - if (helper->fbdev) { 184 - struct fb_info *info; 185 - int ret; 186 - 187 - info = helper->fbdev; 188 - ret = unregister_framebuffer(info); 189 - if (ret < 0) 190 - DRM_DEBUG_KMS("failed unregister_framebuffer() - %d\n", 191 - ret); 192 - 193 - if (info->cmap.len) 194 - fb_dealloc_cmap(&info->cmap); 195 - 196 - framebuffer_release(info); 197 - } 193 + drm_fb_helper_unregister_fbi(helper); 194 + drm_fb_helper_release_fbi(helper); 198 195 199 196 if (helper->fb) 200 197 drm_framebuffer_unreference(helper->fb);