summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Yacoub <markyacoub@google.com>2021-06-21 13:21:46 -0400
committerRodrigo Siqueira <Rodrigo.Siqueira@amd.com>2021-07-08 09:01:51 -0400
commited6bf12d6608af1bc25d1cfdfae09f54e5566284 (patch)
tree7ed9891282b6e1ce857dd23baa2a44effe5bbe90
parent390edfb703c346f06b0850db71bd3cc1342a3c02 (diff)
lib/igt_fb: Support Tile Size for AMD non linear modifiers.
Calculate the width and height of the tile on amdgpu when the modifier is not linear. v1: Change width_ret to bytes not pixels. Cc: bas@basnieuwenhuizen.nl Cc: daniel.vetter@ffwll.ch Signed-off-by: Mark Yacoub <markyacoub@chromium.org> Reviewed-by: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
-rw-r--r--lib/igt_fb.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index 71b89855..acb81518 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -396,6 +396,19 @@ void igt_get_fb_tile_size(int fd, uint64_t modifier, int fb_bpp,
vc4_modifier_param = fourcc_mod_broadcom_param(modifier);
modifier = fourcc_mod_broadcom_mod(modifier);
}
+ // For all non-linear modifiers, AMD uses 64 KiB tiles
+ else if (IS_AMD_FMT_MOD(modifier)) {
+ const int bytes_per_pixel = fb_bpp / 8;
+ const int format_log2 = log2(bytes_per_pixel);
+ const int pixel_log2 = log2(64 * 1024) - format_log2;
+ const int width_log2 = (pixel_log2 + 1) / 2;
+ const int height_log2 = pixel_log2 - width_log2;
+ igt_require_amdgpu(fd);
+
+ *width_ret = bytes_per_pixel << width_log2;
+ *height_ret = 1 << height_log2;
+ return;
+ }
switch (modifier) {
case LOCAL_DRM_FORMAT_MOD_NONE: