From patchwork Sun Mar 3 17:35:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 10837179 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 3A03A1575 for ; Sun, 3 Mar 2019 17:36:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 21C0E29B73 for ; Sun, 3 Mar 2019 17:36:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 155EE29CBF; Sun, 3 Mar 2019 17:36:47 +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,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham 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 ABBA529B73 for ; Sun, 3 Mar 2019 17:36:46 +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=VCC9wAABvVYNa/X1GJA1UxqrGSOKVPqnASjhemsbMAM=; b=Dh1/jC5ZCj7oxD 8B+OETSuXJk8VF0DAYNQv+Q6lbkmj+fDFhSYYAdxFwyatvi7e0+R0ePylCw1wCS/RsI2qG4lJfUYq TGGhD09Kv2cPVrWeKn2TMEebqrF2pSam7PY6Fj/ErL/D9jZWt664Jomql10yYqE3ekpSy4C0ZSKOE vnZYrAEEF7/t+m+rH6t5QiSBwXOsFIiP39jNFsghQz2UnPEem/9blEFbmDBhNscOqgtW1B1qExr3r es/Bybv3sLyvOUBy+pB2JwlvMz9tYKhcXtfQig7vggSu++gg/KhsxJI8ddZU/zyT6/90uMi22tvuu tUOeahm0uyxZNRpoK8zg==; 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 1h0V2a-0002Ob-L0; Sun, 03 Mar 2019 17:36:44 +0000 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h0V2H-0001ur-4t for linux-arm-kernel@lists.infradead.org; Sun, 03 Mar 2019 17:36:29 +0000 Received: by mail-pf1-x442.google.com with SMTP id i20so1296740pfo.6 for ; Sun, 03 Mar 2019 09:36:24 -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=SeROb0sI2fop2jpbyKF+OkejpdGcXO+z0TOiWQ+8P+Y=; b=azB7/TKSI1sGpYuQu5cYJgGyV1BbHN2qWtz/jzBQNGABtiKATw+o4e8327tYUG+def 0/CYRxPtK/mNCC4Y3vmoousXQ81+e2hr1WXOJCzBZjcPpwY7YBwuGo84AlhQThEotbVK Ge1jSGgvaB99KQhqtEhUh0JBFIu9lnvGB1WHg= 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=SeROb0sI2fop2jpbyKF+OkejpdGcXO+z0TOiWQ+8P+Y=; b=m8GYhw15xrWVGbWNEkKtUWFhm1aBrvP//5mlCW+V3WM17THGLaNfdZ8wyIN6oJ2czZ 2AnPXw1u1mx3KEUh0sDTJya6MYa5C4IpAOOFhWVqI3Wmftmj9UkYAKydkmalfQNw3ty/ PZYxAheVdnh+e2Z0t2054g9hB/xpXwCanxK0ieXfg46BjyV2kNOi8neLOkVRkdIHJEVn rErBg5SLLmd4M1O2zlN+8+f/auhjNDb+bOIlCoCxpLgHbbEV/IYRXgn2PqdTQxNg02lL XjiNW9FK/wW1+QR33fPV6FToBZgeZEqcOsPtaghidAzZe0DnBa5gXlp5Qn2cC97kkJz9 eNZA== X-Gm-Message-State: AHQUAuajbm/9cCcCRrOGFSla0NCAhy/x8bsCVaUrEL/J53T+QjUh6OpF tBpvBHNOlMasTyFLE/eNq6u26g== X-Google-Smtp-Source: AHgI3IaHgCR/5gcoWfZyzZcvwfxV9xnkUCOWuDAbEsxR5J/AtP0GFGZ49JcE+EKJuorIFBEXwivTPw== X-Received: by 2002:a62:4188:: with SMTP id g8mr16390415pfd.205.1551634584392; Sun, 03 Mar 2019 09:36:24 -0800 (PST) Received: from localhost.localdomain ([115.97.184.151]) by smtp.gmail.com with ESMTPSA id d129sm5614737pgc.59.2019.03.03.09.36.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 Mar 2019 09:36:23 -0800 (PST) From: Jagan Teki To: Maxime Ripard , David Airlie , Daniel Vetter , Chen-Yu Tsai Subject: [PATCH v9 3/5] drm/sun4i: sun6i_mipi_dsi: Support vblk timing for 4-lane devices Date: Sun, 3 Mar 2019 23:05:25 +0530 Message-Id: <20190303173527.31055-4-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.18.0.321.gffc6fa0e3 In-Reply-To: <20190303173527.31055-1-jagan@amarulasolutions.com> References: <20190303173527.31055-1-jagan@amarulasolutions.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190303_093625_453067_EBA7249C X-CRM114-Status: GOOD ( 14.95 ) 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: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-sunxi@googlegroups.com, Jagan Teki , Michael Trimarchi , linux-amarula@amarulasolutions.com, linux-arm-kernel@lists.infradead.org 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 Like other dsi setup timings, or hblk for that matter vblk would also require compute the timings based payload equation along with packet overhead. But, on the other hand vblk computation is also depends on device lane number. - for 4 lane devices, it is computed based on vtotal, packet overhead along with hblk value. - for others devices, it is simply 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 to support all type of devices. Tested on 2-lane, 4-lane MIPI-DSI LCD panels. Signed-off-by: Jagan Teki Tested-by: Merlijn Wajer --- drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 27 +++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c index 140e55f5ed2e..b38358465d87 100644 --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c @@ -527,6 +527,24 @@ static void sun6i_dsi_setup_format(struct sun6i_dsi *dsi, SUN6I_DSI_PIXEL_CTL0_FORMAT(fmt)); } +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; + unsigned int Bpp = mipi_dsi_pixel_format_to_bpp(device->format) / 8; + int tmp; + + /* + * 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 + tmp = (mode->htotal * Bpp) * mode->vtotal - + (hblk + VBLK_PACKET_OVERHEAD); + + return (device->lanes - tmp % device->lanes); +} + static void sun6i_dsi_setup_timings(struct sun6i_dsi *dsi, struct drm_display_mode *mode) { @@ -586,13 +604,8 @@ 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; + if (device->lanes == 4) + vblk = sun6i_dsi_get_timings_vblk(dsi, mode, hblk); } /* How many bytes do we need to send all payloads? */