From patchwork Thu Feb 14 19:32:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 10813625 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 07D3813A4 for ; Thu, 14 Feb 2019 19:32:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EADB42EF28 for ; Thu, 14 Feb 2019 19:32:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DF4112EF2C; Thu, 14 Feb 2019 19:32:58 +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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BA2952EF28 for ; Thu, 14 Feb 2019 19:32:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9170E6EAB2; Thu, 14 Feb 2019 19:32:56 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0E89F6EAB2 for ; Thu, 14 Feb 2019 19:32:55 +0000 (UTC) Received: by mail-pl1-x643.google.com with SMTP id y10so3682664plp.0 for ; Thu, 14 Feb 2019 11:32:55 -0800 (PST) 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=sMYAwY4ous29UnB5Oi5EE6ejKMZVZfyoGoBh/UV0aBA=; b=gLyuFNxZDVwiWQTyAEaSIKyupd2FO3LthCT3RycZJoo5VAgCCm5xrr3msO/HyfvEMx auFPJhUdBlRrZvPqDagwnB6N2ASgKcbhDF89pYj3momO/Ogc97t3Ki5T1McH6JtrtS06 vx4jHyU0WHSodYQE9+u5hYXAGTDrSCP5XL6vnWnTaA2QsVzEqZtUwWOEcpIo4+rrN+tA ZdZmiHUbcBC1w/oOObos7tVzA1mHsHqr6sPCciXVaJ4c66o9YxgfuOz7NGZzjXgdhJWP 3d5l7S5UXeEQaPsxqnTUEhSJECTqhs/8g+0zcJN7GZDymleVC134rkB5Ud343FhHYbuk oMeA== X-Gm-Message-State: AHQUAuYs5ezlEgaH2xRViIUTThbKepdZoLvh8EfJuqgh2MEFR4QUYhme mKgbCJc++63oZGOjMRoupT8HDA== X-Google-Smtp-Source: AHgI3IYrryFfvBkMudqDb5MR15tKo+bXCkdnvLwU/O93NmFvAdhsZeXXx/m3+32FEnW/CaLE3ptqxg== X-Received: by 2002:a17:902:6a4:: with SMTP id 33mr5804993plh.99.1550172774582; Thu, 14 Feb 2019 11:32:54 -0800 (PST) Received: from localhost.localdomain ([115.97.184.151]) by smtp.gmail.com with ESMTPSA id o23sm10808832pfa.140.2019.02.14.11.32.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Feb 2019 11:32:53 -0800 (PST) From: Jagan Teki To: Maxime Ripard , David Airlie , Daniel Vetter , Chen-Yu Tsai Subject: [PATCH v8 01/10] drm/sun4i: sun6i_mipi_dsi: Compute burst mode loop N1 instruction delay Date: Fri, 15 Feb 2019 01:02:28 +0530 Message-Id: <20190214193236.7504-2-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.18.0.321.gffc6fa0e3 In-Reply-To: <20190214193236.7504-1-jagan@amarulasolutions.com> References: <20190214193236.7504-1-jagan@amarulasolutions.com> MIME-Version: 1.0 X-Mailman-Original-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=sMYAwY4ous29UnB5Oi5EE6ejKMZVZfyoGoBh/UV0aBA=; b=PDVQJJ9lTnIR2obHuE8IXjqrGZaBG4bTXc/s/YlPuONeKs6obUjPfE3bRIwDtftPqD inGbuX4SqIuL8+GS/1HAjQXeoL/eab3hVu0vZLyAUhlbBq1IQw085V5pIU3jbu7XuOfs h+sl/CMRnyVdT/rU7BlJF2VWfHkpyldB7LjBQ= X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Jagan Teki , Michael Trimarchi , linux-amarula@amarulasolutions.com, linux-arm-kernel@lists.infradead.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Loop N1 instruction delay varies between burst and non-burst video modes. 1) for burst mode panels it is computed based on the panel pixel clock along with horizontal sync and porch timings. 2) for non-burst mode panels, it is same as existing (50 - 1) Reference code is available in BSP (from linux-sunxi drivers/video/sunxi/disp2/disp/de/lowlevel_sun50iw1/de_dsi.c) dsi_dev[sel]->dsi_inst_loop_num.bits.loop_n1= (panel->lcd_ht-panel->lcd_x)*(150)/(panel->lcd_dclk_freq*8) - 50; => (((mode->htotal - mode->hdisplay) * 150) / ((mode->clock / 1000) * 8)) - 50; This patch add loop N1 computation for burst mode by simplifying existing code to support all possible modes. Signed-off-by: Jagan Teki Tested-by: Merlijn Wajer --- drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c index 3a28d70dbdc1..8184fbcfd9fd 100644 --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c @@ -355,6 +355,24 @@ static void sun6i_dsi_inst_init(struct sun6i_dsi *dsi, SUN6I_DSI_INST_JUMP_CFG_NUM(1)); }; +static u16 sun6i_dsi_setup_inst_delay(struct sun6i_dsi *dsi, + struct drm_display_mode *mode) +{ + struct mipi_dsi_device *device = dsi->device; + u32 hsync_porch, dclk; + u16 delay; + + hsync_porch = (mode->htotal - mode->hdisplay); + dclk = (mode->clock / 1000); + + if (device->mode_flags & MIPI_DSI_MODE_VIDEO_BURST) + delay = ((hsync_porch * 150) / (dclk * 8)) - 50; + else + delay = 50 - 1; + + return delay; +} + static u16 sun6i_dsi_get_video_start_delay(struct sun6i_dsi *dsi, struct drm_display_mode *mode) { @@ -401,7 +419,7 @@ static void sun6i_dsi_setup_burst(struct sun6i_dsi *dsi, static void sun6i_dsi_setup_inst_loop(struct sun6i_dsi *dsi, struct drm_display_mode *mode) { - u16 delay = 50 - 1; + u16 delay = sun6i_dsi_setup_inst_delay(dsi, mode); regmap_write(dsi->regs, SUN6I_DSI_INST_LOOP_NUM_REG(0), SUN6I_DSI_INST_LOOP_NUM_N0(50 - 1) |