]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
phy: rockchip: samsung-hdptx: Extend rk_hdptx_phy_verify_hdmi_config() helper
authorCristian Ciocaltea <cristian.ciocaltea@collabora.com>
Mon, 12 Jan 2026 23:20:57 +0000 (01:20 +0200)
committerVinod Koul <vkoul@kernel.org>
Wed, 21 Jan 2026 08:41:58 +0000 (14:11 +0530)
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>
drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c

index f1cad026495221f497fc1951c7729bae23ec34b1..c9942aaf2766ce64d66ef3518adc342110389a11 100644 (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;
        }
 
        /*