Skip to content

Commit 3303a20

Browse files
Kwiboommind
authored andcommitted
drm/rockchip: dw_hdmi: Filter modes based on hdmiphy_clk
RK3228 and RK3328 clock rate is being validated against a mpll config table intended for a Synopsys phy, and not the used inno-hdmi-phy. Instead get a reference to the hdmiphy clk and validate rates against it to enable use of HDMI2.0 modes, e.g. 4K@60Hz, on RK3228 and RK3328. For Synopsis phy the max_tmds_clock validation is sufficient. Signed-off-by: Jonas Karlman <[email protected]> Tested-by: Diederik de Haas <[email protected]> # Rock64 Signed-off-by: Heiko Stuebner <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 87d4597 commit 3303a20

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ struct rockchip_hdmi {
7676
struct rockchip_encoder encoder;
7777
const struct rockchip_hdmi_chip_data *chip_data;
7878
const struct dw_hdmi_plat_data *plat_data;
79+
struct clk *hdmiphy_clk;
7980
struct clk *ref_clk;
8081
struct clk *grf_clk;
8182
struct dw_hdmi *hdmi;
@@ -251,10 +252,7 @@ dw_hdmi_rockchip_mode_valid(struct dw_hdmi *dw_hdmi, void *data,
251252
const struct drm_display_mode *mode)
252253
{
253254
struct rockchip_hdmi *hdmi = data;
254-
const struct dw_hdmi_mpll_config *mpll_cfg = rockchip_mpll_cfg;
255255
int pclk = mode->clock * 1000;
256-
bool exact_match = hdmi->plat_data->phy_force_vendor;
257-
int i;
258256

259257
if (hdmi->chip_data->max_tmds_clock &&
260258
mode->clock > hdmi->chip_data->max_tmds_clock)
@@ -263,26 +261,18 @@ dw_hdmi_rockchip_mode_valid(struct dw_hdmi *dw_hdmi, void *data,
263261
if (hdmi->ref_clk) {
264262
int rpclk = clk_round_rate(hdmi->ref_clk, pclk);
265263

266-
if (abs(rpclk - pclk) > pclk / 1000)
264+
if (rpclk < 0 || abs(rpclk - pclk) > pclk / 1000)
267265
return MODE_NOCLOCK;
268266
}
269267

270-
for (i = 0; mpll_cfg[i].mpixelclock != (~0UL); i++) {
271-
/*
272-
* For vendor specific phys force an exact match of the pixelclock
273-
* to preserve the original behaviour of the driver.
274-
*/
275-
if (exact_match && pclk == mpll_cfg[i].mpixelclock)
276-
return MODE_OK;
277-
/*
278-
* The Synopsys phy can work with pixelclocks up to the value given
279-
* in the corresponding mpll_cfg entry.
280-
*/
281-
if (!exact_match && pclk <= mpll_cfg[i].mpixelclock)
282-
return MODE_OK;
268+
if (hdmi->hdmiphy_clk) {
269+
int rpclk = clk_round_rate(hdmi->hdmiphy_clk, pclk);
270+
271+
if (rpclk < 0 || abs(rpclk - pclk) > pclk / 1000)
272+
return MODE_NOCLOCK;
283273
}
284274

285-
return MODE_BAD;
275+
return MODE_OK;
286276
}
287277

288278
static void dw_hdmi_rockchip_encoder_disable(struct drm_encoder *encoder)
@@ -607,6 +597,15 @@ static int dw_hdmi_rockchip_bind(struct device *dev, struct device *master,
607597
return ret;
608598
}
609599

600+
if (hdmi->phy) {
601+
struct of_phandle_args clkspec;
602+
603+
clkspec.np = hdmi->phy->dev.of_node;
604+
hdmi->hdmiphy_clk = of_clk_get_from_provider(&clkspec);
605+
if (IS_ERR(hdmi->hdmiphy_clk))
606+
hdmi->hdmiphy_clk = NULL;
607+
}
608+
610609
if (hdmi->chip_data == &rk3568_chip_data) {
611610
regmap_write(hdmi->regmap, RK3568_GRF_VO_CON1,
612611
HIWORD_UPDATE(RK3568_HDMI_SDAIN_MSK |

0 commit comments

Comments
 (0)