Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Adam Ford and committed by
Vinod Koul
46a87260 41db4623

+8 -1
+8 -1
drivers/phy/freescale/phy-fsl-samsung-hdmi.c
··· 510 510 if (phy_pll_cfg[i].pixclk <= rate) 511 511 break; 512 512 513 - return &phy_pll_cfg[i]; 513 + /* If there is an exact match, or the array has been searched, return the value*/ 514 + if (phy_pll_cfg[i].pixclk == rate || i + 1 > ARRAY_SIZE(phy_pll_cfg) - 1) 515 + return &phy_pll_cfg[i]; 516 + 517 + /* See if the next entry is closer to nominal than this one */ 518 + return (abs((long) rate - (long) phy_pll_cfg[i].pixclk) < 519 + abs((long) rate - (long) phy_pll_cfg[i+1].pixclk) ? 520 + &phy_pll_cfg[i] : &phy_pll_cfg[i+1]); 514 521 } 515 522 516 523 static void fsl_samsung_hdmi_calculate_phy(struct phy_config *cal_phy, unsigned long rate,