From d7dfab62a9853b44bbcd67dac08391d8e5114c97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= Date: Mon, 23 Apr 2018 18:43:21 +0300 Subject: [PATCH] sna/video/sprite: Retry with GPU scaling if setplane fails MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The kernel may reject the setplane due to eg. exceeding the max downscaling limit of the hardware. In that case let's retry the operation but let the GPU do the scaling for us. Tested on my IVB, after hacking the kernel to reject setplane which exceeds the max hw downscaling limit. Signed-off-by: Ville Syrjälä Reviewed-by: Chris Wilson Signed-off-by: Chris Wilson --- src/sna/sna_video_sprite.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/sna/sna_video_sprite.c b/src/sna/sna_video_sprite.c index 7095e16c..56391aa6 100644 --- a/src/sna/sna_video_sprite.c +++ b/src/sna/sna_video_sprite.c @@ -433,14 +433,16 @@ static int sna_video_sprite_put_image(ddPutImage_ARGS) for (i = 0; i < video->sna->mode.num_real_crtc; i++) { xf86CrtcPtr crtc = config->crtc[i]; struct sna_video_frame frame; - BoxRec dst = draw_extents; - int pipe; + const int pipe = sna_crtc_pipe(crtc); + bool hw_scaling = has_hw_scaling(sna, video); INT32 x1, x2, y1, y2; - RegionRec reg; Rotation rotation; + RegionRec reg; + BoxRec dst; bool cache_bo; - pipe = sna_crtc_pipe(crtc); +retry: + dst = draw_extents; sna_video_frame_init(video, format->id, width, height, &frame); @@ -540,7 +542,7 @@ off: cache_bo = true; } - if (!has_hw_scaling(sna, video) && sna->render.video && + if (!hw_scaling && sna->render.video && !((frame.src.x2 - frame.src.x1) == (dst.x2 - dst.x1) && (frame.src.y2 - frame.src.y1) == (dst.y2 - dst.y1))) { ScreenPtr screen = to_screen_from_sna(sna); @@ -603,8 +605,14 @@ off: else kgem_bo_destroy(&sna->kgem, frame.bo); - if (ret != Success) + if (ret != Success) { + /* retry with GPU scaling */ + if (hw_scaling) { + hw_scaling = false; + goto retry; + } goto err; + } } sna_video_fill_colorkey(video, &clip);