From patchwork Wed Apr 8 13:09:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prashant Laddha X-Patchwork-Id: 6179661 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B880EBF4A6 for ; Wed, 8 Apr 2015 13:20:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DBCD220376 for ; Wed, 8 Apr 2015 13:20:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DCADC20328 for ; Wed, 8 Apr 2015 13:20:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754184AbbDHNUc (ORCPT ); Wed, 8 Apr 2015 09:20:32 -0400 Received: from bgl-iport-1.cisco.com ([72.163.197.25]:59675 "EHLO bgl-iport-1.cisco.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753089AbbDHNUa (ORCPT ); Wed, 8 Apr 2015 09:20:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=2211; q=dns/txt; s=iport; t=1428499229; x=1429708829; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=302Hw7gfGGaGq3MeEjdpImT2BzeAkEI4nmImzEYCicw=; b=EhiCubLO4rjD+ZuEnRsEJW9gsF4ayMysvmLR4NTMYnBG0SmRf6TaZ7ST 6VBgfQRx8+fDLdpu++IGBv5pM4mdl+LYapzwWqvQjafNFtIpaoIAX4lmH FZWAIHAPOQxgtgUTLr72yWaT/QHre/mlzxyEr3y45aXAJEuNaY8CXxPO3 I=; X-IronPort-AV: E=Sophos;i="5.11,544,1422921600"; d="scan'208";a="51048822" Received: from vla196-nat.cisco.com (HELO bgl-core-2.cisco.com) ([72.163.197.24]) by bgl-iport-1.cisco.com with ESMTP; 08 Apr 2015 13:09:32 +0000 Received: from pla-VB.cisco.com ([10.142.61.66]) by bgl-core-2.cisco.com (8.14.5/8.14.5) with ESMTP id t38D9V0U015562; Wed, 8 Apr 2015 13:09:32 GMT From: Prashant Laddha To: linux-media@vger.kernel.org Cc: Hans Verkuil , Martin Bugge , Prashant Laddha Subject: [PATCH 1/2] v4l2-dv-timings: fix rounding error in vsync_bp calculation Date: Wed, 8 Apr 2015 18:39:28 +0530 Message-Id: <1428498569-6751-2-git-send-email-prladdha@cisco.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1428498569-6751-1-git-send-email-prladdha@cisco.com> References: <1428498569-6751-1-git-send-email-prladdha@cisco.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-14.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY, USER_IN_DEF_DKIM_WL autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Changed the rounding offsets used in vsync_bp calculation in cvt and gtf timings. The results for vsync_bp should now match with results from timing generator spreadsheets for cvt and gtf standards. In the vsync_bp calculation for cvt, always round down the value of (CVT_MIN_VSYNC_BP / h_period_est) and then add 1. It thus, reflects the equation used in timing generator spreadsheet. Using 1999999 as rounding offset, could pontentially lead to bumping up the vsync_bp value by extra 1. In the vsync_bp calculations for gtf, instead of round up or round down, round the (CVT_MIN_VSYNC_BP / h_period_est) to the nearest integer. Cc: Hans Verkuil Cc: Martin Bugge Thanks to Martin Bugge for validating with standards and suggestions on equations. Signed-off-by: Prashant Laddha --- drivers/media/v4l2-core/v4l2-dv-timings.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-dv-timings.c b/drivers/media/v4l2-core/v4l2-dv-timings.c index 80e4722..5e114ee 100644 --- a/drivers/media/v4l2-core/v4l2-dv-timings.c +++ b/drivers/media/v4l2-core/v4l2-dv-timings.c @@ -367,14 +367,14 @@ bool v4l2_detect_cvt(unsigned frame_height, unsigned hfreq, unsigned vsync, /* Vertical */ if (reduced_blanking) { v_fp = CVT_RB_V_FPORCH; - v_bp = (CVT_RB_MIN_V_BLANK * hfreq + 1999999) / 1000000; + v_bp = (CVT_RB_MIN_V_BLANK * hfreq) / 1000000 + 1; v_bp -= vsync + v_fp; if (v_bp < CVT_RB_MIN_V_BPORCH) v_bp = CVT_RB_MIN_V_BPORCH; } else { v_fp = CVT_MIN_V_PORCH_RND; - v_bp = (CVT_MIN_VSYNC_BP * hfreq + 1999999) / 1000000 - vsync; + v_bp = (CVT_MIN_VSYNC_BP * hfreq) / 1000000 + 1 - vsync; if (v_bp < CVT_MIN_V_BPORCH) v_bp = CVT_MIN_V_BPORCH; @@ -543,7 +543,7 @@ bool v4l2_detect_gtf(unsigned frame_height, /* Vertical */ v_fp = GTF_V_FP; - v_bp = (GTF_MIN_VSYNC_BP * hfreq + 999999) / 1000000 - vsync; + v_bp = (GTF_MIN_VSYNC_BP * hfreq + 500000) / 1000000 - vsync; if (scan == V4L2_DV_INTERLACED) image_height = (frame_height - 2 * v_fp - 2 * vsync - 2 * v_bp)