phy: rockchip: samsung-hdptx: Extend rk_hdptx_phy_verify_hdmi_config() helper

In order to facilitate introduction of HDMI 2.1 FRL support and to avoid
recomputing the link rate after verifying the HDMI configuration given
as input, extend rk_hdptx_phy_verify_hdmi_config() by providing an
optional output parameter to store the validated configuration.

For improved code readability, also rename the existing hdmi input
parameter.

Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
Link: https://patch.msgid.link/20260113-phy-hdptx-frl-v6-10-8d5f97419c0b@collabora.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
This commit is contained in:
Cristian Ciocaltea
2026-01-13 01:20:57 +02:00
committed by Vinod Koul
parent ac079c1207
commit b14fec4dbd

View File

@@ -1439,25 +1439,24 @@ static int rk_hdptx_phy_power_off(struct phy *phy)
}
static int rk_hdptx_phy_verify_hdmi_config(struct rk_hdptx_phy *hdptx,
struct phy_configure_opts_hdmi *hdmi)
struct phy_configure_opts_hdmi *hdmi_in,
struct rk_hdptx_hdmi_cfg *hdmi_out)
{
int i;
if (!hdmi->tmds_char_rate || hdmi->tmds_char_rate > HDMI20_MAX_RATE)
if (!hdmi_in->tmds_char_rate || hdmi_in->tmds_char_rate > HDMI20_MAX_RATE)
return -EINVAL;
for (i = 0; i < ARRAY_SIZE(rk_hdptx_tmds_ropll_cfg); i++)
if (hdmi->tmds_char_rate == rk_hdptx_tmds_ropll_cfg[i].rate)
if (hdmi_in->tmds_char_rate == rk_hdptx_tmds_ropll_cfg[i].rate)
break;
if (i == ARRAY_SIZE(rk_hdptx_tmds_ropll_cfg) &&
!rk_hdptx_phy_clk_pll_calc(hdmi->tmds_char_rate, NULL))
!rk_hdptx_phy_clk_pll_calc(hdmi_in->tmds_char_rate, NULL))
return -EINVAL;
if (!hdmi->bpc)
hdmi->bpc = 8;
switch (hdmi->bpc) {
switch (hdmi_in->bpc) {
case 0:
case 8:
case 10:
case 12:
@@ -1467,6 +1466,11 @@ static int rk_hdptx_phy_verify_hdmi_config(struct rk_hdptx_phy *hdptx,
return -EINVAL;
}
if (hdmi_out) {
hdmi_out->rate = hdmi_in->tmds_char_rate;
hdmi_out->bpc = hdmi_in->bpc ?: 8;
}
return 0;
}
@@ -1732,17 +1736,15 @@ static int rk_hdptx_phy_configure(struct phy *phy, union phy_configure_opts *opt
int ret;
if (mode != PHY_MODE_DP) {
ret = rk_hdptx_phy_verify_hdmi_config(hdptx, &opts->hdmi);
ret = rk_hdptx_phy_verify_hdmi_config(hdptx, &opts->hdmi, &hdptx->hdmi_cfg);
if (ret) {
dev_err(hdptx->dev, "invalid hdmi params for phy configure\n");
} else {
hdptx->hdmi_cfg.rate = opts->hdmi.tmds_char_rate;
hdptx->hdmi_cfg.bpc = opts->hdmi.bpc;
hdptx->restrict_rate_change = true;
dev_dbg(hdptx->dev, "%s rate=%llu bpc=%u\n", __func__,
hdptx->hdmi_cfg.rate, hdptx->hdmi_cfg.bpc);
}
dev_dbg(hdptx->dev, "%s rate=%llu bpc=%u\n", __func__,
hdptx->hdmi_cfg.rate, hdptx->hdmi_cfg.bpc);
return ret;
}
@@ -1786,7 +1788,7 @@ static int rk_hdptx_phy_validate(struct phy *phy, enum phy_mode mode,
struct rk_hdptx_phy *hdptx = phy_get_drvdata(phy);
if (mode != PHY_MODE_DP)
return rk_hdptx_phy_verify_hdmi_config(hdptx, &opts->hdmi);
return rk_hdptx_phy_verify_hdmi_config(hdptx, &opts->hdmi, NULL);
return rk_hdptx_phy_verify_dp_config(hdptx, &opts->dp);
}
@@ -1926,12 +1928,11 @@ static int rk_hdptx_phy_clk_determine_rate(struct clk_hw *hw,
struct phy_configure_opts_hdmi hdmi = {
.tmds_char_rate = req->rate,
};
int ret = rk_hdptx_phy_verify_hdmi_config(hdptx, &hdmi);
int ret = rk_hdptx_phy_verify_hdmi_config(hdptx, &hdmi, &hdptx->hdmi_cfg);
if (ret)
return ret;
hdptx->hdmi_cfg.rate = req->rate;
}
/*