diff options
author | Alex Deucher <alexdeucher@gmail.com> | 2010-02-01 19:06:06 -0500 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2010-02-08 18:32:23 -0500 |
commit | 9ae4786712166638a8daed902886ef400e88ab24 (patch) | |
tree | b2391e1ef489399fd2c137043418f9001e817f79 /drivers | |
parent | 26b9fc3ab13587d4e86b217be43d1fb7ca934576 (diff) |
drm/radeon/kms/atom: add a helper function to get the radeon connector priv
This is used in a lot of places in the atom encoder code.
While here fix the spelling of crtc_source_params.
Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_encoders.c | 107 |
1 files changed, 48 insertions, 59 deletions
diff --git a/drivers/gpu/drm/radeon/radeon_encoders.c b/drivers/gpu/drm/radeon/radeon_encoders.c index 3c91724457ca..c5ba1e30a43f 100644 --- a/drivers/gpu/drm/radeon/radeon_encoders.c +++ b/drivers/gpu/drm/radeon/radeon_encoders.c | |||
@@ -228,6 +228,32 @@ radeon_get_connector_for_encoder(struct drm_encoder *encoder) | |||
228 | return NULL; | 228 | return NULL; |
229 | } | 229 | } |
230 | 230 | ||
231 | static struct radeon_connector_atom_dig * | ||
232 | radeon_get_atom_connector_priv_from_encoder(struct drm_encoder *encoder) | ||
233 | { | ||
234 | struct drm_device *dev = encoder->dev; | ||
235 | struct radeon_device *rdev = dev->dev_private; | ||
236 | struct drm_connector *connector; | ||
237 | struct radeon_connector *radeon_connector; | ||
238 | struct radeon_connector_atom_dig *dig_connector; | ||
239 | |||
240 | if (!rdev->is_atom_bios) | ||
241 | return NULL; | ||
242 | |||
243 | connector = radeon_get_connector_for_encoder(encoder); | ||
244 | if (!connector) | ||
245 | return NULL; | ||
246 | |||
247 | radeon_connector = to_radeon_connector(connector); | ||
248 | |||
249 | if (!radeon_connector->con_priv) | ||
250 | return NULL; | ||
251 | |||
252 | dig_connector = radeon_connector->con_priv; | ||
253 | |||
254 | return dig_connector; | ||
255 | } | ||
256 | |||
231 | static bool radeon_atom_mode_fixup(struct drm_encoder *encoder, | 257 | static bool radeon_atom_mode_fixup(struct drm_encoder *encoder, |
232 | struct drm_display_mode *mode, | 258 | struct drm_display_mode *mode, |
233 | struct drm_display_mode *adjusted_mode) | 259 | struct drm_display_mode *adjusted_mode) |
@@ -458,34 +484,20 @@ atombios_digital_setup(struct drm_encoder *encoder, int action) | |||
458 | struct drm_device *dev = encoder->dev; | 484 | struct drm_device *dev = encoder->dev; |
459 | struct radeon_device *rdev = dev->dev_private; | 485 | struct radeon_device *rdev = dev->dev_private; |
460 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); | 486 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
487 | struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv; | ||
488 | struct radeon_connector_atom_dig *dig_connector = | ||
489 | radeon_get_atom_connector_priv_from_encoder(encoder); | ||
461 | union lvds_encoder_control args; | 490 | union lvds_encoder_control args; |
462 | int index = 0; | 491 | int index = 0; |
463 | int hdmi_detected = 0; | 492 | int hdmi_detected = 0; |
464 | uint8_t frev, crev; | 493 | uint8_t frev, crev; |
465 | struct radeon_encoder_atom_dig *dig; | ||
466 | struct drm_connector *connector; | ||
467 | struct radeon_connector *radeon_connector; | ||
468 | struct radeon_connector_atom_dig *dig_connector; | ||
469 | |||
470 | connector = radeon_get_connector_for_encoder(encoder); | ||
471 | if (!connector) | ||
472 | return; | ||
473 | |||
474 | radeon_connector = to_radeon_connector(connector); | ||
475 | 494 | ||
476 | if (!radeon_encoder->enc_priv) | 495 | if (!dig || !dig_connector) |
477 | return; | ||
478 | |||
479 | dig = radeon_encoder->enc_priv; | ||
480 | |||
481 | if (!radeon_connector->con_priv) | ||
482 | return; | 496 | return; |
483 | 497 | ||
484 | if (drm_detect_hdmi_monitor(radeon_connector->edid)) | 498 | if (atombios_get_encoder_mode(encoder) == ATOM_ENCODER_MODE_HDMI) |
485 | hdmi_detected = 1; | 499 | hdmi_detected = 1; |
486 | 500 | ||
487 | dig_connector = radeon_connector->con_priv; | ||
488 | |||
489 | memset(&args, 0, sizeof(args)); | 501 | memset(&args, 0, sizeof(args)); |
490 | 502 | ||
491 | switch (radeon_encoder->encoder_id) { | 503 | switch (radeon_encoder->encoder_id) { |
@@ -586,7 +598,7 @@ atombios_get_encoder_mode(struct drm_encoder *encoder) | |||
586 | { | 598 | { |
587 | struct drm_connector *connector; | 599 | struct drm_connector *connector; |
588 | struct radeon_connector *radeon_connector; | 600 | struct radeon_connector *radeon_connector; |
589 | struct radeon_connector_atom_dig *radeon_dig_connector; | 601 | struct radeon_connector_atom_dig *dig_connector; |
590 | 602 | ||
591 | connector = radeon_get_connector_for_encoder(encoder); | 603 | connector = radeon_get_connector_for_encoder(encoder); |
592 | if (!connector) | 604 | if (!connector) |
@@ -617,9 +629,9 @@ atombios_get_encoder_mode(struct drm_encoder *encoder) | |||
617 | break; | 629 | break; |
618 | case DRM_MODE_CONNECTOR_DisplayPort: | 630 | case DRM_MODE_CONNECTOR_DisplayPort: |
619 | case DRM_MODE_CONNECTOR_eDP: | 631 | case DRM_MODE_CONNECTOR_eDP: |
620 | radeon_dig_connector = radeon_connector->con_priv; | 632 | dig_connector = radeon_connector->con_priv; |
621 | if ((radeon_dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT) || | 633 | if ((dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT) || |
622 | (radeon_dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_eDP)) | 634 | (dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_eDP)) |
623 | return ATOM_ENCODER_MODE_DP; | 635 | return ATOM_ENCODER_MODE_DP; |
624 | else if (drm_detect_hdmi_monitor(radeon_connector->edid)) | 636 | else if (drm_detect_hdmi_monitor(radeon_connector->edid)) |
625 | return ATOM_ENCODER_MODE_HDMI; | 637 | return ATOM_ENCODER_MODE_HDMI; |
@@ -670,30 +682,16 @@ atombios_dig_encoder_setup(struct drm_encoder *encoder, int action) | |||
670 | struct drm_device *dev = encoder->dev; | 682 | struct drm_device *dev = encoder->dev; |
671 | struct radeon_device *rdev = dev->dev_private; | 683 | struct radeon_device *rdev = dev->dev_private; |
672 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); | 684 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
685 | struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv; | ||
686 | struct radeon_connector_atom_dig *dig_connector = | ||
687 | radeon_get_atom_connector_priv_from_encoder(encoder); | ||
673 | DIG_ENCODER_CONTROL_PS_ALLOCATION args; | 688 | DIG_ENCODER_CONTROL_PS_ALLOCATION args; |
674 | int index = 0, num = 0; | 689 | int index = 0, num = 0; |
675 | uint8_t frev, crev; | 690 | uint8_t frev, crev; |
676 | struct radeon_encoder_atom_dig *dig; | ||
677 | struct drm_connector *connector; | ||
678 | struct radeon_connector *radeon_connector; | ||
679 | struct radeon_connector_atom_dig *dig_connector; | ||
680 | |||
681 | connector = radeon_get_connector_for_encoder(encoder); | ||
682 | if (!connector) | ||
683 | return; | ||
684 | |||
685 | radeon_connector = to_radeon_connector(connector); | ||
686 | |||
687 | if (!radeon_connector->con_priv) | ||
688 | return; | ||
689 | |||
690 | dig_connector = radeon_connector->con_priv; | ||
691 | 691 | ||
692 | if (!radeon_encoder->enc_priv) | 692 | if (!dig || !dig_connector) |
693 | return; | 693 | return; |
694 | 694 | ||
695 | dig = radeon_encoder->enc_priv; | ||
696 | |||
697 | memset(&args, 0, sizeof(args)); | 695 | memset(&args, 0, sizeof(args)); |
698 | 696 | ||
699 | if (dig->dig_encoder) | 697 | if (dig->dig_encoder) |
@@ -761,31 +759,22 @@ atombios_dig_transmitter_setup(struct drm_encoder *encoder, int action, uint8_t | |||
761 | struct drm_device *dev = encoder->dev; | 759 | struct drm_device *dev = encoder->dev; |
762 | struct radeon_device *rdev = dev->dev_private; | 760 | struct radeon_device *rdev = dev->dev_private; |
763 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); | 761 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
762 | struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv; | ||
763 | struct radeon_connector_atom_dig *dig_connector = | ||
764 | radeon_get_atom_connector_priv_from_encoder(encoder); | ||
765 | struct drm_connector *connector; | ||
766 | struct radeon_connector *radeon_connector; | ||
764 | union dig_transmitter_control args; | 767 | union dig_transmitter_control args; |
765 | int index = 0, num = 0; | 768 | int index = 0, num = 0; |
766 | uint8_t frev, crev; | 769 | uint8_t frev, crev; |
767 | struct radeon_encoder_atom_dig *dig; | ||
768 | struct drm_connector *connector; | ||
769 | struct radeon_connector *radeon_connector; | ||
770 | struct radeon_connector_atom_dig *dig_connector; | ||
771 | bool is_dp = false; | 770 | bool is_dp = false; |
772 | 771 | ||
773 | connector = radeon_get_connector_for_encoder(encoder); | 772 | if (!dig || !dig_connector) |
774 | if (!connector) | ||
775 | return; | 773 | return; |
776 | 774 | ||
775 | connector = radeon_get_connector_for_encoder(encoder); | ||
777 | radeon_connector = to_radeon_connector(connector); | 776 | radeon_connector = to_radeon_connector(connector); |
778 | 777 | ||
779 | if (!radeon_encoder->enc_priv) | ||
780 | return; | ||
781 | |||
782 | dig = radeon_encoder->enc_priv; | ||
783 | |||
784 | if (!radeon_connector->con_priv) | ||
785 | return; | ||
786 | |||
787 | dig_connector = radeon_connector->con_priv; | ||
788 | |||
789 | if (atombios_get_encoder_mode(encoder) == ATOM_ENCODER_MODE_DP) | 778 | if (atombios_get_encoder_mode(encoder) == ATOM_ENCODER_MODE_DP) |
790 | is_dp = true; | 779 | is_dp = true; |
791 | 780 | ||
@@ -1026,7 +1015,7 @@ radeon_atom_encoder_dpms(struct drm_encoder *encoder, int mode) | |||
1026 | radeon_atombios_encoder_dpms_scratch_regs(encoder, (mode == DRM_MODE_DPMS_ON) ? true : false); | 1015 | radeon_atombios_encoder_dpms_scratch_regs(encoder, (mode == DRM_MODE_DPMS_ON) ? true : false); |
1027 | } | 1016 | } |
1028 | 1017 | ||
1029 | union crtc_sourc_param { | 1018 | union crtc_source_param { |
1030 | SELECT_CRTC_SOURCE_PS_ALLOCATION v1; | 1019 | SELECT_CRTC_SOURCE_PS_ALLOCATION v1; |
1031 | SELECT_CRTC_SOURCE_PARAMETERS_V2 v2; | 1020 | SELECT_CRTC_SOURCE_PARAMETERS_V2 v2; |
1032 | }; | 1021 | }; |
@@ -1038,7 +1027,7 @@ atombios_set_encoder_crtc_source(struct drm_encoder *encoder) | |||
1038 | struct radeon_device *rdev = dev->dev_private; | 1027 | struct radeon_device *rdev = dev->dev_private; |
1039 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); | 1028 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
1040 | struct radeon_crtc *radeon_crtc = to_radeon_crtc(encoder->crtc); | 1029 | struct radeon_crtc *radeon_crtc = to_radeon_crtc(encoder->crtc); |
1041 | union crtc_sourc_param args; | 1030 | union crtc_source_param args; |
1042 | int index = GetIndexIntoMasterTable(COMMAND, SelectCRTC_Source); | 1031 | int index = GetIndexIntoMasterTable(COMMAND, SelectCRTC_Source); |
1043 | uint8_t frev, crev; | 1032 | uint8_t frev, crev; |
1044 | struct radeon_encoder_atom_dig *dig; | 1033 | struct radeon_encoder_atom_dig *dig; |