From patchwork Mon May 4 10:48:58 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prashant Laddha X-Patchwork-Id: 6325371 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 15F609F374 for ; Mon, 4 May 2015 11:18:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 31DDC202A1 for ; Mon, 4 May 2015 11:18:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3B30E202FF for ; Mon, 4 May 2015 11:18:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752675AbbEDLSL (ORCPT ); Mon, 4 May 2015 07:18:11 -0400 Received: from bgl-iport-3.cisco.com ([72.163.197.27]:55664 "EHLO bgl-iport-3.cisco.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752558AbbEDLSB (ORCPT ); Mon, 4 May 2015 07:18:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=1582; q=dns/txt; s=iport; t=1430738281; x=1431947881; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=lWYbPOkby43ApVHs9IeMg1v+0vK6IxGH3dyJrcVxYEs=; b=m0JqVUq7FEX2S7NnwsgBIwv0nbYmFvcXtXuKbF70b1bmUj5mQFvDTPzw ZfKTPrwQOqvmlRSPgOxay0HKdcfeKay+x+KqySikR/qRbzyGPHHvIWpaH GTJEgmqSmI1gqTCetSb+otWFhU3nEuXWjwKS3JYyl9ebSDuoYiyQWYErV Q=; X-IronPort-AV: E=Sophos;i="5.13,366,1427760000"; d="scan'208";a="17222374" Received: from vla196-nat.cisco.com (HELO bgl-core-4.cisco.com) ([72.163.197.24]) by bgl-iport-3.cisco.com with ESMTP; 04 May 2015 11:17:59 +0000 Received: from pla-VB.cisco.com ([10.142.58.44]) by bgl-core-4.cisco.com (8.14.5/8.14.5) with ESMTP id t44BHv4b027169; Mon, 4 May 2015 11:17:58 GMT From: Prashant Laddha To: linux-media@vger.kernel.org Cc: Hans Verkuil , Prashant Laddha Subject: [PATCH 1/2] v4l2-ctl-modes: fix hblank, hsync rounding in gtf calculation Date: Mon, 4 May 2015 16:18:58 +0530 Message-Id: <1430736539-28469-2-git-send-email-prladdha@cisco.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1430736539-28469-1-git-send-email-prladdha@cisco.com> References: <1430736539-28469-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 In gtf modeline calculations, currently hblank and hsync are rounded down. hblank needs to be rounded to nearest multiple of twice the cell granularity. hsync needs to be rounded to nearest multiple of cell granularity. Changed the rounding calculation to match it with the equations in standards. Cc: Hans Verkuil Signed-off-by: Prashant Laddha --- utils/v4l2-ctl/v4l2-ctl-modes.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/utils/v4l2-ctl/v4l2-ctl-modes.cpp b/utils/v4l2-ctl/v4l2-ctl-modes.cpp index c775bda..4689006 100644 --- a/utils/v4l2-ctl/v4l2-ctl-modes.cpp +++ b/utils/v4l2-ctl/v4l2-ctl-modes.cpp @@ -457,12 +457,13 @@ bool calc_gtf_modeline(int image_width, int image_height, h_blank = active_h_pixel * ideal_blank_duty_cycle / (100 * HV_FACTOR - ideal_blank_duty_cycle); - h_blank -= h_blank % (2 * GTF_CELL_GRAN); + h_blank = ((h_blank + GTF_CELL_GRAN) / (2 * GTF_CELL_GRAN)) + * (2 * GTF_CELL_GRAN); total_h_pixel = active_h_pixel + h_blank; - h_sync = (total_h_pixel * GTF_HSYNC_PERCENT) / 100; - h_sync -= h_sync % GTF_CELL_GRAN; + h_sync = (total_h_pixel * GTF_HSYNC_PERCENT) / 100; + h_sync = ((h_sync + GTF_CELL_GRAN / 2) / GTF_CELL_GRAN) * GTF_CELL_GRAN; h_fp = h_blank / 2 - h_sync; h_bp = h_fp + h_sync; @@ -509,6 +510,5 @@ bool calc_gtf_modeline(int image_width, int image_height, gtf->flags |= V4L2_DV_FL_REDUCED_BLANKING; } else gtf->polarities = V4L2_DV_VSYNC_POS_POL; - return true; }