]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android-sdk/kernel-video.git/commitdiff
OMAP: HDMI : Add initial support for fb mode translation
authorDandawate Saket <dsaket@ti.com>
Sat, 27 Apr 2013 06:52:21 +0000 (23:52 -0700)
committerPraneeth Bajjuri <praneeth@ti.com>
Fri, 12 Jul 2013 23:58:14 +0000 (18:58 -0500)
Add initial support for fb mode detection.

Change-Id: I814921c6f3b55f66dd8cba9dd389b149b64e44dc
Signed-off-by: Dandawate Saket <dsaket@ti.com>
Conflicts:
drivers/video/omap2/dss/hdmi.c

drivers/video/omap2/dss/hdmi.c [changed mode: 0644->0755]
drivers/video/omap2/dss/ti_hdmi.h [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index 133da16..a789eca
@@ -37,6 +37,7 @@
 #include <linux/slab.h>
 #include <linux/of_gpio.h>
 #include <linux/of_i2c.h>
 #include <linux/slab.h>
 #include <linux/of_gpio.h>
 #include <linux/of_i2c.h>
+#include <linux/fb.h>
 #include <video/omapdss.h>
 #include <linux/i2c.h>
 #include <linux/i2c-algo-bit.h>
 #include <video/omapdss.h>
 #include <linux/i2c.h>
 #include <linux/i2c-algo-bit.h>
@@ -380,6 +381,74 @@ static void hdmi_set_ls_state(enum level_shifter_state state)
        sel_hdmi();
 }
 
        sel_hdmi();
 }
 
+static int relaxed_fb_mode_is_equal(const struct fb_videomode *mode1,
+                                       const struct fb_videomode *mode2)
+{
+       u32 ratio1 = mode1->flag & (FB_FLAG_RATIO_4_3 | FB_FLAG_RATIO_16_9);
+       u32 ratio2 = mode2->flag & (FB_FLAG_RATIO_4_3 | FB_FLAG_RATIO_16_9);
+       return (mode1->xres         == mode2->xres &&
+               mode1->yres         == mode2->yres &&
+               mode1->pixclock     <= mode2->pixclock * 201 / 200 &&
+               mode1->pixclock     >= mode2->pixclock * 200 / 201 &&
+               mode1->hsync_len + mode1->left_margin + mode1->right_margin ==
+               mode2->hsync_len + mode2->left_margin + mode2->right_margin &&
+               mode1->vsync_len + mode1->upper_margin + mode1->lower_margin ==
+               mode2->vsync_len + mode2->upper_margin + mode2->lower_margin &&
+               (!ratio1 || !ratio2 || ratio1 == ratio2) &&
+               (mode1->vmode & FB_VMODE_INTERLACED) ==
+               (mode2->vmode & FB_VMODE_INTERLACED));
+
+}
+
+static int hdmi_set_timings(struct fb_videomode *vm, bool check_only)
+{
+       int i = 0;
+       int r = 0;
+       DSSDBG("hdmi_set_timings\n");
+
+       if (!vm->xres || !vm->yres || !vm->pixclock)
+               goto fail;
+
+       for (i = 0; i < CEA_MODEDB_SIZE; i++) {
+               if (relaxed_fb_mode_is_equal(cea_modes + i, vm)) {
+                       *vm = cea_modes[i];
+                       if (check_only)
+                               return 1;
+                       hdmi.ip_data.cfg.cm.code = i;
+                       hdmi.ip_data.cfg.cm.mode = HDMI_HDMI;
+                       hdmi.ip_data.cfg.timingsfb =
+                       cea_modes[hdmi.ip_data.cfg.cm.code];
+                       goto done;
+               }
+       }
+       for (i = 0; i < VESA_MODEDB_SIZE; i++) {
+               if (relaxed_fb_mode_is_equal(vesa_modes + i, vm)) {
+                       *vm = vesa_modes[i];
+                       if (check_only)
+                               return 1;
+                       hdmi.ip_data.cfg.cm.code = i;
+                       hdmi.ip_data.cfg.cm.mode = HDMI_DVI;
+                       hdmi.ip_data.cfg.timingsfb =
+                       vesa_modes[hdmi.ip_data.cfg.cm.code];
+                       goto done;
+               }
+       }
+fail:
+       if (check_only)
+               return 0;
+       hdmi.ip_data.cfg.cm.code = 1;
+       hdmi.ip_data.cfg.cm.mode = HDMI_HDMI;
+       hdmi.ip_data.cfg.timingsfb = cea_modes[hdmi.ip_data.cfg.cm.code];
+       i = -1;
+done:
+       DSSDBG("%s-%d\n", hdmi.ip_data.cfg.cm.mode ? "CEA" : "VESA",
+               hdmi.ip_data.cfg.cm.code);
+
+       r = i >= 0 ? 1 : 0;
+       return r;
+
+}
+
 static int hdmi_runtime_get(void)
 {
        int r;
 static int hdmi_runtime_get(void)
 {
        int r;
old mode 100644 (file)
new mode 100755 (executable)
index 2966a3a..ee28928
@@ -106,6 +106,7 @@ struct hdmi_config {
        struct hdmi_s3d_info s3d_info;
        enum hdmi_deep_color_mode deep_color;
        enum hdmi_range range;
        struct hdmi_s3d_info s3d_info;
        enum hdmi_deep_color_mode deep_color;
        enum hdmi_range range;
+       struct fb_videomode timingsfb;
 };
 
 /* HDMI PLL structure */
 };
 
 /* HDMI PLL structure */