From patchwork Fri Nov 16 16:39:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 47 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pg1-f200.google.com (cartago.priv [10.11.12.1]) by cassiopea (Postfix) with ESMTPS id 99BE52E53B4 for ; Fri, 16 Nov 2018 17:40:09 +0100 (CET) Received: by mail-pg1-f200.google.com with SMTP id s22sf15771447pgv.8 for ; Fri, 16 Nov 2018 08:40:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1542386408; cv=pass; d=google.com; s=arc-20160816; b=aRrhV7pLRsU/h3dOQYCSNZ50EQBT4Jclc8yvdXMY3agB/UU7Avow0BRP1ABjWdjjiq dbhW0FRVEXDW3twZ8QIkLbWCAT7qpaGn50a5Wa+joFfTpnJDhsMGUELo9SOquVJtfHIa JsRsGiynWmPHWHADdlxk8umO8tHtK5q7/iECKRMHi1rYagf81P1E1rtUyfFFenAMC/px YqpKZdLPDXSkHjr2cK4Eh4VMSJU683p2OjbXCQ3lxatjlFKpTZTizqx2s8qHhXHl5lOw hh6MoGQ2X6mKVaN9BOdtLyxYOT1nlzSdSR4QN+nQqUQu6Mlmpck6qpgiOaqRLFhA/BZV +EfQ== 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=YBsrf76ZM/i+rqqgf+m+LE5qjwwWDpXcodR4cqVxPuQ=; b=Iabqq9FpCK+WHSlq63akREYHhaWw5lhsDIfnpJusCrnbVeMu+EFooTwhWEMQ+d03Cp 70FHbP9EoWfLH1Do/9dHOBlM66Ie3fTN3r+l5uOSRbls+aezIA6OwN1FApK03VQ+/DaH qZ1FOZSXYgl4sOeYgy72zhq1ifOX3QgHTRy3xO266QYJD66VDPh/uTW62Re8tnLA4zGP t8+HaSwrjmAZ71X0ETB4ign07uV9BewUth7isl1aNcz79+II0zurT+Jr71YXtp6do47j fryUESwOgJgb+8FiMYmKihRA9ctrpXA2RJmNoVVvvRfmXbc5JDyCaVk6cs/l2sojAej6 cKfg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=WB18R8Bf; 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=YBsrf76ZM/i+rqqgf+m+LE5qjwwWDpXcodR4cqVxPuQ=; b=YWGpfUrVInjkJjrYfLwKJyTtD+bQw7BK8tlP6a1iPZ6apmWOYMLr4HdRMggv+mOeKN uRpN9/wdgls9v/toEaiS0zwJRrl0xQmn0b//wt/SDFYmRhC+soupktjG1ykokx9oQCgX vST7P4a1LVU32oaAZOFQ3hTaHNLBl+1VB6qI4= 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=YBsrf76ZM/i+rqqgf+m+LE5qjwwWDpXcodR4cqVxPuQ=; b=sqGcxoKg+jn+uH7pLgbSZ8ex0MPvNoYF+2T3508SvbQs2YYqKY2KhIXb2A08p4+wuJ nCOaDmitTFzcwtR73hE+xUYrITRMQsYMO1ePqxRAUW8D94XwSs6DJ++w24IaG/kLeChy aJ6CdIcvPMSGs+4B8QhgV1aA+dp6NtZFDU81asAKEgrwk4hBi1MkSvgFATf7RL1GsToH +WdZOxFSBiLj3KSqT2a/F8rjNj8qFaZMQq1ORUaiG+Zcyh7aQngBM/EnBefxX8Y0moqQ oHecdhzzAaghHhVbq1fqo9hspViNbtk2v7tNRMJvPxQkNRvApW0S3sLR6/WoZb/5fWEv Otbg== X-Gm-Message-State: AGRZ1gLtopYO8G8nP/sXuhwnxQI9qh807o/VVUFyPNcQGhs4fcUHCVcL 1KLp0NUrhS7Xql8epiHryMFYWmu+ X-Google-Smtp-Source: AJdET5eyL+3R8y7x+DZvTnfyNuDDIZGu5TyFUszV/Ze+eQ5os/gIYc8SEHHBo8zFeA0DO0GlTheztw== X-Received: by 2002:a63:5503:: with SMTP id j3mr2603742pgb.89.1542386408315; Fri, 16 Nov 2018 08:40:08 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a63:618a:: with SMTP id v132ls6127706pgb.6.gmail; Fri, 16 Nov 2018 08:40:08 -0800 (PST) X-Received: by 2002:a63:e156:: with SMTP id h22mr10658978pgk.255.1542386408017; Fri, 16 Nov 2018 08:40:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542386407; cv=none; d=google.com; s=arc-20160816; b=MjtcsFJUWtU/C8vP817+XHhvDpp6x86n5lzIBFJPUcs9eiW8vOFX6zheG4ZG+Lj1+1 Gpdxtq/bmGS9F3NXzulZvAPzERL+RsqaDpTETxnJhWsEdRSk7nLpEqEeHeiWrrfEoOHC K1AYKMJdgGiTk29ykDebEKkC7CCS8gjWn9nOc+x9Vc4hAptpRnr2YQlMZualY546hCTS 0kCzy+7qANsDp7hlfykMIlCjtuabU+CbU1EO5UX4dzAgnwo3AVJsqGg8loXPguRdDKYJ Cz0LkwONgatEYJPf0Lxc+U+d/DBlftmFUprUywLDV2y34jR80dmooyOkI2SYGm2Gw7+F zdmQ== 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=YBsrf76ZM/i+rqqgf+m+LE5qjwwWDpXcodR4cqVxPuQ=; b=vW7kVkyq7/ezlOPVkoKoGnvr0f284mIWXrJbyB6KXqfpXu3Xzqwefyy7NsMxwKyQPl Amn3M2DcdAfSfFFmDy9JgyaqToU6zgRlPhpin4LHi6IU4UshnzZkF/NqGJE14kSAGeud +oM+H2Gz5K8eb7D4kJS/dOr5eIcqDg4XHSlYyb9sa9g/1MwkZrYuDpuy6jkVt+h5GLdg hEvJ3l+BK+eA0Z0ibqAxg2KfSWc1FBjPHtpRJY9rVSolkXyUv+CW9sPbauUFZT8K3QgH Ie8OtclnljGvlWYeLH/RVLe5869f5ZCAhfJf4V99NO2HVCTRdKIUfbNP6AdbxGLuYN9C aWFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=WB18R8Bf; 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 e16-v6sor35544206pgh.17.2018.11.16.08.40.07 for (Google Transport Security); Fri, 16 Nov 2018 08:40:07 -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:8ac4:: with SMTP id y187mr10597592pgd.446.1542386407688; Fri, 16 Nov 2018 08:40:07 -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.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Nov 2018 08:40:07 -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 04/12] drm/sun4i: sun6i_mipi_dsi: Simplify drq set to support all modes Date: Fri, 16 Nov 2018 22:09:08 +0530 Message-Id: <20181116163916.29621-5-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=WB18R8Bf; 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: , Allwinner MIPI DSI DRQ set value can be varied with respective video modes. - burst mode the set value is always 0 - video modes whose front porch greater than 20, the set value can be computed based front porch and bpp. - video modes whose front porch is not greater than 20, the set value is simply 0 This patch simplifies existing drq set value code by grouping into sun6i_dsi_get_drq and support all video modes. Signed-off-by: Jagan Teki --- drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 38 ++++++++++++++++---------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c index efd08bfd0cb8..d60955880c43 100644 --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c @@ -363,6 +363,26 @@ static void sun6i_dsi_inst_init(struct sun6i_dsi *dsi, SUN6I_DSI_INST_JUMP_CFG_NUM(1)); }; +static int sun6i_dsi_get_drq(struct sun6i_dsi *dsi, + struct drm_display_mode *mode) +{ + struct mipi_dsi_device *device = dsi->device; + int drq = 0; + + if (device->mode_flags & MIPI_DSI_MODE_VIDEO_BURST) + return drq; + + 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; + } + + return drq; +} + static u16 sun6i_dsi_get_timings_vblk(struct sun6i_dsi *dsi, struct drm_display_mode *mode, u16 hblk) { @@ -478,21 +498,9 @@ 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) { - struct mipi_dsi_device *device = dsi->device; - u32 val = 0; - - 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; - - val = (SUN6I_DSI_TCON_DRQ_ENABLE_MODE | - SUN6I_DSI_TCON_DRQ_SET(drq)); - } - - regmap_write(dsi->regs, SUN6I_DSI_TCON_DRQ_REG, val); + 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))); } static void sun6i_dsi_setup_inst_loop(struct sun6i_dsi *dsi,