Skip to content

Commit d2b58a1

Browse files
cristiccgregkh
authored andcommitted
drm/rockchip: vop2: Improve display modes handling on RK3588 HDMI0
[ Upstream commit 2c1268e ] The RK3588 specific implementation is currently quite limited in terms of handling the full range of display modes supported by the connected screens, e.g. 2560x1440@75Hz, 2048x1152@60Hz, 1024x768@60Hz are just a few of them. Additionally, it doesn't cope well with non-integer refresh rates like 59.94, 29.97, 23.98, etc. Make use of HDMI0 PHY PLL as a more accurate DCLK source to handle all display modes up to 4K@60Hz. Tested-by: FUKAUMI Naoki <[email protected]> Signed-off-by: Cristian Ciocaltea <[email protected]> Signed-off-by: Heiko Stuebner <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Signed-off-by: Sasha Levin <[email protected]>
1 parent 91c53b8 commit d2b58a1

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

drivers/gpu/drm/rockchip/rockchip_drm_vop2.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ struct vop2_video_port {
157157
struct drm_crtc crtc;
158158
struct vop2 *vop2;
159159
struct clk *dclk;
160+
struct clk *dclk_src;
160161
unsigned int id;
161162
const struct vop2_video_port_data *data;
162163

@@ -211,6 +212,7 @@ struct vop2 {
211212
struct clk *hclk;
212213
struct clk *aclk;
213214
struct clk *pclk;
215+
struct clk *pll_hdmiphy0;
214216

215217
/* optional internal rgb encoder */
216218
struct rockchip_rgb *rgb;
@@ -219,6 +221,8 @@ struct vop2 {
219221
struct vop2_win win[];
220222
};
221223

224+
#define VOP2_MAX_DCLK_RATE 600000000
225+
222226
#define vop2_output_if_is_hdmi(x) ((x) == ROCKCHIP_VOP2_EP_HDMI0 || \
223227
(x) == ROCKCHIP_VOP2_EP_HDMI1)
224228

@@ -1051,6 +1055,9 @@ static void vop2_crtc_atomic_disable(struct drm_crtc *crtc,
10511055

10521056
vop2_crtc_disable_irq(vp, VP_INT_DSP_HOLD_VALID);
10531057

1058+
if (vp->dclk_src)
1059+
clk_set_parent(vp->dclk, vp->dclk_src);
1060+
10541061
clk_disable_unprepare(vp->dclk);
10551062

10561063
vop2->enable_count--;
@@ -2071,6 +2078,27 @@ static void vop2_crtc_atomic_enable(struct drm_crtc *crtc,
20712078

20722079
vop2_vp_write(vp, RK3568_VP_MIPI_CTRL, 0);
20732080

2081+
/*
2082+
* Switch to HDMI PHY PLL as DCLK source for display modes up
2083+
* to 4K@60Hz, if available, otherwise keep using the system CRU.
2084+
*/
2085+
if (vop2->pll_hdmiphy0 && clock <= VOP2_MAX_DCLK_RATE) {
2086+
drm_for_each_encoder_mask(encoder, crtc->dev, crtc_state->encoder_mask) {
2087+
struct rockchip_encoder *rkencoder = to_rockchip_encoder(encoder);
2088+
2089+
if (rkencoder->crtc_endpoint_id == ROCKCHIP_VOP2_EP_HDMI0) {
2090+
if (!vp->dclk_src)
2091+
vp->dclk_src = clk_get_parent(vp->dclk);
2092+
2093+
ret = clk_set_parent(vp->dclk, vop2->pll_hdmiphy0);
2094+
if (ret < 0)
2095+
drm_warn(vop2->drm,
2096+
"Could not switch to HDMI0 PHY PLL: %d\n", ret);
2097+
break;
2098+
}
2099+
}
2100+
}
2101+
20742102
clk_set_rate(vp->dclk, clock);
20752103

20762104
vop2_post_config(crtc);
@@ -3242,6 +3270,12 @@ static int vop2_bind(struct device *dev, struct device *master, void *data)
32423270
return PTR_ERR(vop2->pclk);
32433271
}
32443272

3273+
vop2->pll_hdmiphy0 = devm_clk_get_optional(vop2->dev, "pll_hdmiphy0");
3274+
if (IS_ERR(vop2->pll_hdmiphy0)) {
3275+
drm_err(vop2->drm, "failed to get pll_hdmiphy0\n");
3276+
return PTR_ERR(vop2->pll_hdmiphy0);
3277+
}
3278+
32453279
vop2->irq = platform_get_irq(pdev, 0);
32463280
if (vop2->irq < 0) {
32473281
drm_err(vop2->drm, "cannot find irq for vop2\n");

0 commit comments

Comments
 (0)