diff options
Diffstat (limited to 'drivers/gpu/drm/i915/intel_dvo.c')
-rw-r--r-- | drivers/gpu/drm/i915/intel_dvo.c | 71 |
1 files changed, 29 insertions, 42 deletions
diff --git a/drivers/gpu/drm/i915/intel_dvo.c b/drivers/gpu/drm/i915/intel_dvo.c index 7c9ec1472d46..6eda1b51c636 100644 --- a/drivers/gpu/drm/i915/intel_dvo.c +++ b/drivers/gpu/drm/i915/intel_dvo.c | |||
@@ -72,7 +72,7 @@ static const struct intel_dvo_device intel_dvo_devices[] = { | |||
72 | .name = "ch7017", | 72 | .name = "ch7017", |
73 | .dvo_reg = DVOC, | 73 | .dvo_reg = DVOC, |
74 | .slave_addr = 0x75, | 74 | .slave_addr = 0x75, |
75 | .gpio = GPIOE, | 75 | .gpio = GMBUS_PORT_DPB, |
76 | .dev_ops = &ch7017_ops, | 76 | .dev_ops = &ch7017_ops, |
77 | } | 77 | } |
78 | }; | 78 | }; |
@@ -88,7 +88,13 @@ struct intel_dvo { | |||
88 | 88 | ||
89 | static struct intel_dvo *enc_to_intel_dvo(struct drm_encoder *encoder) | 89 | static struct intel_dvo *enc_to_intel_dvo(struct drm_encoder *encoder) |
90 | { | 90 | { |
91 | return container_of(enc_to_intel_encoder(encoder), struct intel_dvo, base); | 91 | return container_of(encoder, struct intel_dvo, base.base); |
92 | } | ||
93 | |||
94 | static struct intel_dvo *intel_attached_dvo(struct drm_connector *connector) | ||
95 | { | ||
96 | return container_of(intel_attached_encoder(connector), | ||
97 | struct intel_dvo, base); | ||
92 | } | 98 | } |
93 | 99 | ||
94 | static void intel_dvo_dpms(struct drm_encoder *encoder, int mode) | 100 | static void intel_dvo_dpms(struct drm_encoder *encoder, int mode) |
@@ -112,8 +118,7 @@ static void intel_dvo_dpms(struct drm_encoder *encoder, int mode) | |||
112 | static int intel_dvo_mode_valid(struct drm_connector *connector, | 118 | static int intel_dvo_mode_valid(struct drm_connector *connector, |
113 | struct drm_display_mode *mode) | 119 | struct drm_display_mode *mode) |
114 | { | 120 | { |
115 | struct drm_encoder *encoder = intel_attached_encoder(connector); | 121 | struct intel_dvo *intel_dvo = intel_attached_dvo(connector); |
116 | struct intel_dvo *intel_dvo = enc_to_intel_dvo(encoder); | ||
117 | 122 | ||
118 | if (mode->flags & DRM_MODE_FLAG_DBLSCAN) | 123 | if (mode->flags & DRM_MODE_FLAG_DBLSCAN) |
119 | return MODE_NO_DBLESCAN; | 124 | return MODE_NO_DBLESCAN; |
@@ -173,7 +178,7 @@ static void intel_dvo_mode_set(struct drm_encoder *encoder, | |||
173 | int pipe = intel_crtc->pipe; | 178 | int pipe = intel_crtc->pipe; |
174 | u32 dvo_val; | 179 | u32 dvo_val; |
175 | u32 dvo_reg = intel_dvo->dev.dvo_reg, dvo_srcdim_reg; | 180 | u32 dvo_reg = intel_dvo->dev.dvo_reg, dvo_srcdim_reg; |
176 | int dpll_reg = (pipe == 0) ? DPLL_A : DPLL_B; | 181 | int dpll_reg = DPLL(pipe); |
177 | 182 | ||
178 | switch (dvo_reg) { | 183 | switch (dvo_reg) { |
179 | case DVOA: | 184 | case DVOA: |
@@ -224,23 +229,22 @@ static void intel_dvo_mode_set(struct drm_encoder *encoder, | |||
224 | static enum drm_connector_status | 229 | static enum drm_connector_status |
225 | intel_dvo_detect(struct drm_connector *connector, bool force) | 230 | intel_dvo_detect(struct drm_connector *connector, bool force) |
226 | { | 231 | { |
227 | struct drm_encoder *encoder = intel_attached_encoder(connector); | 232 | struct intel_dvo *intel_dvo = intel_attached_dvo(connector); |
228 | struct intel_dvo *intel_dvo = enc_to_intel_dvo(encoder); | ||
229 | |||
230 | return intel_dvo->dev.dev_ops->detect(&intel_dvo->dev); | 233 | return intel_dvo->dev.dev_ops->detect(&intel_dvo->dev); |
231 | } | 234 | } |
232 | 235 | ||
233 | static int intel_dvo_get_modes(struct drm_connector *connector) | 236 | static int intel_dvo_get_modes(struct drm_connector *connector) |
234 | { | 237 | { |
235 | struct drm_encoder *encoder = intel_attached_encoder(connector); | 238 | struct intel_dvo *intel_dvo = intel_attached_dvo(connector); |
236 | struct intel_dvo *intel_dvo = enc_to_intel_dvo(encoder); | 239 | struct drm_i915_private *dev_priv = connector->dev->dev_private; |
237 | 240 | ||
238 | /* We should probably have an i2c driver get_modes function for those | 241 | /* We should probably have an i2c driver get_modes function for those |
239 | * devices which will have a fixed set of modes determined by the chip | 242 | * devices which will have a fixed set of modes determined by the chip |
240 | * (TV-out, for example), but for now with just TMDS and LVDS, | 243 | * (TV-out, for example), but for now with just TMDS and LVDS, |
241 | * that's not the case. | 244 | * that's not the case. |
242 | */ | 245 | */ |
243 | intel_ddc_get_modes(connector, intel_dvo->base.ddc_bus); | 246 | intel_ddc_get_modes(connector, |
247 | &dev_priv->gmbus[GMBUS_PORT_DPC].adapter); | ||
244 | if (!list_empty(&connector->probed_modes)) | 248 | if (!list_empty(&connector->probed_modes)) |
245 | return 1; | 249 | return 1; |
246 | 250 | ||
@@ -281,7 +285,7 @@ static const struct drm_connector_funcs intel_dvo_connector_funcs = { | |||
281 | static const struct drm_connector_helper_funcs intel_dvo_connector_helper_funcs = { | 285 | static const struct drm_connector_helper_funcs intel_dvo_connector_helper_funcs = { |
282 | .mode_valid = intel_dvo_mode_valid, | 286 | .mode_valid = intel_dvo_mode_valid, |
283 | .get_modes = intel_dvo_get_modes, | 287 | .get_modes = intel_dvo_get_modes, |
284 | .best_encoder = intel_attached_encoder, | 288 | .best_encoder = intel_best_encoder, |
285 | }; | 289 | }; |
286 | 290 | ||
287 | static void intel_dvo_enc_destroy(struct drm_encoder *encoder) | 291 | static void intel_dvo_enc_destroy(struct drm_encoder *encoder) |
@@ -311,8 +315,7 @@ intel_dvo_get_current_mode(struct drm_connector *connector) | |||
311 | { | 315 | { |
312 | struct drm_device *dev = connector->dev; | 316 | struct drm_device *dev = connector->dev; |
313 | struct drm_i915_private *dev_priv = dev->dev_private; | 317 | struct drm_i915_private *dev_priv = dev->dev_private; |
314 | struct drm_encoder *encoder = intel_attached_encoder(connector); | 318 | struct intel_dvo *intel_dvo = intel_attached_dvo(connector); |
315 | struct intel_dvo *intel_dvo = enc_to_intel_dvo(encoder); | ||
316 | uint32_t dvo_val = I915_READ(intel_dvo->dev.dvo_reg); | 319 | uint32_t dvo_val = I915_READ(intel_dvo->dev.dvo_reg); |
317 | struct drm_display_mode *mode = NULL; | 320 | struct drm_display_mode *mode = NULL; |
318 | 321 | ||
@@ -323,7 +326,7 @@ intel_dvo_get_current_mode(struct drm_connector *connector) | |||
323 | struct drm_crtc *crtc; | 326 | struct drm_crtc *crtc; |
324 | int pipe = (dvo_val & DVO_PIPE_B_SELECT) ? 1 : 0; | 327 | int pipe = (dvo_val & DVO_PIPE_B_SELECT) ? 1 : 0; |
325 | 328 | ||
326 | crtc = intel_get_crtc_from_pipe(dev, pipe); | 329 | crtc = intel_get_crtc_for_pipe(dev, pipe); |
327 | if (crtc) { | 330 | if (crtc) { |
328 | mode = intel_crtc_mode_get(dev, crtc); | 331 | mode = intel_crtc_mode_get(dev, crtc); |
329 | if (mode) { | 332 | if (mode) { |
@@ -341,11 +344,10 @@ intel_dvo_get_current_mode(struct drm_connector *connector) | |||
341 | 344 | ||
342 | void intel_dvo_init(struct drm_device *dev) | 345 | void intel_dvo_init(struct drm_device *dev) |
343 | { | 346 | { |
347 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
344 | struct intel_encoder *intel_encoder; | 348 | struct intel_encoder *intel_encoder; |
345 | struct intel_dvo *intel_dvo; | 349 | struct intel_dvo *intel_dvo; |
346 | struct intel_connector *intel_connector; | 350 | struct intel_connector *intel_connector; |
347 | struct i2c_adapter *i2cbus = NULL; | ||
348 | int ret = 0; | ||
349 | int i; | 351 | int i; |
350 | int encoder_type = DRM_MODE_ENCODER_NONE; | 352 | int encoder_type = DRM_MODE_ENCODER_NONE; |
351 | 353 | ||
@@ -360,16 +362,14 @@ void intel_dvo_init(struct drm_device *dev) | |||
360 | } | 362 | } |
361 | 363 | ||
362 | intel_encoder = &intel_dvo->base; | 364 | intel_encoder = &intel_dvo->base; |
363 | 365 | drm_encoder_init(dev, &intel_encoder->base, | |
364 | /* Set up the DDC bus */ | 366 | &intel_dvo_enc_funcs, encoder_type); |
365 | intel_encoder->ddc_bus = intel_i2c_create(dev, GPIOD, "DVODDC_D"); | ||
366 | if (!intel_encoder->ddc_bus) | ||
367 | goto free_intel; | ||
368 | 367 | ||
369 | /* Now, try to find a controller */ | 368 | /* Now, try to find a controller */ |
370 | for (i = 0; i < ARRAY_SIZE(intel_dvo_devices); i++) { | 369 | for (i = 0; i < ARRAY_SIZE(intel_dvo_devices); i++) { |
371 | struct drm_connector *connector = &intel_connector->base; | 370 | struct drm_connector *connector = &intel_connector->base; |
372 | const struct intel_dvo_device *dvo = &intel_dvo_devices[i]; | 371 | const struct intel_dvo_device *dvo = &intel_dvo_devices[i]; |
372 | struct i2c_adapter *i2c; | ||
373 | int gpio; | 373 | int gpio; |
374 | 374 | ||
375 | /* Allow the I2C driver info to specify the GPIO to be used in | 375 | /* Allow the I2C driver info to specify the GPIO to be used in |
@@ -379,24 +379,18 @@ void intel_dvo_init(struct drm_device *dev) | |||
379 | if (dvo->gpio != 0) | 379 | if (dvo->gpio != 0) |
380 | gpio = dvo->gpio; | 380 | gpio = dvo->gpio; |
381 | else if (dvo->type == INTEL_DVO_CHIP_LVDS) | 381 | else if (dvo->type == INTEL_DVO_CHIP_LVDS) |
382 | gpio = GPIOB; | 382 | gpio = GMBUS_PORT_SSC; |
383 | else | 383 | else |
384 | gpio = GPIOE; | 384 | gpio = GMBUS_PORT_DPB; |
385 | 385 | ||
386 | /* Set up the I2C bus necessary for the chip we're probing. | 386 | /* Set up the I2C bus necessary for the chip we're probing. |
387 | * It appears that everything is on GPIOE except for panels | 387 | * It appears that everything is on GPIOE except for panels |
388 | * on i830 laptops, which are on GPIOB (DVOA). | 388 | * on i830 laptops, which are on GPIOB (DVOA). |
389 | */ | 389 | */ |
390 | if (i2cbus != NULL) | 390 | i2c = &dev_priv->gmbus[gpio].adapter; |
391 | intel_i2c_destroy(i2cbus); | ||
392 | if (!(i2cbus = intel_i2c_create(dev, gpio, | ||
393 | gpio == GPIOB ? "DVOI2C_B" : "DVOI2C_E"))) { | ||
394 | continue; | ||
395 | } | ||
396 | 391 | ||
397 | intel_dvo->dev = *dvo; | 392 | intel_dvo->dev = *dvo; |
398 | ret = dvo->dev_ops->init(&intel_dvo->dev, i2cbus); | 393 | if (!dvo->dev_ops->init(&intel_dvo->dev, i2c)) |
399 | if (!ret) | ||
400 | continue; | 394 | continue; |
401 | 395 | ||
402 | intel_encoder->type = INTEL_OUTPUT_DVO; | 396 | intel_encoder->type = INTEL_OUTPUT_DVO; |
@@ -427,13 +421,10 @@ void intel_dvo_init(struct drm_device *dev) | |||
427 | connector->interlace_allowed = false; | 421 | connector->interlace_allowed = false; |
428 | connector->doublescan_allowed = false; | 422 | connector->doublescan_allowed = false; |
429 | 423 | ||
430 | drm_encoder_init(dev, &intel_encoder->enc, | 424 | drm_encoder_helper_add(&intel_encoder->base, |
431 | &intel_dvo_enc_funcs, encoder_type); | ||
432 | drm_encoder_helper_add(&intel_encoder->enc, | ||
433 | &intel_dvo_helper_funcs); | 425 | &intel_dvo_helper_funcs); |
434 | 426 | ||
435 | drm_mode_connector_attach_encoder(&intel_connector->base, | 427 | intel_connector_attach_encoder(intel_connector, intel_encoder); |
436 | &intel_encoder->enc); | ||
437 | if (dvo->type == INTEL_DVO_CHIP_LVDS) { | 428 | if (dvo->type == INTEL_DVO_CHIP_LVDS) { |
438 | /* For our LVDS chipsets, we should hopefully be able | 429 | /* For our LVDS chipsets, we should hopefully be able |
439 | * to dig the fixed panel mode out of the BIOS data. | 430 | * to dig the fixed panel mode out of the BIOS data. |
@@ -451,11 +442,7 @@ void intel_dvo_init(struct drm_device *dev) | |||
451 | return; | 442 | return; |
452 | } | 443 | } |
453 | 444 | ||
454 | intel_i2c_destroy(intel_encoder->ddc_bus); | 445 | drm_encoder_cleanup(&intel_encoder->base); |
455 | /* Didn't find a chip, so tear down. */ | ||
456 | if (i2cbus != NULL) | ||
457 | intel_i2c_destroy(i2cbus); | ||
458 | free_intel: | ||
459 | kfree(intel_dvo); | 446 | kfree(intel_dvo); |
460 | kfree(intel_connector); | 447 | kfree(intel_connector); |
461 | } | 448 | } |