From patchwork Tue Nov 13 11:16:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 10680323 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 2424B13BF for ; Tue, 13 Nov 2018 11:21:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 13B1929A6E for ; Tue, 13 Nov 2018 11:21:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0705E2A3BA; Tue, 13 Nov 2018 11:21:13 +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=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A886F29A6E for ; Tue, 13 Nov 2018 11:21:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=A8nLk7p4c0Fg2oOHGhzY7azrWwVgjOVh1RHZuzeTb58=; b=RBZPKCgfMtEnkT Ud7ikx7TVLb15xL2X2bnGnozp1F+UmK2EvMEdrURvuVPEtfIBuzPOmUuChqM1L4B/1bKBhDWWV/Cq qw8C5EZRYJla6QwKP8rd0sZDhusa/j9lC9Mf8V8sg2WjFPdHR9vu+1KOO8zbueTZg27U5jMQGyCmt KVFycBwxTWxMA4O6+Ot3ZIrteGefKlQtqjvCBX5AcXXDOtYZErHD3XVFsTWnIejuxxZRPLJnxYQoi IlUVQ02hDOcw1wd7hS7+dbtdDvqlHR6Xw7OvFri9z+2U+1H5FYuGlb34bDfAXrWg0wiZ6fK58c1W+ NYDUHP7TD+QKhfqz8Yxw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gMWkj-0003dP-3p; Tue, 13 Nov 2018 11:21:05 +0000 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gMWiJ-0000AF-AY for linux-arm-kernel@lists.infradead.org; Tue, 13 Nov 2018 11:18:45 +0000 Received: by mail-pf1-x443.google.com with SMTP id b81-v6so5383643pfe.11 for ; Tue, 13 Nov 2018 03:18:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KiNNAL5FNd2IGkoW7kve11vnz/CEWnCQcGVfDy5CmDU=; b=oqoD/W7vMonGUOH7jryCGWFxxLuL2hJXGRp68F8je6O2iyl8WOX187F0TSWv86bOvy HMvMWNDDjMuEgEEQS1iI5wIuQjlITCzQH1SMVGHzL3IHM+3ABfjqh5P4/6bxOx3H+eRu nZJn+pyvQSLQntbqnY51w32jkD9zGvo06EVIc= 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=KiNNAL5FNd2IGkoW7kve11vnz/CEWnCQcGVfDy5CmDU=; b=eYy4F4z6jPh/oeBiHmD7i7fiy1g3G0yrh4tDBf9g9qbL0BWv9ZtJLkRoe5l2h7ztWU lDOGBRGM88ljMfyZuyWKK/ZkVdFTaO3KWuzk2zFyZTM6luiLzNOonjeqBJJgcQP7kwd5 61ECCtzCxCTA3ih+/Ad72ViVHg45gIlnM6/iUKigBj9B1PvgJVWFkVg/fTI/XH88YBQE Av0SJAm5/Y8+ZvOPmePsyhNWlhxG+yJyT9rFmg/uGxdpoD8SSGvU9W7zM1BHM6IVVwow Njm2DRND4Nd2GDmV3M3cEmSHWAl7es0r9tZvdl3HH3KrWz+O2GuKHKdPblHGCOvqMb/J t8Tg== X-Gm-Message-State: AGRZ1gImIdG4tOmd293ap9MeCXD+hr2NvJAbTmoUM5yGKCuUB1XdamDP Mm98IeZtfvnKcjuj021+qwcKaQ== X-Google-Smtp-Source: AJdET5fxwmbnpRiHRLvlzdbDPt8wJDBKu18uNDB5dVMb8m8vNdS/K2Bz+hxnyOIAB/e0lbZCxnAjaQ== X-Received: by 2002:a62:8647:: with SMTP id x68-v6mr4951565pfd.252.1542107904617; Tue, 13 Nov 2018 03:18:24 -0800 (PST) Received: from localhost.localdomain ([2401:4900:3670:3f11:bc71:2ef7:4a39:e260]) by smtp.gmail.com with ESMTPSA id 27-v6sm28531377pfm.36.2018.11.13.03.18.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Nov 2018 03:18:24 -0800 (PST) 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, linux-amarula@amarulasolutions.com Subject: [PATCH v4 15/26] drm/sun4i: sun6i_mipi_dsi: Set proper vblk timing calculation Date: Tue, 13 Nov 2018 16:46:22 +0530 Message-Id: <20181113111633.20189-16-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.18.0.321.gffc6fa0e3 In-Reply-To: <20181113111633.20189-1-jagan@amarulasolutions.com> References: <20181113111633.20189-1-jagan@amarulasolutions.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181113_031835_379529_951D7931 X-CRM114-Status: GOOD ( 17.70 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jagan Teki Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Unlike hblk, the vblk timings should follow an equation to compute the desired value for lane 4 devices and rest of devices it would be 0. BSP code from BPI-M64-bsp is computing vblk as for 4-lane devices (from linux-sunxi drivers/video/sunxi/disp2/disp/de/lowlevel_sun50iw1/de_dsi.c) tmp = (ht*dsi_pixel_bits[format]/8)*vt-(4+dsi_hblk+2); dsi_vblk = (lane-tmp%lane); So, update the vblk timing calculation accordingly. Tested on 2-lane, 4-lane MIPI-DSI LCD panels. Signed-off-by: Jagan Teki --- drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 32 ++++++++++++++++++++------ 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c index 63b924b89bd7..703722f7c81b 100644 --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c @@ -355,6 +355,30 @@ static void sun6i_dsi_inst_init(struct sun6i_dsi *dsi, SUN6I_DSI_INST_JUMP_CFG_NUM(1)); }; +static u16 sun6i_dsi_get_timings_vblk(struct sun6i_dsi *dsi, + struct drm_display_mode *mode, u16 hblk) +{ + struct mipi_dsi_device *device = dsi->device; + u16 vblk = 0; + + /* + * The vertical blank is set using a blanking packet (4 bytes + + * payload + 2 bytes). Its minimal size is therefore 6 bytes + */ +#define VBLK_PACKET_OVERHEAD 6 + if (device->lanes == 4) { + unsigned int Bpp; + int tmp; + + Bpp = mipi_dsi_pixel_format_to_bpp(device->format) / 8; + tmp = (mode->htotal * Bpp) * mode->vtotal - + (hblk + VBLK_PACKET_OVERHEAD); + vblk = (device->lanes - tmp % device->lanes); + } + + return vblk; +} + static u16 sun6i_dsi_get_video_start_delay(struct sun6i_dsi *dsi, struct drm_display_mode *mode) { @@ -503,13 +527,7 @@ static void sun6i_dsi_setup_timings(struct sun6i_dsi *dsi, (mode->htotal - (mode->hsync_end - mode->hsync_start)) * Bpp - HBLK_PACKET_OVERHEAD); - /* - * And I'm not entirely sure what vblk is about. The driver in - * Allwinner BSP is using a rather convoluted calculation - * there only for 4 lanes. However, using 0 (the !4 lanes - * case) even with a 4 lanes screen seems to work... - */ - vblk = 0; + vblk = sun6i_dsi_get_timings_vblk(dsi, mode, hblk); /* How many bytes do we need to send all payloads? */ bytes = max_t(size_t, max(max(hfp, hblk), max(hsa, hbp)), vblk);