Skip to content

Commit 6acc619

Browse files
Taimur Hassanalexdeucher
authored andcommitted
drm/amd/display: Round cursor width up for MALL allocation
[Why & How] When calculating cursor size for MALL allocation, the cursor width should be the actual width rounded up to 64 alignment. Additionally, the bit depth should vary depending on color format. Tested-by: Daniel Wheeler <[email protected]> Reviewed-by: Alvin Lee <[email protected]> Acked-by: Pavle Kotarac <[email protected]> Signed-off-by: Taimur Hassan <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 0b15b1e commit 6acc619

File tree

2 files changed

+46
-2
lines changed

2 files changed

+46
-2
lines changed

drivers/gpu/drm/amd/display/dc/dcn32/dcn32_hubp.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ void hubp32_cursor_set_attributes(
103103
enum cursor_lines_per_chunk lpc = hubp2_get_lines_per_chunk(
104104
attr->width, attr->color_format);
105105

106+
//Round cursor width up to next multiple of 64
107+
uint32_t cursor_width = ((attr->width + 63) / 64) * 64;
108+
uint32_t cursor_height = attr->height;
109+
uint32_t cursor_size = cursor_width * cursor_height;
110+
106111
hubp->curs_attr = *attr;
107112

108113
REG_UPDATE(CURSOR_SURFACE_ADDRESS_HIGH,
@@ -126,7 +131,24 @@ void hubp32_cursor_set_attributes(
126131
/* used to shift the cursor chunk request deadline */
127132
CURSOR0_CHUNK_HDL_ADJUST, 3);
128133

129-
if (attr->width * attr->height * 4 > 16384)
134+
switch (attr->color_format) {
135+
case CURSOR_MODE_MONO:
136+
cursor_size /= 2;
137+
break;
138+
case CURSOR_MODE_COLOR_1BIT_AND:
139+
case CURSOR_MODE_COLOR_PRE_MULTIPLIED_ALPHA:
140+
case CURSOR_MODE_COLOR_UN_PRE_MULTIPLIED_ALPHA:
141+
cursor_size *= 4;
142+
break;
143+
144+
case CURSOR_MODE_COLOR_64BIT_FP_PRE_MULTIPLIED:
145+
case CURSOR_MODE_COLOR_64BIT_FP_UN_PRE_MULTIPLIED:
146+
default:
147+
cursor_size *= 8;
148+
break;
149+
}
150+
151+
if (cursor_size > 16384)
130152
REG_UPDATE(DCHUBP_MALL_CONFIG, USE_MALL_FOR_CURSOR, true);
131153
else
132154
REG_UPDATE(DCHUBP_MALL_CONFIG, USE_MALL_FOR_CURSOR, false);

drivers/gpu/drm/amd/display/dc/dcn32/dcn32_hwseq.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,29 @@ void dcn32_update_mall_sel(struct dc *dc, struct dc_state *context)
741741
struct hubp *hubp = pipe->plane_res.hubp;
742742

743743
if (pipe->stream && pipe->plane_state && hubp && hubp->funcs->hubp_update_mall_sel) {
744-
if (hubp->curs_attr.width * hubp->curs_attr.height * 4 > 16384)
744+
//Round cursor width up to next multiple of 64
745+
int cursor_width = ((hubp->curs_attr.width + 63) / 64) * 64;
746+
int cursor_height = hubp->curs_attr.height;
747+
int cursor_size = cursor_width * cursor_height;
748+
749+
switch (hubp->curs_attr.color_format) {
750+
case CURSOR_MODE_MONO:
751+
cursor_size /= 2;
752+
break;
753+
case CURSOR_MODE_COLOR_1BIT_AND:
754+
case CURSOR_MODE_COLOR_PRE_MULTIPLIED_ALPHA:
755+
case CURSOR_MODE_COLOR_UN_PRE_MULTIPLIED_ALPHA:
756+
cursor_size *= 4;
757+
break;
758+
759+
case CURSOR_MODE_COLOR_64BIT_FP_PRE_MULTIPLIED:
760+
case CURSOR_MODE_COLOR_64BIT_FP_UN_PRE_MULTIPLIED:
761+
default:
762+
cursor_size *= 8;
763+
break;
764+
}
765+
766+
if (cursor_size > 16384)
745767
cache_cursor = true;
746768

747769
if (pipe->stream->mall_stream_config.type == SUBVP_PHANTOM) {

0 commit comments

Comments
 (0)