Re: [PATCH] phy: freescale: fsl-samsung-hdmi: return closest rate instead LUT
From: Frieder Schrempf
Date: Mon Mar 10 2025 - 05:32:57 EST
On 10.03.25 2:21 AM, Dominique Martinet wrote:
> From: Makoto Sato <makoto.sato@xxxxxxxxxxxxxxxxx>
>
> If the requested rate is not an exact match of the integer divider
> phy_clk_round_rate() would return the look up table value,
> but phy_clk_set_rate() can still use the integer divider if it results
> in a frequency that is closer than the look up table.
>
> In particular, not returning the actually used value here made the hdmi
> bridge driver reject a frequency that has an integer divider rate
> within 0.5% of the target:
> for 83.5mHz, the integer divider generates 83.2mHz (-0.36%), but the
> next LUT value (82.5mHz) is 1.2% off which incorrectly rejects modes
> requiring this frequency.
>
> This commit updates phy_clk_round_rate() to use the same logic as the
> set operation.
>
> Signed-off-by: Makoto Sato <makoto.sato@xxxxxxxxxxxxxxxxx>
> Signed-off-by: Dominique Martinet <dominique.martinet@xxxxxxxxxxxxxxxxx>
This looks good to me.
Reviewed-by: Frieder Schrempf <frieder.schrempf@xxxxxxxxxx>
But I think we should also add the following Fixes tag:
Fixes: 058ea4a06704 ("phy: freescale: fsl-samsung-hdmi: Use closest
divider")
> ---
> We're finally using this rewrite in our (outdated) tree and noticed the
> "best" mode missing on one of our picky displays.
> It all looks good with this fix, thanks again!
> ---
> drivers/phy/freescale/phy-fsl-samsung-hdmi.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/phy/freescale/phy-fsl-samsung-hdmi.c b/drivers/phy/freescale/phy-fsl-samsung-hdmi.c
> index e4c0a82d16d9ef0f64ebf9e505b8620423cdc416..91c4d27a31f48fc49f1e8417d7089f5519b8a0a2 100644
> --- a/drivers/phy/freescale/phy-fsl-samsung-hdmi.c
> +++ b/drivers/phy/freescale/phy-fsl-samsung-hdmi.c
> @@ -557,8 +557,9 @@ static long phy_clk_round_rate(struct clk_hw *hw,
> if (int_div_clk == rate)
> return int_div_clk;
>
> - /* If neither rate is an exact match, use the value from the LUT */
> - return fract_div_phy->pixclk;
> + /* If neither rate is an exact match, use the closest value */
> + return fsl_samsung_hdmi_phy_get_closest_rate(rate, int_div_clk,
> + fract_div_phy->pixclk);
> }
>
> static int phy_use_fract_div(struct fsl_samsung_hdmi_phy *phy, const struct phy_config *fract_div_phy)
>
> ---
> base-commit: 80e54e84911a923c40d7bee33a34c1b4be148d7a
> change-id: 20250310-8ulp_hdmi-f8deac08611e
>
> Best regards,