mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-09-04 20:19:47 +08:00
phy: freescale: fsl-samsung-hdmi: Improve LUT search for best clock
Searching the look-up-table runs so long as the frequency in the table is at or below the desired rate. This works well in most cases, but the next entry in the LUT might be closer to the nominal value than the lower one. Add some logic to check the higer value is any closer to the nominal value and use it. Signed-off-by: Adam Ford <aford173@gmail.com> Link: https://lore.kernel.org/r/20250504204043.418924-3-aford173@gmail.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
This commit is contained in:
parent
41db462334
commit
46a87260fc
@ -510,7 +510,14 @@ static const struct phy_config *fsl_samsung_hdmi_phy_lookup_rate(unsigned long r
|
|||||||
if (phy_pll_cfg[i].pixclk <= rate)
|
if (phy_pll_cfg[i].pixclk <= rate)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
/* If there is an exact match, or the array has been searched, return the value*/
|
||||||
|
if (phy_pll_cfg[i].pixclk == rate || i + 1 > ARRAY_SIZE(phy_pll_cfg) - 1)
|
||||||
return &phy_pll_cfg[i];
|
return &phy_pll_cfg[i];
|
||||||
|
|
||||||
|
/* See if the next entry is closer to nominal than this one */
|
||||||
|
return (abs((long) rate - (long) phy_pll_cfg[i].pixclk) <
|
||||||
|
abs((long) rate - (long) phy_pll_cfg[i+1].pixclk) ?
|
||||||
|
&phy_pll_cfg[i] : &phy_pll_cfg[i+1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fsl_samsung_hdmi_calculate_phy(struct phy_config *cal_phy, unsigned long rate,
|
static void fsl_samsung_hdmi_calculate_phy(struct phy_config *cal_phy, unsigned long rate,
|
||||||
|
Loading…
Reference in New Issue
Block a user