diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2010-09-09 11:20:55 -0400 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2010-09-09 12:00:43 -0400 |
commit | df0e924883d029a8651a2a0c7b8da67a07611ed2 (patch) | |
tree | 7482d6c4942c709f2c6812f397c3239326ade3b8 /drivers | |
parent | f875c15a4fbf37534dda30771d8bde8604fbbf09 (diff) |
drm/i915: Make the connector->encoder relationship explicit
Currently we have a exact mapping of a connector onto an encoder for its
whole lifetime. Make this an explicit property of the structure and so
simplify the code.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gpu/drm/i915/intel_crt.c | 25 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/intel_display.c | 27 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/intel_dp.c | 23 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/intel_drv.h | 10 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/intel_dvo.c | 24 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/intel_hdmi.c | 17 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/intel_lvds.c | 11 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/intel_sdvo.c | 86 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/intel_tv.c | 34 |
9 files changed, 130 insertions, 127 deletions
diff --git a/drivers/gpu/drm/i915/intel_crt.c b/drivers/gpu/drm/i915/intel_crt.c index e3f5e218036d..b39183bcc9fa 100644 --- a/drivers/gpu/drm/i915/intel_crt.c +++ b/drivers/gpu/drm/i915/intel_crt.c | |||
@@ -404,8 +404,7 @@ intel_crt_load_detect(struct drm_crtc *crtc, struct intel_encoder *intel_encoder | |||
404 | static enum drm_connector_status intel_crt_detect(struct drm_connector *connector) | 404 | static enum drm_connector_status intel_crt_detect(struct drm_connector *connector) |
405 | { | 405 | { |
406 | struct drm_device *dev = connector->dev; | 406 | struct drm_device *dev = connector->dev; |
407 | struct drm_encoder *encoder = intel_attached_encoder(connector); | 407 | struct intel_encoder *encoder = intel_attached_encoder(connector); |
408 | struct intel_encoder *intel_encoder = to_intel_encoder(encoder); | ||
409 | struct drm_crtc *crtc; | 408 | struct drm_crtc *crtc; |
410 | int dpms_mode; | 409 | int dpms_mode; |
411 | enum drm_connector_status status; | 410 | enum drm_connector_status status; |
@@ -417,18 +416,18 @@ static enum drm_connector_status intel_crt_detect(struct drm_connector *connecto | |||
417 | return connector_status_disconnected; | 416 | return connector_status_disconnected; |
418 | } | 417 | } |
419 | 418 | ||
420 | if (intel_crt_detect_ddc(encoder)) | 419 | if (intel_crt_detect_ddc(&encoder->base)) |
421 | return connector_status_connected; | 420 | return connector_status_connected; |
422 | 421 | ||
423 | /* for pre-945g platforms use load detect */ | 422 | /* for pre-945g platforms use load detect */ |
424 | if (encoder->crtc && encoder->crtc->enabled) { | 423 | if (encoder->base.crtc && encoder->base.crtc->enabled) { |
425 | status = intel_crt_load_detect(encoder->crtc, intel_encoder); | 424 | status = intel_crt_load_detect(encoder->base.crtc, encoder); |
426 | } else { | 425 | } else { |
427 | crtc = intel_get_load_detect_pipe(intel_encoder, connector, | 426 | crtc = intel_get_load_detect_pipe(encoder, connector, |
428 | NULL, &dpms_mode); | 427 | NULL, &dpms_mode); |
429 | if (crtc) { | 428 | if (crtc) { |
430 | status = intel_crt_load_detect(crtc, intel_encoder); | 429 | status = intel_crt_load_detect(crtc, encoder); |
431 | intel_release_load_detect_pipe(intel_encoder, | 430 | intel_release_load_detect_pipe(encoder, |
432 | connector, dpms_mode); | 431 | connector, dpms_mode); |
433 | } else | 432 | } else |
434 | status = connector_status_unknown; | 433 | status = connector_status_unknown; |
@@ -447,13 +446,12 @@ static void intel_crt_destroy(struct drm_connector *connector) | |||
447 | static int intel_crt_get_modes(struct drm_connector *connector) | 446 | static int intel_crt_get_modes(struct drm_connector *connector) |
448 | { | 447 | { |
449 | int ret; | 448 | int ret; |
450 | struct drm_encoder *encoder = intel_attached_encoder(connector); | 449 | struct intel_encoder *encoder = intel_attached_encoder(connector); |
451 | struct intel_encoder *intel_encoder = to_intel_encoder(encoder); | ||
452 | struct i2c_adapter *ddc_bus; | 450 | struct i2c_adapter *ddc_bus; |
453 | struct drm_device *dev = connector->dev; | 451 | struct drm_device *dev = connector->dev; |
454 | 452 | ||
455 | 453 | ||
456 | ret = intel_ddc_get_modes(connector, intel_encoder->ddc_bus); | 454 | ret = intel_ddc_get_modes(connector, encoder->ddc_bus); |
457 | if (ret || !IS_G4X(dev)) | 455 | if (ret || !IS_G4X(dev)) |
458 | goto end; | 456 | goto end; |
459 | 457 | ||
@@ -504,7 +502,7 @@ static const struct drm_connector_funcs intel_crt_connector_funcs = { | |||
504 | static const struct drm_connector_helper_funcs intel_crt_connector_helper_funcs = { | 502 | static const struct drm_connector_helper_funcs intel_crt_connector_helper_funcs = { |
505 | .mode_valid = intel_crt_mode_valid, | 503 | .mode_valid = intel_crt_mode_valid, |
506 | .get_modes = intel_crt_get_modes, | 504 | .get_modes = intel_crt_get_modes, |
507 | .best_encoder = intel_attached_encoder, | 505 | .best_encoder = intel_best_encoder, |
508 | }; | 506 | }; |
509 | 507 | ||
510 | static const struct drm_encoder_funcs intel_crt_enc_funcs = { | 508 | static const struct drm_encoder_funcs intel_crt_enc_funcs = { |
@@ -536,8 +534,7 @@ void intel_crt_init(struct drm_device *dev) | |||
536 | drm_encoder_init(dev, &intel_encoder->base, &intel_crt_enc_funcs, | 534 | drm_encoder_init(dev, &intel_encoder->base, &intel_crt_enc_funcs, |
537 | DRM_MODE_ENCODER_DAC); | 535 | DRM_MODE_ENCODER_DAC); |
538 | 536 | ||
539 | drm_mode_connector_attach_encoder(&intel_connector->base, | 537 | intel_connector_attach_encoder(intel_connector, intel_encoder); |
540 | &intel_encoder->base); | ||
541 | 538 | ||
542 | /* Set up the DDC bus. */ | 539 | /* Set up the DDC bus. */ |
543 | if (HAS_PCH_SPLIT(dev)) | 540 | if (HAS_PCH_SPLIT(dev)) |
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index 7e67bf534f89..a9df2787d752 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c | |||
@@ -6120,26 +6120,17 @@ void intel_modeset_cleanup(struct drm_device *dev) | |||
6120 | /* | 6120 | /* |
6121 | * Return which encoder is currently attached for connector. | 6121 | * Return which encoder is currently attached for connector. |
6122 | */ | 6122 | */ |
6123 | struct drm_encoder *intel_attached_encoder (struct drm_connector *connector) | 6123 | struct drm_encoder *intel_best_encoder(struct drm_connector *connector) |
6124 | { | 6124 | { |
6125 | struct drm_mode_object *obj; | 6125 | return &intel_attached_encoder(connector)->base; |
6126 | struct drm_encoder *encoder; | 6126 | } |
6127 | int i; | ||
6128 | |||
6129 | for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { | ||
6130 | if (connector->encoder_ids[i] == 0) | ||
6131 | break; | ||
6132 | |||
6133 | obj = drm_mode_object_find(connector->dev, | ||
6134 | connector->encoder_ids[i], | ||
6135 | DRM_MODE_OBJECT_ENCODER); | ||
6136 | if (!obj) | ||
6137 | continue; | ||
6138 | 6127 | ||
6139 | encoder = obj_to_encoder(obj); | 6128 | void intel_connector_attach_encoder(struct intel_connector *connector, |
6140 | return encoder; | 6129 | struct intel_encoder *encoder) |
6141 | } | 6130 | { |
6142 | return NULL; | 6131 | connector->encoder = encoder; |
6132 | drm_mode_connector_attach_encoder(&connector->base, | ||
6133 | &encoder->base); | ||
6143 | } | 6134 | } |
6144 | 6135 | ||
6145 | /* | 6136 | /* |
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c index 6cdc53de24ac..b9efeaf5d5b4 100644 --- a/drivers/gpu/drm/i915/intel_dp.c +++ b/drivers/gpu/drm/i915/intel_dp.c | |||
@@ -67,6 +67,12 @@ static struct intel_dp *enc_to_intel_dp(struct drm_encoder *encoder) | |||
67 | return container_of(encoder, struct intel_dp, base.base); | 67 | return container_of(encoder, struct intel_dp, base.base); |
68 | } | 68 | } |
69 | 69 | ||
70 | static struct intel_dp *intel_attached_dp(struct drm_connector *connector) | ||
71 | { | ||
72 | return container_of(intel_attached_encoder(connector), | ||
73 | struct intel_dp, base); | ||
74 | } | ||
75 | |||
70 | static void intel_dp_start_link_train(struct intel_dp *intel_dp); | 76 | static void intel_dp_start_link_train(struct intel_dp *intel_dp); |
71 | static void intel_dp_complete_link_train(struct intel_dp *intel_dp); | 77 | static void intel_dp_complete_link_train(struct intel_dp *intel_dp); |
72 | static void intel_dp_link_down(struct intel_dp *intel_dp); | 78 | static void intel_dp_link_down(struct intel_dp *intel_dp); |
@@ -148,8 +154,7 @@ static int | |||
148 | intel_dp_mode_valid(struct drm_connector *connector, | 154 | intel_dp_mode_valid(struct drm_connector *connector, |
149 | struct drm_display_mode *mode) | 155 | struct drm_display_mode *mode) |
150 | { | 156 | { |
151 | struct drm_encoder *encoder = intel_attached_encoder(connector); | 157 | struct intel_dp *intel_dp = intel_attached_dp(connector); |
152 | struct intel_dp *intel_dp = enc_to_intel_dp(encoder); | ||
153 | struct drm_device *dev = connector->dev; | 158 | struct drm_device *dev = connector->dev; |
154 | struct drm_i915_private *dev_priv = dev->dev_private; | 159 | struct drm_i915_private *dev_priv = dev->dev_private; |
155 | int max_link_clock = intel_dp_link_clock(intel_dp_max_link_bw(intel_dp)); | 160 | int max_link_clock = intel_dp_link_clock(intel_dp_max_link_bw(intel_dp)); |
@@ -1405,8 +1410,7 @@ intel_dp_check_link_status(struct intel_dp *intel_dp) | |||
1405 | static enum drm_connector_status | 1410 | static enum drm_connector_status |
1406 | ironlake_dp_detect(struct drm_connector *connector) | 1411 | ironlake_dp_detect(struct drm_connector *connector) |
1407 | { | 1412 | { |
1408 | struct drm_encoder *encoder = intel_attached_encoder(connector); | 1413 | struct intel_dp *intel_dp = intel_attached_dp(connector); |
1409 | struct intel_dp *intel_dp = enc_to_intel_dp(encoder); | ||
1410 | enum drm_connector_status status; | 1414 | enum drm_connector_status status; |
1411 | 1415 | ||
1412 | /* Panel needs power for AUX to work */ | 1416 | /* Panel needs power for AUX to work */ |
@@ -1436,8 +1440,7 @@ ironlake_dp_detect(struct drm_connector *connector) | |||
1436 | static enum drm_connector_status | 1440 | static enum drm_connector_status |
1437 | intel_dp_detect(struct drm_connector *connector) | 1441 | intel_dp_detect(struct drm_connector *connector) |
1438 | { | 1442 | { |
1439 | struct drm_encoder *encoder = intel_attached_encoder(connector); | 1443 | struct intel_dp *intel_dp = intel_attached_dp(connector); |
1440 | struct intel_dp *intel_dp = enc_to_intel_dp(encoder); | ||
1441 | struct drm_device *dev = intel_dp->base.base.dev; | 1444 | struct drm_device *dev = intel_dp->base.base.dev; |
1442 | struct drm_i915_private *dev_priv = dev->dev_private; | 1445 | struct drm_i915_private *dev_priv = dev->dev_private; |
1443 | uint32_t temp, bit; | 1446 | uint32_t temp, bit; |
@@ -1480,8 +1483,7 @@ intel_dp_detect(struct drm_connector *connector) | |||
1480 | 1483 | ||
1481 | static int intel_dp_get_modes(struct drm_connector *connector) | 1484 | static int intel_dp_get_modes(struct drm_connector *connector) |
1482 | { | 1485 | { |
1483 | struct drm_encoder *encoder = intel_attached_encoder(connector); | 1486 | struct intel_dp *intel_dp = intel_attached_dp(connector); |
1484 | struct intel_dp *intel_dp = enc_to_intel_dp(encoder); | ||
1485 | struct drm_device *dev = intel_dp->base.base.dev; | 1487 | struct drm_device *dev = intel_dp->base.base.dev; |
1486 | struct drm_i915_private *dev_priv = dev->dev_private; | 1488 | struct drm_i915_private *dev_priv = dev->dev_private; |
1487 | int ret; | 1489 | int ret; |
@@ -1554,7 +1556,7 @@ static const struct drm_connector_funcs intel_dp_connector_funcs = { | |||
1554 | static const struct drm_connector_helper_funcs intel_dp_connector_helper_funcs = { | 1556 | static const struct drm_connector_helper_funcs intel_dp_connector_helper_funcs = { |
1555 | .get_modes = intel_dp_get_modes, | 1557 | .get_modes = intel_dp_get_modes, |
1556 | .mode_valid = intel_dp_mode_valid, | 1558 | .mode_valid = intel_dp_mode_valid, |
1557 | .best_encoder = intel_attached_encoder, | 1559 | .best_encoder = intel_best_encoder, |
1558 | }; | 1560 | }; |
1559 | 1561 | ||
1560 | static const struct drm_encoder_funcs intel_dp_enc_funcs = { | 1562 | static const struct drm_encoder_funcs intel_dp_enc_funcs = { |
@@ -1674,8 +1676,7 @@ intel_dp_init(struct drm_device *dev, int output_reg) | |||
1674 | DRM_MODE_ENCODER_TMDS); | 1676 | DRM_MODE_ENCODER_TMDS); |
1675 | drm_encoder_helper_add(&intel_encoder->base, &intel_dp_helper_funcs); | 1677 | drm_encoder_helper_add(&intel_encoder->base, &intel_dp_helper_funcs); |
1676 | 1678 | ||
1677 | drm_mode_connector_attach_encoder(&intel_connector->base, | 1679 | intel_connector_attach_encoder(intel_connector, intel_encoder); |
1678 | &intel_encoder->base); | ||
1679 | drm_sysfs_connector_add(connector); | 1680 | drm_sysfs_connector_add(connector); |
1680 | 1681 | ||
1681 | /* Set up the DDC bus. */ | 1682 | /* Set up the DDC bus. */ |
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h index ba94944e4eb1..1ada684ea569 100644 --- a/drivers/gpu/drm/i915/intel_drv.h +++ b/drivers/gpu/drm/i915/intel_drv.h | |||
@@ -150,6 +150,7 @@ struct intel_encoder { | |||
150 | 150 | ||
151 | struct intel_connector { | 151 | struct intel_connector { |
152 | struct drm_connector base; | 152 | struct drm_connector base; |
153 | struct intel_encoder *encoder; | ||
153 | }; | 154 | }; |
154 | 155 | ||
155 | struct intel_crtc { | 156 | struct intel_crtc { |
@@ -234,7 +235,14 @@ extern void intel_encoder_prepare (struct drm_encoder *encoder); | |||
234 | extern void intel_encoder_commit (struct drm_encoder *encoder); | 235 | extern void intel_encoder_commit (struct drm_encoder *encoder); |
235 | extern void intel_encoder_destroy(struct drm_encoder *encoder); | 236 | extern void intel_encoder_destroy(struct drm_encoder *encoder); |
236 | 237 | ||
237 | extern struct drm_encoder *intel_attached_encoder(struct drm_connector *connector); | 238 | static inline struct intel_encoder *intel_attached_encoder(struct drm_connector *connector) |
239 | { | ||
240 | return to_intel_connector(connector)->encoder; | ||
241 | } | ||
242 | |||
243 | extern void intel_connector_attach_encoder(struct intel_connector *connector, | ||
244 | struct intel_encoder *encoder); | ||
245 | extern struct drm_encoder *intel_best_encoder(struct drm_connector *connector); | ||
238 | 246 | ||
239 | extern struct drm_display_mode *intel_crtc_mode_get(struct drm_device *dev, | 247 | extern struct drm_display_mode *intel_crtc_mode_get(struct drm_device *dev, |
240 | struct drm_crtc *crtc); | 248 | struct drm_crtc *crtc); |
diff --git a/drivers/gpu/drm/i915/intel_dvo.c b/drivers/gpu/drm/i915/intel_dvo.c index b15c9da215d6..df42a9c9afc1 100644 --- a/drivers/gpu/drm/i915/intel_dvo.c +++ b/drivers/gpu/drm/i915/intel_dvo.c | |||
@@ -91,6 +91,12 @@ static struct intel_dvo *enc_to_intel_dvo(struct drm_encoder *encoder) | |||
91 | return container_of(encoder, struct intel_dvo, base.base); | 91 | return container_of(encoder, struct intel_dvo, base.base); |
92 | } | 92 | } |
93 | 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); | ||
98 | } | ||
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) |
95 | { | 101 | { |
96 | struct drm_i915_private *dev_priv = encoder->dev->dev_private; | 102 | struct drm_i915_private *dev_priv = encoder->dev->dev_private; |
@@ -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; |
@@ -223,16 +228,13 @@ static void intel_dvo_mode_set(struct drm_encoder *encoder, | |||
223 | */ | 228 | */ |
224 | static enum drm_connector_status intel_dvo_detect(struct drm_connector *connector) | 229 | static enum drm_connector_status intel_dvo_detect(struct drm_connector *connector) |
225 | { | 230 | { |
226 | struct drm_encoder *encoder = intel_attached_encoder(connector); | 231 | struct intel_dvo *intel_dvo = intel_attached_dvo(connector); |
227 | struct intel_dvo *intel_dvo = enc_to_intel_dvo(encoder); | ||
228 | |||
229 | return intel_dvo->dev.dev_ops->detect(&intel_dvo->dev); | 232 | return intel_dvo->dev.dev_ops->detect(&intel_dvo->dev); |
230 | } | 233 | } |
231 | 234 | ||
232 | static int intel_dvo_get_modes(struct drm_connector *connector) | 235 | static int intel_dvo_get_modes(struct drm_connector *connector) |
233 | { | 236 | { |
234 | struct drm_encoder *encoder = intel_attached_encoder(connector); | 237 | struct intel_dvo *intel_dvo = intel_attached_dvo(connector); |
235 | struct intel_dvo *intel_dvo = enc_to_intel_dvo(encoder); | ||
236 | 238 | ||
237 | /* We should probably have an i2c driver get_modes function for those | 239 | /* We should probably have an i2c driver get_modes function for those |
238 | * devices which will have a fixed set of modes determined by the chip | 240 | * devices which will have a fixed set of modes determined by the chip |
@@ -280,7 +282,7 @@ static const struct drm_connector_funcs intel_dvo_connector_funcs = { | |||
280 | static const struct drm_connector_helper_funcs intel_dvo_connector_helper_funcs = { | 282 | static const struct drm_connector_helper_funcs intel_dvo_connector_helper_funcs = { |
281 | .mode_valid = intel_dvo_mode_valid, | 283 | .mode_valid = intel_dvo_mode_valid, |
282 | .get_modes = intel_dvo_get_modes, | 284 | .get_modes = intel_dvo_get_modes, |
283 | .best_encoder = intel_attached_encoder, | 285 | .best_encoder = intel_best_encoder, |
284 | }; | 286 | }; |
285 | 287 | ||
286 | static void intel_dvo_enc_destroy(struct drm_encoder *encoder) | 288 | static void intel_dvo_enc_destroy(struct drm_encoder *encoder) |
@@ -310,8 +312,7 @@ intel_dvo_get_current_mode(struct drm_connector *connector) | |||
310 | { | 312 | { |
311 | struct drm_device *dev = connector->dev; | 313 | struct drm_device *dev = connector->dev; |
312 | struct drm_i915_private *dev_priv = dev->dev_private; | 314 | struct drm_i915_private *dev_priv = dev->dev_private; |
313 | struct drm_encoder *encoder = intel_attached_encoder(connector); | 315 | struct intel_dvo *intel_dvo = intel_attached_dvo(connector); |
314 | struct intel_dvo *intel_dvo = enc_to_intel_dvo(encoder); | ||
315 | uint32_t dvo_val = I915_READ(intel_dvo->dev.dvo_reg); | 316 | uint32_t dvo_val = I915_READ(intel_dvo->dev.dvo_reg); |
316 | struct drm_display_mode *mode = NULL; | 317 | struct drm_display_mode *mode = NULL; |
317 | 318 | ||
@@ -431,8 +432,7 @@ void intel_dvo_init(struct drm_device *dev) | |||
431 | drm_encoder_helper_add(&intel_encoder->base, | 432 | drm_encoder_helper_add(&intel_encoder->base, |
432 | &intel_dvo_helper_funcs); | 433 | &intel_dvo_helper_funcs); |
433 | 434 | ||
434 | drm_mode_connector_attach_encoder(&intel_connector->base, | 435 | intel_connector_attach_encoder(intel_connector, intel_encoder); |
435 | &intel_encoder->base); | ||
436 | if (dvo->type == INTEL_DVO_CHIP_LVDS) { | 436 | if (dvo->type == INTEL_DVO_CHIP_LVDS) { |
437 | /* For our LVDS chipsets, we should hopefully be able | 437 | /* For our LVDS chipsets, we should hopefully be able |
438 | * to dig the fixed panel mode out of the BIOS data. | 438 | * to dig the fixed panel mode out of the BIOS data. |
diff --git a/drivers/gpu/drm/i915/intel_hdmi.c b/drivers/gpu/drm/i915/intel_hdmi.c index 405afd75241b..bba0aba15a96 100644 --- a/drivers/gpu/drm/i915/intel_hdmi.c +++ b/drivers/gpu/drm/i915/intel_hdmi.c | |||
@@ -48,6 +48,12 @@ static struct intel_hdmi *enc_to_intel_hdmi(struct drm_encoder *encoder) | |||
48 | return container_of(encoder, struct intel_hdmi, base.base); | 48 | return container_of(encoder, struct intel_hdmi, base.base); |
49 | } | 49 | } |
50 | 50 | ||
51 | static struct intel_hdmi *intel_attached_hdmi(struct drm_connector *connector) | ||
52 | { | ||
53 | return container_of(intel_attached_encoder(connector), | ||
54 | struct intel_hdmi, base); | ||
55 | } | ||
56 | |||
51 | static void intel_hdmi_mode_set(struct drm_encoder *encoder, | 57 | static void intel_hdmi_mode_set(struct drm_encoder *encoder, |
52 | struct drm_display_mode *mode, | 58 | struct drm_display_mode *mode, |
53 | struct drm_display_mode *adjusted_mode) | 59 | struct drm_display_mode *adjusted_mode) |
@@ -141,8 +147,7 @@ static bool intel_hdmi_mode_fixup(struct drm_encoder *encoder, | |||
141 | static enum drm_connector_status | 147 | static enum drm_connector_status |
142 | intel_hdmi_detect(struct drm_connector *connector) | 148 | intel_hdmi_detect(struct drm_connector *connector) |
143 | { | 149 | { |
144 | struct drm_encoder *encoder = intel_attached_encoder(connector); | 150 | struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector); |
145 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder); | ||
146 | struct edid *edid = NULL; | 151 | struct edid *edid = NULL; |
147 | enum drm_connector_status status = connector_status_disconnected; | 152 | enum drm_connector_status status = connector_status_disconnected; |
148 | 153 | ||
@@ -163,8 +168,7 @@ intel_hdmi_detect(struct drm_connector *connector) | |||
163 | 168 | ||
164 | static int intel_hdmi_get_modes(struct drm_connector *connector) | 169 | static int intel_hdmi_get_modes(struct drm_connector *connector) |
165 | { | 170 | { |
166 | struct drm_encoder *encoder = intel_attached_encoder(connector); | 171 | struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector); |
167 | struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder); | ||
168 | 172 | ||
169 | /* We should parse the EDID data and find out if it's an HDMI sink so | 173 | /* We should parse the EDID data and find out if it's an HDMI sink so |
170 | * we can send audio to it. | 174 | * we can send audio to it. |
@@ -198,7 +202,7 @@ static const struct drm_connector_funcs intel_hdmi_connector_funcs = { | |||
198 | static const struct drm_connector_helper_funcs intel_hdmi_connector_helper_funcs = { | 202 | static const struct drm_connector_helper_funcs intel_hdmi_connector_helper_funcs = { |
199 | .get_modes = intel_hdmi_get_modes, | 203 | .get_modes = intel_hdmi_get_modes, |
200 | .mode_valid = intel_hdmi_mode_valid, | 204 | .mode_valid = intel_hdmi_mode_valid, |
201 | .best_encoder = intel_attached_encoder, | 205 | .best_encoder = intel_best_encoder, |
202 | }; | 206 | }; |
203 | 207 | ||
204 | static const struct drm_encoder_funcs intel_hdmi_enc_funcs = { | 208 | static const struct drm_encoder_funcs intel_hdmi_enc_funcs = { |
@@ -270,8 +274,7 @@ void intel_hdmi_init(struct drm_device *dev, int sdvox_reg) | |||
270 | DRM_MODE_ENCODER_TMDS); | 274 | DRM_MODE_ENCODER_TMDS); |
271 | drm_encoder_helper_add(&intel_encoder->base, &intel_hdmi_helper_funcs); | 275 | drm_encoder_helper_add(&intel_encoder->base, &intel_hdmi_helper_funcs); |
272 | 276 | ||
273 | drm_mode_connector_attach_encoder(&intel_connector->base, | 277 | intel_connector_attach_encoder(intel_connector, intel_encoder); |
274 | &intel_encoder->base); | ||
275 | drm_sysfs_connector_add(connector); | 278 | drm_sysfs_connector_add(connector); |
276 | 279 | ||
277 | /* For G4X desktop chip, PEG_BAND_GAP_DATA 3:0 must first be written | 280 | /* For G4X desktop chip, PEG_BAND_GAP_DATA 3:0 must first be written |
diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c index 987973f4ff7d..93a711d9dcf5 100644 --- a/drivers/gpu/drm/i915/intel_lvds.c +++ b/drivers/gpu/drm/i915/intel_lvds.c | |||
@@ -436,14 +436,11 @@ static enum drm_connector_status intel_lvds_detect(struct drm_connector *connect | |||
436 | static int intel_lvds_get_modes(struct drm_connector *connector) | 436 | static int intel_lvds_get_modes(struct drm_connector *connector) |
437 | { | 437 | { |
438 | struct drm_device *dev = connector->dev; | 438 | struct drm_device *dev = connector->dev; |
439 | struct drm_encoder *encoder = intel_attached_encoder(connector); | ||
440 | struct intel_encoder *intel_encoder = to_intel_encoder(encoder); | ||
441 | struct drm_i915_private *dev_priv = dev->dev_private; | 439 | struct drm_i915_private *dev_priv = dev->dev_private; |
442 | int ret = 0; | ||
443 | 440 | ||
444 | if (dev_priv->lvds_edid_good) { | 441 | if (dev_priv->lvds_edid_good) { |
445 | ret = intel_ddc_get_modes(connector, intel_encoder->ddc_bus); | 442 | struct intel_encoder *encoder = intel_attached_encoder(connector); |
446 | 443 | int ret = intel_ddc_get_modes(connector, encoder->ddc_bus); | |
447 | if (ret) | 444 | if (ret) |
448 | return ret; | 445 | return ret; |
449 | } | 446 | } |
@@ -596,7 +593,7 @@ static const struct drm_encoder_helper_funcs intel_lvds_helper_funcs = { | |||
596 | static const struct drm_connector_helper_funcs intel_lvds_connector_helper_funcs = { | 593 | static const struct drm_connector_helper_funcs intel_lvds_connector_helper_funcs = { |
597 | .get_modes = intel_lvds_get_modes, | 594 | .get_modes = intel_lvds_get_modes, |
598 | .mode_valid = intel_lvds_mode_valid, | 595 | .mode_valid = intel_lvds_mode_valid, |
599 | .best_encoder = intel_attached_encoder, | 596 | .best_encoder = intel_best_encoder, |
600 | }; | 597 | }; |
601 | 598 | ||
602 | static const struct drm_connector_funcs intel_lvds_connector_funcs = { | 599 | static const struct drm_connector_funcs intel_lvds_connector_funcs = { |
@@ -847,7 +844,7 @@ void intel_lvds_init(struct drm_device *dev) | |||
847 | drm_encoder_init(dev, &intel_encoder->base, &intel_lvds_enc_funcs, | 844 | drm_encoder_init(dev, &intel_encoder->base, &intel_lvds_enc_funcs, |
848 | DRM_MODE_ENCODER_LVDS); | 845 | DRM_MODE_ENCODER_LVDS); |
849 | 846 | ||
850 | drm_mode_connector_attach_encoder(&intel_connector->base, &intel_encoder->base); | 847 | intel_connector_attach_encoder(intel_connector, intel_encoder); |
851 | intel_encoder->type = INTEL_OUTPUT_LVDS; | 848 | intel_encoder->type = INTEL_OUTPUT_LVDS; |
852 | 849 | ||
853 | intel_encoder->clone_mask = (1 << INTEL_LVDS_CLONE_BIT); | 850 | intel_encoder->clone_mask = (1 << INTEL_LVDS_CLONE_BIT); |
diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c index 3d8f4f4cf326..96952d20cd21 100644 --- a/drivers/gpu/drm/i915/intel_sdvo.c +++ b/drivers/gpu/drm/i915/intel_sdvo.c | |||
@@ -189,6 +189,12 @@ static struct intel_sdvo *enc_to_intel_sdvo(struct drm_encoder *encoder) | |||
189 | return container_of(encoder, struct intel_sdvo, base.base); | 189 | return container_of(encoder, struct intel_sdvo, base.base); |
190 | } | 190 | } |
191 | 191 | ||
192 | static struct intel_sdvo *intel_attached_sdvo(struct drm_connector *connector) | ||
193 | { | ||
194 | return container_of(intel_attached_encoder(connector), | ||
195 | struct intel_sdvo, base); | ||
196 | } | ||
197 | |||
192 | static struct intel_sdvo_connector *to_intel_sdvo_connector(struct drm_connector *connector) | 198 | static struct intel_sdvo_connector *to_intel_sdvo_connector(struct drm_connector *connector) |
193 | { | 199 | { |
194 | return container_of(to_intel_connector(connector), struct intel_sdvo_connector, base); | 200 | return container_of(to_intel_connector(connector), struct intel_sdvo_connector, base); |
@@ -1239,8 +1245,7 @@ static void intel_sdvo_dpms(struct drm_encoder *encoder, int mode) | |||
1239 | static int intel_sdvo_mode_valid(struct drm_connector *connector, | 1245 | static int intel_sdvo_mode_valid(struct drm_connector *connector, |
1240 | struct drm_display_mode *mode) | 1246 | struct drm_display_mode *mode) |
1241 | { | 1247 | { |
1242 | struct drm_encoder *encoder = intel_attached_encoder(connector); | 1248 | struct intel_sdvo *intel_sdvo = intel_attached_sdvo(connector); |
1243 | struct intel_sdvo *intel_sdvo = enc_to_intel_sdvo(encoder); | ||
1244 | 1249 | ||
1245 | if (mode->flags & DRM_MODE_FLAG_DBLSCAN) | 1250 | if (mode->flags & DRM_MODE_FLAG_DBLSCAN) |
1246 | return MODE_NO_DBLESCAN; | 1251 | return MODE_NO_DBLESCAN; |
@@ -1372,18 +1377,22 @@ static struct drm_connector * | |||
1372 | intel_find_analog_connector(struct drm_device *dev) | 1377 | intel_find_analog_connector(struct drm_device *dev) |
1373 | { | 1378 | { |
1374 | struct drm_connector *connector; | 1379 | struct drm_connector *connector; |
1375 | struct drm_encoder *encoder; | 1380 | struct intel_sdvo *encoder; |
1376 | struct intel_sdvo *intel_sdvo; | 1381 | |
1377 | 1382 | list_for_each_entry(encoder, | |
1378 | list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { | 1383 | &dev->mode_config.encoder_list, |
1379 | intel_sdvo = enc_to_intel_sdvo(encoder); | 1384 | base.base.head) { |
1380 | if (intel_sdvo->base.type == INTEL_OUTPUT_ANALOG) { | 1385 | if (encoder->base.type == INTEL_OUTPUT_ANALOG) { |
1381 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) { | 1386 | list_for_each_entry(connector, |
1382 | if (encoder == intel_attached_encoder(connector)) | 1387 | &dev->mode_config.connector_list, |
1388 | head) { | ||
1389 | if (&encoder->base == | ||
1390 | intel_attached_encoder(connector)) | ||
1383 | return connector; | 1391 | return connector; |
1384 | } | 1392 | } |
1385 | } | 1393 | } |
1386 | } | 1394 | } |
1395 | |||
1387 | return NULL; | 1396 | return NULL; |
1388 | } | 1397 | } |
1389 | 1398 | ||
@@ -1406,8 +1415,7 @@ intel_analog_is_connected(struct drm_device *dev) | |||
1406 | enum drm_connector_status | 1415 | enum drm_connector_status |
1407 | intel_sdvo_hdmi_sink_detect(struct drm_connector *connector) | 1416 | intel_sdvo_hdmi_sink_detect(struct drm_connector *connector) |
1408 | { | 1417 | { |
1409 | struct drm_encoder *encoder = intel_attached_encoder(connector); | 1418 | struct intel_sdvo *intel_sdvo = intel_attached_sdvo(connector); |
1410 | struct intel_sdvo *intel_sdvo = enc_to_intel_sdvo(encoder); | ||
1411 | struct intel_sdvo_connector *intel_sdvo_connector = to_intel_sdvo_connector(connector); | 1419 | struct intel_sdvo_connector *intel_sdvo_connector = to_intel_sdvo_connector(connector); |
1412 | enum drm_connector_status status = connector_status_connected; | 1420 | enum drm_connector_status status = connector_status_connected; |
1413 | struct edid *edid = NULL; | 1421 | struct edid *edid = NULL; |
@@ -1468,8 +1476,7 @@ intel_sdvo_hdmi_sink_detect(struct drm_connector *connector) | |||
1468 | static enum drm_connector_status intel_sdvo_detect(struct drm_connector *connector) | 1476 | static enum drm_connector_status intel_sdvo_detect(struct drm_connector *connector) |
1469 | { | 1477 | { |
1470 | uint16_t response; | 1478 | uint16_t response; |
1471 | struct drm_encoder *encoder = intel_attached_encoder(connector); | 1479 | struct intel_sdvo *intel_sdvo = intel_attached_sdvo(connector); |
1472 | struct intel_sdvo *intel_sdvo = enc_to_intel_sdvo(encoder); | ||
1473 | struct intel_sdvo_connector *intel_sdvo_connector = to_intel_sdvo_connector(connector); | 1480 | struct intel_sdvo_connector *intel_sdvo_connector = to_intel_sdvo_connector(connector); |
1474 | enum drm_connector_status ret; | 1481 | enum drm_connector_status ret; |
1475 | 1482 | ||
@@ -1516,8 +1523,7 @@ static enum drm_connector_status intel_sdvo_detect(struct drm_connector *connect | |||
1516 | 1523 | ||
1517 | static void intel_sdvo_get_ddc_modes(struct drm_connector *connector) | 1524 | static void intel_sdvo_get_ddc_modes(struct drm_connector *connector) |
1518 | { | 1525 | { |
1519 | struct drm_encoder *encoder = intel_attached_encoder(connector); | 1526 | struct intel_sdvo *intel_sdvo = intel_attached_sdvo(connector); |
1520 | struct intel_sdvo *intel_sdvo = enc_to_intel_sdvo(encoder); | ||
1521 | int num_modes; | 1527 | int num_modes; |
1522 | 1528 | ||
1523 | /* set the bus switch and get the modes */ | 1529 | /* set the bus switch and get the modes */ |
@@ -1605,8 +1611,7 @@ struct drm_display_mode sdvo_tv_modes[] = { | |||
1605 | 1611 | ||
1606 | static void intel_sdvo_get_tv_modes(struct drm_connector *connector) | 1612 | static void intel_sdvo_get_tv_modes(struct drm_connector *connector) |
1607 | { | 1613 | { |
1608 | struct drm_encoder *encoder = intel_attached_encoder(connector); | 1614 | struct intel_sdvo *intel_sdvo = intel_attached_sdvo(connector); |
1609 | struct intel_sdvo *intel_sdvo = enc_to_intel_sdvo(encoder); | ||
1610 | struct intel_sdvo_sdtv_resolution_request tv_res; | 1615 | struct intel_sdvo_sdtv_resolution_request tv_res; |
1611 | uint32_t reply = 0, format_map = 0; | 1616 | uint32_t reply = 0, format_map = 0; |
1612 | int i; | 1617 | int i; |
@@ -1640,8 +1645,7 @@ static void intel_sdvo_get_tv_modes(struct drm_connector *connector) | |||
1640 | 1645 | ||
1641 | static void intel_sdvo_get_lvds_modes(struct drm_connector *connector) | 1646 | static void intel_sdvo_get_lvds_modes(struct drm_connector *connector) |
1642 | { | 1647 | { |
1643 | struct drm_encoder *encoder = intel_attached_encoder(connector); | 1648 | struct intel_sdvo *intel_sdvo = intel_attached_sdvo(connector); |
1644 | struct intel_sdvo *intel_sdvo = enc_to_intel_sdvo(encoder); | ||
1645 | struct drm_i915_private *dev_priv = connector->dev->dev_private; | 1649 | struct drm_i915_private *dev_priv = connector->dev->dev_private; |
1646 | struct drm_display_mode *newmode; | 1650 | struct drm_display_mode *newmode; |
1647 | 1651 | ||
@@ -1757,8 +1761,7 @@ intel_sdvo_set_property(struct drm_connector *connector, | |||
1757 | struct drm_property *property, | 1761 | struct drm_property *property, |
1758 | uint64_t val) | 1762 | uint64_t val) |
1759 | { | 1763 | { |
1760 | struct drm_encoder *encoder = intel_attached_encoder(connector); | 1764 | struct intel_sdvo *intel_sdvo = intel_attached_sdvo(connector); |
1761 | struct intel_sdvo *intel_sdvo = enc_to_intel_sdvo(encoder); | ||
1762 | struct intel_sdvo_connector *intel_sdvo_connector = to_intel_sdvo_connector(connector); | 1765 | struct intel_sdvo_connector *intel_sdvo_connector = to_intel_sdvo_connector(connector); |
1763 | uint16_t temp_value; | 1766 | uint16_t temp_value; |
1764 | uint8_t cmd; | 1767 | uint8_t cmd; |
@@ -1861,9 +1864,8 @@ set_value: | |||
1861 | 1864 | ||
1862 | 1865 | ||
1863 | done: | 1866 | done: |
1864 | if (encoder->crtc) { | 1867 | if (intel_sdvo->base.base.crtc) { |
1865 | struct drm_crtc *crtc = encoder->crtc; | 1868 | struct drm_crtc *crtc = intel_sdvo->base.base.crtc; |
1866 | |||
1867 | drm_crtc_helper_set_mode(crtc, &crtc->mode, crtc->x, | 1869 | drm_crtc_helper_set_mode(crtc, &crtc->mode, crtc->x, |
1868 | crtc->y, crtc->fb); | 1870 | crtc->y, crtc->fb); |
1869 | } | 1871 | } |
@@ -1891,7 +1893,7 @@ static const struct drm_connector_funcs intel_sdvo_connector_funcs = { | |||
1891 | static const struct drm_connector_helper_funcs intel_sdvo_connector_helper_funcs = { | 1893 | static const struct drm_connector_helper_funcs intel_sdvo_connector_helper_funcs = { |
1892 | .get_modes = intel_sdvo_get_modes, | 1894 | .get_modes = intel_sdvo_get_modes, |
1893 | .mode_valid = intel_sdvo_mode_valid, | 1895 | .mode_valid = intel_sdvo_mode_valid, |
1894 | .best_encoder = intel_attached_encoder, | 1896 | .best_encoder = intel_best_encoder, |
1895 | }; | 1897 | }; |
1896 | 1898 | ||
1897 | static void intel_sdvo_enc_destroy(struct drm_encoder *encoder) | 1899 | static void intel_sdvo_enc_destroy(struct drm_encoder *encoder) |
@@ -2058,20 +2060,23 @@ intel_sdvo_get_slave_addr(struct drm_device *dev, int sdvo_reg) | |||
2058 | } | 2060 | } |
2059 | 2061 | ||
2060 | static void | 2062 | static void |
2061 | intel_sdvo_connector_init(struct drm_encoder *encoder, | 2063 | intel_sdvo_connector_init(struct intel_sdvo_connector *connector, |
2062 | struct drm_connector *connector) | 2064 | struct intel_sdvo *encoder) |
2063 | { | 2065 | { |
2064 | drm_connector_init(encoder->dev, connector, &intel_sdvo_connector_funcs, | 2066 | drm_connector_init(encoder->base.base.dev, |
2065 | connector->connector_type); | 2067 | &connector->base.base, |
2068 | &intel_sdvo_connector_funcs, | ||
2069 | connector->base.base.connector_type); | ||
2066 | 2070 | ||
2067 | drm_connector_helper_add(connector, &intel_sdvo_connector_helper_funcs); | 2071 | drm_connector_helper_add(&connector->base.base, |
2072 | &intel_sdvo_connector_helper_funcs); | ||
2068 | 2073 | ||
2069 | connector->interlace_allowed = 0; | 2074 | connector->base.base.interlace_allowed = 0; |
2070 | connector->doublescan_allowed = 0; | 2075 | connector->base.base.doublescan_allowed = 0; |
2071 | connector->display_info.subpixel_order = SubPixelHorizontalRGB; | 2076 | connector->base.base.display_info.subpixel_order = SubPixelHorizontalRGB; |
2072 | 2077 | ||
2073 | drm_mode_connector_attach_encoder(connector, encoder); | 2078 | intel_connector_attach_encoder(&connector->base, &encoder->base); |
2074 | drm_sysfs_connector_add(connector); | 2079 | drm_sysfs_connector_add(&connector->base.base); |
2075 | } | 2080 | } |
2076 | 2081 | ||
2077 | static bool | 2082 | static bool |
@@ -2112,7 +2117,7 @@ intel_sdvo_dvi_init(struct intel_sdvo *intel_sdvo, int device) | |||
2112 | intel_sdvo->base.clone_mask = ((1 << INTEL_SDVO_NON_TV_CLONE_BIT) | | 2117 | intel_sdvo->base.clone_mask = ((1 << INTEL_SDVO_NON_TV_CLONE_BIT) | |
2113 | (1 << INTEL_ANALOG_CLONE_BIT)); | 2118 | (1 << INTEL_ANALOG_CLONE_BIT)); |
2114 | 2119 | ||
2115 | intel_sdvo_connector_init(encoder, connector); | 2120 | intel_sdvo_connector_init(intel_sdvo_connector, intel_sdvo); |
2116 | 2121 | ||
2117 | return true; | 2122 | return true; |
2118 | } | 2123 | } |
@@ -2141,7 +2146,7 @@ intel_sdvo_tv_init(struct intel_sdvo *intel_sdvo, int type) | |||
2141 | intel_sdvo->base.needs_tv_clock = true; | 2146 | intel_sdvo->base.needs_tv_clock = true; |
2142 | intel_sdvo->base.clone_mask = 1 << INTEL_SDVO_TV_CLONE_BIT; | 2147 | intel_sdvo->base.clone_mask = 1 << INTEL_SDVO_TV_CLONE_BIT; |
2143 | 2148 | ||
2144 | intel_sdvo_connector_init(encoder, connector); | 2149 | intel_sdvo_connector_init(intel_sdvo_connector, intel_sdvo); |
2145 | 2150 | ||
2146 | if (!intel_sdvo_tv_create_property(intel_sdvo, intel_sdvo_connector, type)) | 2151 | if (!intel_sdvo_tv_create_property(intel_sdvo, intel_sdvo_connector, type)) |
2147 | goto err; | 2152 | goto err; |
@@ -2186,7 +2191,8 @@ intel_sdvo_analog_init(struct intel_sdvo *intel_sdvo, int device) | |||
2186 | intel_sdvo->base.clone_mask = ((1 << INTEL_SDVO_NON_TV_CLONE_BIT) | | 2191 | intel_sdvo->base.clone_mask = ((1 << INTEL_SDVO_NON_TV_CLONE_BIT) | |
2187 | (1 << INTEL_ANALOG_CLONE_BIT)); | 2192 | (1 << INTEL_ANALOG_CLONE_BIT)); |
2188 | 2193 | ||
2189 | intel_sdvo_connector_init(encoder, connector); | 2194 | intel_sdvo_connector_init(intel_sdvo_connector, |
2195 | intel_sdvo); | ||
2190 | return true; | 2196 | return true; |
2191 | } | 2197 | } |
2192 | 2198 | ||
@@ -2218,7 +2224,7 @@ intel_sdvo_lvds_init(struct intel_sdvo *intel_sdvo, int device) | |||
2218 | intel_sdvo->base.clone_mask = ((1 << INTEL_ANALOG_CLONE_BIT) | | 2224 | intel_sdvo->base.clone_mask = ((1 << INTEL_ANALOG_CLONE_BIT) | |
2219 | (1 << INTEL_SDVO_LVDS_CLONE_BIT)); | 2225 | (1 << INTEL_SDVO_LVDS_CLONE_BIT)); |
2220 | 2226 | ||
2221 | intel_sdvo_connector_init(encoder, connector); | 2227 | intel_sdvo_connector_init(intel_sdvo_connector, intel_sdvo); |
2222 | if (!intel_sdvo_create_enhance_property(intel_sdvo, intel_sdvo_connector)) | 2228 | if (!intel_sdvo_create_enhance_property(intel_sdvo, intel_sdvo_connector)) |
2223 | goto err; | 2229 | goto err; |
2224 | 2230 | ||
diff --git a/drivers/gpu/drm/i915/intel_tv.c b/drivers/gpu/drm/i915/intel_tv.c index 12f15cb31dbb..267da3289263 100644 --- a/drivers/gpu/drm/i915/intel_tv.c +++ b/drivers/gpu/drm/i915/intel_tv.c | |||
@@ -903,6 +903,13 @@ static struct intel_tv *enc_to_intel_tv(struct drm_encoder *encoder) | |||
903 | return container_of(encoder, struct intel_tv, base.base); | 903 | return container_of(encoder, struct intel_tv, base.base); |
904 | } | 904 | } |
905 | 905 | ||
906 | static struct intel_tv *intel_attached_tv(struct drm_connector *connector) | ||
907 | { | ||
908 | return container_of(intel_attached_encoder(connector), | ||
909 | struct intel_tv, | ||
910 | base); | ||
911 | } | ||
912 | |||
906 | static void | 913 | static void |
907 | intel_tv_dpms(struct drm_encoder *encoder, int mode) | 914 | intel_tv_dpms(struct drm_encoder *encoder, int mode) |
908 | { | 915 | { |
@@ -945,8 +952,7 @@ static enum drm_mode_status | |||
945 | intel_tv_mode_valid(struct drm_connector *connector, | 952 | intel_tv_mode_valid(struct drm_connector *connector, |
946 | struct drm_display_mode *mode) | 953 | struct drm_display_mode *mode) |
947 | { | 954 | { |
948 | struct drm_encoder *encoder = intel_attached_encoder(connector); | 955 | struct intel_tv *intel_tv = intel_attached_tv(connector); |
949 | struct intel_tv *intel_tv = enc_to_intel_tv(encoder); | ||
950 | const struct tv_mode *tv_mode = intel_tv_mode_find(intel_tv); | 956 | const struct tv_mode *tv_mode = intel_tv_mode_find(intel_tv); |
951 | 957 | ||
952 | /* Ensure TV refresh is close to desired refresh */ | 958 | /* Ensure TV refresh is close to desired refresh */ |
@@ -1306,8 +1312,7 @@ intel_tv_detect_type (struct intel_tv *intel_tv) | |||
1306 | */ | 1312 | */ |
1307 | static void intel_tv_find_better_format(struct drm_connector *connector) | 1313 | static void intel_tv_find_better_format(struct drm_connector *connector) |
1308 | { | 1314 | { |
1309 | struct drm_encoder *encoder = intel_attached_encoder(connector); | 1315 | struct intel_tv *intel_tv = intel_attached_tv(connector); |
1310 | struct intel_tv *intel_tv = enc_to_intel_tv(encoder); | ||
1311 | const struct tv_mode *tv_mode = intel_tv_mode_find(intel_tv); | 1316 | const struct tv_mode *tv_mode = intel_tv_mode_find(intel_tv); |
1312 | int i; | 1317 | int i; |
1313 | 1318 | ||
@@ -1339,14 +1344,13 @@ static enum drm_connector_status | |||
1339 | intel_tv_detect(struct drm_connector *connector) | 1344 | intel_tv_detect(struct drm_connector *connector) |
1340 | { | 1345 | { |
1341 | struct drm_display_mode mode; | 1346 | struct drm_display_mode mode; |
1342 | struct drm_encoder *encoder = intel_attached_encoder(connector); | 1347 | struct intel_tv *intel_tv = intel_attached_tv(connector); |
1343 | struct intel_tv *intel_tv = enc_to_intel_tv(encoder); | ||
1344 | int type; | 1348 | int type; |
1345 | 1349 | ||
1346 | mode = reported_modes[0]; | 1350 | mode = reported_modes[0]; |
1347 | drm_mode_set_crtcinfo(&mode, CRTC_INTERLACE_HALVE_V); | 1351 | drm_mode_set_crtcinfo(&mode, CRTC_INTERLACE_HALVE_V); |
1348 | 1352 | ||
1349 | if (encoder->crtc && encoder->crtc->enabled) { | 1353 | if (intel_tv->base.base.crtc && intel_tv->base.base.crtc->enabled) { |
1350 | type = intel_tv_detect_type(intel_tv); | 1354 | type = intel_tv_detect_type(intel_tv); |
1351 | } else { | 1355 | } else { |
1352 | struct drm_crtc *crtc; | 1356 | struct drm_crtc *crtc; |
@@ -1391,8 +1395,7 @@ static void | |||
1391 | intel_tv_chose_preferred_modes(struct drm_connector *connector, | 1395 | intel_tv_chose_preferred_modes(struct drm_connector *connector, |
1392 | struct drm_display_mode *mode_ptr) | 1396 | struct drm_display_mode *mode_ptr) |
1393 | { | 1397 | { |
1394 | struct drm_encoder *encoder = intel_attached_encoder(connector); | 1398 | struct intel_tv *intel_tv = intel_attached_tv(connector); |
1395 | struct intel_tv *intel_tv = enc_to_intel_tv(encoder); | ||
1396 | const struct tv_mode *tv_mode = intel_tv_mode_find(intel_tv); | 1399 | const struct tv_mode *tv_mode = intel_tv_mode_find(intel_tv); |
1397 | 1400 | ||
1398 | if (tv_mode->nbr_end < 480 && mode_ptr->vdisplay == 480) | 1401 | if (tv_mode->nbr_end < 480 && mode_ptr->vdisplay == 480) |
@@ -1417,8 +1420,7 @@ static int | |||
1417 | intel_tv_get_modes(struct drm_connector *connector) | 1420 | intel_tv_get_modes(struct drm_connector *connector) |
1418 | { | 1421 | { |
1419 | struct drm_display_mode *mode_ptr; | 1422 | struct drm_display_mode *mode_ptr; |
1420 | struct drm_encoder *encoder = intel_attached_encoder(connector); | 1423 | struct intel_tv *intel_tv = intel_attached_tv(connector); |
1421 | struct intel_tv *intel_tv = enc_to_intel_tv(encoder); | ||
1422 | const struct tv_mode *tv_mode = intel_tv_mode_find(intel_tv); | 1424 | const struct tv_mode *tv_mode = intel_tv_mode_find(intel_tv); |
1423 | int j, count = 0; | 1425 | int j, count = 0; |
1424 | u64 tmp; | 1426 | u64 tmp; |
@@ -1483,9 +1485,8 @@ intel_tv_set_property(struct drm_connector *connector, struct drm_property *prop | |||
1483 | uint64_t val) | 1485 | uint64_t val) |
1484 | { | 1486 | { |
1485 | struct drm_device *dev = connector->dev; | 1487 | struct drm_device *dev = connector->dev; |
1486 | struct drm_encoder *encoder = intel_attached_encoder(connector); | 1488 | struct intel_tv *intel_tv = intel_attached_tv(connector); |
1487 | struct intel_tv *intel_tv = enc_to_intel_tv(encoder); | 1489 | struct drm_crtc *crtc = intel_tv->base.base.crtc; |
1488 | struct drm_crtc *crtc = encoder->crtc; | ||
1489 | int ret = 0; | 1490 | int ret = 0; |
1490 | bool changed = false; | 1491 | bool changed = false; |
1491 | 1492 | ||
@@ -1550,7 +1551,7 @@ static const struct drm_connector_funcs intel_tv_connector_funcs = { | |||
1550 | static const struct drm_connector_helper_funcs intel_tv_connector_helper_funcs = { | 1551 | static const struct drm_connector_helper_funcs intel_tv_connector_helper_funcs = { |
1551 | .mode_valid = intel_tv_mode_valid, | 1552 | .mode_valid = intel_tv_mode_valid, |
1552 | .get_modes = intel_tv_get_modes, | 1553 | .get_modes = intel_tv_get_modes, |
1553 | .best_encoder = intel_attached_encoder, | 1554 | .best_encoder = intel_best_encoder, |
1554 | }; | 1555 | }; |
1555 | 1556 | ||
1556 | static const struct drm_encoder_funcs intel_tv_enc_funcs = { | 1557 | static const struct drm_encoder_funcs intel_tv_enc_funcs = { |
@@ -1659,8 +1660,7 @@ intel_tv_init(struct drm_device *dev) | |||
1659 | drm_encoder_init(dev, &intel_encoder->base, &intel_tv_enc_funcs, | 1660 | drm_encoder_init(dev, &intel_encoder->base, &intel_tv_enc_funcs, |
1660 | DRM_MODE_ENCODER_TVDAC); | 1661 | DRM_MODE_ENCODER_TVDAC); |
1661 | 1662 | ||
1662 | drm_mode_connector_attach_encoder(&intel_connector->base, | 1663 | intel_connector_attach_encoder(intel_connector, intel_encoder); |
1663 | &intel_encoder->base); | ||
1664 | intel_encoder->type = INTEL_OUTPUT_TVOUT; | 1664 | intel_encoder->type = INTEL_OUTPUT_TVOUT; |
1665 | intel_encoder->crtc_mask = (1 << 0) | (1 << 1); | 1665 | intel_encoder->crtc_mask = (1 << 0) | (1 << 1); |
1666 | intel_encoder->clone_mask = (1 << INTEL_TV_CLONE_BIT); | 1666 | intel_encoder->clone_mask = (1 << INTEL_TV_CLONE_BIT); |