summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Macnak <natsu@google.com>2022-04-01 19:19:49 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2022-04-01 19:19:49 +0000
commit720b1f1cae8e8e7ba5d6fe498ba4defa10f782b1 (patch)
tree40006207a1caf05720d4b09009899dd940023875
parent044dc5e0ae0103f82657047643c424218f5196eb (diff)
parent67f75e1c74860c6c0f5c7afc0d1562a4b15dae9a (diff)
downloadminigbm-720b1f1cae8e8e7ba5d6fe498ba4defa10f782b1.tar.gz
Merge branch 'aosp/upstream-main' into 'aosp/main' am: dffef56827 am: 67f75e1c74
Original change: https://android-review.googlesource.com/c/platform/external/minigbm/+/2052055 Change-Id: I5303ac8d0fcae93c3edc2350dcd9c6416eb4b4da Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--amdgpu.c3
-rw-r--r--common.mk2
-rw-r--r--cros_gralloc/cros_gralloc_driver.cc2
-rw-r--r--cros_gralloc/cros_gralloc_driver.h4
-rw-r--r--cros_gralloc/gralloc4/CrosGralloc4Allocator.cc9
-rw-r--r--i915.c21
-rw-r--r--mediatek.c2
7 files changed, 31 insertions, 12 deletions
diff --git a/amdgpu.c b/amdgpu.c
index f0053d6..700a8c7 100644
--- a/amdgpu.c
+++ b/amdgpu.c
@@ -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
diff --git a/common.mk b/common.mk
index 3d7e7d4..a06728b 100644
--- a/common.mk
+++ b/common.mk
@@ -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;
diff --git a/i915.c b/i915.c
index 6a44448..de33cd8 100644
--- a/i915.c
+++ b/i915.c
@@ -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
diff --git a/mediatek.c b/mediatek.c
index cd3e641..076f478 100644
--- a/mediatek.c
+++ b/mediatek.c
@@ -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 };