drivers: video: tegra: dc: Fix VIC for a few modes
Naveen Kumar S [Fri, 20 Nov 2015 14:15:10 +0000 (19:15 +0530)]
This change fixes the VIC not being set correctly on a few modes. For
1000/1001 modes, the pixclock is now reverted back to the mode
corresponding to the CEA modedb before it is compared.

Since the refresh in the mode database is also not trustable, it
compares the modes from the CEA modedb with a +/- 1 offset

Bug 200148145
Bug 200145631
Bug 1689283

Change-Id: I3742b4d090c26d6c1fc3e2f4af44fd1389079d1a
Signed-off-by: Naveen Kumar S <nkumars@nvidia.com>
Reviewed-on: http://git-master/r/837681
Reviewed-by: Tao Xie <txie@nvidia.com>
Reviewed-by: Manish Tuteja <mtuteja@nvidia.com>
Tested-by: Manish Tuteja <mtuteja@nvidia.com>

drivers/video/tegra/dc/hdmi2.0.c

index bfa9158..404f35d 100644 (file)
@@ -1117,6 +1117,11 @@ static void tegra_hdmi_get_cea_fb_videomode(struct fb_videomode *m,
                dc_mode.pclk = (dc_mode.pclk / 5) * 8;
        }
 
+       if (dc_mode.vmode & FB_VMODE_1000DIV1001) {
+               dc_mode.pclk = DIV_ROUND_UP((u64)dc_mode.pclk * 1001,  1000);
+               dc_mode.vmode &= ~FB_VMODE_1000DIV1001;
+       }
+
        tegra_dc_to_fb_videomode(m, &dc_mode);
 
        /* only interlaced required for VIC identification */
@@ -1148,7 +1153,20 @@ static int tegra_hdmi_find_cea_vic(struct tegra_hdmi *hdmi)
        for (i = 1; i < modedb_size; i++) {
                const struct fb_videomode *curr = &cea_modes[i];
 
-               if (!fb_mode_is_equal(&m, curr))
+               if (!((m.refresh == curr->refresh ||
+                      m.refresh + 1 == curr->refresh ||
+                      m.refresh == curr->refresh + 1) &&
+                     m.xres         == curr->xres &&
+                     m.yres         == curr->yres &&
+                     m.pixclock     == curr->pixclock &&
+                     m.hsync_len    == curr->hsync_len &&
+                     m.vsync_len    == curr->vsync_len &&
+                     m.left_margin  == curr->left_margin &&
+                     m.right_margin == curr->right_margin &&
+                     m.upper_margin == curr->upper_margin &&
+                     m.lower_margin == curr->lower_margin &&
+                     m.sync         == curr->sync &&
+                     m.vmode        == curr->vmode))
                        continue;
 
                if (!best)