-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dispmanx vsync callback is called 4 times per frame #218
Comments
Hi I think this should be reported in the firmware repository (https://github.com/raspberrypi/firmware/issues) rather than userland. Having said that I can see a similar issue. I wrote the following when the vsync_callback was first added. #include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/time.h>
#include "bcm_host.h"
volatile uint32_t count = 0;
void
vsync_callback(
DISPMANX_UPDATE_HANDLE_T update,
void *arg)
{
++count;
}
int
main(void)
{
struct timeval startTime;
struct timeval endTime;
struct timeval diffTime;
bcm_host_init();
DISPMANX_DISPLAY_HANDLE_T display = vc_dispmanx_display_open(0);
vc_dispmanx_vsync_callback(display, vsync_callback, NULL);
gettimeofday(&startTime, NULL);
while (1)
{
sleep(1);
gettimeofday(&endTime, NULL);
timersub(&endTime, &startTime, &diffTime);
double fps = count/(diffTime.tv_sec+(diffTime.tv_usec/1000000.0));
printf("fps = %0.1f\n", fps);
}
return 0;
} When run, it would reliably print out fps=50.0 (pal composite display). When I relinked it today (after rebuilding)
firmware version
|
Actually, after a firmware update and a reboot, it went back to working as I expected
I do wonder about your code. The printf in the callback may cause some problems. |
i had done similar code using GPIO
https://www.dropbox.com/s/d4na2naqjlidrzm/20150206_184717.jpg?dl=0 top trace is the gpio pin, showing several callbacks per frame, bottom is the raw composite video, v-sync is over the E in peakdet and if i switch to single sweep mode i can confirm the timings ali1234 saw, the first 9 fields have 1 callback each, then it starts to go nuts |
After firmware update it works for me too. I'm now on: |
same here, jan 20th was broken, feb 7th works |
yeah, i see the problem now
if you forget to turn the vsync off with this (or the app crashes), you get an extra callback next time you run the app so the 1st time you run it, 1 call per field this explains why it always vanished after a reboot i have a feeling that 2 apps using v-sync at once will likely also cause the issue, and that is a valid use case, ali1234 would be outputing teletext in the VBI while something else (3d, omx?) does v-sync |
And if you run two programs at the same time that listen for vsync, the first one gets no callbacks and the second one gets two. (Most likely it's just random/race condition which app gets the event.) |
Also as soon as any app calls
ALL callbacks stop firing in all apps. |
Please run rpi-update and test. |
kernel: fiq_fsm: Falling out of the state machine isn't fatal See: raspberrypi/linux#739 kernel: rtl8192cu: Add PID for D-Link DWA 131 See: raspberrypi/linux#818 firmware: vc_dispmanx: Fix update/vsync callbacks See: #355 firmware: dispserv: Clean up vsync requests on client disconnection See: raspberrypi/userland#218 firmware: [hdmi] Work around an issue with Toshiba TV See: http://www.raspberrypi.org/forums/viewtopic.php?f=28&t=62155 firmware: Allow Pi1/Pi2 and EDID device id specific config options See: #361 See: #320
kernel: fiq_fsm: Falling out of the state machine isn't fatal See: raspberrypi/linux#739 kernel: rtl8192cu: Add PID for D-Link DWA 131 See: raspberrypi/linux#818 firmware: vc_dispmanx: Fix update/vsync callbacks See: raspberrypi/firmware#355 firmware: dispserv: Clean up vsync requests on client disconnection See: raspberrypi/userland#218 firmware: [hdmi] Work around an issue with Toshiba TV See: http://www.raspberrypi.org/forums/viewtopic.php?f=28&t=62155 firmware: Allow Pi1/Pi2 and EDID device id specific config options See: raspberrypi/firmware#361 See: raspberrypi/firmware#320
Feb 12 2015 17:27:39 Identical behaviour. On 12 February 2015 at 18:10, popcornmix [email protected] wrote:
Alistair Buxton |
Actually the vsync is cleaned up on exit automatically now, but if two apps register a callback, one of them still gets two events, and clearing the callback still clears it for all apps. |
kernel: Align pcm512x driver with upstream See: raspberrypi/linux#873 kernel: dts: overlay: add mz61581, fix piscreen and rpi-display See: raspberrypi/linux#874 kernel: bcm2709: Increase the spare/free IRQs to match bcm2708 See: raspberrypi/linux#871 kernel: add support for Adafruit PiTFT See: raspberrypi/linux#858 firmware: dispserve: Allow vsync requests from multiple clients See: raspberrypi/userland#218 firmware: hello_fft: Update to version 3 See: http://www.aholme.co.uk/GPU_FFT/Main.htm
kernel: Align pcm512x driver with upstream See: raspberrypi/linux#873 kernel: dts: overlay: add mz61581, fix piscreen and rpi-display See: raspberrypi/linux#874 kernel: bcm2709: Increase the spare/free IRQs to match bcm2708 See: raspberrypi/linux#871 kernel: add support for Adafruit PiTFT See: raspberrypi/linux#858 firmware: dispserve: Allow vsync requests from multiple clients See: raspberrypi/userland#218 firmware: hello_fft: Update to version 3 See: http://www.aholme.co.uk/GPU_FFT/Main.htm
Latest rpi-firmware code has an update to fix an issue with mulitple apps registering vsync callbacks. Can you test? |
Looks like it is fixed. Multiple programs can now vsync, and don't steal messages from each other. Forgetting to unregister the callback at exit also doesn't seem to cause any problems. |
Okay to close? |
kernel: fiq_fsm: Falling out of the state machine isn't fatal See: raspberrypi/linux#739 kernel: rtl8192cu: Add PID for D-Link DWA 131 See: raspberrypi/linux#818 firmware: vc_dispmanx: Fix update/vsync callbacks See: raspberrypi#355 firmware: dispserv: Clean up vsync requests on client disconnection See: raspberrypi/userland#218 firmware: [hdmi] Work around an issue with Toshiba TV See: http://www.raspberrypi.org/forums/viewtopic.php?f=28&t=62155 firmware: Allow Pi1/Pi2 and EDID device id specific config options See: raspberrypi#361 See: raspberrypi#320
kernel: Align pcm512x driver with upstream See: raspberrypi/linux#873 kernel: dts: overlay: add mz61581, fix piscreen and rpi-display See: raspberrypi/linux#874 kernel: bcm2709: Increase the spare/free IRQs to match bcm2708 See: raspberrypi/linux#871 kernel: add support for Adafruit PiTFT See: raspberrypi/linux#858 firmware: dispserve: Allow vsync requests from multiple clients See: raspberrypi/userland#218 firmware: hello_fft: Update to version 3 See: http://www.aholme.co.uk/GPU_FFT/Main.htm
The following example runs for 1 second and measures the time between calls to the vsync callback in microseconds. With PAL composite out, the time between each call should be 20000 microseconds if the vsync happens per field.
The callback fires correctly about 20 times, then it starts firing 4 times per field. Same happens when using HDMI output.
Test code:
Output:
The text was updated successfully, but these errors were encountered: