From patchwork Fri Oct 26 14:43:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 10659119 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BCA4C14DE for ; Mon, 29 Oct 2018 11:12:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC23329732 for ; Mon, 29 Oct 2018 11:12:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9CA5229868; Mon, 29 Oct 2018 11:12:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3493F29732 for ; Mon, 29 Oct 2018 11:12:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7C5D689DBA; Mon, 29 Oct 2018 11:11:15 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by gabe.freedesktop.org (Postfix) with ESMTPS id CF8FF6E4A7 for ; Fri, 26 Oct 2018 14:45:31 +0000 (UTC) Received: by mail-pl1-x643.google.com with SMTP id d23-v6so609144pls.11 for ; Fri, 26 Oct 2018 07:45:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=efp6sFiQWGhKGiEpT9DPizID7xKe3bNjf2I9V30y+Ys=; b=cqOqgbex63NUAPrM2Kw3qfA1+puxanDdhJSgDAKA2UsHp9/+I1T0cZ4UKmQBpe5xPU t8ZnZTV1T2Hu6+Fgo+tGEAAcYr3302ojFQS1kB+6om6CsXCLm2H5K8y91+/yHehmESHD rmCqLQXYOtRLKUteioYPNGZqpASmp41bwiojHbrYBzV1F9g7oWDTp/8+4Z04zMqaiLwj ceU+ngkGh7FaWo1cDOJhuATuwUSRvjQVFRpeVTO/Bxs9svu1PXtaSAPGHcw9ox00+w2t nRDtIidfvBUR7L+cdDmtENomQeQOKS8+VXGNtIYCcmv5cV0HPN+wY9Mhq30csqTAkNCs qHVw== X-Gm-Message-State: AGRZ1gI9Uga/orMJzEYeTsByDwiub5QD6y67hio5sy1BcCoKbr60hJme GQrcMPPFRbPRaRog0zgw0KQF/Q== X-Google-Smtp-Source: AJdET5fucCB5re78rfZVblg7SE55jUyPO8u1lB6Zs29yTuXi0Svqs/9BYlVGAZ5aL7lBnP6KYNcuFg== X-Received: by 2002:a17:902:b106:: with SMTP id q6-v6mr3811436plr.238.1540565131346; Fri, 26 Oct 2018 07:45:31 -0700 (PDT) Received: from localhost.localdomain ([27.7.51.1]) by smtp.gmail.com with ESMTPSA id z22-v6sm12044467pgv.24.2018.10.26.07.45.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Oct 2018 07:45:30 -0700 (PDT) From: Jagan Teki To: Maxime Ripard , Chen-Yu Tsai , Icenowy Zheng , Jernej Skrabec , Vasily Khoruzhick , Rob Herring , Mark Rutland , Catalin Marinas , Will Deacon , David Airlie , dri-devel@lists.freedesktop.org, Michael Turquette , Stephen Boyd , linux-clk@vger.kernel.org, Michael Trimarchi , linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com Subject: [PATCH v3 14/25] drm/sun4i: sun6i_mipi_dsi: Increase hfp packet overhead Date: Fri, 26 Oct 2018 20:13:33 +0530 Message-Id: <20181026144344.27778-15-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.18.0.321.gffc6fa0e3 In-Reply-To: <20181026144344.27778-1-jagan@amarulasolutions.com> References: <20181026144344.27778-1-jagan@amarulasolutions.com> MIME-Version: 1.0 X-Mailman-Approved-At: Mon, 29 Oct 2018 11:10:30 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jagan Teki Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Increase the hfp packet overhead with another 10 bytes, the extra 10 bytes(which is hblk packet overhead) is adding for hfp packet overhead since hfp depends on hblk. This is truely as per BSP code from BPI-M64-bsp. The real computation from BSP is (in drivers/video/sunxi/disp2/disp/de/lowlevel_sun50iw1/de_dsi.c) dsi_hbp = (hbp-hspw)*dsi_pixel_bits[format]/8 - (4+2); dsi_hact = x * dsi_pixel_bits[format]/8; dsi_hblk = (ht-hspw)*dsi_pixel_bits[format]/8-(4+4+2); dsi_hfp = dsi_hblk - (4+dsi_hact+2) - (4+dsi_hbp+2); Example, u32 fmt = dsi_pixel_bits[format]/8; => ((ht-hspw)*fmt - 10) - (6 + x * fmt) - (6 + (hbp-hspw)*fmt - 6) => (ht - hspw - x - (hbp - hspw)) * fmt - 16 => (ht - x - hbp) * fmt - 16 => (ht - x - (timmings->hor_total_time - timmings->hor_front_porch - x) * fmt - 16 => (timmings->hor_total_time - x - timmings->hor_total_time + timmings->hor_front_porch + x) * fmt - 16 => timmings->hor_front_porch * fmt - 16 So, increase the DSI hfp packet overhead by hblk packet overhead. Tested on 2-lane, 4-lane MIPI-DSI LCD panels. Signed-off-by: Jagan Teki Tested-by: Jagan Teki --- Changes for v3: - new patch Changes for v2: - none drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c index 6584b51736a9..20e330186b7f 100644 --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c @@ -461,7 +461,7 @@ static void sun6i_dsi_setup_timings(struct sun6i_dsi *dsi, { struct mipi_dsi_device *device = dsi->device; unsigned int Bpp = mipi_dsi_pixel_format_to_bpp(device->format) / 8; - u16 hbp, hfp, hsa, hblk_max, hblk, vblk; + u16 hbp, hfp_pkt_overhead, hfp, hsa, hblk_max, hblk, vblk; size_t bytes; u8 *buffer; @@ -484,14 +484,6 @@ static void sun6i_dsi_setup_timings(struct sun6i_dsi *dsi, hbp = max((unsigned int)HBP_PACKET_OVERHEAD, (mode->htotal - mode->hsync_end) * Bpp - HBP_PACKET_OVERHEAD); - /* - * The frontporch is set using a blanking packet (4 bytes + - * payload + 2 bytes). Its minimal size is therefore 6 bytes - */ -#define HFP_PACKET_OVERHEAD 6 - hfp = max((unsigned int)HFP_PACKET_OVERHEAD, - (mode->hsync_start - mode->hdisplay) * Bpp - HFP_PACKET_OVERHEAD); - /* * hblk seems to be the line + porches length. * The blank is set using a blanking packet (4 bytes + 4 bytes + @@ -502,6 +494,18 @@ static void sun6i_dsi_setup_timings(struct sun6i_dsi *dsi, hblk_max -= HBLK_PACKET_OVERHEAD; hblk = max((unsigned int)HBLK_PACKET_OVERHEAD, hblk_max); + /* + * The frontporch is set using a blanking packet (4 bytes + + * payload + 2 bytes). Its minimal size is therefore 6 bytes + * + * According to BSP code, extra 10 bytes(which is hblk packet overhead) + * is adding for hfp packet overhead since hfp depends on hblk. + */ +#define HFP_PACKET_OVERHEAD 6 + hfp_pkt_overhead = (HFP_PACKET_OVERHEAD + HBLK_PACKET_OVERHEAD); + hfp = max((unsigned int)hfp_pkt_overhead, + (mode->hsync_start - mode->hdisplay) * Bpp - hfp_pkt_overhead); + /* * And I'm not entirely sure what vblk is about. The driver in * Allwinner BSP is using a rather convoluted calculation