From: Mario Kleiner Subject: Re: [PATCH 01/11] drm: add drm_send_vblank_event() helper Date: Sat, 13 Oct 2012 02:28:03 +0200 Message-ID: <5078B593.4000506@tuebingen.mpg.de> References: <1349725849-22433-1-git-send-email-rob.clark@linaro.org> <1349725849-22433-2-git-send-email-rob.clark@linaro.org> <2521012.j15Ecn3JsI@avalon> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: Received: from mx2.mpg.de (mx2.mpg.de [134.76.10.35]) by gabe.freedesktop.org (Postfix) with ESMTP id DB7259E853 for ; Fri, 12 Oct 2012 17:28:05 -0700 (PDT) In-Reply-To: <2521012.j15Ecn3JsI@avalon> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org Errors-To: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org To: Laurent Pinchart Cc: patches@linaro.org, daniel.vetter@ffwll.ch, dri-devel@lists.freedesktop.org, Rob Clark , bskeggs@redhat.com, gregkh@linuxfoundation.org, Rob Clark List-Id: dri-devel@lists.freedesktop.org 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 >> ... > > 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