diff options
author | George Shen <george.shen@amd.com> | 2024-06-14 21:13:43 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2024-07-01 16:06:53 -0400 |
commit | ac01f6ad710c41c8c2cfab24be8bb71586bf8c44 (patch) | |
tree | ad75898e64debb6a2cca362bd2a54fb2a19e767b /drivers/gpu/drm/amd/display/dc/hubp/dcn401 | |
parent | eb6dfbb7a9c67c7d9bcdb9f9b9131270e2144e3d (diff) | |
download | linux-ac01f6ad710c41c8c2cfab24be8bb71586bf8c44.tar.gz linux-ac01f6ad710c41c8c2cfab24be8bb71586bf8c44.tar.bz2 linux-ac01f6ad710c41c8c2cfab24be8bb71586bf8c44.zip |
drm/amd/display: Fix divide by zero in CURSOR_DST_X_OFFSET calculation
[Why]
Certain situations cause pipes to have a recout of 0, such as when the
dst_rect lies completely outside of a given ODM slice.
[How]
Skip calculation that transforms cursor coordinates to viewport space.
Reviewed-by: Alvin Lee <alvin.lee2@amd.com>
Signed-off-by: Jerry Zuo <jerry.zuo@amd.com>
Signed-off-by: George Shen <george.shen@amd.com>
Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/display/dc/hubp/dcn401')
-rw-r--r-- | drivers/gpu/drm/amd/display/dc/hubp/dcn401/dcn401_hubp.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/drivers/gpu/drm/amd/display/dc/hubp/dcn401/dcn401_hubp.c b/drivers/gpu/drm/amd/display/dc/hubp/dcn401/dcn401_hubp.c index f0c45a74c2e5..eb0da6c6b87c 100644 --- a/drivers/gpu/drm/amd/display/dc/hubp/dcn401/dcn401_hubp.c +++ b/drivers/gpu/drm/amd/display/dc/hubp/dcn401/dcn401_hubp.c @@ -677,12 +677,23 @@ void hubp401_cursor_set_position( int rec_x_offset = x_pos - pos->x_hotspot; int rec_y_offset = y_pos - pos->y_hotspot; int dst_x_offset; - int x_pos_viewport = x_pos * param->viewport.width / param->recout.width; - int x_hot_viewport = pos->x_hotspot * param->viewport.width / param->recout.width; + int x_pos_viewport = 0; + int x_hot_viewport = 0; uint32_t cur_en = pos->enable ? 1 : 0; hubp->curs_pos = *pos; + /* Recout is zero for pipes if the entire dst_rect is contained + * within preceeding ODM slices. + */ + if (param->recout.width) { + x_pos_viewport = x_pos * param->viewport.width / param->recout.width; + x_hot_viewport = pos->x_hotspot * param->viewport.width / param->recout.width; + } else { + ASSERT(!cur_en || x_pos == 0); + ASSERT(!cur_en || pos->x_hotspot == 0); + } + /* * Guard aganst cursor_set_position() from being called with invalid * attributes |