]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
drm: Trust format_mod_supported() when it OKs a plane modifier.
authorEric Anholt <eric@anholt.net>
Fri, 16 Mar 2018 22:04:33 +0000 (15:04 -0700)
committerEric Anholt <eric@anholt.net>
Thu, 31 May 2018 18:19:04 +0000 (11:19 -0700)
For parameterized modifiers (Broadcom's SAND and UIF), we need to
allow the parameter fields to be filled in, while exposing only the
variant of the modifier with the parameter unfilled in the internal
arrays and the format blob.

Signed-off-by: Eric Anholt <eric@anholt.net>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180316220435.31416-1-eric@anholt.net
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
drivers/gpu/drm/drm_plane.c
include/drm/drm_plane.h

index 0350544553010c374c122af5093d7d93aac95e4e..7ce88dff871d7769aa441e9c32a248439d85b7bd 100644 (file)
@@ -561,19 +561,20 @@ int drm_plane_check_pixel_format(struct drm_plane *plane,
        if (i == plane->format_count)
                return -EINVAL;
 
-       if (!plane->modifier_count)
-               return 0;
+       if (plane->funcs->format_mod_supported) {
+               if (!plane->funcs->format_mod_supported(plane, format, modifier))
+                       return -EINVAL;
+       } else {
+               if (!plane->modifier_count)
+                       return 0;
 
-       for (i = 0; i < plane->modifier_count; i++) {
-               if (modifier == plane->modifiers[i])
-                       break;
+               for (i = 0; i < plane->modifier_count; i++) {
+                       if (modifier == plane->modifiers[i])
+                               break;
+               }
+               if (i == plane->modifier_count)
+                       return -EINVAL;
        }
-       if (i == plane->modifier_count)
-               return -EINVAL;
-
-       if (plane->funcs->format_mod_supported &&
-           !plane->funcs->format_mod_supported(plane, format, modifier))
-               return -EINVAL;
 
        return 0;
 }
index 26fa50c2a50e8cf88c7e5ad6e344ac0ba19de18c..14b1607aba4bb464fae1ebe8fd9eb4b0c971c670 100644 (file)
@@ -431,7 +431,10 @@ struct drm_plane_funcs {
         * This optional hook is used for the DRM to determine if the given
         * format/modifier combination is valid for the plane. This allows the
         * DRM to generate the correct format bitmask (which formats apply to
-        * which modifier).
+        * which modifier), and to valdiate modifiers at atomic_check time.
+        *
+        * If not present, then any modifier in the plane's modifier
+        * list is allowed with any of the plane's formats.
         *
         * Returns:
         *