Skip to content

Commit 44b0712

Browse files
mtk-rex-bc-chenChun-Kuang Hu
authored andcommitted
drm/mediatek: dpi: Add check for max clock rate in mode_valid
Add per-platform max clock rate check in mtk_dpi_bridge_mode_valid. Signed-off-by: Pi-Hsun Shih <[email protected]> Signed-off-by: Rex-BC Chen <[email protected]> Signed-off-by: Jitao Shi <[email protected]> Signed-off-by: Chun-Kuang Hu <[email protected]>
1 parent ee5ee18 commit 44b0712

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

drivers/gpu/drm/mediatek/mtk_dpi.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ struct mtk_dpi_yc_limit {
120120
struct mtk_dpi_conf {
121121
unsigned int (*cal_factor)(int clock);
122122
u32 reg_h_fre_con;
123+
u32 max_clock_khz;
123124
bool edge_sel_en;
124125
};
125126

@@ -557,9 +558,23 @@ static void mtk_dpi_bridge_enable(struct drm_bridge *bridge)
557558
mtk_dpi_set_display_mode(dpi, &dpi->mode);
558559
}
559560

561+
static enum drm_mode_status
562+
mtk_dpi_bridge_mode_valid(struct drm_bridge *bridge,
563+
const struct drm_display_info *info,
564+
const struct drm_display_mode *mode)
565+
{
566+
struct mtk_dpi *dpi = bridge_to_dpi(bridge);
567+
568+
if (mode->clock > dpi->conf->max_clock_khz)
569+
return MODE_CLOCK_HIGH;
570+
571+
return MODE_OK;
572+
}
573+
560574
static const struct drm_bridge_funcs mtk_dpi_bridge_funcs = {
561575
.attach = mtk_dpi_bridge_attach,
562576
.mode_set = mtk_dpi_bridge_mode_set,
577+
.mode_valid = mtk_dpi_bridge_mode_valid,
563578
.disable = mtk_dpi_bridge_disable,
564579
.enable = mtk_dpi_bridge_enable,
565580
};
@@ -668,17 +683,20 @@ static unsigned int mt8183_calculate_factor(int clock)
668683
static const struct mtk_dpi_conf mt8173_conf = {
669684
.cal_factor = mt8173_calculate_factor,
670685
.reg_h_fre_con = 0xe0,
686+
.max_clock_khz = 300000,
671687
};
672688

673689
static const struct mtk_dpi_conf mt2701_conf = {
674690
.cal_factor = mt2701_calculate_factor,
675691
.reg_h_fre_con = 0xb0,
676692
.edge_sel_en = true,
693+
.max_clock_khz = 150000,
677694
};
678695

679696
static const struct mtk_dpi_conf mt8183_conf = {
680697
.cal_factor = mt8183_calculate_factor,
681698
.reg_h_fre_con = 0xe0,
699+
.max_clock_khz = 100000,
682700
};
683701

684702
static int mtk_dpi_probe(struct platform_device *pdev)

0 commit comments

Comments
 (0)