From patchwork Fri Nov 16 16:39:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 50 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-io1-f70.google.com (cartago.priv [10.11.12.1]) by cassiopea (Postfix) with ESMTPS id B27592E5432 for ; Fri, 16 Nov 2018 17:40:32 +0100 (CET) Received: by mail-io1-f70.google.com with SMTP id w22-v6sf23147806ioc.5 for ; Fri, 16 Nov 2018 08:40:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1542386431; cv=pass; d=google.com; s=arc-20160816; b=oZCHdAe9oKQjptvQ7uhvQQ/GtoM1U7OtsDbvgXBsXknGAoqV9LG6CoixYtx+Hb+qHW 25fc9vX3NvT3KrPRTXttXDUk/vcgpA81xrro9pUacfN4gAH9uCKtt4+QRCi02jEppe3w IsrHK98BVtXgp5vYUID5E3pBAhD5yMv00Z6leut7wRrdiWMnpAWcxSIAkJI7fLpMSKFV gEfY8E9trKTnFJ4OfWqRLeP28XzqvtiGcDR5iL8kMG4Bto8duesqhh5eGIdmiRSyfhg+ saI5QAPZdqBMqcAIz12Y8MD68jDrMcXMKmr69T8XcCgUu39PRhZ68vIRCKSOdGeBGC/J u/hg== 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=gDMHNSRr+JX7iJxWUt7jlD3FaFmi6BRpMEbYYc93LBg=; b=VnnbCmf6ApmxNrcQWDhAPi5WulEDViUEaBxPKU5urcrxRG6kGUNvisC3YWgOGKy30L dDBL2UGB1RwmBWxzKzYzmYFucTAkb/pKYwRJ5ATOIgmbXNZ/Trq4nMYTF5DSWhdtV+NU h4Z9yiAcGa5kb7M+sPdK7+zAfwyqENmp++E8n2KwVA/U4MGKXoAMz4tUt6gre2lJjB2r 7iP+SL9mMgTfmn+1b6dwkWnoEDSpBlkIp/8aQXLwc+o/heWNFIavyDdJGMIizyFrUL20 p5MmmH78GVwLchafx5R2KZem3mnjQvNrrFg/d1zz7x6fQ9NC2a9CLhieLuh4hNBGpapO dP6g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=gKNQLXv9; 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=gDMHNSRr+JX7iJxWUt7jlD3FaFmi6BRpMEbYYc93LBg=; b=Wj43FJ/tZCaNAjBFKmEDw0qbApjADqqJJrRCqVNu0NteVaEnl2Nuhw+ELLk5vVWGH0 CLoxq+av3d1jJhvgK+FWhhmafD9PwnBF2yRVwaIgTwytDRGukv8VhoOsg3AAkuzW94D5 0pfNtJf3Albz710r2ZBcS2QHvGd5sBgzqILkI= 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=gDMHNSRr+JX7iJxWUt7jlD3FaFmi6BRpMEbYYc93LBg=; b=qCf1VjJwe+Z+gZCr53EdOKBK9xqpKhKS/zL2Qbv4zdMfRI6/EGdqu1N3CXv8Y22PYQ japB99US98y5r9XmTFzFMulHf3ZtExZzF8g14ARaVJlkGVfc2CYWLcd0mQxE9sO+TTSu EEwt1q7oVNCcTfFxPhwKDyQ02HZaLWd6OoNxMJSRI7v7F3Ymw5Qq8KF7rfATuTOp1NXn tOc/VLtC0KYJW7J5xvwoSQsx1W6UGt0cfE3QBoTK4UHBYe8KQiMKyhrDfztc8N/AJ4QM IC2K4+wK5iAexdfElP3DjHytwg3ioMPPT/yhLnT5qlhPBLq+jOQhh4DY47dbnYvst4Gk Gd0A== X-Gm-Message-State: AGRZ1gKqCWDzQNEtSLAJDUmNeFvaRvtUIaX5GtkWr8czoLlHgmC6muK6 ByUZL1ilk0dh8XNsqhjD/e9jWaZ0 X-Google-Smtp-Source: AJdET5fhJ58eXe87Hhbv0qQS714CrqMjy8D0y7UDFqV+o9J+L51NVUPBiFAavFKtcpE1puGwmDHaDA== X-Received: by 2002:a24:46d5:: with SMTP id j204mr198452itb.38.1542386430890; Fri, 16 Nov 2018 08:40:30 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a24:7648:: with SMTP id z69-v6ls129331itb.4.gmail; Fri, 16 Nov 2018 08:40:30 -0800 (PST) X-Received: by 2002:a05:660c:7c8:: with SMTP id e8mr11396281itl.55.1542386430367; Fri, 16 Nov 2018 08:40:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542386430; cv=none; d=google.com; s=arc-20160816; b=Tued9z4BSK2fessmioLs4l2hUqOJ7EwaMOKdlUZr33onsVx5hgxCcutLUmQjQgbWbH 3po40P8FHga3p5lejZwcX5P0nLFCsPRCBprGtW5i1XQxH/2hhwmK7IiIxKjsNi2AOWqw iasRxUCb9NOIH24iE2wmG6LlN5c+AM0czrinpUpKY0eB2zEefAnaY0D+jAcZsZFlk4Wz o3oUWk29b7pFeKQLFJ9/vCFp2zSOjwyMEL2IZMpZw6Mw4lWwkD6wMp79FsP/etSMRf5a 7tWVEgVGAPhxJxEgF6MCuM8FYaU+E7gylI5jBUFDk4xJuiNWZ9cFL+1xPqP/lj2UJy0+ 572A== 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=gDMHNSRr+JX7iJxWUt7jlD3FaFmi6BRpMEbYYc93LBg=; b=wBb/4SDNCnmYT9X+Mrp+m74VdGkv0ErTr/mQSS38GblZ5FpQlNAsSqr+mY++eM9ixu qYwfPjRAJT9XxHGEAcv2BVlDsVMONdEDex2UkdOxBe0mTf9Aucsq23B1hbqJyfdMB/eW pzAY/t032YYNUSsewCFHhk/yd+dLJB6z34KoS3a9rFp1kMDtkNP5VIAkqiygbkCGzlPP y4UsTlDxyOOW0wrk8lbjPEi3plo4K3QDTY3GSVwyt1mPkAUqs6N58WFiwPD6fKhApV68 CLdNpRxuf84TRxik8RBdqDkPX5t2X+ZXqGcTxUWIKf3IFb/Fp8jolwpoA04BYm8WiCQE ONvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=gKNQLXv9; 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 b202-v6sor2860989itb.0.2018.11.16.08.40.30 for (Google Transport Security); Fri, 16 Nov 2018 08:40:30 -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:a63:a35c:: with SMTP id v28mr10516381pgn.205.1542386429771; Fri, 16 Nov 2018 08:40:29 -0800 (PST) Received: from localhost.localdomain ([115.97.190.86]) by smtp.gmail.com with ESMTPSA id p5-v6sm34622213pfb.109.2018.11.16.08.40.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Nov 2018 08:40:29 -0800 (PST) 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, linux-amarula@amarulasolutions.com Cc: Jagan Teki Subject: [PATCH v2 07/12] drm/sun4i: sun6i_mipi_dsi: Setup burst mode Date: Fri, 16 Nov 2018 22:09:11 +0530 Message-Id: <20181116163916.29621-8-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.18.0.321.gffc6fa0e3 In-Reply-To: <20181116163916.29621-1-jagan@amarulasolutions.com> References: <20181116163916.29621-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=gKNQLXv9; 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: , 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 (from linux-sunxi/ 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 | 72 ++++++++++++++++++++++++-- 1 file changed, 68 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c index 66a01061e51d..0182408f8932 100644 --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c @@ -364,6 +364,41 @@ static void sun6i_dsi_inst_init(struct sun6i_dsi *dsi, SUN6I_DSI_INST_JUMP_CFG_NUM(1)); }; +static u32 sun6i_dsi_get_edge1(struct sun6i_dsi *dsi, + struct drm_display_mode *mode, u32 sync_point) +{ + struct mipi_dsi_device *device = dsi->device; + unsigned int bpp = mipi_dsi_pixel_format_to_bpp(device->format); + u32 hact_sync_bp; + + /* Horizontal timings duration excluding front porch */ + hact_sync_bp = (mode->hdisplay + mode->htotal - mode->hsync_start); + + return (sync_point + ((hact_sync_bp + 20) * bpp / (8 * device->lanes))); +} + +static u32 sun6i_dsi_get_edge0(struct sun6i_dsi *dsi, + struct drm_display_mode *mode, u32 edge1) +{ + struct sun4i_tcon *tcon = dsi->tcon; + unsigned long dclk_rate, dclk_parent_rate, tcon0_div; + + dclk_rate = clk_get_rate(tcon->dclk); + dclk_parent_rate = clk_get_rate(clk_get_parent(tcon->dclk)); + tcon0_div = dclk_parent_rate / dclk_rate; + + return (edge1 + (mode->hdisplay + 40) * tcon0_div / 8); +} + +static u32 sun6i_dsi_get_line_num(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); + + return (mode->htotal * bpp / (8 * device->lanes)); +} + static int sun6i_dsi_get_drq(struct sun6i_dsi *dsi, struct drm_display_mode *mode) { @@ -499,9 +534,32 @@ static u16 sun6i_dsi_get_video_start_delay(struct sun6i_dsi *dsi, static void sun6i_dsi_setup_burst(struct sun6i_dsi *dsi, struct drm_display_mode *mode) { - regmap_write(dsi->regs, SUN6I_DSI_TCON_DRQ_REG, - SUN6I_DSI_TCON_DRQ_ENABLE_MODE | - SUN6I_DSI_TCON_DRQ_SET(sun6i_dsi_get_drq(dsi, mode))); + struct mipi_dsi_device *device = dsi->device; + u32 sync_point = 40; + u32 line_num = sun6i_dsi_get_line_num(dsi, mode); + u32 edge1 = sun6i_dsi_get_edge1(dsi, mode, sync_point); + u32 edge0 = sun6i_dsi_get_edge0(dsi, mode, edge1); + u32 val; + + if (edge1 > line_num) + edge1 = line_num; + + 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_BURST_LINE_REG, + SUN6I_DSI_BURST_LINE_NUM(line_num) | + SUN6I_DSI_BURST_LINE_SYNC_POINT(sync_point)); + + /* enable burst mode */ + regmap_read(dsi->regs, SUN6I_DSI_BASIC_CTL_REG, &val); + val |= SUN6I_DSI_BASIC_CTL_VIDEO_BURST; + regmap_write(dsi->regs, SUN6I_DSI_BASIC_CTL_REG, val); } static void sun6i_dsi_setup_inst_loop(struct sun6i_dsi *dsi, @@ -726,7 +784,13 @@ static void sun6i_dsi_encoder_enable(struct drm_encoder *encoder) SUN6I_DSI_BASIC_CTL1_VIDEO_PRECISION | SUN6I_DSI_BASIC_CTL1_VIDEO_MODE); - sun6i_dsi_setup_burst(dsi, mode); + regmap_write(dsi->regs, SUN6I_DSI_TCON_DRQ_REG, + SUN6I_DSI_TCON_DRQ_ENABLE_MODE | + SUN6I_DSI_TCON_DRQ_SET(sun6i_dsi_get_drq(dsi, mode))); + + if (device->mode_flags & MIPI_DSI_MODE_VIDEO_BURST) + sun6i_dsi_setup_burst(dsi, mode); + sun6i_dsi_setup_inst_loop(dsi, mode); sun6i_dsi_setup_format(dsi, mode); sun6i_dsi_setup_timings(dsi, mode);