[PATCH 48/50] drm/amd/display: improve logic for addition of modifers
Fangzhi Zuo
Jerry.Zuo at amd.com
Wed Jul 10 19:37:05 UTC 2024
From: Aurabindo Pillai <aurabindo.pillai at amd.com>
Use an extra for loop to reduce duplicate code for adding modifiers
Reviewed-by: Rodrigo Siqueira <Rodrigo.Siqueira at amd.com>
Signed-off-by: Jerry Zuo <jerry.zuo at amd.com>
Signed-off-by: Aurabindo Pillai <aurabindo.pillai at amd.com>
---
.../amd/display/amdgpu_dm/amdgpu_dm_plane.c | 36 +++++++++----------
1 file changed, 17 insertions(+), 19 deletions(-)
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c
index dde4f1dda2e2..dc16d82aced4 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c
@@ -695,28 +695,26 @@ static void amdgpu_dm_plane_add_gfx12_modifiers(struct amdgpu_device *adev,
uint64_t mod_256b = ver | AMD_FMT_MOD_SET(TILE, AMD_FMT_MOD_TILE_GFX12_256B_2D);
uint64_t dcc = ver | AMD_FMT_MOD_SET(DCC, 1);
uint8_t max_comp_block[] = {1, 0};
- uint64_t max_comp_block_mod[2] = {0};
- uint8_t i = 0;
+ uint64_t max_comp_block_mod[ARRAY_SIZE(max_comp_block)] = {0};
+ uint8_t i = 0, j = 0;
+ uint64_t gfx12_modifiers[] = {mod_256k, mod_64k, mod_4k, mod_256b, DRM_FORMAT_MOD_LINEAR};
- /* With DCC: Best choice should be kept first. Hence, add all 256k modifiers of different
- * max compressed blocks first and then move on to the next smaller sized layouts */
for (i = 0; i < 2; i++)
max_comp_block_mod[i] = AMD_FMT_MOD_SET(DCC_MAX_COMPRESSED_BLOCK, max_comp_block[i]);
- for (i = 0; i < 2; i++)
- amdgpu_dm_plane_add_modifier(mods, size, capacity, ver | dcc | max_comp_block_mod[i] | mod_256k);
- for (i = 0; i < 2; i++)
- amdgpu_dm_plane_add_modifier(mods, size, capacity, ver | dcc | max_comp_block_mod[i] | mod_64k);
- for (i = 0; i < 2; i++)
- amdgpu_dm_plane_add_modifier(mods, size, capacity, ver | dcc | max_comp_block_mod[i] | mod_4k);
- for (i = 0; i < 2; i++)
- amdgpu_dm_plane_add_modifier(mods, size, capacity, ver | dcc | max_comp_block_mod[i] | mod_256b);
-
- /* Without DCC: */
- amdgpu_dm_plane_add_modifier(mods, size, capacity, ver | mod_256k);
- amdgpu_dm_plane_add_modifier(mods, size, capacity, ver | mod_64k);
- amdgpu_dm_plane_add_modifier(mods, size, capacity, ver | mod_4k);
- amdgpu_dm_plane_add_modifier(mods, size, capacity, ver | mod_256b);
- amdgpu_dm_plane_add_modifier(mods, size, capacity, DRM_FORMAT_MOD_LINEAR);
+
+ /* With DCC: Best choice should be kept first. Hence, add all 256k modifiers of different
+ * max compressed blocks first and then move on to the next smaller sized layouts.
+ * Do not add the linear modifier here, and hence the condition of size-1 for the loop
+ */
+ for (j = 0; j < ARRAY_SIZE(gfx12_modifiers) - 1; j++)
+ for (i = 0; i < ARRAY_SIZE(max_comp_block); i++)
+ amdgpu_dm_plane_add_modifier(mods, size, capacity,
+ ver | dcc | max_comp_block_mod[i] | gfx12_modifiers[j]);
+
+ /* Without DCC. Add all modifiers including linear at the end */
+ for (i = 0; i < ARRAY_SIZE(gfx12_modifiers); i++)
+ amdgpu_dm_plane_add_modifier(mods, size, capacity, gfx12_modifiers[i]);
+
}
static int amdgpu_dm_plane_get_plane_modifiers(struct amdgpu_device *adev, unsigned int plane_type, uint64_t **mods)
--
2.34.1
More information about the amd-gfx
mailing list