From patchwork Fri Nov 16 16:39:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 46 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pf1-f197.google.com (cartago.priv [10.11.12.1]) by cassiopea (Postfix) with ESMTPS id 8C0D52E53B4 for ; Fri, 16 Nov 2018 17:40:02 +0100 (CET) Received: by mail-pf1-f197.google.com with SMTP id 129-v6sf19478906pfx.11 for ; Fri, 16 Nov 2018 08:40:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1542386401; cv=pass; d=google.com; s=arc-20160816; b=guagvwHkeo7QbLH5X1y36lusrE5PeBt3S1tGzMGLTXoXNsiucNjErBgAVp/vVR0Zzk eZvWxHWbBoXFcGFj1iZXjQFkBwEtt3iIqnIb0rwSSTxyp6OG4Za4dUtlBuhMltGXjgdT sGKBI1/as7nyqYNxf9H+Ng4ypKHb7d3F20VMLPhMR34eJEdUppY3L7VFklYLGKbghlyt rje7MKE7mbT0G146ddDqwyIhfnbkS6mCYJofyqPy3WThKsOvgKq8xR0w7y4ljGWniN+d Zqrr1JJs4R9JVYbojUUuIK29zUJ5lYUkcmtMqX2/z4IeHbagVAeEXAdzNxwl9x76k78e HYlw== 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=1dP1vOMxWacxYs/v4J30IWXfhdx6NrRFGWFTZApmbYU=; b=nKIlYh5rynO9y4eXwp5B9uqLJXKlIiTxADwqIK5iWQ02bQunheIudpW9bMzehb8H/X dy+PlbHJXZ3JQ74DlAHfXBPoTj0qSx4qM26sSjvQuWVucZ8E2QY4/NrU660h/ok0129+ OdXwkcvQYQAvJqc9GCvB/KpVcZ5dxgz1d3SobXgOD5VTuKiX/czuBryCMVpBbBAd8t5j dWOq5qOAClHYgVZunSimbVyjEQHZc2yYM8lULnO0KZKtbv+c9qNMLkosAls6U79F6hkq zcwWVeHdcT7kLCbluMXWfI4a2hXxRL5Z+5iYoG9fa2Yqsy8LUjk5TD/ILVn4v9By5He+ vDBw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=ceOdo43z; 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=1dP1vOMxWacxYs/v4J30IWXfhdx6NrRFGWFTZApmbYU=; b=HiHimCjbH3t5pyZD2nlgXEIFpZXb1ZVWFOxBpCh4jqc2Zu47KMo8pw8ar1Uckr2EwU NClS9B/e2PLiAk8svUaW0hZ0XuR0DvUaTg689I3y+zl764tZONu9TOULIpztRrrOw2gB tHQFgbQQ1yRyAUyV2k72zf0BIXCZu928MAUbk= 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=1dP1vOMxWacxYs/v4J30IWXfhdx6NrRFGWFTZApmbYU=; b=lP3QihqutlxlM3mkiUOTj/vs2eI/VKmkY9gXb8XdOcyhsQXiJd9WwZCsL7pbULeYSJ 9NPudXujKtcWrklyfh4ZFNdMadihndBkReYbr0Chq+ya6k5qT8mvdEHZWTCmIay/YUa+ a8osCMd2LrkP9tw/Gk9q5sqry7UiqeD/IqVgKrdDxm6cG1SFt8Yl3ndJRLyD8owqcpoY DnphGblaNq0/mGvBxWiJyL/k6pi+wmWtg0onyLGpoEq91TY4K81mXRGOci96lg8iD/RO 0BWx6IOuQL6nP3Gq2ploxaL8prIiVzllAiWRrZaXRXc4Qv/TKKVJbFDU3AOJdrPc9OMe bGYQ== X-Gm-Message-State: AGRZ1gL7JInT3RChhBgsQAslVFuPwHCUGk1wGsBO/fbxAGiCTQkt1x0u FFBv0g+nA/EVQen7N/v4gcrBEyds X-Google-Smtp-Source: AJdET5ejYqtqu+ehEZuS0N4XsT3LAclaq03MCcoh+AGICN37XrYlLe1bwFjfL4Jpym2Z6AWDNiTS5Q== X-Received: by 2002:a62:7d11:: with SMTP id y17mr2646033pfc.117.1542386400936; Fri, 16 Nov 2018 08:40:00 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a62:20d5:: with SMTP id m82ls4935452pfj.5.gmail; Fri, 16 Nov 2018 08:40:00 -0800 (PST) X-Received: by 2002:a63:7a5b:: with SMTP id j27mr10656232pgn.112.1542386400593; Fri, 16 Nov 2018 08:40:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542386400; cv=none; d=google.com; s=arc-20160816; b=rGScDkNoH/sHFqhsBS8oUbvBmhlWGpcZP6TAqsy7/ki9nL6sFg5mTzLTw4VRHjKKCG r3Bm9J+BSeb/zZepkJJl8e+Ue5FvhES6SgMdQKkXfQrUhOSYwd/iLRIwWUuA7OdppmhT f6Mq67Rxg/eZsldpQ2TluhxhxxAjne3qPyNAVJqBcRz0WP3UMvUof6AheMMfO21ggAd2 ZwN7KnaYVya/+tDtHd2Q7s1wZ5GEL0GdWRhbtDswad4/z/GF1pdaAfyr3hey8wAQ364i n1sS0f6FDXkpqqYHggmw3uWOQHhpg0rJwWyVWhKlL7vG1xLNp6609iGe+fxnjilAs6om tRuw== 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=1dP1vOMxWacxYs/v4J30IWXfhdx6NrRFGWFTZApmbYU=; b=glWEF7XDlz2yjM/GW/s1rvYQFFdkpWNmp/2HmozGgZfo3fHc73vbodsgNUdzfcLNGE UGzFFYLyQl3y/MfHLEI58PC9J2YbbVxefsdo2b2uBlq99f6Ei8R91kIAf35gF3s2EvS1 /LUyIquReXNPOl4ODjwagLReYrsAcYRm5JDlp74820+y1VN5PDzJEdZGMyXTcD8F20jo hYUm5tq3WRhLKNI8EqlKDRwT7MNPFURoXdXVxQEH8wwhTcuPW3in2vkT14sHFnEqvAZ/ mXdyl9BHYAm8b030gosqnhLDkI/PYgf2ZGLVfvmkBB5eN2XjUbUxDNFILfFOxB0uUju3 YMqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=ceOdo43z; 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 q5sor11845497pgv.82.2018.11.16.08.40.00 for (Google Transport Security); Fri, 16 Nov 2018 08:40:00 -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:1412:: with SMTP id u18mr10422416pgl.247.1542386400202; Fri, 16 Nov 2018 08:40:00 -0800 (PST) Received: from localhost.localdomain ([115.97.190.86]) by smtp.gmail.com with ESMTPSA id p5-v6sm34622213pfb.109.2018.11.16.08.39.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Nov 2018 08:39:59 -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 03/12] drm/sun4i: sun6i_mipi_dsi: Setup burst mode timings Date: Fri, 16 Nov 2018 22:09:07 +0530 Message-Id: <20181116163916.29621-4-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=ceOdo43z; 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: , Burst mode display timings are different from convectional video mode so update the horizontal and vertical timings. Reference code taken from BSP (from linux-sunxi/ drivers/video/sunxi/disp2/disp/de/lowlevel_sun50iw1/de_dsi.c) dsi_hsa = 0; dsi_hbp = 0; dsi_hact = x*dsi_pixel_bits[format]/8; dsi_hblk = dsi_hact; dsi_hfp = 0; dsi_vblk = 0; Signed-off-by: Jagan Teki --- drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 128 +++++++++++++++---------- 1 file changed, 80 insertions(+), 48 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c index 3ac002c4d8b3..efd08bfd0cb8 100644 --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c @@ -153,6 +153,14 @@ #define SUN6I_DSI_CMD_TX_REG(n) (0x300 + (n) * 0x04) +struct sun6i_dsi_timings { + u16 hsa; + u16 hbp; + u16 hblk; + u16 hfp; + u16 vblk; +}; + enum sun6i_dsi_start_inst { DSI_START_LPRX, DSI_START_LPTX, @@ -379,6 +387,60 @@ static u16 sun6i_dsi_get_timings_vblk(struct sun6i_dsi *dsi, return vblk; } +static void sun6i_dsi_get_timings(struct sun6i_dsi *dsi, + struct drm_display_mode *mode, + struct sun6i_dsi_timings *timings) +{ + struct mipi_dsi_device *device = dsi->device; + unsigned int Bpp = mipi_dsi_pixel_format_to_bpp(device->format) / 8; + u16 hsa, hbp, hblk, hfp, vblk; + + /* + * A sync period is composed of a blanking packet (4 bytes + + * payload + 2 bytes) and a sync event packet (4 bytes). + * Its minimal size is therefore 10 bytes + */ +#define HSA_PACKET_OVERHEAD 10 + hsa = max((unsigned int)HSA_PACKET_OVERHEAD, + (mode->hsync_end - mode->hsync_start) * Bpp - + HSA_PACKET_OVERHEAD); + + /* + * The backporch is set using a blanking packet (4 bytes + + * payload + 2 bytes). Its minimal size is therefore 6 bytes + */ +#define HBP_PACKET_OVERHEAD 6 + hbp = max((unsigned int)HBP_PACKET_OVERHEAD, + (mode->htotal - mode->hsync_end) * Bpp - HBP_PACKET_OVERHEAD); + + /* + * hblk seems to be the line + porches length. + * The blank is set using a blanking packet (4 bytes + 4 bytes + * + payload + 2 bytes). So minimal size is 10 bytes + */ +#define HBLK_PACKET_OVERHEAD 10 + hblk = max((unsigned int)HBLK_PACKET_OVERHEAD, + (mode->htotal - (mode->hsync_end - mode->hsync_start)) * + Bpp - HBLK_PACKET_OVERHEAD); + + /* + * The frontporch is set using a blanking packet (4 bytes + + * payload + 2 bytes). Its minimal size is therefore 6 bytes + */ +#define HFP_PACKET_OVERHEAD 6 + hfp = max((unsigned int)HFP_PACKET_OVERHEAD, + (mode->hsync_start - mode->hdisplay) * Bpp - + HFP_PACKET_OVERHEAD); + + vblk = sun6i_dsi_get_timings_vblk(dsi, mode, hblk); + + timings->hsa = hsa; + timings->hbp = hbp; + timings->hblk = hblk; + timings->hfp = hfp; + timings->vblk = vblk; +} + static u16 sun6i_dsi_setup_inst_delay(struct sun6i_dsi *dsi, struct drm_display_mode *mode) { @@ -506,52 +568,22 @@ static void sun6i_dsi_setup_timings(struct sun6i_dsi *dsi, { struct mipi_dsi_device *device = dsi->device; unsigned int Bpp = mipi_dsi_pixel_format_to_bpp(device->format) / 8; - u16 hbp, hfp, hsa, hblk, vblk; + struct sun6i_dsi_timings timings; size_t bytes; u8 *buffer; /* Do all timing calculations up front to allocate buffer space */ - /* - * A sync period is composed of a blanking packet (4 bytes + - * payload + 2 bytes) and a sync event packet (4 bytes). Its - * minimal size is therefore 10 bytes - */ -#define HSA_PACKET_OVERHEAD 10 - hsa = max((unsigned int)HSA_PACKET_OVERHEAD, - (mode->hsync_end - mode->hsync_start) * Bpp - HSA_PACKET_OVERHEAD); + memset(&timings, 0, sizeof(timings)); - /* - * The backporch is set using a blanking packet (4 bytes + - * payload + 2 bytes). Its minimal size is therefore 6 bytes - */ -#define HBP_PACKET_OVERHEAD 6 - hbp = max((unsigned int)HBP_PACKET_OVERHEAD, - (mode->htotal - mode->hsync_end) * Bpp - HBP_PACKET_OVERHEAD); - - /* - * The frontporch is set using a blanking packet (4 bytes + - * payload + 2 bytes). Its minimal size is therefore 6 bytes - */ -#define HFP_PACKET_OVERHEAD 6 - hfp = max((unsigned int)HFP_PACKET_OVERHEAD, - (mode->hsync_start - mode->hdisplay) * Bpp - - HFP_PACKET_OVERHEAD); - - /* - * hblk seems to be the line + porches length. - * The blank is set using a blanking packet (4 bytes + 4 bytes + - * payload + 2 bytes). So minimal size is 10 bytes - */ -#define HBLK_PACKET_OVERHEAD 10 - hblk = max((unsigned int)HBLK_PACKET_OVERHEAD, - (mode->htotal - (mode->hsync_end - mode->hsync_start)) * - Bpp - HBLK_PACKET_OVERHEAD); - - vblk = sun6i_dsi_get_timings_vblk(dsi, mode, hblk); + if (device->mode_flags & MIPI_DSI_MODE_VIDEO_BURST) + timings.hblk = (mode->hdisplay * Bpp); + else + sun6i_dsi_get_timings(dsi, mode, &timings); /* How many bytes do we need to send all payloads? */ - bytes = max_t(size_t, max(max(hfp, hblk), max(hsa, hbp)), vblk); + bytes = max_t(size_t, max(max(timings.hfp, timings.hblk), + max(timings.hsa, timings.hbp)), timings.vblk); buffer = kmalloc(bytes, GFP_KERNEL); if (WARN_ON(!buffer)) return; @@ -590,33 +622,33 @@ static void sun6i_dsi_setup_timings(struct sun6i_dsi *dsi, /* sync */ regmap_write(dsi->regs, SUN6I_DSI_BLK_HSA0_REG, - sun6i_dsi_build_blk0_pkt(device->channel, hsa)); + sun6i_dsi_build_blk0_pkt(device->channel, timings.hsa)); regmap_write(dsi->regs, SUN6I_DSI_BLK_HSA1_REG, - sun6i_dsi_build_blk1_pkt(0, buffer, hsa)); + sun6i_dsi_build_blk1_pkt(0, buffer, timings.hsa)); /* backporch */ regmap_write(dsi->regs, SUN6I_DSI_BLK_HBP0_REG, - sun6i_dsi_build_blk0_pkt(device->channel, hbp)); + sun6i_dsi_build_blk0_pkt(device->channel, timings.hbp)); regmap_write(dsi->regs, SUN6I_DSI_BLK_HBP1_REG, - sun6i_dsi_build_blk1_pkt(0, buffer, hbp)); + sun6i_dsi_build_blk1_pkt(0, buffer, timings.hbp)); /* frontporch */ regmap_write(dsi->regs, SUN6I_DSI_BLK_HFP0_REG, - sun6i_dsi_build_blk0_pkt(device->channel, hfp)); + sun6i_dsi_build_blk0_pkt(device->channel, timings.hfp)); regmap_write(dsi->regs, SUN6I_DSI_BLK_HFP1_REG, - sun6i_dsi_build_blk1_pkt(0, buffer, hfp)); + sun6i_dsi_build_blk1_pkt(0, buffer, timings.hfp)); /* hblk */ regmap_write(dsi->regs, SUN6I_DSI_BLK_HBLK0_REG, - sun6i_dsi_build_blk0_pkt(device->channel, hblk)); + sun6i_dsi_build_blk0_pkt(device->channel, timings.hblk)); regmap_write(dsi->regs, SUN6I_DSI_BLK_HBLK1_REG, - sun6i_dsi_build_blk1_pkt(0, buffer, hblk)); + sun6i_dsi_build_blk1_pkt(0, buffer, timings.hblk)); /* vblk */ regmap_write(dsi->regs, SUN6I_DSI_BLK_VBLK0_REG, - sun6i_dsi_build_blk0_pkt(device->channel, vblk)); + sun6i_dsi_build_blk0_pkt(device->channel, timings.vblk)); regmap_write(dsi->regs, SUN6I_DSI_BLK_VBLK1_REG, - sun6i_dsi_build_blk1_pkt(0, buffer, vblk)); + sun6i_dsi_build_blk1_pkt(0, buffer, timings.vblk)); kfree(buffer); }