gralloc: resolve format and use_flags at cros_gralloc_driver level
This simplify the separate resolving efforts in different gralloc
frontends (including separate logic in gralloc4 mapper and allocator).
BUG=b:199524294
TEST=CtsNativeHardwareTestCases
Change-Id: I74cd19df9b06c26a124e89c3367dd76b5b57dbd0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3166893
Reviewed-by: Jason Macnak <natsu@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Jason Macnak <natsu@google.com>
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
diff --git a/cros_gralloc/gralloc0/gralloc0.cc b/cros_gralloc/gralloc0/gralloc0.cc
index cc87f3b..7140966 100644
--- a/cros_gralloc/gralloc0/gralloc0.cc
+++ b/cros_gralloc/gralloc0/gralloc0.cc
@@ -84,7 +84,6 @@
buffer_handle_t *handle, int *stride)
{
int32_t ret;
- bool supported;
struct cros_gralloc_buffer_descriptor descriptor;
auto mod = (struct gralloc0_module const *)dev->common.module;
@@ -96,28 +95,7 @@
descriptor.use_flags = cros_gralloc_convert_usage(usage);
descriptor.reserved_region_size = 0;
- supported = mod->driver->is_supported(&descriptor);
- if (!supported && (usage & GRALLOC_USAGE_HW_COMPOSER)) {
- descriptor.use_flags &= ~BO_USE_SCANOUT;
- supported = mod->driver->is_supported(&descriptor);
- }
- if (!supported && (usage & GRALLOC_USAGE_HW_VIDEO_ENCODER) &&
- format != HAL_PIXEL_FORMAT_YCbCr_420_888) {
- // Unmask BO_USE_HW_VIDEO_ENCODER for other formats. They are mostly
- // intermediate formats not passed directly to the encoder (e.g.
- // camera). YV12 is passed to the encoder component, but it is converted
- // to YCbCr_420_888 before being passed to the hw encoder.
- descriptor.use_flags &= ~BO_USE_HW_VIDEO_ENCODER;
- drv_log("Retrying format %u allocation without encoder flag", format);
- supported = mod->driver->is_supported(&descriptor);
- }
- if (!supported && (usage & BUFFER_USAGE_FRONT_RENDERING)) {
- descriptor.use_flags &= ~BO_USE_FRONT_RENDERING;
- descriptor.use_flags |= BO_USE_LINEAR;
- supported = mod->driver->is_supported(&descriptor);
- }
-
- if (!supported) {
+ if (!mod->driver->is_supported(&descriptor)) {
drv_log("Unsupported combination -- HAL format: %u, HAL usage: %u, "
"drv_format: %4.4s, use_flags: %llu\n",
format, usage, reinterpret_cast<char *>(&descriptor.drm_format),