Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp840891pxb; Thu, 19 Nov 2020 15:27:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJyVtGffdonAiFzBPJqGHYBdk4OLSH93ytDfIgGjp6uOVFgmnslqWu2BX9wyBZsKuNZK8+MD X-Received: by 2002:a17:906:1458:: with SMTP id q24mr31788924ejc.541.1605828443732; Thu, 19 Nov 2020 15:27:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605828443; cv=none; d=google.com; s=arc-20160816; b=fypcv85jkxTc7KgjT9jRAwPFmYAFFJVmgllToazQJTKBKmQRoShqNXXo7avzKeolTa I6ClVZPgkwn/Xcdr47INRJ8EHuOPsdP3oSbxpab17nmHAbv/MEhpnCWNA34/O6xdCtDX zRDfl3a7RL/3IEexolhaYNvgE4NCGAzmP6DBJtfuiKO1QZA2pamjWa6rbvlFP4OSxagl m7wZXUi84aGsiSrAD2MF3tuOFSx0uHh0Xjx1Z8q9vk+GO4SEC7o0Z4oP6NUGXWgRAbsI eY600CggOprlNIp2jskEo9SuJzIbT4OlZyJ2r9HUvpl2RNmIlWxR3lp/wTYrXFQ9U/8g yxFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=nOOQlcxkN1hXGbceqUlhj41myAT/qRNDu+7vZvocGTU=; b=cRxGnOvsak20oMtBHIQYZSwEFs0oNmUk6FJtntDhxEO2ydNuDp9uNZFUkUscZ4rYzx kFA8nWVDUY42r5OtX3VKL5y3OtpBiSANw0w9f2iQC6d9Xkw4KwokatHHWQVhPLdr6dNc Af0Xv5v8uUXl6Jle/WEZXqAnNq6o37eS7kWcrKLKam0cXJRlGfG6vb+jzFF7zFmzFKfL oaiEFFu0yN7cOiNBRYGaISSHzDE2Ey6X9tU5jJaHE9OyYbSylRaOogrb4tY6fjpxkTIo a66l7UOZ0HkPzJOhrkpfDQYcApGrF53o+9PXHeethwZte6EZI3ZZK489rgfqYCbTsXQb B/Kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=VmGuids1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j14si724193ejx.329.2020.11.19.15.27.00; Thu, 19 Nov 2020 15:27:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=VmGuids1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727026AbgKSXXs (ORCPT + 99 others); Thu, 19 Nov 2020 18:23:48 -0500 Received: from mail.kernel.org ([198.145.29.99]:40538 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726854AbgKSXXs (ORCPT ); Thu, 19 Nov 2020 18:23:48 -0500 Received: from DESKTOP-GFFITBK.localdomain (218-161-90-76.HINET-IP.hinet.net [218.161.90.76]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 71C8E2145D; Thu, 19 Nov 2020 23:23:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605828227; bh=cIts+rqCO629Rmhzj8eiwrJ/3uQfEGptv9+PyIIrZ4Y=; h=From:To:Cc:Subject:Date:From; b=VmGuids1Gc/XQSJeEHmARY0exFdBpK/dpyz/dPwXpjMZ5kqs5NMek8U2CYVbAsFtT NCSw75uC4tT0OqsC181u/jPXWvWv01OqGDavIODn9zE14epgWNiDIf0sX5u1AZBKuy 715r+D0/Df+SNv/iftzZn8sp5biGASE/FU/H0xR0= From: Chun-Kuang Hu To: Jitao Shi , Bilal Wasim , Philipp Zabel , David Airlie , Daniel Vetter Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, CK Hu , Chun-Kuang Hu Subject: [PATCH] drm/mediatek: dsi: Modify horizontal front/back porch byte formula Date: Fri, 20 Nov 2020 07:23:35 +0800 Message-Id: <20201119232335.6704-1-chunkuang.hu@kernel.org> X-Mailer: git-send-email 2.17.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: CK Hu In the patch to be fixed, horizontal_backporch_byte become to large for some panel, so roll back that patch. For small hfp or hbp panel, using vm->hfront_porch + vm->hback_porch to calculate horizontal_backporch_byte would make it negtive, so use horizontal_backporch_byte itself to make it positive. Fixes: 35bf948f1edb ("drm/mediatek: dsi: Fix scrolling of panel with small hfp or hbp") Signed-off-by: CK Hu Signed-off-by: Chun-Kuang Hu --- drivers/gpu/drm/mediatek/mtk_dsi.c | 61 +++++++++++------------------- 1 file changed, 22 insertions(+), 39 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c b/drivers/gpu/drm/mediatek/mtk_dsi.c index 4a188a942c38..65fd99c528af 100644 --- a/drivers/gpu/drm/mediatek/mtk_dsi.c +++ b/drivers/gpu/drm/mediatek/mtk_dsi.c @@ -444,7 +444,10 @@ static void mtk_dsi_config_vdo_timing(struct mtk_dsi *dsi) u32 horizontal_sync_active_byte; u32 horizontal_backporch_byte; u32 horizontal_frontporch_byte; + u32 horizontal_front_back_byte; + u32 data_phy_cycles_byte; u32 dsi_tmp_buf_bpp, data_phy_cycles; + u32 delta; struct mtk_phy_timing *timing = &dsi->phy_timing; struct videomode *vm = &dsi->vm; @@ -466,50 +469,30 @@ static void mtk_dsi_config_vdo_timing(struct mtk_dsi *dsi) horizontal_sync_active_byte = (vm->hsync_len * dsi_tmp_buf_bpp - 10); if (dsi->mode_flags & MIPI_DSI_MODE_VIDEO_SYNC_PULSE) - horizontal_backporch_byte = vm->hback_porch * dsi_tmp_buf_bpp; + horizontal_backporch_byte = vm->hback_porch * dsi_tmp_buf_bpp - 10; else horizontal_backporch_byte = (vm->hback_porch + vm->hsync_len) * - dsi_tmp_buf_bpp; + dsi_tmp_buf_bpp - 10; data_phy_cycles = timing->lpx + timing->da_hs_prepare + - timing->da_hs_zero + timing->da_hs_exit; - - if (dsi->mode_flags & MIPI_DSI_MODE_VIDEO_BURST) { - if ((vm->hfront_porch + vm->hback_porch) * dsi_tmp_buf_bpp > - data_phy_cycles * dsi->lanes + 18) { - horizontal_frontporch_byte = - vm->hfront_porch * dsi_tmp_buf_bpp - - (data_phy_cycles * dsi->lanes + 18) * - vm->hfront_porch / - (vm->hfront_porch + vm->hback_porch); - - horizontal_backporch_byte = - horizontal_backporch_byte - - (data_phy_cycles * dsi->lanes + 18) * - vm->hback_porch / - (vm->hfront_porch + vm->hback_porch); - } else { - DRM_WARN("HFP less than d-phy, FPS will under 60Hz\n"); - horizontal_frontporch_byte = vm->hfront_porch * - dsi_tmp_buf_bpp; - } + timing->da_hs_zero + timing->da_hs_exit + 3; + + delta = dsi->mode_flags & MIPI_DSI_MODE_VIDEO_BURST ? 18 : 12; + + horizontal_frontporch_byte = vm->hfront_porch * dsi_tmp_buf_bpp; + horizontal_front_back_byte = horizontal_frontporch_byte + horizontal_backporch_byte; + data_phy_cycles_byte = data_phy_cycles * dsi->lanes + delta; + + if (horizontal_front_back_byte > data_phy_cycles_byte) { + horizontal_frontporch_byte -= data_phy_cycles_byte * + horizontal_frontporch_byte / + horizontal_front_back_byte; + + horizontal_backporch_byte -= data_phy_cycles_byte * + horizontal_backporch_byte / + horizontal_front_back_byte; } else { - if ((vm->hfront_porch + vm->hback_porch) * dsi_tmp_buf_bpp > - data_phy_cycles * dsi->lanes + 12) { - horizontal_frontporch_byte = - vm->hfront_porch * dsi_tmp_buf_bpp - - (data_phy_cycles * dsi->lanes + 12) * - vm->hfront_porch / - (vm->hfront_porch + vm->hback_porch); - horizontal_backporch_byte = horizontal_backporch_byte - - (data_phy_cycles * dsi->lanes + 12) * - vm->hback_porch / - (vm->hfront_porch + vm->hback_porch); - } else { - DRM_WARN("HFP less than d-phy, FPS will under 60Hz\n"); - horizontal_frontporch_byte = vm->hfront_porch * - dsi_tmp_buf_bpp; - } + DRM_WARN("HFP + HBP less than d-phy, FPS will under 60Hz\n"); } writel(horizontal_sync_active_byte, dsi->regs + DSI_HSA_WC); -- 2.17.1