Merge v5.2-rc5 into drm-next
[sfrench/cifs-2.6.git] / drivers / gpu / drm / rockchip / rockchip_drm_fb.c
index 1c69066b68947d66cebde76f4030713eb44fb2e9..64ca87cf6d50a0193fbeb3b6bd5d53ec6e89c7f3 100644 (file)
@@ -8,6 +8,7 @@
 #include <drm/drm.h>
 #include <drm/drmP.h>
 #include <drm/drm_atomic.h>
+#include <drm/drm_damage_helper.h>
 #include <drm/drm_fb_helper.h>
 #include <drm/drm_gem_framebuffer_helper.h>
 #include <drm/drm_probe_helper.h>
 #include "rockchip_drm_gem.h"
 #include "rockchip_drm_psr.h"
 
-static int rockchip_drm_fb_dirty(struct drm_framebuffer *fb,
-                                struct drm_file *file,
-                                unsigned int flags, unsigned int color,
-                                struct drm_clip_rect *clips,
-                                unsigned int num_clips)
-{
-       rockchip_drm_psr_flush_all(fb->dev);
-       return 0;
-}
-
 static const struct drm_framebuffer_funcs rockchip_drm_fb_funcs = {
        .destroy       = drm_gem_fb_destroy,
        .create_handle = drm_gem_fb_create_handle,
-       .dirty         = rockchip_drm_fb_dirty,
+       .dirty         = drm_atomic_helper_dirtyfb,
 };
 
 static struct drm_framebuffer *
@@ -66,23 +57,18 @@ static struct drm_framebuffer *
 rockchip_user_fb_create(struct drm_device *dev, struct drm_file *file_priv,
                        const struct drm_mode_fb_cmd2 *mode_cmd)
 {
+       const struct drm_format_info *info = drm_get_format_info(dev,
+                                                                mode_cmd);
        struct drm_framebuffer *fb;
        struct drm_gem_object *objs[ROCKCHIP_MAX_FB_BUFFER];
        struct drm_gem_object *obj;
-       unsigned int hsub;
-       unsigned int vsub;
-       int num_planes;
+       int num_planes = min_t(int, info->num_planes, ROCKCHIP_MAX_FB_BUFFER);
        int ret;
        int i;
 
-       hsub = drm_format_horz_chroma_subsampling(mode_cmd->pixel_format);
-       vsub = drm_format_vert_chroma_subsampling(mode_cmd->pixel_format);
-       num_planes = min(drm_format_num_planes(mode_cmd->pixel_format),
-                        ROCKCHIP_MAX_FB_BUFFER);
-
        for (i = 0; i < num_planes; i++) {
-               unsigned int width = mode_cmd->width / (i ? hsub : 1);
-               unsigned int height = mode_cmd->height / (i ? vsub : 1);
+               unsigned int width = mode_cmd->width / (i ? info->hsub : 1);
+               unsigned int height = mode_cmd->height / (i ? info->vsub : 1);
                unsigned int min_size;
 
                obj = drm_gem_object_lookup(file_priv, mode_cmd->handles[i]);
@@ -95,7 +81,7 @@ rockchip_user_fb_create(struct drm_device *dev, struct drm_file *file_priv,
 
                min_size = (height - 1) * mode_cmd->pitches[i] +
                        mode_cmd->offsets[i] +
-                       width * drm_format_plane_cpp(mode_cmd->pixel_format, i);
+                       width * info->cpp[i];
 
                if (obj->size < min_size) {
                        drm_gem_object_put_unlocked(obj);