diff mbox

[1/6] drm/fb: Enable choosing a preferred noedid mode

Message ID 1343185657.3715.33.camel@pasglop (mailing list archive)
State New, archived
Headers show

Commit Message

Benjamin Herrenschmidt July 25, 2012, 3:07 a.m. UTC
This adds a "preferred" argument to drm_add_modes_noedid() which
allow drivers such as cirrusdrmfb to select a preferred mode based
on firmware configuration

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
 drivers/gpu/drm/cirrus/cirrus_mode.c |    8 +++++++-
 drivers/gpu/drm/drm_crtc_helper.c    |    2 +-
 drivers/gpu/drm/drm_edid.c           |    7 ++++++-
 include/drm/drm_crtc.h               |    2 +-
 4 files changed, 15 insertions(+), 4 deletions(-)
diff mbox

Patch

diff --git a/drivers/gpu/drm/cirrus/cirrus_mode.c b/drivers/gpu/drm/cirrus/cirrus_mode.c
index a44d31a..e3d2dc0 100644
--- a/drivers/gpu/drm/cirrus/cirrus_mode.c
+++ b/drivers/gpu/drm/cirrus/cirrus_mode.c
@@ -495,13 +495,19 @@  static struct drm_encoder *cirrus_encoder_init(struct drm_device *dev)
 
 int cirrus_vga_get_modes(struct drm_connector *connector)
 {
+	int count = 0;
+
 	/* Just add a static list of modes */
+	count += drm_add_modes_noedid(connector, 640, 480, false);
+	count += drm_add_modes_noedid(connector, 800, 600, false);
+	count += drm_add_modes_noedid(connector, 1024, 768, false);
+	count += drm_add_modes_noedid(connector, 1280, 1024, false);
 	drm_add_modes_noedid(connector, 640, 480);
 	drm_add_modes_noedid(connector, 800, 600);
 	drm_add_modes_noedid(connector, 1024, 768);
 	drm_add_modes_noedid(connector, 1280, 1024);
 
-	return 4;
+	return count;
 }
 
 static int cirrus_vga_mode_valid(struct drm_connector *connector,
diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
index 3252e70..2b8612f 100644
--- a/drivers/gpu/drm/drm_crtc_helper.c
+++ b/drivers/gpu/drm/drm_crtc_helper.c
@@ -126,7 +126,7 @@  int drm_helper_probe_single_connector_modes(struct drm_connector *connector,
 		count = (*connector_funcs->get_modes)(connector);
 
 	if (count == 0 && connector->status == connector_status_connected)
-		count = drm_add_modes_noedid(connector, 1024, 768);
+		count = drm_add_modes_noedid(connector, 1024, 768, false);
 	if (count == 0)
 		goto prune;
 
diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index a8743c3..38cab74 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -1945,7 +1945,7 @@  EXPORT_SYMBOL(drm_add_edid_modes);
  * 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 hdisplay, int vdisplay, bool preferred)
 {
 	int i, count, num_modes = 0;
 	struct drm_display_mode *mode;
@@ -1973,6 +1973,11 @@  int drm_add_modes_noedid(struct drm_connector *connector,
 			continue;
 		mode = drm_mode_duplicate(dev, ptr);
 		if (mode) {
+			if (preferred && ptr->hdisplay == hdisplay &&
+			    ptr->vdisplay == vdisplay) {
+				mode->type |= DRM_MODE_TYPE_PREFERRED;
+				preferred = false;
+			}
 			drm_mode_probed_add(connector, mode);
 			num_modes++;
 		}
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index a1a0386..e8e94b7 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -1033,7 +1033,7 @@  extern struct drm_display_mode *drm_gtf_mode_complex(struct drm_device *dev,
 				bool interlaced, int margins, int GTF_M,
 				int GTF_2C, int GTF_K, int GTF_2J);
 extern int drm_add_modes_noedid(struct drm_connector *connector,
-				int hdisplay, int vdisplay);
+				int hdisplay, int vdisplay, bool preferred);
 
 extern int drm_edid_header_is_valid(const u8 *raw_edid);
 extern bool drm_edid_block_valid(u8 *raw_edid, int block);