From nobody Thu Dec 18 10:03:40 2025 Received: from bali.collaboradmins.com (bali.collaboradmins.com [148.251.105.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 854BA25A325; Tue, 11 Feb 2025 11:35:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.251.105.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739273714; cv=none; b=aYqK6+wxmG4nTT08ciAUHa1NHcSM8Nr5SmKO2rlN0O2Eh/88kc9keWlxxHkkpFt1cdjqwanb2ks+ivk7jBn79nA2DfAXyUv3vJXHbTNtW6kaY9KVpjk93LxmIvZf3TC320oRk/EzndYaYtevJtM4+7uESPkf8YxzrtYwnURtolU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739273714; c=relaxed/simple; bh=9euLeaGAQYKAWOedQJ4UAB8tD9i+xpomVLm2bCNv3Qo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Cs+xEVWWEh4uKhO7ncJWvrd7izt5yHjMG1UaqbzpWq6gJJLTXO7fCXW8d7ZekMvxX1AZ225egxdUj3LggAWqLccV5FLqWWCp4mVRNnf/29FxJH0sSOWumCO9tfc6DqFh2xoUstIqV464fO08+D9o9lJ6pGKtHNzp6MBzsPFV090= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=Jn6756AR; arc=none smtp.client-ip=148.251.105.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="Jn6756AR" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1739273710; bh=9euLeaGAQYKAWOedQJ4UAB8tD9i+xpomVLm2bCNv3Qo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Jn6756ARradUnGOxcJ+zZ348OzDvn+HHfqagcSkiPaSa5KKIvcibUpttDjMPUsHqc bAcCO5swXU4ksgeYTkhnTk/rNm125RgWYE4+Bs1oPIUiSOcB4uoTFVeBfuzya/Ll1w EmxMd7kAuSlLEproxR7pO6ebjojXw/p/QdcYUQJFiZyyo5CAMlPG2EVXV4N16WLY1+ gYUYkWE93uDNi1i1blAJYmp6kcvHK7nZk+oqxs7tkIWaRZQwU55mKMArALNTiI18ka TW15LJ17EUQO/C0fty0xF1j+HCRylq9PY0Hg75rYZVaO4Js21GOr0g4qMzW2hyBKcH RN8X/I1C7V9jw== 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 9136617E1551; Tue, 11 Feb 2025 12:35:09 +0100 (CET) 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 v6 34/42] drm/mediatek: mtk_hdmi: Add HDMI IP version configuration to pdata Date: Tue, 11 Feb 2025 12:34:01 +0100 Message-ID: <20250211113409.1517534-35-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250211113409.1517534-1-angelogioacchino.delregno@collabora.com> References: <20250211113409.1517534-1-angelogioacchino.delregno@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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. 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 d3bfae2f1842..332567f18c9a 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; }; =20 +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; @@ -1605,7 +1613,7 @@ static int mtk_hdmi_register_audio_driver(struct devi= ce *dev) struct mtk_hdmi *hdmi =3D dev_get_drvdata(dev); struct hdmi_audio_param *aud_param =3D &hdmi->aud_param; struct hdmi_codec_pdata codec_data =3D { - .ops =3D &mtk_hdmi_audio_codec_ops, + .ops =3D hdmi->conf->ver_conf->codec_ops, .max_i2s_channels =3D 2, .i2s =3D 1, .data =3D hdmi, @@ -1638,6 +1646,7 @@ static int mtk_hdmi_register_audio_driver(struct devi= ce *dev) =20 static int mtk_hdmi_probe(struct platform_device *pdev) { + const struct mtk_hdmi_ver_conf *ver_conf; struct mtk_hdmi *hdmi; struct device *dev =3D &pdev->dev; const int num_clocks =3D MTK_HDMI_CLK_COUNT; @@ -1649,12 +1658,14 @@ static int mtk_hdmi_probe(struct platform_device *p= dev) =20 hdmi->dev =3D dev; hdmi->conf =3D of_device_get_match_data(dev); + ver_conf =3D hdmi->conf->ver_conf; =20 - hdmi->clk =3D devm_kcalloc(dev, num_clocks, sizeof(*hdmi->clk), GFP_KERNE= L); + hdmi->clk =3D devm_kcalloc(dev, ver_conf->num_clocks, sizeof(*hdmi->clk),= GFP_KERNEL); if (!hdmi->clk) return -ENOMEM; =20 - ret =3D mtk_hdmi_dt_parse_pdata(hdmi, pdev, mtk_hdmi_clk_names, num_clock= s); + ret =3D mtk_hdmi_dt_parse_pdata(hdmi, pdev, ver_conf->mtk_hdmi_clock_name= s, + ver_conf->num_clocks); if (ret) return ret; =20 @@ -1671,7 +1682,7 @@ static int mtk_hdmi_probe(struct platform_device *pde= v) return dev_err_probe(dev, ret, "Failed to register audio driver\n"); =20 - hdmi->bridge.funcs =3D &mtk_hdmi_bridge_funcs; + hdmi->bridge.funcs =3D ver_conf->bridge_funcs; hdmi->bridge.of_node =3D pdev->dev.of_node; hdmi->bridge.ops =3D DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID | DRM_BRIDGE_OP_HPD; @@ -1716,19 +1727,32 @@ static __maybe_unused int mtk_hdmi_resume(struct de= vice *dev) =20 static SIMPLE_DEV_PM_OPS(mtk_hdmi_pm_ops, mtk_hdmi_suspend, mtk_hdmi_resum= e); =20 +static const struct mtk_hdmi_ver_conf mtk_hdmi_v1_ver_conf =3D { + .bridge_funcs =3D &mtk_hdmi_bridge_funcs, + .codec_ops =3D &mtk_hdmi_audio_codec_ops, + .mtk_hdmi_clock_names =3D mtk_hdmi_clk_names, + .num_clocks =3D ARRAY_SIZE(mtk_hdmi_clk_names) +}; + static const struct mtk_hdmi_conf mtk_hdmi_conf_mt2701 =3D { .tz_disabled =3D true, + .ver_conf =3D &mtk_hdmi_v1_ver_conf }; =20 static const struct mtk_hdmi_conf mtk_hdmi_conf_mt8167 =3D { - .max_mode_clock =3D 148500, .cea_modes_only =3D true, + .max_mode_clock =3D 148500, + .ver_conf =3D &mtk_hdmi_v1_ver_conf +}; + +static const struct mtk_hdmi_conf mtk_hdmi_conf_mt8173 =3D { + .ver_conf =3D &mtk_hdmi_v1_ver_conf }; =20 static const struct of_device_id mtk_hdmi_of_ids[] =3D { { .compatible =3D "mediatek,mt2701-hdmi", .data =3D &mtk_hdmi_conf_mt2701= }, { .compatible =3D "mediatek,mt8167-hdmi", .data =3D &mtk_hdmi_conf_mt8167= }, - { .compatible =3D "mediatek,mt8173-hdmi" }, + { .compatible =3D "mediatek,mt8173-hdmi", .data =3D &mtk_hdmi_conf_mt8173= }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, mtk_hdmi_of_ids); --=20 2.48.1