summaryrefslogtreecommitdiff
path: root/cros_gralloc
diff options
context:
space:
mode:
authorJason Macnak <natsu@google.com>2021-06-10 07:32:43 -0700
committerJason Macnak <natsu@google.com>2021-06-10 07:32:43 -0700
commit20e8ce7d5f3cfe3bc51c221e70693b6085914b9d (patch)
tree2c241a7ad325d9ec00b7dad5881fcb0111269335 /cros_gralloc
parent59831098b8ff2ecf71397fef57d50d9bc17cb641 (diff)
parentb505a50005e86852e88e5ef0c3a8cc1122a1d4ff (diff)
downloadminigbm-20e8ce7d5f3cfe3bc51c221e70693b6085914b9d.tar.gz
Merge remote-tracking branch 'aosp/upstream-main' into 'aosp/master'
... to update Minigbm for Cuttlefish to pull in crrev.com/c/2946768 to support PixelFormat::RGBA_1010102. Bug: b/179501410 Test: cts -m CtsMediaV2TestCases Change-Id: I97fe4578436b574cfe4844cfb91ee5b93494f1c2
Diffstat (limited to 'cros_gralloc')
-rw-r--r--cros_gralloc/gralloc0/gralloc0.cc28
1 files changed, 24 insertions, 4 deletions
diff --git a/cros_gralloc/gralloc0/gralloc0.cc b/cros_gralloc/gralloc0/gralloc0.cc
index 73f2b9a..5899d5a 100644
--- a/cros_gralloc/gralloc0/gralloc0.cc
+++ b/cros_gralloc/gralloc0/gralloc0.cc
@@ -264,9 +264,10 @@ static int gralloc0_register_buffer(struct gralloc_module_t const *module, buffe
auto const_module = reinterpret_cast<const struct gralloc0_module *>(module);
auto mod = const_cast<struct gralloc0_module *>(const_module);
- if (!mod->initialized)
+ if (!mod->initialized) {
if (gralloc0_init(mod, false))
return -ENODEV;
+ }
return mod->driver->retain(handle);
}
@@ -310,11 +311,17 @@ static int gralloc0_perform(struct gralloc_module_t const *module, int op, ...)
uint32_t offsets[DRV_MAX_PLANES] = { 0, 0, 0, 0 };
uint64_t format_modifier = 0;
struct cros_gralloc0_buffer_info *info;
- auto mod = (struct gralloc0_module const *)module;
+ auto const_module = reinterpret_cast<const struct gralloc0_module *>(module);
+ auto mod = const_cast<struct gralloc0_module *>(const_module);
uint32_t req_usage;
uint32_t gralloc_usage = 0;
uint32_t *out_gralloc_usage;
+ if (!mod->initialized) {
+ if (gralloc0_init(mod, false))
+ return -ENODEV;
+ }
+
va_start(args, op);
switch (op) {
@@ -371,6 +378,7 @@ static int gralloc0_perform(struct gralloc_module_t const *module, int op, ...)
break;
case GRALLOC_DRM_GET_BUFFER_INFO:
info = va_arg(args, struct cros_gralloc0_buffer_info *);
+ memset(info, 0, sizeof(*info));
info->drm_fourcc = drv_get_standard_fourcc(hnd->format);
info->num_fds = hnd->num_planes;
ret = mod->driver->resource_info(handle, strides, offsets, &format_modifier);
@@ -417,12 +425,18 @@ static int gralloc0_lock_async(struct gralloc_module_t const *module, buffer_han
int32_t ret;
uint32_t map_flags;
uint8_t *addr[DRV_MAX_PLANES];
- auto mod = (struct gralloc0_module const *)module;
+ auto const_module = reinterpret_cast<const struct gralloc0_module *>(module);
+ auto mod = const_cast<struct gralloc0_module *>(const_module);
struct rectangle rect = { .x = static_cast<uint32_t>(l),
.y = static_cast<uint32_t>(t),
.width = static_cast<uint32_t>(w),
.height = static_cast<uint32_t>(h) };
+ if (!mod->initialized) {
+ if (gralloc0_init(mod, false))
+ return -ENODEV;
+ }
+
auto hnd = cros_gralloc_convert_handle(handle);
if (!hnd) {
drv_log("Invalid handle.\n");
@@ -462,12 +476,18 @@ static int gralloc0_lock_async_ycbcr(struct gralloc_module_t const *module, buff
uint32_t offsets[DRV_MAX_PLANES] = { 0, 0, 0, 0 };
uint64_t format_modifier = 0;
uint8_t *addr[DRV_MAX_PLANES] = { nullptr, nullptr, nullptr, nullptr };
- auto mod = (struct gralloc0_module const *)module;
+ auto const_module = reinterpret_cast<const struct gralloc0_module *>(module);
+ auto mod = const_cast<struct gralloc0_module *>(const_module);
struct rectangle rect = { .x = static_cast<uint32_t>(l),
.y = static_cast<uint32_t>(t),
.width = static_cast<uint32_t>(w),
.height = static_cast<uint32_t>(h) };
+ if (!mod->initialized) {
+ if (gralloc0_init(mod, false))
+ return -ENODEV;
+ }
+
auto hnd = cros_gralloc_convert_handle(handle);
if (!hnd) {
drv_log("Invalid handle.\n");