diff options
author | Zhenyu Wang <zhenyuw@linux.intel.com> | 2010-03-29 03:53:23 -0400 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2010-04-12 12:23:48 -0400 |
commit | 454c1ca8be2f30cc4b21a20d1b6a69c442f2d8bd (patch) | |
tree | fc55d463cfad54c7d5c46747b3d05d587fde98e3 /drivers/gpu/drm/i915/intel_crt.c | |
parent | 9c9e792795f96d201d85188607261f9f8bbf3219 (diff) |
drm/i915: convert VGA driver to new encoder/connector structure
Signed-off-by: Zhenyu Wang <zhenyuw@linux.intel.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
Diffstat (limited to 'drivers/gpu/drm/i915/intel_crt.c')
-rw-r--r-- | drivers/gpu/drm/i915/intel_crt.c | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/drivers/gpu/drm/i915/intel_crt.c b/drivers/gpu/drm/i915/intel_crt.c index 996d063c40ca..d7a1d9d58d05 100644 --- a/drivers/gpu/drm/i915/intel_crt.c +++ b/drivers/gpu/drm/i915/intel_crt.c | |||
@@ -261,9 +261,9 @@ static bool intel_crt_detect_hotplug(struct drm_connector *connector) | |||
261 | return false; | 261 | return false; |
262 | } | 262 | } |
263 | 263 | ||
264 | static bool intel_crt_detect_ddc(struct drm_connector *connector) | 264 | static bool intel_crt_detect_ddc(struct drm_encoder *encoder) |
265 | { | 265 | { |
266 | struct intel_encoder *intel_encoder = to_intel_encoder(connector); | 266 | struct intel_encoder *intel_encoder = enc_to_intel_encoder(encoder); |
267 | 267 | ||
268 | /* CRT should always be at 0, but check anyway */ | 268 | /* CRT should always be at 0, but check anyway */ |
269 | if (intel_encoder->type != INTEL_OUTPUT_ANALOG) | 269 | if (intel_encoder->type != INTEL_OUTPUT_ANALOG) |
@@ -403,8 +403,8 @@ intel_crt_load_detect(struct drm_crtc *crtc, struct intel_encoder *intel_encoder | |||
403 | static enum drm_connector_status intel_crt_detect(struct drm_connector *connector) | 403 | static enum drm_connector_status intel_crt_detect(struct drm_connector *connector) |
404 | { | 404 | { |
405 | struct drm_device *dev = connector->dev; | 405 | struct drm_device *dev = connector->dev; |
406 | struct intel_encoder *intel_encoder = to_intel_encoder(connector); | 406 | struct drm_encoder *encoder = intel_attached_encoder(connector); |
407 | struct drm_encoder *encoder = &intel_encoder->enc; | 407 | struct intel_encoder *intel_encoder = enc_to_intel_encoder(encoder); |
408 | struct drm_crtc *crtc; | 408 | struct drm_crtc *crtc; |
409 | int dpms_mode; | 409 | int dpms_mode; |
410 | enum drm_connector_status status; | 410 | enum drm_connector_status status; |
@@ -416,7 +416,7 @@ static enum drm_connector_status intel_crt_detect(struct drm_connector *connecto | |||
416 | return connector_status_disconnected; | 416 | return connector_status_disconnected; |
417 | } | 417 | } |
418 | 418 | ||
419 | if (intel_crt_detect_ddc(connector)) | 419 | if (intel_crt_detect_ddc(encoder)) |
420 | return connector_status_connected; | 420 | return connector_status_connected; |
421 | 421 | ||
422 | /* for pre-945g platforms use load detect */ | 422 | /* for pre-945g platforms use load detect */ |
@@ -438,9 +438,6 @@ static enum drm_connector_status intel_crt_detect(struct drm_connector *connecto | |||
438 | 438 | ||
439 | static void intel_crt_destroy(struct drm_connector *connector) | 439 | static void intel_crt_destroy(struct drm_connector *connector) |
440 | { | 440 | { |
441 | struct intel_encoder *intel_encoder = to_intel_encoder(connector); | ||
442 | |||
443 | intel_i2c_destroy(intel_encoder->ddc_bus); | ||
444 | drm_sysfs_connector_remove(connector); | 441 | drm_sysfs_connector_remove(connector); |
445 | drm_connector_cleanup(connector); | 442 | drm_connector_cleanup(connector); |
446 | kfree(connector); | 443 | kfree(connector); |
@@ -449,7 +446,8 @@ static void intel_crt_destroy(struct drm_connector *connector) | |||
449 | static int intel_crt_get_modes(struct drm_connector *connector) | 446 | static int intel_crt_get_modes(struct drm_connector *connector) |
450 | { | 447 | { |
451 | int ret; | 448 | int ret; |
452 | struct intel_encoder *intel_encoder = to_intel_encoder(connector); | 449 | struct drm_encoder *encoder = intel_attached_encoder(connector); |
450 | struct intel_encoder *intel_encoder = enc_to_intel_encoder(encoder); | ||
453 | struct i2c_adapter *ddc_bus; | 451 | struct i2c_adapter *ddc_bus; |
454 | struct drm_device *dev = connector->dev; | 452 | struct drm_device *dev = connector->dev; |
455 | 453 | ||
@@ -505,12 +503,16 @@ static const struct drm_connector_funcs intel_crt_connector_funcs = { | |||
505 | static const struct drm_connector_helper_funcs intel_crt_connector_helper_funcs = { | 503 | static const struct drm_connector_helper_funcs intel_crt_connector_helper_funcs = { |
506 | .mode_valid = intel_crt_mode_valid, | 504 | .mode_valid = intel_crt_mode_valid, |
507 | .get_modes = intel_crt_get_modes, | 505 | .get_modes = intel_crt_get_modes, |
508 | .best_encoder = intel_best_encoder, | 506 | .best_encoder = intel_attached_encoder, |
509 | }; | 507 | }; |
510 | 508 | ||
511 | static void intel_crt_enc_destroy(struct drm_encoder *encoder) | 509 | static void intel_crt_enc_destroy(struct drm_encoder *encoder) |
512 | { | 510 | { |
511 | struct intel_encoder *intel_encoder = enc_to_intel_encoder(encoder); | ||
512 | |||
513 | intel_i2c_destroy(intel_encoder->ddc_bus); | ||
513 | drm_encoder_cleanup(encoder); | 514 | drm_encoder_cleanup(encoder); |
515 | kfree(intel_encoder); | ||
514 | } | 516 | } |
515 | 517 | ||
516 | static const struct drm_encoder_funcs intel_crt_enc_funcs = { | 518 | static const struct drm_encoder_funcs intel_crt_enc_funcs = { |
@@ -521,6 +523,7 @@ void intel_crt_init(struct drm_device *dev) | |||
521 | { | 523 | { |
522 | struct drm_connector *connector; | 524 | struct drm_connector *connector; |
523 | struct intel_encoder *intel_encoder; | 525 | struct intel_encoder *intel_encoder; |
526 | struct intel_connector *intel_connector; | ||
524 | struct drm_i915_private *dev_priv = dev->dev_private; | 527 | struct drm_i915_private *dev_priv = dev->dev_private; |
525 | u32 i2c_reg; | 528 | u32 i2c_reg; |
526 | 529 | ||
@@ -528,14 +531,20 @@ void intel_crt_init(struct drm_device *dev) | |||
528 | if (!intel_encoder) | 531 | if (!intel_encoder) |
529 | return; | 532 | return; |
530 | 533 | ||
531 | connector = &intel_encoder->base; | 534 | intel_connector = kzalloc(sizeof(struct intel_connector), GFP_KERNEL); |
532 | drm_connector_init(dev, &intel_encoder->base, | 535 | if (!intel_connector) { |
536 | kfree(intel_encoder); | ||
537 | return; | ||
538 | } | ||
539 | |||
540 | connector = &intel_connector->base; | ||
541 | drm_connector_init(dev, &intel_connector->base, | ||
533 | &intel_crt_connector_funcs, DRM_MODE_CONNECTOR_VGA); | 542 | &intel_crt_connector_funcs, DRM_MODE_CONNECTOR_VGA); |
534 | 543 | ||
535 | drm_encoder_init(dev, &intel_encoder->enc, &intel_crt_enc_funcs, | 544 | drm_encoder_init(dev, &intel_encoder->enc, &intel_crt_enc_funcs, |
536 | DRM_MODE_ENCODER_DAC); | 545 | DRM_MODE_ENCODER_DAC); |
537 | 546 | ||
538 | drm_mode_connector_attach_encoder(&intel_encoder->base, | 547 | drm_mode_connector_attach_encoder(&intel_connector->base, |
539 | &intel_encoder->enc); | 548 | &intel_encoder->enc); |
540 | 549 | ||
541 | /* Set up the DDC bus. */ | 550 | /* Set up the DDC bus. */ |