drm/i915: Don't store temporary load-detect variables in the generic encoder
Chris Wilson [Tue, 19 Apr 2011 22:18:09 +0000 (23:18 +0100)]
Keep all the state required for undoing and restoring the previous pipe
configuration together in a single struct passed from
intel_get_load_detect_pipe() to intel_release_load_detect_pipe() rather
than stuffing them inside the common encoder structure.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>

drivers/gpu/drm/i915/intel_crt.c
drivers/gpu/drm/i915/intel_display.c
drivers/gpu/drm/i915/intel_drv.h
drivers/gpu/drm/i915/intel_tv.c

index 2eb60cd..e93f93c 100644 (file)
@@ -430,7 +430,6 @@ intel_crt_detect(struct drm_connector *connector, bool force)
        struct drm_device *dev = connector->dev;
        struct intel_crt *crt = intel_attached_crt(connector);
        struct drm_crtc *crtc;
-       int dpms_mode;
        enum drm_connector_status status;
 
        if (I915_HAS_HOTPLUG(dev)) {
@@ -454,14 +453,16 @@ intel_crt_detect(struct drm_connector *connector, bool force)
        if (crtc && crtc->enabled) {
                status = intel_crt_load_detect(crt);
        } else {
-               if (intel_get_load_detect_pipe(&crt->base, connector,
-                                              NULL, &dpms_mode)) {
+               struct intel_load_detect_pipe tmp;
+
+               if (intel_get_load_detect_pipe(&crt->base, connector, NULL,
+                                              &tmp)) {
                        if (intel_crt_detect_ddc(connector))
                                status = connector_status_connected;
                        else
                                status = intel_crt_load_detect(crt);
-                       intel_release_load_detect_pipe(&crt->base,
-                                                      connector, dpms_mode);
+                       intel_release_load_detect_pipe(&crt->base, connector,
+                                                      &tmp);
                } else
                        status = connector_status_unknown;
        }
index 943bcbc..81c4f59 100644 (file)
@@ -5484,7 +5484,7 @@ static struct drm_display_mode load_detect_mode = {
 bool intel_get_load_detect_pipe(struct intel_encoder *intel_encoder,
                                struct drm_connector *connector,
                                struct drm_display_mode *mode,
-                               int *dpms_mode)
+                               struct intel_load_detect_pipe *old)
 {
        struct intel_crtc *intel_crtc;
        struct drm_crtc *possible_crtc;
@@ -5509,14 +5509,18 @@ bool intel_get_load_detect_pipe(struct intel_encoder *intel_encoder,
        /* See if we already have a CRTC for this connector */
        if (encoder->crtc) {
                crtc = encoder->crtc;
-               /* Make sure the crtc and connector are running */
+
                intel_crtc = to_intel_crtc(crtc);
-               *dpms_mode = intel_crtc->dpms_mode;
+               old->dpms_mode = intel_crtc->dpms_mode;
+               old->load_detect_temp = false;
+
+               /* Make sure the crtc and connector are running */
                if (intel_crtc->dpms_mode != DRM_MODE_DPMS_ON) {
                        crtc_funcs = crtc->helper_private;
                        crtc_funcs->dpms(crtc, DRM_MODE_DPMS_ON);
                        encoder_funcs->dpms(encoder, DRM_MODE_DPMS_ON);
                }
+
                return true;
        }
 
@@ -5543,10 +5547,10 @@ bool intel_get_load_detect_pipe(struct intel_encoder *intel_encoder,
 
        encoder->crtc = crtc;
        connector->encoder = encoder;
-       intel_encoder->load_detect_temp = true;
 
        intel_crtc = to_intel_crtc(crtc);
-       *dpms_mode = intel_crtc->dpms_mode;
+       old->dpms_mode = intel_crtc->dpms_mode;
+       old->load_detect_temp = true;
 
        if (!crtc->enabled) {
                if (!mode)
@@ -5574,7 +5578,8 @@ bool intel_get_load_detect_pipe(struct intel_encoder *intel_encoder,
 }
 
 void intel_release_load_detect_pipe(struct intel_encoder *intel_encoder,
-                                   struct drm_connector *connector, int dpms_mode)
+                                   struct drm_connector *connector,
+                                   struct intel_load_detect_pipe *old)
 {
        struct drm_encoder *encoder = &intel_encoder->base;
        struct drm_device *dev = encoder->dev;
@@ -5582,19 +5587,18 @@ void intel_release_load_detect_pipe(struct intel_encoder *intel_encoder,
        struct drm_encoder_helper_funcs *encoder_funcs = encoder->helper_private;
        struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
 
-       if (intel_encoder->load_detect_temp) {
+       if (old->load_detect_temp) {
                encoder->crtc = NULL;
                connector->encoder = NULL;
-               intel_encoder->load_detect_temp = false;
                crtc->enabled = drm_helper_crtc_in_use(crtc);
                drm_helper_disable_unused_functions(dev);
        }
 
        /* Switch crtc and encoder back off if necessary */
-       if (crtc->enabled && dpms_mode != DRM_MODE_DPMS_ON) {
+       if (crtc->enabled && old->dpms_mode != DRM_MODE_DPMS_ON) {
                if (encoder->crtc == crtc)
-                       encoder_funcs->dpms(encoder, dpms_mode);
-               crtc_funcs->dpms(crtc, dpms_mode);
+                       encoder_funcs->dpms(encoder, old->dpms_mode);
+               crtc_funcs->dpms(crtc, old->dpms_mode);
        }
 }
 
index fa46d32..3ceb3da 100644 (file)
@@ -140,7 +140,6 @@ struct intel_fbdev {
 struct intel_encoder {
        struct drm_encoder base;
        int type;
-       bool load_detect_temp;
        bool needs_tv_clock;
        void (*hot_plug)(struct intel_encoder *);
        int crtc_mask;
@@ -291,13 +290,18 @@ int intel_get_pipe_from_crtc_id(struct drm_device *dev, void *data,
                                struct drm_file *file_priv);
 extern void intel_wait_for_vblank(struct drm_device *dev, int pipe);
 extern void intel_wait_for_pipe_off(struct drm_device *dev, int pipe);
+
+struct intel_load_detect_pipe {
+       bool load_detect_temp;
+       int dpms_mode;
+};
 extern bool intel_get_load_detect_pipe(struct intel_encoder *intel_encoder,
                                       struct drm_connector *connector,
                                       struct drm_display_mode *mode,
-                                      int *dpms_mode);
+                                      struct intel_load_detect_pipe *old);
 extern void intel_release_load_detect_pipe(struct intel_encoder *intel_encoder,
                                           struct drm_connector *connector,
-                                          int dpms_mode);
+                                          struct intel_load_detect_pipe *old);
 
 extern struct drm_connector* intel_sdvo_find(struct drm_device *dev, int sdvoB);
 extern int intel_sdvo_supports_hotplug(struct drm_connector *connector);
index 3322582..113e4e7 100644 (file)
@@ -1361,13 +1361,14 @@ intel_tv_detect(struct drm_connector *connector, bool force)
        if (intel_tv->base.base.crtc && intel_tv->base.base.crtc->enabled) {
                type = intel_tv_detect_type(intel_tv, connector);
        } else if (force) {
-               int dpms_mode;
+               struct intel_load_detect_pipe tmp;
 
                if (intel_get_load_detect_pipe(&intel_tv->base, connector,
-                                              &mode, &dpms_mode)) {
+                                              &mode, &tmp)) {
                        type = intel_tv_detect_type(intel_tv, connector);
-                       intel_release_load_detect_pipe(&intel_tv->base, connector,
-                                                      dpms_mode);
+                       intel_release_load_detect_pipe(&intel_tv->base,
+                                                      connector,
+                                                      &tmp);
                } else
                        return connector_status_unknown;
        } else