From mboxrd@z Thu Jan 1 00:00:00 1970 From: Laurent Pinchart Subject: Re: [PATCH 01/11] drm: add drm_send_vblank_event() helper Date: Tue, 16 Oct 2012 14:53:01 +0200 Message-ID: <1779281.5yh4JDbOvO@avalon> References: <1349725849-22433-1-git-send-email-rob.clark@linaro.org> <2521012.j15Ecn3JsI@avalon> <5078B593.4000506@tuebingen.mpg.de> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [95.142.166.194]) by gabe.freedesktop.org (Postfix) with ESMTP id 361079E7BB for ; Tue, 16 Oct 2012 05:52:14 -0700 (PDT) In-Reply-To: <5078B593.4000506@tuebingen.mpg.de> 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: Mario Kleiner 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 Hi Mario, On Saturday 13 October 2012 02:28:03 Mario Kleiner wrote: > On 11.10.12 16:19, Laurent Pinchart wrote: > > 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. I totally understand the feeling, but please don't give up. You can CC me on the next iteration, I'll make sure to review the patches (even though I have no experience with the nouveau driver). > 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 -- Regards, Laurent Pinchart