From c0e1c24799054961091df4e88c09be9828cb8220 Mon Sep 17 00:00:00 2001 From: Huaibin Yang Date: Mon, 10 Dec 2012 16:37:01 -0800 Subject: [PATCH] msm_fb: display: fix frame rate wrong calculation For cmd mode the frame rate calculation result is wrong. Also in mdp driver there are several places to do the same calculation. So fix the wrong calculation and use a single func to do calculation. Conflicts: drivers/video/msm/msm_fb.c Change-Id: I3a4be39e480ce82677dcefb666202947f7f6d3c1 Signed-off-by: Huaibin Yang (cherry picked from commit d4eb5a1a3ef0935ce6aeffb2b48974c01b9518b9) Signed-off-by: Neha Pandey --- drivers/video/msm/mdp.c | 53 ++++++++++++++++++++++++-------------- drivers/video/msm/msm_fb.c | 22 +--------------- 2 files changed, 35 insertions(+), 40 deletions(-) diff --git a/drivers/video/msm/mdp.c b/drivers/video/msm/mdp.c index 92ba51da990e..06ef1d1fd103 100644 --- a/drivers/video/msm/mdp.c +++ b/drivers/video/msm/mdp.c @@ -1419,32 +1419,47 @@ int mdp_ppp_pipe_wait(void) u32 mdp_get_panel_framerate(struct msm_fb_data_type *mfd) { - u32 frame_rate = 0, total_pixel; + u32 frame_rate = 0, pixel_rate = 0, total_pixel; struct msm_panel_info *panel_info = &mfd->panel_info; + + pixel_rate = + (panel_info->type == MIPI_CMD_PANEL || + panel_info->type == MIPI_VIDEO_PANEL) ? + panel_info->mipi.dsi_pclk_rate : + panel_info->clk_rate; + + if (!pixel_rate) + pr_warn("%s pixel rate is zero\n", __func__); + + total_pixel = + (panel_info->lcdc.h_back_porch + + panel_info->lcdc.h_front_porch + + panel_info->lcdc.h_pulse_width + + panel_info->xres) * + (panel_info->lcdc.v_back_porch + + panel_info->lcdc.v_front_porch + + panel_info->lcdc.v_pulse_width + + panel_info->yres); + + if (total_pixel) + frame_rate = pixel_rate / total_pixel; + else + pr_warn("%s total pixels are zero\n", __func__); + if (mfd->dest == DISPLAY_LCD) { if (panel_info->type == MDDI_PANEL && panel_info->mddi.is_type1) frame_rate = panel_info->lcd.refx100 / (100 * 2); - else + else if (panel_info->type != MIPI_CMD_PANEL) frame_rate = panel_info->lcd.refx100 / 100; - } else { - if (panel_info->type == MIPI_VIDEO_PANEL) { - frame_rate = panel_info->mipi.frame_rate; - } else { - total_pixel = (panel_info->lcdc.h_back_porch + - panel_info->lcdc.h_front_porch + - panel_info->lcdc.h_pulse_width + - panel_info->xres) * - (panel_info->lcdc.v_back_porch + - panel_info->lcdc.v_front_porch + - panel_info->lcdc.v_pulse_width + - panel_info->yres); - if (total_pixel) - frame_rate = panel_info->clk_rate / - total_pixel; - } } - if (frame_rate == 0) + + if (frame_rate == 0) { frame_rate = DEFAULT_FRAME_RATE; + pr_warn("%s frame rate=%d is default\n", __func__, frame_rate); + } + pr_debug("%s frame rate=%d total_pixel=%d, pixel_rate=%d\n", __func__, + frame_rate, total_pixel, pixel_rate); + return frame_rate; } diff --git a/drivers/video/msm/msm_fb.c b/drivers/video/msm/msm_fb.c index 44743bc1baa7..4fb2423f2cf3 100644 --- a/drivers/video/msm/msm_fb.c +++ b/drivers/video/msm/msm_fb.c @@ -1372,27 +1372,7 @@ static int msm_fb_register(struct msm_fb_data_type *mfd) var->yres_virtual = panel_info->yres * mfd->fb_page + ((PAGE_SIZE - remainder)/fix->line_length) * mfd->fb_page; var->bits_per_pixel = bpp * 8; /* FrameBuffer color depth */ - if (mfd->dest == DISPLAY_LCD) { - if (panel_info->type == MDDI_PANEL && panel_info->mddi.is_type1) - var->reserved[3] = panel_info->lcd.refx100 / (100 * 2); - else - var->reserved[3] = panel_info->lcd.refx100 / 100; - } else { - if (panel_info->type == MIPI_VIDEO_PANEL) { - var->reserved[3] = panel_info->mipi.frame_rate; - } else { - var->reserved[3] = panel_info->clk_rate / - ((panel_info->lcdc.h_back_porch + - panel_info->lcdc.h_front_porch + - panel_info->lcdc.h_pulse_width + - panel_info->xres) * - (panel_info->lcdc.v_back_porch + - panel_info->lcdc.v_front_porch + - panel_info->lcdc.v_pulse_width + - panel_info->yres)); - } - } - pr_debug("reserved[3] %u\n", var->reserved[3]); + var->reserved[3] = mdp_get_panel_framerate(mfd); /* * id field for fb app