diff options
Diffstat (limited to 'drivers/video/tegra/dc/mode.c')
-rw-r--r-- | drivers/video/tegra/dc/mode.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/drivers/video/tegra/dc/mode.c b/drivers/video/tegra/dc/mode.c index 49cc5f5abd53..3a95f2e7ab0e 100644 --- a/drivers/video/tegra/dc/mode.c +++ b/drivers/video/tegra/dc/mode.c @@ -137,6 +137,17 @@ static bool check_ref_to_sync(struct tegra_dc_mode *mode) return true; } +static s64 calc_frametime_ns(const struct tegra_dc_mode *m) +{ + long h_total, v_total; + h_total = m->h_active + m->h_front_porch + m->h_back_porch + + m->h_sync_width; + v_total = m->v_active + m->v_front_porch + m->v_back_porch + + m->v_sync_width; + return (!m->pclk) ? 0 : (s64)(div_s64(((s64)h_total * v_total * + 1000000000ULL), m->pclk)); +} + /* return in 1000ths of a Hertz */ int tegra_dc_calc_refresh(const struct tegra_dc_mode *m) { @@ -247,11 +258,25 @@ int tegra_dc_program_mode(struct tegra_dc *dc, struct tegra_dc_mode *mode) return 0; } +static int panel_sync_rate; + +int tegra_dc_get_panel_sync_rate(void) +{ + return panel_sync_rate; +} +EXPORT_SYMBOL(tegra_dc_get_panel_sync_rate); + int tegra_dc_set_mode(struct tegra_dc *dc, const struct tegra_dc_mode *mode) { memcpy(&dc->mode, mode, sizeof(dc->mode)); + if (dc->out->type == TEGRA_DC_OUT_RGB) + panel_sync_rate = tegra_dc_calc_refresh(mode); + else if (dc->out->type == TEGRA_DC_OUT_DSI) + panel_sync_rate = dc->out->dsi->rated_refresh_rate * 1000; + print_mode(dc, mode, __func__); + dc->frametime_ns = calc_frametime_ns(mode); return 0; } |