OSDN Git Service

minigbm: add buffer bandwidth compression flag to gbm device
authorPilar Molina Lopez <pmolinalopez@google.com>
Thu, 12 Nov 2020 23:19:42 +0000 (18:19 -0500)
committerCommit Bot <commit-bot@chromium.org>
Fri, 4 Dec 2020 20:12:34 +0000 (20:12 +0000)
Read MINIGBM_DEBUG env var when creating a gbm driver
Store value as a flag inside driver
Avoid allocating compressed buffers in the backends
when the flag disables compression

BUG=b:172215587

Change-Id: Idbd6f0aebc1782c1bf5921a6438310a87212d1f8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2535658
Tested-by: Pilar Molina Lopez <pmolinalopez@google.com>
Commit-Queue: Pilar Molina Lopez <pmolinalopez@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Kristian H. Kristensen <hoegsberg@chromium.org>
drv.c
drv_priv.h
i915.c
msm.c
rockchip.c

diff --git a/drv.c b/drv.c
index 10e8f8d..233cce7 100644 (file)
--- a/drv.c
+++ b/drv.c
@@ -128,6 +128,10 @@ struct driver *drv_create(int fd)
        if (!drv)
                return NULL;
 
+       char *minigbm_debug;
+       minigbm_debug = getenv("MINIGBM_DEBUG");
+       drv->compression = (minigbm_debug == NULL) || (strcmp(minigbm_debug, "nocompression") != 0);
+
        drv->fd = fd;
        drv->backend = drv_get_backend(fd);
 
index d918b33..6ce7fa1 100644 (file)
@@ -57,6 +57,7 @@ struct driver {
        struct drv_array *mappings;
        struct drv_array *combos;
        pthread_mutex_t driver_lock;
+       bool compression;
 };
 
 struct backend {
diff --git a/i915.c b/i915.c
index 723d009..b45cbfe 100644 (file)
--- a/i915.c
+++ b/i915.c
@@ -353,6 +353,22 @@ static int i915_bo_compute_metadata(struct bo *bo, uint32_t width, uint32_t heig
                        modifier = I915_FORMAT_MOD_X_TILED;
        }
 
+       /*
+        * Skip I915_FORMAT_MOD_Y_TILED_CCS modifier if compression is disabled
+        * Pick y tiled modifier if it has been passed in, otherwise use linear
+        */
+       if (!bo->drv->compression && modifier == I915_FORMAT_MOD_Y_TILED_CCS) {
+               uint32_t i;
+               for (i = 0; modifiers && i < count; i++) {
+                       if (modifiers[i] == I915_FORMAT_MOD_Y_TILED)
+                               break;
+               }
+               if (i == count)
+                       modifier = DRM_FORMAT_MOD_LINEAR;
+               else
+                       modifier = I915_FORMAT_MOD_Y_TILED;
+       }
+
        switch (modifier) {
        case DRM_FORMAT_MOD_LINEAR:
                bo->meta.tiling = I915_TILING_NONE;
diff --git a/msm.c b/msm.c
index 033dda5..acfc1ef 100644 (file)
--- a/msm.c
+++ b/msm.c
@@ -250,7 +250,7 @@ static int msm_init(struct driver *drv)
 
        drv_modify_linear_combinations(drv);
 
-       if (should_avoid_ubwc())
+       if (should_avoid_ubwc() || !drv->compression)
                return 0;
 
        metadata.tiling = MSM_UBWC_TILING;
@@ -315,6 +315,9 @@ static int msm_bo_create_with_modifiers(struct bo *bo, uint32_t width, uint32_t
        uint64_t modifier =
            drv_pick_modifier(modifiers, count, modifier_order, ARRAY_SIZE(modifier_order));
 
+       if (!bo->drv->compression && modifier == DRM_FORMAT_MOD_QCOM_COMPRESSED)
+               modifier = DRM_FORMAT_MOD_LINEAR;
+
        return msm_bo_create_for_modifier(bo, width, height, format, modifier);
 }
 
index 9ef7962..30d9fbe 100644 (file)
@@ -128,7 +128,8 @@ static int rockchip_bo_create_with_modifiers(struct bo *bo, uint32_t width, uint
                 */
                bo->meta.total_size += w_mbs * h_mbs * 128;
        } else if (width <= 2560 &&
-                  drv_has_modifier(modifiers, count, DRM_FORMAT_MOD_CHROMEOS_ROCKCHIP_AFBC)) {
+                  drv_has_modifier(modifiers, count, DRM_FORMAT_MOD_CHROMEOS_ROCKCHIP_AFBC) &&
+                  bo->drv->compression) {
                /* If the caller has decided they can use AFBC, always
                 * pick that */
                afbc_bo_from_format(bo, width, height, format);