blob: 3b0cf719725461e794501f86e50da177bfca59b6 [file] [log] [blame]
Eric Anholt7d573822009-01-02 13:33:00 -08001/*
2 * Copyright 2006 Dave Airlie <airlied@linux.ie>
3 * Copyright © 2006-2009 Intel Corporation
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
14 * Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 *
24 * Authors:
25 * Eric Anholt <eric@anholt.net>
26 * Jesse Barnes <jesse.barnes@intel.com>
27 */
28
29#include <linux/i2c.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090030#include <linux/slab.h>
Eric Anholt7d573822009-01-02 13:33:00 -080031#include <linux/delay.h>
32#include "drmP.h"
33#include "drm.h"
34#include "drm_crtc.h"
Keith Packardaa93d632009-05-05 09:52:46 -070035#include "drm_edid.h"
Eric Anholt7d573822009-01-02 13:33:00 -080036#include "intel_drv.h"
37#include "i915_drm.h"
38#include "i915_drv.h"
39
Chris Wilsonea5b2132010-08-04 13:50:23 +010040struct intel_hdmi {
41 struct intel_encoder base;
Eric Anholt7d573822009-01-02 13:33:00 -080042 u32 sdvox_reg;
Chris Wilsonf899fc62010-07-20 15:44:45 -070043 int ddc_bus;
Eugeni Dodonov7ceae0a2012-05-09 15:37:28 -030044 int ddi_port;
Chris Wilsone953fd72011-02-21 22:23:52 +000045 uint32_t color_range;
Ma Ling9dff6af2009-04-02 13:13:26 +080046 bool has_hdmi_sink;
Zhenyu Wang2e3d6002010-09-10 10:39:40 +080047 bool has_audio;
Wu Fengguangb1d7e4b2012-02-14 11:45:36 +080048 enum hdmi_force_audio force_audio;
Jesse Barnes45187ac2011-08-03 09:22:55 -070049 void (*write_infoframe)(struct drm_encoder *encoder,
50 struct dip_infoframe *frame);
Eric Anholt7d573822009-01-02 13:33:00 -080051};
52
Chris Wilsonea5b2132010-08-04 13:50:23 +010053static struct intel_hdmi *enc_to_intel_hdmi(struct drm_encoder *encoder)
54{
Chris Wilson4ef69c72010-09-09 15:14:28 +010055 return container_of(encoder, struct intel_hdmi, base.base);
Chris Wilsonea5b2132010-08-04 13:50:23 +010056}
57
Chris Wilsondf0e9242010-09-09 16:20:55 +010058static struct intel_hdmi *intel_attached_hdmi(struct drm_connector *connector)
59{
60 return container_of(intel_attached_encoder(connector),
61 struct intel_hdmi, base);
62}
63
Jesse Barnes45187ac2011-08-03 09:22:55 -070064void intel_dip_infoframe_csum(struct dip_infoframe *frame)
David Härdeman3c17fe42010-09-24 21:44:32 +020065{
Jesse Barnes45187ac2011-08-03 09:22:55 -070066 uint8_t *data = (uint8_t *)frame;
David Härdeman3c17fe42010-09-24 21:44:32 +020067 uint8_t sum = 0;
68 unsigned i;
69
Jesse Barnes45187ac2011-08-03 09:22:55 -070070 frame->checksum = 0;
71 frame->ecc = 0;
David Härdeman3c17fe42010-09-24 21:44:32 +020072
Jesse Barnes64a8fc02011-09-22 11:16:00 +053073 for (i = 0; i < frame->len + DIP_HEADER_SIZE; i++)
David Härdeman3c17fe42010-09-24 21:44:32 +020074 sum += data[i];
75
Jesse Barnes45187ac2011-08-03 09:22:55 -070076 frame->checksum = 0x100 - sum;
David Härdeman3c17fe42010-09-24 21:44:32 +020077}
78
Daniel Vetterbc2481f2012-05-08 15:18:32 +020079static u32 g4x_infoframe_index(struct dip_infoframe *frame)
David Härdeman3c17fe42010-09-24 21:44:32 +020080{
Jesse Barnes45187ac2011-08-03 09:22:55 -070081 u32 flags = 0;
82
83 switch (frame->type) {
84 case DIP_TYPE_AVI:
85 flags |= VIDEO_DIP_SELECT_AVI;
86 break;
87 case DIP_TYPE_SPD:
88 flags |= VIDEO_DIP_SELECT_SPD;
89 break;
90 default:
91 DRM_DEBUG_DRIVER("unknown info frame type %d\n", frame->type);
92 break;
93 }
94
95 return flags;
96}
97
Daniel Vetterbc2481f2012-05-08 15:18:32 +020098static u32 g4x_infoframe_enable(struct dip_infoframe *frame)
Jesse Barnes45187ac2011-08-03 09:22:55 -070099{
100 u32 flags = 0;
101
102 switch (frame->type) {
103 case DIP_TYPE_AVI:
Paulo Zanonifa193ff2012-05-04 17:18:20 -0300104 flags |= VIDEO_DIP_ENABLE_AVI;
Jesse Barnes45187ac2011-08-03 09:22:55 -0700105 break;
106 case DIP_TYPE_SPD:
Paulo Zanonifa193ff2012-05-04 17:18:20 -0300107 flags |= VIDEO_DIP_ENABLE_SPD;
108 break;
109 default:
110 DRM_DEBUG_DRIVER("unknown info frame type %d\n", frame->type);
111 break;
112 }
113
114 return flags;
115}
116
Daniel Vettera3da1df2012-05-08 15:19:06 +0200117static void g4x_write_infoframe(struct drm_encoder *encoder,
118 struct dip_infoframe *frame)
Jesse Barnes45187ac2011-08-03 09:22:55 -0700119{
120 uint32_t *data = (uint32_t *)frame;
David Härdeman3c17fe42010-09-24 21:44:32 +0200121 struct drm_device *dev = encoder->dev;
122 struct drm_i915_private *dev_priv = dev->dev_private;
123 struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder);
Paulo Zanoni22509ec2012-05-04 17:18:17 -0300124 u32 val = I915_READ(VIDEO_DIP_CTL);
Jesse Barnes45187ac2011-08-03 09:22:55 -0700125 unsigned i, len = DIP_HEADER_SIZE + frame->len;
David Härdeman3c17fe42010-09-24 21:44:32 +0200126
David Härdeman3c17fe42010-09-24 21:44:32 +0200127
128 /* XXX first guess at handling video port, is this corrent? */
Paulo Zanoni3e6e6392012-05-04 17:18:19 -0300129 val &= ~VIDEO_DIP_PORT_MASK;
David Härdeman3c17fe42010-09-24 21:44:32 +0200130 if (intel_hdmi->sdvox_reg == SDVOB)
Paulo Zanoni22509ec2012-05-04 17:18:17 -0300131 val |= VIDEO_DIP_PORT_B;
David Härdeman3c17fe42010-09-24 21:44:32 +0200132 else if (intel_hdmi->sdvox_reg == SDVOC)
Paulo Zanoni22509ec2012-05-04 17:18:17 -0300133 val |= VIDEO_DIP_PORT_C;
David Härdeman3c17fe42010-09-24 21:44:32 +0200134 else
135 return;
136
Paulo Zanoni1d4f85a2012-05-04 17:18:18 -0300137 val &= ~(VIDEO_DIP_SELECT_MASK | 0xf); /* clear DIP data offset */
Daniel Vetterbc2481f2012-05-08 15:18:32 +0200138 val |= g4x_infoframe_index(frame);
Jesse Barnes45187ac2011-08-03 09:22:55 -0700139
Daniel Vetterbc2481f2012-05-08 15:18:32 +0200140 val &= ~g4x_infoframe_enable(frame);
Paulo Zanoni22509ec2012-05-04 17:18:17 -0300141 val |= VIDEO_DIP_ENABLE;
142
143 I915_WRITE(VIDEO_DIP_CTL, val);
Jesse Barnes45187ac2011-08-03 09:22:55 -0700144
145 for (i = 0; i < len; i += 4) {
David Härdeman3c17fe42010-09-24 21:44:32 +0200146 I915_WRITE(VIDEO_DIP_DATA, *data);
147 data++;
148 }
149
Daniel Vetterbc2481f2012-05-08 15:18:32 +0200150 val |= g4x_infoframe_enable(frame);
Paulo Zanoni60c5ea22012-05-04 17:18:22 -0300151 val &= ~VIDEO_DIP_FREQ_MASK;
Daniel Vetter4b24c932012-05-08 14:41:00 +0200152 val |= VIDEO_DIP_FREQ_VSYNC;
Jesse Barnes45187ac2011-08-03 09:22:55 -0700153
Paulo Zanoni22509ec2012-05-04 17:18:17 -0300154 I915_WRITE(VIDEO_DIP_CTL, val);
David Härdeman3c17fe42010-09-24 21:44:32 +0200155}
156
Paulo Zanonifdf12502012-05-04 17:18:24 -0300157static void ibx_write_infoframe(struct drm_encoder *encoder,
158 struct dip_infoframe *frame)
159{
160 uint32_t *data = (uint32_t *)frame;
161 struct drm_device *dev = encoder->dev;
162 struct drm_i915_private *dev_priv = dev->dev_private;
163 struct drm_crtc *crtc = encoder->crtc;
164 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
Paulo Zanoni4e89ee12012-05-04 17:18:26 -0300165 struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder);
Paulo Zanonifdf12502012-05-04 17:18:24 -0300166 int reg = TVIDEO_DIP_CTL(intel_crtc->pipe);
167 unsigned i, len = DIP_HEADER_SIZE + frame->len;
168 u32 val = I915_READ(reg);
169
Paulo Zanoni4e89ee12012-05-04 17:18:26 -0300170 val &= ~VIDEO_DIP_PORT_MASK;
171 switch (intel_hdmi->sdvox_reg) {
172 case HDMIB:
173 val |= VIDEO_DIP_PORT_B;
174 break;
175 case HDMIC:
176 val |= VIDEO_DIP_PORT_C;
177 break;
178 case HDMID:
179 val |= VIDEO_DIP_PORT_D;
180 break;
181 default:
182 return;
183 }
184
Paulo Zanonifdf12502012-05-04 17:18:24 -0300185 intel_wait_for_vblank(dev, intel_crtc->pipe);
186
187 val &= ~(VIDEO_DIP_SELECT_MASK | 0xf); /* clear DIP data offset */
Daniel Vetterbc2481f2012-05-08 15:18:32 +0200188 val |= g4x_infoframe_index(frame);
Paulo Zanonifdf12502012-05-04 17:18:24 -0300189
Daniel Vetterbc2481f2012-05-08 15:18:32 +0200190 val &= ~g4x_infoframe_enable(frame);
Paulo Zanonifdf12502012-05-04 17:18:24 -0300191 val |= VIDEO_DIP_ENABLE;
192
193 I915_WRITE(reg, val);
194
195 for (i = 0; i < len; i += 4) {
196 I915_WRITE(TVIDEO_DIP_DATA(intel_crtc->pipe), *data);
197 data++;
198 }
199
Daniel Vetterbc2481f2012-05-08 15:18:32 +0200200 val |= g4x_infoframe_enable(frame);
Paulo Zanonifdf12502012-05-04 17:18:24 -0300201 val &= ~VIDEO_DIP_FREQ_MASK;
Daniel Vetter4b24c932012-05-08 14:41:00 +0200202 val |= VIDEO_DIP_FREQ_VSYNC;
Paulo Zanonifdf12502012-05-04 17:18:24 -0300203
204 I915_WRITE(reg, val);
205}
206
207static void cpt_write_infoframe(struct drm_encoder *encoder,
208 struct dip_infoframe *frame)
Jesse Barnes45187ac2011-08-03 09:22:55 -0700209{
210 uint32_t *data = (uint32_t *)frame;
211 struct drm_device *dev = encoder->dev;
212 struct drm_i915_private *dev_priv = dev->dev_private;
213 struct drm_crtc *crtc = encoder->crtc;
214 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
215 int reg = TVIDEO_DIP_CTL(intel_crtc->pipe);
216 unsigned i, len = DIP_HEADER_SIZE + frame->len;
Paulo Zanoni22509ec2012-05-04 17:18:17 -0300217 u32 val = I915_READ(reg);
Jesse Barnes45187ac2011-08-03 09:22:55 -0700218
219 intel_wait_for_vblank(dev, intel_crtc->pipe);
220
Jesse Barnes64a8fc02011-09-22 11:16:00 +0530221 val &= ~(VIDEO_DIP_SELECT_MASK | 0xf); /* clear DIP data offset */
Daniel Vetterbc2481f2012-05-08 15:18:32 +0200222 val |= g4x_infoframe_index(frame);
Jesse Barnes45187ac2011-08-03 09:22:55 -0700223
Paulo Zanoniecb97852012-05-04 17:18:21 -0300224 /* The DIP control register spec says that we need to update the AVI
225 * infoframe without clearing its enable bit */
226 if (frame->type == DIP_TYPE_AVI)
227 val |= VIDEO_DIP_ENABLE_AVI;
228 else
Daniel Vetterbc2481f2012-05-08 15:18:32 +0200229 val &= ~g4x_infoframe_enable(frame);
Paulo Zanoniecb97852012-05-04 17:18:21 -0300230
Paulo Zanoni22509ec2012-05-04 17:18:17 -0300231 val |= VIDEO_DIP_ENABLE;
232
233 I915_WRITE(reg, val);
Jesse Barnes45187ac2011-08-03 09:22:55 -0700234
235 for (i = 0; i < len; i += 4) {
236 I915_WRITE(TVIDEO_DIP_DATA(intel_crtc->pipe), *data);
237 data++;
238 }
239
Daniel Vetterbc2481f2012-05-08 15:18:32 +0200240 val |= g4x_infoframe_enable(frame);
Paulo Zanoni60c5ea22012-05-04 17:18:22 -0300241 val &= ~VIDEO_DIP_FREQ_MASK;
Daniel Vetter4b24c932012-05-08 14:41:00 +0200242 val |= VIDEO_DIP_FREQ_VSYNC;
Jesse Barnes45187ac2011-08-03 09:22:55 -0700243
Paulo Zanoni22509ec2012-05-04 17:18:17 -0300244 I915_WRITE(reg, val);
Jesse Barnes45187ac2011-08-03 09:22:55 -0700245}
Shobhit Kumar90b107c2012-03-28 13:39:32 -0700246
247static void vlv_write_infoframe(struct drm_encoder *encoder,
248 struct dip_infoframe *frame)
249{
250 uint32_t *data = (uint32_t *)frame;
251 struct drm_device *dev = encoder->dev;
252 struct drm_i915_private *dev_priv = dev->dev_private;
253 struct drm_crtc *crtc = encoder->crtc;
254 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
255 int reg = VLV_TVIDEO_DIP_CTL(intel_crtc->pipe);
256 unsigned i, len = DIP_HEADER_SIZE + frame->len;
Paulo Zanoni22509ec2012-05-04 17:18:17 -0300257 u32 val = I915_READ(reg);
Shobhit Kumar90b107c2012-03-28 13:39:32 -0700258
259 intel_wait_for_vblank(dev, intel_crtc->pipe);
260
Shobhit Kumar90b107c2012-03-28 13:39:32 -0700261 val &= ~(VIDEO_DIP_SELECT_MASK | 0xf); /* clear DIP data offset */
Daniel Vetterbc2481f2012-05-08 15:18:32 +0200262 val |= g4x_infoframe_index(frame);
Shobhit Kumar90b107c2012-03-28 13:39:32 -0700263
Daniel Vetterbc2481f2012-05-08 15:18:32 +0200264 val &= ~g4x_infoframe_enable(frame);
Paulo Zanoni22509ec2012-05-04 17:18:17 -0300265 val |= VIDEO_DIP_ENABLE;
266
267 I915_WRITE(reg, val);
Shobhit Kumar90b107c2012-03-28 13:39:32 -0700268
269 for (i = 0; i < len; i += 4) {
270 I915_WRITE(VLV_TVIDEO_DIP_DATA(intel_crtc->pipe), *data);
271 data++;
272 }
273
Daniel Vetterbc2481f2012-05-08 15:18:32 +0200274 val |= g4x_infoframe_enable(frame);
Paulo Zanoni60c5ea22012-05-04 17:18:22 -0300275 val &= ~VIDEO_DIP_FREQ_MASK;
Daniel Vetter4b24c932012-05-08 14:41:00 +0200276 val |= VIDEO_DIP_FREQ_VSYNC;
Shobhit Kumar90b107c2012-03-28 13:39:32 -0700277
Paulo Zanoni22509ec2012-05-04 17:18:17 -0300278 I915_WRITE(reg, val);
Shobhit Kumar90b107c2012-03-28 13:39:32 -0700279}
280
Eugeni Dodonov8c5f5f72012-05-10 10:18:02 -0300281static void hsw_write_infoframe(struct drm_encoder *encoder,
282 struct dip_infoframe *frame)
283{
284 /* Not implemented yet, so avoid doing anything at all.
285 * This is the placeholder for Paulo Zanoni's infoframe writing patch
286 */
287 DRM_DEBUG_DRIVER("Attempting to write infoframe on Haswell, this is not implemented yet.\n");
288
289 return;
290
291}
292
Jesse Barnes45187ac2011-08-03 09:22:55 -0700293static void intel_set_infoframe(struct drm_encoder *encoder,
294 struct dip_infoframe *frame)
295{
296 struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder);
297
298 if (!intel_hdmi->has_hdmi_sink)
299 return;
300
301 intel_dip_infoframe_csum(frame);
302 intel_hdmi->write_infoframe(encoder, frame);
303}
304
Paulo Zanonic846b612012-04-13 16:31:41 -0300305static void intel_hdmi_set_avi_infoframe(struct drm_encoder *encoder,
306 struct drm_display_mode *adjusted_mode)
Jesse Barnesb055c8f2011-07-08 11:31:57 -0700307{
308 struct dip_infoframe avi_if = {
309 .type = DIP_TYPE_AVI,
310 .ver = DIP_VERSION_AVI,
311 .len = DIP_LEN_AVI,
312 };
Jesse Barnesb055c8f2011-07-08 11:31:57 -0700313
Paulo Zanonic846b612012-04-13 16:31:41 -0300314 if (adjusted_mode->flags & DRM_MODE_FLAG_DBLCLK)
315 avi_if.body.avi.YQ_CN_PR |= DIP_AVI_PR_2;
316
Jesse Barnes45187ac2011-08-03 09:22:55 -0700317 intel_set_infoframe(encoder, &avi_if);
Jesse Barnesb055c8f2011-07-08 11:31:57 -0700318}
319
Jesse Barnesc0864cb2011-08-03 09:22:56 -0700320static void intel_hdmi_set_spd_infoframe(struct drm_encoder *encoder)
321{
322 struct dip_infoframe spd_if;
323
324 memset(&spd_if, 0, sizeof(spd_if));
325 spd_if.type = DIP_TYPE_SPD;
326 spd_if.ver = DIP_VERSION_SPD;
327 spd_if.len = DIP_LEN_SPD;
328 strcpy(spd_if.body.spd.vn, "Intel");
329 strcpy(spd_if.body.spd.pd, "Integrated gfx");
330 spd_if.body.spd.sdi = DIP_SPD_PC;
331
332 intel_set_infoframe(encoder, &spd_if);
333}
334
Eric Anholt7d573822009-01-02 13:33:00 -0800335static void intel_hdmi_mode_set(struct drm_encoder *encoder,
336 struct drm_display_mode *mode,
337 struct drm_display_mode *adjusted_mode)
338{
339 struct drm_device *dev = encoder->dev;
340 struct drm_i915_private *dev_priv = dev->dev_private;
341 struct drm_crtc *crtc = encoder->crtc;
342 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
Chris Wilsonea5b2132010-08-04 13:50:23 +0100343 struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder);
Eric Anholt7d573822009-01-02 13:33:00 -0800344 u32 sdvox;
345
Adam Jacksonb599c0b2010-07-16 14:46:31 -0400346 sdvox = SDVO_ENCODING_HDMI | SDVO_BORDER_ENABLE;
Jesse Barnes5d4fac92011-06-24 12:19:19 -0700347 if (!HAS_PCH_SPLIT(dev))
348 sdvox |= intel_hdmi->color_range;
Adam Jacksonb599c0b2010-07-16 14:46:31 -0400349 if (adjusted_mode->flags & DRM_MODE_FLAG_PVSYNC)
350 sdvox |= SDVO_VSYNC_ACTIVE_HIGH;
351 if (adjusted_mode->flags & DRM_MODE_FLAG_PHSYNC)
352 sdvox |= SDVO_HSYNC_ACTIVE_HIGH;
Eric Anholt7d573822009-01-02 13:33:00 -0800353
Jesse Barnes020f6702011-06-24 12:19:25 -0700354 if (intel_crtc->bpp > 24)
355 sdvox |= COLOR_FORMAT_12bpc;
356 else
357 sdvox |= COLOR_FORMAT_8bpc;
358
Zhenyu Wang2e3d6002010-09-10 10:39:40 +0800359 /* Required on CPT */
360 if (intel_hdmi->has_hdmi_sink && HAS_PCH_CPT(dev))
361 sdvox |= HDMI_MODE_SELECT;
362
David Härdeman3c17fe42010-09-24 21:44:32 +0200363 if (intel_hdmi->has_audio) {
Wu Fengguange0dac652011-09-05 14:25:34 +0800364 DRM_DEBUG_DRIVER("Enabling HDMI audio on pipe %c\n",
365 pipe_name(intel_crtc->pipe));
Eric Anholt7d573822009-01-02 13:33:00 -0800366 sdvox |= SDVO_AUDIO_ENABLE;
David Härdeman3c17fe42010-09-24 21:44:32 +0200367 sdvox |= SDVO_NULL_PACKETS_DURING_VSYNC;
Wu Fengguange0dac652011-09-05 14:25:34 +0800368 intel_write_eld(encoder, adjusted_mode);
David Härdeman3c17fe42010-09-24 21:44:32 +0200369 }
Eric Anholt7d573822009-01-02 13:33:00 -0800370
Jesse Barnes75770562011-10-12 09:01:58 -0700371 if (HAS_PCH_CPT(dev))
372 sdvox |= PORT_TRANS_SEL_CPT(intel_crtc->pipe);
373 else if (intel_crtc->pipe == 1)
374 sdvox |= SDVO_PIPE_B_SELECT;
Eric Anholt7d573822009-01-02 13:33:00 -0800375
Chris Wilsonea5b2132010-08-04 13:50:23 +0100376 I915_WRITE(intel_hdmi->sdvox_reg, sdvox);
377 POSTING_READ(intel_hdmi->sdvox_reg);
David Härdeman3c17fe42010-09-24 21:44:32 +0200378
Paulo Zanonic846b612012-04-13 16:31:41 -0300379 intel_hdmi_set_avi_infoframe(encoder, adjusted_mode);
Jesse Barnesc0864cb2011-08-03 09:22:56 -0700380 intel_hdmi_set_spd_infoframe(encoder);
Eric Anholt7d573822009-01-02 13:33:00 -0800381}
382
383static void intel_hdmi_dpms(struct drm_encoder *encoder, int mode)
384{
385 struct drm_device *dev = encoder->dev;
386 struct drm_i915_private *dev_priv = dev->dev_private;
Chris Wilsonea5b2132010-08-04 13:50:23 +0100387 struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder);
Eric Anholt7d573822009-01-02 13:33:00 -0800388 u32 temp;
Wu Fengguang2deed762011-12-09 20:42:20 +0800389 u32 enable_bits = SDVO_ENABLE;
390
391 if (intel_hdmi->has_audio)
392 enable_bits |= SDVO_AUDIO_ENABLE;
Eric Anholt7d573822009-01-02 13:33:00 -0800393
Chris Wilsonea5b2132010-08-04 13:50:23 +0100394 temp = I915_READ(intel_hdmi->sdvox_reg);
Zhenyu Wangd8a2d0e2009-11-02 07:52:30 +0000395
396 /* HW workaround, need to toggle enable bit off and on for 12bpc, but
397 * we do this anyway which shows more stable in testing.
398 */
Eric Anholtc619eed2010-01-28 16:45:52 -0800399 if (HAS_PCH_SPLIT(dev)) {
Chris Wilsonea5b2132010-08-04 13:50:23 +0100400 I915_WRITE(intel_hdmi->sdvox_reg, temp & ~SDVO_ENABLE);
401 POSTING_READ(intel_hdmi->sdvox_reg);
Eric Anholt7d573822009-01-02 13:33:00 -0800402 }
Zhenyu Wangd8a2d0e2009-11-02 07:52:30 +0000403
404 if (mode != DRM_MODE_DPMS_ON) {
Wu Fengguang2deed762011-12-09 20:42:20 +0800405 temp &= ~enable_bits;
Zhenyu Wangd8a2d0e2009-11-02 07:52:30 +0000406 } else {
Wu Fengguang2deed762011-12-09 20:42:20 +0800407 temp |= enable_bits;
Zhenyu Wangd8a2d0e2009-11-02 07:52:30 +0000408 }
409
Chris Wilsonea5b2132010-08-04 13:50:23 +0100410 I915_WRITE(intel_hdmi->sdvox_reg, temp);
411 POSTING_READ(intel_hdmi->sdvox_reg);
Zhenyu Wangd8a2d0e2009-11-02 07:52:30 +0000412
413 /* HW workaround, need to write this twice for issue that may result
414 * in first write getting masked.
415 */
Eric Anholtc619eed2010-01-28 16:45:52 -0800416 if (HAS_PCH_SPLIT(dev)) {
Chris Wilsonea5b2132010-08-04 13:50:23 +0100417 I915_WRITE(intel_hdmi->sdvox_reg, temp);
418 POSTING_READ(intel_hdmi->sdvox_reg);
Zhenyu Wangd8a2d0e2009-11-02 07:52:30 +0000419 }
Eric Anholt7d573822009-01-02 13:33:00 -0800420}
421
Eric Anholt7d573822009-01-02 13:33:00 -0800422static int intel_hdmi_mode_valid(struct drm_connector *connector,
423 struct drm_display_mode *mode)
424{
425 if (mode->clock > 165000)
426 return MODE_CLOCK_HIGH;
427 if (mode->clock < 20000)
Nicolas Kaiser5cbba412011-05-30 12:48:26 +0200428 return MODE_CLOCK_LOW;
Eric Anholt7d573822009-01-02 13:33:00 -0800429
430 if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
431 return MODE_NO_DBLESCAN;
432
433 return MODE_OK;
434}
435
436static bool intel_hdmi_mode_fixup(struct drm_encoder *encoder,
437 struct drm_display_mode *mode,
438 struct drm_display_mode *adjusted_mode)
439{
440 return true;
441}
442
Keith Packardaa93d632009-05-05 09:52:46 -0700443static enum drm_connector_status
Chris Wilson930a9e22010-09-14 11:07:23 +0100444intel_hdmi_detect(struct drm_connector *connector, bool force)
Ma Ling9dff6af2009-04-02 13:13:26 +0800445{
Chris Wilsondf0e9242010-09-09 16:20:55 +0100446 struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector);
Chris Wilsonf899fc62010-07-20 15:44:45 -0700447 struct drm_i915_private *dev_priv = connector->dev->dev_private;
448 struct edid *edid;
Keith Packardaa93d632009-05-05 09:52:46 -0700449 enum drm_connector_status status = connector_status_disconnected;
Ma Ling9dff6af2009-04-02 13:13:26 +0800450
Chris Wilsonea5b2132010-08-04 13:50:23 +0100451 intel_hdmi->has_hdmi_sink = false;
Zhenyu Wang2e3d6002010-09-10 10:39:40 +0800452 intel_hdmi->has_audio = false;
Chris Wilsonf899fc62010-07-20 15:44:45 -0700453 edid = drm_get_edid(connector,
Daniel Kurtz3bd7d902012-03-28 02:36:14 +0800454 intel_gmbus_get_adapter(dev_priv,
455 intel_hdmi->ddc_bus));
ling.ma@intel.com2ded9e22009-07-16 17:23:09 +0800456
Keith Packardaa93d632009-05-05 09:52:46 -0700457 if (edid) {
Eric Anholtbe9f1c42009-06-21 22:14:55 -0700458 if (edid->input & DRM_EDID_INPUT_DIGITAL) {
Keith Packardaa93d632009-05-05 09:52:46 -0700459 status = connector_status_connected;
Wu Fengguangb1d7e4b2012-02-14 11:45:36 +0800460 if (intel_hdmi->force_audio != HDMI_AUDIO_OFF_DVI)
461 intel_hdmi->has_hdmi_sink =
462 drm_detect_hdmi_monitor(edid);
Zhenyu Wang2e3d6002010-09-10 10:39:40 +0800463 intel_hdmi->has_audio = drm_detect_monitor_audio(edid);
Keith Packardaa93d632009-05-05 09:52:46 -0700464 }
Zhenyu Wang674e2d02010-03-29 15:57:42 +0800465 connector->display_info.raw_edid = NULL;
Keith Packardaa93d632009-05-05 09:52:46 -0700466 kfree(edid);
Ma Ling9dff6af2009-04-02 13:13:26 +0800467 }
ling.ma@intel.com2ded9e22009-07-16 17:23:09 +0800468
Chris Wilson55b7d6e82010-09-19 09:29:33 +0100469 if (status == connector_status_connected) {
Wu Fengguangb1d7e4b2012-02-14 11:45:36 +0800470 if (intel_hdmi->force_audio != HDMI_AUDIO_AUTO)
471 intel_hdmi->has_audio =
472 (intel_hdmi->force_audio == HDMI_AUDIO_ON);
Chris Wilson55b7d6e82010-09-19 09:29:33 +0100473 }
474
Keith Packardaa93d632009-05-05 09:52:46 -0700475 return status;
Ma Ling9dff6af2009-04-02 13:13:26 +0800476}
477
Eric Anholt7d573822009-01-02 13:33:00 -0800478static int intel_hdmi_get_modes(struct drm_connector *connector)
479{
Chris Wilsondf0e9242010-09-09 16:20:55 +0100480 struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector);
Chris Wilsonf899fc62010-07-20 15:44:45 -0700481 struct drm_i915_private *dev_priv = connector->dev->dev_private;
Eric Anholt7d573822009-01-02 13:33:00 -0800482
483 /* We should parse the EDID data and find out if it's an HDMI sink so
484 * we can send audio to it.
485 */
486
Chris Wilsonf899fc62010-07-20 15:44:45 -0700487 return intel_ddc_get_modes(connector,
Daniel Kurtz3bd7d902012-03-28 02:36:14 +0800488 intel_gmbus_get_adapter(dev_priv,
489 intel_hdmi->ddc_bus));
Eric Anholt7d573822009-01-02 13:33:00 -0800490}
491
Chris Wilson1aad7ac2011-02-09 18:46:58 +0000492static bool
493intel_hdmi_detect_audio(struct drm_connector *connector)
494{
495 struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector);
496 struct drm_i915_private *dev_priv = connector->dev->dev_private;
497 struct edid *edid;
498 bool has_audio = false;
499
500 edid = drm_get_edid(connector,
Daniel Kurtz3bd7d902012-03-28 02:36:14 +0800501 intel_gmbus_get_adapter(dev_priv,
502 intel_hdmi->ddc_bus));
Chris Wilson1aad7ac2011-02-09 18:46:58 +0000503 if (edid) {
504 if (edid->input & DRM_EDID_INPUT_DIGITAL)
505 has_audio = drm_detect_monitor_audio(edid);
506
507 connector->display_info.raw_edid = NULL;
508 kfree(edid);
509 }
510
511 return has_audio;
512}
513
Chris Wilson55b7d6e82010-09-19 09:29:33 +0100514static int
515intel_hdmi_set_property(struct drm_connector *connector,
516 struct drm_property *property,
517 uint64_t val)
518{
519 struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector);
Chris Wilsone953fd72011-02-21 22:23:52 +0000520 struct drm_i915_private *dev_priv = connector->dev->dev_private;
Chris Wilson55b7d6e82010-09-19 09:29:33 +0100521 int ret;
522
523 ret = drm_connector_property_set_value(connector, property, val);
524 if (ret)
525 return ret;
526
Chris Wilson3f43c482011-05-12 22:17:24 +0100527 if (property == dev_priv->force_audio_property) {
Wu Fengguangb1d7e4b2012-02-14 11:45:36 +0800528 enum hdmi_force_audio i = val;
Chris Wilson1aad7ac2011-02-09 18:46:58 +0000529 bool has_audio;
530
531 if (i == intel_hdmi->force_audio)
Chris Wilson55b7d6e82010-09-19 09:29:33 +0100532 return 0;
533
Chris Wilson1aad7ac2011-02-09 18:46:58 +0000534 intel_hdmi->force_audio = i;
Chris Wilson55b7d6e82010-09-19 09:29:33 +0100535
Wu Fengguangb1d7e4b2012-02-14 11:45:36 +0800536 if (i == HDMI_AUDIO_AUTO)
Chris Wilson1aad7ac2011-02-09 18:46:58 +0000537 has_audio = intel_hdmi_detect_audio(connector);
538 else
Wu Fengguangb1d7e4b2012-02-14 11:45:36 +0800539 has_audio = (i == HDMI_AUDIO_ON);
Chris Wilson1aad7ac2011-02-09 18:46:58 +0000540
Wu Fengguangb1d7e4b2012-02-14 11:45:36 +0800541 if (i == HDMI_AUDIO_OFF_DVI)
542 intel_hdmi->has_hdmi_sink = 0;
Chris Wilson55b7d6e82010-09-19 09:29:33 +0100543
Chris Wilson1aad7ac2011-02-09 18:46:58 +0000544 intel_hdmi->has_audio = has_audio;
Chris Wilson55b7d6e82010-09-19 09:29:33 +0100545 goto done;
546 }
547
Chris Wilsone953fd72011-02-21 22:23:52 +0000548 if (property == dev_priv->broadcast_rgb_property) {
549 if (val == !!intel_hdmi->color_range)
550 return 0;
551
552 intel_hdmi->color_range = val ? SDVO_COLOR_RANGE_16_235 : 0;
553 goto done;
554 }
555
Chris Wilson55b7d6e82010-09-19 09:29:33 +0100556 return -EINVAL;
557
558done:
559 if (intel_hdmi->base.base.crtc) {
560 struct drm_crtc *crtc = intel_hdmi->base.base.crtc;
561 drm_crtc_helper_set_mode(crtc, &crtc->mode,
562 crtc->x, crtc->y,
563 crtc->fb);
564 }
565
566 return 0;
567}
568
Eric Anholt7d573822009-01-02 13:33:00 -0800569static void intel_hdmi_destroy(struct drm_connector *connector)
570{
Eric Anholt7d573822009-01-02 13:33:00 -0800571 drm_sysfs_connector_remove(connector);
572 drm_connector_cleanup(connector);
Zhenyu Wang674e2d02010-03-29 15:57:42 +0800573 kfree(connector);
Eric Anholt7d573822009-01-02 13:33:00 -0800574}
575
576static const struct drm_encoder_helper_funcs intel_hdmi_helper_funcs = {
577 .dpms = intel_hdmi_dpms,
578 .mode_fixup = intel_hdmi_mode_fixup,
579 .prepare = intel_encoder_prepare,
580 .mode_set = intel_hdmi_mode_set,
581 .commit = intel_encoder_commit,
582};
583
584static const struct drm_connector_funcs intel_hdmi_connector_funcs = {
Keith Packardc9fb15f2009-05-30 20:42:28 -0700585 .dpms = drm_helper_connector_dpms,
Eric Anholt7d573822009-01-02 13:33:00 -0800586 .detect = intel_hdmi_detect,
587 .fill_modes = drm_helper_probe_single_connector_modes,
Chris Wilson55b7d6e82010-09-19 09:29:33 +0100588 .set_property = intel_hdmi_set_property,
Eric Anholt7d573822009-01-02 13:33:00 -0800589 .destroy = intel_hdmi_destroy,
590};
591
592static const struct drm_connector_helper_funcs intel_hdmi_connector_helper_funcs = {
593 .get_modes = intel_hdmi_get_modes,
594 .mode_valid = intel_hdmi_mode_valid,
Chris Wilsondf0e9242010-09-09 16:20:55 +0100595 .best_encoder = intel_best_encoder,
Eric Anholt7d573822009-01-02 13:33:00 -0800596};
597
Eric Anholt7d573822009-01-02 13:33:00 -0800598static const struct drm_encoder_funcs intel_hdmi_enc_funcs = {
Chris Wilsonea5b2132010-08-04 13:50:23 +0100599 .destroy = intel_encoder_destroy,
Eric Anholt7d573822009-01-02 13:33:00 -0800600};
601
Chris Wilson55b7d6e82010-09-19 09:29:33 +0100602static void
603intel_hdmi_add_properties(struct intel_hdmi *intel_hdmi, struct drm_connector *connector)
604{
Chris Wilson3f43c482011-05-12 22:17:24 +0100605 intel_attach_force_audio_property(connector);
Chris Wilsone953fd72011-02-21 22:23:52 +0000606 intel_attach_broadcast_rgb_property(connector);
Chris Wilson55b7d6e82010-09-19 09:29:33 +0100607}
608
Eric Anholt7d573822009-01-02 13:33:00 -0800609void intel_hdmi_init(struct drm_device *dev, int sdvox_reg)
610{
611 struct drm_i915_private *dev_priv = dev->dev_private;
612 struct drm_connector *connector;
Eric Anholt21d40d32010-03-25 11:11:14 -0700613 struct intel_encoder *intel_encoder;
Zhenyu Wang674e2d02010-03-29 15:57:42 +0800614 struct intel_connector *intel_connector;
Chris Wilsonea5b2132010-08-04 13:50:23 +0100615 struct intel_hdmi *intel_hdmi;
Jesse Barnes64a8fc02011-09-22 11:16:00 +0530616 int i;
Eric Anholt7d573822009-01-02 13:33:00 -0800617
Chris Wilsonea5b2132010-08-04 13:50:23 +0100618 intel_hdmi = kzalloc(sizeof(struct intel_hdmi), GFP_KERNEL);
619 if (!intel_hdmi)
Eric Anholt7d573822009-01-02 13:33:00 -0800620 return;
Zhenyu Wang674e2d02010-03-29 15:57:42 +0800621
622 intel_connector = kzalloc(sizeof(struct intel_connector), GFP_KERNEL);
623 if (!intel_connector) {
Chris Wilsonea5b2132010-08-04 13:50:23 +0100624 kfree(intel_hdmi);
Zhenyu Wang674e2d02010-03-29 15:57:42 +0800625 return;
626 }
627
Chris Wilsonea5b2132010-08-04 13:50:23 +0100628 intel_encoder = &intel_hdmi->base;
Chris Wilson373a3cf2010-09-15 12:03:59 +0100629 drm_encoder_init(dev, &intel_encoder->base, &intel_hdmi_enc_funcs,
630 DRM_MODE_ENCODER_TMDS);
631
Zhenyu Wang674e2d02010-03-29 15:57:42 +0800632 connector = &intel_connector->base;
Eric Anholt7d573822009-01-02 13:33:00 -0800633 drm_connector_init(dev, connector, &intel_hdmi_connector_funcs,
Adam Jackson8d911042009-09-23 15:08:29 -0400634 DRM_MODE_CONNECTOR_HDMIA);
Eric Anholt7d573822009-01-02 13:33:00 -0800635 drm_connector_helper_add(connector, &intel_hdmi_connector_helper_funcs);
636
Eric Anholt21d40d32010-03-25 11:11:14 -0700637 intel_encoder->type = INTEL_OUTPUT_HDMI;
Eric Anholt7d573822009-01-02 13:33:00 -0800638
Dave Airlieeb1f8e42010-05-07 06:42:51 +0000639 connector->polled = DRM_CONNECTOR_POLL_HPD;
Peter Rossc3febcc2012-01-28 14:49:26 +0100640 connector->interlace_allowed = 1;
Eric Anholt7d573822009-01-02 13:33:00 -0800641 connector->doublescan_allowed = 0;
Jesse Barnes27f82272011-09-02 12:54:37 -0700642 intel_encoder->crtc_mask = (1 << 0) | (1 << 1) | (1 << 2);
Eric Anholt7d573822009-01-02 13:33:00 -0800643
644 /* Set up the DDC bus. */
Ma Lingf8aed702009-08-24 13:50:24 +0800645 if (sdvox_reg == SDVOB) {
Eric Anholt21d40d32010-03-25 11:11:14 -0700646 intel_encoder->clone_mask = (1 << INTEL_HDMIB_CLONE_BIT);
Chris Wilsonf899fc62010-07-20 15:44:45 -0700647 intel_hdmi->ddc_bus = GMBUS_PORT_DPB;
Jesse Barnesb01f2c32009-12-11 11:07:17 -0800648 dev_priv->hotplug_supported_mask |= HDMIB_HOTPLUG_INT_STATUS;
Ma Lingf8aed702009-08-24 13:50:24 +0800649 } else if (sdvox_reg == SDVOC) {
Eric Anholt21d40d32010-03-25 11:11:14 -0700650 intel_encoder->clone_mask = (1 << INTEL_HDMIC_CLONE_BIT);
Chris Wilsonf899fc62010-07-20 15:44:45 -0700651 intel_hdmi->ddc_bus = GMBUS_PORT_DPC;
Jesse Barnesb01f2c32009-12-11 11:07:17 -0800652 dev_priv->hotplug_supported_mask |= HDMIC_HOTPLUG_INT_STATUS;
Ma Lingf8aed702009-08-24 13:50:24 +0800653 } else if (sdvox_reg == HDMIB) {
Eric Anholt21d40d32010-03-25 11:11:14 -0700654 intel_encoder->clone_mask = (1 << INTEL_HDMID_CLONE_BIT);
Chris Wilsonf899fc62010-07-20 15:44:45 -0700655 intel_hdmi->ddc_bus = GMBUS_PORT_DPB;
Jesse Barnesb01f2c32009-12-11 11:07:17 -0800656 dev_priv->hotplug_supported_mask |= HDMIB_HOTPLUG_INT_STATUS;
Ma Lingf8aed702009-08-24 13:50:24 +0800657 } else if (sdvox_reg == HDMIC) {
Eric Anholt21d40d32010-03-25 11:11:14 -0700658 intel_encoder->clone_mask = (1 << INTEL_HDMIE_CLONE_BIT);
Chris Wilsonf899fc62010-07-20 15:44:45 -0700659 intel_hdmi->ddc_bus = GMBUS_PORT_DPC;
Jesse Barnesb01f2c32009-12-11 11:07:17 -0800660 dev_priv->hotplug_supported_mask |= HDMIC_HOTPLUG_INT_STATUS;
Ma Lingf8aed702009-08-24 13:50:24 +0800661 } else if (sdvox_reg == HDMID) {
Eric Anholt21d40d32010-03-25 11:11:14 -0700662 intel_encoder->clone_mask = (1 << INTEL_HDMIF_CLONE_BIT);
Chris Wilsonf899fc62010-07-20 15:44:45 -0700663 intel_hdmi->ddc_bus = GMBUS_PORT_DPD;
Jesse Barnesb01f2c32009-12-11 11:07:17 -0800664 dev_priv->hotplug_supported_mask |= HDMID_HOTPLUG_INT_STATUS;
Eugeni Dodonov7ceae0a2012-05-09 15:37:28 -0300665 } else if (sdvox_reg == DDI_BUF_CTL(PORT_B)) {
666 DRM_DEBUG_DRIVER("LPT: detected output on DDI B\n");
667 intel_encoder->clone_mask = (1 << INTEL_HDMIB_CLONE_BIT);
668 intel_hdmi->ddc_bus = GMBUS_PORT_DPB;
669 intel_hdmi->ddi_port = PORT_B;
670 dev_priv->hotplug_supported_mask |= HDMIB_HOTPLUG_INT_STATUS;
671 } else if (sdvox_reg == DDI_BUF_CTL(PORT_C)) {
672 DRM_DEBUG_DRIVER("LPT: detected output on DDI C\n");
673 intel_encoder->clone_mask = (1 << INTEL_HDMIC_CLONE_BIT);
674 intel_hdmi->ddc_bus = GMBUS_PORT_DPC;
675 intel_hdmi->ddi_port = PORT_C;
676 dev_priv->hotplug_supported_mask |= HDMIC_HOTPLUG_INT_STATUS;
677 } else if (sdvox_reg == DDI_BUF_CTL(PORT_D)) {
678 DRM_DEBUG_DRIVER("LPT: detected output on DDI D\n");
679 intel_encoder->clone_mask = (1 << INTEL_HDMID_CLONE_BIT);
680 intel_hdmi->ddc_bus = GMBUS_PORT_DPD;
681 intel_hdmi->ddi_port = PORT_D;
682 dev_priv->hotplug_supported_mask |= HDMID_HOTPLUG_INT_STATUS;
Eugeni Dodonov6e4c1672012-05-09 15:37:13 -0300683 } else {
684 /* If we got an unknown sdvox_reg, things are pretty much broken
685 * in a way that we should let the kernel know about it */
686 BUG();
Ma Lingf8aed702009-08-24 13:50:24 +0800687 }
Eric Anholt7d573822009-01-02 13:33:00 -0800688
Chris Wilsonea5b2132010-08-04 13:50:23 +0100689 intel_hdmi->sdvox_reg = sdvox_reg;
Eric Anholt7d573822009-01-02 13:33:00 -0800690
Jesse Barnes64a8fc02011-09-22 11:16:00 +0530691 if (!HAS_PCH_SPLIT(dev)) {
Daniel Vettera3da1df2012-05-08 15:19:06 +0200692 intel_hdmi->write_infoframe = g4x_write_infoframe;
Jesse Barnes64a8fc02011-09-22 11:16:00 +0530693 I915_WRITE(VIDEO_DIP_CTL, 0);
Shobhit Kumar90b107c2012-03-28 13:39:32 -0700694 } else if (IS_VALLEYVIEW(dev)) {
695 intel_hdmi->write_infoframe = vlv_write_infoframe;
696 for_each_pipe(i)
697 I915_WRITE(VLV_TVIDEO_DIP_CTL(i), 0);
Eugeni Dodonov8c5f5f72012-05-10 10:18:02 -0300698 } else if (IS_HASWELL(dev)) {
699 /* FIXME: Haswell has a new set of DIP frame registers, but we are
700 * just doing the minimal required for HDMI to work at this stage.
701 */
702 intel_hdmi->write_infoframe = hsw_write_infoframe;
703 for_each_pipe(i)
704 I915_WRITE(HSW_TVIDEO_DIP_CTL(i), 0);
Paulo Zanonifdf12502012-05-04 17:18:24 -0300705 } else if (HAS_PCH_IBX(dev)) {
706 intel_hdmi->write_infoframe = ibx_write_infoframe;
707 for_each_pipe(i)
708 I915_WRITE(TVIDEO_DIP_CTL(i), 0);
709 } else {
710 intel_hdmi->write_infoframe = cpt_write_infoframe;
Jesse Barnes64a8fc02011-09-22 11:16:00 +0530711 for_each_pipe(i)
712 I915_WRITE(TVIDEO_DIP_CTL(i), 0);
713 }
Jesse Barnes45187ac2011-08-03 09:22:55 -0700714
Chris Wilson4ef69c72010-09-09 15:14:28 +0100715 drm_encoder_helper_add(&intel_encoder->base, &intel_hdmi_helper_funcs);
Eric Anholt7d573822009-01-02 13:33:00 -0800716
Chris Wilson55b7d6e82010-09-19 09:29:33 +0100717 intel_hdmi_add_properties(intel_hdmi, connector);
718
Chris Wilsondf0e9242010-09-09 16:20:55 +0100719 intel_connector_attach_encoder(intel_connector, intel_encoder);
Eric Anholt7d573822009-01-02 13:33:00 -0800720 drm_sysfs_connector_add(connector);
721
722 /* For G4X desktop chip, PEG_BAND_GAP_DATA 3:0 must first be written
723 * 0xd. Failure to do so will result in spurious interrupts being
724 * generated on the port when a cable is not attached.
725 */
726 if (IS_G4X(dev) && !IS_GM45(dev)) {
727 u32 temp = I915_READ(PEG_BAND_GAP_DATA);
728 I915_WRITE(PEG_BAND_GAP_DATA, (temp & ~0xf) | 0xd);
729 }
Eric Anholt7d573822009-01-02 13:33:00 -0800730}