Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp2164293pxb; Sat, 14 Nov 2020 16:17:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJxHhr3o8cNaETRw/NT4lAWW3lrl3tH7bgnprFYnvYlbXCukeiZ7FJt2n2tGxAxWGxOQ50bL X-Received: by 2002:a05:6402:b02:: with SMTP id bm2mr9202085edb.299.1605399446956; Sat, 14 Nov 2020 16:17:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605399446; cv=none; d=google.com; s=arc-20160816; b=S3zqpC8lRkn9j9t++Ve7cQ4APgVLxTGt15Gm8aW4Dr8RhUPsQ01h+iAKOu4+qNstiZ 62r+rl4FNiQjfggNnnFT6gFMCyEVGWX8R4NdSUkYVxdLwTBXsxtxmhccnEv4x75UFa+W J6lzjpYqJlKUF4Mz9ATatVesYo2QB+WYTUYM6gcUf+6RfbGWeKQRxbgBwByTqL/wMl8P wfwxooWp9XyrKifN+4tmQf7el0H67Hmyupl8VjDdv8SOXeUsGU5kGnPtpqJ2s4aYPrW9 xo9fIy0uf89GRqVF5H1zwK9IIkjMJi2lNcQEHBnyjV9bOsEY45GiBmStEDvlhfXuwEWs S4Cg== 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=m2u/SAnQquZQet/EzUPvHHIR2HjQGvgjFWC7rPj8xJ0=; b=H6cu842EM3taD31bLykoCRjtgNJY+/8nl4aTIvepj9lWof2lBMUbOHZVZVk3zhICdZ /+0g+/IDyfiEWS6VuQRak5lVnWvFlGF495CpiUN1gYyNvcw5vV//r232tcxOxS9ZW4bR Lu0RHiH4WiOe2YxCoZ+dBEkyT8CkoomFFUXbcfMTJEe9yp3VX5++RJepXBB/Edjisgbb mVHyK1tbfRfpupvw1kIdGcKLg6vWfB4UsZKGNm97cEjkJHWYuD3Q/+OXCRzJMK1Cs7tg iit7uz/1T03/ZLR8/kEQ7YqfTRdQNLbFVESEah2QurY3HZCYz/tCHoYGnoqmGivzaE7R 166A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ey5LMsHW; 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 bx12si9178761edb.10.2020.11.14.16.17.03; Sat, 14 Nov 2020 16:17:26 -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=ey5LMsHW; 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 S1726429AbgKOAO1 (ORCPT + 99 others); Sat, 14 Nov 2020 19:14:27 -0500 Received: from mail.kernel.org ([198.145.29.99]:37638 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726265AbgKOAO1 (ORCPT ); Sat, 14 Nov 2020 19:14:27 -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 E7992239D2; Sun, 15 Nov 2020 00:14:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605399266; bh=aFodP6QBgsn9xkYrio2coFUfOEugpYzOvzPkPjiijz4=; h=From:To:Cc:Subject:Date:From; b=ey5LMsHWOGuLxIFw7YVnb+bfMgjlg16qCiKGZDHQAJbRmq7Su1LHKYnDJCgOfXUS6 PXXZd9LlW3wB78nNjrdOEbPKzs7VvbtKTRaJXeJlXvZ1PBkxLDEp7l97V7WZwJ4/w4 67x+xF6/BYtdG13/jeY6rZk0OpHCZf2hVaHYkJcs= 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: Calculate horizontal_backporch_byte by itself Date: Sun, 15 Nov 2020 08:14:03 +0800 Message-Id: <20201115001403.7833-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 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 | 53 ++++++++++-------------------- 1 file changed, 18 insertions(+), 35 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c b/drivers/gpu/drm/mediatek/mtk_dsi.c index 4a188a942c38..2a64fdaed9a7 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; @@ -474,42 +477,22 @@ static void mtk_dsi_config_vdo_timing(struct mtk_dsi *dsi) 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; - } + 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