summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDonghan Ryu <dryu@nvidia.com>2011-06-14 17:45:08 +0900
committerManish Tuteja <mtuteja@nvidia.com>2011-08-02 00:18:12 -0700
commitff4babd883b8eb2028ebfabbf68a65d7b0d7f107 (patch)
tree364a17e759bd770d49d7ebd4d98cd57af1694a03
parent33a27f8e7f016a2530b85acda8d100d4139e0044 (diff)
video: tegra: dc: fix hdmi mode filter
If there are more than one hdmi modes that have same xres, yres, and vmode, tegra_dc_hdmi_mode_equal can return true even though pixclocks are way different from each other. Now, tegra_dc_hdmi_mode_equal will retun false if pixclock has more than 1Hz of difference. Also, tegra_fb_set_par will use fb_find_nearest_mode instead of fb_find_best_mode to take refresh rate into the consideration. Bug: 815409 Reviewed-on: http://git-master/r/36464 (cherry picked from commit 8cf6e47dd3d4efaa3a1f0a15f1bd36ad34d3a951) Change-Id: I14fbfba832bd130c7f04369b360d48fbbfad3d7b Signed-off-by: Sanjay Singh Rawat <srawat@nvidia.com> Reviewed-on: http://git-master/r/43655 Reviewed-by: Manish Tuteja <mtuteja@nvidia.com> Tested-by: Manish Tuteja <mtuteja@nvidia.com>
-rw-r--r--drivers/video/tegra/dc/hdmi.c23
-rw-r--r--drivers/video/tegra/fb.c5
2 files changed, 23 insertions, 5 deletions
diff --git a/drivers/video/tegra/dc/hdmi.c b/drivers/video/tegra/dc/hdmi.c
index c93b3c4c72f1..871560f95e40 100644
--- a/drivers/video/tegra/dc/hdmi.c
+++ b/drivers/video/tegra/dc/hdmi.c
@@ -488,11 +488,23 @@ static void hdmi_dumpregs(struct tegra_dc_hdmi_data *hdmi)
#define PIXCLOCK_TOLERANCE 200
+static int tegra_dc_calc_clock_per_frame(const struct fb_videomode *mode)
+{
+ return (mode->left_margin + mode->xres +
+ mode->right_margin + mode->hsync_len) *
+ (mode->upper_margin + mode->yres +
+ mode->lower_margin + mode->vsync_len);
+}
static bool tegra_dc_hdmi_mode_equal(const struct fb_videomode *mode1,
const struct fb_videomode *mode2)
{
+ int clock_per_frame = tegra_dc_calc_clock_per_frame(mode1);
+
+ /* allows up to 1Hz of pixclock difference */
return mode1->xres == mode2->xres &&
mode1->yres == mode2->yres &&
+ (abs(PICOS2KHZ(mode1->pixclock - mode2->pixclock)) *
+ 1000 / clock_per_frame <= 1) &&
mode1->vmode == mode2->vmode;
}
@@ -512,16 +524,19 @@ static bool tegra_dc_hdmi_mode_filter(const struct tegra_dc *dc,
struct fb_videomode *mode)
{
int i;
- int clocks;
+ int clock_per_frame;
+
+ if (!mode->pixclock)
+ return false;
for (i = 0; i < ARRAY_SIZE(tegra_dc_hdmi_supported_modes); i++) {
if (tegra_dc_hdmi_mode_equal(&tegra_dc_hdmi_supported_modes[i], mode) &&
tegra_dc_hdmi_valid_pixclock(dc, &tegra_dc_hdmi_supported_modes[i])) {
memcpy(mode, &tegra_dc_hdmi_supported_modes[i], sizeof(*mode));
mode->flag = FB_MODE_IS_DETAILED;
- clocks = (mode->left_margin + mode->xres + mode->right_margin + mode->hsync_len) *
- (mode->upper_margin + mode->yres + mode->lower_margin + mode->vsync_len);
- mode->refresh = (PICOS2KHZ(mode->pixclock) * 1000) / clocks;
+ clock_per_frame = tegra_dc_calc_clock_per_frame(mode);
+ mode->refresh = (PICOS2KHZ(mode->pixclock) * 1000)
+ / clock_per_frame;
return true;
}
}
diff --git a/drivers/video/tegra/fb.c b/drivers/video/tegra/fb.c
index 1b1952b774b3..1f628d51c5af 100644
--- a/drivers/video/tegra/fb.c
+++ b/drivers/video/tegra/fb.c
@@ -175,9 +175,12 @@ static int tegra_fb_set_par(struct fb_info *info)
if (var->pixclock) {
struct tegra_dc_mode mode;
+ struct fb_videomode m;
+
+ fb_var_to_videomode(&m, var);
info->mode = (struct fb_videomode *)
- fb_find_best_mode(var, &info->modelist);
+ fb_find_nearest_mode(&m, &info->modelist);
if (!info->mode) {
dev_warn(&tegra_fb->ndev->dev, "can't match video mode\n");
return -EINVAL;