]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
drm: Check that the plane supports the request format+modifier combo
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Fri, 22 Dec 2017 19:22:30 +0000 (21:22 +0200)
committerVille Syrjälä <ville.syrjala@linux.intel.com>
Mon, 26 Feb 2018 14:29:47 +0000 (16:29 +0200)
Currently we only check that the plane supports the pixel format of the
fb we're about to feed to it. Extend it to check also the modifier, and
more specifically that the combination of the format and modifier is
supported.

Cc: dri-devel@lists.freedesktop.org
Cc: Ben Widawsky <ben@bwidawsk.net>
Cc: Jason Ekstrand <jason@jlekstrand.net>
Cc: Daniel Stone <daniels@collabora.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20171222192231.17981-8-ville.syrjala@linux.intel.com
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/drm_atomic.c
drivers/gpu/drm/drm_crtc.c
drivers/gpu/drm/drm_crtc_internal.h
drivers/gpu/drm/drm_plane.c

index 46733d534587bc15be02b225f7e092f16af1d645..3a30ee715752a6e73431df40d85605b6c7ec676f 100644 (file)
@@ -882,12 +882,14 @@ static int drm_atomic_plane_check(struct drm_plane *plane,
        }
 
        /* Check whether this plane supports the fb pixel format. */
-       ret = drm_plane_check_pixel_format(plane, state->fb->format->format);
+       ret = drm_plane_check_pixel_format(plane, state->fb->format->format,
+                                          state->fb->modifier);
        if (ret) {
                struct drm_format_name_buf format_name;
-               DRM_DEBUG_ATOMIC("Invalid pixel format %s\n",
-                                drm_get_format_name(state->fb->format->format,
-                                                    &format_name));
+               DRM_DEBUG_ATOMIC("Invalid pixel format %s, modifier 0x%llx\n",
+                                drm_get_format_name(state->fb->format->format,
+                                                    &format_name),
+                                state->fb->modifier);
                return ret;
        }
 
index 353e24fcde9e9b5cbbec60174615e30352b71601..03583887cfec323628ee9723ee1be8b275bc37ef 100644 (file)
@@ -629,12 +629,14 @@ retry:
                 */
                if (!crtc->primary->format_default) {
                        ret = drm_plane_check_pixel_format(crtc->primary,
-                                                          fb->format->format);
+                                                          fb->format->format,
+                                                          fb->modifier);
                        if (ret) {
                                struct drm_format_name_buf format_name;
-                               DRM_DEBUG_KMS("Invalid pixel format %s\n",
-                                             drm_get_format_name(fb->format->format,
-                                                                 &format_name));
+                               DRM_DEBUG_KMS("Invalid pixel format %s, modifier 0x%llx\n",
+                                             drm_get_format_name(fb->format->format,
+                                                                 &format_name),
+                                             fb->modifier);
                                goto out;
                        }
                }
index af00f42ba269b0da3111ac5be480688815875da8..860968a64ae7777addaccbffa039ef13bf82b8ac 100644 (file)
@@ -196,8 +196,8 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,
 /* drm_plane.c */
 int drm_plane_register_all(struct drm_device *dev);
 void drm_plane_unregister_all(struct drm_device *dev);
-int drm_plane_check_pixel_format(const struct drm_plane *plane,
-                                u32 format);
+int drm_plane_check_pixel_format(struct drm_plane *plane,
+                                u32 format, u64 modifier);
 
 /* drm_bridge.c */
 void drm_bridge_detach(struct drm_bridge *bridge);
index 22b54663b6e7e6aa69f81accda0971ceb698af17..46fbd019a3377ee1c916e2a73e0428b68a52bd83 100644 (file)
@@ -549,16 +549,33 @@ int drm_mode_getplane(struct drm_device *dev, void *data,
        return 0;
 }
 
-int drm_plane_check_pixel_format(const struct drm_plane *plane, u32 format)
+int drm_plane_check_pixel_format(struct drm_plane *plane,
+                                u32 format, u64 modifier)
 {
        unsigned int i;
 
        for (i = 0; i < plane->format_count; i++) {
                if (format == plane->format_types[i])
-                       return 0;
+                       break;
+       }
+       if (i == plane->format_count)
+               return -EINVAL;
+
+       if (!plane->modifier_count)
+               return 0;
+
+       for (i = 0; i < plane->modifier_count; i++) {
+               if (modifier == plane->modifiers[i])
+                       break;
        }
+       if (i == plane->modifier_count)
+               return -EINVAL;
 
-       return -EINVAL;
+       if (plane->funcs->format_mod_supported &&
+           !plane->funcs->format_mod_supported(plane, format, modifier))
+               return -EINVAL;
+
+       return 0;
 }
 
 /*
@@ -602,12 +619,14 @@ static int __setplane_internal(struct drm_plane *plane,
        }
 
        /* Check whether this plane supports the fb pixel format. */
-       ret = drm_plane_check_pixel_format(plane, fb->format->format);
+       ret = drm_plane_check_pixel_format(plane, fb->format->format,
+                                          fb->modifier);
        if (ret) {
                struct drm_format_name_buf format_name;
-               DRM_DEBUG_KMS("Invalid pixel format %s\n",
-                             drm_get_format_name(fb->format->format,
-                                                 &format_name));
+               DRM_DEBUG_KMS("Invalid pixel format %s, modifier 0x%llx\n",
+                             drm_get_format_name(fb->format->format,
+                                                 &format_name),
+                             fb->modifier);
                goto out;
        }