summaryrefslogtreecommitdiff
path: root/gralloc4/src
diff options
context:
space:
mode:
authorAnkit Goyal <layog@google.com>2023-03-01 16:55:18 -0800
committerAnkit Goyal <layog@google.com>2023-03-01 17:00:54 -0800
commite21346e84c6e0377f49416d64f5d94688c6b3619 (patch)
treed6f2c5f3c7df472759acc5bee3bac4e517b8b033 /gralloc4/src
parent955a611bb3a2ee61a706f22deb71cde7b0dbe96a (diff)
downloadgchips-e21346e84c6e0377f49416d64f5d94688c6b3619.tar.gz
Revert "gralloc4: Add warnings for using multi-fd formats"
This reverts commit fc18d4c806f9abd4098a8af576dad68331fccd70. Bug: 269705937 Test: No display artifacts after camera shot Change-Id: If5743a82f6d008e7a22c71c13d6a27ea574d7cdf
Diffstat (limited to 'gralloc4/src')
-rw-r--r--gralloc4/src/core/mali_gralloc_bufferallocation.cpp54
-rw-r--r--gralloc4/src/core/mali_gralloc_formats.cpp27
-rw-r--r--gralloc4/src/hidl_common/MapperMetadata.cpp10
-rw-r--r--gralloc4/src/mali_gralloc_formats.h2
4 files changed, 34 insertions, 59 deletions
diff --git a/gralloc4/src/core/mali_gralloc_bufferallocation.cpp b/gralloc4/src/core/mali_gralloc_bufferallocation.cpp
index 7355930..f76bcf9 100644
--- a/gralloc4/src/core/mali_gralloc_bufferallocation.cpp
+++ b/gralloc4/src/core/mali_gralloc_bufferallocation.cpp
@@ -22,7 +22,6 @@
#include <assert.h>
#include <atomic>
#include <algorithm>
-#include <set>
#include <utils/Trace.h>
#include <hardware/hardware.h>
@@ -793,12 +792,12 @@ static int prepare_descriptor_exynos_formats(
buffer_descriptor_t *bufDescriptor,
format_info_t format_info)
{
+ int fd_count = 1;
int w = bufDescriptor->width;
int h = bufDescriptor->height;
uint64_t usage = bufDescriptor->producer_usage | bufDescriptor->consumer_usage;
int plane_count = 2;
int format = MALI_GRALLOC_INTFMT_FMT_MASK & bufDescriptor->alloc_format;
- int fd_count = get_exynos_fd_count(format);
if (usage & (GRALLOC_USAGE_HW_VIDEO_ENCODER | GRALLOC_USAGE_HW_VIDEO_DECODER))
{
@@ -807,6 +806,23 @@ static int prepare_descriptor_exynos_formats(
bufDescriptor->consumer_usage |= GRALLOC_USAGE_VIDEO_PRIVATE_DATA;
}
+ /* set SBWC format fd_count */
+ fd_count = 1;
+ switch (format)
+ {
+ case HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_SP_M_SBWC:
+ case HAL_PIXEL_FORMAT_EXYNOS_YCrCb_420_SP_M_SBWC:
+ case HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_SP_M_10B_SBWC:
+ case HAL_PIXEL_FORMAT_EXYNOS_YCrCb_420_SP_M_10B_SBWC:
+ case HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_SP_M_SBWC_L50:
+ case HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_SP_M_SBWC_L75:
+ case HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_SP_M_10B_SBWC_L40:
+ case HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_SP_M_10B_SBWC_L60:
+ case HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_SP_M_10B_SBWC_L80:
+ fd_count = 2;
+ break;
+ }
+
/* SWBC Formats have special size requirements */
switch (format)
{
@@ -848,6 +864,7 @@ static int prepare_descriptor_exynos_formats(
break;
case HAL_PIXEL_FORMAT_YCrCb_420_SP:
+ fd_count = 1;
h = GRALLOC_ALIGN(h, 2);
plane_count = setup_420_sp(w, h, fd_count, bufDescriptor->plane_info);
break;
@@ -856,17 +873,20 @@ static int prepare_descriptor_exynos_formats(
case HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_P_M:
w = GRALLOC_ALIGN(w, 32);
h = GRALLOC_ALIGN(h, 16);
+ fd_count = 3;
plane_count = setup_420_p(w, h, fd_count, bufDescriptor->plane_info);
break;
case HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_SP_M_TILED:
w = GRALLOC_ALIGN(w, 16);
h = GRALLOC_ALIGN(h, 32);
+ fd_count = 2;
plane_count = setup_420_sp_tiled(w, h, fd_count, bufDescriptor->plane_info);
break;
case HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_P:
w = GRALLOC_ALIGN(w, 16);
+ fd_count = 1;
plane_count = setup_420_p(w, h, fd_count, bufDescriptor->plane_info);
break;
@@ -875,12 +895,14 @@ static int prepare_descriptor_exynos_formats(
case HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_SP_M:
w = GRALLOC_ALIGN(w, 16);
h = GRALLOC_ALIGN(h, 32);
+ fd_count = 2;
plane_count = setup_420_sp(w, h, fd_count, bufDescriptor->plane_info);
break;
case HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_SPN:
w = GRALLOC_ALIGN(w, 64);
h = GRALLOC_ALIGN(h, 16);
+ fd_count = 1;
plane_count = setup_420_sp(w, h, fd_count, bufDescriptor->plane_info);
break;
@@ -888,24 +910,28 @@ static int prepare_descriptor_exynos_formats(
/* This is 64 pixel align for now */
w = GRALLOC_ALIGN(w, BOARD_EXYNOS_S10B_FORMAT_ALIGN);
h = GRALLOC_ALIGN(h, 16);
+ fd_count = 2;
plane_count = setup_420_sp_s10b(w, h, fd_count, bufDescriptor->plane_info);
break;
case HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_SPN_S10B:
w = GRALLOC_ALIGN(w, BOARD_EXYNOS_S10B_FORMAT_ALIGN);
h = GRALLOC_ALIGN(h, 16);
+ fd_count = 1;
plane_count = setup_420_sp_s10b(w, h, fd_count, bufDescriptor->plane_info);
break;
case HAL_PIXEL_FORMAT_EXYNOS_YCbCr_P010_M:
w = GRALLOC_ALIGN(w, 16);
h = GRALLOC_ALIGN(h, 16);
+ fd_count = 2;
plane_count = setup_p010_sp(w, h, fd_count, bufDescriptor->plane_info);
break;
case HAL_PIXEL_FORMAT_EXYNOS_YCbCr_P010_SPN:
w = GRALLOC_ALIGN(w, 64);
h = GRALLOC_ALIGN(h, 16);
+ fd_count = 1;
plane_count = setup_p010_sp(w, h, fd_count, bufDescriptor->plane_info);
break;
@@ -976,6 +1002,7 @@ static int prepare_descriptor_exynos_formats(
bufDescriptor->alloc_sizes[fidx] = size;
}
+
bufDescriptor->fd_count = fd_count;
bufDescriptor->plane_count = plane_count;
@@ -997,22 +1024,6 @@ int mali_gralloc_derive_format_and_size(buffer_descriptor_t * const bufDescripto
bufDescriptor->alloc_format = mali_gralloc_select_format(bufDescriptor->hal_format,
bufDescriptor->format_type,
usage);
-
- int base_format = bufDescriptor->alloc_format & MALI_GRALLOC_INTFMT_FMT_MASK;
-
- // TODO(b/182885532): Delete all multi-fd related dead code from gralloc
- if (is_exynos_format(base_format) && get_exynos_fd_count(base_format) != 1)
- {
- static std::set<uint32_t> seen_formats;
- if (seen_formats.find(base_format) == seen_formats.end()) {
- MALI_GRALLOC_LOGW("Multi-fd format (%s 0x%" PRIx64 ") have been deprecated. Requested format: %s 0x%" PRIx64
- ". Consider changing the format to one of the single-fd options.",
- format_name(base_format), static_cast<uint64_t>(base_format),
- format_name(bufDescriptor->hal_format), bufDescriptor->hal_format);
- seen_formats.insert(base_format);
- }
- }
-
if (bufDescriptor->alloc_format == MALI_GRALLOC_FORMAT_INTERNAL_UNDEFINED)
{
MALI_GRALLOC_LOGE("ERROR: Unrecognized and/or unsupported format (%s 0x%" PRIx64 ") and usage (%s 0x%" PRIx64 ")",
@@ -1021,7 +1032,7 @@ int mali_gralloc_derive_format_and_size(buffer_descriptor_t * const bufDescripto
return -EINVAL;
}
- int32_t format_idx = get_format_index(base_format);
+ int32_t format_idx = get_format_index(bufDescriptor->alloc_format & MALI_GRALLOC_INTFMT_FMT_MASK);
if (format_idx == -1)
{
return -EINVAL;
@@ -1043,7 +1054,7 @@ int mali_gralloc_derive_format_and_size(buffer_descriptor_t * const bufDescripto
return -EINVAL;
}
- if (is_exynos_format(base_format))
+ if (is_exynos_format(bufDescriptor->alloc_format))
{
prepare_descriptor_exynos_formats(bufDescriptor, formats[format_idx]);
}
@@ -1076,7 +1087,7 @@ int mali_gralloc_derive_format_and_size(buffer_descriptor_t * const bufDescripto
}
/* Set pixel stride differently for RAW formats */
- switch (base_format)
+ switch (MALI_GRALLOC_INTFMT_FMT_MASK & bufDescriptor->alloc_format)
{
case MALI_GRALLOC_FORMAT_INTERNAL_RAW12:
case MALI_GRALLOC_FORMAT_INTERNAL_RAW10:
@@ -1123,6 +1134,7 @@ int mali_gralloc_derive_format_and_size(buffer_descriptor_t * const bufDescripto
return 0;
}
+
int mali_gralloc_buffer_allocate(const gralloc_buffer_descriptor_t *descriptors,
uint32_t numDescriptors, buffer_handle_t *pHandle, bool *shared_backend,
int fd)
diff --git a/gralloc4/src/core/mali_gralloc_formats.cpp b/gralloc4/src/core/mali_gralloc_formats.cpp
index 5f7dee1..1baaada 100644
--- a/gralloc4/src/core/mali_gralloc_formats.cpp
+++ b/gralloc4/src/core/mali_gralloc_formats.cpp
@@ -1625,30 +1625,3 @@ bool is_exynos_format(uint32_t base_format)
return false;
}
-uint8_t get_exynos_fd_count(uint32_t format) {
- switch (format)
- {
- case HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_SP_M_SBWC:
- case HAL_PIXEL_FORMAT_EXYNOS_YCrCb_420_SP_M_SBWC:
- case HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_SP_M_10B_SBWC:
- case HAL_PIXEL_FORMAT_EXYNOS_YCrCb_420_SP_M_10B_SBWC:
- case HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_SP_M_SBWC_L50:
- case HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_SP_M_SBWC_L75:
- case HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_SP_M_10B_SBWC_L40:
- case HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_SP_M_10B_SBWC_L60:
- case HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_SP_M_10B_SBWC_L80:
- case HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_SP_M_TILED:
- case HAL_PIXEL_FORMAT_EXYNOS_YCrCb_420_SP_M:
- case HAL_PIXEL_FORMAT_EXYNOS_YCrCb_420_SP_M_FULL:
- case HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_SP_M:
- case HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_SP_M_S10B:
- case HAL_PIXEL_FORMAT_EXYNOS_YCbCr_P010_M:
- return 2;
- case HAL_PIXEL_FORMAT_EXYNOS_YV12_M:
- case HAL_PIXEL_FORMAT_EXYNOS_YCbCr_420_P_M:
- return 3;
- }
-
- return 1;
-}
-
diff --git a/gralloc4/src/hidl_common/MapperMetadata.cpp b/gralloc4/src/hidl_common/MapperMetadata.cpp
index 1123270..7cd4c92 100644
--- a/gralloc4/src/hidl_common/MapperMetadata.cpp
+++ b/gralloc4/src/hidl_common/MapperMetadata.cpp
@@ -286,8 +286,7 @@ static std::vector<std::vector<PlaneLayoutComponent>> plane_layout_components_fr
static android::status_t get_plane_layouts(const private_handle_t *handle, std::vector<PlaneLayout> *layouts)
{
const int num_planes = get_num_planes(handle);
- uint32_t base_format = handle->alloc_format & MALI_GRALLOC_INTFMT_FMT_MASK;
- int32_t format_index = get_format_index(base_format);
+ int32_t format_index = get_format_index(handle->alloc_format & MALI_GRALLOC_INTFMT_FMT_MASK);
if (format_index < 0)
{
MALI_GRALLOC_LOGE("Negative format index in get_plane_layouts");
@@ -305,13 +304,6 @@ static android::status_t get_plane_layouts(const private_handle_t *handle, std::
int64_t sample_increment_in_bits = format_info.bpp[plane_index];
int64_t offset = handle->plane_info[plane_index].offset;
- uint8_t fd_count = get_exynos_fd_count(base_format);
- if (fd_count != 1) {
- MALI_GRALLOC_LOGW("Offsets in plane layouts of multi-fd format (%s %" PRIu64
- ") are not reliable. This can lead to image corruption.",
- format_name(base_format), handle->alloc_format);
- }
-
PlaneLayout layout = {.offsetInBytes = offset,
.sampleIncrementInBits = sample_increment_in_bits,
.strideInBytes = handle->plane_info[plane_index].byte_stride,
diff --git a/gralloc4/src/mali_gralloc_formats.h b/gralloc4/src/mali_gralloc_formats.h
index e4120fa..0d16a50 100644
--- a/gralloc4/src/mali_gralloc_formats.h
+++ b/gralloc4/src/mali_gralloc_formats.h
@@ -371,6 +371,4 @@ bool is_subsampled_yuv(const uint32_t base_format);
bool is_exynos_format(uint32_t base_format);
-uint8_t get_exynos_fd_count(uint32_t format);
-
#endif /* MALI_GRALLOC_FORMATS_H_ */