From patchwork Mon Dec 10 16:17:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 84 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wm1-f70.google.com (cartago.priv [10.11.12.1]) by cassiopea (Postfix) with ESMTPS id 617852E54A3 for ; Mon, 10 Dec 2018 17:18:06 +0100 (CET) Received: by mail-wm1-f70.google.com with SMTP id y74sf3762605wmc.0 for ; Mon, 10 Dec 2018 08:18:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1544458686; cv=pass; d=google.com; s=arc-20160816; b=TGcwZ5BGirkIYKPNxk2rrlHSS2KnWLmKah5etKbx42PRlmCD6WlPdYK0TypMGkylKS JStwvZpmnt+HUNFMfswt+SyhHD07zeLfesjrS45emTT1kTCJW03vbnUVzsKZcmXJysun rfPIisUGoe9GMKldV40fNWQS386q+lrRkzK/Sc+dNVW6ptOTjU/7tYiV8iwiLEWNpkT0 M17nf+qG5OadQqLSmf0PKiX72u3Iu1vDGGNPu7dmkwH3eWJdFaFmEZGIK1RVkr0b2Dfz SbtOAEKxLEpZw6n0UkPlt1TGIapd6vFilAUJnCTEPscyDackiR8d8CJ7jFw74dqRbbmE ZTRw== 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=DaE2bcL6r+p/M15eQzTefkij1Q0qgITroLCaQhT54ts=; b=sFqZRdpDH//kzBkZtKGCOfbf//qiVEFjR8Oe6Dd/MOYSK12cOYS2EYKUgceF0cIVJz wMDe1ebTZTlgx+3uDd/KKj+VYzVXW11723ZnTxeG0mwLim89w80yLdWOfFYUeAjtuog1 ZvfVkkS90ihVadrfIwe52sltR6OyPegkgJN9Z9rDknxebhaDF1B9p7C5M1LaZKNRrpRY +fYulkTd2lSDn91nfyOnVJ6EMzcxNAHtN28NAIs8aBlvS8OM/JRLf64ce1HWHoaYZF2R iuYZn356DZvyw1AOY1Zn5xUoZA9cCSPKwpB2AF2sjZehu4NcTtvTvbYwc0ToIIXStxnd ygAg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=S6PS8uPD; 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=DaE2bcL6r+p/M15eQzTefkij1Q0qgITroLCaQhT54ts=; b=gPKTFP86uPbzIWEYoLRD1RASZBvTHZhFzqymnv2RqMhnfHgd2wKy5TYLobODh/guOI H0l0J+qjRooFGP4gh6GvHC3h6ayd/mzo8Tc/LJsc10B4a3NCjsJjTAGTDvGW+UHnN+FB dUslgly8/+QRfeYZKGQko+Up6lXGzeQdjPBuA= 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=DaE2bcL6r+p/M15eQzTefkij1Q0qgITroLCaQhT54ts=; b=nNAiLcXkjmJsQzmlvM8r/Y8wakLxCHU8EscBP5/WZLSVWgcxcpdj/YZROsmKB098cW Eh5S167fjRAGHeez5hyS7M545TAhVyVPrtdpV2Ows+0W83nL0qrQ3fCzBgwXeRwRdjD5 F/htQMDuDLAFATAFUT9hqYFNtelFVRVOrk59XX9mh96H0YBmvRXqZ333zmypk45AdkbJ RhupiXpWqj3HpmY4M0fn7UW6j8q/cYrBlNtKlZsyTEwy2H90EI0rKIvfjSKNDPi7SbUR 4CFOUNxcblcJauYkAyuAa9rSTYWq0u6DXG/Xt3B3XFralvGnsgi65gZt3QqAldMs87C0 C5Ww== X-Gm-Message-State: AA+aEWZ6lzQQAKn6TvJ/bHOh1z7WMLXwHeQ6lImGILvZXNjXBBrdL/go UqGLDOXTkDZtcpikyqnDbBsahKyZ X-Google-Smtp-Source: AFSGD/XzN4uM2yujHRmQVLZtFVfghvI9hc4zXgIKBG3esbDEveqlqsiLxF0GNWmTZIkvPVbHF8aRJQ== X-Received: by 2002:a1c:8850:: with SMTP id k77mr1309242wmd.15.1544458686084; Mon, 10 Dec 2018 08:18:06 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a1c:788:: with SMTP id 130ls1886228wmh.6.canary-gmail; Mon, 10 Dec 2018 08:18:05 -0800 (PST) X-Received: by 2002:a1c:bbd6:: with SMTP id l205mr10498940wmf.97.1544458685262; Mon, 10 Dec 2018 08:18:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544458685; cv=none; d=google.com; s=arc-20160816; b=AB+rty/1pTkEOEueTX5YeMiQ5bD0yfCDuVzm2Dc+kfuo5jgCGWCAfEjZkLXA9QOjL9 uLfO9Cp+CXTGujRJfgmYmRfNZVJu/k9GSTrz5wqq6CdSDtGLZP//i7/42U6WgQK0mQI4 dv80thCG0NH7bNgnGz1Hr03Z3onE7tEIDLVkm/IqfJznSMi8h3OEM7OMzm1ty/UZto74 n1J5CVhyj/7FbB8xciYpRP0PuSpTidJRF0UFstaUNL5BuBr/9JRK7YI18c9QdoZ3uNC7 83gNGfkulPLxRco0Y5IxL2atnzZB9GazKwJwz6msJcQAC+cFivb2M8c1KVu7m+zhsHDF MMLw== 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=DaE2bcL6r+p/M15eQzTefkij1Q0qgITroLCaQhT54ts=; b=T3N4PG7vUuhJ4HgQucDoZciO66uXRIv1kNQtHkyuTZdmDQcxXfe7k8EJFlN0cFt7yh NSzA84DVAde4zaBdQD1Cs+7cP8cGh7lyQpvZVhUYh4NYOHoxpeL3HoeLSPQLdHWeZ4N9 nStOZ64OEWvdOqr4A3HFUMQmpAYARB+NVVE6Z5inefIQgEiCI9trNGnsM+oci+FJJyVi zeSdN00yLCbgzvQqrQD4fXoQxf+qKDwen99ZU769vb7XpInuKtWhStCFCv4jBmhrrcFw HMNJjFlKdng+EH7mr+/2acjpL6u8YScrLAoa6plGryOjepEmLMbeJoJdUapb1DUytsCA Pbow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=S6PS8uPD; 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 b5sor4558834wmc.5.2018.12.10.08.18.05 for (Google Transport Security); Mon, 10 Dec 2018 08:18:05 -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:a1c:9dcc:: with SMTP id g195mr10789931wme.153.1544458684950; Mon, 10 Dec 2018 08:18:04 -0800 (PST) Received: from localhost.localdomain (ip-162-59.sn-213-198.clouditalia.com. [213.198.162.59]) by smtp.gmail.com with ESMTPSA id b13sm8397503wrn.28.2018.12.10.08.18.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Dec 2018 08:18:04 -0800 (PST) From: Jagan Teki To: Maxime Ripard , Chen-Yu Tsai , Michael Turquette , Stephen Boyd Cc: linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Michael Trimarchi , linux-sunxi , linux-amarula@amarulasolutions.com, Jagan Teki Subject: [PATCH v5 12/17] drm/sun4i: sun6i_mipi_dsi: Set proper vblk timing calculation Date: Mon, 10 Dec 2018 21:47:24 +0530 Message-Id: <20181210161729.29720-13-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.18.0.321.gffc6fa0e3 In-Reply-To: <20181210161729.29720-1-jagan@amarulasolutions.com> References: <20181210161729.29720-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=S6PS8uPD; 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 | 29 +++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c index d8947be92f9d..cbcef7bf7681 100644 --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c @@ -355,6 +355,27 @@ 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; + unsigned int Bpp = mipi_dsi_pixel_format_to_bpp(device->format) / 8; + int tmp; + + if (device->lanes != 4) + return 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 + tmp = (mode->htotal * Bpp) * mode->vtotal - + (hblk + VBLK_PACKET_OVERHEAD); + + return (device->lanes - tmp % device->lanes); +} + static u16 sun6i_dsi_get_video_start_delay(struct sun6i_dsi *dsi, struct drm_display_mode *mode) { @@ -503,13 +524,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);