29 #include <linux/i2c.h>
30 #include <linux/slab.h>
36 #include <drm/i915_drm.h>
49 "HDMI port enabled, expecting disabled\n");
60 struct intel_hdmi,
base);
80 switch (frame->
type) {
86 DRM_DEBUG_DRIVER(
"unknown info frame type %d\n", frame->
type);
93 switch (frame->
type) {
99 DRM_DEBUG_DRIVER(
"unknown info frame type %d\n", frame->
type);
106 switch (frame->
type) {
112 DRM_DEBUG_DRIVER(
"unknown info frame type %d\n", frame->
type);
119 switch (frame->
type) {
125 DRM_DEBUG_DRIVER(
"unknown info frame type %d\n", frame->
type);
130 static void g4x_write_infoframe(
struct drm_encoder *encoder,
142 val |= g4x_infoframe_index(frame);
144 val &= ~g4x_infoframe_enable(frame);
149 for (i = 0; i < len; i += 4) {
158 val |= g4x_infoframe_enable(frame);
166 static void ibx_write_infoframe(
struct drm_encoder *encoder,
180 val |= g4x_infoframe_index(frame);
182 val &= ~g4x_infoframe_enable(frame);
187 for (i = 0; i < len; i += 4) {
196 val |= g4x_infoframe_enable(frame);
204 static void cpt_write_infoframe(
struct drm_encoder *encoder,
218 val |= g4x_infoframe_index(frame);
223 val &= ~g4x_infoframe_enable(frame);
228 for (i = 0; i < len; i += 4) {
237 val |= g4x_infoframe_enable(frame);
245 static void vlv_write_infoframe(
struct drm_encoder *encoder,
259 val |= g4x_infoframe_index(frame);
261 val &= ~g4x_infoframe_enable(frame);
266 for (i = 0; i < len; i += 4) {
275 val |= g4x_infoframe_enable(frame);
283 static void hsw_write_infoframe(
struct drm_encoder *encoder,
291 u32 data_reg = hsw_infoframe_data_reg(frame, intel_crtc->
pipe);
298 val &= ~hsw_infoframe_enable(frame);
302 for (i = 0; i < len; i += 4) {
311 val |= hsw_infoframe_enable(frame);
316 static void intel_set_infoframe(
struct drm_encoder *encoder,
325 static void intel_hdmi_set_avi_infoframe(
struct drm_encoder *encoder,
337 intel_set_infoframe(encoder, &avi_if);
340 static void intel_hdmi_set_spd_infoframe(
struct drm_encoder *encoder)
344 memset(&spd_if, 0,
sizeof(spd_if));
348 strcpy(spd_if.body.spd.vn,
"Intel");
349 strcpy(spd_if.body.spd.pd,
"Integrated gfx");
352 intel_set_infoframe(encoder, &spd_if);
355 static void g4x_set_infoframes(
struct drm_encoder *encoder,
364 assert_hdmi_port_disabled(intel_hdmi);
380 val &= ~VIDEO_DIP_ENABLE;
400 val &= ~VIDEO_DIP_ENABLE;
404 val &= ~VIDEO_DIP_PORT_MASK;
414 intel_hdmi_set_avi_infoframe(encoder, adjusted_mode);
415 intel_hdmi_set_spd_infoframe(encoder);
418 static void ibx_set_infoframes(
struct drm_encoder *encoder,
428 assert_hdmi_port_disabled(intel_hdmi);
436 val &= ~VIDEO_DIP_ENABLE;
457 if (port != (val & VIDEO_DIP_PORT_MASK)) {
459 val &= ~VIDEO_DIP_ENABLE;
463 val &= ~VIDEO_DIP_PORT_MASK;
474 intel_hdmi_set_avi_infoframe(encoder, adjusted_mode);
475 intel_hdmi_set_spd_infoframe(encoder);
478 static void cpt_set_infoframes(
struct drm_encoder *encoder,
487 assert_hdmi_port_disabled(intel_hdmi);
509 intel_hdmi_set_avi_infoframe(encoder, adjusted_mode);
510 intel_hdmi_set_spd_infoframe(encoder);
513 static void vlv_set_infoframes(
struct drm_encoder *encoder,
522 assert_hdmi_port_disabled(intel_hdmi);
530 val &= ~VIDEO_DIP_ENABLE;
543 intel_hdmi_set_avi_infoframe(encoder, adjusted_mode);
544 intel_hdmi_set_spd_infoframe(encoder);
547 static void hsw_set_infoframes(
struct drm_encoder *encoder,
556 assert_hdmi_port_disabled(intel_hdmi);
570 intel_hdmi_set_avi_infoframe(encoder, adjusted_mode);
571 intel_hdmi_set_spd_infoframe(encoder);
574 static void intel_hdmi_mode_set(
struct drm_encoder *encoder,
592 if (intel_crtc->
bpp > 24)
602 DRM_DEBUG_DRIVER(
"Enabling HDMI audio on pipe %c\n",
620 static bool intel_hdmi_get_hw_state(
struct intel_encoder *encoder,
687 static void intel_disable_hdmi(
struct intel_encoder *encoder)
704 temp &= ~SDVO_PIPE_B_SELECT;
729 temp &= ~enable_bits;
743 static int intel_hdmi_mode_valid(
struct drm_connector *connector,
746 if (mode->
clock > 165000)
748 if (mode->
clock < 20000)
757 static bool intel_hdmi_mode_fixup(
struct drm_encoder *encoder,
764 static bool g4x_hdmi_connected(
struct intel_hdmi *intel_hdmi)
788 struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector);
793 if (
IS_G4X(connector->
dev) && !g4x_hdmi_connected(intel_hdmi))
822 static int intel_hdmi_get_modes(
struct drm_connector *connector)
824 struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector);
839 struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector);
842 bool has_audio =
false;
861 struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector);
879 has_audio = intel_hdmi_detect_audio(connector);
901 if (intel_hdmi->
base.base.crtc) {
904 crtc->
x, crtc->
y, crtc->
fb);
910 static void intel_hdmi_destroy(
struct drm_connector *connector)
918 .mode_fixup = intel_hdmi_mode_fixup,
924 .mode_fixup = intel_hdmi_mode_fixup,
925 .mode_set = intel_hdmi_mode_set,
931 .detect = intel_hdmi_detect,
933 .set_property = intel_hdmi_set_property,
934 .destroy = intel_hdmi_destroy,
938 .get_modes = intel_hdmi_get_modes,
939 .mode_valid = intel_hdmi_mode_valid,
948 intel_hdmi_add_properties(
struct intel_hdmi *intel_hdmi,
struct drm_connector *connector)
960 struct intel_hdmi *intel_hdmi;
962 intel_hdmi = kzalloc(
sizeof(
struct intel_hdmi),
GFP_KERNEL);
966 intel_connector = kzalloc(
sizeof(
struct intel_connector),
GFP_KERNEL);
967 if (!intel_connector) {
972 intel_encoder = &intel_hdmi->
base;
976 connector = &intel_connector->
base;
979 drm_connector_helper_add(connector, &intel_hdmi_connector_helper_funcs);
986 intel_encoder->
crtc_mask = (1 << 0) | (1 << 1) | (1 << 2);
1033 drm_encoder_helper_add(&intel_encoder->
base,
1034 &intel_hdmi_helper_funcs_hsw);
1036 intel_encoder->
enable = intel_enable_hdmi;
1037 intel_encoder->
disable = intel_disable_hdmi;
1039 drm_encoder_helper_add(&intel_encoder->
base,
1040 &intel_hdmi_helper_funcs);
1045 intel_hdmi_add_properties(intel_hdmi, connector);