diff mbox

[04/13] drm: add initial_config function to fb helper

Message ID 1361309508-4901-5-git-send-email-jbarnes@virtuousgeek.org (mailing list archive)
State New, archived
Headers show

Commit Message

Jesse Barnes Feb. 19, 2013, 9:31 p.m. UTC
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
---
 drivers/gpu/drm/drm_fb_helper.c |   23 +++++++++++++++--------
 include/drm/drm_fb_helper.h     |    4 ++++
 2 files changed, 19 insertions(+), 8 deletions(-)

Comments

Daniel Vetter March 26, 2013, 8:34 p.m. UTC | #1
On Tue, Feb 19, 2013 at 01:31:39PM -0800, Jesse Barnes wrote:
> 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
Queued for -next with Dave's irc ack, thanks for the patch. Note that
you've frobbed the authorship stuff a bit, probably through an amend,
without adding a patch reflog. Tsk ;-)
-Daniel

> ---
>  drivers/gpu/drm/drm_fb_helper.c |   23 +++++++++++++++--------
>  include/drm/drm_fb_helper.h     |    4 ++++
>  2 files changed, 19 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
> index 0c6e25e..0d96471 100644
> --- a/drivers/gpu/drm/drm_fb_helper.c
> +++ b/drivers/gpu/drm/drm_fb_helper.c
> @@ -1275,7 +1275,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");
>  
> @@ -1296,16 +1296,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 */
> diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h
> index 5120b01..40b0c5c 100644
> --- a/include/drm/drm_fb_helper.h
> +++ b/include/drm/drm_fb_helper.h
> @@ -56,6 +56,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 {
> -- 
> 1.7.9.5
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Chris Wilson March 26, 2013, 8:52 p.m. UTC | #2
On Tue, Mar 26, 2013 at 09:34:29PM +0100, Daniel Vetter wrote:
> On Tue, Feb 19, 2013 at 01:31:39PM -0800, Jesse Barnes wrote:
> > 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
> Queued for -next with Dave's irc ack, thanks for the patch. Note that
> you've frobbed the authorship stuff a bit, probably through an amend,
> without adding a patch reflog. Tsk ;-)

It's one of Jesse's patches that I substantially altered, the core idea
and implementation is still Jesse's. If I remember the history
correctly, that is.
-Chris
Jesse Barnes March 26, 2013, 8:57 p.m. UTC | #3
On Tue, 26 Mar 2013 20:52:53 +0000
Chris Wilson <chris@chris-wilson.co.uk> wrote:

> On Tue, Mar 26, 2013 at 09:34:29PM +0100, Daniel Vetter wrote:
> > On Tue, Feb 19, 2013 at 01:31:39PM -0800, Jesse Barnes wrote:
> > > 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
> > Queued for -next with Dave's irc ack, thanks for the patch. Note that
> > you've frobbed the authorship stuff a bit, probably through an amend,
> > without adding a patch reflog. Tsk ;-)
> 
> It's one of Jesse's patches that I substantially altered, the core idea
> and implementation is still Jesse's. If I remember the history
> correctly, that is.

Yeah either way is fine with me, thanks for applying.
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 0c6e25e..0d96471 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -1275,7 +1275,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");
 
@@ -1296,16 +1296,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 */
diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h
index 5120b01..40b0c5c 100644
--- a/include/drm/drm_fb_helper.h
+++ b/include/drm/drm_fb_helper.h
@@ -56,6 +56,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 {