From patchwork Fri Apr 8 10:32:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sandor Yu X-Patchwork-Id: 12806399 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 2B062C433EF for ; Fri, 8 Apr 2022 10:33:11 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3968410F14D; Fri, 8 Apr 2022 10:33:10 +0000 (UTC) Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80085.outbound.protection.outlook.com [40.107.8.85]) by gabe.freedesktop.org (Postfix) with ESMTPS id B216810F14E for ; Fri, 8 Apr 2022 10:33:08 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dKB7BDJgTk9la2eELYxVOcBCDHDc6ETZXtkG8xe2zBc/5NhTa1KtHGMJL6Fa+QLCH8E33Eiv/qH6YszaMr/KN97Em+ZvXM+k8vtgCo0XmYaokQx7aTxhySAAnP5AnOoIAavVXdzraSKtFLlcCqVpjXoQNB2GW5WkXxtx7Q8sIhv/lF0ON0frJZCxfm93pscX26+xvp0PYVX95vSG0vaKeh47yGsY3r9tvPg/HOdKIq7e9UGGqAxmu9HpzVyEvWd31MAZC7FF9FLM6kwAXN7jv4U75GkI5sMsJ7rM3BM02duQRFlA0oRD7UmdCM735usxhJkrbG4R56JuZ/8RyrV7nA== 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=e/UinYkAx6YLN/H678GMQTXmItd+HI/0hnc5JsCgZSA=; b=j0VWrEmjVDuk6sosemt7YCwcAQIJR7id9zrdmxSYh9eUvakr0pcdBM9l6xHQZaD5Els1h5Kg1HADXeRcsObE0T3TIxwn9AXHSLIERj0qCUiEDEzZMsNpozthd08VuBqMpG3qjOFjbPJN0tIyZN6GNOTNDV2RFtgITPiyoPh/0Q0RREWc6BbXxs+706W2l3umYtC/PCaWNAnnbu/5jinuTKIOA2R8doFJ4kZXXou/Qa+ZLtvW5JCiSqzKT9mtyYIIH5xh2HUtceLL/5D0pSnhb7hNZeYmEkEQpEQHWJCHysDyhZggUrZL56qvTjiPpyEP55mWP6HcsPsRluaeiJCc0w== 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=e/UinYkAx6YLN/H678GMQTXmItd+HI/0hnc5JsCgZSA=; b=H7d4kl+yQupeLNxTiN62UlZJcV431QOBUCxIHAlacr+u63qf0N6P29SzlbA49OnPZwCCrG1PryQ3KYjAeepkyd5kUabWjh8o1uz5YE8nhVj+CIiJxdd4y5kFaSDE6NXHr/zvTkAs8X+0wcCDWE6a8bXla3RlGhkgM9943Nvq3eI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DB7PR04MB5450.eurprd04.prod.outlook.com (2603:10a6:10:86::11) by VI1PR0402MB3405.eurprd04.prod.outlook.com (2603:10a6:803:3::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5144.22; Fri, 8 Apr 2022 10:33:06 +0000 Received: from DB7PR04MB5450.eurprd04.prod.outlook.com ([fe80::7997:2892:d230:2430]) by DB7PR04MB5450.eurprd04.prod.outlook.com ([fe80::7997:2892:d230:2430%7]) with mapi id 15.20.5144.025; Fri, 8 Apr 2022 10:33:05 +0000 From: Sandor Yu To: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, andrzej.hajda@intel.com, narmstrong@baylibre.com, robert.foss@linaro.org, Laurent.pinchart@ideasonboard.com, jonas@kwiboo.se, jernej.skrabec@gmail.com, hverkuil-cisco@xs4all.nl Subject: [PATCH v2 1/5] drm: bridge: dw_hdmi: cec: Add cec suspend/resume function Date: Fri, 8 Apr 2022 18:32:24 +0800 Message-Id: <45739041a743cd435415ca53264678e57a653147.1649412256.git.Sandor.yu@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: X-ClientProxiedBy: SGXP274CA0017.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b8::29) To DB7PR04MB5450.eurprd04.prod.outlook.com (2603:10a6:10:86::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 18941857-4ec3-4330-abc2-08da194b2ab3 X-MS-TrafficTypeDiagnostic: VI1PR0402MB3405:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7PpLvTSw2XNeTv80dFNp8x4hQ1yxcUX09phvDZKJbWFzbPJIXWXmnH59mz31uRUDShNu/tKB8i329jVbgmid4JrO+TFOU4AUACwR7TsZxKfFZ9aquJhAKaW3OV7vccRvKD2zYuJatw7Sx65OKVRDm/VRZqdU7qNfCvzQuTSiyb6xdCsfGm02qJWmsK+Vl5zT6aWNAg/HWtPu0eM6IJGY8Eno5MOiQHQHOLpR0sqTlvbWzf01qauhyFAy0v0lVZggSAas/oVJCyRurn8rIBKdHiaKEIaHRV8jQgrhIw2+w7jykGOzJRJ3yC4oBXsQsCoz39SOycvBJQyhHNDxOFK9+po52RQqIUmzUEbAL9sywJYRggleXPNAlTbg6fiqRNosmaVwMBp1Dn1kFy2C80YigSkR1C9Cs9b8+ir4er+ftr4tX66Zzugnp13nGuZO9dgoiFzCh0OV7UC+zdW79DUGmGi2MZv2GJ8qvpHu3186pPlNy7vaeG8mVsLptLV57IOXMqCNS7PzIOtY0A9xuavEuQq2RSbujGsLkexLirZh9rOZ+50zhrMzoJ0aLyuvPtrI9jtsmi8sSHqsBx3oBDsWhfXRqZx9xQayuEyJf6DekNg3kG1uikXQebWQeMtOePMV6FhqDVxoIwR7WWq0BINGjN/f2EyYozYFZ3s/oF22KndjglksBPiGYO/L4MXjDN56oVnicByCS0hGdHnE0+OJMA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB7PR04MB5450.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(8936002)(2616005)(52116002)(66476007)(15650500001)(6666004)(83380400001)(8676002)(86362001)(508600001)(66556008)(66946007)(38350700002)(4326008)(7416002)(2906002)(186003)(316002)(5660300002)(6506007)(26005)(36756003)(6512007)(38100700002)(6486002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: YeIUHj3/NB80GLYqCKsknM7ML3qfXHQ6a9kji9IqoXbXs6nxk1tAgigAbT6s1DSryu483n4Q5anYCvHRpTKb4fgnNs9jlS8WYudzMr5TOR0PUc3GKRJDRUO/jLgPckm7ISOfYuwSriQtTzc0oT4CO8Jm+LkHInB6/v1Xl4nwBCNqJ3x8At00Bt8EyOEKH5wRWc7vfrCLfCcV6iy/p/R5ESIpKfrbyAZzgPMGMzGdn3/mwkaK5eLGes+gBWFjukGT8na+pD9Dwsmo7nsMJK+3DS2kmASDS2eIUDSTi2jr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DvA52d7BbSHAs0/Y1x4lZ+bU8tvNzWXnGNgl3OAQhbUfnANKa3XoIF8SFWDyBp6Xj60fcKZa4ML4I3isgy5myw0a2wwa/gnbXmutOrDvZqbDxLDBTs6S1G7XCrXdlFgU9tWno1oXfoUHUzPv2QkGHJgDAFkTdbCCKBcx+hKVddk++NeRA1h6bZUQOtKPIl87AYU4iQ95kRhP2DDW6t5VJYm+AyM+D7DSI1NaGx8OxLHiX34hVgK7GhW5NUhpjcSG7HW3301sRzULqvHzM6K3YK2QNzBrZvJ2XrLSKizkVntoFGXZAhoUF53Kb6OCXf5Pr1xcRdC8ot9QFu3YePuNN47ROTukTBt8jZjKnEztDw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 18941857-4ec3-4330-abc2-08da194b2ab3 X-MS-Exchange-CrossTenant-AuthSource: DB7PR04MB5450.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Apr 2022 10:33:05.8037 (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: YlIm8ZGPdR+O4c0z3JOcNq+0FZLrLvkIk+sxdVMbuE09U1JrXuPaaOPAhAujtDaNu3MPZPuQ4OiWSQdUvjHHOw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3405 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sandor.yu@nxp.com, shengjiu.wang@nxp.com, cai.huoqing@linux.dev, maxime@cerno.tech Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" CEC interrupt status/mask and logical address registers will be reset when device enter suspend. It will cause cec fail to work after device resume. Add CEC suspend/resume functions, reinitialize logical address registers and restore interrupt status/mask registers after resume. Signed-off-by: Sandor Yu --- drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c index c8f44bcb298a..ab176401b727 100644 --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c @@ -62,6 +62,10 @@ struct dw_hdmi_cec { bool rx_done; struct cec_notifier *notify; int irq; + + u8 regs_polarity; + u8 regs_mask; + u8 regs_mute_stat0; }; static void dw_hdmi_write(struct dw_hdmi_cec *cec, u8 val, int offset) @@ -306,11 +310,44 @@ static int dw_hdmi_cec_remove(struct platform_device *pdev) return 0; } +static int __maybe_unused dw_hdmi_cec_resume(struct device *dev) +{ + struct dw_hdmi_cec *cec = dev_get_drvdata(dev); + + /* Restore logical address */ + dw_hdmi_write(cec, cec->addresses & 255, HDMI_CEC_ADDR_L); + dw_hdmi_write(cec, cec->addresses >> 8, HDMI_CEC_ADDR_H); + + /* Restore interrupt status/mask register */ + dw_hdmi_write(cec, cec->regs_polarity, HDMI_CEC_POLARITY); + dw_hdmi_write(cec, cec->regs_mask, HDMI_CEC_MASK); + dw_hdmi_write(cec, cec->regs_mute_stat0, HDMI_IH_MUTE_CEC_STAT0); + + return 0; +} + +static int __maybe_unused dw_hdmi_cec_suspend(struct device *dev) +{ + struct dw_hdmi_cec *cec = dev_get_drvdata(dev); + + /* store interrupt status/mask register */ + cec->regs_polarity = dw_hdmi_read(cec, HDMI_CEC_POLARITY); + cec->regs_mask = dw_hdmi_read(cec, HDMI_CEC_MASK); + cec->regs_mute_stat0 = dw_hdmi_read(cec, HDMI_IH_MUTE_CEC_STAT0); + + return 0; +} + +static const struct dev_pm_ops dw_hdmi_cec_pm = { + SET_SYSTEM_SLEEP_PM_OPS(dw_hdmi_cec_suspend, dw_hdmi_cec_resume) +}; + static struct platform_driver dw_hdmi_cec_driver = { .probe = dw_hdmi_cec_probe, .remove = dw_hdmi_cec_remove, .driver = { .name = "dw-hdmi-cec", + .pm = &dw_hdmi_cec_pm, }, }; module_platform_driver(dw_hdmi_cec_driver); From patchwork Fri Apr 8 10:32:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sandor Yu X-Patchwork-Id: 12806400 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 C329CC433FE for ; Fri, 8 Apr 2022 10:33:17 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B8EDC10EFB1; Fri, 8 Apr 2022 10:33:16 +0000 (UTC) Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80080.outbound.protection.outlook.com [40.107.8.80]) by gabe.freedesktop.org (Postfix) with ESMTPS id 789F010F14F for ; Fri, 8 Apr 2022 10:33:15 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Za00OkBNvD0z6i/50iubox2CxGlZrG8a6zPCpFLp/BR87OdfC9Oyw3p7NZ2Udn/HmkhrNU+JbVE8keLYnFdUqlIqdvPIVn22OxfRVQ/nEiW2nrsGHya/tX2Q1Xvi4TdjpQ0oTT47QLKViawWBm0D+voG6UaoYaUdCWPdbq2Yt7PYMrU7WIwJyLURUynLfj65HGVJd3Mul4qaixZvH9dVwH8oJ85mV4XDroH62mSZTdx03SPHvK3HWWN8GocY3ve6laT/ow1d+RRPLUwtDry4vUMQtWfAWjTraGk5g6y0X2W50qLdbg+tRn7cW0XwRBiltgkz0XzwDWGZNpVTFLwxKw== 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=6ESsHq+HwjbkpRagROK6lpXlHO1JmzQs8/tplC/pzhc=; b=RZRsELc1pX6lYi9y/EI2PjvZ+0+dENqkSnXxpzjtfgZflcqWI2mF6mZi5494Mnhu4OL6TluwFRSSWq2SWvdZ1KQMSjPtV093j4qhIAv2rPl+tRZOsR/b0m7PqWlTrTslucLbP58VinrY9+OTdN1ypqJPCo3llEn/ZBA6qo3sZ19BDpoew7oLwd4nAjafeK/c5YVPOR9U79QKa0sMg2fqx0JBIviTodIylwIKOxXeG8E6i79VxqdHe07r7TM8f3a1++mLhIJzekhlO3Qnyt3yMRXcHT+/BEVB+oJExzV6ylwJXp30QC62uW6vJcvJWkLOq0KmHgSBNExo/MBWx7e6IQ== 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=6ESsHq+HwjbkpRagROK6lpXlHO1JmzQs8/tplC/pzhc=; b=MJDbTaAbf6yhWPXNERqVARE60UGDeHoNhOAdRbZLIly+GYYe1/LqUPlkAAefA6Hfvk784bBaMs7v6bpe/RHuBTWatjV34FX9skD9wiz9yAOObaAH3htF2y/lNiqnoLh5WJagVsZ1y+bBZ/7uKIJeSo2dplzleS75ZSywQr5ZKA8= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DB7PR04MB5450.eurprd04.prod.outlook.com (2603:10a6:10:86::11) by VI1PR0402MB3405.eurprd04.prod.outlook.com (2603:10a6:803:3::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5144.22; Fri, 8 Apr 2022 10:33:10 +0000 Received: from DB7PR04MB5450.eurprd04.prod.outlook.com ([fe80::7997:2892:d230:2430]) by DB7PR04MB5450.eurprd04.prod.outlook.com ([fe80::7997:2892:d230:2430%7]) with mapi id 15.20.5144.025; Fri, 8 Apr 2022 10:33:10 +0000 From: Sandor Yu To: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, andrzej.hajda@intel.com, narmstrong@baylibre.com, robert.foss@linaro.org, Laurent.pinchart@ideasonboard.com, jonas@kwiboo.se, jernej.skrabec@gmail.com, hverkuil-cisco@xs4all.nl Subject: [PATCH v2 2/5] drm: bridge: dw_hdmi: default enable workaround to clear the overflow Date: Fri, 8 Apr 2022 18:32:25 +0800 Message-Id: <39592fee39610c544058e6b8f9af4b4ea8dc4cdc.1649412256.git.Sandor.yu@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: X-ClientProxiedBy: SGXP274CA0017.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b8::29) To DB7PR04MB5450.eurprd04.prod.outlook.com (2603:10a6:10:86::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: da5d15d0-f462-4d42-0bce-08da194b2d48 X-MS-TrafficTypeDiagnostic: VI1PR0402MB3405:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dkhEhFZ+xS6J09gYyLOwX8iR1J3TTq/GMtjOD6RgXdR/46g7NCUx7D3JYEkcOILe6y8+IihEY5u4ex2WcdeV3cGGlpO8rEg3JDfSl7vcOHo8Ft3CzPMtQS9BNtNaXr3V4mxFjpJt1aHQCpu4DDs0+OnHIQkX7ZgiU/Uhn9V9y7UhgbnRYN9DJKZysYlTWJsEKf32benXv0xA1BdOWOg4qrmWlyT/coSszHEaccSWQg7RmZGNl3SQzepvZOtdO16COEHbsG6LOSqgLGyZrNWM/pKwroZqfZ4z9lR38owNczDS/0kc//nkL7QQeqDIihilfIxqFEKY2qIw+SAGAxHA01CQ6QnLwle1tAKNPMVW3Ag6AtaCAWDAbWAh9/0CoxURWgQ+f4giHDofGJHrjfmDJAaoMoCV2oa4QRQQIaB8Q/XgGoh4YrpLm8T5MGPymlYMHjKxoy26fEVKDoEwuLSytn58F27YjdJSLdtEpivB4HfCSxTApidpmGu8fhx2Lj2yRuZPlb4lXJn3oTvgYsIr9px3FcLrTTFGY38MZxbOqIfoylQYb0olfoFcn920JPv9VjtLL+b37RRqGFoUWiWZ1ev8xexgG7h1ISj9UVetRE4P/wzfXax5FLSUm4hTFCb6hM9nnxF56/RGXoiSAaJM+A5tsHDHfbT83iytW8XfetQVXN8RR1NfhdsiW+Db6bsQE0h5DdoZ1ax1Y/ver3+0uQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB7PR04MB5450.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(8936002)(2616005)(52116002)(66476007)(6666004)(83380400001)(8676002)(86362001)(508600001)(66556008)(66946007)(38350700002)(4326008)(7416002)(2906002)(186003)(316002)(5660300002)(6506007)(26005)(36756003)(6512007)(38100700002)(6486002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: BIaF6a89edY6OXfSl4qKLqEqKOTW2DD+zTiKbJX9CDiW69y96wYPc9lVE7EI8t1yoV0ih0SmPFyLs6dSY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McjrTXFqnDBxqPQ96yIOrLJjqhUDt+Qxvk4xAQkbwDPKxsNLzkFTYbQL6bYfjp8zOSUWXLq0qMKo15x8X5+eL/2xkzYRX8yQ58HNN1CReD88NjPNqEKyjPmgk+Edm9Q+oXp4ERaQRmMkKEIDanmUnFrzVbftCmb2X+BwKTcntdlb3q/PxUF9FRxRCI3sDjixe4BUFMy/Yznr2MykPOxO7tZ8xAj4eLjxhPoeBaERZhQx1TgfKkmaUU5ZyrwzlWcsYaiIzGlRhXI3ZnuD5iQaHcpQC9phfODodC8+wFQba0YhCR/LMw+p1IDm/XH4EFBRLC2GhSFlR7al1AIl7KlH+x36jDmTwakUJ02cp/GMV1fz5ckSewvznP25NgvPQTnG2+IZSZxR/82r91ZbITYai73L+9w/FEHaMuOGW2RfZZA/Mta9KvxyYmH0GosbboqDHy3nfW1LlP2ZrJpDg7XRbw5c6LM6QFaMqJjCAOAeZrBuW4fPuVBxDFIcCLHQnMAefRFCPj6cQNPITdmmBQTlFT5TrE8Pu35UedHYAkgIp3r3KDBOFU2Y+4buLXNX3XwVaLhIP9trWrpM44/0hpdyQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: da5d15d0-f462-4d42-0bce-08da194b2d48 X-MS-Exchange-CrossTenant-AuthSource: DB7PR04MB5450.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Apr 2022 10:33:10.1784 (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: tHglaFb8Yu/+uzmh1p01YFcNY9GFdUhs8Cfq8Cc/HC2YaBAyGkomZuFVKCk8ftK5GfNB6yj8ztXlmJWjHs5T6w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3405 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sandor.yu@nxp.com, shengjiu.wang@nxp.com, cai.huoqing@linux.dev, maxime@cerno.tech Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" i.MX8MPlus (v2.13a) has verified need the workaround to clear the overflow with one iteration. Only i.MX6Q(v1.30a) need the workaround with 4 iterations, the others versions later than v1.3a have been identified as needing the workaround with a single iteration. Default enable the workaround with one iteration for all versions later than v1.30a. Signed-off-by: Sandor Yu Acked-by: Neil Armstrong --- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c index 4befc104d220..02d8f7e08814 100644 --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c @@ -2086,30 +2086,21 @@ static void dw_hdmi_clear_overflow(struct dw_hdmi *hdmi) * then write one of the FC registers several times. * * The number of iterations matters and depends on the HDMI TX revision - * (and possibly on the platform). So far i.MX6Q (v1.30a), i.MX6DL - * (v1.31a) and multiple Allwinner SoCs (v1.32a) have been identified - * as needing the workaround, with 4 iterations for v1.30a and 1 - * iteration for others. - * The Amlogic Meson GX SoCs (v2.01a) have been identified as needing - * the workaround with a single iteration. - * The Rockchip RK3288 SoC (v2.00a) and RK3328/RK3399 SoCs (v2.11a) have - * been identified as needing the workaround with a single iteration. + * (and possibly on the platform). + * 4 iterations for i.MX6Q(v1.30a) and 1 iteration for others. + * i.MX6DL (v1.31a), Allwinner SoCs (v1.32a), Rockchip RK3288 SoC (v2.00a), + * Amlogic Meson GX SoCs (v2.01a), RK3328/RK3399 SoCs (v2.11a) + * and i.MX8MPlus (v2.13a) have been identified as needing the workaround + * with a single iteration. */ switch (hdmi->version) { case 0x130a: count = 4; break; - case 0x131a: - case 0x132a: - case 0x200a: - case 0x201a: - case 0x211a: - case 0x212a: + default: count = 1; break; - default: - return; } /* TMDS software reset */ From patchwork Fri Apr 8 10:32:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sandor Yu X-Patchwork-Id: 12806401 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 B6938C433EF for ; Fri, 8 Apr 2022 10:33:20 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 06A7B10E1A9; Fri, 8 Apr 2022 10:33:19 +0000 (UTC) Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80080.outbound.protection.outlook.com [40.107.8.80]) by gabe.freedesktop.org (Postfix) with ESMTPS id D0CFA10F14F for ; Fri, 8 Apr 2022 10:33:15 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=J5fSkip+//FqmNiZaEZHQ6RMZyfSi2diTCk6MrS6Ao83TSuKQ1n/NqilSJxCqis10MEuQv/SmD2p8hXDqnJItlMDTy6uTgyibhqMRHRwvgdgU2YwMfftAyI7sS4k121/ycK7IeWBi7YSGJMNKO1hV6wNPXeVqLYC6x4TakdrkKSNPC0XjKt0hMp1R0Pg4Scbb4wkeiynpcwOBMriuZO86LdHEBITfiIbFDJKmAWoyZFulh0w9zXrR9QAm7H5QrJfpRIfUb35tJP7FqRTk7ujDkMapc+kpF8DAvyJUaCa54Co8ztzB/Furf1B3FeMDeiDvwYubqoTnQwgNqjTEQlXKA== 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=THrNQKpsWNdMxuYojeIsC5d7vKf1mcZHEIGlOy6s2W8=; b=H1NugxnIbArzuUQaKAdMMdgfk9HASuQh3EmKpeJxk1+5j6ruLoDlq2xP8vcwQUZXhvqbCXFoZNGDAUYrY00cZ7gsSnStnWE7GbACse4cL/s74e37IhFu9n0QvC+i8jPgciJJ16s+Rra1DfVN5PDFkdsjAYt/WM7FWhVP4QUkJhtMjKWNfbbrP9y7vGeCWKUuaMBkM1H+rcSgWPVMK3jeYC+QD4duKpsrd9MuWD5DmaWQ90UeomYuXJNx3SyT1kiorvXkoCG8vBYjqyl6YjLVFclg8t9rVxzOAgKgNFzJ/v2zeQamX1LogMvRBL0WL0W5QsOxYS8JwUxHvatjIbYMRw== 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=THrNQKpsWNdMxuYojeIsC5d7vKf1mcZHEIGlOy6s2W8=; b=mgoqElixFE10nA9dQUVTS5FULmuyuRHZ/I4/qThEQhdLGtO62UGkpH3KNOV+IPL+a1zEn0vbj2I68RlOSkBXLNmqddLW19+PeEMWUC2ka5gorZStrW1DufpMKil5ygMjTD54VKJcoLKSAXJvF5zXMKFfRgytfgyV1w4OTMxd0gU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DB7PR04MB5450.eurprd04.prod.outlook.com (2603:10a6:10:86::11) by VI1PR0402MB3405.eurprd04.prod.outlook.com (2603:10a6:803:3::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5144.22; Fri, 8 Apr 2022 10:33:14 +0000 Received: from DB7PR04MB5450.eurprd04.prod.outlook.com ([fe80::7997:2892:d230:2430]) by DB7PR04MB5450.eurprd04.prod.outlook.com ([fe80::7997:2892:d230:2430%7]) with mapi id 15.20.5144.025; Fri, 8 Apr 2022 10:33:14 +0000 From: Sandor Yu To: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, andrzej.hajda@intel.com, narmstrong@baylibre.com, robert.foss@linaro.org, Laurent.pinchart@ideasonboard.com, jonas@kwiboo.se, jernej.skrabec@gmail.com, hverkuil-cisco@xs4all.nl Subject: [PATCH v2 3/5] drm: bridge: dw_hdmi: Enable GCP only for Deep Color Date: Fri, 8 Apr 2022 18:32:26 +0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: X-ClientProxiedBy: SGXP274CA0017.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b8::29) To DB7PR04MB5450.eurprd04.prod.outlook.com (2603:10a6:10:86::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ebeea71f-0afe-4f5b-92c4-08da194b2fe3 X-MS-TrafficTypeDiagnostic: VI1PR0402MB3405:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pwBaMCRpcWeGPPgyipSPtBONNAjDCEzGAQojEpUF1ZPdvNziU2cS798XSNu5GlYYK+PMaES1CZga0vy1ncDPGa18iAaH6SKocSfqlPgA3Wv3v5A+AgVdgq3nRe2t81+auRo1cgaJxyuAzp6m4Ifdj4Z3zna0jkrw9S1GZ2Qso6PKIJkshH7U6RI2DOApbHSrHq7sRwMa5sCCPWUtpElyFR/JlArKkOO6qwLp10JWVOjvKVCphFLQiElLOf8AN0TAp7/Js9tX6J1QYvV++7Sx1xIqX6gdzCJjOvUYA8eGoM5eeMq4nnQJWMI9laWytAtUXz9NLeBacQbCUDw8DnQcYV6PVoAfk1uxaiKMlKHu4lJLjrmjKyaeApb1uscz2W3mliUH0glwEdw70VmN1kyXiGFpf9LPO87GTjQ+WRSzN2A0QKJczaPEL0BLhZP0Q01VcIAdrBXerqh1D6e2pSXAITFVDqS4PkZk3zPdO0BBbBF0OVYUvCL/0KBT0+9lPbksJEHCtXJLzUDZdbdFBDub6oZ7iz3rgGQretlaMGK02a8WxFen5lZr5fRALuN+fl/7L4+tkEbC7xrqrfthelcMlQtaz1oZ+xbfo3Vv29oROf/BUK3OVYJEvwr4L8nBicdSIePYbOdI6Fxkm27487T0zwueduRHvIlOCrg5SkIFZF6CVuPUx4Bapcb7fig7FCnaea7oid37ZGyPzIAMSZ0XYw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB7PR04MB5450.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(8936002)(2616005)(52116002)(66476007)(6666004)(8676002)(86362001)(508600001)(66556008)(66946007)(38350700002)(4326008)(7416002)(2906002)(186003)(316002)(5660300002)(6506007)(26005)(36756003)(6512007)(38100700002)(6486002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ezpyk5Eu2k3iU6sBJSf/pXyKhQQ2QsmeOwKuKFiOYkEhKS/PePhQ/D1iEjBS2ko4R2ZONrDplB4yQXu0y6RTtQHc15KvKLu765LtEmciLvyCZjQOw2QeR+hbG9ZbygHdW4fyl/dHKwkfK15f8TR8ALbzPm31WEK6S5dVD9SxP/7jeFBpI4FnjcVUCE+YJirKPikd2E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vDfJR/3NBIJmkIeSHqlejKAdeHAiGCvK52frGRfvWbKZM4WqbmZ/K8ZOvOuumBC3F8ty3BOy71+DHTlUV1dphKKa5srljMPpvNHle6mBBgVfSex0SUSImpKSCMezIRGIT63NF2SbAvyH7qIiU2Igjk/HUtpak1zMJv9DpQ1ewSTbTeV6rvMjpuivUwNSJ2Of+lHobMyZ3FIXTJu5Bg7AyHfPmuMZhubhlwkiLFovTgsvOOBlMCQ/2jeBCGhhlSryMHS7w0HPFAMFBRb3bLBTI66p+tq8HX4IZWscgKmuGcIXiPVB09A/k4hBmg7GqplSJhgRlv+S9sr8SgXZcZzUzLI46M9cffsi8c2CTSNToP0038bSH4ZsvVLODZWyjGXy0+v/h3C08JWQxHvxcucxf9VcSGJHIuzx3TrOzHqd/EpG4nJCYzP/2a13G7F3mle8Ha8b/fcv3QexoMvXhjZw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ebeea71f-0afe-4f5b-92c4-08da194b2fe3 X-MS-Exchange-CrossTenant-AuthSource: DB7PR04MB5450.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Apr 2022 10:33:14.4906 (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: zdjA4GR6/jD/CBe90U5YdbnM1jjA8Z0FNlo8yMdsW2E+coCWwHZP4QSwioHCmjNJHNW5qT1RlmQCdGeTkAUcOg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3405 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sandor.yu@nxp.com, shengjiu.wang@nxp.com, cai.huoqing@linux.dev, maxime@cerno.tech Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" HDMI1.4b specification section 6.5.3: Source shall only send GCPs with non-zero CD to sinks that indicate support for Deep Color. DW HDMI GCP default enabled, clear gpc_auto bit for 24-bit color depth. Signed-off-by: Sandor Yu --- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c index 02d8f7e08814..5a7ec066e37a 100644 --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c @@ -1108,6 +1108,8 @@ static void hdmi_video_packetize(struct dw_hdmi *hdmi) unsigned int output_select = HDMI_VP_CONF_OUTPUT_SELECTOR_PP; struct hdmi_data_info *hdmi_data = &hdmi->hdmi_data; u8 val, vp_conf; + u8 clear_gcp_auto = 0; + if (hdmi_bus_fmt_is_rgb(hdmi->hdmi_data.enc_out_bus_format) || hdmi_bus_fmt_is_yuv444(hdmi->hdmi_data.enc_out_bus_format) || @@ -1117,6 +1119,7 @@ static void hdmi_video_packetize(struct dw_hdmi *hdmi) case 8: color_depth = 4; output_select = HDMI_VP_CONF_OUTPUT_SELECTOR_BYPASS; + clear_gcp_auto = 1; break; case 10: color_depth = 5; @@ -1136,6 +1139,7 @@ static void hdmi_video_packetize(struct dw_hdmi *hdmi) case 0: case 8: remap_size = HDMI_VP_REMAP_YCC422_16bit; + clear_gcp_auto = 1; break; case 10: remap_size = HDMI_VP_REMAP_YCC422_20bit; @@ -1160,6 +1164,14 @@ static void hdmi_video_packetize(struct dw_hdmi *hdmi) HDMI_VP_PR_CD_DESIRED_PR_FACTOR_MASK); hdmi_writeb(hdmi, val, HDMI_VP_PR_CD); + val = hdmi_readb(hdmi, HDMI_FC_DATAUTO3); + if (clear_gcp_auto == 1) + /* disable Auto GCP when 24-bit color */ + val &= ~0x4; + else + val |= 0x4; + hdmi_writeb(hdmi, val, HDMI_FC_DATAUTO3); + hdmi_modb(hdmi, HDMI_VP_STUFF_PR_STUFFING_STUFFING_MODE, HDMI_VP_STUFF_PR_STUFFING_MASK, HDMI_VP_STUFF); From patchwork Fri Apr 8 10:32:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sandor Yu X-Patchwork-Id: 12806412 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 02BFAC433F5 for ; Fri, 8 Apr 2022 10:33:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E3A3B10E288; Fri, 8 Apr 2022 10:33:22 +0000 (UTC) Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80050.outbound.protection.outlook.com [40.107.8.50]) by gabe.freedesktop.org (Postfix) with ESMTPS id 87B2610E393 for ; Fri, 8 Apr 2022 10:33:21 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SHVIU7KyvunlV99673Z4Nr/1gKDCW2fms4e0Mu7F1gItUZIqPpy4Kck2DdzQR3jsGevptw+y7SfbGc3GXYDZIm3VbcCw/YXrE7CfS0sYEhQTk1HVL2xMsKlu+mCBRG9fL3Chn1LiHxDBY39nSBByFcZHq0kcSGzCcfO9RI323vG7N4qV5tXtp0kSnPeJsXSaUMVsg3Zg21SWFQBHnB9tt6kn9uMgOo0J0vtFc57+YHlrjZFDpgOdI9qj7pEUuR0C+fj9ryYroMC7zRUDUh54v0PclUPs+AhaYgS+j1Q84KFRj1dKCif6F87sq2Y97RTrqovEwHgGjIkl1y6a0OUMmw== 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=Mou73KzW0uXaX/nUX4AVL21HLgyJpCoTh7NY5JE2aww=; b=TtsJv3relzYYIESASGefl/LUWCE0gPHAgCYdde3gcAFST9jkq4UfmpgyPiGSNkHCvL71rUZmeSToHEYIADob+J742U68gb0ZF4CpsB/r0o3sDkjVYZJ+L29DbseukoV1gyswnTPkbtCiSzkO9OzMqE/Spi0u47G5T3ovasvzwfvBX49FzJpEFknwclCD8SF6r43LSdm9aAKuwPhY8V0lmD/yDOlL4JmAPEHluLRBc6C10nFvF0SoxcJVegIns1Anf5OHX2lYenY4JrALunxqSrxrCfwZSgC99PhKdzizN+GxHCoFJbNlp3FYeF0lulpwbY038oDdb/qyDtQbudAwjg== 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=Mou73KzW0uXaX/nUX4AVL21HLgyJpCoTh7NY5JE2aww=; b=LDtt6XrNrWrhUWmjwrwlZXUv+bqkOy11X0EqVRQZD51Bk1kbpRWk4sTXSGHPSriTUyr3xU9lxyEQvdQ0QAJnXe1REYIoiCYv2bnJ7YklJ5h7sguLTGyGKDMkp6V61i7L3lRvRKy9aQxxPlUb5ERrx85NPY0aumP9X9mNCEJ+EJc= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DB7PR04MB5450.eurprd04.prod.outlook.com (2603:10a6:10:86::11) by VI1PR0402MB3405.eurprd04.prod.outlook.com (2603:10a6:803:3::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5144.22; Fri, 8 Apr 2022 10:33:18 +0000 Received: from DB7PR04MB5450.eurprd04.prod.outlook.com ([fe80::7997:2892:d230:2430]) by DB7PR04MB5450.eurprd04.prod.outlook.com ([fe80::7997:2892:d230:2430%7]) with mapi id 15.20.5144.025; Fri, 8 Apr 2022 10:33:18 +0000 From: Sandor Yu To: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, andrzej.hajda@intel.com, narmstrong@baylibre.com, robert.foss@linaro.org, Laurent.pinchart@ideasonboard.com, jonas@kwiboo.se, jernej.skrabec@gmail.com, hverkuil-cisco@xs4all.nl Subject: [PATCH v2 4/5] drm: bridge: dw_hdmi: add reset function for PHY GEN1 Date: Fri, 8 Apr 2022 18:32:27 +0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: X-ClientProxiedBy: SGXP274CA0017.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b8::29) To DB7PR04MB5450.eurprd04.prod.outlook.com (2603:10a6:10:86::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b92eda1d-1342-4852-2e33-08da194b3273 X-MS-TrafficTypeDiagnostic: VI1PR0402MB3405:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VRiJ46s7G9tMMRzJBFLuahvorIiK/9ywLP8U5qwbmb1yk8F9hkNIIFSXtYMkFMUGAO4GXZsPkMCUtagS1OGexzsK/rTbv53t6NjNxN79Z8e2oZprVSKv2o30PGS7ouPNGmsz1pN/K63i1Os7EVMszJTiWam/Fqbh8QPlNrySD0NH9Us+l7Ky7WOkErdtU1lYaA7gKecVos/iMljHFuagh0jRsdgwZ8mN/4yUzYB9I5YVkA1J1cVXV8PgV5zyDEV8kxu4HzymfVAlnjy07n3bDBIu6qnm+YC73e6n8fkMZlaV0Bdy4pYr7MQV/Gim3+laja93/qhdXrbiSnHB6EJevPy8S1qhJj9L8M70URcV1EoOkM1FteQJ+cpoy6JZcvxDU1V8lHto5O1SlsulXkN+4W/ZwG6hsjbBXA4zSPWaWj8bZAGSUYRsBmnG5IEEo4VCzzCs3/EtTcOUOkmT/JkQ5LlE7Yy2nuOCZVIiPL995rs7dsv/5JCB5C9g0FrvkWvDI6E3LH2F1h9lGmOmYZb2+LZXZCyF5H4phwI5KdNAuv5uoT8VundRz8rW4vu7H6Ee5pwFxhcuaDmJTejtGKSDaoQQBubJT9HfGNxsU6CWC4o+GqIKDnQk2r10BLLTESIHaWxdpiKkyHE+vKHDPqxLrXycpEKxKGIHcWQqSUtHz3rWlYcTqinRrRk5f8PP2lHznsqmFgejeCa+shTntcWsSw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB7PR04MB5450.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(8936002)(2616005)(52116002)(66476007)(6666004)(83380400001)(8676002)(86362001)(508600001)(66556008)(66946007)(38350700002)(4326008)(7416002)(2906002)(186003)(316002)(5660300002)(6506007)(26005)(36756003)(6512007)(38100700002)(6486002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: jfdY9Hlz/iPk7bCtu84/h/LrxeUMU47NKbeZsHVEzbMi4XsUO1VJGhT16CyKWg/x9gN8tfbb5Oci/MVuqFap9hGS0UScKRbaJZDWgfzIP6FcOhjBS5dyynw8lLV+yjiD6KIfBec+lrYTk8Eo0TvvXbxyIrn2DRlaczv2e1xz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3A5G+O8bR6oa0TFpnEOB8qBPAhHKF8Pa9j/ptw2TVvy/wgZxLZ016PlRJxk7KbhKAkE/X0jSkgHTN6ss3zzX5IejNNjUhRIAWYeWLUevwBZxVBibQPqp1uIVPZNpMId1tHSAY3tr2pSiCh/HK3BWSUb4sdtRCQK59Ag6T2QPdFg8iOAmsL+5qkFjeiqZpoM2h59Qd9K3T0ak/0POzhj3RDuIy30EJy2lR2X0DPRFJIbUxynUW56Y3x9+t4XdTu2efENcgh/sgwi9lxVUpRzIsIjgyw6RryfIhHxWocl86sJqmnxpfPMhvCc748VZkKOybyJLNiQN9G6kwLqnfw8APWRe3BybphitQl63WJXAvBxuiNrxK8RDNdw/gXOXC8H5w5W7E3mmcUAJf76QBcJKGCqvdtaRPyBdfIM1ZIqgnBfUOMSqL8YM7fvMunozBLwcF9St1RTgzzX8tCDYhyLkGurpbxPwlpfoI/NMoCEv8URFt0Y6PXAoqjA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b92eda1d-1342-4852-2e33-08da194b3273 X-MS-Exchange-CrossTenant-AuthSource: DB7PR04MB5450.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Apr 2022 10:33:18.7872 (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: ce7ulaSeq7hg1Dfjnahaq8pAr7SHoTp+sfXDEQ8mXFfaWxZBVrPjIVWoXiVws3nPETLvuv5pRrxdsP4vUnSFkg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3405 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sandor.yu@nxp.com, shengjiu.wang@nxp.com, cai.huoqing@linux.dev, maxime@cerno.tech Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" PHY reset register(MC_PHYRSTZ) active high reset control for PHY GEN2, and active low reset control for PHY GEN1. Rename function dw_hdmi_phy_reset to dw_hdmi_phy_gen2_reset. Add dw_hdmi_phy_gen1_reset function for PHY GEN1. Signed-off-by: Sandor Yu Reviewed-by: Neil Armstrong Acked-by: Jernej Skrabec --- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 14 +++++++++++--- drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c | 2 +- include/drm/bridge/dw_hdmi.h | 4 +++- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c index 5a7ec066e37a..13270d96e5be 100644 --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c @@ -1369,13 +1369,21 @@ static void dw_hdmi_phy_sel_interface_control(struct dw_hdmi *hdmi, u8 enable) HDMI_PHY_CONF0_SELDIPIF_MASK); } -void dw_hdmi_phy_reset(struct dw_hdmi *hdmi) +void dw_hdmi_phy_gen1_reset(struct dw_hdmi *hdmi) +{ + /* PHY reset. The reset signal is active low on Gen1 PHYs. */ + hdmi_writeb(hdmi, 0, HDMI_MC_PHYRSTZ); + hdmi_writeb(hdmi, HDMI_MC_PHYRSTZ_PHYRSTZ, HDMI_MC_PHYRSTZ); +} +EXPORT_SYMBOL_GPL(dw_hdmi_phy_gen1_reset); + +void dw_hdmi_phy_gen2_reset(struct dw_hdmi *hdmi) { /* PHY reset. The reset signal is active high on Gen2 PHYs. */ hdmi_writeb(hdmi, HDMI_MC_PHYRSTZ_PHYRSTZ, HDMI_MC_PHYRSTZ); hdmi_writeb(hdmi, 0, HDMI_MC_PHYRSTZ); } -EXPORT_SYMBOL_GPL(dw_hdmi_phy_reset); +EXPORT_SYMBOL_GPL(dw_hdmi_phy_gen2_reset); void dw_hdmi_phy_i2c_set_addr(struct dw_hdmi *hdmi, u8 address) { @@ -1529,7 +1537,7 @@ static int hdmi_phy_configure(struct dw_hdmi *hdmi, if (phy->has_svsret) dw_hdmi_phy_enable_svsret(hdmi, 1); - dw_hdmi_phy_reset(hdmi); + dw_hdmi_phy_gen2_reset(hdmi); hdmi_writeb(hdmi, HDMI_MC_HEACPHY_RST_ASSERT, HDMI_MC_HEACPHY_RST); diff --git a/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c b/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c index 5e2b0175df36..2860e6bff8b7 100644 --- a/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c +++ b/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c @@ -135,7 +135,7 @@ static int sun8i_hdmi_phy_config_a83t(struct dw_hdmi *hdmi, dw_hdmi_phy_gen2_txpwron(hdmi, 0); dw_hdmi_phy_gen2_pddq(hdmi, 1); - dw_hdmi_phy_reset(hdmi); + dw_hdmi_phy_gen2_reset(hdmi); dw_hdmi_phy_gen2_pddq(hdmi, 0); diff --git a/include/drm/bridge/dw_hdmi.h b/include/drm/bridge/dw_hdmi.h index 2a1f85f9a8a3..70082f80a8c8 100644 --- a/include/drm/bridge/dw_hdmi.h +++ b/include/drm/bridge/dw_hdmi.h @@ -187,9 +187,11 @@ void dw_hdmi_phy_i2c_set_addr(struct dw_hdmi *hdmi, u8 address); void dw_hdmi_phy_i2c_write(struct dw_hdmi *hdmi, unsigned short data, unsigned char addr); +void dw_hdmi_phy_gen1_reset(struct dw_hdmi *hdmi); + void dw_hdmi_phy_gen2_pddq(struct dw_hdmi *hdmi, u8 enable); void dw_hdmi_phy_gen2_txpwron(struct dw_hdmi *hdmi, u8 enable); -void dw_hdmi_phy_reset(struct dw_hdmi *hdmi); +void dw_hdmi_phy_gen2_reset(struct dw_hdmi *hdmi); enum drm_connector_status dw_hdmi_phy_read_hpd(struct dw_hdmi *hdmi, void *data); From patchwork Fri Apr 8 10:32:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sandor Yu X-Patchwork-Id: 12806413 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 E2DF2C433EF for ; Fri, 8 Apr 2022 10:33:28 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 047F010E393; Fri, 8 Apr 2022 10:33:28 +0000 (UTC) Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80089.outbound.protection.outlook.com [40.107.8.89]) by gabe.freedesktop.org (Postfix) with ESMTPS id E981D10E41D for ; Fri, 8 Apr 2022 10:33:25 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ARDU35salKFhlOcpct2wkxuzkHyBfi3MhkufLFF90XOw5P7DKSxBpqb9jgyJZ6gu0kjCizwB1UlPI44G1fbes3mtrYIt/Jl7vYAAuBU9a9wF+v9019ZhuS3gfwmYfIlVeHXGrPQC3mIFJn+8P39+V1ub2xmZcuCWeKUpUJ1UQ8424uOGKoe9JilxnWRRUir2JWVZEK9prDU1rgbcAJaAY57KTrJg2BRdui1NbBJhg7Bpvh7B/Ix1ZNUvDjkqKqk4Mi+/g429Y3mhsmqOoZFtFKXtyfmEpsXvWxqRcb9yqB7x4x/6Glc8XDvJGx+tXp6TxXfUNSo4her7gDO9z7s2xw== 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=ejtBfzbWzWEfRbA052Z5HtmhmHAZq1Mhygd1OrxWbAQ=; b=HnTCRzEWJU6xWQCXBBENLOfz7UzlsHYUA46XE/D76gwDXVb9iNtqi4E8WZ016vyX1+Ped0EZD7zWFVRfZBKjh0TOWMSUvpyL/z+Bhj0SxlE6cEQlMyoawmq0nF2VNZnR3qCSsex20ugciemFLO8gnSKYT+YtqrIX2ysSicby7T3h90DCAqkN0Fk+K8N/tB6gUpJ0QO2xszbC4J2LlK3m5LFJ1/46bmuDgwa5GhkDZRioS9lRIDweWrwWyKDvcmG3C94LXoguHPndFzJ0svO4UbpW3X8yBjuhezCegngr9/t+43pUJ4THCPofTcYr5AfKTxnuopKOfuwU5QLWZ2KEMA== 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=ejtBfzbWzWEfRbA052Z5HtmhmHAZq1Mhygd1OrxWbAQ=; b=Me1vmOZMMHsxGzMd4OQbZ2FLHqzW8P1mwgqD6C6/Kjv0YjjlD2ICAZuPN6mrqH7rI6ZkWmvBEO3E1vfw8GbaHlKeWHrWLxtDwhpIQIUqTAGDcfbXNwOH58GlNURtdquGOJROnP9j6iQitO2eyKKEv46Lgq2DvBe/KdvbKgEIDJA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DB7PR04MB5450.eurprd04.prod.outlook.com (2603:10a6:10:86::11) by VI1PR0402MB3405.eurprd04.prod.outlook.com (2603:10a6:803:3::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5144.22; Fri, 8 Apr 2022 10:33:23 +0000 Received: from DB7PR04MB5450.eurprd04.prod.outlook.com ([fe80::7997:2892:d230:2430]) by DB7PR04MB5450.eurprd04.prod.outlook.com ([fe80::7997:2892:d230:2430%7]) with mapi id 15.20.5144.025; Fri, 8 Apr 2022 10:33:23 +0000 From: Sandor Yu To: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, andrzej.hajda@intel.com, narmstrong@baylibre.com, robert.foss@linaro.org, Laurent.pinchart@ideasonboard.com, jonas@kwiboo.se, jernej.skrabec@gmail.com, hverkuil-cisco@xs4all.nl Subject: [PATCH v2 5/5] drm: bridge: dw_hdmi: Audio: Add General Parallel Audio (GPA) driver Date: Fri, 8 Apr 2022 18:32:28 +0800 Message-Id: <2ab98e4cf8fccc56dbb69b6d5248bb244f0c2a61.1649412256.git.Sandor.yu@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: X-ClientProxiedBy: SGXP274CA0017.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b8::29) To DB7PR04MB5450.eurprd04.prod.outlook.com (2603:10a6:10:86::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5c752bb3-fb21-45c8-2bf0-08da194b3505 X-MS-TrafficTypeDiagnostic: VI1PR0402MB3405:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: S/Z6LcmUv8s9sX6QBGfAhGlLgNaiQChzdU43NFrP5PeER97ZA3fNSyF/jRF0q8Rij28XKScbnjMcGJM0GeU5AItmdYqfbf1hBOKSkjzD8bkulVC2R79XvGvE8VMgj8cIKvThjcnioQCSze0uOMaqY1O94xuBskFMC10u1CNvTfvuupna54C/NyE9IxlmUtMr0bRtb14+0w/ltJ7D2tACxi8eZa0IvT8Hpj1O8GDv5E0xuOJVtSQzJCkL+KLY+FnOiT7FFaEggNJd6Aspo1mOumt2H+H2PRPRVG3hbSSFcc+4Os5O51tmnn5re3fH70brY4+/pbzPIDQEt8UFWlS3c4YAS7Xk+DcnjhDSp/Ccktd85UP5gg/nuEK1Bat+4EVTGSozAmxGKyL6dMBDw43pPI5I5eMWVnoJpmGj6EuDaGUxwDhj8vxuVftRva1TaVbEzcBEYFJsd1Ltlv/ijsy9NVDl4TJ+k8npitEiiv0I24PTDezO8O66uvmT0UGBTty8y5/9Vl3VR3v/VYnLJlmEYhQc5YVkF/ASdCHApG3lmv5CdjphjaVVR4XrMOEbLusq45HaDxcd5xSpPPXDan/8gTxfyuPV+ym0hju+QZ0QWOWvjMkfxNgHJ3REHZ0Kw2ni96xPp4zjAj2qiinZCju/0Y/56VZh2XHwGHSQpixNnS2m3kFATD2jjRNS+ZvSh2OykGmPJLW6EGMeRmYKsKuz1w== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB7PR04MB5450.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(8936002)(2616005)(52116002)(66476007)(83380400001)(8676002)(86362001)(508600001)(66556008)(66946007)(38350700002)(4326008)(30864003)(7416002)(2906002)(186003)(316002)(5660300002)(6506007)(26005)(36756003)(6512007)(38100700002)(6486002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: XagKwmq9f9xA4AtyBK8iUrzQx85gwJ0DgKNa7TC3REvSYzUgGTcY6jzhFsZ/TPG/XIJwpMBG251Wn9qKJzutMfei+lzcy7iCaiHEClMDf2d3biiPql19QCOj6wMZ1KVskrmZJGB34GF/NJw/XU/DzpSf4wnXFFmqxfzzklKDuvyF8DF1ELYy4U7dIGA2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YHOPeVUCUc+9QbM6jP+8ok/+2CvfvLdT0gOX73oPMV+IndvY+dARX165ovCrs/a2yMSz4UN5UecACEbVSrVVwqVlD3/aTxBWlYaLYtx3j6edULrxRC8tNws5+DwQIVYfYYjIhbYUy7zf4MtHehlzh1wwnZLUF+dSehwOejv/1kVT8gvmvNkDTaXVYEcj6Havku/4GQlt6tRLO+GErWrlUqxDgIkDjSpSMIUx4hzGXVA9yz9mzajgayV6TnboYL/huVolYc5g10iU4SjEmOd2tPT3bkmMcqfSGXdNPDigMq0LKLytUCpNkBNdBFwoZ4uwQx3Wlo7TSnyOnfBFKIjUNaC1GEdqwW+wxy8jN7m8ZPAKuT04HOUtpeUcrziOIP5EyM47rk2LDve7F60rfq2HdftItDSBkxnJLyy8Ob3CuMgTpwJ4g6oT8CAznWceI/sc9fjxJdprmCMyEsphr62fan7BDNUBAQ+g== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5c752bb3-fb21-45c8-2bf0-08da194b3505 X-MS-Exchange-CrossTenant-AuthSource: DB7PR04MB5450.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Apr 2022 10:33:23.2088 (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: WzUoiv94WfFIqCLIBsJ28ZL0BXDdXnrHUm33HxV89b19DJeg6eGWYIq7ONKh7xugv5hDwxcHFf2u/WhXNlm+OQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3405 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sandor.yu@nxp.com, shengjiu.wang@nxp.com, cai.huoqing@linux.dev, maxime@cerno.tech Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" General Parallel Audio (GPA) interface is one of the supported audio interface for synopsys HDMI module, which has verified for i.MX8MPlus platform. This is initial version for GPA. Signed-off-by: Shengjiu Wang Signed-off-by: Sandor Yu --- drivers/gpu/drm/bridge/synopsys/Kconfig | 10 + drivers/gpu/drm/bridge/synopsys/Makefile | 1 + .../drm/bridge/synopsys/dw-hdmi-gp-audio.c | 199 ++++++++++++++++++ drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 128 ++++++++++- drivers/gpu/drm/bridge/synopsys/dw-hdmi.h | 13 +- include/drm/bridge/dw_hdmi.h | 5 + 6 files changed, 353 insertions(+), 3 deletions(-) create mode 100644 drivers/gpu/drm/bridge/synopsys/dw-hdmi-gp-audio.c diff --git a/drivers/gpu/drm/bridge/synopsys/Kconfig b/drivers/gpu/drm/bridge/synopsys/Kconfig index 21a1be3ced0f..a4a31b669b65 100644 --- a/drivers/gpu/drm/bridge/synopsys/Kconfig +++ b/drivers/gpu/drm/bridge/synopsys/Kconfig @@ -25,6 +25,16 @@ config DRM_DW_HDMI_I2S_AUDIO Support the I2S Audio interface which is part of the Synopsys Designware HDMI block. +config DRM_DW_HDMI_GP_AUDIO + tristate "Synopsys Designware GP Audio interface" + depends on DRM_DW_HDMI && SND + select SND_PCM + select SND_PCM_ELD + select SND_PCM_IEC958 + help + Support the GP Audio interface which is part of the Synopsys + Designware HDMI block. + config DRM_DW_HDMI_CEC tristate "Synopsis Designware CEC interface" depends on DRM_DW_HDMI diff --git a/drivers/gpu/drm/bridge/synopsys/Makefile b/drivers/gpu/drm/bridge/synopsys/Makefile index 91d746ad5de1..ce715562e9e5 100644 --- a/drivers/gpu/drm/bridge/synopsys/Makefile +++ b/drivers/gpu/drm/bridge/synopsys/Makefile @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_DRM_DW_HDMI) += dw-hdmi.o obj-$(CONFIG_DRM_DW_HDMI_AHB_AUDIO) += dw-hdmi-ahb-audio.o +obj-$(CONFIG_DRM_DW_HDMI_GP_AUDIO) += dw-hdmi-gp-audio.o obj-$(CONFIG_DRM_DW_HDMI_I2S_AUDIO) += dw-hdmi-i2s-audio.o obj-$(CONFIG_DRM_DW_HDMI_CEC) += dw-hdmi-cec.o diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi-gp-audio.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-gp-audio.c new file mode 100644 index 000000000000..10a957c85a83 --- /dev/null +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-gp-audio.c @@ -0,0 +1,199 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * dw-hdmi-gp-audio.c + * + * Copyright 2020-2022 NXP + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "dw-hdmi-audio.h" + +#define DRIVER_NAME "dw-hdmi-gp-audio" +#define DRV_NAME "hdmi-gp-audio" + +struct snd_dw_hdmi { + struct dw_hdmi_audio_data data; + struct platform_device *audio_pdev; + unsigned int pos; +}; + +struct dw_hdmi_channel_conf { + u8 conf1; + u8 ca; +}; + +/* + * The default mapping of ALSA channels to HDMI channels and speaker + * allocation bits. Note that we can't do channel remapping here - + * channels must be in the same order. + * + * Mappings for alsa-lib pcm/surround*.conf files: + * + * Front Sur4.0 Sur4.1 Sur5.0 Sur5.1 Sur7.1 + * Channels 2 4 6 6 6 8 + * + * Our mapping from ALSA channel to CEA686D speaker name and HDMI channel: + * + * Number of ALSA channels + * ALSA Channel 2 3 4 5 6 7 8 + * 0 FL:0 = = = = = = + * 1 FR:1 = = = = = = + * 2 FC:3 RL:4 LFE:2 = = = + * 3 RR:5 RL:4 FC:3 = = + * 4 RR:5 RL:4 = = + * 5 RR:5 = = + * 6 RC:6 = + * 7 RLC/FRC RLC/FRC + */ +static struct dw_hdmi_channel_conf default_hdmi_channel_config[7] = { + { 0x03, 0x00 }, /* FL,FR */ + { 0x0b, 0x02 }, /* FL,FR,FC */ + { 0x33, 0x08 }, /* FL,FR,RL,RR */ + { 0x37, 0x09 }, /* FL,FR,LFE,RL,RR */ + { 0x3f, 0x0b }, /* FL,FR,LFE,FC,RL,RR */ + { 0x7f, 0x0f }, /* FL,FR,LFE,FC,RL,RR,RC */ + { 0xff, 0x13 }, /* FL,FR,LFE,FC,RL,RR,[FR]RC,[FR]LC */ +}; + +static int audio_hw_params(struct device *dev, void *data, + struct hdmi_codec_daifmt *daifmt, + struct hdmi_codec_params *params) +{ + struct snd_dw_hdmi *dw = dev_get_drvdata(dev); + int ret = 0; + u8 ca; + + dw_hdmi_set_sample_rate(dw->data.hdmi, params->sample_rate); + + ca = default_hdmi_channel_config[params->channels - 2].ca; + + dw_hdmi_set_channel_count(dw->data.hdmi, params->channels); + dw_hdmi_set_channel_allocation(dw->data.hdmi, ca); + + dw_hdmi_set_sample_non_pcm(dw->data.hdmi, + params->iec.status[0] & IEC958_AES0_NONAUDIO); + dw_hdmi_set_sample_width(dw->data.hdmi, params->sample_width); + + return ret; +} + +static void audio_shutdown(struct device *dev, void *data) +{ +} + +static int audio_mute_stream(struct device *dev, void *data, + bool enable, int direction) +{ + struct snd_dw_hdmi *dw = dev_get_drvdata(dev); + int ret = 0; + + if (!enable) + dw_hdmi_audio_enable(dw->data.hdmi); + else + dw_hdmi_audio_disable(dw->data.hdmi); + + return ret; +} + +static int audio_get_eld(struct device *dev, void *data, + u8 *buf, size_t len) +{ + struct dw_hdmi_audio_data *audio = data; + u8 *eld; + + eld = audio->get_eld(audio->hdmi); + if (eld) + memcpy(buf, eld, min_t(size_t, MAX_ELD_BYTES, len)); + else + /* Pass en empty ELD if connector not available */ + memset(buf, 0, len); + + return 0; +} + +static int audio_hook_plugged_cb(struct device *dev, void *data, + hdmi_codec_plugged_cb fn, + struct device *codec_dev) +{ + struct snd_dw_hdmi *dw = dev_get_drvdata(dev); + + return dw_hdmi_set_plugged_cb(dw->data.hdmi, fn, codec_dev); +} + +static const struct hdmi_codec_ops audio_codec_ops = { + .hw_params = audio_hw_params, + .audio_shutdown = audio_shutdown, + .mute_stream = audio_mute_stream, + .get_eld = audio_get_eld, + .hook_plugged_cb = audio_hook_plugged_cb, +}; + +static int snd_dw_hdmi_probe(struct platform_device *pdev) +{ + struct dw_hdmi_audio_data *data = pdev->dev.platform_data; + struct snd_dw_hdmi *dw; + + const struct hdmi_codec_pdata codec_data = { + .i2s = 1, + .spdif = 0, + .ops = &audio_codec_ops, + .max_i2s_channels = 8, + .data = data, + }; + + dw = devm_kzalloc(&pdev->dev, sizeof(*dw), GFP_KERNEL); + if (!dw) + return -ENOMEM; + + dw->data = *data; + + platform_set_drvdata(pdev, dw); + + dw->audio_pdev = platform_device_register_data(&pdev->dev, + HDMI_CODEC_DRV_NAME, 1, + &codec_data, + sizeof(codec_data)); + + return PTR_ERR_OR_ZERO(dw->audio_pdev); +} + +static int snd_dw_hdmi_remove(struct platform_device *pdev) +{ + struct snd_dw_hdmi *dw = platform_get_drvdata(pdev); + + platform_device_unregister(dw->audio_pdev); + + return 0; +} + +static struct platform_driver snd_dw_hdmi_driver = { + .probe = snd_dw_hdmi_probe, + .remove = snd_dw_hdmi_remove, + .driver = { + .name = DRIVER_NAME, + }, +}; + +module_platform_driver(snd_dw_hdmi_driver); + +MODULE_AUTHOR("Shengjiu Wang "); +MODULE_DESCRIPTION("Synopsis Designware HDMI GPA ALSA interface"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:" DRIVER_NAME); diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c index 13270d96e5be..2ebbe9fc5d7f 100644 --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c @@ -191,7 +191,10 @@ struct dw_hdmi { spinlock_t audio_lock; struct mutex audio_mutex; + unsigned int sample_non_pcm; + unsigned int sample_width; unsigned int sample_rate; + unsigned int channels; unsigned int audio_cts; unsigned int audio_n; bool audio_enable; @@ -589,6 +592,8 @@ static unsigned int hdmi_compute_n(unsigned int freq, unsigned long pixel_clk) n = 4096; else if (pixel_clk == 74176000 || pixel_clk == 148352000) n = 11648; + else if (pixel_clk == 297000000) + n = 3072; else n = 4096; n *= mult; @@ -601,6 +606,8 @@ static unsigned int hdmi_compute_n(unsigned int freq, unsigned long pixel_clk) n = 17836; else if (pixel_clk == 148352000) n = 8918; + else if (pixel_clk == 297000000) + n = 4704; else n = 6272; n *= mult; @@ -615,6 +622,8 @@ static unsigned int hdmi_compute_n(unsigned int freq, unsigned long pixel_clk) n = 11648; else if (pixel_clk == 148352000) n = 5824; + else if (pixel_clk == 297000000) + n = 5120; else n = 6144; n *= mult; @@ -660,7 +669,7 @@ static void hdmi_set_clk_regenerator(struct dw_hdmi *hdmi, config3 = hdmi_readb(hdmi, HDMI_CONFIG3_ID); /* Only compute CTS when using internal AHB audio */ - if (config3 & HDMI_CONFIG3_AHBAUDDMA) { + if ((config3 & HDMI_CONFIG3_AHBAUDDMA) || (config3 & HDMI_CONFIG3_GPAUD)) { /* * Compute the CTS value from the N value. Note that CTS and N * can be up to 20 bits in total, so we need 64-bit math. Also @@ -702,6 +711,22 @@ static void hdmi_clk_regenerator_update_pixel_clock(struct dw_hdmi *hdmi) mutex_unlock(&hdmi->audio_mutex); } +void dw_hdmi_set_sample_width(struct dw_hdmi *hdmi, unsigned int width) +{ + mutex_lock(&hdmi->audio_mutex); + hdmi->sample_width = width; + mutex_unlock(&hdmi->audio_mutex); +} +EXPORT_SYMBOL_GPL(dw_hdmi_set_sample_width); + +void dw_hdmi_set_sample_non_pcm(struct dw_hdmi *hdmi, unsigned int non_pcm) +{ + mutex_lock(&hdmi->audio_mutex); + hdmi->sample_non_pcm = non_pcm; + mutex_unlock(&hdmi->audio_mutex); +} +EXPORT_SYMBOL_GPL(dw_hdmi_set_sample_non_pcm); + void dw_hdmi_set_sample_rate(struct dw_hdmi *hdmi, unsigned int rate) { mutex_lock(&hdmi->audio_mutex); @@ -717,6 +742,7 @@ void dw_hdmi_set_channel_count(struct dw_hdmi *hdmi, unsigned int cnt) u8 layout; mutex_lock(&hdmi->audio_mutex); + hdmi->channels = cnt; /* * For >2 channel PCM audio, we need to select layout 1 @@ -765,6 +791,87 @@ static u8 *hdmi_audio_get_eld(struct dw_hdmi *hdmi) return hdmi->curr_conn->eld; } +static void dw_hdmi_gp_audio_enable(struct dw_hdmi *hdmi) +{ + int sample_freq = 0x2, org_sample_freq = 0xD; + int ch_mask = BIT(hdmi->channels) - 1; + + switch (hdmi->sample_rate) { + case 32000: + sample_freq = 0x03; + org_sample_freq = 0x0C; + break; + case 44100: + sample_freq = 0x00; + org_sample_freq = 0x0F; + break; + case 48000: + sample_freq = 0x02; + org_sample_freq = 0x0D; + break; + case 88200: + sample_freq = 0x08; + org_sample_freq = 0x07; + break; + case 96000: + sample_freq = 0x0A; + org_sample_freq = 0x05; + break; + case 176400: + sample_freq = 0x0C; + org_sample_freq = 0x03; + break; + case 192000: + sample_freq = 0x0E; + org_sample_freq = 0x01; + break; + default: + break; + } + + hdmi_set_cts_n(hdmi, hdmi->audio_cts, hdmi->audio_n); + hdmi_enable_audio_clk(hdmi, true); + + hdmi_writeb(hdmi, 0x1, HDMI_FC_AUDSCHNLS0); + hdmi_writeb(hdmi, hdmi->channels, HDMI_FC_AUDSCHNLS2); + hdmi_writeb(hdmi, 0x22, HDMI_FC_AUDSCHNLS3); + hdmi_writeb(hdmi, 0x22, HDMI_FC_AUDSCHNLS4); + hdmi_writeb(hdmi, 0x11, HDMI_FC_AUDSCHNLS5); + hdmi_writeb(hdmi, 0x11, HDMI_FC_AUDSCHNLS6); + hdmi_writeb(hdmi, (0x3 << 4) | sample_freq, HDMI_FC_AUDSCHNLS7); + hdmi_writeb(hdmi, (org_sample_freq << 4) | 0xb, HDMI_FC_AUDSCHNLS8); + + hdmi_writeb(hdmi, ch_mask, HDMI_GP_CONF1); + hdmi_writeb(hdmi, 0x02, HDMI_GP_CONF2); + hdmi_writeb(hdmi, 0x01, HDMI_GP_CONF0); + + hdmi_modb(hdmi, 0x3, 0x3, HDMI_FC_DATAUTO3); + + /* hbr */ + if (hdmi->sample_rate == 192000 && hdmi->channels == 8 && + hdmi->sample_width == 32 && hdmi->sample_non_pcm) { + hdmi_modb(hdmi, 0x01, 0x01, HDMI_GP_CONF2); + } + + if (hdmi->phy.ops->enable_audio) + hdmi->phy.ops->enable_audio(hdmi, hdmi->phy.data, + hdmi->channels, + hdmi->sample_width, + hdmi->sample_rate, + hdmi->sample_non_pcm); +} + +static void dw_hdmi_gp_audio_disable(struct dw_hdmi *hdmi) +{ + hdmi_set_cts_n(hdmi, hdmi->audio_cts, 0); + + hdmi_modb(hdmi, 0, 0x3, HDMI_FC_DATAUTO3); + if (hdmi->phy.ops->disable_audio) + hdmi->phy.ops->disable_audio(hdmi, hdmi->phy.data); + + hdmi_enable_audio_clk(hdmi, false); +} + static void dw_hdmi_ahb_audio_enable(struct dw_hdmi *hdmi) { hdmi_set_cts_n(hdmi, hdmi->audio_cts, hdmi->audio_n); @@ -3253,6 +3360,7 @@ struct dw_hdmi *dw_hdmi_probe(struct platform_device *pdev, hdmi->plat_data = plat_data; hdmi->dev = dev; hdmi->sample_rate = 48000; + hdmi->channels = 2; hdmi->disabled = true; hdmi->rxsense = true; hdmi->phy_mask = (u8)~(HDMI_PHY_HPD | HDMI_PHY_RX_SENSE); @@ -3476,6 +3584,24 @@ struct dw_hdmi *dw_hdmi_probe(struct platform_device *pdev, pdevinfo.size_data = sizeof(audio); pdevinfo.dma_mask = DMA_BIT_MASK(32); hdmi->audio = platform_device_register_full(&pdevinfo); + } else if (iores && config3 & HDMI_CONFIG3_GPAUD) { + struct dw_hdmi_audio_data audio; + + audio.phys = iores->start; + audio.base = hdmi->regs; + audio.irq = irq; + audio.hdmi = hdmi; + audio.get_eld = hdmi_audio_get_eld; + + hdmi->enable_audio = dw_hdmi_gp_audio_enable; + hdmi->disable_audio = dw_hdmi_gp_audio_disable; + + pdevinfo.name = "dw-hdmi-gp-audio"; + pdevinfo.id = PLATFORM_DEVID_NONE; + pdevinfo.data = &audio; + pdevinfo.size_data = sizeof(audio); + pdevinfo.dma_mask = DMA_BIT_MASK(32); + hdmi->audio = platform_device_register_full(&pdevinfo); } if (!plat_data->disable_cec && (config0 & HDMI_CONFIG0_CEC)) { diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.h b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.h index 1999db05bc3b..99aa1c03343b 100644 --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.h +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.h @@ -158,8 +158,17 @@ #define HDMI_FC_SPDDEVICEINF 0x1062 #define HDMI_FC_AUDSCONF 0x1063 #define HDMI_FC_AUDSSTAT 0x1064 -#define HDMI_FC_AUDSCHNLS7 0x106e -#define HDMI_FC_AUDSCHNLS8 0x106f +#define HDMI_FC_AUDSV 0x1065 +#define HDMI_FC_AUDSU 0x1066 +#define HDMI_FC_AUDSCHNLS0 0x1067 +#define HDMI_FC_AUDSCHNLS1 0x1068 +#define HDMI_FC_AUDSCHNLS2 0x1069 +#define HDMI_FC_AUDSCHNLS3 0x106A +#define HDMI_FC_AUDSCHNLS4 0x106B +#define HDMI_FC_AUDSCHNLS5 0x106C +#define HDMI_FC_AUDSCHNLS6 0x106D +#define HDMI_FC_AUDSCHNLS7 0x106E +#define HDMI_FC_AUDSCHNLS8 0x106F #define HDMI_FC_DATACH0FILL 0x1070 #define HDMI_FC_DATACH1FILL 0x1071 #define HDMI_FC_DATACH2FILL 0x1072 diff --git a/include/drm/bridge/dw_hdmi.h b/include/drm/bridge/dw_hdmi.h index 70082f80a8c8..7f73c3398a54 100644 --- a/include/drm/bridge/dw_hdmi.h +++ b/include/drm/bridge/dw_hdmi.h @@ -121,6 +121,9 @@ struct dw_hdmi_phy_ops { void (*update_hpd)(struct dw_hdmi *hdmi, void *data, bool force, bool disabled, bool rxsense); void (*setup_hpd)(struct dw_hdmi *hdmi, void *data); + void (*enable_audio)(struct dw_hdmi *hdmi, void *data, int channel, + int width, int rate, int non_pcm); + void (*disable_audio)(struct dw_hdmi *hdmi, void *data); }; struct dw_hdmi_plat_data { @@ -173,6 +176,8 @@ void dw_hdmi_setup_rx_sense(struct dw_hdmi *hdmi, bool hpd, bool rx_sense); int dw_hdmi_set_plugged_cb(struct dw_hdmi *hdmi, hdmi_codec_plugged_cb fn, struct device *codec_dev); +void dw_hdmi_set_sample_non_pcm(struct dw_hdmi *hdmi, unsigned int non_pcm); +void dw_hdmi_set_sample_width(struct dw_hdmi *hdmi, unsigned int width); void dw_hdmi_set_sample_rate(struct dw_hdmi *hdmi, unsigned int rate); void dw_hdmi_set_channel_count(struct dw_hdmi *hdmi, unsigned int cnt); void dw_hdmi_set_channel_status(struct dw_hdmi *hdmi, u8 *channel_status);