drm/i915: call drm_encoder_init first
authorChris Wilson <chris@chris-wilson.co.uk>
Wed, 15 Sep 2010 11:03:59 +0000 (12:03 +0100)
committerChris Wilson <chris@chris-wilson.co.uk>
Wed, 15 Sep 2010 15:45:25 +0000 (16:45 +0100)
Later initialisation of the encoder often requires that
drm_encoder_init() has already been called, for instance, initialiasing
the DDC buses.

Yet another recent regression, as 819f3fb7 depended upon these fixes
which I missed when cherry-picking.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
drivers/gpu/drm/i915/intel_crt.c
drivers/gpu/drm/i915/intel_dvo.c
drivers/gpu/drm/i915/intel_hdmi.c
drivers/gpu/drm/i915/intel_sdvo.c

index 0403ec9e164aa08fe2601fbe305c9cfd218f60bc..2353da625d2524388ed569018a483e91cc166861 100644 (file)
@@ -548,6 +548,10 @@ void intel_crt_init(struct drm_device *dev)
        if (!intel_encoder->ddc_bus) {
                dev_printk(KERN_ERR, &dev->pdev->dev, "DDC bus registration "
                           "failed.\n");
+               drm_connector_cleanup(&intel_connector->base);
+               kfree(intel_connector);
+               drm_encoder_cleanup(&intel_encoder->base);
+               kfree(intel_encoder);
                return;
        }
 
index 7de7d1a68c075b7034e9be0563c83156ee69e454..d8a586b41275d27a0e9bbe35087232e40dd897d0 100644 (file)
@@ -360,6 +360,8 @@ void intel_dvo_init(struct drm_device *dev)
        }
 
        intel_encoder = &intel_dvo->base;
+       drm_encoder_init(dev, &intel_encoder->base,
+                        &intel_dvo_enc_funcs, encoder_type);
 
        /* Set up the DDC bus */
        intel_encoder->ddc_bus = intel_i2c_create(intel_encoder,
@@ -428,8 +430,6 @@ void intel_dvo_init(struct drm_device *dev)
                connector->interlace_allowed = false;
                connector->doublescan_allowed = false;
 
-               drm_encoder_init(dev, &intel_encoder->base,
-                                &intel_dvo_enc_funcs, encoder_type);
                drm_encoder_helper_add(&intel_encoder->base,
                                       &intel_dvo_helper_funcs);
 
@@ -456,6 +456,7 @@ void intel_dvo_init(struct drm_device *dev)
        if (i2cbus != NULL)
                intel_i2c_destroy(i2cbus);
 free_intel:
+       drm_encoder_cleanup(&intel_encoder->base);
        kfree(intel_dvo);
        kfree(intel_connector);
 }
index 93d5b61bf5bd6ea257d43b5ecb27b3a4eabce198..783924c7682ac4a95b173715f0cdf9f5a02319e9 100644 (file)
@@ -228,6 +228,9 @@ void intel_hdmi_init(struct drm_device *dev, int sdvox_reg)
        }
 
        intel_encoder = &intel_hdmi->base;
+       drm_encoder_init(dev, &intel_encoder->base, &intel_hdmi_enc_funcs,
+                        DRM_MODE_ENCODER_TMDS);
+
        connector = &intel_connector->base;
        drm_connector_init(dev, connector, &intel_hdmi_connector_funcs,
                           DRM_MODE_CONNECTOR_HDMIA);
@@ -272,8 +275,6 @@ void intel_hdmi_init(struct drm_device *dev, int sdvox_reg)
 
        intel_hdmi->sdvox_reg = sdvox_reg;
 
-       drm_encoder_init(dev, &intel_encoder->base, &intel_hdmi_enc_funcs,
-                        DRM_MODE_ENCODER_TMDS);
        drm_encoder_helper_add(&intel_encoder->base, &intel_hdmi_helper_funcs);
 
        intel_connector_attach_encoder(intel_connector, intel_encoder);
@@ -291,6 +292,7 @@ void intel_hdmi_init(struct drm_device *dev, int sdvox_reg)
        return;
 
 err_connector:
+       drm_encoder_cleanup(&intel_encoder->base);
        drm_connector_cleanup(connector);
        kfree(intel_hdmi);
        kfree(intel_connector);
index d2b4a6a2840551fdd1c9da823bd135854f87e14b..f7030e4810833f3577a1f952c702764cda24b9cb 100644 (file)
@@ -2552,6 +2552,8 @@ bool intel_sdvo_init(struct drm_device *dev, int sdvo_reg)
 
        intel_encoder = &intel_sdvo->base;
        intel_encoder->type = INTEL_OUTPUT_SDVO;
+       /* encoder type will be decided later */
+       drm_encoder_init(dev, &intel_encoder->base, &intel_sdvo_enc_funcs, 0);
 
        if (HAS_PCH_SPLIT(dev)) {
                i2c_reg = PCH_GPIOE;
@@ -2606,31 +2608,29 @@ bool intel_sdvo_init(struct drm_device *dev, int sdvo_reg)
        /* Wrap with our custom algo which switches to DDC mode */
        intel_encoder->ddc_bus->algo = &intel_sdvo_i2c_bit_algo;
 
-       /* encoder type will be decided later */
-       drm_encoder_init(dev, &intel_encoder->base, &intel_sdvo_enc_funcs, 0);
        drm_encoder_helper_add(&intel_encoder->base, &intel_sdvo_helper_funcs);
 
        /* In default case sdvo lvds is false */
        if (!intel_sdvo_get_capabilities(intel_sdvo, &intel_sdvo->caps))
-               goto err_enc;
+               goto err_i2c;
 
        if (intel_sdvo_output_setup(intel_sdvo,
                                    intel_sdvo->caps.output_flags) != true) {
                DRM_DEBUG_KMS("SDVO output failed to setup on SDVO%c\n",
                              IS_SDVOB(sdvo_reg) ? 'B' : 'C');
-               goto err_enc;
+               goto err_i2c;
        }
 
        intel_sdvo_select_ddc_bus(dev_priv, intel_sdvo, sdvo_reg);
 
        /* Set the input timing to the screen. Assume always input 0. */
        if (!intel_sdvo_set_target_input(intel_sdvo))
-               goto err_enc;
+               goto err_i2c;
 
        if (!intel_sdvo_get_input_pixel_clock_range(intel_sdvo,
                                                    &intel_sdvo->pixel_clock_min,
                                                    &intel_sdvo->pixel_clock_max))
-               goto err_enc;
+               goto err_i2c;
 
        DRM_DEBUG_KMS("%s device VID/DID: %02X:%02X.%02X, "
                        "clock range %dMHz - %dMHz, "
@@ -2650,14 +2650,13 @@ bool intel_sdvo_init(struct drm_device *dev, int sdvo_reg)
                        (SDVO_OUTPUT_TMDS1 | SDVO_OUTPUT_RGB1) ? 'Y' : 'N');
        return true;
 
-err_enc:
-       drm_encoder_cleanup(&intel_encoder->base);
 err_i2c:
        if (intel_encoder->ddc_bus != NULL)
                intel_i2c_destroy(intel_encoder->ddc_bus);
        if (intel_encoder->i2c_bus != NULL)
                intel_i2c_destroy(intel_encoder->i2c_bus);
 err_inteloutput:
+       drm_encoder_cleanup(&intel_encoder->base);
        kfree(intel_sdvo);
 
        return false;