From patchwork Tue Jun 9 17:16: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: 6574271 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 49EC19F402 for ; Tue, 9 Jun 2015 17:17:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5E45E20523 for ; Tue, 9 Jun 2015 17:17:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8DDDF204AD for ; Tue, 9 Jun 2015 17:17:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753738AbbFIRRE (ORCPT ); Tue, 9 Jun 2015 13:17:04 -0400 Received: from bgl-iport-1.cisco.com ([72.163.197.25]:34791 "EHLO bgl-iport-1.cisco.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751075AbbFIRRD (ORCPT ); Tue, 9 Jun 2015 13:17:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=3696; q=dns/txt; s=iport; t=1433870224; x=1435079824; h=from:to:cc:subject:date:message-id; bh=A8BcP4vZkjOTiiTH8/csrogvnAmJxCw5P63Li/11vK8=; b=PcGo9mKTlICazpCBWh84ULqwWVe86VSDUEE+nkREhX2E6NIHiYyTkuOB dzuVfqBbJ+wuscPYHhLN9Dc/IgKW4+W+81/1IVTcNrV08PCWz4uGw0tw8 cpxBXFx9L70NeoJGEEqGQsUKiKTIWZYSRPmVSG/irUmN5Ge/88yTwzRFD 8=; X-IronPort-AV: E=Sophos;i="5.13,582,1427760000"; d="scan'208";a="52640298" Received: from vla196-nat.cisco.com (HELO bgl-core-3.cisco.com) ([72.163.197.24]) by bgl-iport-1.cisco.com with ESMTP; 09 Jun 2015 17:17:00 +0000 Received: from pla-VB.cisco.com ([10.65.72.180]) by bgl-core-3.cisco.com (8.14.5/8.14.5) with ESMTP id t59HGx1f013163; Tue, 9 Jun 2015 17:16:59 GMT From: Prashant Laddha To: Cc: Linux Media Mailing List , Prashant Laddha Subject: [PATCH] v4l2-ctl-modes: add support for reduced blanking v2 Date: Tue, 9 Jun 2015 22:46:58 +0530 Message-Id: <1433870218-18107-1-git-send-email-prladdha@cisco.com> X-Mailer: git-send-email 1.9.1 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 Currently, if reduced blanking flag is set to true, cvt timings are calculated for reduced blanking version 2. To Do: extend the cvt options to inlcude rb v2. Signed-off-by: Prashant Laddha --- utils/v4l2-ctl/v4l2-ctl-modes.cpp | 40 +++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/utils/v4l2-ctl/v4l2-ctl-modes.cpp b/utils/v4l2-ctl/v4l2-ctl-modes.cpp index 7422bc5..cfe4086 100644 --- a/utils/v4l2-ctl/v4l2-ctl-modes.cpp +++ b/utils/v4l2-ctl/v4l2-ctl-modes.cpp @@ -52,6 +52,7 @@ static bool valid_params(int width, int height, int refresh_rate) */ #define CVT_PXL_CLK_GRAN (250000) /* pixel clock granularity */ +#define CVT_PXL_CLK_GRAN_RB_V2 (1000) /* granularity for reduced blanking v2*/ /* Normal blanking */ #define CVT_MIN_V_BPORCH (7) /* lines */ @@ -77,6 +78,12 @@ static bool valid_params(int width, int height, int refresh_rate) #define CVT_RB_H_BPORCH (80) /* pixels */ #define CVT_RB_H_BLANK (160) /* pixels */ +/* Reduce blanking Version 2 */ +#define CVT_RB_V2_H_BLANK 80 /* pixels */ +#define CVT_RB_MIN_V_FPORCH 3 /* lines */ +#define CVT_RB_V2_MIN_V_FPORCH 1 /* lines */ +#define CVT_RB_V_BPORCH 6 /* lines */ + static int v_sync_from_aspect_ratio(int width, int height) { if (((height * 4 / 3) / CVT_CELL_GRAN) * CVT_CELL_GRAN == width) @@ -148,6 +155,11 @@ bool calc_cvt_modeline(int image_width, int image_height, int interlace; int v_refresh; int pixel_clock; + int clk_gran; + bool rb_v2 = false; + + rb_v2 = reduced_blanking ? true : false; + clk_gran = rb_v2 ? CVT_PXL_CLK_GRAN_RB_V2 : CVT_PXL_CLK_GRAN; if (!valid_params(image_width, image_height, refresh_rate)) return false; @@ -186,7 +198,7 @@ bool calc_cvt_modeline(int image_width, int image_height, active_h_pixel = h_pixel_rnd; active_v_lines = v_lines_rnd; - v_sync = v_sync_from_aspect_ratio(h_pixel, v_lines); + v_sync = rb_v2 ? 8 : v_sync_from_aspect_ratio(h_pixel, v_lines); if (!reduced_blanking) { int tmp1, tmp2; @@ -235,6 +247,8 @@ bool calc_cvt_modeline(int image_width, int image_height, int vbi_lines; int tmp1, tmp2; + int min_vbi_lines; + int h_blank; /* estimate horizontal period. */ tmp1 = HV_FACTOR * 1000000 - @@ -245,26 +259,36 @@ bool calc_cvt_modeline(int image_width, int image_height, vbi_lines = CVT_RB_MIN_V_BLANK * HV_FACTOR / h_period + 1; - if (vbi_lines < (CVT_RB_V_FPORCH + v_sync + CVT_MIN_V_BPORCH)) - vbi_lines = CVT_RB_V_FPORCH + v_sync + CVT_MIN_V_BPORCH; + if (rb_v2) + min_vbi_lines = CVT_RB_V2_MIN_V_FPORCH + v_sync + CVT_RB_V_BPORCH; + else + min_vbi_lines = CVT_RB_V_FPORCH + v_sync + CVT_MIN_V_BPORCH; - total_h_pixel = active_h_pixel + CVT_RB_H_BLANK; + if (vbi_lines < min_vbi_lines) + vbi_lines = min_vbi_lines; - h_blank = CVT_RB_H_BLANK; + h_blank = rb_v2 ? CVT_RB_V2_H_BLANK : CVT_RB_H_BLANK; v_blank = vbi_lines; + total_h_pixel = active_h_pixel + h_blank; + h_sync = CVT_RB_H_SYNC; h_bp = h_blank / 2; h_fp = h_blank - h_bp - h_sync; - v_fp = CVT_RB_V_FPORCH; - v_bp = v_blank - v_fp - v_sync; + if (rb_v2) { + v_bp = CVT_RB_V_BPORCH; + v_fp = v_blank - v_bp - v_sync; + } else { + v_fp = CVT_RB_V_FPORCH; + v_bp = v_blank - v_fp - v_sync; + } } pixel_clock = ((long long)total_h_pixel * HV_FACTOR * 1000000) / h_period; - pixel_clock -= pixel_clock % CVT_PXL_CLK_GRAN; + pixel_clock -= pixel_clock % clk_gran; cvt->standards = V4L2_DV_BT_STD_CVT;