@@ -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,
@@ -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;
@@ -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++;
}
@@ -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);
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(-)