minigbm: format fix

BUG=n/a
TEST=./presubmit.sh

Change-Id: Ic581ebe770c648ee344cfbe20ba6655786a2088e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/5505015
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Satoshi Niwa <niwa@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
This commit is contained in:
Yiwei Zhang 2024-04-30 22:22:30 -07:00 committed by Chromeos LUCI
parent 772c24c476
commit 8291bfe6f1
6 changed files with 49 additions and 52 deletions

67
i915.c
View file

@ -37,18 +37,17 @@ static const uint32_t texture_only_formats[] = { DRM_FORMAT_R8, DRM_FORMAT_NV12,
static const uint64_t gen_modifier_order[] = { I915_FORMAT_MOD_Y_TILED_CCS, I915_FORMAT_MOD_Y_TILED,
I915_FORMAT_MOD_X_TILED, DRM_FORMAT_MOD_LINEAR };
static const uint64_t gen12_modifier_order[] = {
I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS, I915_FORMAT_MOD_Y_TILED_GEN12_MC_CCS,
I915_FORMAT_MOD_Y_TILED, I915_FORMAT_MOD_X_TILED, DRM_FORMAT_MOD_LINEAR
};
static const uint64_t gen12_modifier_order[] = { I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS,
I915_FORMAT_MOD_Y_TILED_GEN12_MC_CCS,
I915_FORMAT_MOD_Y_TILED, I915_FORMAT_MOD_X_TILED,
DRM_FORMAT_MOD_LINEAR };
static const uint64_t gen11_modifier_order[] = { I915_FORMAT_MOD_Y_TILED, I915_FORMAT_MOD_X_TILED,
DRM_FORMAT_MOD_LINEAR };
static const uint64_t xe_lpdp_modifier_order[] = { I915_FORMAT_MOD_4_TILED_MTL_RC_CCS,
I915_FORMAT_MOD_4_TILED_MTL_MC_CCS,
I915_FORMAT_MOD_4_TILED,
I915_FORMAT_MOD_X_TILED,
I915_FORMAT_MOD_4_TILED, I915_FORMAT_MOD_X_TILED,
DRM_FORMAT_MOD_LINEAR };
struct modifier_support_t {
@ -114,12 +113,13 @@ static void i915_info_from_device_id(struct i915_device *i915)
0x46b3, 0x46c0, 0x46c1, 0x46c2, 0x46c3, 0x9A40, 0x9A49, 0x9A59, 0x9A60, 0x9A68,
0x9A70, 0x9A78, 0x9AC0, 0x9AC9, 0x9AD9, 0x9AF8, 0x4905, 0x4906, 0x4907, 0x4908
};
const uint16_t adlp_ids[] = { 0x46A0, 0x46A1, 0x46A2, 0x46A3, 0x46A6, 0x46A8, 0x46AA,
0x462A, 0x4626, 0x4628, 0x46B0, 0x46B1, 0x46B2, 0x46B3,
0x46C0, 0x46C1, 0x46C2, 0x46C3, 0x46D0, 0x46D1, 0x46D2,
0x46D3, 0x46D4 };
const uint16_t adlp_ids[] = { 0x46A0, 0x46A1, 0x46A2, 0x46A3, 0x46A6, 0x46A8,
0x46AA, 0x462A, 0x4626, 0x4628, 0x46B0, 0x46B1,
0x46B2, 0x46B3, 0x46C0, 0x46C1, 0x46C2, 0x46C3,
0x46D0, 0x46D1, 0x46D2, 0x46D3, 0x46D4 };
const uint16_t rplp_ids[] = { 0xA720, 0xA721, 0xA7A0, 0xA7A1, 0xA7A8, 0xA7A9, 0xA7AA, 0xA7AB, 0xA7AC, 0xA7AD };
const uint16_t rplp_ids[] = { 0xA720, 0xA721, 0xA7A0, 0xA7A1, 0xA7A8,
0xA7A9, 0xA7AA, 0xA7AB, 0xA7AC, 0xA7AD };
const uint16_t mtl_ids[] = { 0x7D40, 0x7D60, 0x7D45, 0x7D55, 0x7DD5 };
@ -573,13 +573,13 @@ static size_t i915_num_planes_from_modifier(struct driver *drv, uint32_t format,
return num_planes;
}
#define gbm_fls(x) ((x) ? __builtin_choose_expr(sizeof(x) == 8, \
64 - __builtin_clzll(x), \
32 - __builtin_clz(x)) : 0)
#define gbm_fls(x) \
((x) ? __builtin_choose_expr(sizeof(x) == 8, 64 - __builtin_clzll(x), \
32 - __builtin_clz(x)) \
: 0)
#define roundup_power_of_two(x) ((x) != 0 ? 1ULL << gbm_fls((x) - 1) : 0)
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)
{
@ -601,17 +601,16 @@ static int i915_bo_compute_metadata(struct bo *bo, uint32_t width, uint32_t heig
* gbm_bo_create_with_modifiers().
*/
assert(modifier != I915_FORMAT_MOD_Y_TILED_GEN12_MC_CCS &&
modifier != I915_FORMAT_MOD_4_TILED_MTL_MC_CCS);
modifier != I915_FORMAT_MOD_4_TILED_MTL_MC_CCS);
/* TODO(b/323863689): Account for driver's bandwidth compression in minigbm for
* media compressed buffers. */
}
if ((modifier == I915_FORMAT_MOD_Y_TILED_GEN12_MC_CCS ||
modifier == I915_FORMAT_MOD_4_TILED_MTL_MC_CCS) &&
!(format == DRM_FORMAT_NV12 || format == DRM_FORMAT_P010))
{
drv_loge("Media compression is only supported for NV12 and P010\n");
return -EINVAL;
}
modifier == I915_FORMAT_MOD_4_TILED_MTL_MC_CCS) &&
!(format == DRM_FORMAT_NV12 || format == DRM_FORMAT_P010)) {
drv_loge("Media compression is only supported for NV12 and P010\n");
return -EINVAL;
}
/*
* i915 only supports linear/x-tiled above 4096 wide on Gen9/Gen10 GPU.
@ -802,21 +801,20 @@ static int i915_bo_compute_metadata(struct bo *bo, uint32_t width, uint32_t heig
* gbm_bo_create_with_modifiers() path, i.e., the minigbm client needs to
* explicitly request it.
*/
assert(modifier != I915_FORMAT_MOD_4_TILED_MTL_MC_CCS || use_flags == BO_USE_NONE);
assert(modifier != I915_FORMAT_MOD_4_TILED_MTL_MC_CCS ||
use_flags == BO_USE_NONE);
bo->meta.use_flags == BO_USE_NONE);
assert(modifier != I915_FORMAT_MOD_4_TILED_MTL_MC_CCS ||
bo->meta.use_flags == BO_USE_NONE);
(!!modifiers && count > 0));
assert(modifier != I915_FORMAT_MOD_4_TILED_MTL_MC_CCS ||
(!!modifiers && count > 0));
assert(modifier != I915_FORMAT_MOD_4_TILED_MTL_MC_CCS ||
(format == DRM_FORMAT_NV12 || format == DRM_FORMAT_P010 ||
format == DRM_FORMAT_XRGB8888 || format == DRM_FORMAT_XBGR8888));
(format == DRM_FORMAT_NV12 || format == DRM_FORMAT_P010 ||
format == DRM_FORMAT_XRGB8888 || format == DRM_FORMAT_XBGR8888));
assert(drv_num_planes_from_format(format) > 0);
uint32_t offset = 0, stride = 0;
size_t plane = 0;
size_t a_plane = 0;
for(plane = 0; plane < drv_num_planes_from_format(format); plane++) {
for (plane = 0; plane < drv_num_planes_from_format(format); plane++) {
uint32_t alignment = 0, val, tmpoffset = 0;
/*
@ -829,7 +827,8 @@ static int i915_bo_compute_metadata(struct bo *bo, uint32_t width, uint32_t heig
/* MTL needs 1MB Alignment */
bo->meta.sizes[plane] = ALIGN(stride * height, 0x100000);
if (plane == 1 && (format == DRM_FORMAT_NV12 || format == DRM_FORMAT_P010)) {
if (plane == 1 &&
(format == DRM_FORMAT_NV12 || format == DRM_FORMAT_P010)) {
alignment = 1 << 20;
offset += alignment - (offset % alignment);
tmpoffset = offset;
@ -845,12 +844,13 @@ static int i915_bo_compute_metadata(struct bo *bo, uint32_t width, uint32_t heig
/* Aux buffer is linear and page aligned. It is placed after
* other planes and aligned to main buffer stride.
*/
for(a_plane = 0; a_plane < plane; a_plane++) {
for (a_plane = 0; a_plane < plane; a_plane++) {
stride = bo->meta.strides[a_plane] / 8;
bo->meta.strides[a_plane + plane] = stride;
/* Aligned to page size */
bo->meta.sizes[a_plane + plane] = ALIGN(bo->meta.sizes[a_plane] / 256, getpagesize());
bo->meta.sizes[a_plane + plane] =
ALIGN(bo->meta.sizes[a_plane] / 256, getpagesize());
bo->meta.offsets[a_plane + plane] = offset;
/* next buffer offset */
offset += bo->meta.sizes[plane + a_plane];
@ -922,8 +922,7 @@ static int i915_bo_create_from_metadata(struct bo *bo)
}
}
bo->meta.cached = (i915->has_llc || i915->is_mtl) &&
!(bo->meta.use_flags & BO_USE_SCANOUT);
bo->meta.cached = (i915->has_llc || i915->is_mtl) && !(bo->meta.use_flags & BO_USE_SCANOUT);
return 0;
}