From patchwork Thu Dec 27 01:01:46 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Kurtz X-Patchwork-Id: 1911711 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork2.kernel.org (Postfix) with ESMTP id 4F24ADF230 for ; Thu, 27 Dec 2012 01:02:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EA40EE6010 for ; Wed, 26 Dec 2012 17:02:03 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pa0-f53.google.com (mail-pa0-f53.google.com [209.85.220.53]) by gabe.freedesktop.org (Postfix) with ESMTP id 12A8EE5BF3 for ; Wed, 26 Dec 2012 17:01:53 -0800 (PST) Received: by mail-pa0-f53.google.com with SMTP id hz1so5142813pad.26 for ; Wed, 26 Dec 2012 17:01:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=x-received:from:to:cc:subject:date:message-id:x-mailer; bh=6Ncl9FRHQi7jwsWfY5/QY2GGB5fxtJYWzpUnXWL6WBs=; b=m3z+DgQbNqm2crQT5JT2CdV+zFW/Qxu+5ouasSjO302j8hgBXT8R7MffVPe/odWfWT FaHafXBOAEgdR8uOkYHZIrxGBE83VnNyC/mbl4m9XCgrz8qxdaRWAjtDRoHru65IWp9y GTt2MK+PKTtdJOLTGsFWSMZi4+eXdjVefGw0s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=6Ncl9FRHQi7jwsWfY5/QY2GGB5fxtJYWzpUnXWL6WBs=; b=mi+1/sPWJl6QsAfYTtaVVDBlTN0mMp/9EKYDOM063p+nZ7RA1Ka2O2mJRcVWnRAuui U411RGn/Pzo14K9t5K2deKydW3UpLena9MAStcGHGJ+SjrQPwaLJDXXnXUaJbY8cjOlF WX0lkzWZocCei/tM3W+G89maYA1XqvNsptLdoZHrQckbOkS8gxuBVvmoyHEbd3wQR3Ra cbXYb6uFk2lkoptDA+etbjxPkMtG8cCRKhTyYyJwAttSRfl4p2+j7VkpYTsbe35XhXj0 QpeZQOV76khJIktCZ6OwAQ+XFf5hIvCGUkZpyugrz116mNzLnneypMaCTNiD3s10l7XQ 7Vzw== X-Received: by 10.68.245.167 with SMTP id xp7mr91790344pbc.75.1356570112967; Wed, 26 Dec 2012 17:01:52 -0800 (PST) Received: from djkurtzt530-glaptop.corp.google.com ([172.30.22.134]) by mx.google.com with ESMTPS id oj1sm16753332pbb.19.2012.12.26.17.01.50 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 26 Dec 2012 17:01:52 -0800 (PST) From: Daniel Kurtz To: David Airlie Subject: [PATCH] drm: make frame duration time calculation more precise Date: Thu, 27 Dec 2012 09:01:46 +0800 Message-Id: <1356570106-2263-1-git-send-email-djkurtz@chromium.org> X-Mailer: git-send-email 1.7.7.3 X-Gm-Message-State: ALoCoQkAUUptCDV6T6egJKv2e1B56wC4X4e4D7MK/j/OprFEJX4rHMCFehpKZ7vfcfPXls0TfGtg Cc: marcheu@chromium.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org It is a bit more precise to compute the total number of pixels first and then divide, rather than multiplying the line pixel count by the already-rounded line duration. Signed-off-by: Daniel Kurtz --- drivers/gpu/drm/drm_irq.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c index 19c01ca..05c91e0 100644 --- a/drivers/gpu/drm/drm_irq.c +++ b/drivers/gpu/drm/drm_irq.c @@ -505,6 +505,7 @@ void drm_calc_timestamping_constants(struct drm_crtc *crtc) /* Valid dotclock? */ if (dotclock > 0) { + int frame_size; /* Convert scanline length in pixels and video dot clock to * line duration, frame duration and pixel duration in * nanoseconds: @@ -512,7 +513,10 @@ void drm_calc_timestamping_constants(struct drm_crtc *crtc) pixeldur_ns = (s64) div64_u64(1000000000, dotclock); linedur_ns = (s64) div64_u64(((u64) crtc->hwmode.crtc_htotal * 1000000000), dotclock); - framedur_ns = (s64) crtc->hwmode.crtc_vtotal * linedur_ns; + frame_size = crtc->hwmode.crtc_htotal * + crtc->hwmode.crtc_vtotal; + framedur_ns = (s64) div64_u64((u64) frame_size * 1000000000, + dotclock); } else DRM_ERROR("crtc %d: Can't calculate constants, dotclock = 0!\n", crtc->base.id);