drm/i915: change intel_ddc_get_modes() function parameters
authorZhenyu Wang <zhenyuw@linux.intel.com>
Tue, 30 Mar 2010 06:39:31 +0000 (14:39 +0800)
committerEric Anholt <eric@anholt.net>
Fri, 9 Apr 2010 21:17:31 +0000 (14:17 -0700)
This one replaces original param for intel_ddc_get_modes() with
DRM connector and i2c bus adapter instead. With explicit params,
we won't require that a single driver structure must hold connector
and DDC bus reference, which ease the conversion to splitted encoder/
connector model.

It also clears up for some cases that we would steal other DDC bus
for mode probe, like VGA analog DDC probe for DVI-I. Also it fixed
a bug in old DVI-I probe handling, that failed to restore origin
analog GPIO port.

Signed-off-by: Zhenyu Wang <zhenyuw@linux.intel.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
drivers/gpu/drm/i915/intel_crt.c
drivers/gpu/drm/i915/intel_dp.c
drivers/gpu/drm/i915/intel_drv.h
drivers/gpu/drm/i915/intel_dvo.c
drivers/gpu/drm/i915/intel_hdmi.c
drivers/gpu/drm/i915/intel_lvds.c
drivers/gpu/drm/i915/intel_modes.c
drivers/gpu/drm/i915/intel_sdvo.c

