gralloc: move the logic to strip BO_USE_HW_VIDEO_ENCODER to the backends

BUG=b:199524294
TEST=CQ

Change-Id: I2b36a0ef17cd6ecb77723d4a9d95196ad27ff4ad
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3200148
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Jason Macnak <natsu@google.com>
Reviewed-by: Jason Macnak <natsu@google.com>
Reviewed-by: Chia-I Wu <olv@google.com>
diff --git a/cros_gralloc/cros_gralloc_driver.cc b/cros_gralloc/cros_gralloc_driver.cc
index fea4e1a..c7da42b 100644
--- a/cros_gralloc/cros_gralloc_driver.cc
+++ b/cros_gralloc/cros_gralloc_driver.cc
@@ -139,15 +139,6 @@
 	drv_resolve_format_and_use_flags(drv_, descriptor->drm_format, descriptor->use_flags,
 					 &resolved_format, &resolved_use_flags);
 
-	/*
-	 * This unmask is a backup in the case DRM_FORMAT_FLEX_IMPLEMENTATION_DEFINED is resolved
-	 * to non-YUV formats.
-	 */
-	if (descriptor->drm_format == DRM_FORMAT_FLEX_IMPLEMENTATION_DEFINED &&
-	    (resolved_format == DRM_FORMAT_XBGR8888 || resolved_format == DRM_FORMAT_ABGR8888)) {
-		resolved_use_flags &= ~BO_USE_HW_VIDEO_ENCODER;
-	}
-
 	combo = drv_get_combination(drv_, resolved_format, resolved_use_flags);
 	if (!combo && (descriptor->droid_usage & GRALLOC_USAGE_HW_VIDEO_ENCODER) &&
 	    descriptor->droid_format != HAL_PIXEL_FORMAT_YCbCr_420_888) {
diff --git a/drv_helpers.c b/drv_helpers.c
index 0b6cb29..6ea4b8e 100644
--- a/drv_helpers.c
+++ b/drv_helpers.c
@@ -587,6 +587,7 @@
 		} else {
 			/* HACK: See b/28671744 */
 			*out_format = DRM_FORMAT_XBGR8888;
+			*out_use_flags &= ~BO_USE_HW_VIDEO_ENCODER;
 		}
 		break;
 	case DRM_FORMAT_FLEX_YCbCr_420_888:
diff --git a/mediatek.c b/mediatek.c
index 19cece7..a95ed46 100644
--- a/mediatek.c
+++ b/mediatek.c
@@ -299,6 +299,7 @@
 
 		/* HACK: See b/28671744 */
 		*out_format = DRM_FORMAT_XBGR8888;
+		*out_use_flags &= ~BO_USE_HW_VIDEO_ENCODER;
 		break;
 	case DRM_FORMAT_FLEX_YCbCr_420_888:
 #if defined(MTK_MT8183) || defined(MTK_MT8192) || defined(MTK_MT8195)
diff --git a/virtgpu_virgl.c b/virtgpu_virgl.c
index becce8b..ec02ead 100644
--- a/virtgpu_virgl.c
+++ b/virtgpu_virgl.c
@@ -959,6 +959,7 @@
 		} else {
 			/* HACK: See b/28671744 */
 			*out_format = DRM_FORMAT_XBGR8888;
+			*out_use_flags &= ~BO_USE_HW_VIDEO_ENCODER;
 		}
 		break;
 	case DRM_FORMAT_FLEX_YCbCr_420_888:
@@ -1006,6 +1007,7 @@
 		} else {
 			/* HACK: See b/28671744 */
 			*out_format = DRM_FORMAT_XBGR8888;
+			*out_use_flags &= ~BO_USE_HW_VIDEO_ENCODER;
 		}
 		break;
 	case DRM_FORMAT_FLEX_YCbCr_420_888: