Rev 3031 | Rev 3480 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3031 | Rev 3243 | ||
---|---|---|---|
Line 34... | Line 34... | ||
34 | #include |
34 | #include |
35 | #include "intel_drv.h" |
35 | #include "intel_drv.h" |
36 | #include |
36 | #include |
37 | #include "i915_drv.h" |
37 | #include "i915_drv.h" |
Line -... | Line 38... | ||
- | 38 | ||
- | 39 | static struct drm_device *intel_hdmi_to_dev(struct intel_hdmi *intel_hdmi) |
|
- | 40 | { |
|
- | 41 | return hdmi_to_dig_port(intel_hdmi)->base.base.dev; |
|
- | 42 | } |
|
38 | 43 | ||
39 | static void |
44 | static void |
40 | assert_hdmi_port_disabled(struct intel_hdmi *intel_hdmi) |
45 | assert_hdmi_port_disabled(struct intel_hdmi *intel_hdmi) |
41 | { |
46 | { |
42 | struct drm_device *dev = intel_hdmi->base.base.dev; |
47 | struct drm_device *dev = intel_hdmi_to_dev(intel_hdmi); |
43 | struct drm_i915_private *dev_priv = dev->dev_private; |
48 | struct drm_i915_private *dev_priv = dev->dev_private; |
Line 44... | Line 49... | ||
44 | uint32_t enabled_bits; |
49 | uint32_t enabled_bits; |
Line 49... | Line 54... | ||
49 | "HDMI port enabled, expecting disabled\n"); |
54 | "HDMI port enabled, expecting disabled\n"); |
50 | } |
55 | } |
Line 51... | Line 56... | ||
51 | 56 | ||
52 | struct intel_hdmi *enc_to_intel_hdmi(struct drm_encoder *encoder) |
57 | struct intel_hdmi *enc_to_intel_hdmi(struct drm_encoder *encoder) |
- | 58 | { |
|
53 | { |
59 | struct intel_digital_port *intel_dig_port = |
- | 60 | container_of(encoder, struct intel_digital_port, base.base); |
|
54 | return container_of(encoder, struct intel_hdmi, base.base); |
61 | return &intel_dig_port->hdmi; |
Line 55... | Line 62... | ||
55 | } |
62 | } |
56 | 63 | ||
57 | static struct intel_hdmi *intel_attached_hdmi(struct drm_connector *connector) |
64 | static struct intel_hdmi *intel_attached_hdmi(struct drm_connector *connector) |
58 | { |
- | |
59 | return container_of(intel_attached_encoder(connector), |
65 | { |
Line 60... | Line 66... | ||
60 | struct intel_hdmi, base); |
66 | return enc_to_intel_hdmi(&intel_attached_encoder(connector)->base); |
61 | } |
67 | } |
62 | 68 | ||
Line 332... | Line 338... | ||
332 | }; |
338 | }; |
Line 333... | Line 339... | ||
333 | 339 | ||
334 | if (adjusted_mode->flags & DRM_MODE_FLAG_DBLCLK) |
340 | if (adjusted_mode->flags & DRM_MODE_FLAG_DBLCLK) |
Line -... | Line 341... | ||
- | 341 | avi_if.body.avi.YQ_CN_PR |= DIP_AVI_PR_2; |
|
- | 342 | ||
335 | avi_if.body.avi.YQ_CN_PR |= DIP_AVI_PR_2; |
343 | avi_if.body.avi.VIC = drm_mode_cea_vic(adjusted_mode); |
336 | 344 | ||
Line 337... | Line 345... | ||
337 | intel_set_infoframe(encoder, &avi_if); |
345 | intel_set_infoframe(encoder, &avi_if); |
338 | } |
346 | } |
Line 752... | Line 760... | ||
752 | return MODE_NO_DBLESCAN; |
760 | return MODE_NO_DBLESCAN; |
Line 753... | Line 761... | ||
753 | 761 | ||
754 | return MODE_OK; |
762 | return MODE_OK; |
Line 755... | Line 763... | ||
755 | } |
763 | } |
756 | 764 | ||
757 | static bool intel_hdmi_mode_fixup(struct drm_encoder *encoder, |
765 | bool intel_hdmi_mode_fixup(struct drm_encoder *encoder, |
758 | const struct drm_display_mode *mode, |
766 | const struct drm_display_mode *mode, |
759 | struct drm_display_mode *adjusted_mode) |
767 | struct drm_display_mode *adjusted_mode) |
760 | { |
768 | { |
Line 761... | Line 769... | ||
761 | return true; |
769 | return true; |
762 | } |
770 | } |
763 | 771 | ||
764 | static bool g4x_hdmi_connected(struct intel_hdmi *intel_hdmi) |
772 | static bool g4x_hdmi_connected(struct intel_hdmi *intel_hdmi) |
765 | { |
773 | { |
Line 766... | Line 774... | ||
766 | struct drm_device *dev = intel_hdmi->base.base.dev; |
774 | struct drm_device *dev = intel_hdmi_to_dev(intel_hdmi); |
767 | struct drm_i915_private *dev_priv = dev->dev_private; |
775 | struct drm_i915_private *dev_priv = dev->dev_private; |
Line 784... | Line 792... | ||
784 | 792 | ||
785 | static enum drm_connector_status |
793 | static enum drm_connector_status |
786 | intel_hdmi_detect(struct drm_connector *connector, bool force) |
794 | intel_hdmi_detect(struct drm_connector *connector, bool force) |
787 | { |
795 | { |
- | 796 | struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector); |
|
- | 797 | struct intel_digital_port *intel_dig_port = |
|
- | 798 | hdmi_to_dig_port(intel_hdmi); |
|
788 | struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector); |
799 | struct intel_encoder *intel_encoder = &intel_dig_port->base; |
789 | struct drm_i915_private *dev_priv = connector->dev->dev_private; |
800 | struct drm_i915_private *dev_priv = connector->dev->dev_private; |
790 | struct edid *edid; |
801 | struct edid *edid; |
Line 791... | Line 802... | ||
791 | enum drm_connector_status status = connector_status_disconnected; |
802 | enum drm_connector_status status = connector_status_disconnected; |
Line 812... | Line 823... | ||
812 | 823 | ||
813 | if (status == connector_status_connected) { |
824 | if (status == connector_status_connected) { |
814 | if (intel_hdmi->force_audio != HDMI_AUDIO_AUTO) |
825 | if (intel_hdmi->force_audio != HDMI_AUDIO_AUTO) |
815 | intel_hdmi->has_audio = |
826 | intel_hdmi->has_audio = |
- | 827 | (intel_hdmi->force_audio == HDMI_AUDIO_ON); |
|
816 | (intel_hdmi->force_audio == HDMI_AUDIO_ON); |
828 | intel_encoder->type = INTEL_OUTPUT_HDMI; |
Line 817... | Line 829... | ||
817 | } |
829 | } |
818 | 830 | ||
Line 857... | Line 869... | ||
857 | intel_hdmi_set_property(struct drm_connector *connector, |
869 | intel_hdmi_set_property(struct drm_connector *connector, |
858 | struct drm_property *property, |
870 | struct drm_property *property, |
859 | uint64_t val) |
871 | uint64_t val) |
860 | { |
872 | { |
861 | struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector); |
873 | struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector); |
- | 874 | struct intel_digital_port *intel_dig_port = |
|
- | 875 | hdmi_to_dig_port(intel_hdmi); |
|
862 | struct drm_i915_private *dev_priv = connector->dev->dev_private; |
876 | struct drm_i915_private *dev_priv = connector->dev->dev_private; |
863 | int ret; |
877 | int ret; |
Line 864... | Line 878... | ||
864 | 878 | ||
865 | ret = drm_connector_property_set_value(connector, property, val); |
879 | ret = drm_object_property_set_value(&connector->base, property, val); |
866 | if (ret) |
880 | if (ret) |
867 | return ret; |
881 | return ret; |
868 | #if 0 |
882 | #if 0 |
869 | if (property == dev_priv->force_audio_property) { |
883 | if (property == dev_priv->force_audio_property) { |
Line 897... | Line 911... | ||
897 | } |
911 | } |
Line 898... | Line 912... | ||
898 | 912 | ||
Line 899... | Line 913... | ||
899 | return -EINVAL; |
913 | return -EINVAL; |
900 | 914 | ||
901 | done: |
915 | done: |
902 | if (intel_hdmi->base.base.crtc) { |
916 | if (intel_dig_port->base.base.crtc) { |
903 | struct drm_crtc *crtc = intel_hdmi->base.base.crtc; |
917 | struct drm_crtc *crtc = intel_dig_port->base.base.crtc; |
904 | intel_set_mode(crtc, &crtc->mode, |
918 | intel_set_mode(crtc, &crtc->mode, |
Line 905... | Line 919... | ||
905 | crtc->x, crtc->y, crtc->fb); |
919 | crtc->x, crtc->y, crtc->fb); |
Line 913... | Line 927... | ||
913 | drm_sysfs_connector_remove(connector); |
927 | drm_sysfs_connector_remove(connector); |
914 | drm_connector_cleanup(connector); |
928 | drm_connector_cleanup(connector); |
915 | kfree(connector); |
929 | kfree(connector); |
916 | } |
930 | } |
Line 917... | Line -... | ||
917 | - | ||
918 | static const struct drm_encoder_helper_funcs intel_hdmi_helper_funcs_hsw = { |
- | |
919 | .mode_fixup = intel_hdmi_mode_fixup, |
- | |
920 | .mode_set = intel_ddi_mode_set, |
- | |
921 | .disable = intel_encoder_noop, |
- | |
922 | }; |
- | |
923 | 931 | ||
924 | static const struct drm_encoder_helper_funcs intel_hdmi_helper_funcs = { |
932 | static const struct drm_encoder_helper_funcs intel_hdmi_helper_funcs = { |
925 | .mode_fixup = intel_hdmi_mode_fixup, |
933 | .mode_fixup = intel_hdmi_mode_fixup, |
926 | .mode_set = intel_hdmi_mode_set, |
934 | .mode_set = intel_hdmi_mode_set, |
927 | .disable = intel_encoder_noop, |
935 | .disable = intel_encoder_noop, |
Line 950... | Line 958... | ||
950 | { |
958 | { |
951 | intel_attach_force_audio_property(connector); |
959 | intel_attach_force_audio_property(connector); |
952 | intel_attach_broadcast_rgb_property(connector); |
960 | intel_attach_broadcast_rgb_property(connector); |
953 | } |
961 | } |
Line 954... | Line 962... | ||
954 | 962 | ||
- | 963 | void intel_hdmi_init_connector(struct intel_digital_port *intel_dig_port, |
|
955 | void intel_hdmi_init(struct drm_device *dev, int sdvox_reg, enum port port) |
964 | struct intel_connector *intel_connector) |
- | 965 | { |
|
- | 966 | struct drm_connector *connector = &intel_connector->base; |
|
- | 967 | struct intel_hdmi *intel_hdmi = &intel_dig_port->hdmi; |
|
- | 968 | struct intel_encoder *intel_encoder = &intel_dig_port->base; |
|
956 | { |
969 | struct drm_device *dev = intel_encoder->base.dev; |
957 | struct drm_i915_private *dev_priv = dev->dev_private; |
- | |
958 | struct drm_connector *connector; |
- | |
959 | struct intel_encoder *intel_encoder; |
970 | struct drm_i915_private *dev_priv = dev->dev_private; |
960 | struct intel_connector *intel_connector; |
- | |
Line 961... | Line -... | ||
961 | struct intel_hdmi *intel_hdmi; |
- | |
962 | - | ||
963 | intel_hdmi = kzalloc(sizeof(struct intel_hdmi), GFP_KERNEL); |
- | |
964 | if (!intel_hdmi) |
- | |
965 | return; |
- | |
966 | - | ||
967 | intel_connector = kzalloc(sizeof(struct intel_connector), GFP_KERNEL); |
- | |
968 | if (!intel_connector) { |
- | |
969 | kfree(intel_hdmi); |
- | |
970 | return; |
- | |
971 | } |
- | |
972 | - | ||
973 | intel_encoder = &intel_hdmi->base; |
- | |
974 | drm_encoder_init(dev, &intel_encoder->base, &intel_hdmi_enc_funcs, |
- | |
975 | DRM_MODE_ENCODER_TMDS); |
- | |
976 | 971 | enum port port = intel_dig_port->port; |
|
977 | connector = &intel_connector->base; |
972 | |
978 | drm_connector_init(dev, connector, &intel_hdmi_connector_funcs, |
973 | drm_connector_init(dev, connector, &intel_hdmi_connector_funcs, |
Line 979... | Line -... | ||
979 | DRM_MODE_CONNECTOR_HDMIA); |
- | |
980 | drm_connector_helper_add(connector, &intel_hdmi_connector_helper_funcs); |
- | |
981 | 974 | DRM_MODE_CONNECTOR_HDMIA); |
|
982 | intel_encoder->type = INTEL_OUTPUT_HDMI; |
975 | drm_connector_helper_add(connector, &intel_hdmi_connector_helper_funcs); |
983 | 976 | ||
984 | connector->polled = DRM_CONNECTOR_POLL_HPD; |
- | |
985 | connector->interlace_allowed = 1; |
- | |
986 | connector->doublescan_allowed = 0; |
- | |
Line 987... | Line -... | ||
987 | intel_encoder->crtc_mask = (1 << 0) | (1 << 1) | (1 << 2); |
- | |
988 | 977 | connector->polled = DRM_CONNECTOR_POLL_HPD; |
|
989 | intel_encoder->cloneable = false; |
978 | connector->interlace_allowed = 1; |
990 | 979 | connector->doublescan_allowed = 0; |
|
991 | intel_hdmi->ddi_port = port; |
980 | |
992 | switch (port) { |
981 | switch (port) { |
Line 1006... | Line 995... | ||
1006 | /* Internal port only for eDP. */ |
995 | /* Internal port only for eDP. */ |
1007 | default: |
996 | default: |
1008 | BUG(); |
997 | BUG(); |
1009 | } |
998 | } |
Line 1010... | Line -... | ||
1010 | - | ||
1011 | intel_hdmi->sdvox_reg = sdvox_reg; |
- | |
1012 | 999 | ||
1013 | if (!HAS_PCH_SPLIT(dev)) { |
1000 | if (!HAS_PCH_SPLIT(dev)) { |
1014 | intel_hdmi->write_infoframe = g4x_write_infoframe; |
1001 | intel_hdmi->write_infoframe = g4x_write_infoframe; |
1015 | intel_hdmi->set_infoframes = g4x_set_infoframes; |
1002 | intel_hdmi->set_infoframes = g4x_set_infoframes; |
1016 | } else if (IS_VALLEYVIEW(dev)) { |
1003 | } else if (IS_VALLEYVIEW(dev)) { |
Line 1025... | Line 1012... | ||
1025 | } else { |
1012 | } else { |
1026 | intel_hdmi->write_infoframe = cpt_write_infoframe; |
1013 | intel_hdmi->write_infoframe = cpt_write_infoframe; |
1027 | intel_hdmi->set_infoframes = cpt_set_infoframes; |
1014 | intel_hdmi->set_infoframes = cpt_set_infoframes; |
1028 | } |
1015 | } |
Line 1029... | Line 1016... | ||
1029 | 1016 | ||
1030 | if (IS_HASWELL(dev)) { |
- | |
1031 | intel_encoder->enable = intel_enable_ddi; |
- | |
1032 | intel_encoder->disable = intel_disable_ddi; |
1017 | if (IS_HASWELL(dev)) |
1033 | intel_encoder->get_hw_state = intel_ddi_get_hw_state; |
- | |
1034 | drm_encoder_helper_add(&intel_encoder->base, |
- | |
1035 | &intel_hdmi_helper_funcs_hsw); |
1018 | intel_connector->get_hw_state = intel_ddi_connector_get_hw_state; |
1036 | } else { |
- | |
1037 | intel_encoder->enable = intel_enable_hdmi; |
- | |
1038 | intel_encoder->disable = intel_disable_hdmi; |
- | |
1039 | intel_encoder->get_hw_state = intel_hdmi_get_hw_state; |
- | |
1040 | drm_encoder_helper_add(&intel_encoder->base, |
- | |
1041 | &intel_hdmi_helper_funcs); |
- | |
1042 | } |
1019 | else |
Line 1043... | Line -... | ||
1043 | intel_connector->get_hw_state = intel_connector_get_hw_state; |
- | |
1044 | 1020 | intel_connector->get_hw_state = intel_connector_get_hw_state; |
|
Line 1045... | Line 1021... | ||
1045 | 1021 | ||
1046 | intel_hdmi_add_properties(intel_hdmi, connector); |
1022 | intel_hdmi_add_properties(intel_hdmi, connector); |
Line 1055... | Line 1031... | ||
1055 | if (IS_G4X(dev) && !IS_GM45(dev)) { |
1031 | if (IS_G4X(dev) && !IS_GM45(dev)) { |
1056 | u32 temp = I915_READ(PEG_BAND_GAP_DATA); |
1032 | u32 temp = I915_READ(PEG_BAND_GAP_DATA); |
1057 | I915_WRITE(PEG_BAND_GAP_DATA, (temp & ~0xf) | 0xd); |
1033 | I915_WRITE(PEG_BAND_GAP_DATA, (temp & ~0xf) | 0xd); |
1058 | } |
1034 | } |
1059 | }><>><>><>>>>>>>>>>>>> |
1035 | } |
- | 1036 | ||
- | 1037 | void intel_hdmi_init(struct drm_device *dev, int sdvox_reg, enum port port) |
|
- | 1038 | { |
|
- | 1039 | struct intel_digital_port *intel_dig_port; |
|
- | 1040 | struct intel_encoder *intel_encoder; |
|
- | 1041 | struct drm_encoder *encoder; |
|
- | 1042 | struct intel_connector *intel_connector; |
|
- | 1043 | ||
- | 1044 | intel_dig_port = kzalloc(sizeof(struct intel_digital_port), GFP_KERNEL); |
|
- | 1045 | if (!intel_dig_port) |
|
- | 1046 | return; |
|
- | 1047 | ||
- | 1048 | intel_connector = kzalloc(sizeof(struct intel_connector), GFP_KERNEL); |
|
- | 1049 | if (!intel_connector) { |
|
- | 1050 | kfree(intel_dig_port); |
|
- | 1051 | return; |
|
- | 1052 | } |
|
- | 1053 | ||
- | 1054 | intel_encoder = &intel_dig_port->base; |
|
- | 1055 | encoder = &intel_encoder->base; |
|
- | 1056 | ||
- | 1057 | drm_encoder_init(dev, &intel_encoder->base, &intel_hdmi_enc_funcs, |
|
- | 1058 | DRM_MODE_ENCODER_TMDS); |
|
- | 1059 | drm_encoder_helper_add(&intel_encoder->base, &intel_hdmi_helper_funcs); |
|
- | 1060 | ||
- | 1061 | intel_encoder->enable = intel_enable_hdmi; |
|
- | 1062 | intel_encoder->disable = intel_disable_hdmi; |
|
- | 1063 | intel_encoder->get_hw_state = intel_hdmi_get_hw_state; |
|
- | 1064 | ||
- | 1065 | intel_encoder->type = INTEL_OUTPUT_HDMI; |
|
- | 1066 | intel_encoder->crtc_mask = (1 << 0) | (1 << 1) | (1 << 2); |
|
- | 1067 | intel_encoder->cloneable = false; |
|
- | 1068 | ||
- | 1069 | intel_dig_port->port = port; |
|
- | 1070 | intel_dig_port->hdmi.sdvox_reg = sdvox_reg; |
|
- | 1071 | intel_dig_port->dp.output_reg = 0; |
|
- | 1072 | ||
- | 1073 | intel_hdmi_init_connector(intel_dig_port, intel_connector); |
|
- | 1074 | }><>><>><>>>>>>>>>>>>> |