tegra: hdmi: support HDMI VSDB VIC parsing
Emma Yan [Mon, 30 Sep 2013 13:39:14 +0000 (21:39 +0800)]
Bug 1167856
Bug 1357380
Bug 1366416
Bug 1369156
Bug 1375947

(cherry-picked from commit f649c7aded9902bbeb6e79423e1af87553441949)
Change-Id: Ifd2fce407405bed92d8c399c742635f6e9c59918
Signed-off-by: Emma Yan <eyan@nvidia.com>
Reviewed-on: http://git-master/r/280300
Reviewed-by: Jon Mayo <jmayo@nvidia.com>
Reviewed-on: http://git-master/r/299001
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit

drivers/video/tegra/dc/edid.c

index 3f3368c..a56b6ac 100644 (file)
@@ -33,6 +33,8 @@ struct tegra_edid_pvt {
        bool                            support_stereo;
        bool                            support_underscan;
        bool                            support_audio;
+       int                             hdmi_vic_len;
+       u8                              hdmi_vic[7];
        /* Note: dc_edid must remain the last member */
        struct tegra_dc_edid            dc_edid;
 };
@@ -277,6 +279,13 @@ int tegra_edid_parse_ext_block(const u8 *raw, int idx,
                                        /* 3D_present? */
                                        if (j <= len && (ptr[j] & 0x80))
                                                edid->support_stereo = 1;
+                                       /* HDMI_VIC_LEN */
+                                       if (++j <= len && (ptr[j] & 0xe0)) {
+                                               int k = 0;
+                                               edid->hdmi_vic_len = ptr[j] >> 5;
+                                               for (k = 0; k < edid->hdmi_vic_len; k++)
+                                                   edid->hdmi_vic[k] = ptr[j+k+1];
+                                       }
                                }
                        }
                        if ((len > 5) &&
@@ -479,6 +488,30 @@ int tegra_edid_get_monspecs(struct tegra_edid *edid, struct fb_monspecs *specs)
 #endif
                                }
                        }
+
+                       if (new_data->hdmi_vic_len > 0) {
+                               int k;
+                               int l = specs->modedb_len;
+                               struct fb_videomode *m;
+                               m = kzalloc((specs->modedb_len + new_data->hdmi_vic_len) *
+                                   sizeof(struct fb_videomode), GFP_KERNEL);
+                               if (!m)
+                                   break;
+                               memcpy(m, specs->modedb, specs->modedb_len *
+                                       sizeof(struct fb_videomode));
+                               for (k = 0; k < new_data->hdmi_vic_len; k++) {
+                                   unsigned vic = new_data->hdmi_vic[k];
+                                   if (vic >= HDMI_EXT_MODEDB_SIZE) {
+                                       pr_warning("Unsupported HDMI VIC %d, ignoring\n", vic);
+                                       continue;
+                                   }
+                                   memcpy(&m[l], &hdmi_ext_modes[vic], sizeof(m[l]));
+                                   l++;
+                               }
+                               kfree(specs->modedb);
+                               specs->modedb = m;
+                               specs->modedb_len = specs->modedb_len + new_data->hdmi_vic_len;
+                       }
                }
        }