blob: 1b72aa42c2f9e46691c9e0ad908c57fe89dd3950 [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;
Chris Wilsone953fd72011-02-21 22:23:52 +000044 uint32_t color_range;
Ma Ling9dff6af2009-04-02 13:13:26 +080045 bool has_hdmi_sink;
Zhenyu Wang2e3d6002010-09-10 10:39:40 +080046 bool has_audio;
Chris Wilson55b7d6e82010-09-19 09:29:33 +010047 int force_audio;
Eric Anholt7d573822009-01-02 13:33:00 -080048};
49
Chris Wilsonea5b2132010-08-04 13:50:23 +010050static struct intel_hdmi *enc_to_intel_hdmi(struct drm_encoder *encoder)
51{
Chris Wilson4ef69c72010-09-09 15:14:28 +010052 return container_of(encoder, struct intel_hdmi, base.base);
Chris Wilsonea5b2132010-08-04 13:50:23 +010053}
54
Chris Wilsondf0e9242010-09-09 16:20:55 +010055static struct intel_hdmi *intel_attached_hdmi(struct drm_connector *connector)
56{
57 return container_of(intel_attached_encoder(connector),
58 struct intel_hdmi, base);
59}
60
David Härdeman3c17fe42010-09-24 21:44:32 +020061void intel_dip_infoframe_csum(struct dip_infoframe *avi_if)
62{
63 uint8_t *data = (uint8_t *)avi_if;
64 uint8_t sum = 0;
65 unsigned i;
66
67 avi_if->checksum = 0;
68 avi_if->ecc = 0;
69
70 for (i = 0; i < sizeof(*avi_if); i++)
71 sum += data[i];
72
73 avi_if->checksum = 0x100 - sum;
74}
75
76static void intel_hdmi_set_avi_infoframe(struct drm_encoder *encoder)
77{
78 struct dip_infoframe avi_if = {
79 .type = DIP_TYPE_AVI,
80 .ver = DIP_VERSION_AVI,
81 .len = DIP_LEN_AVI,
82 };
83 uint32_t *data = (uint32_t *)&avi_if;
84 struct drm_device *dev = encoder->dev;
85 struct drm_i915_private *dev_priv = dev->dev_private;
86 struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder);
87 u32 port;
88 unsigned i;
89
90 if (!intel_hdmi->has_hdmi_sink)
91 return;
92
93 /* XXX first guess at handling video port, is this corrent? */
94 if (intel_hdmi->sdvox_reg == SDVOB)
95 port = VIDEO_DIP_PORT_B;
96 else if (intel_hdmi->sdvox_reg == SDVOC)
97 port = VIDEO_DIP_PORT_C;
98 else
99 return;
100
101 I915_WRITE(VIDEO_DIP_CTL, VIDEO_DIP_ENABLE | port |
102 VIDEO_DIP_SELECT_AVI | VIDEO_DIP_FREQ_VSYNC);
103
104 intel_dip_infoframe_csum(&avi_if);
105 for (i = 0; i < sizeof(avi_if); i += 4) {
106 I915_WRITE(VIDEO_DIP_DATA, *data);
107 data++;
108 }
109
110 I915_WRITE(VIDEO_DIP_CTL, VIDEO_DIP_ENABLE | port |
111 VIDEO_DIP_SELECT_AVI | VIDEO_DIP_FREQ_VSYNC |
112 VIDEO_DIP_ENABLE_AVI);
113}
114
Eric Anholt7d573822009-01-02 13:33:00 -0800115static void intel_hdmi_mode_set(struct drm_encoder *encoder,
116 struct drm_display_mode *mode,
117 struct drm_display_mode *adjusted_mode)
118{
119 struct drm_device *dev = encoder->dev;
120 struct drm_i915_private *dev_priv = dev->dev_private;
121 struct drm_crtc *crtc = encoder->crtc;
122 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
Chris Wilsonea5b2132010-08-04 13:50:23 +0100123 struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder);
Eric Anholt7d573822009-01-02 13:33:00 -0800124 u32 sdvox;
125
Adam Jacksonb599c0b2010-07-16 14:46:31 -0400126 sdvox = SDVO_ENCODING_HDMI | SDVO_BORDER_ENABLE;
Jesse Barnes5d4fac92011-06-24 12:19:19 -0700127 if (!HAS_PCH_SPLIT(dev))
128 sdvox |= intel_hdmi->color_range;
Adam Jacksonb599c0b2010-07-16 14:46:31 -0400129 if (adjusted_mode->flags & DRM_MODE_FLAG_PVSYNC)
130 sdvox |= SDVO_VSYNC_ACTIVE_HIGH;
131 if (adjusted_mode->flags & DRM_MODE_FLAG_PHSYNC)
132 sdvox |= SDVO_HSYNC_ACTIVE_HIGH;
Eric Anholt7d573822009-01-02 13:33:00 -0800133
Zhenyu Wang2e3d6002010-09-10 10:39:40 +0800134 /* Required on CPT */
135 if (intel_hdmi->has_hdmi_sink && HAS_PCH_CPT(dev))
136 sdvox |= HDMI_MODE_SELECT;
137
David Härdeman3c17fe42010-09-24 21:44:32 +0200138 if (intel_hdmi->has_audio) {
Eric Anholt7d573822009-01-02 13:33:00 -0800139 sdvox |= SDVO_AUDIO_ENABLE;
David Härdeman3c17fe42010-09-24 21:44:32 +0200140 sdvox |= SDVO_NULL_PACKETS_DURING_VSYNC;
141 }
Eric Anholt7d573822009-01-02 13:33:00 -0800142
Zhenyu Wang0f229062010-04-07 16:15:57 +0800143 if (intel_crtc->pipe == 1) {
144 if (HAS_PCH_CPT(dev))
145 sdvox |= PORT_TRANS_B_SEL_CPT;
146 else
147 sdvox |= SDVO_PIPE_B_SELECT;
148 }
Eric Anholt7d573822009-01-02 13:33:00 -0800149
Chris Wilsonea5b2132010-08-04 13:50:23 +0100150 I915_WRITE(intel_hdmi->sdvox_reg, sdvox);
151 POSTING_READ(intel_hdmi->sdvox_reg);
David Härdeman3c17fe42010-09-24 21:44:32 +0200152
153 intel_hdmi_set_avi_infoframe(encoder);
Eric Anholt7d573822009-01-02 13:33:00 -0800154}
155
156static void intel_hdmi_dpms(struct drm_encoder *encoder, int mode)
157{
158 struct drm_device *dev = encoder->dev;
159 struct drm_i915_private *dev_priv = dev->dev_private;
Chris Wilsonea5b2132010-08-04 13:50:23 +0100160 struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder);
Eric Anholt7d573822009-01-02 13:33:00 -0800161 u32 temp;
162
Chris Wilsonea5b2132010-08-04 13:50:23 +0100163 temp = I915_READ(intel_hdmi->sdvox_reg);
Zhenyu Wangd8a2d0e2009-11-02 07:52:30 +0000164
165 /* HW workaround, need to toggle enable bit off and on for 12bpc, but
166 * we do this anyway which shows more stable in testing.
167 */
Eric Anholtc619eed2010-01-28 16:45:52 -0800168 if (HAS_PCH_SPLIT(dev)) {
Chris Wilsonea5b2132010-08-04 13:50:23 +0100169 I915_WRITE(intel_hdmi->sdvox_reg, temp & ~SDVO_ENABLE);
170 POSTING_READ(intel_hdmi->sdvox_reg);
Eric Anholt7d573822009-01-02 13:33:00 -0800171 }
Zhenyu Wangd8a2d0e2009-11-02 07:52:30 +0000172
173 if (mode != DRM_MODE_DPMS_ON) {
174 temp &= ~SDVO_ENABLE;
175 } else {
176 temp |= SDVO_ENABLE;
177 }
178
Chris Wilsonea5b2132010-08-04 13:50:23 +0100179 I915_WRITE(intel_hdmi->sdvox_reg, temp);
180 POSTING_READ(intel_hdmi->sdvox_reg);
Zhenyu Wangd8a2d0e2009-11-02 07:52:30 +0000181
182 /* HW workaround, need to write this twice for issue that may result
183 * in first write getting masked.
184 */
Eric Anholtc619eed2010-01-28 16:45:52 -0800185 if (HAS_PCH_SPLIT(dev)) {
Chris Wilsonea5b2132010-08-04 13:50:23 +0100186 I915_WRITE(intel_hdmi->sdvox_reg, temp);
187 POSTING_READ(intel_hdmi->sdvox_reg);
Zhenyu Wangd8a2d0e2009-11-02 07:52:30 +0000188 }
Eric Anholt7d573822009-01-02 13:33:00 -0800189}
190
Eric Anholt7d573822009-01-02 13:33:00 -0800191static int intel_hdmi_mode_valid(struct drm_connector *connector,
192 struct drm_display_mode *mode)
193{
194 if (mode->clock > 165000)
195 return MODE_CLOCK_HIGH;
196 if (mode->clock < 20000)
Nicolas Kaiser5cbba412011-05-30 12:48:26 +0200197 return MODE_CLOCK_LOW;
Eric Anholt7d573822009-01-02 13:33:00 -0800198
199 if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
200 return MODE_NO_DBLESCAN;
201
202 return MODE_OK;
203}
204
205static bool intel_hdmi_mode_fixup(struct drm_encoder *encoder,
206 struct drm_display_mode *mode,
207 struct drm_display_mode *adjusted_mode)
208{
209 return true;
210}
211
Keith Packardaa93d632009-05-05 09:52:46 -0700212static enum drm_connector_status
Chris Wilson930a9e22010-09-14 11:07:23 +0100213intel_hdmi_detect(struct drm_connector *connector, bool force)
Ma Ling9dff6af2009-04-02 13:13:26 +0800214{
Chris Wilsondf0e9242010-09-09 16:20:55 +0100215 struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector);
Chris Wilsonf899fc62010-07-20 15:44:45 -0700216 struct drm_i915_private *dev_priv = connector->dev->dev_private;
217 struct edid *edid;
Keith Packardaa93d632009-05-05 09:52:46 -0700218 enum drm_connector_status status = connector_status_disconnected;
Ma Ling9dff6af2009-04-02 13:13:26 +0800219
Chris Wilsonea5b2132010-08-04 13:50:23 +0100220 intel_hdmi->has_hdmi_sink = false;
Zhenyu Wang2e3d6002010-09-10 10:39:40 +0800221 intel_hdmi->has_audio = false;
Chris Wilsonf899fc62010-07-20 15:44:45 -0700222 edid = drm_get_edid(connector,
223 &dev_priv->gmbus[intel_hdmi->ddc_bus].adapter);
ling.ma@intel.com2ded9e22009-07-16 17:23:09 +0800224
Keith Packardaa93d632009-05-05 09:52:46 -0700225 if (edid) {
Eric Anholtbe9f1c42009-06-21 22:14:55 -0700226 if (edid->input & DRM_EDID_INPUT_DIGITAL) {
Keith Packardaa93d632009-05-05 09:52:46 -0700227 status = connector_status_connected;
Chris Wilsonea5b2132010-08-04 13:50:23 +0100228 intel_hdmi->has_hdmi_sink = drm_detect_hdmi_monitor(edid);
Zhenyu Wang2e3d6002010-09-10 10:39:40 +0800229 intel_hdmi->has_audio = drm_detect_monitor_audio(edid);
Keith Packardaa93d632009-05-05 09:52:46 -0700230 }
Zhenyu Wang674e2d02010-03-29 15:57:42 +0800231 connector->display_info.raw_edid = NULL;
Keith Packardaa93d632009-05-05 09:52:46 -0700232 kfree(edid);
Ma Ling9dff6af2009-04-02 13:13:26 +0800233 }
ling.ma@intel.com2ded9e22009-07-16 17:23:09 +0800234
Chris Wilson55b7d6e82010-09-19 09:29:33 +0100235 if (status == connector_status_connected) {
236 if (intel_hdmi->force_audio)
237 intel_hdmi->has_audio = intel_hdmi->force_audio > 0;
238 }
239
Keith Packardaa93d632009-05-05 09:52:46 -0700240 return status;
Ma Ling9dff6af2009-04-02 13:13:26 +0800241}
242
Eric Anholt7d573822009-01-02 13:33:00 -0800243static int intel_hdmi_get_modes(struct drm_connector *connector)
244{
Chris Wilsondf0e9242010-09-09 16:20:55 +0100245 struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector);
Chris Wilsonf899fc62010-07-20 15:44:45 -0700246 struct drm_i915_private *dev_priv = connector->dev->dev_private;
Eric Anholt7d573822009-01-02 13:33:00 -0800247
248 /* We should parse the EDID data and find out if it's an HDMI sink so
249 * we can send audio to it.
250 */
251
Chris Wilsonf899fc62010-07-20 15:44:45 -0700252 return intel_ddc_get_modes(connector,
253 &dev_priv->gmbus[intel_hdmi->ddc_bus].adapter);
Eric Anholt7d573822009-01-02 13:33:00 -0800254}
255
Chris Wilson1aad7ac2011-02-09 18:46:58 +0000256static bool
257intel_hdmi_detect_audio(struct drm_connector *connector)
258{
259 struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector);
260 struct drm_i915_private *dev_priv = connector->dev->dev_private;
261 struct edid *edid;
262 bool has_audio = false;
263
264 edid = drm_get_edid(connector,
265 &dev_priv->gmbus[intel_hdmi->ddc_bus].adapter);
266 if (edid) {
267 if (edid->input & DRM_EDID_INPUT_DIGITAL)
268 has_audio = drm_detect_monitor_audio(edid);
269
270 connector->display_info.raw_edid = NULL;
271 kfree(edid);
272 }
273
274 return has_audio;
275}
276
Chris Wilson55b7d6e82010-09-19 09:29:33 +0100277static int
278intel_hdmi_set_property(struct drm_connector *connector,
279 struct drm_property *property,
280 uint64_t val)
281{
282 struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector);
Chris Wilsone953fd72011-02-21 22:23:52 +0000283 struct drm_i915_private *dev_priv = connector->dev->dev_private;
Chris Wilson55b7d6e82010-09-19 09:29:33 +0100284 int ret;
285
286 ret = drm_connector_property_set_value(connector, property, val);
287 if (ret)
288 return ret;
289
Chris Wilson3f43c482011-05-12 22:17:24 +0100290 if (property == dev_priv->force_audio_property) {
Chris Wilson1aad7ac2011-02-09 18:46:58 +0000291 int i = val;
292 bool has_audio;
293
294 if (i == intel_hdmi->force_audio)
Chris Wilson55b7d6e82010-09-19 09:29:33 +0100295 return 0;
296
Chris Wilson1aad7ac2011-02-09 18:46:58 +0000297 intel_hdmi->force_audio = i;
Chris Wilson55b7d6e82010-09-19 09:29:33 +0100298
Chris Wilson1aad7ac2011-02-09 18:46:58 +0000299 if (i == 0)
300 has_audio = intel_hdmi_detect_audio(connector);
301 else
302 has_audio = i > 0;
303
304 if (has_audio == intel_hdmi->has_audio)
Chris Wilson55b7d6e82010-09-19 09:29:33 +0100305 return 0;
306
Chris Wilson1aad7ac2011-02-09 18:46:58 +0000307 intel_hdmi->has_audio = has_audio;
Chris Wilson55b7d6e82010-09-19 09:29:33 +0100308 goto done;
309 }
310
Chris Wilsone953fd72011-02-21 22:23:52 +0000311 if (property == dev_priv->broadcast_rgb_property) {
312 if (val == !!intel_hdmi->color_range)
313 return 0;
314
315 intel_hdmi->color_range = val ? SDVO_COLOR_RANGE_16_235 : 0;
316 goto done;
317 }
318
Chris Wilson55b7d6e82010-09-19 09:29:33 +0100319 return -EINVAL;
320
321done:
322 if (intel_hdmi->base.base.crtc) {
323 struct drm_crtc *crtc = intel_hdmi->base.base.crtc;
324 drm_crtc_helper_set_mode(crtc, &crtc->mode,
325 crtc->x, crtc->y,
326 crtc->fb);
327 }
328
329 return 0;
330}
331
Eric Anholt7d573822009-01-02 13:33:00 -0800332static void intel_hdmi_destroy(struct drm_connector *connector)
333{
Eric Anholt7d573822009-01-02 13:33:00 -0800334 drm_sysfs_connector_remove(connector);
335 drm_connector_cleanup(connector);
Zhenyu Wang674e2d02010-03-29 15:57:42 +0800336 kfree(connector);
Eric Anholt7d573822009-01-02 13:33:00 -0800337}
338
339static const struct drm_encoder_helper_funcs intel_hdmi_helper_funcs = {
340 .dpms = intel_hdmi_dpms,
341 .mode_fixup = intel_hdmi_mode_fixup,
342 .prepare = intel_encoder_prepare,
343 .mode_set = intel_hdmi_mode_set,
344 .commit = intel_encoder_commit,
345};
346
347static const struct drm_connector_funcs intel_hdmi_connector_funcs = {
Keith Packardc9fb15f2009-05-30 20:42:28 -0700348 .dpms = drm_helper_connector_dpms,
Eric Anholt7d573822009-01-02 13:33:00 -0800349 .detect = intel_hdmi_detect,
350 .fill_modes = drm_helper_probe_single_connector_modes,
Chris Wilson55b7d6e82010-09-19 09:29:33 +0100351 .set_property = intel_hdmi_set_property,
Eric Anholt7d573822009-01-02 13:33:00 -0800352 .destroy = intel_hdmi_destroy,
353};
354
355static const struct drm_connector_helper_funcs intel_hdmi_connector_helper_funcs = {
356 .get_modes = intel_hdmi_get_modes,
357 .mode_valid = intel_hdmi_mode_valid,
Chris Wilsondf0e9242010-09-09 16:20:55 +0100358 .best_encoder = intel_best_encoder,
Eric Anholt7d573822009-01-02 13:33:00 -0800359};
360
Eric Anholt7d573822009-01-02 13:33:00 -0800361static const struct drm_encoder_funcs intel_hdmi_enc_funcs = {
Chris Wilsonea5b2132010-08-04 13:50:23 +0100362 .destroy = intel_encoder_destroy,
Eric Anholt7d573822009-01-02 13:33:00 -0800363};
364
Chris Wilson55b7d6e82010-09-19 09:29:33 +0100365static void
366intel_hdmi_add_properties(struct intel_hdmi *intel_hdmi, struct drm_connector *connector)
367{
Chris Wilson3f43c482011-05-12 22:17:24 +0100368 intel_attach_force_audio_property(connector);
Chris Wilsone953fd72011-02-21 22:23:52 +0000369 intel_attach_broadcast_rgb_property(connector);
Chris Wilson55b7d6e82010-09-19 09:29:33 +0100370}
371
Eric Anholt7d573822009-01-02 13:33:00 -0800372void intel_hdmi_init(struct drm_device *dev, int sdvox_reg)
373{
374 struct drm_i915_private *dev_priv = dev->dev_private;
375 struct drm_connector *connector;
Eric Anholt21d40d32010-03-25 11:11:14 -0700376 struct intel_encoder *intel_encoder;
Zhenyu Wang674e2d02010-03-29 15:57:42 +0800377 struct intel_connector *intel_connector;
Chris Wilsonea5b2132010-08-04 13:50:23 +0100378 struct intel_hdmi *intel_hdmi;
Eric Anholt7d573822009-01-02 13:33:00 -0800379
Chris Wilsonea5b2132010-08-04 13:50:23 +0100380 intel_hdmi = kzalloc(sizeof(struct intel_hdmi), GFP_KERNEL);
381 if (!intel_hdmi)
Eric Anholt7d573822009-01-02 13:33:00 -0800382 return;
Zhenyu Wang674e2d02010-03-29 15:57:42 +0800383
384 intel_connector = kzalloc(sizeof(struct intel_connector), GFP_KERNEL);
385 if (!intel_connector) {
Chris Wilsonea5b2132010-08-04 13:50:23 +0100386 kfree(intel_hdmi);
Zhenyu Wang674e2d02010-03-29 15:57:42 +0800387 return;
388 }
389
Chris Wilsonea5b2132010-08-04 13:50:23 +0100390 intel_encoder = &intel_hdmi->base;
Chris Wilson373a3cf2010-09-15 12:03:59 +0100391 drm_encoder_init(dev, &intel_encoder->base, &intel_hdmi_enc_funcs,
392 DRM_MODE_ENCODER_TMDS);
393
Zhenyu Wang674e2d02010-03-29 15:57:42 +0800394 connector = &intel_connector->base;
Eric Anholt7d573822009-01-02 13:33:00 -0800395 drm_connector_init(dev, connector, &intel_hdmi_connector_funcs,
Adam Jackson8d911042009-09-23 15:08:29 -0400396 DRM_MODE_CONNECTOR_HDMIA);
Eric Anholt7d573822009-01-02 13:33:00 -0800397 drm_connector_helper_add(connector, &intel_hdmi_connector_helper_funcs);
398
Eric Anholt21d40d32010-03-25 11:11:14 -0700399 intel_encoder->type = INTEL_OUTPUT_HDMI;
Eric Anholt7d573822009-01-02 13:33:00 -0800400
Dave Airlieeb1f8e42010-05-07 06:42:51 +0000401 connector->polled = DRM_CONNECTOR_POLL_HPD;
Eric Anholt7d573822009-01-02 13:33:00 -0800402 connector->interlace_allowed = 0;
403 connector->doublescan_allowed = 0;
Eric Anholt21d40d32010-03-25 11:11:14 -0700404 intel_encoder->crtc_mask = (1 << 0) | (1 << 1);
Eric Anholt7d573822009-01-02 13:33:00 -0800405
406 /* Set up the DDC bus. */
Ma Lingf8aed702009-08-24 13:50:24 +0800407 if (sdvox_reg == SDVOB) {
Eric Anholt21d40d32010-03-25 11:11:14 -0700408 intel_encoder->clone_mask = (1 << INTEL_HDMIB_CLONE_BIT);
Chris Wilsonf899fc62010-07-20 15:44:45 -0700409 intel_hdmi->ddc_bus = GMBUS_PORT_DPB;
Jesse Barnesb01f2c32009-12-11 11:07:17 -0800410 dev_priv->hotplug_supported_mask |= HDMIB_HOTPLUG_INT_STATUS;
Ma Lingf8aed702009-08-24 13:50:24 +0800411 } else if (sdvox_reg == SDVOC) {
Eric Anholt21d40d32010-03-25 11:11:14 -0700412 intel_encoder->clone_mask = (1 << INTEL_HDMIC_CLONE_BIT);
Chris Wilsonf899fc62010-07-20 15:44:45 -0700413 intel_hdmi->ddc_bus = GMBUS_PORT_DPC;
Jesse Barnesb01f2c32009-12-11 11:07:17 -0800414 dev_priv->hotplug_supported_mask |= HDMIC_HOTPLUG_INT_STATUS;
Ma Lingf8aed702009-08-24 13:50:24 +0800415 } else if (sdvox_reg == HDMIB) {
Eric Anholt21d40d32010-03-25 11:11:14 -0700416 intel_encoder->clone_mask = (1 << INTEL_HDMID_CLONE_BIT);
Chris Wilsonf899fc62010-07-20 15:44:45 -0700417 intel_hdmi->ddc_bus = GMBUS_PORT_DPB;
Jesse Barnesb01f2c32009-12-11 11:07:17 -0800418 dev_priv->hotplug_supported_mask |= HDMIB_HOTPLUG_INT_STATUS;
Ma Lingf8aed702009-08-24 13:50:24 +0800419 } else if (sdvox_reg == HDMIC) {
Eric Anholt21d40d32010-03-25 11:11:14 -0700420 intel_encoder->clone_mask = (1 << INTEL_HDMIE_CLONE_BIT);
Chris Wilsonf899fc62010-07-20 15:44:45 -0700421 intel_hdmi->ddc_bus = GMBUS_PORT_DPC;
Jesse Barnesb01f2c32009-12-11 11:07:17 -0800422 dev_priv->hotplug_supported_mask |= HDMIC_HOTPLUG_INT_STATUS;
Ma Lingf8aed702009-08-24 13:50:24 +0800423 } else if (sdvox_reg == HDMID) {
Eric Anholt21d40d32010-03-25 11:11:14 -0700424 intel_encoder->clone_mask = (1 << INTEL_HDMIF_CLONE_BIT);
Chris Wilsonf899fc62010-07-20 15:44:45 -0700425 intel_hdmi->ddc_bus = GMBUS_PORT_DPD;
Jesse Barnesb01f2c32009-12-11 11:07:17 -0800426 dev_priv->hotplug_supported_mask |= HDMID_HOTPLUG_INT_STATUS;
Ma Lingf8aed702009-08-24 13:50:24 +0800427 }
Eric Anholt7d573822009-01-02 13:33:00 -0800428
Chris Wilsonea5b2132010-08-04 13:50:23 +0100429 intel_hdmi->sdvox_reg = sdvox_reg;
Eric Anholt7d573822009-01-02 13:33:00 -0800430
Chris Wilson4ef69c72010-09-09 15:14:28 +0100431 drm_encoder_helper_add(&intel_encoder->base, &intel_hdmi_helper_funcs);
Eric Anholt7d573822009-01-02 13:33:00 -0800432
Chris Wilson55b7d6e82010-09-19 09:29:33 +0100433 intel_hdmi_add_properties(intel_hdmi, connector);
434
Chris Wilsondf0e9242010-09-09 16:20:55 +0100435 intel_connector_attach_encoder(intel_connector, intel_encoder);
Eric Anholt7d573822009-01-02 13:33:00 -0800436 drm_sysfs_connector_add(connector);
437
438 /* For G4X desktop chip, PEG_BAND_GAP_DATA 3:0 must first be written
439 * 0xd. Failure to do so will result in spurious interrupts being
440 * generated on the port when a cable is not attached.
441 */
442 if (IS_G4X(dev) && !IS_GM45(dev)) {
443 u32 temp = I915_READ(PEG_BAND_GAP_DATA);
444 I915_WRITE(PEG_BAND_GAP_DATA, (temp & ~0xf) | 0xd);
445 }
Eric Anholt7d573822009-01-02 13:33:00 -0800446}