Commit b9cb234cbdc7fb34b78068d5faeace61351347b7
Committed by
Daniel Vetter
1 parent
da63a9f2e4
Exists in
master
and in
20 other branches
drm/i915: split intel_hdmi_init into encoder and connector pieces
We want to split the HDMI connector and encoder initialization because in the future the DDI code will have its own "encoder init" function, but it will still call intel_hdmi_init_connector. The DDI encoder will actually have two connectors attached to it: HDMI and DP. The best way to look at this patch is to imagine that we're renaming intel_hdmi_init to intel_hdmi_init_connector and removing the encoder-specific pieces and placing them into intel_hdmi_init. Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com> Reviewed-by: Damien Lespiau <damien.lespiau@intel.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Showing 1 changed file with 53 additions and 43 deletions Side-by-side Diff
drivers/gpu/drm/i915/intel_hdmi.c
... | ... | @@ -959,45 +959,24 @@ |
959 | 959 | intel_attach_broadcast_rgb_property(connector); |
960 | 960 | } |
961 | 961 | |
962 | -void intel_hdmi_init(struct drm_device *dev, int sdvox_reg, enum port port) | |
962 | +static void intel_hdmi_init_connector(struct intel_digital_port *intel_dig_port, | |
963 | + struct intel_connector *intel_connector) | |
963 | 964 | { |
965 | + struct drm_connector *connector = &intel_connector->base; | |
966 | + struct intel_hdmi *intel_hdmi = &intel_dig_port->hdmi; | |
967 | + struct intel_encoder *intel_encoder = &intel_dig_port->base; | |
968 | + struct drm_device *dev = intel_encoder->base.dev; | |
964 | 969 | struct drm_i915_private *dev_priv = dev->dev_private; |
965 | - struct drm_connector *connector; | |
966 | - struct intel_encoder *intel_encoder; | |
967 | - struct intel_connector *intel_connector; | |
968 | - struct intel_digital_port *intel_dig_port; | |
969 | - struct intel_hdmi *intel_hdmi; | |
970 | + enum port port = intel_hdmi->ddi_port; | |
970 | 971 | |
971 | - intel_dig_port = kzalloc(sizeof(struct intel_digital_port), GFP_KERNEL); | |
972 | - if (!intel_dig_port) | |
973 | - return; | |
974 | - | |
975 | - intel_connector = kzalloc(sizeof(struct intel_connector), GFP_KERNEL); | |
976 | - if (!intel_connector) { | |
977 | - kfree(intel_dig_port); | |
978 | - return; | |
979 | - } | |
980 | - | |
981 | - intel_hdmi = &intel_dig_port->hdmi; | |
982 | - intel_encoder = &intel_dig_port->base; | |
983 | - drm_encoder_init(dev, &intel_encoder->base, &intel_hdmi_enc_funcs, | |
984 | - DRM_MODE_ENCODER_TMDS); | |
985 | - | |
986 | - connector = &intel_connector->base; | |
987 | 972 | drm_connector_init(dev, connector, &intel_hdmi_connector_funcs, |
988 | 973 | DRM_MODE_CONNECTOR_HDMIA); |
989 | 974 | drm_connector_helper_add(connector, &intel_hdmi_connector_helper_funcs); |
990 | 975 | |
991 | - intel_encoder->type = INTEL_OUTPUT_HDMI; | |
992 | - | |
993 | 976 | connector->polled = DRM_CONNECTOR_POLL_HPD; |
994 | 977 | connector->interlace_allowed = 1; |
995 | 978 | connector->doublescan_allowed = 0; |
996 | - intel_encoder->crtc_mask = (1 << 0) | (1 << 1) | (1 << 2); | |
997 | 979 | |
998 | - intel_encoder->cloneable = false; | |
999 | - | |
1000 | - intel_hdmi->ddi_port = port; | |
1001 | 980 | switch (port) { |
1002 | 981 | case PORT_B: |
1003 | 982 | intel_hdmi->ddc_bus = GMBUS_PORT_DPB; |
... | ... | @@ -1017,8 +996,6 @@ |
1017 | 996 | BUG(); |
1018 | 997 | } |
1019 | 998 | |
1020 | - intel_hdmi->sdvox_reg = sdvox_reg; | |
1021 | - | |
1022 | 999 | if (!HAS_PCH_SPLIT(dev)) { |
1023 | 1000 | intel_hdmi->write_infoframe = g4x_write_infoframe; |
1024 | 1001 | intel_hdmi->set_infoframes = g4x_set_infoframes; |
... | ... | @@ -1036,6 +1013,45 @@ |
1036 | 1013 | intel_hdmi->set_infoframes = cpt_set_infoframes; |
1037 | 1014 | } |
1038 | 1015 | |
1016 | + intel_connector->get_hw_state = intel_connector_get_hw_state; | |
1017 | + | |
1018 | + intel_hdmi_add_properties(intel_hdmi, connector); | |
1019 | + | |
1020 | + intel_connector_attach_encoder(intel_connector, intel_encoder); | |
1021 | + drm_sysfs_connector_add(connector); | |
1022 | + | |
1023 | + /* For G4X desktop chip, PEG_BAND_GAP_DATA 3:0 must first be written | |
1024 | + * 0xd. Failure to do so will result in spurious interrupts being | |
1025 | + * generated on the port when a cable is not attached. | |
1026 | + */ | |
1027 | + if (IS_G4X(dev) && !IS_GM45(dev)) { | |
1028 | + u32 temp = I915_READ(PEG_BAND_GAP_DATA); | |
1029 | + I915_WRITE(PEG_BAND_GAP_DATA, (temp & ~0xf) | 0xd); | |
1030 | + } | |
1031 | +} | |
1032 | + | |
1033 | +void intel_hdmi_init(struct drm_device *dev, int sdvox_reg, enum port port) | |
1034 | +{ | |
1035 | + struct intel_digital_port *intel_dig_port; | |
1036 | + struct intel_encoder *intel_encoder; | |
1037 | + struct drm_encoder *encoder; | |
1038 | + struct intel_connector *intel_connector; | |
1039 | + | |
1040 | + intel_dig_port = kzalloc(sizeof(struct intel_digital_port), GFP_KERNEL); | |
1041 | + if (!intel_dig_port) | |
1042 | + return; | |
1043 | + | |
1044 | + intel_connector = kzalloc(sizeof(struct intel_connector), GFP_KERNEL); | |
1045 | + if (!intel_connector) { | |
1046 | + kfree(intel_dig_port); | |
1047 | + return; | |
1048 | + } | |
1049 | + | |
1050 | + intel_encoder = &intel_dig_port->base; | |
1051 | + encoder = &intel_encoder->base; | |
1052 | + | |
1053 | + drm_encoder_init(dev, &intel_encoder->base, &intel_hdmi_enc_funcs, | |
1054 | + DRM_MODE_ENCODER_TMDS); | |
1039 | 1055 | if (IS_HASWELL(dev)) { |
1040 | 1056 | intel_encoder->pre_enable = intel_ddi_pre_enable; |
1041 | 1057 | intel_encoder->enable = intel_enable_ddi; |
1042 | 1058 | |
1043 | 1059 | |
1044 | 1060 | |
... | ... | @@ -1051,21 +1067,15 @@ |
1051 | 1067 | drm_encoder_helper_add(&intel_encoder->base, |
1052 | 1068 | &intel_hdmi_helper_funcs); |
1053 | 1069 | } |
1054 | - intel_connector->get_hw_state = intel_connector_get_hw_state; | |
1055 | 1070 | |
1071 | + intel_encoder->type = INTEL_OUTPUT_HDMI; | |
1072 | + intel_encoder->crtc_mask = (1 << 0) | (1 << 1) | (1 << 2); | |
1073 | + intel_encoder->cloneable = false; | |
1056 | 1074 | |
1057 | - intel_hdmi_add_properties(intel_hdmi, connector); | |
1075 | + intel_dig_port->hdmi.ddi_port = port; | |
1076 | + intel_dig_port->hdmi.sdvox_reg = sdvox_reg; | |
1077 | + intel_dig_port->dp.output_reg = 0; | |
1058 | 1078 | |
1059 | - intel_connector_attach_encoder(intel_connector, intel_encoder); | |
1060 | - drm_sysfs_connector_add(connector); | |
1061 | - | |
1062 | - /* For G4X desktop chip, PEG_BAND_GAP_DATA 3:0 must first be written | |
1063 | - * 0xd. Failure to do so will result in spurious interrupts being | |
1064 | - * generated on the port when a cable is not attached. | |
1065 | - */ | |
1066 | - if (IS_G4X(dev) && !IS_GM45(dev)) { | |
1067 | - u32 temp = I915_READ(PEG_BAND_GAP_DATA); | |
1068 | - I915_WRITE(PEG_BAND_GAP_DATA, (temp & ~0xf) | 0xd); | |
1069 | - } | |
1079 | + intel_hdmi_init_connector(intel_dig_port, intel_connector); | |
1070 | 1080 | } |