drm: add initial_config function to fb helper
authorJesse Barnes <jbarnes@virtuousgeek.org>
Tue, 19 Feb 2013 21:31:39 +0000 (13:31 -0800)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Tue, 26 Mar 2013 20:32:53 +0000 (21:32 +0100)
Rather than building a config which may or may not work, let the driver
build an initial fb config.  This allows the driver to use the BIOS boot
configuration for example, displaying kernel messages and the initial fb
console on the same outputs the BIOS lit up at boot time.  If that
fails, the driver can still fall back the same way as the core.

Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: dri-devel@lists.freedesktop.org
Acked-by: Dave Airlie <airlied@gmail.com>
Reviewed-by: Imre Deak <imre.deak@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/drm_fb_helper.c
include/drm/drm_fb_helper.h

index 59d6b9bf204bbd2d76b8440b3f7d435def394fe7..6764dce44e84e9a48e984a929c5cfe39f25cea42 100644 (file)
@@ -1398,7 +1398,7 @@ static void drm_setup_crtcs(struct drm_fb_helper *fb_helper)
        struct drm_mode_set *modeset;
        bool *enabled;
        int width, height;
-       int i, ret;
+       int i;
 
        DRM_DEBUG_KMS("\n");
 
@@ -1419,16 +1419,23 @@ static void drm_setup_crtcs(struct drm_fb_helper *fb_helper)
 
        drm_enable_connectors(fb_helper, enabled);
 
-       ret = drm_target_cloned(fb_helper, modes, enabled, width, height);
-       if (!ret) {
-               ret = drm_target_preferred(fb_helper, modes, enabled, width, height);
-               if (!ret)
+       if (!(fb_helper->funcs->initial_config &&
+             fb_helper->funcs->initial_config(fb_helper, crtcs, modes,
+                                              enabled, width, height))) {
+               memset(modes, 0, dev->mode_config.num_connector*sizeof(modes[0]));
+               memset(crtcs, 0, dev->mode_config.num_connector*sizeof(crtcs[0]));
+
+               if (!drm_target_cloned(fb_helper,
+                                      modes, enabled, width, height) &&
+                   !drm_target_preferred(fb_helper,
+                                         modes, enabled, width, height))
                        DRM_ERROR("Unable to find initial modes\n");
-       }
 
-       DRM_DEBUG_KMS("picking CRTCs for %dx%d config\n", width, height);
+               DRM_DEBUG_KMS("picking CRTCs for %dx%d config\n",
+                             width, height);
 
-       drm_pick_crtcs(fb_helper, crtcs, modes, 0, width, height);
+               drm_pick_crtcs(fb_helper, crtcs, modes, 0, width, height);
+       }
 
        /* need to set the modesets up here for use later */
        /* fill out the connector<->crtc mappings into the modesets */
index c09511625a11244f8a07a9114952b9352f619f8d..f97a8ef1d728899449e87ac149f6bf756761655c 100644 (file)
@@ -68,6 +68,10 @@ struct drm_fb_helper_funcs {
 
        int (*fb_probe)(struct drm_fb_helper *helper,
                        struct drm_fb_helper_surface_size *sizes);
+       bool (*initial_config)(struct drm_fb_helper *fb_helper,
+                              struct drm_fb_helper_crtc **crtcs,
+                              struct drm_display_mode **modes,
+                              bool *enabled, int width, int height);
 };
 
 struct drm_fb_helper_connector {