Skip to contentSkip to conversation

vsync + vaapi question

DISCUSSION Lukas Hejtmanek 3 participants 20 messages Dec 18, 2015 – Jan 13, 2016

lore
Share & tools
lore
#0 lore raw

Hello,

is it possible to switch vsync from internal LCD (laptop) to external monitor when playing movie via VA-API? I can drop vsync with internal LCD and keep vsync only with external monitor. I tried to use --primary for excernal monitor when enabling output but no luck.

Is there any way to sync with external monitor? Chris once told me that anything is possible. So? :)

Signature · 5 lines
Lukáš Hejtmánek
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw
Quoted 6 lines · Lukas Hejtmanek

Hello,

is it possible to switch vsync from internal LCD (laptop) to external monitor when playing movie via VA-API? I can drop vsync with internal LCD and keep vsync only with external monitor. I tried to use --primary for excernal monitor when enabling output but no luck.

Not really. The Primary output will be used as the vsync so long as a single pixel of the Window is upon it. Fundamentally, we need to use the output that the Window is on in order to driver the vblank update.

Quoted 2 lines

Is there any way to sync with external monitor? Chris once told me that anything is possible. So? :)

Ville once upon a time mentioned plans to try and synchronise the vblanks on matched outputs, i.e. start two 60Hz monitors at precisely the same time so they remain reasonably in sync.
-Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw
Quoted 3 lines · Chris Wilson

Not really. The Primary output will be used as the vsync so long as a single pixel of the Window is upon it. Fundamentally, we need to use the output that the Window is on in order to driver the vblank update.

Which window? Any window or the va-api window? In the latter case, it would be quite ok to setup left-of instead of clone and move mplayer window solely to the external monitor. Do I understand it correctly?

Quoted 3 lines

Ville once upon a time mentioned plans to try and synchronise the vblanks on matched outputs, i.e. start two 60Hz monitors at precisely the same time so they remain reasonably in sync.

hmm, well, right now, LVDS is running on 60Hz while HDMI2 runs at 30Hz.

Signature · 5 lines
Lukáš Hejtmánek
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#3 lore raw
Quoted 8 lines · Lukas Hejtmanek
Quoted 3 lines · Chris Wilson

Not really. The Primary output will be used as the vsync so long as a single pixel of the Window is upon it. Fundamentally, we need to use the output that the Window is on in order to driver the vblank update.

Which window? Any window or the va-api window? In the latter case, it would be quite ok to setup left-of instead of clone and move mplayer window solely to the external monitor. Do I understand it correctly?

The clipped extents of the va-api Window is used to determine which CRTC to use as the vblank source. Hmm, the Primary Output is used as the preference (i.e. if any part of that Window is on the Primary, it is used as the CRTC - the idea being that Primary is important and this should share the vblank source for more Windows and prevent arbitrary jumps between vblank sources as the Window moves).
-Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#4 lore raw
Quoted 6 lines · Chris Wilson

The clipped extents of the va-api Window is used to determine which CRTC to use as the vblank source. Hmm, the Primary Output is used as the preference (i.e. if any part of that Window is on the Primary, it is used as the CRTC - the idea being that Primary is important and this should share the vblank source for more Windows and prevent arbitrary jumps between vblank sources as the Window moves).

just tested, with xv output, vsync seems to be quite ok. however, with va-api it not ok on both LVDS and HDMI. HDMI seems to be far worse with va-api (i.e. out of sync). Maybe a bug in va-api sync code?

Signature · 5 lines
Lukáš Hejtmánek
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#5 lore raw
Quoted 11 lines · Lukas Hejtmanek
Quoted 6 lines · Chris Wilson

The clipped extents of the va-api Window is used to determine which CRTC to use as the vblank source. Hmm, the Primary Output is used as the preference (i.e. if any part of that Window is on the Primary, it is used as the CRTC - the idea being that Primary is important and this should share the vblank source for more Windows and prevent arbitrary jumps between vblank sources as the Window moves).

