Skip to content

Commit d19d5b8

Browse files
author
Abhinav Kumar
committed
drm/msm/dp: fix the max supported bpp logic
Fix the dp_panel_get_supported_bpp() API to return the minimum supported bpp correctly for relevant cases and use this API to correct the behavior of DP driver which hard-codes the max supported bpp to 30. This is incorrect because the number of lanes and max data rate supported by the lanes need to be taken into account. Replace the hardcoded limit with the appropriate math which accounts for the accurate number of lanes and max data rate. changes in v2: - Fix the dp_panel_get_supported_bpp() and use it - Drop the max_t usage as dp_panel_get_supported_bpp() already returns the min_bpp correctly now changes in v3: - replace min_t with just min as all params are u32 Fixes: c943b49 ("drm/msm/dp: add displayPort driver support") Reported-by: Dmitry Baryshkov <[email protected]> Closes: https://gitlab.freedesktop.org/drm/msm/-/issues/43 Tested-by: Dmitry Baryshkov <[email protected]> # SM8350-HDK Reviewed-by: Stephen Boyd <[email protected]> Patchwork: https://patchwork.freedesktop.org/patch/607073/ Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Stephen Boyd <[email protected]> Signed-off-by: Abhinav Kumar <[email protected]>
1 parent df24373 commit d19d5b8

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

drivers/gpu/drm/msm/dp/dp_panel.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,22 +90,22 @@ static int dp_panel_read_dpcd(struct dp_panel *dp_panel)
9090
static u32 dp_panel_get_supported_bpp(struct dp_panel *dp_panel,
9191
u32 mode_edid_bpp, u32 mode_pclk_khz)
9292
{
93-
struct dp_link_info *link_info;
93+
const struct dp_link_info *link_info;
9494
const u32 max_supported_bpp = 30, min_supported_bpp = 18;
95-
u32 bpp = 0, data_rate_khz = 0;
95+
u32 bpp, data_rate_khz;
9696

97-
bpp = min_t(u32, mode_edid_bpp, max_supported_bpp);
97+
bpp = min(mode_edid_bpp, max_supported_bpp);
9898

9999
link_info = &dp_panel->link_info;
100100
data_rate_khz = link_info->num_lanes * link_info->rate * 8;
101101

102-
while (bpp > min_supported_bpp) {
102+
do {
103103
if (mode_pclk_khz * bpp <= data_rate_khz)
104-
break;
104+
return bpp;
105105
bpp -= 6;
106-
}
106+
} while (bpp > min_supported_bpp);
107107

108-
return bpp;
108+
return min_supported_bpp;
109109
}
110110

111111
int dp_panel_read_sink_caps(struct dp_panel *dp_panel,
@@ -423,8 +423,9 @@ int dp_panel_init_panel_info(struct dp_panel *dp_panel)
423423
drm_mode->clock);
424424
drm_dbg_dp(panel->drm_dev, "bpp = %d\n", dp_panel->dp_mode.bpp);
425425

426-
dp_panel->dp_mode.bpp = max_t(u32, 18,
427-
min_t(u32, dp_panel->dp_mode.bpp, 30));
426+
dp_panel->dp_mode.bpp = dp_panel_get_mode_bpp(dp_panel, dp_panel->dp_mode.bpp,
427+
dp_panel->dp_mode.drm_mode.clock);
428+
428429
drm_dbg_dp(panel->drm_dev, "updated bpp = %d\n",
429430
dp_panel->dp_mode.bpp);
430431

0 commit comments

Comments
 (0)