summaryrefslogtreecommitdiff
path: root/cros_gralloc/cros_gralloc_driver.cc
diff options
context:
space:
mode:
Diffstat (limited to 'cros_gralloc/cros_gralloc_driver.cc')
-rw-r--r--cros_gralloc/cros_gralloc_driver.cc38
1 files changed, 14 insertions, 24 deletions
diff --git a/cros_gralloc/cros_gralloc_driver.cc b/cros_gralloc/cros_gralloc_driver.cc
index 550f75a..ed7d954 100644
--- a/cros_gralloc/cros_gralloc_driver.cc
+++ b/cros_gralloc/cros_gralloc_driver.cc
@@ -15,6 +15,7 @@
#include <xf86drm.h>
#include "../util.h"
+#include "cros_gralloc_buffer_metadata.h"
// Constants taken from pipe_loader_drm.c in Mesa
@@ -267,7 +268,7 @@ int32_t cros_gralloc_driver::allocate(const struct cros_gralloc_buffer_descripto
num_planes = drv_bo_get_num_planes(bo);
num_fds = num_planes;
- if (descriptor->reserved_region_size > 0)
+ if (descriptor->enable_metadata_fd)
num_fds += 1;
num_ints = ((sizeof(struct cros_gralloc_handle) - sizeof(native_handle_t)) / sizeof(int)) -
@@ -291,7 +292,11 @@ int32_t cros_gralloc_driver::allocate(const struct cros_gralloc_buffer_descripto
hnd->sizes[plane] = drv_bo_get_plane_size(bo, plane);
}
- hnd->reserved_region_size = descriptor->reserved_region_size;
+ hnd->reserved_region_size = 0;
+ if (descriptor->enable_metadata_fd)
+ hnd->reserved_region_size =
+ sizeof(struct cros_gralloc_buffer_metadata) + descriptor->client_metadata_size;
+
if (hnd->reserved_region_size > 0) {
ret = create_reserved_region(descriptor->name, hnd->reserved_region_size);
if (ret < 0)
@@ -313,7 +318,7 @@ int32_t cros_gralloc_driver::allocate(const struct cros_gralloc_buffer_descripto
hnd->magic = cros_gralloc_magic;
hnd->droid_format = descriptor->droid_format;
hnd->usage = descriptor->droid_usage;
- hnd->total_size = descriptor->reserved_region_size + drv_bo_get_total_size(bo);
+ hnd->total_size = hnd->reserved_region_size + drv_bo_get_total_size(bo);
buffer = cros_gralloc_buffer::create(bo, hnd);
if (!buffer) {
@@ -322,6 +327,12 @@ int32_t cros_gralloc_driver::allocate(const struct cros_gralloc_buffer_descripto
goto destroy_hnd;
}
+ ret = buffer->initialize_metadata(descriptor);
+ if (ret) {
+ ALOGE("Failed to allocate: failed to initialize cros_gralloc_buffer metadata.");
+ goto destroy_hnd;
+ }
+
{
std::lock_guard<std::mutex> lock(mutex_);
@@ -572,27 +583,6 @@ int32_t cros_gralloc_driver::resource_info(buffer_handle_t handle, uint32_t stri
return buffer->resource_info(strides, offsets, format_modifier);
}
-int32_t cros_gralloc_driver::get_reserved_region(buffer_handle_t handle,
- void **reserved_region_addr,
- uint64_t *reserved_region_size)
-{
- std::lock_guard<std::mutex> lock(mutex_);
-
- auto hnd = cros_gralloc_convert_handle(handle);
- if (!hnd) {
- ALOGE("Invalid handle.");
- return -EINVAL;
- }
-
- auto buffer = get_buffer(hnd);
- if (!buffer) {
- ALOGE("Invalid reference (get_reserved_region() called on unregistered handle).");
- return -EINVAL;
- }
-
- return buffer->get_reserved_region(reserved_region_addr, reserved_region_size);
-}
-
uint32_t cros_gralloc_driver::get_resolved_drm_format(uint32_t drm_format, uint64_t use_flags)
{
uint32_t resolved_format;