From: Zhao Yakui <yakui.z...@intel.com>

Add a function that can be used to add the default mode for the output device
without EDID.
It will add the default mode that meets with the requirements of given
hdisplay/vdisplay limit.

Signed-off-by: Zhao Yakui <yakui.z...@intel.com>
---
 drivers/gpu/drm/drm_edid.c |   46 +++++++++++++++++++++++++++++++++++++++++++++
 include/drm/drm_crtc.h     |    2 +
 2 files changed, 48 insertions(+)

Index: linux-2.6/drivers/gpu/drm/drm_edid.c
===================================================================
--- linux-2.6.orig/drivers/gpu/drm/drm_edid.c   2009-09-03 09:14:28.000000000 
+0800
+++ linux-2.6/drivers/gpu/drm/drm_edid.c        2009-09-03 09:28:14.000000000 
+0800
@@ -1215,3 +1215,49 @@
        return num_modes;
 }
 EXPORT_SYMBOL(drm_add_edid_modes);
+
+/**
+ * drm_add_modes_noedid - add modes for the connectors without EDID
+ * @connector: connector we're probing
+ * @hdisplay: the horizontal display limit
+ * @vdisplay: the vertical display limit
+ *
+ * Add the specified modes to the connector's mode list. Only when the
+ * hdisplay/vdisplay is not beyond the given limit, it will be added.
+ *
+ * Return number of modes added or 0 if we couldn't find any.
+ */
+int drm_add_modes_noedid(struct drm_connector *connector,
+                       int hdisplay, int vdisplay)
+{
+       int i, count, num_modes = 0;
+       struct drm_display_mode *mode, *ptr;
+       struct drm_device *dev = connector->dev;
+
+       count = sizeof(drm_dmt_modes) / sizeof(struct drm_display_mode);
+       if (hdisplay < 0)
+               hdisplay = 0;
+       if (vdisplay < 0)
+               vdisplay = 0;
+
+       for (i = 0; i < count; i++) {
+               ptr = &drm_dmt_modes[i];
+               if (hdisplay && vdisplay) {
+                       /*
+                        * Only when two are valid, they will be used to check
+                        * whether the mode should be added to the mode list of
+                        * the connector.
+                        */
+                       if (ptr->hdisplay > hdisplay ||
+                                       ptr->vdisplay > vdisplay)
+                               continue;
+               }
+               mode = drm_mode_duplicate(dev, ptr);
+               if (mode) {
+                       drm_mode_probed_add(connector, mode);
+                       num_modes++;
+               }
+       }
+       return num_modes;
+}
+EXPORT_SYMBOL(drm_add_modes_noedid);
Index: linux-2.6/include/drm/drm_crtc.h
===================================================================
--- linux-2.6.orig/include/drm/drm_crtc.h       2009-09-03 08:56:50.000000000 
+0800
+++ linux-2.6/include/drm/drm_crtc.h    2009-09-03 09:24:38.000000000 +0800
@@ -750,4 +750,6 @@
 extern struct drm_display_mode *drm_gtf_mode(struct drm_device *dev,
                                int hdisplay, int vdisplay, int vrefresh,
                                bool interlaced, int margins);
+extern int drm_add_mode_noedid(struct drm_connector *connector,
+                               int hdisplay, int vdisplay);
 #endif /* __DRM_CRTC_H__ */

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
--
_______________________________________________
Dri-devel mailing list
Dri-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dri-devel

Reply via email to