minigbm: standardize naming of buffer creation flags
We use the terms "flags" and "usage" interchangeably in this repo,
since they essentally mean the same thing. However, let's be a
little more consistent since it's kind of confusing, especially
when buffer map flags come to play. Let's:
- refer to everything in the drv_* layer as use_flags
- refer to everything in the gbm/gralloc layers as
usages
BUG=chromium:764871
TEST=emerge-eve {arc-cros-gralloc, minigbm}
Change-Id: If987d72369b895f38cde87e50ce1080f78f2a084
Reviewed-on: https://chromium-review.googlesource.com/691423
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
diff --git a/cros_gralloc/cros_gralloc_driver.cc b/cros_gralloc/cros_gralloc_driver.cc
index 805c123..7a4632e 100644
--- a/cros_gralloc/cros_gralloc_driver.cc
+++ b/cros_gralloc/cros_gralloc_driver.cc
@@ -78,8 +78,8 @@
{
struct combination *combo;
uint32_t resolved_format;
- resolved_format = drv_resolve_format(drv_, descriptor->drm_format, descriptor->drv_usage);
- combo = drv_get_combination(drv_, resolved_format, descriptor->drv_usage);
+ resolved_format = drv_resolve_format(drv_, descriptor->drm_format, descriptor->use_flags);
+ combo = drv_get_combination(drv_, resolved_format, descriptor->use_flags);
return (combo != nullptr);
}
@@ -94,9 +94,9 @@
struct bo *bo;
struct cros_gralloc_handle *hnd;
- resolved_format = drv_resolve_format(drv_, descriptor->drm_format, descriptor->drv_usage);
+ resolved_format = drv_resolve_format(drv_, descriptor->drm_format, descriptor->use_flags);
bo = drv_bo_create(drv_, descriptor->width, descriptor->height, resolved_format,
- descriptor->drv_usage);
+ descriptor->use_flags);
if (!bo) {
cros_gralloc_error("Failed to create bo.");
return -ENOMEM;
@@ -133,8 +133,8 @@
hnd->width = drv_bo_get_width(bo);
hnd->height = drv_bo_get_height(bo);
hnd->format = drv_bo_get_format(bo);
- hnd->flags[0] = static_cast<uint32_t>(descriptor->drv_usage >> 32);
- hnd->flags[1] = static_cast<uint32_t>(descriptor->drv_usage);
+ hnd->use_flags[0] = static_cast<uint32_t>(descriptor->use_flags >> 32);
+ hnd->use_flags[1] = static_cast<uint32_t>(descriptor->use_flags);
hnd->pixel_stride = drv_bo_get_stride_in_pixels(bo);
hnd->magic = cros_gralloc_magic;
hnd->droid_format = descriptor->droid_format;
@@ -182,8 +182,8 @@
data.format = hnd->format;
data.width = hnd->width;
data.height = hnd->height;
- data.flags = static_cast<uint64_t>(hnd->flags[0]) << 32;
- data.flags |= hnd->flags[1];
+ data.use_flags = static_cast<uint64_t>(hnd->use_flags[0]) << 32;
+ data.use_flags |= hnd->use_flags[1];
memcpy(data.fds, hnd->fds, sizeof(data.fds));
memcpy(data.strides, hnd->strides, sizeof(data.strides));
diff --git a/cros_gralloc/cros_gralloc_handle.h b/cros_gralloc/cros_gralloc_handle.h
index bdd3f07..cd3edfe 100644
--- a/cros_gralloc/cros_gralloc_handle.h
+++ b/cros_gralloc/cros_gralloc_handle.h
@@ -25,8 +25,8 @@
uint32_t format_modifiers[2 * DRV_MAX_PLANES];
uint32_t width;
uint32_t height;
- uint32_t format; /* DRM format */
- uint32_t flags[2]; /* driver creation time flags */
+ uint32_t format; /* DRM format */
+ uint32_t use_flags[2]; /* Buffer creation flags */
uint32_t magic;
uint32_t pixel_stride;
int32_t droid_format;
diff --git a/cros_gralloc/cros_gralloc_types.h b/cros_gralloc/cros_gralloc_types.h
index 2f6122e..1fa81de 100644
--- a/cros_gralloc/cros_gralloc_types.h
+++ b/cros_gralloc/cros_gralloc_types.h
@@ -14,7 +14,7 @@
uint32_t producer_usage;
uint32_t droid_format;
uint32_t drm_format;
- uint64_t drv_usage;
+ uint64_t use_flags;
};
#endif
diff --git a/cros_gralloc/gralloc0/gralloc0.cc b/cros_gralloc/gralloc0/gralloc0.cc
index 533f8ca..22932f5 100644
--- a/cros_gralloc/gralloc0/gralloc0.cc
+++ b/cros_gralloc/gralloc0/gralloc0.cc
@@ -32,50 +32,50 @@
};
// clang-format on
-static int64_t gralloc0_convert_flags(int flags)
+static uint64_t gralloc0_convert_usage(int usage)
{
- uint64_t usage = BO_USE_NONE;
+ uint64_t use_flags = BO_USE_NONE;
- if (flags & GRALLOC_USAGE_CURSOR)
- usage |= BO_USE_NONE;
- if ((flags & GRALLOC_USAGE_SW_READ_MASK) == GRALLOC_USAGE_SW_READ_RARELY)
- usage |= BO_USE_SW_READ_RARELY;
- if ((flags & GRALLOC_USAGE_SW_READ_MASK) == GRALLOC_USAGE_SW_READ_OFTEN)
- usage |= BO_USE_SW_READ_OFTEN;
- if ((flags & GRALLOC_USAGE_SW_WRITE_MASK) == GRALLOC_USAGE_SW_WRITE_RARELY)
- usage |= BO_USE_SW_WRITE_RARELY;
- if ((flags & GRALLOC_USAGE_SW_WRITE_MASK) == GRALLOC_USAGE_SW_WRITE_OFTEN)
- usage |= BO_USE_SW_WRITE_OFTEN;
- if (flags & GRALLOC_USAGE_HW_TEXTURE)
- usage |= BO_USE_TEXTURE;
- if (flags & GRALLOC_USAGE_HW_RENDER)
- usage |= BO_USE_RENDERING;
- if (flags & GRALLOC_USAGE_HW_2D)
- usage |= BO_USE_RENDERING;
- if (flags & GRALLOC_USAGE_HW_COMPOSER)
+ if (usage & GRALLOC_USAGE_CURSOR)
+ use_flags |= BO_USE_NONE;
+ if ((usage & GRALLOC_USAGE_SW_READ_MASK) == GRALLOC_USAGE_SW_READ_RARELY)
+ use_flags |= BO_USE_SW_READ_RARELY;
+ if ((usage & GRALLOC_USAGE_SW_READ_MASK) == GRALLOC_USAGE_SW_READ_OFTEN)
+ use_flags |= BO_USE_SW_READ_OFTEN;
+ if ((usage & GRALLOC_USAGE_SW_WRITE_MASK) == GRALLOC_USAGE_SW_WRITE_RARELY)
+ use_flags |= BO_USE_SW_WRITE_RARELY;
+ if ((usage & GRALLOC_USAGE_SW_WRITE_MASK) == GRALLOC_USAGE_SW_WRITE_OFTEN)
+ use_flags |= BO_USE_SW_WRITE_OFTEN;
+ if (usage & GRALLOC_USAGE_HW_TEXTURE)
+ use_flags |= BO_USE_TEXTURE;
+ if (usage & GRALLOC_USAGE_HW_RENDER)
+ use_flags |= BO_USE_RENDERING;
+ if (usage & GRALLOC_USAGE_HW_2D)
+ use_flags |= BO_USE_RENDERING;
+ if (usage & GRALLOC_USAGE_HW_COMPOSER)
/* HWC wants to use display hardware, but can defer to OpenGL. */
- usage |= BO_USE_SCANOUT | BO_USE_TEXTURE;
- if (flags & GRALLOC_USAGE_HW_FB)
- usage |= BO_USE_NONE;
- if (flags & GRALLOC_USAGE_EXTERNAL_DISP)
+ use_flags |= BO_USE_SCANOUT | BO_USE_TEXTURE;
+ if (usage & GRALLOC_USAGE_HW_FB)
+ use_flags |= BO_USE_NONE;
+ if (usage & GRALLOC_USAGE_EXTERNAL_DISP)
/*
* This flag potentially covers external display for the normal drivers (i915,
* rockchip) and usb monitors (evdi/udl). It's complicated so ignore it.
* */
- usage |= BO_USE_NONE;
- if (flags & GRALLOC_USAGE_PROTECTED)
- usage |= BO_USE_PROTECTED;
- if (flags & GRALLOC_USAGE_HW_VIDEO_ENCODER)
+ use_flags |= BO_USE_NONE;
+ if (usage & GRALLOC_USAGE_PROTECTED)
+ use_flags |= BO_USE_PROTECTED;
+ if (usage & GRALLOC_USAGE_HW_VIDEO_ENCODER)
/*HACK: See b/30054495 */
- usage |= BO_USE_SW_READ_OFTEN;
- if (flags & GRALLOC_USAGE_HW_CAMERA_WRITE)
- usage |= BO_USE_CAMERA_WRITE;
- if (flags & GRALLOC_USAGE_HW_CAMERA_READ)
- usage |= BO_USE_CAMERA_READ;
- if (flags & GRALLOC_USAGE_RENDERSCRIPT)
- usage |= BO_USE_RENDERSCRIPT;
+ use_flags |= BO_USE_SW_READ_OFTEN;
+ if (usage & GRALLOC_USAGE_HW_CAMERA_WRITE)
+ use_flags |= BO_USE_CAMERA_WRITE;
+ if (usage & GRALLOC_USAGE_HW_CAMERA_READ)
+ use_flags |= BO_USE_CAMERA_READ;
+ if (usage & GRALLOC_USAGE_RENDERSCRIPT)
+ use_flags |= BO_USE_RENDERSCRIPT;
- return usage;
+ return use_flags;
}
static int gralloc0_alloc(alloc_device_t *dev, int w, int h, int format, int usage,
@@ -91,19 +91,19 @@
descriptor.droid_format = format;
descriptor.producer_usage = descriptor.consumer_usage = usage;
descriptor.drm_format = cros_gralloc_convert_format(format);
- descriptor.drv_usage = gralloc0_convert_flags(usage);
+ descriptor.use_flags = gralloc0_convert_usage(usage);
supported = mod->driver->is_supported(&descriptor);
if (!supported && (usage & GRALLOC_USAGE_HW_COMPOSER)) {
- descriptor.drv_usage &= ~BO_USE_SCANOUT;
+ descriptor.use_flags &= ~BO_USE_SCANOUT;
supported = mod->driver->is_supported(&descriptor);
}
if (!supported) {
- cros_gralloc_error("Unsupported combination -- HAL format: %u, HAL flags: %u, "
- "drv_format: %4.4s, drv_flags: %llu",
+ cros_gralloc_error("Unsupported combination -- HAL format: %u, HAL usage: %u, "
+ "drv_format: %4.4s, use_flags: %llu",
format, usage, reinterpret_cast<char *>(&descriptor.drm_format),
- static_cast<unsigned long long>(descriptor.drv_usage));
+ static_cast<unsigned long long>(descriptor.use_flags));
return -EINVAL;
}
@@ -297,7 +297,7 @@
return -EINVAL;
}
- flags = gralloc0_convert_flags(usage);
+ flags = gralloc0_convert_usage(usage);
ret = mod->driver->lock(handle, fence_fd, flags, addr);
*vaddr = addr[0];
return ret;
@@ -332,7 +332,7 @@
return -EINVAL;
}
- flags = gralloc0_convert_flags(usage);
+ flags = gralloc0_convert_usage(usage);
ret = mod->driver->lock(handle, fence_fd, flags, addr);
if (ret)
return ret;