Skip to content

Commit 2316129

Browse files
AngeloGioacchino Del RegnoChun-Kuang Hu
authored andcommitted
drm/mediatek: mtk_hdmi: Add HDMI IP version configuration to pdata
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 <ck.hu@mediatek.com> Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Signed-off-by: Louis-Alexis Eyraud <louisalexis.eyraud@collabora.com> Link: https://patchwork.kernel.org/project/linux-mediatek/patch/20251023-mediatek-drm-hdmi-v2-v11-3-7873ec4a1edf@collabora.com/ Signed-off-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
1 parent 0d410bd commit 2316129

1 file changed

Lines changed: 37 additions & 8 deletions

File tree

drivers/gpu/drm/mediatek/mtk_hdmi.c

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,15 @@ struct hdmi_audio_param {
144144
struct hdmi_codec_params codec_params;
145145
};
146146

147+
struct mtk_hdmi_ver_conf {
148+
const struct drm_bridge_funcs *bridge_funcs;
149+
const struct hdmi_codec_ops *codec_ops;
150+
const char * const *mtk_hdmi_clock_names;
151+
int num_clocks;
152+
};
153+
147154
struct mtk_hdmi_conf {
155+
const struct mtk_hdmi_ver_conf *ver_conf;
148156
bool tz_disabled;
149157
bool cea_modes_only;
150158
unsigned long max_mode_clock;
@@ -1618,7 +1626,7 @@ static int mtk_hdmi_register_audio_driver(struct device *dev)
16181626
struct mtk_hdmi *hdmi = dev_get_drvdata(dev);
16191627
struct hdmi_audio_param *aud_param = &hdmi->aud_param;
16201628
struct hdmi_codec_pdata codec_data = {
1621-
.ops = &mtk_hdmi_audio_codec_ops,
1629+
.ops = hdmi->conf->ver_conf->codec_ops,
16221630
.max_i2s_channels = 2,
16231631
.i2s = 1,
16241632
.data = hdmi,
@@ -1651,24 +1659,32 @@ static int mtk_hdmi_register_audio_driver(struct device *dev)
16511659

16521660
static int mtk_hdmi_probe(struct platform_device *pdev)
16531661
{
1662+
const struct mtk_hdmi_ver_conf *ver_conf;
1663+
const struct mtk_hdmi_conf *hdmi_conf;
16541664
struct mtk_hdmi *hdmi;
16551665
struct device *dev = &pdev->dev;
1656-
const int num_clocks = MTK_HDMI_CLK_COUNT;
16571666
int ret;
16581667

1668+
hdmi_conf = of_device_get_match_data(dev);
1669+
if (!hdmi_conf)
1670+
return -ENODEV;
1671+
1672+
ver_conf = hdmi_conf->ver_conf;
1673+
16591674
hdmi = devm_drm_bridge_alloc(dev, struct mtk_hdmi, bridge,
1660-
&mtk_hdmi_bridge_funcs);
1675+
ver_conf->bridge_funcs);
16611676
if (IS_ERR(hdmi))
16621677
return PTR_ERR(hdmi);
16631678

16641679
hdmi->dev = dev;
1665-
hdmi->conf = of_device_get_match_data(dev);
1680+
hdmi->conf = hdmi_conf;
16661681

1667-
hdmi->clk = devm_kcalloc(dev, num_clocks, sizeof(*hdmi->clk), GFP_KERNEL);
1682+
hdmi->clk = devm_kcalloc(dev, ver_conf->num_clocks, sizeof(*hdmi->clk), GFP_KERNEL);
16681683
if (!hdmi->clk)
16691684
return -ENOMEM;
16701685

1671-
ret = mtk_hdmi_dt_parse_pdata(hdmi, pdev, mtk_hdmi_clk_names, num_clocks);
1686+
ret = mtk_hdmi_dt_parse_pdata(hdmi, pdev, ver_conf->mtk_hdmi_clock_names,
1687+
ver_conf->num_clocks);
16721688
if (ret)
16731689
return ret;
16741690

@@ -1729,19 +1745,32 @@ static __maybe_unused int mtk_hdmi_resume(struct device *dev)
17291745

17301746
static SIMPLE_DEV_PM_OPS(mtk_hdmi_pm_ops, mtk_hdmi_suspend, mtk_hdmi_resume);
17311747

1748+
static const struct mtk_hdmi_ver_conf mtk_hdmi_v1_ver_conf = {
1749+
.bridge_funcs = &mtk_hdmi_bridge_funcs,
1750+
.codec_ops = &mtk_hdmi_audio_codec_ops,
1751+
.mtk_hdmi_clock_names = mtk_hdmi_clk_names,
1752+
.num_clocks = ARRAY_SIZE(mtk_hdmi_clk_names)
1753+
};
1754+
17321755
static const struct mtk_hdmi_conf mtk_hdmi_conf_mt2701 = {
17331756
.tz_disabled = true,
1757+
.ver_conf = &mtk_hdmi_v1_ver_conf
17341758
};
17351759

17361760
static const struct mtk_hdmi_conf mtk_hdmi_conf_mt8167 = {
1737-
.max_mode_clock = 148500,
17381761
.cea_modes_only = true,
1762+
.max_mode_clock = 148500,
1763+
.ver_conf = &mtk_hdmi_v1_ver_conf
1764+
};
1765+
1766+
static const struct mtk_hdmi_conf mtk_hdmi_conf_mt8173 = {
1767+
.ver_conf = &mtk_hdmi_v1_ver_conf
17391768
};
17401769

17411770
static const struct of_device_id mtk_hdmi_of_ids[] = {
17421771
{ .compatible = "mediatek,mt2701-hdmi", .data = &mtk_hdmi_conf_mt2701 },
17431772
{ .compatible = "mediatek,mt8167-hdmi", .data = &mtk_hdmi_conf_mt8167 },
1744-
{ .compatible = "mediatek,mt8173-hdmi" },
1773+
{ .compatible = "mediatek,mt8173-hdmi", .data = &mtk_hdmi_conf_mt8173 },
17451774
{ /* sentinel */ }
17461775
};
17471776
MODULE_DEVICE_TABLE(of, mtk_hdmi_of_ids);

0 commit comments

Comments
 (0)