index b96574ea4707383f3d31672bd603e1c3728d4922..4dd5daa8ebe7c1805b926ab198c92cdd8384609c 100644 (file)
@@ -433,28 +433,25 @@ static int intel_crt_get_modes(struct drm_connector *connector)
 {
        int ret;
        struct intel_encoder *intel_encoder = to_intel_encoder(connector);
-       struct i2c_adapter *ddcbus;
+       struct i2c_adapter *ddc_bus;
        struct drm_device *dev = connector->dev;
 
 
-       ret = intel_ddc_get_modes(intel_encoder);
+       ret = intel_ddc_get_modes(connector, intel_encoder->ddc_bus);
        if (ret || !IS_G4X(dev))
                goto end;
 
-       ddcbus = intel_encoder->ddc_bus;
        /* Try to probe digital port for output in DVI-I -> VGA mode. */
-       intel_encoder->ddc_bus =
-               intel_i2c_create(connector->dev, GPIOD, "CRTDDC_D");
+       ddc_bus = intel_i2c_create(connector->dev, GPIOD, "CRTDDC_D");
 
-       if (!intel_encoder->ddc_bus) {
-               intel_encoder->ddc_bus = ddcbus;
+       if (!ddc_bus) {
                dev_printk(KERN_ERR, &connector->dev->pdev->dev,
                           "DDC bus registration failed for CRTDDC_D.\n");
                goto end;
        }
        /* Try to get modes by GPIOD port */
-       ret = intel_ddc_get_modes(intel_encoder);
-       intel_i2c_destroy(ddcbus);
+       ret = intel_ddc_get_modes(connector, ddc_bus);
+       intel_i2c_destroy(ddc_bus);
 
 end:
        return ret;
index 0a7e3264dac213c91f28dadbf04e50af1cfe62ed..6064fd70a424dc6438577fc55d6ab7ecb5bc79a1 100644 (file)
@@ -1229,7 +1229,7 @@ static int intel_dp_get_modes(struct drm_connector *connector)
        /* We should parse the EDID data and find out if it has an audio sink
         */
 
-       ret = intel_ddc_get_modes(intel_encoder);
+       ret = intel_ddc_get_modes(connector, intel_encoder->ddc_bus);
        if (ret)
                return ret;
 
index 4741713df74aabd9f974e59f5aebf36a072e1f49..c15ec471c8494a278d1569e27435b0926a4933c6 100644 (file)
@@ -165,7 +165,7 @@ struct intel_crtc {
 struct i2c_adapter *intel_i2c_create(struct drm_device *dev, const u32 reg,
                                     const char *name);
 void intel_i2c_destroy(struct i2c_adapter *adapter);
-int intel_ddc_get_modes(struct intel_encoder *intel_encoder);
+int intel_ddc_get_modes(struct drm_connector *c, struct i2c_adapter *adapter);
 extern bool intel_ddc_probe(struct intel_encoder *intel_encoder);
 void intel_i2c_quirk_set(struct drm_device *dev, bool enable);
 void intel_i2c_reset_gmbus(struct drm_device *dev);
index 62282f34eba9c1cd0abf3b7dad8b28c9b56df325..a3e6efa38c75d85479f22fd49bb3d784abd1483e 100644 (file)
@@ -256,7 +256,7 @@ static int intel_dvo_get_modes(struct drm_connector *connector)
         * (TV-out, for example), but for now with just TMDS and LVDS,
         * that's not the case.
         */
-       intel_ddc_get_modes(intel_encoder);
+       intel_ddc_get_modes(connector, intel_encoder->ddc_bus);
        if (!list_empty(&connector->probed_modes))
                return 1;
 
index 9777504afeb261fb9e8eebce966e9fd00926843d..74823e77b2fe524f2618a9ef5c55ed6149d037f9 100644 (file)
@@ -179,7 +179,7 @@ static int intel_hdmi_get_modes(struct drm_connector *connector)
         * we can send audio to it.
         */
 
-       return intel_ddc_get_modes(intel_encoder);
+       return intel_ddc_get_modes(connector, intel_encoder->ddc_bus);
 }
 
 static void intel_hdmi_destroy(struct drm_connector *connector)
index 527cfa2626bff5ed92378ea22869d95050c6f952..a3b82081e1a71b0fbcfccc654c347b9bd9783b2a 100644 (file)
@@ -639,7 +639,7 @@ static int intel_lvds_get_modes(struct drm_connector *connector)
        int ret = 0;
 
        if (dev_priv->lvds_edid_good) {
-               ret = intel_ddc_get_modes(intel_encoder);
+               ret = intel_ddc_get_modes(connector, intel_encoder->ddc_bus);
 
                if (ret)
                        return ret;
@@ -1066,7 +1066,7 @@ void intel_lvds_init(struct drm_device *dev)
         */
        dev_priv->lvds_edid_good = true;
 
-       if (!intel_ddc_get_modes(intel_encoder))
+       if (!intel_ddc_get_modes(connector, intel_encoder->ddc_bus))
                dev_priv->lvds_edid_good = false;
 
        list_for_each_entry(scan, &connector->probed_modes, head) {
index 3111a1c2731f2b398e2b8400dcfd8f12a6e85a19..9562176defc4be349a1daf787bed0e0e3cbb5d10 100644 (file)
@@ -53,9 +53,9 @@ bool intel_ddc_probe(struct intel_encoder *intel_encoder)
                }
        };
 
-       intel_i2c_quirk_set(intel_encoder->base.dev, true);
+       intel_i2c_quirk_set(intel_encoder->enc.dev, true);
        ret = i2c_transfer(intel_encoder->ddc_bus, msgs, 2);
-       intel_i2c_quirk_set(intel_encoder->base.dev, false);
+       intel_i2c_quirk_set(intel_encoder->enc.dev, false);
        if (ret == 2)
                return true;
 
@@ -65,22 +65,23 @@ bool intel_ddc_probe(struct intel_encoder *intel_encoder)
 /**
  * intel_ddc_get_modes - get modelist from monitor
  * @connector: DRM connector device to use
+ * @adapter: i2c adapter
  *
  * Fetch the EDID information from @connector using the DDC bus.
  */
-int intel_ddc_get_modes(struct intel_encoder *intel_encoder)
+int intel_ddc_get_modes(struct drm_connector *connector,
+                       struct i2c_adapter *adapter)
 {
        struct edid *edid;
        int ret = 0;
 
-       intel_i2c_quirk_set(intel_encoder->base.dev, true);
-       edid = drm_get_edid(&intel_encoder->base, intel_encoder->ddc_bus);
-       intel_i2c_quirk_set(intel_encoder->base.dev, false);
+       intel_i2c_quirk_set(connector->dev, true);
+       edid = drm_get_edid(connector, adapter);
+       intel_i2c_quirk_set(connector->dev, false);
        if (edid) {
-               drm_mode_connector_update_edid_property(&intel_encoder->base,
-                                                       edid);
-               ret = drm_add_edid_modes(&intel_encoder->base, edid);
-               intel_encoder->base.display_info.raw_edid = NULL;
+               drm_mode_connector_update_edid_property(connector, edid);
+               ret = drm_add_edid_modes(connector, edid);
+               connector->display_info.raw_edid = NULL;
                kfree(edid);
        }
 
index a5b049f94915ed7d41d192a60f9ab542b27228c4..097819c51a15b63a961f0adf234523402a9e0852 100644 (file)
@@ -1729,7 +1729,7 @@ static void intel_sdvo_get_ddc_modes(struct drm_connector *connector)
        int num_modes;
 
        /* set the bus switch and get the modes */
-       num_modes = intel_ddc_get_modes(intel_encoder);
+       num_modes = intel_ddc_get_modes(connector, intel_encoder->ddc_bus);
 
        /*
         * Mac mini hack.  On this device, the DVI-I connector shares one DDC
@@ -1740,16 +1740,9 @@ static void intel_sdvo_get_ddc_modes(struct drm_connector *connector)
        if (num_modes == 0 &&
            sdvo_priv->analog_ddc_bus &&
            !intel_analog_is_connected(intel_encoder->base.dev)) {
-               struct i2c_adapter *digital_ddc_bus;
-
                /* Switch to the analog ddc bus and try that
                 */
-               digital_ddc_bus = intel_encoder->ddc_bus;
-               intel_encoder->ddc_bus = sdvo_priv->analog_ddc_bus;
-
-               (void) intel_ddc_get_modes(intel_encoder);
-
-               intel_encoder->ddc_bus = digital_ddc_bus;
+               (void) intel_ddc_get_modes(connector, sdvo_priv->analog_ddc_bus);
        }
 }
 
@@ -1872,7 +1865,7 @@ static void intel_sdvo_get_lvds_modes(struct drm_connector *connector)
         * Assume that the preferred modes are
         * arranged in priority order.
         */
-       intel_ddc_get_modes(intel_encoder);
+       intel_ddc_get_modes(connector, intel_encoder->ddc_bus);
        if (list_empty(&connector->probed_modes) == false)
                goto end;