On 06/23/2016 09:28 AM, Daniel Vetter wrote:
On Thu, Jun 23, 2016 at 8:17 AM, Mario Kleiner
<mario.kleiner.de@xxxxxxxxx> wrote:
The following patch implements precise vblank timestamping
for RaspberryPi's VC4, at least for standard progressive
scan display modes.
It has been tested on the HDMI output with half a dozen different
video modes using special hardware measurement equipment to compare
generated time stamps against reality. According to the tests it
works well in its current form.
Due to hw limitations of the VC4, timestamps can't be scanline
accurate when taken within vblank, as explained in the patch,
but at least they will never be off by more than 1 vblank
duration, and are typically still accurate to ~0.1 msecs
for the common case when the timestamping is triggered from
vblank interrupt.
The patch exposed some problems with how the drm core handles
calculation of vblank timestamping constants for interlaced
video modes in drm_calc_timestamping_constants(). Seems it cuts
the expected frame duration framedur_ns into half for interlaced
modes two times, so it ends up expecting a field duration half
of what it should be and then miscalculates vblank counter increments
as soon as vblank timestamping is supported and the core tries to
derive vblank counts from it. To work around this bug, for the
moment the vblank timestamping will disable itself for interlaced
modes and only work for regular progressive scan.
Eric: In the patch i need to calculate fifo_lines as the capacity
of what seems to be a multi-line fifo line buffer for composited output
scanlines between the HVS and the PV, or maybe an input fifo between
the framebuffer(s) and the HVS? The formula i currently use is ad-hoc,
found by trial and error. It works reasonably well for a range of
video modes i could test with my measurement equipment, but it would
be good to replace it by one that is actually accurately derived from
your hardware docs.
Other than that, this should be good to go.
Just out of curiosity: Is there no timestamp register that samples a
refclock on each vblank that could be used instead? That seems to be a
somewhat common feature afaict (but I don't know about vc4).
-Daniel
Not according to what Eric told me. I also couldn't find anything in the
documented register set from vc4_regs.h, or poking around the
neighborhood of those regs. The HVS register i use now seems to be the
only thing one can use to approximate the typical scanoutpos method well
enough to be useful and precise enough.
It would be good to know what other SoCs support such timetamp regs.
Using them probably wouldn't be much more simple than the current
scanoutpos method, with the need to then synchronize/map the gpu clocks
time to the hosts CLOCK_MONOTONIC time, but having the precision
timestamps would be valuable, also for modern compositors.
-mario
_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel