Skip to content

Commit 0d68b55

Browse files
yangliankun1Chun-Kuang Hu
authored andcommitted
drm/mediatek: Fix mode valid issue for dp
Fix dp mode valid issue to avoid abnormal display of limit state. After DP passes link training, it can express the lane count of the current link status is good. Calculate the maximum bandwidth supported by DP using the current lane count. The color format will select the best one based on the bandwidth requirements of the current timing mode. If the current timing mode uses RGB and meets the DP link bandwidth requirements, RGB will be used. If the timing mode uses RGB but does not meet the DP link bandwidthi requirements, it will continue to check whether YUV422 meets the DP link bandwidth. FEC overhead is approximately 2.4% from DP 1.4a spec 2.2.1.4.2. The down-spread amplitude shall either be disabled (0.0%) or up to 0.5% from 1.4a 3.5.2.6. Add up to approximately 3% total overhead. Because rate is already divided by 10, mode->clock does not need to be multiplied by 10. Fixes: f70ac09 ("drm/mediatek: Add MT8195 Embedded DisplayPort driver") Signed-off-by: Liankun Yang <[email protected]> Link: https://patchwork.kernel.org/project/dri-devel/patch/[email protected]/ Signed-off-by: Chun-Kuang Hu <[email protected]>
1 parent ef24fbd commit 0d68b55

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

drivers/gpu/drm/mediatek/mtk_dp.c

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2411,12 +2411,19 @@ mtk_dp_bridge_mode_valid(struct drm_bridge *bridge,
24112411
{
24122412
struct mtk_dp *mtk_dp = mtk_dp_from_bridge(bridge);
24132413
u32 bpp = info->color_formats & DRM_COLOR_FORMAT_YCBCR422 ? 16 : 24;
2414-
u32 rate = min_t(u32, drm_dp_max_link_rate(mtk_dp->rx_cap) *
2415-
drm_dp_max_lane_count(mtk_dp->rx_cap),
2416-
drm_dp_bw_code_to_link_rate(mtk_dp->max_linkrate) *
2417-
mtk_dp->max_lanes);
2414+
u32 lane_count_min = mtk_dp->train_info.lane_count;
2415+
u32 rate = drm_dp_bw_code_to_link_rate(mtk_dp->train_info.link_rate) *
2416+
lane_count_min;
24182417

2419-
if (rate < mode->clock * bpp / 8)
2418+
/*
2419+
*FEC overhead is approximately 2.4% from DP 1.4a spec 2.2.1.4.2.
2420+
*The down-spread amplitude shall either be disabled (0.0%) or up
2421+
*to 0.5% from 1.4a 3.5.2.6. Add up to approximately 3% total overhead.
2422+
*
2423+
*Because rate is already divided by 10,
2424+
*mode->clock does not need to be multiplied by 10
2425+
*/
2426+
if ((rate * 97 / 100) < (mode->clock * bpp / 8))
24202427
return MODE_CLOCK_HIGH;
24212428

24222429
return MODE_OK;
@@ -2457,10 +2464,9 @@ static u32 *mtk_dp_bridge_atomic_get_input_bus_fmts(struct drm_bridge *bridge,
24572464
struct drm_display_mode *mode = &crtc_state->adjusted_mode;
24582465
struct drm_display_info *display_info =
24592466
&conn_state->connector->display_info;
2460-
u32 rate = min_t(u32, drm_dp_max_link_rate(mtk_dp->rx_cap) *
2461-
drm_dp_max_lane_count(mtk_dp->rx_cap),
2462-
drm_dp_bw_code_to_link_rate(mtk_dp->max_linkrate) *
2463-
mtk_dp->max_lanes);
2467+
u32 lane_count_min = mtk_dp->train_info.lane_count;
2468+
u32 rate = drm_dp_bw_code_to_link_rate(mtk_dp->train_info.link_rate) *
2469+
lane_count_min;
24642470

24652471
*num_input_fmts = 0;
24662472

@@ -2469,8 +2475,8 @@ static u32 *mtk_dp_bridge_atomic_get_input_bus_fmts(struct drm_bridge *bridge,
24692475
* datarate of YUV422 and sink device supports YUV422, we output YUV422
24702476
* format. Use this condition, we can support more resolution.
24712477
*/
2472-
if ((rate < (mode->clock * 24 / 8)) &&
2473-
(rate > (mode->clock * 16 / 8)) &&
2478+
if (((rate * 97 / 100) < (mode->clock * 24 / 8)) &&
2479+
((rate * 97 / 100) > (mode->clock * 16 / 8)) &&
24742480
(display_info->color_formats & DRM_COLOR_FORMAT_YCBCR422)) {
24752481
input_fmts = kcalloc(1, sizeof(*input_fmts), GFP_KERNEL);
24762482
if (!input_fmts)

0 commit comments

Comments
 (0)