diff mbox

[1/2] drm: add helper to sort panels to the head of the connector list

Message ID 1351345925-17510-1-git-send-email-daniel.vetter@ffwll.ch (mailing list archive)
State New, archived
Headers show

Commit Message

Daniel Vetter Oct. 27, 2012, 1:52 p.m. UTC
Userspace seems to like this, see

commit cb0953d734348e8862d6d7edc666cfb3bf6d8fae
Author: Adam Jackson <ajax@redhat.com>
Date:   Fri Jul 16 14:46:29 2010 -0400

    drm/i915: Initialize LVDS and eDP outputs before anything else

    This makes them sort to the front in X, which makes them likely to be
    the primary outputs if you haven't specified a preference in your DE,
    which is likely to be what you want.

    Signed-off-by: Adam Jackson <ajax@redhat.com>
    Signed-off-by: Eric Anholt <eric@anholt.net>

Sorting the connector list after the fact is much easier than trying
to be clever with the init sequence.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/drm_crtc_helper.c | 18 ++++++++++++++++++
 include/drm/drm_crtc_helper.h     |  2 ++
 2 files changed, 20 insertions(+)

Comments

Laurent Pinchart Oct. 30, 2012, 10:11 a.m. UTC | #1
Hi Daniel,

Thanks for the patch.

On Saturday 27 October 2012 15:52:04 Daniel Vetter wrote:
> Userspace seems to like this, see
> 
> commit cb0953d734348e8862d6d7edc666cfb3bf6d8fae
> Author: Adam Jackson <ajax@redhat.com>
> Date:   Fri Jul 16 14:46:29 2010 -0400
> 
>     drm/i915: Initialize LVDS and eDP outputs before anything else
> 
>     This makes them sort to the front in X, which makes them likely to be
>     the primary outputs if you haven't specified a preference in your DE,
>     which is likely to be what you want.
> 
>     Signed-off-by: Adam Jackson <ajax@redhat.com>
>     Signed-off-by: Eric Anholt <eric@anholt.net>
> 
> Sorting the connector list after the fact is much easier than trying
> to be clever with the init sequence.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> ---
>  drivers/gpu/drm/drm_crtc_helper.c | 18 ++++++++++++++++++
>  include/drm/drm_crtc_helper.h     |  2 ++
>  2 files changed, 20 insertions(+)

You forgot Documentation/DocBook/drm.tmpl :-)

> 
> diff --git a/drivers/gpu/drm/drm_crtc_helper.c
> b/drivers/gpu/drm/drm_crtc_helper.c index 1227adf..7105168 100644
> --- a/drivers/gpu/drm/drm_crtc_helper.c
> +++ b/drivers/gpu/drm/drm_crtc_helper.c
> @@ -39,6 +39,24 @@
>  #include <drm/drm_fb_helper.h>
>  #include <drm/drm_edid.h>
> 
> +void drm_helper_move_panel_connectors_to_head(struct drm_device *dev)
> +{
> +	struct drm_connector *connector, *tmp;
> +	struct list_head panel_list;
> +
> +	INIT_LIST_HEAD(&panel_list);
> +
> +	list_for_each_entry_safe(connector, tmp,
> +				 &dev->mode_config.connector_list, head) {
> +		if (connector->connector_type == DRM_MODE_CONNECTOR_LVDS ||
> +		    connector->connector_type == DRM_MODE_CONNECTOR_eDP)
> +			list_move_tail(&connector->head, &panel_list);
> +	}
> +
> +	list_splice(&panel_list, &dev->mode_config.connector_list);
> +}
> +EXPORT_SYMBOL(drm_helper_move_panel_connectors_to_head);
> +
>  static bool drm_kms_helper_poll = true;
>  module_param_named(poll, drm_kms_helper_poll, bool, 0600);
> 
> diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
> index e01cc80..defee28 100644
> --- a/include/drm/drm_crtc_helper.h
> +++ b/include/drm/drm_crtc_helper.h
> @@ -137,6 +137,8 @@ extern bool drm_helper_encoder_in_use(struct drm_encoder
> *encoder);
> 
>  extern void drm_helper_connector_dpms(struct drm_connector *connector, int
> mode);
> 
> +extern void drm_helper_move_panel_connectors_to_head(struct drm_device *);
> +
>  extern int drm_helper_mode_fill_fb_struct(struct drm_framebuffer *fb,
>  					  struct drm_mode_fb_cmd2 *mode_cmd);
Adam Jackson Oct. 31, 2012, 7:59 p.m. UTC | #2
On 10/27/12 9:52 AM, Daniel Vetter wrote:
> Userspace seems to like this, see
>
> commit cb0953d734348e8862d6d7edc666cfb3bf6d8fae
> Author: Adam Jackson <ajax@redhat.com>
> Date:   Fri Jul 16 14:46:29 2010 -0400
>
>      drm/i915: Initialize LVDS and eDP outputs before anything else
>
>      This makes them sort to the front in X, which makes them likely to be
>      the primary outputs if you haven't specified a preference in your DE,
>      which is likely to be what you want.
>
>      Signed-off-by: Adam Jackson <ajax@redhat.com>
>      Signed-off-by: Eric Anholt <eric@anholt.net>
>
> Sorting the connector list after the fact is much easier than trying
> to be clever with the init sequence.

Entirely reasonable.

Reviewed-by: Adam Jackson <ajax@redhat.com>

- ajax
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
index 1227adf..7105168 100644
--- a/drivers/gpu/drm/drm_crtc_helper.c
+++ b/drivers/gpu/drm/drm_crtc_helper.c
@@ -39,6 +39,24 @@ 
 #include <drm/drm_fb_helper.h>
 #include <drm/drm_edid.h>
 
+void drm_helper_move_panel_connectors_to_head(struct drm_device *dev)
+{
+	struct drm_connector *connector, *tmp;
+	struct list_head panel_list;
+
+	INIT_LIST_HEAD(&panel_list);
+
+	list_for_each_entry_safe(connector, tmp,
+				 &dev->mode_config.connector_list, head) {
+		if (connector->connector_type == DRM_MODE_CONNECTOR_LVDS ||
+		    connector->connector_type == DRM_MODE_CONNECTOR_eDP)
+			list_move_tail(&connector->head, &panel_list);
+	}
+
+	list_splice(&panel_list, &dev->mode_config.connector_list);
+}
+EXPORT_SYMBOL(drm_helper_move_panel_connectors_to_head);
+
 static bool drm_kms_helper_poll = true;
 module_param_named(poll, drm_kms_helper_poll, bool, 0600);
 
diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
index e01cc80..defee28 100644
--- a/include/drm/drm_crtc_helper.h
+++ b/include/drm/drm_crtc_helper.h
@@ -137,6 +137,8 @@  extern bool drm_helper_encoder_in_use(struct drm_encoder *encoder);
 
 extern void drm_helper_connector_dpms(struct drm_connector *connector, int mode);
 
+extern void drm_helper_move_panel_connectors_to_head(struct drm_device *);
+
 extern int drm_helper_mode_fill_fb_struct(struct drm_framebuffer *fb,
 					  struct drm_mode_fb_cmd2 *mode_cmd);