diff options
author | Jason Macnak <natsu@google.com> | 2022-04-01 19:40:38 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2022-04-01 19:40:38 +0000 |
commit | d358e6b84a6b0d4685d7529524452e8436d9ffdc (patch) | |
tree | 19bbc48d0115552fa9039cdc5cbc6ee3c077dba5 | |
parent | f409c2edd05fe212ea572e4c66570f1a93783052 (diff) | |
parent | 720b1f1cae8e8e7ba5d6fe498ba4defa10f782b1 (diff) | |
download | minigbm-d358e6b84a6b0d4685d7529524452e8436d9ffdc.tar.gz |
Merge branch 'aosp/upstream-main' into 'aosp/main' am: dffef56827 am: 67f75e1c74 am: 720b1f1cae
Original change: https://android-review.googlesource.com/c/platform/external/minigbm/+/2052055
Change-Id: Ia0a6ca586fbdf3693041d3217909788ead909df2
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r-- | amdgpu.c | 3 | ||||
-rw-r--r-- | common.mk | 2 | ||||
-rw-r--r-- | cros_gralloc/cros_gralloc_driver.cc | 2 | ||||
-rw-r--r-- | cros_gralloc/cros_gralloc_driver.h | 4 | ||||
-rw-r--r-- | cros_gralloc/gralloc4/CrosGralloc4Allocator.cc | 9 | ||||
-rw-r--r-- | i915.c | 21 | ||||
-rw-r--r-- | mediatek.c | 2 |
7 files changed, 31 insertions, 12 deletions
@@ -625,6 +625,9 @@ static int amdgpu_import_bo(struct bo *bo, struct drv_import_fd_data *data) dri_tiling = combo->metadata.tiling != TILE_TYPE_LINEAR; } + bo->meta.num_planes = dri_num_planes_from_modifier(bo->drv, data->format, + data->format_modifier); + if (dri_tiling) return dri_bo_import(bo, data); else @@ -7,7 +7,7 @@ # # NOTE NOTE NOTE # The authoritative common.mk is located in: -# https://chromium.googlesource.com/chromiumos/platform2/+/master/common-mk +# https://chromium.googlesource.com/chromiumos/platform2/+/HEAD/common-mk # Please make all changes there, then copy into place in other repos. # NOTE NOTE NOTE # diff --git a/cros_gralloc/cros_gralloc_driver.cc b/cros_gralloc/cros_gralloc_driver.cc index 6ac094d..46de30d 100644 --- a/cros_gralloc/cros_gralloc_driver.cc +++ b/cros_gralloc/cros_gralloc_driver.cc @@ -205,7 +205,7 @@ int cros_gralloc_driver::create_reserved_region(const std::string &buffer_name, { int ret; -#if ANDROID_API_LEVEL >= 31 +#if ANDROID_API_LEVEL >= 31 && defined(HAS_DMABUF_SYSTEM_HEAP) ret = allocator_.Alloc(kDmabufSystemHeapName, reserved_region_size); if (ret >= 0) return ret; diff --git a/cros_gralloc/cros_gralloc_driver.h b/cros_gralloc/cros_gralloc_driver.h index d9528d7..5678b76 100644 --- a/cros_gralloc/cros_gralloc_driver.h +++ b/cros_gralloc/cros_gralloc_driver.h @@ -15,7 +15,7 @@ #include <string> #include <unordered_map> -#if ANDROID_API_LEVEL >= 31 +#if ANDROID_API_LEVEL >= 31 && defined(HAS_DMABUF_SYSTEM_HEAP) #include <BufferAllocator/BufferAllocator.h> #endif @@ -62,7 +62,7 @@ class cros_gralloc_driver int create_reserved_region(const std::string &buffer_name, uint64_t reserved_region_size); -#if ANDROID_API_LEVEL >= 31 +#if ANDROID_API_LEVEL >= 31 && defined(HAS_DMABUF_SYSTEM_HEAP) /* For allocating cros_gralloc_buffer reserved regions for metadata. */ BufferAllocator allocator_; #endif diff --git a/cros_gralloc/gralloc4/CrosGralloc4Allocator.cc b/cros_gralloc/gralloc4/CrosGralloc4Allocator.cc index 6610c5e..43c0b0c 100644 --- a/cros_gralloc/gralloc4/CrosGralloc4Allocator.cc +++ b/cros_gralloc/gralloc4/CrosGralloc4Allocator.cc @@ -95,18 +95,17 @@ Error CrosGralloc4Allocator::allocate(const BufferDescriptorInfo& descriptor, ui return Error::NO_RESOURCES; } - outHandle->setTo(handle, /*shouldOwn=*/true); - cros_gralloc_handle_t crosHandle = cros_gralloc_convert_handle(handle); - if (!crosHandle) { - return Error::NO_RESOURCES; - } Error error = initializeMetadata(crosHandle, crosDescriptor); if (error != Error::NONE) { + mDriver->release(handle); + native_handle_close(handle); + native_handle_delete(handle); return error; } + outHandle->setTo(handle, /*shouldOwn=*/true); *outStride = crosHandle->pixel_stride; return Error::NONE; @@ -440,6 +440,19 @@ static int i915_bo_from_format(struct bo *bo, uint32_t width, uint32_t height, u return 0; } +static size_t i915_num_planes_from_modifier(struct driver *drv, uint32_t format, + uint64_t modifier) +{ + size_t num_planes = drv_num_planes_from_format(format); + if (modifier == I915_FORMAT_MOD_Y_TILED_CCS || + modifier == I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS) { + assert(num_planes == 1); + return 2; + } + + return num_planes; +} + static int i915_bo_compute_metadata(struct bo *bo, uint32_t width, uint32_t height, uint32_t format, uint64_t use_flags, const uint64_t *modifiers, uint32_t count) { @@ -564,7 +577,7 @@ static int i915_bo_compute_metadata(struct bo *bo, uint32_t width, uint32_t heig bo->meta.offsets[1] = offset; offset += ccs_size; - bo->meta.num_planes = 2; + bo->meta.num_planes = i915_num_planes_from_modifier(bo->drv, format, modifier); bo->meta.total_size = offset; } else if (modifier == I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS) { @@ -599,7 +612,7 @@ static int i915_bo_compute_metadata(struct bo *bo, uint32_t width, uint32_t heig bo->meta.sizes[1] = ALIGN(bo->meta.sizes[0] / 256, getpagesize()); bo->meta.offsets[1] = bo->meta.sizes[0]; /* Total number of planes & sizes */ - bo->meta.num_planes = 2; + bo->meta.num_planes = i915_num_planes_from_modifier(bo->drv, format, modifier); bo->meta.total_size = bo->meta.sizes[0] + bo->meta.sizes[1]; } else { i915_bo_from_format(bo, width, height, format); @@ -677,6 +690,9 @@ static int i915_bo_import(struct bo *bo, struct drv_import_fd_data *data) int ret; struct drm_i915_gem_get_tiling gem_get_tiling = { 0 }; + bo->meta.num_planes = i915_num_planes_from_modifier(bo->drv, data->format, + data->format_modifier); + ret = drv_prime_bo_import(bo, data); if (ret) return ret; @@ -807,6 +823,7 @@ const struct backend backend_i915 = { .bo_invalidate = i915_bo_invalidate, .bo_flush = i915_bo_flush, .resolve_format_and_use_flags = drv_resolve_format_and_use_flags_helper, + .num_planes_from_modifier = i915_num_planes_from_modifier, }; #endif @@ -163,7 +163,7 @@ static int mediatek_bo_create_with_modifiers(struct bo *bo, uint32_t width, uint stride = ALIGN(stride, 64); #endif - if (bo->meta.use_flags & BO_USE_HW_VIDEO_ENCODER) { + if (bo->meta.use_flags & (BO_USE_HW_VIDEO_ENCODER | BO_USE_SCANOUT)) { uint32_t aligned_height = ALIGN(height, 32); uint32_t padding[DRV_MAX_PLANES] = { 0 }; |