backend-drm: allow to disable GBM modifiers
authorStefan Agner <stefan@agner.ch>
Wed, 17 Jun 2020 21:36:44 +0000 (23:36 +0200)
committerDaniel Stone <daniels@collabora.com>
Mon, 17 Aug 2020 10:17:30 +0000 (10:17 +0000)
Allow to disable GBM modifiers at runtime using the environment variable
WESTON_DISABLE_GBM_MODIFIERS.

This can be useful for debugging or when modifiers cause issues, e.g. in
case modifiers use higher memory bandwidth and hence impose a lower
resolution limit as it is the case with Intel Kaby Lake graphics.

Related to: https://gitlab.freedesktop.org/wayland/weston/-/issues/404
Signed-off-by: Stefan Agner <stefan@agner.ch>
libweston/backend-drm/drm-internal.h
libweston/backend-drm/drm.c
libweston/backend-drm/kms.c

index 7ece756dcb703d282fa05ae10874a3fbdacc7950..06f952f22d15a307c2a703e665e9a96d178af71a 100644 (file)
@@ -634,7 +634,8 @@ drm_property_get_range_values(struct drm_property_info *info,
                              const drmModeObjectProperties *props);
 int
 drm_plane_populate_formats(struct drm_plane *plane, const drmModePlane *kplane,
-                          const drmModeObjectProperties *props);
+                          const drmModeObjectProperties *props,
+                          const bool use_modifiers);
 void
 drm_property_info_free(struct drm_property_info *info, int num_props);
 
index 83993da5a98712c1cbe2e900aa9e00ca5a309b97..980a12da6030cbed72528b46c2e12f27968b8f88 100644 (file)
@@ -808,7 +808,8 @@ drm_plane_create(struct drm_backend *b, const drmModePlane *kplane,
                        plane->zpos_max = DRM_PLANE_ZPOS_INVALID_PLANE;
                }
 
-               if (drm_plane_populate_formats(plane, kplane, props) < 0) {
+               if (drm_plane_populate_formats(plane, kplane, props,
+                                              b->fb_modifiers) < 0) {
                        drmModeFreeObjectProperties(props);
                        goto err;
                }
index f5215f20d694aeedf6168edcb295ed2786d71614..c91e381034ea8e555796373bc2f9ead2c332358c 100644 (file)
@@ -434,7 +434,8 @@ modifiers_ptr(struct drm_format_modifier_blob *blob)
  */
 int
 drm_plane_populate_formats(struct drm_plane *plane, const drmModePlane *kplane,
-                          const drmModeObjectProperties *props)
+                          const drmModeObjectProperties *props,
+                          const bool use_modifiers)
 {
        unsigned i;
        drmModePropertyBlobRes *blob;
@@ -443,6 +444,9 @@ drm_plane_populate_formats(struct drm_plane *plane, const drmModePlane *kplane,
        uint32_t *blob_formats;
        uint32_t blob_id;
 
+       if (!use_modifiers)
+               goto fallback;
+
        blob_id = drm_property_get_value(&plane->props[WDRM_PLANE_IN_FORMATS],
                                         props,
                                         0);
@@ -1474,11 +1478,13 @@ init_kms_caps(struct drm_backend *b)
        weston_log("DRM: %s atomic modesetting\n",
                   b->atomic_modeset ? "supports" : "does not support");
 
-       ret = drmGetCap(b->drm.fd, DRM_CAP_ADDFB2_MODIFIERS, &cap);
-       if (ret == 0)
-               b->fb_modifiers = cap;
-       else
-               b->fb_modifiers = 0;
+       if (!getenv("WESTON_DISABLE_GBM_MODIFIERS")) {
+               ret = drmGetCap(b->drm.fd, DRM_CAP_ADDFB2_MODIFIERS, &cap);
+               if (ret == 0)
+                       b->fb_modifiers = cap;
+       }
+       weston_log("DRM: %s GBM modifiers\n",
+                  b->fb_modifiers ? "supports" : "does not support");
 
        /*
         * KMS support for hardware planes cannot properly synchronize