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: 23 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pl1-f200.google.com (cartago.priv [10.11.12.1]) by cassiopea (Postfix) with ESMTPS id 875C92E5422 for ; Tue, 13 Nov 2018 12:18:26 +0100 (CET) Received: by mail-pl1-f200.google.com with SMTP id v11sf4423104ply.4 for ; Tue, 13 Nov 2018 03:18:26 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1542107905; cv=pass; d=google.com; s=arc-20160816; b=kgJ5ma0x/nkB287YbohCnAY6JM5Xja3vbr0bjHc616mlhDxTWZetDVdh7o6AHc1sX/ crsLBn/8HE2ZN0hmYodj/p0e6N+KRTWrJb5tIdzkFsneY7ns8Kzvz81PU7jJIiz95J/m 76Ci+tv7wRO/l8xjNi6Uo3FCS2kd1cKQPSyHOMwVEeO1iKdiguBBqT2Kj3ICcrZntbD6 0iX6c7yD8g3BfkiYxw5YZ1Pagh/CzbkNe7cfMJgacigUC8Q9MHOTkGNmg4/X+e+lx+He dQYi/IoOR8iRPR/FDGg+db9571TjOybnBeV6XRBEasPLEtE8ctcaebTivuKYd4gJoNZb yx0A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=KiNNAL5FNd2IGkoW7kve11vnz/CEWnCQcGVfDy5CmDU=; b=ziGYjvZ7hrzHil3Jz64kMD1BxSqAKQM1mFhwy4e7PHpmZu627hkfOlkqvWws01YE0t CqSRBR1iO8kiwgqqJfVKT2GwLXVLYr+ehyBxaxkb9QKi2+mld5a/O4L4m7EeQ1a5pxSN P4cEIlKTlOhtsRF4kH98k9CnR+UrjMQGjGhoJc2zPsxEwe8ynCSOI1a0C+gR0QKPn1d1 27f40RSfQvDjqBVI87gJx9Oft1iklH6pN1R/fPiDxYv45QnYF/lX0KL7irBqKW5Q+DJb JkDiBuvGUDmkgBKIMTwff9AyXNhANiusZAtwBcHJ6i7fV0qEs7d4jrkmj22Vv+cDx6SG cMJg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="oqoD/W7v"; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com 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:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=KiNNAL5FNd2IGkoW7kve11vnz/CEWnCQcGVfDy5CmDU=; b=n7pMKxDEO0hYTeHlkNJnkzupUkSrSGCglVQspmrBAfwel61LOy3ylyrnkkiI9Bqd2n ucB4kjt0z7Ur9JJST5rGngiOWc9tuPRSoBlIESm3czDaHOUTo56o9Asl7c0CuaQ9734w Tk0iQyJIwfSWI/eLyZo27yuwIsINdeNGqBKhw= 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:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=KiNNAL5FNd2IGkoW7kve11vnz/CEWnCQcGVfDy5CmDU=; b=CGJ4+IA5TuIpP2q/EQ0y2tUIucvbiVZ03rYIZRFoTZZgyaokby7aYDYmsPcotEGhyH rWdGfp3lfBCf12vVsdZG+acHfH37SiwNP6dcwSPQQnPJvA04zrVvNrh6ZhRNjH6FXN2e 4NQ4BekbEn9KlucOo2KHrgRjcGGrSu1OX6mgcvhzLYyfNDlG9+pPu5I+eo92/cp+5Tk6 NGGz5Qu1WcLB5AT/Oc+D3lhoDO1LUTO7upmY9oQe1Z6URFewrTo/DzN3HPqPOclqvjE7 y23NU/YMyCk+ltzn0Mmo8piCLshRF/Xyr/8giQvQqQ13P7z3PDVIP0wTItrj2l2xLtLJ KLYA== X-Gm-Message-State: AGRZ1gKilTrlUekB4/chrgVIqyBn/Mu5zfARJYjCngHUOjsz3d1T6wNc 1+3RK+z/qvyUf9lNxxQzuERGVRmk X-Google-Smtp-Source: AJdET5eAhBLPlsbpAZuLHIpwtNlM8kmLRazk+tIjqoBzz8uFepYsKCWPYEW69cSRSR+/3ScpNjDDpg== X-Received: by 2002:a17:902:9b85:: with SMTP id y5-v6mr1147201plp.110.1542107905250; Tue, 13 Nov 2018 03:18:25 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a62:cd1:: with SMTP id 78ls126468pfm.14.gmail; Tue, 13 Nov 2018 03:18:25 -0800 (PST) X-Received: by 2002:a63:1848:: with SMTP id 8mr4330110pgy.81.1542107904958; Tue, 13 Nov 2018 03:18:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542107904; cv=none; d=google.com; s=arc-20160816; b=UZxzdDjlWV3zbmmfIhuJaReHsbYxztecN1gSc9FUfRhctQEpi08bMIRbvzVg2TFtSu XJ2wSX369dwmLA8GWB3o2NTaduzJ6SXNBaulydrWdbRQiCinSNeDpQwXq+v1RggCd2YR m4DIuzu6Zr+3SqWJcWq4wsFdQKSUfJG8vOM/+U+9raaMH9wWeYzbcBo1VyTQA620Hvzb pMQtfByzRrg4ZcYHh3NfOiXOsPg17hbhc4hx20o9w9dHh8HO82fpL08h2DM0qsogwgdv DVmyzg35hyGCs8MhMoTgtWjeAOjQCLcucf9J8kSQdg8hfOUYNVuYOf9KGOTBkd7dbhpM KBtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=KiNNAL5FNd2IGkoW7kve11vnz/CEWnCQcGVfDy5CmDU=; b=NT+PcE52r/uAF4Yvc8++2/BWoPFqf4TgF74bJ771WksBhlsmRCgof/cj8ECqnmOTGQ /fYxsO44pFo67e13WJArk5pb5oaUDMKKR/c4cO5m0LC+RR7mbytAu/Pj/G4KisOz69ss GSiQ/NpNatfKk7k37fBWEtYNwC4atRitEHhZAe67SNrevG0xFav3mFRUoIwvwZs/6qqX CGBaWLYqdKAkAkyYqAAAo2fTRt6El23VzIck6sLEGstv9okGO4xvpHUcekzBFYaQpNcF Ufzh51z8zJxKiP2DFfBgLoO2NP+Wx60v7EJbETFoFCN2gRSiqvUgk/zx4fUsM0yuS+Jg YgHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="oqoD/W7v"; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id q79-v6sor14815838pfa.57.2018.11.13.03.18.24 for (Google Transport Security); Tue, 13 Nov 2018 03:18:24 -0800 (PST) Received-SPF: pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; 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 Cc: Jagan Teki 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-Original-Sender: jagan@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="oqoD/W7v"; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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);