just tested, with xv output, vsync seems to be quite ok. however, with va-api it not ok on both LVDS and HDMI. HDMI seems to be far worse with va-api (i.e. out of sync). Maybe a bug in va-api sync code?

Try (libva):

va/x11/dri2_util.c +3 -2
index d076fb3..9ff5e95 100644
@@ -95,8 +95,9 @@ dri2SwapBuffer(VADriverContextP ctx, struct dri_drawable *dri_drawable)
     if (dri2_drawable->has_backbuffer) {
         if (gsDRI2SwapAvailable) {
             CARD64 ret;
-            VA_DRI2SwapBuffers(ctx->native_dpy, dri_drawable->x_drawable, 0, 0,
-                               0, &ret);
+            VA_DRI2SwapBuffers(ctx->native_dpy, dri_drawable->x_drawable,
+                              0, 1, 0,
+                              &ret);
         } else {
             xrect.x = 0;
             xrect.y = 0;
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#6 lore raw
Quoted 1 line · Chris Wilson

Try (libva):

seems to be much better. I got one lockup though but it may be unrelated. Thanks, hope you push it into mainstream.

Quoted 19 lines
va/x11/dri2_util.c +3 -2
index d076fb3..9ff5e95 100644
@@ -95,8 +95,9 @@ dri2SwapBuffer(VADriverContextP ctx, struct dri_drawable *dri_drawable)
     if (dri2_drawable->has_backbuffer) {
         if (gsDRI2SwapAvailable) {
             CARD64 ret;
-            VA_DRI2SwapBuffers(ctx->native_dpy, dri_drawable->x_drawable, 0, 0,
-                               0, &ret);
+            VA_DRI2SwapBuffers(ctx->native_dpy, dri_drawable->x_drawable,
+                              0, 1, 0,
+                              &ret);
         } else {
             xrect.x = 0;
             xrect.y = 0;
Signature · 2 lines
-- 
Chris Wilson, Intel Open Source Technology Centre
Signature · 5 lines
Lukáš Hejtmánek
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#7 lore raw
Quoted 4 lines · Lukas Hejtmanek
Quoted 1 line · Chris Wilson

Try (libva):

seems to be much better. I got one lockup though but it may be unrelated.

Unfortunately probably related, since we now enforce synchronisation to vblank there are a few more bit and pieces involved.

Quoted 1 line

Thanks, hope you push it into mainstream.

Patch sent.
-Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#8 lore raw
Quoted 4 lines · Chris Wilson
Quoted 3 lines · Lukas Hejtmanek
Quoted 1 line · Chris Wilson

Try (libva):

Quoted 8 lines
Quoted 1 line

seems to be much better. I got one lockup though but it may be unrelated.

Unfortunately probably related, since we now enforce synchronisation to vblank there are a few more bit and pieces involved.

Quoted 1 line

Thanks, hope you push it into mainstream.

Patch sent.

huh, maybe it is not good idea. Had to revert it because of number of hard lockups :(

or are there any patches I can try to fix those lockups?

Signature · 5 lines
Lukáš Hejtmánek
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#9 lore raw
Quoted 10 lines · Lukas Hejtmanek
Quoted 9 lines · Chris Wilson
Quoted 4 lines · Lukas Hejtmanek
Quoted 1 line · Chris Wilson

Try (libva):

seems to be much better. I got one lockup though but it may be unrelated.

Unfortunately probably related, since we now enforce synchronisation to vblank there are a few more bit and pieces involved.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Thanks, hope you push it into mainstream.

Patch sent.

huh, maybe it is not good idea. Had to revert it because of number of hard lockups :(

or are there any patches I can try to fix those lockups?

Hard? The fault isn't in libva this time at least. -Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#10 lore raw
Quoted 6 lines · Chris Wilson
Quoted 4 lines

huh, maybe it is not good idea. Had to revert it because of number of hard lockups :(

or are there any patches I can try to fix those lockups?

Hard? The fault isn't in libva this time at least.

applied patch results in hard lockup when playing a movie (short sound loop and even sysrq keys are not working). I thought that driver would reset gpu eventualy but it seems to be completely dead.

So I reverted the patch and it seems lockups are gone.

Signature · 5 lines
Lukáš Hejtmánek
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#11 lore raw
Quoted 11 lines · Lukas Hejtmanek
Quoted 6 lines · Chris Wilson
Quoted 4 lines

huh, maybe it is not good idea. Had to revert it because of number of hard lockups :(

or are there any patches I can try to fix those lockups?

Hard? The fault isn't in libva this time at least.

applied patch results in hard lockup when playing a movie (short sound loop and even sysrq keys are not working). I thought that driver would reset gpu eventualy but it seems to be completely dead.

That's a kernel panic or total machine lockup. Do you have a few different kernels you can try? Hopefully it's a recent regression. -Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#12 lore raw
Quoted 2 lines · Chris Wilson

That's a kernel panic or total machine lockup. Do you have a few different kernels you can try? Hopefully it's a recent regression.

the same for ubuntu's kernel 4.2.0 and 4.3.0.

Signature · 5 lines
Lukáš Hejtmánek
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#13 lore raw
Quoted 5 lines · Lukas Hejtmanek
Quoted 2 lines · Chris Wilson

That's a kernel panic or total machine lockup. Do you have a few different kernels you can try? Hopefully it's a recent regression.

the same for ubuntu's kernel 4.2.0 and 4.3.0.

Keep going... Jump to about 3.19
-Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#14 lore raw
Quoted 8 lines · Chris Wilson
Quoted 5 lines · Lukas Hejtmanek
Quoted 2 lines · Chris Wilson

That's a kernel panic or total machine lockup. Do you have a few different kernels you can try? Hopefully it's a recent regression.

the same for ubuntu's kernel 4.2.0 and 4.3.0.

Keep going... Jump to about 3.19

tried 3.19.0-42 from ubuntu. lockup as well it just took more time..

Signature · 5 lines
Lukáš Hejtmánek
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#15 lore raw
Quoted 11 lines · Lukas Hejtmanek
Quoted 8 lines · Chris Wilson
Quoted 5 lines · Lukas Hejtmanek
Quoted 2 lines · Chris Wilson

That's a kernel panic or total machine lockup. Do you have a few different kernels you can try? Hopefully it's a recent regression.

the same for ubuntu's kernel 4.2.0 and 4.3.0.

Keep going... Jump to about 3.19

tried 3.19.0-42 from ubuntu. lockup as well it just took more time..

Hmm. What hardware? Baytrail?
-Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#16 lore raw
Quoted 3 lines · Chris Wilson
Quoted 1 line

tried 3.19.0-42 from ubuntu. lockup as well it just took more time..

Hmm. What hardware? Baytrail?

Lenovo X1 Carbon 2015. Intel(R) HD Graphics 5500 (according to log) pci id 8086:1616 (rev 09)

Signature · 5 lines
Lukáš Hejtmánek
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#17 lore raw
Quoted 8 lines · Lukas Hejtmanek
Quoted 3 lines · Chris Wilson
Quoted 1 line

tried 3.19.0-42 from ubuntu. lockup as well it just took more time..

Hmm. What hardware? Baytrail?

Lenovo X1 Carbon 2015. Intel(R) HD Graphics 5500 (according to log) pci id 8086:1616 (rev 09)

Quoted 6 lines

--
Lukáš Hejtmánek
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

The 3.19 distro kernel in ubuntu is using 4.2-ish drm backported on broadwell, try http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.19.8-ckt12-vivid/
instead which is stock upstream.
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#19 lore raw
In reply to Lukas Hejtmanek

Hi,

Quoted 7 lines · Lukas Hejtmanek
Quoted 1 line

Hard? The fault isn't in libva this time at least.

applied patch results in hard lockup when playing a movie (short sound loop and even sysrq keys are not working). I thought that driver would reset gpu eventualy but it seems to be completely dead.

So I reverted the patch and it seems lockups are gone.

For ubuntu, that vaapi sync patch just landed. Had to switch to xv from vaapi to avoid frequent lockup. Anything out there I can try to fix lockups?

Signature · 5 lines
Lukáš Hejtmánek
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx