From patchwork Mon Aug 7 05:26:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Ying X-Patchwork-Id: 13343016 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 235E1C04A6A for ; Mon, 7 Aug 2023 05:22:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=OvwK2G+o0HpD7FuLTH1tTBWIO8O9YyCLVN35TGTxFg4=; b=bKhOoCP4R1Y4dA JjLFIYhendiUb737syh1M5ICR3AJjAP8npCNILSXvaU36PU+BpCcYweRw7q/lcBscm+ybXgNoRgdH tRPm1lLqV37gKuOAejRoDrPP0ICd/QZ/9iAs7c4oJnnAlv0NWHsN3m83bQ/vHGPvDlFWWuYsANW+P ICODjkCawmVY18F9FWCEm6cm31ijj+H+KgBwxcBOJYkZfxOort93YFWFptNx31dcrCgqFX3zGyJz7 AxUk1aofeeeXd5/1iAr7fipUd3Iu39s+kyVuzh++mXIctsS8XNUp7ynflR/hq8KW14+koTaSkBE60 YIR+kvcrqqvJYNDCpytw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qSshL-00GAYS-1v; Mon, 07 Aug 2023 05:22:31 +0000 Received: from mail-am7eur03on2062e.outbound.protection.outlook.com ([2a01:111:f400:7eaf::62e] helo=EUR03-AM7-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qSshG-00GAUi-23 for linux-arm-kernel@lists.infradead.org; Mon, 07 Aug 2023 05:22:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=judhNTCadGuRJ9QhwwmOxjWldC0bnky2wcHVgn6Hfc0WUT58YLagqrmSt15oKIQy8dLRapOTsN7QeIUBa94qMFj2xjskSqAOzhK7uUP9gXm32NHhBH9VJBEZBqkc0PzPi9p3d4jp4cUoRQQ/GSlWxk3/C2lrt+TmwiCSjtm7inVKZftxAv/OAPhG/NOrRE8KLZ/JAMMRtHmG1w84P+jU4Otl71WCVRv2AH3pz5g5enq88rW7lmZkOy0XAd8x83gvzB/BCKOc2ihyaDUQSlwT1upA88fnOfGVnhcoaJu5sMmGyw1NBDBQ0TeJBvoCZDwI/sgnUE3bMoX1K29fIrimYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=XPvwHyPm/+RhMw62kuGEMYt5dvTiM3F8aa/srDQdTvc=; b=OzflrwFk7h2bIT3EZiqq3Fm1ulii67edMIv61HqveG+rf6H7jWmu5V7iT3g0/ktd346iRBg+HIFppZSfmFOA+iSHSDT44vV2gA07YlU1mOF5tJ3fAW/D47+7uaAKHPXpSUIk19UwA7Lh/BwC9EWq40f/bWV7+1pelpGEmG2OF5HGajzRaimLCs26vhHRTDJmadLKpWsZFyIC2bsbCzpBMwb6o7QQ+oUf86ca/eJAoi9e3Xr2ifE2GsSsRLcdz155Kgx+eCNuTNZ6eFBIKn8awfP98CUR8QyhYGdsHysCjDkIiwTULAZSesiFi056vS+U6+rhXrteVUW1tO75Ebz1zA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XPvwHyPm/+RhMw62kuGEMYt5dvTiM3F8aa/srDQdTvc=; b=OmidvkvjFy0xDT7Z6xH4E0g+eFuRlC8zU8wtiKUHNBt5AVz4qNOmXKMPwYAgj9qby2AnoBSusZHVm0umMQJfMDDMuM0joMUGMqwYuiOwN9/90oGpfAj7CBk/17OTf2I9uaV8v/26UcM88Vm/7tGpbpoxkkeCoiJHcl9cd3WfL0U= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM7PR04MB7046.eurprd04.prod.outlook.com (2603:10a6:20b:113::22) by PA4PR04MB9390.eurprd04.prod.outlook.com (2603:10a6:102:2a9::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.25; Mon, 7 Aug 2023 05:22:23 +0000 Received: from AM7PR04MB7046.eurprd04.prod.outlook.com ([fe80::9018:e395:332c:e24b]) by AM7PR04MB7046.eurprd04.prod.outlook.com ([fe80::9018:e395:332c:e24b%4]) with mapi id 15.20.6652.026; Mon, 7 Aug 2023 05:22:23 +0000 From: Liu Ying To: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: andrzej.hajda@intel.com, neil.armstrong@linaro.org, rfoss@kernel.org, Laurent.pinchart@ideasonboard.com, jonas@kwiboo.se, jernej.skrabec@gmail.com, airlied@gmail.com, daniel@ffwll.ch, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, alexander.stein@ew.tq-group.com, sam@ravnborg.org, jagan@amarulasolutions.com, yannick.fertre@foss.st.com, raphael.gallais-pou@foss.st.com, philippe.cornu@foss.st.com, hjc@rock-chips.com, heiko@sntech.de, zyw@rock-chips.com Subject: [PATCH v3 5/9] drm/bridge: synopsys: dw-mipi-dsi: Use pixel clock rate to calculate lbcc Date: Mon, 7 Aug 2023 13:26:04 +0800 Message-Id: <20230807052608.3038698-6-victor.liu@nxp.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230807052608.3038698-1-victor.liu@nxp.com> References: <20230807052608.3038698-1-victor.liu@nxp.com> X-ClientProxiedBy: SI2PR01CA0006.apcprd01.prod.exchangelabs.com (2603:1096:4:191::14) To AM7PR04MB7046.eurprd04.prod.outlook.com (2603:10a6:20b:113::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM7PR04MB7046:EE_|PA4PR04MB9390:EE_ X-MS-Office365-Filtering-Correlation-Id: 47616819-f20d-4c08-e88a-08db970647ba X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mzM/P0Z6MCMc2dVHWzt4nTLajKDCLuAworpivIvnhwkIvGuZugAcr+0oUS3La4wmRPY3RcNbEDCrLwP7kDVCVH7/FJD4VfXflOMD8j8y65PlqiuCjjq52fiWJLEqTlzsG5/7Ths0baimuQeA3GnRcYfVn+a8fdNHG5EWLanSpdS0q14sNRqJjLa/Q0KoDx3taIc4RIaq/61GIVQDcF8/g2flUN7CH33l9puV+DD47iCN4xoCBPUktNt70CDaCb/DCRrVS3MJboqfwDktK8pBMsVdBZCm7XnBBY7TuzbtdnlW9VW6dVucgT5COz0ZwS/0t08G2IRU/HYVhbX2nURHZiJiAI160vxXMsl2kTIIC93oFSulwAI6RvgFlziFpCqdEbv50NjyZfxVUJB/AshOdYo9+x17XLzHvN7cPnJnJR29m956FqOaFpspABUTd0wbsRN+96+OoGqFRUdzL0v2DXKilw/EsK8ml8AgQSLCQ/Odnm2KYur/+smx3p2rm3iLpbx/DH1QssdQkP5r9h/toTtfbiqVqEeCHgwYF2J1KMwVb57vd8/2/Q+GprhzGKlc+JmifULEWJMyKssWe/z6ssGTXTU4ZfhqEKabygqRR1k= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM7PR04MB7046.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(136003)(39860400002)(376002)(366004)(396003)(346002)(451199021)(1800799003)(186006)(2616005)(6486002)(52116002)(6666004)(6512007)(478600001)(86362001)(26005)(36756003)(1076003)(6506007)(41300700001)(316002)(8936002)(5660300002)(8676002)(7416002)(38350700002)(4326008)(2906002)(66946007)(66556008)(66476007)(38100700002)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1IQIK5DPTOpzYcMWukI4IcCA27fHF8CzMl0yfjmNerHWqQ8WewkB+Ll1IFzPx/t0s6VZ2O74ukzTjX9Dk32q7uc4QFGepejVcORO92c3jDzXdk6J8rk6HYP6CNDa9wtOXEQKqNOHuLecaWIxQh24RLPSVjJ9AsMUvwIa/C8J1P+B+oIXrWBQCoL+D9ogpbhZLtEXEDKaeIsVFHVNJU7Y9iHaLx6VNQ3bRIzN/ydRqvTBCGz4tV0F/ilLd4BBaBetyQFzQevmmYBon24Z8LtHvHscgN8Cw0IKLrcW1bMwmyAMPnrGaJj9lRU6u3+C0ltCmkxQQFFyKvRK899Ap6vTHmmWmNm4GDfK+hL3fwxQrjo3JjExLl7fW4ZnHvcsnaigd9VRFvnOZ1iUrvvsYox7Co9v+2uazXS4dsHTcCbtTS7tc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sakiWpd0d/IE2OXuzoeIipTVYOJ6VpiCJj1il7Juag7mvUljFHu3bnvrzU/+IOiBE8O9f3nQj9ctvm8DzN+nspRT1W8 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 47616819-f20d-4c08-e88a-08db970647ba X-MS-Exchange-CrossTenant-AuthSource: AM7PR04MB7046.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2023 05:22:23.4877 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: QIUXFf8UJ6NbqzsC6iC9exIrkqmnst6LOJ+m4j53H4jgPzF69ON8XO0eStC3Gk7Dd53EWfBs+1al81ob3VdCpw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB9390 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230806_222226_676515_0B60F951 X-CRM114-Status: GOOD ( 12.77 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org To get better accuration, use pixel clock rate to calculate lbcc instead of lane_mbps since the pixel clock rate is in KHz while lane_mbps is in MHz. Without this, distorted image can be seen on a HDMI monitor connected with i.MX93 11x11 EVK through ADV7535 DSI to HDMI bridge in 1920x1080p@60 video mode. Signed-off-by: Liu Ying Reviewed-by: Neil Armstrong --- v2->v3: * Add Neil's R-b tag from v1. v1->v2: * No change. drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c index c754d55f71d1..332388fd86da 100644 --- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -762,8 +763,15 @@ static u32 dw_mipi_dsi_get_hcomponent_lbcc(struct dw_mipi_dsi *dsi, u32 hcomponent) { u32 frac, lbcc; + int bpp; - lbcc = hcomponent * dsi->lane_mbps * MSEC_PER_SEC / 8; + bpp = mipi_dsi_pixel_format_to_bpp(dsi->format); + if (bpp < 0) { + dev_err(dsi->dev, "failed to get bpp\n"); + return 0; + } + + lbcc = div_u64((u64)hcomponent * mode->clock * bpp, dsi->lanes * 8); frac = lbcc % mode->clock; lbcc = lbcc / mode->clock;