From patchwork Sat Nov 3 10:08:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 10666605 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 E376F109C for ; Sat, 3 Nov 2018 10:13:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CDC1028DF1 for ; Sat, 3 Nov 2018 10:13:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C16F72931E; Sat, 3 Nov 2018 10:13:34 +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=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 4F79628DF1 for ; Sat, 3 Nov 2018 10:13:34 +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=Q7yCAhLTUlz/lMtoU/itFe14WElHkDoUVjMILlUlGNk=; b=NAu5fCiPvN8ETX vwUiXO8fkGe+iVeUxmTK+SWTU5c/ZEQWAVTjbvpgMFrAEfosxSmkFrEq4TO9LzqYZq/TcXWsipB9Z ZR/DZugDyAV9hQs33NZtfietePDO3CTUCxhz4GCNJvGc9M549L6cfwXyaf9pp0jvdUiB6ZuF4laJg efY7zCJdgqpGlLhzq3I24R954QOL83klZyf55XlZxAJlm1Q2cOZ+JxZQ1qX1ZT1dBL3zixxnOCHOL FyFqm1j8iDhfO7y0s2OGbPCOT5prDWdr6ps6y4xnRxOrkrpGDXTJrYlwco5z92Y8IBy+laYh5Idy0 LW+slKFwWG7O5As8MJYA==; 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 1gIsvt-0005Nx-8x; Sat, 03 Nov 2018 10:13:33 +0000 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gIssN-0002xr-8w for linux-arm-kernel@lists.infradead.org; Sat, 03 Nov 2018 10:10:00 +0000 Received: by mail-pl1-x641.google.com with SMTP id p6-v6so2130620pll.4 for ; Sat, 03 Nov 2018 03:09:52 -0700 (PDT) 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=RoHXhQs3sGHJc3VqucM8YHfwrLVjYZhUwHaLNgzq7Hk=; b=PDS9oZXI08XHodXR7M+0+fMtcP+VlY9g+hL69LXq+DNFteFFc+lUCpCpwI7wLoHCbG i1r9Nbg5hKlV3gpKaTq29eKsfIcOM2gv2hoYNro/woLd7+XOwl1AuDQrqvfhPQ1oDEHW JAzTxzknORGbhh4L0SgffAHR07HzUdEktD9rQ= 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=RoHXhQs3sGHJc3VqucM8YHfwrLVjYZhUwHaLNgzq7Hk=; b=dzeq/uOFEUJUdoIHv6k59doevUwV0LFBbbDiKQYU2StTXT/Sa4Nk77vMj9CE55fVAV JhgH+OyZOxPgnSn1EWIoWNYjqNu/bRGWf1UK3GAgj5ri69q7jSoi/lLm9cKYld1ecChJ KEycGUpNZLul92tnJUxWOM9mBfNwL2gSDoBp/bhtwNoI0Al7b1ITjIU9KN2enoHX9qmp FuwRd/h40Oj8zIvxAOsE4O14JOjD/NP4W7D29rFm2MCiLt3EU+AqtiEm6ftAoYKijmqo DBArAYa3a8c8HYTj1G0Yb+4lHMAYeg2kM2LAT3NcgbpLx5JixxjdWpZROOqPq2FGK/Ui Q/Bg== X-Gm-Message-State: AGRZ1gI/h7KHDV4gr3qOrY1ZGcA9gfxrGE+WGfkY6X7KCxA6aIkA7II4 fwX+KnUuVxODaRBJVSy8Z2itTA== X-Google-Smtp-Source: AJdET5cZWnpRoke0soGNzGMb4cUkutwXdz4Xu2YGKFvhfMeGnaV3L3bKJ4djXsCJup2lz7coshRSDA== X-Received: by 2002:a17:902:bf0c:: with SMTP id bi12-v6mr15243833plb.330.1541239791555; Sat, 03 Nov 2018 03:09:51 -0700 (PDT) Received: from localhost.localdomain ([2405:204:6094:3f7a:ed0a:fb74:1220:defe]) by smtp.gmail.com with ESMTPSA id z79-v6sm28466823pfl.33.2018.11.03.03.09.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 03 Nov 2018 03:09:50 -0700 (PDT) From: Jagan Teki To: Maarten Lankhorst , Maxime Ripard , Sean Paul , David Airlie , Rob Herring , Chen-Yu Tsai , Icenowy Zheng , Jernej Skrabec , Vasily Khoruzhick , Thierry Reding , Mark Rutland , dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Michael Trimarchi , TL Lim , linux-sunxi@googlegroups.com Subject: [PATCH 04/10] drm/sun4i: sun6i_mipi_dsi: Setup burst mode Date: Sat, 3 Nov 2018 15:38:54 +0530 Message-Id: <20181103100900.30313-5-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.18.0.321.gffc6fa0e3 In-Reply-To: <20181103100900.30313-1-jagan@amarulasolutions.com> References: <20181103100900.30313-1-jagan@amarulasolutions.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181103_030955_564191_2E5781D5 X-CRM114-Status: GOOD ( 17.85 ) 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 Setting up burst mode display would require to compute - Horizontal timing edge values to fill burst drq register - Line, sync values to fill burst line register Since there is no direct documentation for these computations the edge and line formulas are taken from BSP code (in drivers/video/sunxi/disp2/disp/de/lowlevel_sun50iw1/de_dsi.c) line_num = panel->lcd_ht*dsi_pixel_bits[panel->lcd_dsi_format]/ (8*panel->lcd_dsi_lane); edge1 = sync_point+(panel->lcd_x+panel->lcd_hbp+20)* dsi_pixel_bits[panel->lcd_dsi_format] /(8*panel->lcd_dsi_lane); edge1 = (edge1>line_num)?line_num:edge1; edge0 = edge1+(panel->lcd_x+40)*tcon_div/8; edge0 = (edge0>line_num)?(edge0-line_num):1; Signed-off-by: Jagan Teki --- drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 48 +++++++++++++++++++++----- 1 file changed, 40 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c index 4965b2c71e4c..b6c01891df36 100644 --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c @@ -375,20 +375,52 @@ static void sun6i_dsi_setup_burst(struct sun6i_dsi *dsi, struct drm_display_mode *mode) { struct mipi_dsi_device *device = dsi->device; + unsigned int Bpp = mipi_dsi_pixel_format_to_bpp(device->format); + u32 line_num, edge0, edge1, hact_sync_bp; + u32 sync_point, tcon_div; u32 val = 0; - if ((mode->hsync_start - mode->hdisplay) > 20) { - /* Maaaaaagic */ - u16 drq = (mode->hsync_start - mode->hdisplay) - 20; + if (device->mode_flags != MIPI_DSI_MODE_VIDEO_BURST) { + if ((mode->hsync_start - mode->hdisplay) > 20) { + /* Maaaaaagic */ + u16 drq = (mode->hsync_start - mode->hdisplay) - 20; - drq *= mipi_dsi_pixel_format_to_bpp(device->format); - drq /= 32; + drq *= Bpp; + drq /= 32; - val = (SUN6I_DSI_TCON_DRQ_ENABLE_MODE | - SUN6I_DSI_TCON_DRQ_SET(drq)); + val = (SUN6I_DSI_TCON_DRQ_ENABLE_MODE | + SUN6I_DSI_TCON_DRQ_SET(drq)); + } + + regmap_write(dsi->regs, SUN6I_DSI_TCON_DRQ_REG, val); + + return; } - regmap_write(dsi->regs, SUN6I_DSI_TCON_DRQ_REG, val); + sync_point = 40; + tcon_div = 8; /* FIXME need to retrive the divider from TCON */ + + line_num = mode->htotal * Bpp / (8 * device->lanes); + /* Horizental timings duration excluding front porch */ + hact_sync_bp = (mode->hdisplay + mode->htotal - mode->hsync_start); + edge1 = sync_point + ((hact_sync_bp + 20) * Bpp / (8 * device->lanes)); + if (edge1 > line_num) + edge1 = line_num; + + edge0 = edge1 + (mode->hdisplay + 40) * tcon_div / 8; + if (edge0 > line_num) + edge0 -= line_num; + else + edge0 = 1; + + regmap_write(dsi->regs, SUN6I_DSI_BURST_DRQ_REG, + SUN6I_DSI_BURST_DRQ_EDGE1(edge1) | + SUN6I_DSI_BURST_DRQ_EDGE0(edge0)); + regmap_write(dsi->regs, SUN6I_DSI_TCON_DRQ_REG, + SUN6I_DSI_TCON_DRQ_ENABLE_MODE); + regmap_write(dsi->regs, SUN6I_DSI_BURST_LINE_REG, + SUN6I_DSI_BURST_LINE_NUM(line_num) | + SUN6I_DSI_BURST_LINE_SYNC_POINT(sync_point)); } static void sun6i_dsi_setup_inst_loop(struct sun6i_dsi *dsi,