diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2010-09-14 11:46:59 -0400 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2010-09-14 16:08:36 -0400 |
commit | 890f3359f7b84d7015104360d647ccac5f515542 (patch) | |
tree | 88c65ad9638fd84d3921fbe9a9fbecb42816c1ec | |
parent | 2cf34d7b7ee99c27c1a6bdd2f91344cbfa5fef5c (diff) |
drm/i915/i2c: Track the parent encoder rather than just the dev
The SDVO proxy i2c adapter wants to be able to use information stored in
the encoder, so pass that through intel_i2c rather than iterate over all
known encoders every time.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r-- | drivers/gpu/drm/i915/intel_crt.c | 9 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/intel_drv.h | 5 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/intel_dvo.c | 9 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/intel_hdmi.c | 18 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/intel_i2c.c | 26 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/intel_lvds.c | 3 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/intel_sdvo.c | 62 |
7 files changed, 67 insertions, 65 deletions
diff --git a/drivers/gpu/drm/i915/intel_crt.c b/drivers/gpu/drm/i915/intel_crt.c index b39183bcc9fa..0403ec9e164a 100644 --- a/drivers/gpu/drm/i915/intel_crt.c +++ b/drivers/gpu/drm/i915/intel_crt.c | |||
@@ -445,19 +445,17 @@ static void intel_crt_destroy(struct drm_connector *connector) | |||
445 | 445 | ||
446 | static int intel_crt_get_modes(struct drm_connector *connector) | 446 | static int intel_crt_get_modes(struct drm_connector *connector) |
447 | { | 447 | { |
448 | int ret; | ||
449 | struct intel_encoder *encoder = intel_attached_encoder(connector); | 448 | struct intel_encoder *encoder = intel_attached_encoder(connector); |
450 | struct i2c_adapter *ddc_bus; | 449 | struct i2c_adapter *ddc_bus; |
451 | struct drm_device *dev = connector->dev; | 450 | struct drm_device *dev = connector->dev; |
452 | 451 | int ret; | |
453 | 452 | ||
454 | ret = intel_ddc_get_modes(connector, encoder->ddc_bus); | 453 | ret = intel_ddc_get_modes(connector, encoder->ddc_bus); |
455 | if (ret || !IS_G4X(dev)) | 454 | if (ret || !IS_G4X(dev)) |
456 | goto end; | 455 | goto end; |
457 | 456 | ||
458 | /* Try to probe digital port for output in DVI-I -> VGA mode. */ | 457 | /* Try to probe digital port for output in DVI-I -> VGA mode. */ |
459 | ddc_bus = intel_i2c_create(connector->dev, GPIOD, "CRTDDC_D"); | 458 | ddc_bus = intel_i2c_create(encoder, GPIOD, "CRTDDC_D"); |
460 | |||
461 | if (!ddc_bus) { | 459 | if (!ddc_bus) { |
462 | dev_printk(KERN_ERR, &connector->dev->pdev->dev, | 460 | dev_printk(KERN_ERR, &connector->dev->pdev->dev, |
463 | "DDC bus registration failed for CRTDDC_D.\n"); | 461 | "DDC bus registration failed for CRTDDC_D.\n"); |
@@ -545,7 +543,8 @@ void intel_crt_init(struct drm_device *dev) | |||
545 | if (dev_priv->crt_ddc_bus != 0) | 543 | if (dev_priv->crt_ddc_bus != 0) |
546 | i2c_reg = dev_priv->crt_ddc_bus; | 544 | i2c_reg = dev_priv->crt_ddc_bus; |
547 | } | 545 | } |
548 | intel_encoder->ddc_bus = intel_i2c_create(dev, i2c_reg, "CRTDDC_A"); | 546 | intel_encoder->ddc_bus = intel_i2c_create(intel_encoder, |
547 | i2c_reg, "CRTDDC_A"); | ||
549 | if (!intel_encoder->ddc_bus) { | 548 | if (!intel_encoder->ddc_bus) { |
550 | dev_printk(KERN_ERR, &dev->pdev->dev, "DDC bus registration " | 549 | dev_printk(KERN_ERR, &dev->pdev->dev, "DDC bus registration " |
551 | "failed.\n"); | 550 | "failed.\n"); |
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h index 31f072d31e37..8fe6b730c679 100644 --- a/drivers/gpu/drm/i915/intel_drv.h +++ b/drivers/gpu/drm/i915/intel_drv.h | |||
@@ -128,7 +128,7 @@ intel_mode_get_pixel_multiplier(const struct drm_display_mode *mode) | |||
128 | } | 128 | } |
129 | 129 | ||
130 | struct intel_i2c_chan { | 130 | struct intel_i2c_chan { |
131 | struct drm_device *drm_dev; /* for getting at dev. private (mmio etc.) */ | 131 | struct intel_encoder *encoder; |
132 | u32 reg; /* GPIO reg */ | 132 | u32 reg; /* GPIO reg */ |
133 | struct i2c_adapter adapter; | 133 | struct i2c_adapter adapter; |
134 | struct i2c_algo_bit_data algo; | 134 | struct i2c_algo_bit_data algo; |
@@ -206,7 +206,8 @@ struct intel_unpin_work { | |||
206 | bool enable_stall_check; | 206 | bool enable_stall_check; |
207 | }; | 207 | }; |
208 | 208 | ||
209 | struct i2c_adapter *intel_i2c_create(struct drm_device *dev, const u32 reg, | 209 | struct i2c_adapter *intel_i2c_create(struct intel_encoder *encoder, |
210 | const u32 reg, | ||
210 | const char *name); | 211 | const char *name); |
211 | void intel_i2c_destroy(struct i2c_adapter *adapter); | 212 | void intel_i2c_destroy(struct i2c_adapter *adapter); |
212 | int intel_ddc_get_modes(struct drm_connector *c, struct i2c_adapter *adapter); | 213 | int intel_ddc_get_modes(struct drm_connector *c, struct i2c_adapter *adapter); |
diff --git a/drivers/gpu/drm/i915/intel_dvo.c b/drivers/gpu/drm/i915/intel_dvo.c index df42a9c9afc1..7de7d1a68c07 100644 --- a/drivers/gpu/drm/i915/intel_dvo.c +++ b/drivers/gpu/drm/i915/intel_dvo.c | |||
@@ -362,7 +362,8 @@ void intel_dvo_init(struct drm_device *dev) | |||
362 | intel_encoder = &intel_dvo->base; | 362 | intel_encoder = &intel_dvo->base; |
363 | 363 | ||
364 | /* Set up the DDC bus */ | 364 | /* Set up the DDC bus */ |
365 | intel_encoder->ddc_bus = intel_i2c_create(dev, GPIOD, "DVODDC_D"); | 365 | intel_encoder->ddc_bus = intel_i2c_create(intel_encoder, |
366 | GPIOD, "DVODDC_D"); | ||
366 | if (!intel_encoder->ddc_bus) | 367 | if (!intel_encoder->ddc_bus) |
367 | goto free_intel; | 368 | goto free_intel; |
368 | 369 | ||
@@ -389,10 +390,10 @@ void intel_dvo_init(struct drm_device *dev) | |||
389 | */ | 390 | */ |
390 | if (i2cbus != NULL) | 391 | if (i2cbus != NULL) |
391 | intel_i2c_destroy(i2cbus); | 392 | intel_i2c_destroy(i2cbus); |
392 | if (!(i2cbus = intel_i2c_create(dev, gpio, | 393 | i2cbus = intel_i2c_create(intel_encoder, gpio, |
393 | gpio == GPIOB ? "DVOI2C_B" : "DVOI2C_E"))) { | 394 | gpio == GPIOB ? "DVOI2C_B" : "DVOI2C_E"); |
395 | if (i2cbus == NULL) | ||
394 | continue; | 396 | continue; |
395 | } | ||
396 | 397 | ||
397 | intel_dvo->dev = *dvo; | 398 | intel_dvo->dev = *dvo; |
398 | ret = dvo->dev_ops->init(&intel_dvo->dev, i2cbus); | 399 | ret = dvo->dev_ops->init(&intel_dvo->dev, i2cbus); |
diff --git a/drivers/gpu/drm/i915/intel_hdmi.c b/drivers/gpu/drm/i915/intel_hdmi.c index bba0aba15a96..93d5b61bf5bd 100644 --- a/drivers/gpu/drm/i915/intel_hdmi.c +++ b/drivers/gpu/drm/i915/intel_hdmi.c | |||
@@ -243,26 +243,28 @@ void intel_hdmi_init(struct drm_device *dev, int sdvox_reg) | |||
243 | /* Set up the DDC bus. */ | 243 | /* Set up the DDC bus. */ |
244 | if (sdvox_reg == SDVOB) { | 244 | if (sdvox_reg == SDVOB) { |
245 | intel_encoder->clone_mask = (1 << INTEL_HDMIB_CLONE_BIT); | 245 | intel_encoder->clone_mask = (1 << INTEL_HDMIB_CLONE_BIT); |
246 | intel_encoder->ddc_bus = intel_i2c_create(dev, GPIOE, "HDMIB"); | 246 | intel_encoder->ddc_bus = intel_i2c_create(intel_encoder, |
247 | GPIOE, "HDMIB"); | ||
247 | dev_priv->hotplug_supported_mask |= HDMIB_HOTPLUG_INT_STATUS; | 248 | dev_priv->hotplug_supported_mask |= HDMIB_HOTPLUG_INT_STATUS; |
248 | } else if (sdvox_reg == SDVOC) { | 249 | } else if (sdvox_reg == SDVOC) { |
249 | intel_encoder->clone_mask = (1 << INTEL_HDMIC_CLONE_BIT); | 250 | intel_encoder->clone_mask = (1 << INTEL_HDMIC_CLONE_BIT); |
250 | intel_encoder->ddc_bus = intel_i2c_create(dev, GPIOD, "HDMIC"); | 251 | intel_encoder->ddc_bus = intel_i2c_create(intel_encoder, |
252 | GPIOD, "HDMIC"); | ||
251 | dev_priv->hotplug_supported_mask |= HDMIC_HOTPLUG_INT_STATUS; | 253 | dev_priv->hotplug_supported_mask |= HDMIC_HOTPLUG_INT_STATUS; |
252 | } else if (sdvox_reg == HDMIB) { | 254 | } else if (sdvox_reg == HDMIB) { |
253 | intel_encoder->clone_mask = (1 << INTEL_HDMID_CLONE_BIT); | 255 | intel_encoder->clone_mask = (1 << INTEL_HDMID_CLONE_BIT); |
254 | intel_encoder->ddc_bus = intel_i2c_create(dev, PCH_GPIOE, | 256 | intel_encoder->ddc_bus = intel_i2c_create(intel_encoder, |
255 | "HDMIB"); | 257 | PCH_GPIOE, "HDMIB"); |
256 | dev_priv->hotplug_supported_mask |= HDMIB_HOTPLUG_INT_STATUS; | 258 | dev_priv->hotplug_supported_mask |= HDMIB_HOTPLUG_INT_STATUS; |
257 | } else if (sdvox_reg == HDMIC) { | 259 | } else if (sdvox_reg == HDMIC) { |
258 | intel_encoder->clone_mask = (1 << INTEL_HDMIE_CLONE_BIT); | 260 | intel_encoder->clone_mask = (1 << INTEL_HDMIE_CLONE_BIT); |
259 | intel_encoder->ddc_bus = intel_i2c_create(dev, PCH_GPIOD, | 261 | intel_encoder->ddc_bus = intel_i2c_create(intel_encoder, |
260 | "HDMIC"); | 262 | PCH_GPIOD, "HDMIC"); |
261 | dev_priv->hotplug_supported_mask |= HDMIC_HOTPLUG_INT_STATUS; | 263 | dev_priv->hotplug_supported_mask |= HDMIC_HOTPLUG_INT_STATUS; |
262 | } else if (sdvox_reg == HDMID) { | 264 | } else if (sdvox_reg == HDMID) { |
263 | intel_encoder->clone_mask = (1 << INTEL_HDMIF_CLONE_BIT); | 265 | intel_encoder->clone_mask = (1 << INTEL_HDMIF_CLONE_BIT); |
264 | intel_encoder->ddc_bus = intel_i2c_create(dev, PCH_GPIOF, | 266 | intel_encoder->ddc_bus = intel_i2c_create(intel_encoder, |
265 | "HDMID"); | 267 | PCH_GPIOF, "HDMID"); |
266 | dev_priv->hotplug_supported_mask |= HDMID_HOTPLUG_INT_STATUS; | 268 | dev_priv->hotplug_supported_mask |= HDMID_HOTPLUG_INT_STATUS; |
267 | } | 269 | } |
268 | if (!intel_encoder->ddc_bus) | 270 | if (!intel_encoder->ddc_bus) |
diff --git a/drivers/gpu/drm/i915/intel_i2c.c b/drivers/gpu/drm/i915/intel_i2c.c index de03989d6df3..d3d65a9cfba1 100644 --- a/drivers/gpu/drm/i915/intel_i2c.c +++ b/drivers/gpu/drm/i915/intel_i2c.c | |||
@@ -58,25 +58,31 @@ void intel_i2c_quirk_set(struct drm_device *dev, bool enable) | |||
58 | 58 | ||
59 | #define I2C_RISEFALL_TIME 20 | 59 | #define I2C_RISEFALL_TIME 20 |
60 | 60 | ||
61 | static inline struct drm_i915_private * | ||
62 | get_dev_priv(struct intel_i2c_chan *chan) | ||
63 | { | ||
64 | return chan->encoder->base.dev->dev_private; | ||
65 | } | ||
66 | |||
61 | static int get_clock(void *data) | 67 | static int get_clock(void *data) |
62 | { | 68 | { |
63 | struct intel_i2c_chan *chan = data; | 69 | struct intel_i2c_chan *chan = data; |
64 | struct drm_i915_private *dev_priv = chan->drm_dev->dev_private; | 70 | struct drm_i915_private *dev_priv = get_dev_priv(chan); |
65 | return (I915_READ(chan->reg) & GPIO_CLOCK_VAL_IN) != 0; | 71 | return (I915_READ(chan->reg) & GPIO_CLOCK_VAL_IN) != 0; |
66 | } | 72 | } |
67 | 73 | ||
68 | static int get_data(void *data) | 74 | static int get_data(void *data) |
69 | { | 75 | { |
70 | struct intel_i2c_chan *chan = data; | 76 | struct intel_i2c_chan *chan = data; |
71 | struct drm_i915_private *dev_priv = chan->drm_dev->dev_private; | 77 | struct drm_i915_private *dev_priv = get_dev_priv(chan); |
72 | return (I915_READ(chan->reg) & GPIO_DATA_VAL_IN) != 0; | 78 | return (I915_READ(chan->reg) & GPIO_DATA_VAL_IN) != 0; |
73 | } | 79 | } |
74 | 80 | ||
75 | static void set_clock(void *data, int state_high) | 81 | static void set_clock(void *data, int state_high) |
76 | { | 82 | { |
77 | struct intel_i2c_chan *chan = data; | 83 | struct intel_i2c_chan *chan = data; |
78 | struct drm_device *dev = chan->drm_dev; | 84 | struct drm_i915_private *dev_priv = get_dev_priv(chan); |
79 | struct drm_i915_private *dev_priv = chan->drm_dev->dev_private; | 85 | struct drm_device *dev = dev_priv->dev; |
80 | u32 reserved = 0, clock_bits; | 86 | u32 reserved = 0, clock_bits; |
81 | 87 | ||
82 | /* On most chips, these bits must be preserved in software. */ | 88 | /* On most chips, these bits must be preserved in software. */ |
@@ -96,8 +102,8 @@ static void set_clock(void *data, int state_high) | |||
96 | static void set_data(void *data, int state_high) | 102 | static void set_data(void *data, int state_high) |
97 | { | 103 | { |
98 | struct intel_i2c_chan *chan = data; | 104 | struct intel_i2c_chan *chan = data; |
99 | struct drm_device *dev = chan->drm_dev; | 105 | struct drm_i915_private *dev_priv = get_dev_priv(chan); |
100 | struct drm_i915_private *dev_priv = chan->drm_dev->dev_private; | 106 | struct drm_device *dev = dev_priv->dev; |
101 | u32 reserved = 0, data_bits; | 107 | u32 reserved = 0, data_bits; |
102 | 108 | ||
103 | /* On most chips, these bits must be preserved in software. */ | 109 | /* On most chips, these bits must be preserved in software. */ |
@@ -153,16 +159,18 @@ intel_i2c_reset_gmbus(struct drm_device *dev) | |||
153 | * %GPIOH | 159 | * %GPIOH |
154 | * see PRM for details on how these different busses are used. | 160 | * see PRM for details on how these different busses are used. |
155 | */ | 161 | */ |
156 | struct i2c_adapter *intel_i2c_create(struct drm_device *dev, const u32 reg, | 162 | struct i2c_adapter *intel_i2c_create(struct intel_encoder *encoder, |
163 | const u32 reg, | ||
157 | const char *name) | 164 | const char *name) |
158 | { | 165 | { |
159 | struct intel_i2c_chan *chan; | 166 | struct intel_i2c_chan *chan; |
167 | struct drm_device *dev = encoder->base.dev; | ||
160 | 168 | ||
161 | chan = kzalloc(sizeof(struct intel_i2c_chan), GFP_KERNEL); | 169 | chan = kzalloc(sizeof(struct intel_i2c_chan), GFP_KERNEL); |
162 | if (!chan) | 170 | if (!chan) |
163 | goto out_free; | 171 | goto out_free; |
164 | 172 | ||
165 | chan->drm_dev = dev; | 173 | chan->encoder = encoder; |
166 | chan->reg = reg; | 174 | chan->reg = reg; |
167 | snprintf(chan->adapter.name, I2C_NAME_SIZE, "intel drm %s", name); | 175 | snprintf(chan->adapter.name, I2C_NAME_SIZE, "intel drm %s", name); |
168 | chan->adapter.owner = THIS_MODULE; | 176 | chan->adapter.owner = THIS_MODULE; |
@@ -178,7 +186,7 @@ struct i2c_adapter *intel_i2c_create(struct drm_device *dev, const u32 reg, | |||
178 | 186 | ||
179 | i2c_set_adapdata(&chan->adapter, chan); | 187 | i2c_set_adapdata(&chan->adapter, chan); |
180 | 188 | ||
181 | if(i2c_bit_add_bus(&chan->adapter)) | 189 | if (i2c_bit_add_bus(&chan->adapter)) |
182 | goto out_free; | 190 | goto out_free; |
183 | 191 | ||
184 | intel_i2c_reset_gmbus(dev); | 192 | intel_i2c_reset_gmbus(dev); |
diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c index b56b59236e31..2ff4a5cb2d56 100644 --- a/drivers/gpu/drm/i915/intel_lvds.c +++ b/drivers/gpu/drm/i915/intel_lvds.c | |||
@@ -899,7 +899,8 @@ void intel_lvds_init(struct drm_device *dev) | |||
899 | */ | 899 | */ |
900 | 900 | ||
901 | /* Set up the DDC bus. */ | 901 | /* Set up the DDC bus. */ |
902 | intel_encoder->ddc_bus = intel_i2c_create(dev, gpio, "LVDSDDC_C"); | 902 | intel_encoder->ddc_bus = intel_i2c_create(intel_encoder, |
903 | gpio, "LVDSDDC_C"); | ||
903 | if (!intel_encoder->ddc_bus) { | 904 | if (!intel_encoder->ddc_bus) { |
904 | dev_printk(KERN_ERR, &dev->pdev->dev, "DDC bus registration " | 905 | dev_printk(KERN_ERR, &dev->pdev->dev, "DDC bus registration " |
905 | "failed.\n"); | 906 | "failed.\n"); |
diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c index a812d65fa31e..0e68f9622565 100644 --- a/drivers/gpu/drm/i915/intel_sdvo.c +++ b/drivers/gpu/drm/i915/intel_sdvo.c | |||
@@ -184,7 +184,7 @@ struct intel_sdvo_connector { | |||
184 | u32 cur_dot_crawl, max_dot_crawl; | 184 | u32 cur_dot_crawl, max_dot_crawl; |
185 | }; | 185 | }; |
186 | 186 | ||
187 | static struct intel_sdvo *enc_to_intel_sdvo(struct drm_encoder *encoder) | 187 | static struct intel_sdvo *to_intel_sdvo(struct drm_encoder *encoder) |
188 | { | 188 | { |
189 | return container_of(encoder, struct intel_sdvo, base.base); | 189 | return container_of(encoder, struct intel_sdvo, base.base); |
190 | } | 190 | } |
@@ -1051,7 +1051,7 @@ static bool intel_sdvo_mode_fixup(struct drm_encoder *encoder, | |||
1051 | struct drm_display_mode *mode, | 1051 | struct drm_display_mode *mode, |
1052 | struct drm_display_mode *adjusted_mode) | 1052 | struct drm_display_mode *adjusted_mode) |
1053 | { | 1053 | { |
1054 | struct intel_sdvo *intel_sdvo = enc_to_intel_sdvo(encoder); | 1054 | struct intel_sdvo *intel_sdvo = to_intel_sdvo(encoder); |
1055 | int multiplier; | 1055 | int multiplier; |
1056 | 1056 | ||
1057 | /* We need to construct preferred input timings based on our | 1057 | /* We need to construct preferred input timings based on our |
@@ -1093,7 +1093,7 @@ static void intel_sdvo_mode_set(struct drm_encoder *encoder, | |||
1093 | struct drm_i915_private *dev_priv = dev->dev_private; | 1093 | struct drm_i915_private *dev_priv = dev->dev_private; |
1094 | struct drm_crtc *crtc = encoder->crtc; | 1094 | struct drm_crtc *crtc = encoder->crtc; |
1095 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); | 1095 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
1096 | struct intel_sdvo *intel_sdvo = enc_to_intel_sdvo(encoder); | 1096 | struct intel_sdvo *intel_sdvo = to_intel_sdvo(encoder); |
1097 | u32 sdvox; | 1097 | u32 sdvox; |
1098 | struct intel_sdvo_in_out_map in_out; | 1098 | struct intel_sdvo_in_out_map in_out; |
1099 | struct intel_sdvo_dtd input_dtd; | 1099 | struct intel_sdvo_dtd input_dtd; |
@@ -1200,7 +1200,7 @@ static void intel_sdvo_dpms(struct drm_encoder *encoder, int mode) | |||
1200 | { | 1200 | { |
1201 | struct drm_device *dev = encoder->dev; | 1201 | struct drm_device *dev = encoder->dev; |
1202 | struct drm_i915_private *dev_priv = dev->dev_private; | 1202 | struct drm_i915_private *dev_priv = dev->dev_private; |
1203 | struct intel_sdvo *intel_sdvo = enc_to_intel_sdvo(encoder); | 1203 | struct intel_sdvo *intel_sdvo = to_intel_sdvo(encoder); |
1204 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc); | 1204 | struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc); |
1205 | u32 temp; | 1205 | u32 temp; |
1206 | 1206 | ||
@@ -1899,7 +1899,7 @@ static const struct drm_connector_helper_funcs intel_sdvo_connector_helper_funcs | |||
1899 | 1899 | ||
1900 | static void intel_sdvo_enc_destroy(struct drm_encoder *encoder) | 1900 | static void intel_sdvo_enc_destroy(struct drm_encoder *encoder) |
1901 | { | 1901 | { |
1902 | struct intel_sdvo *intel_sdvo = enc_to_intel_sdvo(encoder); | 1902 | struct intel_sdvo *intel_sdvo = to_intel_sdvo(encoder); |
1903 | 1903 | ||
1904 | if (intel_sdvo->analog_ddc_bus) | 1904 | if (intel_sdvo->analog_ddc_bus) |
1905 | intel_i2c_destroy(intel_sdvo->analog_ddc_bus); | 1905 | intel_i2c_destroy(intel_sdvo->analog_ddc_bus); |
@@ -1984,35 +1984,15 @@ intel_sdvo_get_digital_encoding_mode(struct intel_sdvo *intel_sdvo, int device) | |||
1984 | &intel_sdvo->is_hdmi, 1); | 1984 | &intel_sdvo->is_hdmi, 1); |
1985 | } | 1985 | } |
1986 | 1986 | ||
1987 | static struct intel_sdvo * | ||
1988 | intel_sdvo_chan_to_intel_sdvo(struct intel_i2c_chan *chan) | ||
1989 | { | ||
1990 | struct drm_device *dev = chan->drm_dev; | ||
1991 | struct drm_encoder *encoder; | ||
1992 | |||
1993 | list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { | ||
1994 | struct intel_sdvo *intel_sdvo = enc_to_intel_sdvo(encoder); | ||
1995 | if (intel_sdvo->base.ddc_bus == &chan->adapter) | ||
1996 | return intel_sdvo; | ||
1997 | } | ||
1998 | |||
1999 | return NULL; | ||
2000 | } | ||
2001 | |||
2002 | static int intel_sdvo_master_xfer(struct i2c_adapter *i2c_adap, | 1987 | static int intel_sdvo_master_xfer(struct i2c_adapter *i2c_adap, |
2003 | struct i2c_msg msgs[], int num) | 1988 | struct i2c_msg msgs[], int num) |
2004 | { | 1989 | { |
2005 | struct intel_sdvo *intel_sdvo; | 1990 | struct intel_sdvo *intel_sdvo; |
2006 | struct i2c_algo_bit_data *algo_data; | ||
2007 | const struct i2c_algorithm *algo; | 1991 | const struct i2c_algorithm *algo; |
2008 | 1992 | ||
2009 | algo_data = (struct i2c_algo_bit_data *)i2c_adap->algo_data; | 1993 | intel_sdvo = container_of(i2c_adap->algo_data, |
2010 | intel_sdvo = | 1994 | struct intel_sdvo, |
2011 | intel_sdvo_chan_to_intel_sdvo((struct intel_i2c_chan *) | 1995 | base); |
2012 | (algo_data->data)); | ||
2013 | if (intel_sdvo == NULL) | ||
2014 | return -EINVAL; | ||
2015 | |||
2016 | algo = intel_sdvo->base.i2c_bus->algo; | 1996 | algo = intel_sdvo->base.i2c_bus->algo; |
2017 | 1997 | ||
2018 | intel_sdvo_set_control_bus_switch(intel_sdvo, intel_sdvo->ddc_bus); | 1998 | intel_sdvo_set_control_bus_switch(intel_sdvo, intel_sdvo->ddc_bus); |
@@ -2560,9 +2540,13 @@ bool intel_sdvo_init(struct drm_device *dev, int sdvo_reg) | |||
2560 | 2540 | ||
2561 | /* setup the DDC bus. */ | 2541 | /* setup the DDC bus. */ |
2562 | if (IS_SDVOB(sdvo_reg)) | 2542 | if (IS_SDVOB(sdvo_reg)) |
2563 | intel_encoder->i2c_bus = intel_i2c_create(dev, i2c_reg, "SDVOCTRL_E for SDVOB"); | 2543 | intel_encoder->i2c_bus = |
2544 | intel_i2c_create(intel_encoder, | ||
2545 | i2c_reg, "SDVOCTRL_E for SDVOB"); | ||
2564 | else | 2546 | else |
2565 | intel_encoder->i2c_bus = intel_i2c_create(dev, i2c_reg, "SDVOCTRL_E for SDVOC"); | 2547 | intel_encoder->i2c_bus = |
2548 | intel_i2c_create(intel_encoder, | ||
2549 | i2c_reg, "SDVOCTRL_E for SDVOC"); | ||
2566 | 2550 | ||
2567 | if (!intel_encoder->i2c_bus) | 2551 | if (!intel_encoder->i2c_bus) |
2568 | goto err_inteloutput; | 2552 | goto err_inteloutput; |
@@ -2583,14 +2567,20 @@ bool intel_sdvo_init(struct drm_device *dev, int sdvo_reg) | |||
2583 | 2567 | ||
2584 | /* setup the DDC bus. */ | 2568 | /* setup the DDC bus. */ |
2585 | if (IS_SDVOB(sdvo_reg)) { | 2569 | if (IS_SDVOB(sdvo_reg)) { |
2586 | intel_encoder->ddc_bus = intel_i2c_create(dev, ddc_reg, "SDVOB DDC BUS"); | 2570 | intel_encoder->ddc_bus = |
2587 | intel_sdvo->analog_ddc_bus = intel_i2c_create(dev, analog_ddc_reg, | 2571 | intel_i2c_create(intel_encoder, |
2588 | "SDVOB/VGA DDC BUS"); | 2572 | ddc_reg, "SDVOB DDC BUS"); |
2573 | intel_sdvo->analog_ddc_bus = | ||
2574 | intel_i2c_create(intel_encoder, | ||
2575 | analog_ddc_reg, "SDVOB/VGA DDC BUS"); | ||
2589 | dev_priv->hotplug_supported_mask |= SDVOB_HOTPLUG_INT_STATUS; | 2576 | dev_priv->hotplug_supported_mask |= SDVOB_HOTPLUG_INT_STATUS; |
2590 | } else { | 2577 | } else { |
2591 | intel_encoder->ddc_bus = intel_i2c_create(dev, ddc_reg, "SDVOC DDC BUS"); | 2578 | intel_encoder->ddc_bus = |
2592 | intel_sdvo->analog_ddc_bus = intel_i2c_create(dev, analog_ddc_reg, | 2579 | intel_i2c_create(intel_encoder, |
2593 | "SDVOC/VGA DDC BUS"); | 2580 | ddc_reg, "SDVOC DDC BUS"); |
2581 | intel_sdvo->analog_ddc_bus = | ||
2582 | intel_i2c_create(intel_encoder, | ||
2583 | analog_ddc_reg, "SDVOC/VGA DDC BUS"); | ||
2594 | dev_priv->hotplug_supported_mask |= SDVOC_HOTPLUG_INT_STATUS; | 2584 | dev_priv->hotplug_supported_mask |= SDVOC_HOTPLUG_INT_STATUS; |
2595 | } | 2585 | } |
2596 | if (intel_encoder->ddc_bus == NULL || intel_sdvo->analog_ddc_bus == NULL) | 2586 | if (intel_encoder->ddc_bus == NULL || intel_sdvo->analog_ddc_bus == NULL) |