From patchwork Mon Sep 30 05:28:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ying Liu X-Patchwork-Id: 13815402 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 441CDCF6491 for ; Mon, 30 Sep 2024 05:38:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-Type: Content-Transfer-Encoding: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=cHBqa3+OL2Qfk9ygLdKmIKmRg+wTlyOij3iu7z6WS50=; b=X+WbegRxgUEXhWLz0CskQ4Q2b+ vwmMV2wDsvQ03gnp8dt0FPdPddQnZ8qeOZ3eyrZRPLDrICrM1XBE3Nl1UWDiXP89YiKN5xV0PDk8U fjTftLHH+8sqFf0Czvq0mt9pCKjzMmQfto93xZ743kC92PC3qngdfxqOP7YXnlAT37QBOPjUF6JYM stBqPQBe5vuHMoLbYWtqXMPoKCtFGvk6fqLqnJ1ORmZQhzswTY5Bjhn2EkxfQ0XjhjLkhQhgOGaCr en5KumMH0QmQmaLyx8prGT5F74MRUyuxaLpJpU3D1s8vbRFuABoZSyYh9bQtrA3W29oE5cZ6Of2gl lhAGvqeg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1sv96s-0000000FzTC-2TOG; Mon, 30 Sep 2024 05:38:14 +0000 Received: from mail-westeuropeazlp170110003.outbound.protection.outlook.com ([2a01:111:f403:c201::3] helo=AS8PR04CU009.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1sv8yR-0000000Fy5b-1REL for linux-arm-kernel@lists.infradead.org; Mon, 30 Sep 2024 05:29:32 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ryqJzzlp50bJ/md9BIsoNP5+qA6TnwumRzM+Az/qykB5L/Yk/ZGKnjYB/4p9DBdWFLko3WWTcDG+CmfO1AgSvie8hpDYk7QQlJxcWS7BSxP9qMD1mtwDSFGOg0/5zGA502na11A7RzMNn6KCYnG46w7N0oyTzKVyKKpQZejZ84N/ulcgmL9f4Bb1s4yQhfM9QEMdIFZQRHaQ7hQcArwDaDTok/aoECuDqDFsWh6AXw05KNi1ITtZvQktN5pnwO1mgcWypyKb7DnK26MMTbaq8yLb/U0nA5D+jqWnDII5Hye8EyhOhpjyo/fWrB5lUZ/dm71rKKOuS9zLXYl+W0nwiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=cHBqa3+OL2Qfk9ygLdKmIKmRg+wTlyOij3iu7z6WS50=; b=kA8uMS4AkWELPlETPG2+Z1DJam886Vc2m9agSKUdric6sx9vlYen/AWXiK+NgVofyc2hzkFEFZIXQ2RyCVMa5+HZnm9UFz8sCwh4pGiZW59CoihXrhj1b5uJxIaFdSm63CfPA0RC18wM3jSJPzYTcnuwD9hRdv9E8pXD8AyVxWzv6ouoIaYebNJRHbGacMR6aPVrmHRFMJ6eidUsa2/VCfMtRpNs7Bm0BaunA1Lx1vsR+Nx/5RvrsPJjeTkPQTuHkIqP7GMzE18fuSeSrX9i7RQAU1QBbiUSwVvoJCFzymemnSJisAikUPpb26DR5dnAmyQyqwwoskz5H2mGsbMOvA== 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=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cHBqa3+OL2Qfk9ygLdKmIKmRg+wTlyOij3iu7z6WS50=; b=lvUrHre2YRlH0c76VtHEZftN7Xqb8V/ePjmUbTxfudNthNrVFsHq6UBWxUwIZ4avj0m9aXMPqKa7r/73qAjYKsF2W8jV3QDDVdHcGtvKTWchFUGWJ5lNGbsH4XjAu+xO+ZpzktawKTk6ydq9UlXCfdq3DqQD2J384avQiyJI/MBFHE6PEnuQXeXoLHrOC8STcavB17M/AA1QsatPNo/tnLeby2hs7svgquE2krnDzFkyZ4LoxdHRbWXIh8idIRwJI6D2CKq7wuR0lEUdEDnwBjjzuyYF6Jf6hOpneTU8SmQoZmLMEV+thRqWYPzUo9YFc/SNRRwpIgQsO2geWO/Mlg== 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 GV1PR04MB10536.eurprd04.prod.outlook.com (2603:10a6:150:208::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.26; Mon, 30 Sep 2024 05:29:27 +0000 Received: from AM7PR04MB7046.eurprd04.prod.outlook.com ([fe80::d1ce:ea15:6648:6f90]) by AM7PR04MB7046.eurprd04.prod.outlook.com ([fe80::d1ce:ea15:6648:6f90%4]) with mapi id 15.20.8005.024; Mon, 30 Sep 2024 05:29:27 +0000 From: Liu Ying To: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, 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, maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com, simona@ffwll.ch, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, catalin.marinas@arm.com, will@kernel.org, quic_bjorande@quicinc.com, geert+renesas@glider.be, dmitry.baryshkov@linaro.org, arnd@arndb.de, nfraprado@collabora.com, o.rempel@pengutronix.de, y.moog@phytec.de Subject: [PATCH 4/8] drm/bridge: fsl-ldb: Use clk_round_rate() to validate "ldb" clock rate Date: Mon, 30 Sep 2024 13:28:59 +0800 Message-Id: <20240930052903.168881-5-victor.liu@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240930052903.168881-1-victor.liu@nxp.com> References: <20240930052903.168881-1-victor.liu@nxp.com> X-ClientProxiedBy: SI2PR06CA0015.apcprd06.prod.outlook.com (2603:1096:4:186::7) To AM7PR04MB7046.eurprd04.prod.outlook.com (2603:10a6:20b:113::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM7PR04MB7046:EE_|GV1PR04MB10536:EE_ X-MS-Office365-Filtering-Correlation-Id: d3b65d07-1b42-49c8-3732-08dce110da04 X-LD-Processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|52116014|7416014|376014|38350700014; X-Microsoft-Antispam-Message-Info: zQxLsW+h7SYZR/xYzy8v27XPmcbnmH9KbV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2h3pHvUPTqW8s5JNio+EBOymDHFKlRrZDxXRcYCiELDFRPUIr03Dg3ml92PoA8X2G5iIx6ReoDSrDU8/d0gja7s/SyWPY2rY9jgIhynl0h83ulI9V5PHvrJ2IIRnw8T7rDuv4BKIYGhWza8r2N7UCc+liP50C1gKuzp2lEGEtO4KEBEG3NAhBwwM8hjlYiwQgNMKRTT+QNHb0hSxLz+QP5KenTFNLpaH4AR8/gvro+j2AajZLf5TyQKu5WZr7PgjZE67FCfV3RTdiRm5d1iH/9tZJJZFzA/uz7b4nKWT/Dcr6ck73xdMu76x+9ZY3w== 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:(13230040)(366016)(1800799024)(52116014)(7416014)(376014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +1o8AakIeMmKB2N8hkOi1nbobbQ4c+Uv40jZGNooOIO8uhOgLQJ9m6wsl9Oob60rY8jrTtg/V8jJ/+pBsBrTI6ukPTYW3/GTjkVoCUMQv4wU0FcUu6R+YAKYy0WBqoS1yGXItJxReUp/cWqgUIP0H09rDRS4p+eXutrwLKnKEe69a3c++vi4lL22QOtH9E4n6ukS4d6Iie6OnH580bLb0lKNgBBXXrNaX5SvPeOlUBsG/MUrGBK6wzEgPUMMvAXaeQet8fqobbQxg8K6dEHq0FaMAOmAzBhJkP517765MoCdVlqVXUXhM5Uz8MDFlJeo0teYSLInK12qA4hnLlNzQbuJYwMGOGbSw42Ie5xuQW7hiPCVWlbPaBWp4VNjMNoNBaBn3ugTREpKysb8GmEnOtMlgDb2u9qbuMkyPhkzY0p32TGApwFbFpYAZWvUrCT9gvk4JwYU+fDvSTkxa7o2jP/b+j8pV9yNPulnFKO2fP4zqsHVmLBtEwboBRm9VHn3upM9kY/BdFU3k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nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d3b65d07-1b42-49c8-3732-08dce110da04 X-MS-Exchange-CrossTenant-AuthSource: AM7PR04MB7046.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2024 05:29:27.5818 (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: 5BfrBRs845fs/jtkbnCjVJ/GWnNEE3SmCJJmkhk4gNCFQB71qsD5hVAwF98FXTPy+aYd+nRWkE+oJ7YEihgF8g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR04MB10536 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240929_222931_410937_E2386646 X-CRM114-Status: GOOD ( 17.88 ) 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 Multiple display modes could be read from a display device's EDID. Use clk_round_rate() to validate the "ldb" clock rate for each mode in drm_bridge_funcs::mode_valid() to filter unsupported modes out. Also, if the "ldb" clock and the pixel clock are sibling in clock tree, use clk_round_rate() to validate the pixel clock rate against the "ldb" clock. This is not done in display controller driver because drm_crtc_helper_funcs::mode_valid() may not decide to do the validation or not if multiple encoders are connected to the CRTC, e.g., i.MX93 LCDIF may connect with MIPI DSI controller, LDB and parallel display output simultaneously. Signed-off-by: Liu Ying --- drivers/gpu/drm/bridge/fsl-ldb.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/gpu/drm/bridge/fsl-ldb.c b/drivers/gpu/drm/bridge/fsl-ldb.c index b559f3e0bef6..ee8471c86617 100644 --- a/drivers/gpu/drm/bridge/fsl-ldb.c +++ b/drivers/gpu/drm/bridge/fsl-ldb.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -64,6 +65,7 @@ struct fsl_ldb_devdata { u32 lvds_ctrl; bool lvds_en_bit; bool single_ctrl_reg; + bool ldb_clk_pixel_clk_sibling; }; static const struct fsl_ldb_devdata fsl_ldb_devdata[] = { @@ -74,11 +76,13 @@ static const struct fsl_ldb_devdata fsl_ldb_devdata[] = { [IMX8MP_LDB] = { .ldb_ctrl = 0x5c, .lvds_ctrl = 0x128, + .ldb_clk_pixel_clk_sibling = true, }, [IMX93_LDB] = { .ldb_ctrl = 0x20, .lvds_ctrl = 0x24, .lvds_en_bit = true, + .ldb_clk_pixel_clk_sibling = true, }, }; @@ -269,11 +273,29 @@ fsl_ldb_mode_valid(struct drm_bridge *bridge, const struct drm_display_info *info, const struct drm_display_mode *mode) { + unsigned long link_freq, pclk_rate, rounded_pclk_rate; struct fsl_ldb *fsl_ldb = to_fsl_ldb(bridge); if (mode->clock > (fsl_ldb_is_dual(fsl_ldb) ? 160000 : 80000)) return MODE_CLOCK_HIGH; + /* Validate "ldb" clock rate. */ + link_freq = fsl_ldb_link_frequency(fsl_ldb, mode->clock); + if (link_freq != clk_round_rate(fsl_ldb->clk, link_freq)) + return MODE_NOCLOCK; + + /* + * Use "ldb" clock to validate pixel clock rate, + * if the two clocks are sibling. + */ + if (fsl_ldb->devdata->ldb_clk_pixel_clk_sibling) { + pclk_rate = mode->clock * HZ_PER_KHZ; + + rounded_pclk_rate = clk_round_rate(fsl_ldb->clk, pclk_rate); + if (rounded_pclk_rate != pclk_rate) + return MODE_NOCLOCK; + } + return MODE_OK; }