On Thu, Jun 23, 2016 at 8:17 AM, Mario Kleiner <mario.kleiner.de at gmail.com> 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 -- Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch