[PATCH 01/11] drm: add drm_send_vblank_event() helper
Mario Kleiner
mario.kleiner at tuebingen.mpg.de
Fri Oct 12 17:28:03 PDT 2012
On 11.10.12 16:19, Laurent Pinchart wrote:
> Hi Rob,
>
> Thanks for the patch.
>
> On Monday 08 October 2012 14:50:39 Rob Clark wrote:
>> From: Rob Clark <rob at ti.com>
>>
...
>
> Do you know why some drivers don't call drm_vblank_count_and_time() ? For
> instance nouveau sets the sequence to 0 and uses do_gettimeofday(), but it
> looks like it could just call drm_vblank_count_and_time().
>
At least nouveau could use it. Lucas Stach and me wrote patches for
nouveau-kms, and they went through many iterations and missed many
kernel merge windows due to slow review until i think both of us got
tired of resubmitting with tiny changes. The latest iteration is posted
by Lucas on nouveau-devel from 26. April 2012. Not sure if they'd still
apply after the nouveau-kms rewrite. I'll probably give them another try
once that has landed when i have some spare time.
In principle it's very simple to use drm_vblank_count_and_time(). A
driver needs to
1. Call drm_handle_vblank() from its vblank irq handler.
2. Make sure that in the vblank of pageflip completion
drm_handle_vblank() is called before drm_vblank_count_and_time(), so the
latter picks up updated counts and timestamps.
3. Big bonus for high precision and robustness: Implement the
driver->get_vblank_timestamp() hook to provide a precise vblank
timestamp. One simple way to do that is like radeon-kms or intel-kms do
it: Call back into drm_calc_vbltimestamp_from_scanoutpos() and provide
the driver->get_scanout_position() function - a function that returns
the current hardware scanline counter. This is precise down to ~ 10
microseconds (at least confirmed by measurements on
intel,radeon,nouveau) and robust against delayed vblank irq handling.
-mario
More information about the dri-devel
mailing list