]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/rockchip: vop2: Simplify format_mod_supported
authorDaniel Stone <daniels@collabora.com>
Mon, 15 Dec 2025 14:09:24 +0000 (15:09 +0100)
committerHeiko Stuebner <heiko@sntech.de>
Thu, 8 Jan 2026 19:00:35 +0000 (20:00 +0100)
Make it a little less convoluted, and just directly check if the
combination of plane + format + modifier is supported.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Link: https://patch.msgid.link/20251215-vop2-atomic-fixups-v5-8-83463c075a8d@collabora.com
drivers/gpu/drm/rockchip/rockchip_drm_vop2.c

index 707b48c7e9d81a7ee49027097b340f91b00152cc..a0099e4dd4ea9756b0ff083d69aea7dd19b22449 100644 (file)
@@ -367,59 +367,47 @@ static bool is_yuv_output(u32 bus_format)
        }
 }
 
-static bool rockchip_afbc(struct drm_plane *plane, u64 modifier)
-{
-       int i;
-
-       if (modifier == DRM_FORMAT_MOD_LINEAR)
-               return false;
-
-       for (i = 0 ; i < plane->modifier_count; i++)
-               if (plane->modifiers[i] == modifier)
-                       return true;
-
-       return false;
-}
-
 static bool rockchip_vop2_mod_supported(struct drm_plane *plane, u32 format,
                                        u64 modifier)
 {
        struct vop2_win *win = to_vop2_win(plane);
        struct vop2 *vop2 = win->vop2;
+       int i;
 
+       /* No support for implicit modifiers */
        if (modifier == DRM_FORMAT_MOD_INVALID)
                return false;
 
-       if (vop2->version == VOP_VERSION_RK3568) {
-               if (vop2_cluster_window(win)) {
-                       if (modifier == DRM_FORMAT_MOD_LINEAR) {
-                               drm_dbg_kms(vop2->drm,
-                                           "Cluster window only supports format with afbc\n");
-                               return false;
-                       }
-               }
+       /* The cluster window on 3568 is AFBC-only */
+       if (vop2->version == VOP_VERSION_RK3568 && vop2_cluster_window(win) &&
+           !drm_is_afbc(modifier)) {
+               drm_dbg_kms(vop2->drm,
+                           "Cluster window only supports format with afbc\n");
+               return false;
        }
 
-       if (format == DRM_FORMAT_XRGB2101010 || format == DRM_FORMAT_XBGR2101010) {
-               if (vop2->version == VOP_VERSION_RK3588) {
-                       if (!rockchip_afbc(plane, modifier)) {
-                               drm_dbg_kms(vop2->drm, "Only support 32 bpp format with afbc\n");
-                               return false;
-                       }
-               }
+       /* 10bpc formats on 3588 are AFBC-only */
+       if (vop2->version == VOP_VERSION_RK3588 && !drm_is_afbc(modifier) &&
+           (format == DRM_FORMAT_XRGB2101010 || format == DRM_FORMAT_XBGR2101010)) {
+               drm_dbg_kms(vop2->drm, "Only support 10bpc format with afbc\n");
+               return false;
        }
 
+       /* Linear is otherwise supported everywhere */
        if (modifier == DRM_FORMAT_MOD_LINEAR)
                return true;
 
-       if (!rockchip_afbc(plane, modifier)) {
-               drm_dbg_kms(vop2->drm, "Unsupported format modifier 0x%llx\n",
-                           modifier);
-
+       /* Not all format+modifier combinations are allowable */
+       if (vop2_convert_afbc_format(format) == VOP2_AFBC_FMT_INVALID)
                return false;
+
+       /* Different windows have different format/modifier support */
+       for (i = 0; i < plane->modifier_count; i++) {
+               if (plane->modifiers[i] == modifier)
+                       return true;
        }
 
-       return vop2_convert_afbc_format(format) >= 0;
+       return false;
 }
 
 /*