From mboxrd@z Thu Jan 1 00:00:00 1970 From: Benjamin Herrenschmidt Subject: [PATCH 1/6] drm/fb: Enable choosing a preferred noedid mode Date: Wed, 25 Jul 2012 13:07:37 +1000 Message-ID: <1343185657.3715.33.camel@pasglop> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) by gabe.freedesktop.org (Postfix) with ESMTP id 2AA139EB42 for ; Tue, 24 Jul 2012 20:22:43 -0700 (PDT) Received: from [127.0.0.1] (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.13.8) with ESMTP id q6P37bqQ022454 for ; Tue, 24 Jul 2012 22:07:38 -0500 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org Errors-To: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org To: dri-devel@lists.freedesktop.org List-Id: dri-devel@lists.freedesktop.org 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 --- 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 --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);