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

drm/rockchip: Use drm_gem_fb_create_with_dirty

If rockchip would switch over to the generic fbdev setup we could
grabage collect even more of all this code (all of the remaining fb
handling code really).

v2: Actually use _with_dirty like the patch subject promised (Andrzej)

Cc: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
Reviewed-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Sandy Huang <hjc@rock-chips.com>
Cc: "Heiko Stübner" <heiko@sntech.de>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-rockchip@lists.infradead.org
Link: https://patchwork.freedesktop.org/patch/msgid/20191127180035.416209-1-daniel.vetter@ffwll.ch

+1 -53
+1 -53
drivers/gpu/drm/rockchip/rockchip_drm_fb.c
··· 53 53 return fb; 54 54 } 55 55 56 - static struct drm_framebuffer * 57 - rockchip_user_fb_create(struct drm_device *dev, struct drm_file *file_priv, 58 - const struct drm_mode_fb_cmd2 *mode_cmd) 59 - { 60 - const struct drm_format_info *info = drm_get_format_info(dev, 61 - mode_cmd); 62 - struct drm_framebuffer *fb; 63 - struct drm_gem_object *objs[ROCKCHIP_MAX_FB_BUFFER]; 64 - struct drm_gem_object *obj; 65 - int num_planes = min_t(int, info->num_planes, ROCKCHIP_MAX_FB_BUFFER); 66 - int ret; 67 - int i; 68 - 69 - for (i = 0; i < num_planes; i++) { 70 - unsigned int width = mode_cmd->width / (i ? info->hsub : 1); 71 - unsigned int height = mode_cmd->height / (i ? info->vsub : 1); 72 - unsigned int min_size; 73 - 74 - obj = drm_gem_object_lookup(file_priv, mode_cmd->handles[i]); 75 - if (!obj) { 76 - DRM_DEV_ERROR(dev->dev, 77 - "Failed to lookup GEM object\n"); 78 - ret = -ENXIO; 79 - goto err_gem_object_unreference; 80 - } 81 - 82 - min_size = (height - 1) * mode_cmd->pitches[i] + 83 - mode_cmd->offsets[i] + 84 - width * info->cpp[i]; 85 - 86 - if (obj->size < min_size) { 87 - drm_gem_object_put_unlocked(obj); 88 - ret = -EINVAL; 89 - goto err_gem_object_unreference; 90 - } 91 - objs[i] = obj; 92 - } 93 - 94 - fb = rockchip_fb_alloc(dev, mode_cmd, objs, i); 95 - if (IS_ERR(fb)) { 96 - ret = PTR_ERR(fb); 97 - goto err_gem_object_unreference; 98 - } 99 - 100 - return fb; 101 - 102 - err_gem_object_unreference: 103 - for (i--; i >= 0; i--) 104 - drm_gem_object_put_unlocked(objs[i]); 105 - return ERR_PTR(ret); 106 - } 107 - 108 56 static const struct drm_mode_config_helper_funcs rockchip_mode_config_helpers = { 109 57 .atomic_commit_tail = drm_atomic_helper_commit_tail_rpm, 110 58 }; 111 59 112 60 static const struct drm_mode_config_funcs rockchip_drm_mode_config_funcs = { 113 - .fb_create = rockchip_user_fb_create, 61 + .fb_create = drm_gem_fb_create_with_dirty, 114 62 .output_poll_changed = drm_fb_helper_output_poll_changed, 115 63 .atomic_check = drm_atomic_helper_check, 116 64 .atomic_commit = drm_atomic_helper_commit,