From ff5ffe6d5ca68ef2db8e6cc2e219bfd00baccc53 Mon Sep 17 00:00:00 2001 From: "Kristian H. Kristensen" Date: Wed, 12 Aug 2020 15:16:33 -0700 Subject: [PATCH] cros_gralloc: Add new perform op for getting buffer info This perform op gives us all the underlying info about the BO, which lets us import multiplane BOs (such as Intel compressed BOs). This eliminates a lot of guessing and fudging in EGL and wayland_service when trying to determine this info from the Android handle. This generalizes the GET_MODIFIER op, which nothing was using yet. BUG=b:145579089, b:79682290. b:163562363 TEST=arc++ apps using non-linear format layouts Change-Id: I821e14477d35794b7247fab59649f564e8ff6985 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2353750 Reviewed-by: Jason Macnak Reviewed-by: Gurchetan Singh Tested-by: Kristian H. Kristensen Commit-Queue: Kristian H. Kristensen --- cros_gralloc/gralloc0/gralloc0.cc | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/cros_gralloc/gralloc0/gralloc0.cc b/cros_gralloc/gralloc0/gralloc0.cc index 2a7b87f..943c8e8 100644 --- a/cros_gralloc/gralloc0/gralloc0.cc +++ b/cros_gralloc/gralloc0/gralloc0.cc @@ -19,6 +19,15 @@ struct gralloc0_module { std::mutex initialization_mutex; }; +struct cros_gralloc0_buffer_info { + uint32_t drm_fourcc; + int num_fds; + int fds[4]; + uint64_t modifier; + uint32_t offset[4]; + uint32_t stride[4]; +}; + /* This enumeration must match the one in . * The functions supported by this gralloc's temporary private API are listed * below. Use of these functions is highly discouraged and should only be @@ -31,7 +40,7 @@ enum { GRALLOC_DRM_GET_FORMAT, GRALLOC_DRM_GET_DIMENSIONS, GRALLOC_DRM_GET_BACKING_STORE, - GRALLOC_DRM_GET_MODIFIER, + GRALLOC_DRM_GET_BUFFER_INFO, }; // clang-format on @@ -262,11 +271,11 @@ static int gralloc0_perform(struct gralloc_module_t const *module, int op, ...) va_list args; int32_t *out_format, ret; uint64_t *out_store; - uint64_t *out_modifier; buffer_handle_t handle; uint32_t *out_width, *out_height, *out_stride; uint32_t strides[DRV_MAX_PLANES] = { 0, 0, 0, 0 }; uint32_t offsets[DRV_MAX_PLANES] = { 0, 0, 0, 0 }; + struct cros_gralloc0_buffer_info *info; auto mod = (struct gralloc0_module const *)module; switch (op) { @@ -274,7 +283,7 @@ static int gralloc0_perform(struct gralloc_module_t const *module, int op, ...) case GRALLOC_DRM_GET_FORMAT: case GRALLOC_DRM_GET_DIMENSIONS: case GRALLOC_DRM_GET_BACKING_STORE: - case GRALLOC_DRM_GET_MODIFIER: + case GRALLOC_DRM_GET_BUFFER_INFO: break; default: return -EINVAL; @@ -319,9 +328,16 @@ static int gralloc0_perform(struct gralloc_module_t const *module, int op, ...) out_store = va_arg(args, uint64_t *); ret = mod->driver->get_backing_store(handle, out_store); break; - case GRALLOC_DRM_GET_MODIFIER: - out_modifier = va_arg(args, uint64_t *); - *out_modifier = hnd->format_modifier; + case GRALLOC_DRM_GET_BUFFER_INFO: + info = va_arg(args, struct cros_gralloc0_buffer_info *); + info->drm_fourcc = hnd->format; + info->num_fds = hnd->num_planes; + info->modifier = hnd->format_modifier; + for (uint32_t i = 0; i < hnd->num_planes; i++) { + info->fds[i] = hnd->fds[i]; + info->offset[i] = hnd->offsets[i]; + info->stride[i] = hnd->strides[i]; + } break; default: ret = -EINVAL; -- 2.11.0