MLK-14857: mxc_hdmi: Set default mode a CEA mode
authorRobert Chiras <robert.chiras@nxp.com>
Thu, 11 May 2017 11:34:01 +0000 (14:34 +0300)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 20:22:17 +0000 (15:22 -0500)
When using fb_find_mode from fbdev/core with a specified user more,
it will return a screeninfo structure with the pixclock corresponding to
a different refresh rate than the requested one. For example, for
1920x1080@60 it will return pixclock=5780. When we get the videmode for
this screeninfo, it will have a refresh of 59Hz, instead of 60Hz.
If we use this mode as default mode when EDID cannot be read, on a
monitor with fixed refresh rate of 60Hz, it won't work. Therefore, we
should save the default mode, the nearest mode from CEA modes defined by
our own driver (which will have the correct refresh rate and pixclock for
the requested resolution).

Signed-off-by: Robert Chiras <robert.chiras@nxp.com>
drivers/video/fbdev/mxc/mxc_hdmi.c

index 467fe63..ebec8d2 100644 (file)
@@ -222,7 +222,7 @@ static inline int cpu_is_imx6dl(struct mxc_hdmi *hdmi)
        return hdmi->cpu_type == IMX6DL_HDMI;
 }
 #ifdef DEBUG
-static void dump_fb_videomode(struct fb_videomode *m)
+static void dump_fb_videomode(const struct fb_videomode *m)
 {
        pr_debug("fb_videomode = %d %d %d %d %d %d %d %d %d %d %d %d %d\n",
                m->refresh, m->xres, m->yres, m->pixclock, m->left_margin,
@@ -230,7 +230,7 @@ static void dump_fb_videomode(struct fb_videomode *m)
                m->hsync_len, m->vsync_len, m->sync, m->vmode, m->flag);
 }
 #else
-static void dump_fb_videomode(struct fb_videomode *m)
+static void dump_fb_videomode(const struct fb_videomode *m)
 {}
 #endif
 
@@ -2598,17 +2598,16 @@ static int mxc_hdmi_disp_init(struct mxc_dispdrv_handle *disp,
 
        /* Find a nearest mode in default modelist */
        fb_var_to_videomode(&m, &hdmi->fbi->var);
-       dump_fb_videomode(&m);
 
        hdmi->dft_mode_set = false;
-       /* Save default video mode */
-       memcpy(&hdmi->default_mode, &m, sizeof(struct fb_videomode));
-
        mode = fb_find_nearest_mode(&m, &hdmi->fbi->modelist);
        if (!mode) {
                pr_err("%s: could not find mode in modelist\n", __func__);
                return -1;
        }
+       dump_fb_videomode(mode);
+       /* Save default video mode */
+       memcpy(&hdmi->default_mode, mode, sizeof(struct fb_videomode));
 
        fb_videomode_to_var(&hdmi->fbi->var, mode);