From patchwork Wed Apr 9 13:13:10 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 14044699 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 859CFC36002 for ; Wed, 9 Apr 2025 13:51:40 +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:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=aWlJK4WTq1UQF2tUU8Wfd9GXCVh2GwfT3rw60makh/c=; b=5A8KUUDKPGMyFmnR5zn+prPhsZ IKhIhXJQA/bLg0b1Vs4shUob88FgcM+MHLY734bElXlFnQ/pQE7+wlI+a9c6gz/RBtY/Y5IoLZz7r N2ogeec20cbmgOIQTghFAdMYdn8Qrs1lU1UxyjshHeJmvVLmel0JPbPj6iie6vU4TjlreA3FDeAOA +LV65cucrXiRObKcWjWJAy7xMpZPKoR6cXBB+/3jkQ4dNJgYEUzN6OXORc3BtmR6raIbO8kdoRdGW Bj0lPLZFRMT+J0BwFbw58TpeaH7vgik231azUuDg/yn7ssXXPj1/db7nnyEXd3BSK1Z5LGKodFB+L 3n0cDO8A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1u2Vpx-00000007M4e-3xJy; Wed, 09 Apr 2025 13:51:29 +0000 Received: from bali.collaboradmins.com ([2a01:4f8:201:9162::2]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1u2VFU-00000007FP4-1cts; Wed, 09 Apr 2025 13:13:49 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1744204427; bh=eqzljcI5k9NvlLrzPg4W0BEhMgRDDnz7WbvPijjWyH0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WZiT39GCY5F0PlKbBR+cJVvsuWRrE+iU7z1dYv8v6YcJr/OmCfXZG2mNTqupylEXR 4/r3ip3O8pMAvQRS6zcnKDtH4ZpGrnaxUEVnmpd8CTksQNsCcWd5cJfuYctHs1Jxo+ 30AuqmpWlpMyDa59yP+62EmmDbRbPlKmX6lpXX+He2uqh8kH++xLYmbFD4WTl9xJ0r S19JD15yGZhZozZA7PNidVS15aPmS+E8dE+pXzvsIzGfRIlohNhtBO0sxVUatYXThi ZmROqxww/1Iy5TmzRisx5DdSjOQyf/k/UPP6cEs969eI1wqv27dyqXfqYbo6eh4nWq t/FLrrW3oh9yA== Received: from IcarusMOD.eternityproject.eu (2-237-20-237.ip236.fastwebnet.it [2.237.20.237]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: kholk11) by bali.collaboradmins.com (Postfix) with ESMTPSA id 997F617E35EB; Wed, 9 Apr 2025 15:13:45 +0200 (CEST) From: AngeloGioacchino Del Regno To: chunkuang.hu@kernel.org Cc: p.zabel@pengutronix.de, airlied@gmail.com, simona@ffwll.ch, maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, ck.hu@mediatek.com, jitao.shi@mediatek.com, jie.qiu@mediatek.com, junzhi.zhao@mediatek.com, dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@collabora.com, dmitry.baryshkov@linaro.org, lewis.liao@mediatek.com, ives.chenjh@mediatek.com, tommyyl.chen@mediatek.com, jason-jh.lin@mediatek.com Subject: [PATCH v8 15/23] drm/mediatek: mtk_hdmi: Add HDMI IP version configuration to pdata Date: Wed, 9 Apr 2025 15:13:10 +0200 Message-ID: <20250409131318.108690-16-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250409131318.108690-1-angelogioacchino.delregno@collabora.com> References: <20250409131318.108690-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250409_061348_570471_C70085DB X-CRM114-Status: GOOD ( 17.11 ) 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 In preparation for adding a driver for the HDMIv2 IP and before moving the common bits out of this driver, add a new structure `mtk_hdmi_ver_conf`, holding pointers to HDMI IP version specific drm_bridge_funcs, hdmi_codec_ops and clock array used for probe, and nest it into the mtk_hdmi_conf platform data structure. While at it, also convert all of the direct users of mtk_hdmi_bridge_funcs, mtk_hdmi_audio_codec_ops, mtk_hdmi_clk_names to use pointers from the ver_conf platform data. In order to do so, it was also necessary to fill a new version 1 specific const `mtk_hdmi_v1_ver_conf` and assign it to all of the currently supported compatibles for this driver. This commit brings no functional change. Reviewed-by: CK Hu Signed-off-by: AngeloGioacchino Del Regno --- drivers/gpu/drm/mediatek/mtk_hdmi.c | 36 ++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi.c b/drivers/gpu/drm/mediatek/mtk_hdmi.c index 68f479ec34c7..8c213a8b49f7 100644 --- a/drivers/gpu/drm/mediatek/mtk_hdmi.c +++ b/drivers/gpu/drm/mediatek/mtk_hdmi.c @@ -144,7 +144,15 @@ struct hdmi_audio_param { struct hdmi_codec_params codec_params; }; +struct mtk_hdmi_ver_conf { + const struct drm_bridge_funcs *bridge_funcs; + const struct hdmi_codec_ops *codec_ops; + const char * const *mtk_hdmi_clock_names; + int num_clocks; +}; + struct mtk_hdmi_conf { + const struct mtk_hdmi_ver_conf *ver_conf; bool tz_disabled; bool cea_modes_only; unsigned long max_mode_clock; @@ -1604,7 +1612,7 @@ static int mtk_hdmi_register_audio_driver(struct device *dev) struct mtk_hdmi *hdmi = dev_get_drvdata(dev); struct hdmi_audio_param *aud_param = &hdmi->aud_param; struct hdmi_codec_pdata codec_data = { - .ops = &mtk_hdmi_audio_codec_ops, + .ops = hdmi->conf->ver_conf->codec_ops, .max_i2s_channels = 2, .i2s = 1, .data = hdmi, @@ -1637,6 +1645,7 @@ static int mtk_hdmi_register_audio_driver(struct device *dev) static int mtk_hdmi_probe(struct platform_device *pdev) { + const struct mtk_hdmi_ver_conf *ver_conf; struct mtk_hdmi *hdmi; struct device *dev = &pdev->dev; const int num_clocks = MTK_HDMI_CLK_COUNT; @@ -1648,12 +1657,14 @@ static int mtk_hdmi_probe(struct platform_device *pdev) hdmi->dev = dev; hdmi->conf = of_device_get_match_data(dev); + ver_conf = hdmi->conf->ver_conf; - hdmi->clk = devm_kcalloc(dev, num_clocks, sizeof(*hdmi->clk), GFP_KERNEL); + hdmi->clk = devm_kcalloc(dev, ver_conf->num_clocks, sizeof(*hdmi->clk), GFP_KERNEL); if (!hdmi->clk) return -ENOMEM; - ret = mtk_hdmi_dt_parse_pdata(hdmi, pdev, mtk_hdmi_clk_names, num_clocks); + ret = mtk_hdmi_dt_parse_pdata(hdmi, pdev, ver_conf->mtk_hdmi_clock_names, + ver_conf->num_clocks); if (ret) return ret; @@ -1670,7 +1681,7 @@ static int mtk_hdmi_probe(struct platform_device *pdev) return dev_err_probe(dev, ret, "Failed to register audio driver\n"); - hdmi->bridge.funcs = &mtk_hdmi_bridge_funcs; + hdmi->bridge.funcs = ver_conf->bridge_funcs; hdmi->bridge.of_node = pdev->dev.of_node; hdmi->bridge.ops = DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID | DRM_BRIDGE_OP_HPD; @@ -1715,19 +1726,32 @@ static __maybe_unused int mtk_hdmi_resume(struct device *dev) static SIMPLE_DEV_PM_OPS(mtk_hdmi_pm_ops, mtk_hdmi_suspend, mtk_hdmi_resume); +static const struct mtk_hdmi_ver_conf mtk_hdmi_v1_ver_conf = { + .bridge_funcs = &mtk_hdmi_bridge_funcs, + .codec_ops = &mtk_hdmi_audio_codec_ops, + .mtk_hdmi_clock_names = mtk_hdmi_clk_names, + .num_clocks = ARRAY_SIZE(mtk_hdmi_clk_names) +}; + static const struct mtk_hdmi_conf mtk_hdmi_conf_mt2701 = { .tz_disabled = true, + .ver_conf = &mtk_hdmi_v1_ver_conf }; static const struct mtk_hdmi_conf mtk_hdmi_conf_mt8167 = { - .max_mode_clock = 148500, .cea_modes_only = true, + .max_mode_clock = 148500, + .ver_conf = &mtk_hdmi_v1_ver_conf +}; + +static const struct mtk_hdmi_conf mtk_hdmi_conf_mt8173 = { + .ver_conf = &mtk_hdmi_v1_ver_conf }; static const struct of_device_id mtk_hdmi_of_ids[] = { { .compatible = "mediatek,mt2701-hdmi", .data = &mtk_hdmi_conf_mt2701 }, { .compatible = "mediatek,mt8167-hdmi", .data = &mtk_hdmi_conf_mt8167 }, - { .compatible = "mediatek,mt8173-hdmi" }, + { .compatible = "mediatek,mt8173-hdmi", .data = &mtk_hdmi_conf_mt8173 }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, mtk_hdmi_of_ids);