intel_crt.c 31.8 KB
Newer Older
J
Jesse Barnes 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
/*
 * Copyright © 2006-2007 Intel Corporation
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice (including the next
 * paragraph) shall be included in all copies or substantial portions of the
 * Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 *
 * Authors:
 *	Eric Anholt <eric@anholt.net>
 */

27
#include <linux/dmi.h>
J
Jesse Barnes 已提交
28
#include <linux/i2c.h>
29
#include <linux/slab.h>
30

31
#include <drm/drm_atomic_helper.h>
32 33
#include <drm/drm_crtc.h>
#include <drm/drm_edid.h>
34
#include <drm/drm_probe_helper.h>
35

J
Jesse Barnes 已提交
36
#include "i915_drv.h"
37
#include "intel_connector.h"
38
#include "intel_crt.h"
39
#include "intel_crtc.h"
40
#include "intel_ddi.h"
41
#include "intel_ddi_buf_trans.h"
42
#include "intel_de.h"
43
#include "intel_display_types.h"
44
#include "intel_fdi.h"
45
#include "intel_fifo_underrun.h"
46
#include "intel_gmbus.h"
47
#include "intel_hotplug.h"
48
#include "intel_pch_display.h"
49
#include "intel_pch_refclk.h"
J
Jesse Barnes 已提交
50

51 52 53 54 55 56 57 58
/* Here's the desired hotplug mode */
#define ADPA_HOTPLUG_BITS (ADPA_CRT_HOTPLUG_PERIOD_128 |		\
			   ADPA_CRT_HOTPLUG_WARMUP_10MS |		\
			   ADPA_CRT_HOTPLUG_SAMPLE_4S |			\
			   ADPA_CRT_HOTPLUG_VOLTAGE_50 |		\
			   ADPA_CRT_HOTPLUG_VOLREF_325MV |		\
			   ADPA_CRT_HOTPLUG_ENABLE)

59 60
struct intel_crt {
	struct intel_encoder base;
61 62 63
	/* DPMS state is stored in the connector, which we need in the
	 * encoder's enable/disable callbacks */
	struct intel_connector *connector;
64
	bool force_hotplug_required;
65
	i915_reg_t adpa_reg;
66 67
};

68
static struct intel_crt *intel_encoder_to_crt(struct intel_encoder *encoder)
69
{
70
	return container_of(encoder, struct intel_crt, base);
71 72
}

73
static struct intel_crt *intel_attached_crt(struct intel_connector *connector)
J
Jesse Barnes 已提交
74
{
75
	return intel_encoder_to_crt(intel_attached_encoder(connector));
D
Daniel Vetter 已提交
76 77
}

78 79 80 81 82
bool intel_crt_port_enabled(struct drm_i915_private *dev_priv,
			    i915_reg_t adpa_reg, enum pipe *pipe)
{
	u32 val;

83
	val = intel_de_read(dev_priv, adpa_reg);
84 85 86 87 88 89 90 91 92 93

	/* asserts want to know the pipe even if the port is disabled */
	if (HAS_PCH_CPT(dev_priv))
		*pipe = (val & ADPA_PIPE_SEL_MASK_CPT) >> ADPA_PIPE_SEL_SHIFT_CPT;
	else
		*pipe = (val & ADPA_PIPE_SEL_MASK) >> ADPA_PIPE_SEL_SHIFT;

	return val & ADPA_DAC_ENABLE;
}

94 95
static bool intel_crt_get_hw_state(struct intel_encoder *encoder,
				   enum pipe *pipe)
J
Jesse Barnes 已提交
96
{
97
	struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
98
	struct intel_crt *crt = intel_encoder_to_crt(encoder);
99
	intel_wakeref_t wakeref;
100
	bool ret;
101

102 103 104
	wakeref = intel_display_power_get_if_enabled(dev_priv,
						     encoder->power_domain);
	if (!wakeref)
105 106
		return false;

107
	ret = intel_crt_port_enabled(dev_priv, crt->adpa_reg, pipe);
108

109
	intel_display_power_put(dev_priv, encoder->power_domain, wakeref);
110 111

	return ret;
112 113
}

114
static unsigned int intel_crt_get_flags(struct intel_encoder *encoder)
115
{
116
	struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
117 118 119
	struct intel_crt *crt = intel_encoder_to_crt(encoder);
	u32 tmp, flags = 0;

120
	tmp = intel_de_read(dev_priv, crt->adpa_reg);
121 122 123 124 125 126 127 128 129 130 131

	if (tmp & ADPA_HSYNC_ACTIVE_HIGH)
		flags |= DRM_MODE_FLAG_PHSYNC;
	else
		flags |= DRM_MODE_FLAG_NHSYNC;

	if (tmp & ADPA_VSYNC_ACTIVE_HIGH)
		flags |= DRM_MODE_FLAG_PVSYNC;
	else
		flags |= DRM_MODE_FLAG_NVSYNC;

132 133 134 135
	return flags;
}

static void intel_crt_get_config(struct intel_encoder *encoder,
136
				 struct intel_crtc_state *pipe_config)
137
{
138 139
	pipe_config->output_types |= BIT(INTEL_OUTPUT_ANALOG);

140
	pipe_config->hw.adjusted_mode.flags |= intel_crt_get_flags(encoder);
141

142
	pipe_config->hw.adjusted_mode.crtc_clock = pipe_config->port_clock;
143 144
}

145
static void hsw_crt_get_config(struct intel_encoder *encoder,
146
			       struct intel_crtc_state *pipe_config)
147
{
148 149
	lpt_pch_get_config(pipe_config);

150
	hsw_ddi_get_config(encoder, pipe_config);
151

152
	pipe_config->hw.adjusted_mode.flags &= ~(DRM_MODE_FLAG_PHSYNC |
153 154 155
					      DRM_MODE_FLAG_NHSYNC |
					      DRM_MODE_FLAG_PVSYNC |
					      DRM_MODE_FLAG_NVSYNC);
156
	pipe_config->hw.adjusted_mode.flags |= intel_crt_get_flags(encoder);
157 158
}

159 160
/* Note: The caller is required to filter out dpms modes not supported by the
 * platform. */
161
static void intel_crt_set_dpms(struct intel_encoder *encoder,
162
			       const struct intel_crtc_state *crtc_state,
163
			       int mode)
164
{
165
	struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
166
	struct intel_crt *crt = intel_encoder_to_crt(encoder);
167
	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
168
	const struct drm_display_mode *adjusted_mode = &crtc_state->hw.adjusted_mode;
169 170
	u32 adpa;

171
	if (DISPLAY_VER(dev_priv) >= 5)
172 173 174
		adpa = ADPA_HOTPLUG_BITS;
	else
		adpa = 0;
175

176 177 178 179 180 181
	if (adjusted_mode->flags & DRM_MODE_FLAG_PHSYNC)
		adpa |= ADPA_HSYNC_ACTIVE_HIGH;
	if (adjusted_mode->flags & DRM_MODE_FLAG_PVSYNC)
		adpa |= ADPA_VSYNC_ACTIVE_HIGH;

	/* For CPT allow 3 pipe config, for others just use A or B */
182
	if (HAS_PCH_LPT(dev_priv))
183
		; /* Those bits don't exist here */
184
	else if (HAS_PCH_CPT(dev_priv))
185
		adpa |= ADPA_PIPE_SEL_CPT(crtc->pipe);
186
	else
187
		adpa |= ADPA_PIPE_SEL(crtc->pipe);
188

189
	if (!HAS_PCH_SPLIT(dev_priv))
190
		intel_de_write(dev_priv, BCLRPAT(crtc->pipe), 0);
J
Jesse Barnes 已提交
191

192
	switch (mode) {
J
Jesse Barnes 已提交
193
	case DRM_MODE_DPMS_ON:
194
		adpa |= ADPA_DAC_ENABLE;
J
Jesse Barnes 已提交
195 196
		break;
	case DRM_MODE_DPMS_STANDBY:
197
		adpa |= ADPA_DAC_ENABLE | ADPA_HSYNC_CNTL_DISABLE;
J
Jesse Barnes 已提交
198 199
		break;
	case DRM_MODE_DPMS_SUSPEND:
200
		adpa |= ADPA_DAC_ENABLE | ADPA_VSYNC_CNTL_DISABLE;
J
Jesse Barnes 已提交
201 202
		break;
	case DRM_MODE_DPMS_OFF:
203
		adpa |= ADPA_HSYNC_CNTL_DISABLE | ADPA_VSYNC_CNTL_DISABLE;
J
Jesse Barnes 已提交
204 205 206
		break;
	}

207
	intel_de_write(dev_priv, crt->adpa_reg, adpa);
208
}
209

210 211
static void intel_disable_crt(struct intel_atomic_state *state,
			      struct intel_encoder *encoder,
212 213
			      const struct intel_crtc_state *old_crtc_state,
			      const struct drm_connector_state *old_conn_state)
214
{
215
	intel_crt_set_dpms(encoder, old_crtc_state, DRM_MODE_DPMS_OFF);
216 217
}

218 219
static void pch_disable_crt(struct intel_atomic_state *state,
			    struct intel_encoder *encoder,
220 221
			    const struct intel_crtc_state *old_crtc_state,
			    const struct drm_connector_state *old_conn_state)
222 223 224
{
}

225 226
static void pch_post_disable_crt(struct intel_atomic_state *state,
				 struct intel_encoder *encoder,
227 228
				 const struct intel_crtc_state *old_crtc_state,
				 const struct drm_connector_state *old_conn_state)
229
{
230
	intel_disable_crt(state, encoder, old_crtc_state, old_conn_state);
231
}
232

233 234
static void hsw_disable_crt(struct intel_atomic_state *state,
			    struct intel_encoder *encoder,
235 236 237
			    const struct intel_crtc_state *old_crtc_state,
			    const struct drm_connector_state *old_conn_state)
{
238
	struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
239

240
	drm_WARN_ON(&dev_priv->drm, !old_crtc_state->has_pch_encoder);
241 242 243 244

	intel_set_pch_fifo_underrun_reporting(dev_priv, PIPE_A, false);
}

245 246
static void hsw_post_disable_crt(struct intel_atomic_state *state,
				 struct intel_encoder *encoder,
247 248
				 const struct intel_crtc_state *old_crtc_state,
				 const struct drm_connector_state *old_conn_state)
249 250 251
{
	struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);

252 253
	intel_crtc_vblank_off(old_crtc_state);

254
	intel_disable_transcoder(old_crtc_state);
255 256 257

	intel_ddi_disable_transcoder_func(old_crtc_state);

258
	ilk_pfit_disable(old_crtc_state);
259

260 261
	intel_ddi_disable_pipe_clock(old_crtc_state);

262
	pch_post_disable_crt(state, encoder, old_crtc_state, old_conn_state);
263 264 265 266

	lpt_disable_pch_transcoder(dev_priv);
	lpt_disable_iclkip(dev_priv);

267
	intel_ddi_fdi_post_disable(state, encoder, old_crtc_state, old_conn_state);
268

269
	drm_WARN_ON(&dev_priv->drm, !old_crtc_state->has_pch_encoder);
270 271

	intel_set_pch_fifo_underrun_reporting(dev_priv, PIPE_A, true);
272 273
}

274 275
static void hsw_pre_pll_enable_crt(struct intel_atomic_state *state,
				   struct intel_encoder *encoder,
276
				   const struct intel_crtc_state *crtc_state,
277 278
				   const struct drm_connector_state *conn_state)
{
279
	struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
280

281
	drm_WARN_ON(&dev_priv->drm, !crtc_state->has_pch_encoder);
282 283 284 285

	intel_set_pch_fifo_underrun_reporting(dev_priv, PIPE_A, false);
}

286 287
static void hsw_pre_enable_crt(struct intel_atomic_state *state,
			       struct intel_encoder *encoder,
288
			       const struct intel_crtc_state *crtc_state,
289 290
			       const struct drm_connector_state *conn_state)
{
291
	struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
292
	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
293
	enum pipe pipe = crtc->pipe;
294

295
	drm_WARN_ON(&dev_priv->drm, !crtc_state->has_pch_encoder);
296 297

	intel_set_cpu_fifo_underrun_reporting(dev_priv, pipe, false);
298

299
	hsw_fdi_link_train(encoder, crtc_state);
300

301
	intel_ddi_enable_pipe_clock(encoder, crtc_state);
302 303
}

304 305
static void hsw_enable_crt(struct intel_atomic_state *state,
			   struct intel_encoder *encoder,
306
			   const struct intel_crtc_state *crtc_state,
307 308
			   const struct drm_connector_state *conn_state)
{
309
	struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
310
	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
311
	enum pipe pipe = crtc->pipe;
312

313
	drm_WARN_ON(&dev_priv->drm, !crtc_state->has_pch_encoder);
314

315
	intel_ddi_enable_transcoder_func(encoder, crtc_state);
316

317
	intel_enable_transcoder(crtc_state);
318

319
	lpt_pch_enable(state, crtc);
320 321 322

	intel_crtc_vblank_on(crtc_state);

323
	intel_crt_set_dpms(encoder, crtc_state, DRM_MODE_DPMS_ON);
324 325 326 327 328 329 330

	intel_wait_for_vblank(dev_priv, pipe);
	intel_wait_for_vblank(dev_priv, pipe);
	intel_set_cpu_fifo_underrun_reporting(dev_priv, pipe, true);
	intel_set_pch_fifo_underrun_reporting(dev_priv, PIPE_A, true);
}

331 332
static void intel_enable_crt(struct intel_atomic_state *state,
			     struct intel_encoder *encoder,
333
			     const struct intel_crtc_state *crtc_state,
334
			     const struct drm_connector_state *conn_state)
335
{
336
	intel_crt_set_dpms(encoder, crtc_state, DRM_MODE_DPMS_ON);
337 338
}

339 340 341
static enum drm_mode_status
intel_crt_mode_valid(struct drm_connector *connector,
		     struct drm_display_mode *mode)
J
Jesse Barnes 已提交
342
{
343
	struct drm_device *dev = connector->dev;
344 345
	struct drm_i915_private *dev_priv = to_i915(dev);
	int max_dotclk = dev_priv->max_dotclk_freq;
346
	int max_clock;
347

348 349 350
	if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
		return MODE_NO_DBLESCAN;

351 352 353
	if (mode->clock < 25000)
		return MODE_CLOCK_LOW;

354
	if (HAS_PCH_LPT(dev_priv))
355
		max_clock = 180000;
356
	else if (IS_VALLEYVIEW(dev_priv))
357 358 359 360 361
		/*
		 * 270 MHz due to current DPLL limits,
		 * DAC limit supposedly 355 MHz.
		 */
		max_clock = 270000;
362
	else if (IS_DISPLAY_VER(dev_priv, 3, 4))
363
		max_clock = 400000;
364 365
	else
		max_clock = 350000;
366 367
	if (mode->clock > max_clock)
		return MODE_CLOCK_HIGH;
J
Jesse Barnes 已提交
368

M
Mika Kahola 已提交
369 370 371
	if (mode->clock > max_dotclk)
		return MODE_CLOCK_HIGH;

372
	/* The FDI receiver on LPT only supports 8bpc and only has 2 lanes. */
373
	if (HAS_PCH_LPT(dev_priv) &&
374
	    ilk_get_lanes_required(mode->clock, 270000, 24) > 2)
375 376
		return MODE_CLOCK_HIGH;

377 378 379 380
	/* HSW/BDW FDI limited to 4k */
	if (mode->hdisplay > 4096)
		return MODE_H_ILLEGAL;

J
Jesse Barnes 已提交
381 382 383
	return MODE_OK;
}

384 385 386
static int intel_crt_compute_config(struct intel_encoder *encoder,
				    struct intel_crtc_state *pipe_config,
				    struct drm_connector_state *conn_state)
387
{
388
	struct drm_display_mode *adjusted_mode =
389
		&pipe_config->hw.adjusted_mode;
390 391

	if (adjusted_mode->flags & DRM_MODE_FLAG_DBLSCAN)
392
		return -EINVAL;
393

394
	pipe_config->output_format = INTEL_OUTPUT_FORMAT_RGB;
395 396

	return 0;
397 398
}

399 400 401
static int pch_crt_compute_config(struct intel_encoder *encoder,
				  struct intel_crtc_state *pipe_config,
				  struct drm_connector_state *conn_state)
402
{
403
	struct drm_display_mode *adjusted_mode =
404
		&pipe_config->hw.adjusted_mode;
405 406

	if (adjusted_mode->flags & DRM_MODE_FLAG_DBLSCAN)
407
		return -EINVAL;
408

409
	pipe_config->has_pch_encoder = true;
410
	pipe_config->output_format = INTEL_OUTPUT_FORMAT_RGB;
411

412
	return 0;
413 414
}

415 416 417
static int hsw_crt_compute_config(struct intel_encoder *encoder,
				  struct intel_crtc_state *pipe_config,
				  struct drm_connector_state *conn_state)
J
Jesse Barnes 已提交
418
{
419
	struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
420
	struct drm_display_mode *adjusted_mode =
421
		&pipe_config->hw.adjusted_mode;
422 423

	if (adjusted_mode->flags & DRM_MODE_FLAG_DBLSCAN)
424
		return -EINVAL;
425

426 427 428
	/* HSW/BDW FDI limited to 4k */
	if (adjusted_mode->crtc_hdisplay > 4096 ||
	    adjusted_mode->crtc_hblank_start > 4096)
429
		return -EINVAL;
430

431
	pipe_config->has_pch_encoder = true;
432
	pipe_config->output_format = INTEL_OUTPUT_FORMAT_RGB;
433

434
	/* LPT FDI RX only supports 8bpc. */
435
	if (HAS_PCH_LPT(dev_priv)) {
436
		if (pipe_config->bw_constrained && pipe_config->pipe_bpp < 24) {
437 438
			drm_dbg_kms(&dev_priv->drm,
				    "LPT only supports 24bpp\n");
439
			return -EINVAL;
440 441
		}

442
		pipe_config->pipe_bpp = 24;
443
	}
444

445
	/* FDI must always be 2.7 GHz */
446
	pipe_config->port_clock = 135000 * 2;
447

448
	return 0;
J
Jesse Barnes 已提交
449 450
}

451
static bool ilk_crt_detect_hotplug(struct drm_connector *connector)
452 453
{
	struct drm_device *dev = connector->dev;
454
	struct intel_crt *crt = intel_attached_crt(to_intel_connector(connector));
455
	struct drm_i915_private *dev_priv = to_i915(dev);
456
	u32 adpa;
457 458
	bool ret;

459 460
	/* The first time through, trigger an explicit detection cycle */
	if (crt->force_hotplug_required) {
461
		bool turn_off_dac = HAS_PCH_SPLIT(dev_priv);
462
		u32 save_adpa;
Z
Zhenyu Wang 已提交
463

464
		crt->force_hotplug_required = false;
465

466
		save_adpa = adpa = intel_de_read(dev_priv, crt->adpa_reg);
467 468
		drm_dbg_kms(&dev_priv->drm,
			    "trigger hotplug detect cycle: adpa=0x%x\n", adpa);
469 470 471 472 473

		adpa |= ADPA_CRT_HOTPLUG_FORCE_TRIGGER;
		if (turn_off_dac)
			adpa &= ~ADPA_DAC_ENABLE;

474
		intel_de_write(dev_priv, crt->adpa_reg, adpa);
475

476
		if (intel_de_wait_for_clear(dev_priv,
477
					    crt->adpa_reg,
478
					    ADPA_CRT_HOTPLUG_FORCE_TRIGGER,
479
					    1000))
480 481
			drm_dbg_kms(&dev_priv->drm,
				    "timed out waiting for FORCE_TRIGGER");
482 483

		if (turn_off_dac) {
484 485
			intel_de_write(dev_priv, crt->adpa_reg, save_adpa);
			intel_de_posting_read(dev_priv, crt->adpa_reg);
486
		}
487 488
	}

489
	/* Check the status to see if both blue and green are on now */
490
	adpa = intel_de_read(dev_priv, crt->adpa_reg);
491
	if ((adpa & ADPA_CRT_HOTPLUG_MONITOR_MASK) != 0)
492 493 494
		ret = true;
	else
		ret = false;
495 496
	drm_dbg_kms(&dev_priv->drm, "ironlake hotplug adpa=0x%x, result %d\n",
		    adpa, ret);
497 498

	return ret;
J
Jesse Barnes 已提交
499 500
}

501 502 503
static bool valleyview_crt_detect_hotplug(struct drm_connector *connector)
{
	struct drm_device *dev = connector->dev;
504
	struct intel_crt *crt = intel_attached_crt(to_intel_connector(connector));
505
	struct drm_i915_private *dev_priv = to_i915(dev);
506
	bool reenable_hpd;
507 508 509 510
	u32 adpa;
	bool ret;
	u32 save_adpa;

511 512 513 514 515 516 517 518 519 520 521 522 523 524
	/*
	 * Doing a force trigger causes a hpd interrupt to get sent, which can
	 * get us stuck in a loop if we're polling:
	 *  - We enable power wells and reset the ADPA
	 *  - output_poll_exec does force probe on VGA, triggering a hpd
	 *  - HPD handler waits for poll to unlock dev->mode_config.mutex
	 *  - output_poll_exec shuts off the ADPA, unlocks
	 *    dev->mode_config.mutex
	 *  - HPD handler runs, resets ADPA and brings us back to the start
	 *
	 * Just disable HPD interrupts here to prevent this
	 */
	reenable_hpd = intel_hpd_disable(dev_priv, crt->base.hpd_pin);

525
	save_adpa = adpa = intel_de_read(dev_priv, crt->adpa_reg);
526 527
	drm_dbg_kms(&dev_priv->drm,
		    "trigger hotplug detect cycle: adpa=0x%x\n", adpa);
528 529 530

	adpa |= ADPA_CRT_HOTPLUG_FORCE_TRIGGER;

531
	intel_de_write(dev_priv, crt->adpa_reg, adpa);
532

533 534
	if (intel_de_wait_for_clear(dev_priv, crt->adpa_reg,
				    ADPA_CRT_HOTPLUG_FORCE_TRIGGER, 1000)) {
535 536
		drm_dbg_kms(&dev_priv->drm,
			    "timed out waiting for FORCE_TRIGGER");
537
		intel_de_write(dev_priv, crt->adpa_reg, save_adpa);
538 539 540
	}

	/* Check the status to see if both blue and green are on now */
541
	adpa = intel_de_read(dev_priv, crt->adpa_reg);
542 543 544 545 546
	if ((adpa & ADPA_CRT_HOTPLUG_MONITOR_MASK) != 0)
		ret = true;
	else
		ret = false;

547 548
	drm_dbg_kms(&dev_priv->drm,
		    "valleyview hotplug adpa=0x%x, result %d\n", adpa, ret);
549

550 551 552
	if (reenable_hpd)
		intel_hpd_enable(dev_priv, crt->base.hpd_pin);

553 554 555
	return ret;
}

J
Jesse Barnes 已提交
556 557 558
static bool intel_crt_detect_hotplug(struct drm_connector *connector)
{
	struct drm_device *dev = connector->dev;
559
	struct drm_i915_private *dev_priv = to_i915(dev);
560
	u32 stat;
561
	bool ret = false;
562
	int i, tries = 0;
563

564
	if (HAS_PCH_SPLIT(dev_priv))
565
		return ilk_crt_detect_hotplug(connector);
566

567
	if (IS_VALLEYVIEW(dev_priv))
568 569
		return valleyview_crt_detect_hotplug(connector);

570 571 572 573
	/*
	 * On 4 series desktop, CRT detect sequence need to be done twice
	 * to get a reliable result.
	 */
J
Jesse Barnes 已提交
574

575
	if (IS_G45(dev_priv))
576 577 578 579 580 581
		tries = 2;
	else
		tries = 1;

	for (i = 0; i < tries ; i++) {
		/* turn on the FORCE_DETECT */
582 583 584
		i915_hotplug_interrupt_update(dev_priv,
					      CRT_HOTPLUG_FORCE_DETECT,
					      CRT_HOTPLUG_FORCE_DETECT);
585
		/* wait for FORCE_DETECT to go off */
586 587
		if (intel_de_wait_for_clear(dev_priv, PORT_HOTPLUG_EN,
					    CRT_HOTPLUG_FORCE_DETECT, 1000))
588 589
			drm_dbg_kms(&dev_priv->drm,
				    "timed out waiting for FORCE_DETECT to go off");
590
	}
J
Jesse Barnes 已提交
591

592
	stat = intel_de_read(dev_priv, PORT_HOTPLUG_STAT);
593 594 595 596
	if ((stat & CRT_HOTPLUG_MONITOR_MASK) != CRT_HOTPLUG_MONITOR_NONE)
		ret = true;

	/* clear the interrupt we just generated, if any */
597
	intel_de_write(dev_priv, PORT_HOTPLUG_STAT, CRT_HOTPLUG_INT_STATUS);
J
Jesse Barnes 已提交
598

599
	i915_hotplug_interrupt_update(dev_priv, CRT_HOTPLUG_FORCE_DETECT, 0);
600 601

	return ret;
J
Jesse Barnes 已提交
602 603
}

604 605 606 607 608 609 610 611
static struct edid *intel_crt_get_edid(struct drm_connector *connector,
				struct i2c_adapter *i2c)
{
	struct edid *edid;

	edid = drm_get_edid(connector, i2c);

	if (!edid && !intel_gmbus_is_forced_bit(i2c)) {
612 613
		drm_dbg_kms(connector->dev,
			    "CRT GMBUS EDID read failed, retry using GPIO bit-banging\n");
614 615 616 617 618 619 620 621 622 623 624 625 626
		intel_gmbus_force_bit(i2c, true);
		edid = drm_get_edid(connector, i2c);
		intel_gmbus_force_bit(i2c, false);
	}

	return edid;
}

/* local version of intel_ddc_get_modes() to use intel_crt_get_edid() */
static int intel_crt_ddc_get_modes(struct drm_connector *connector,
				struct i2c_adapter *adapter)
{
	struct edid *edid;
627
	int ret;
628 629 630 631 632

	edid = intel_crt_get_edid(connector, adapter);
	if (!edid)
		return 0;

633 634 635 636
	ret = intel_connector_update_modes(connector, edid);
	kfree(edid);

	return ret;
637 638
}

639
static bool intel_crt_detect_ddc(struct drm_connector *connector)
J
Jesse Barnes 已提交
640
{
641
	struct intel_crt *crt = intel_attached_crt(to_intel_connector(connector));
642
	struct drm_i915_private *dev_priv = to_i915(crt->base.base.dev);
643 644
	struct edid *edid;
	struct i2c_adapter *i2c;
645
	bool ret = false;
J
Jesse Barnes 已提交
646

647
	BUG_ON(crt->base.type != INTEL_OUTPUT_ANALOG);
J
Jesse Barnes 已提交
648

649
	i2c = intel_gmbus_get_adapter(dev_priv, dev_priv->vbt.crt_ddc_pin);
650
	edid = intel_crt_get_edid(connector, i2c);
651 652 653

	if (edid) {
		bool is_digital = edid->input & DRM_EDID_INPUT_DIGITAL;
654 655 656 657 658 659 660

		/*
		 * This may be a DVI-I connector with a shared DDC
		 * link between analog and digital outputs, so we
		 * have to check the EDID input spec of the attached device.
		 */
		if (!is_digital) {
661 662
			drm_dbg_kms(&dev_priv->drm,
				    "CRT detected via DDC:0x50 [EDID]\n");
663 664
			ret = true;
		} else {
665 666
			drm_dbg_kms(&dev_priv->drm,
				    "CRT not detected via DDC:0x50 [EDID reports a digital panel]\n");
667
		}
668
	} else {
669 670
		drm_dbg_kms(&dev_priv->drm,
			    "CRT not detected via DDC:0x50 [no valid EDID found]\n");
671 672
	}

673 674
	kfree(edid);

675
	return ret;
J
Jesse Barnes 已提交
676 677
}

678
static enum drm_connector_status
679
intel_crt_load_detect(struct intel_crt *crt, u32 pipe)
680
{
681
	struct drm_device *dev = crt->base.base.dev;
682
	struct drm_i915_private *dev_priv = to_i915(dev);
T
Tvrtko Ursulin 已提交
683
	struct intel_uncore *uncore = &dev_priv->uncore;
684 685 686 687 688 689
	u32 save_bclrpat;
	u32 save_vtotal;
	u32 vtotal, vactive;
	u32 vsample;
	u32 vblank, vblank_start, vblank_end;
	u32 dsl;
690 691
	i915_reg_t bclrpat_reg, vtotal_reg,
		vblank_reg, vsync_reg, pipeconf_reg, pipe_dsl_reg;
692
	u8 st00;
693 694
	enum drm_connector_status status;

695
	drm_dbg_kms(&dev_priv->drm, "starting load-detect on CRT\n");
696

697 698 699 700 701 702
	bclrpat_reg = BCLRPAT(pipe);
	vtotal_reg = VTOTAL(pipe);
	vblank_reg = VBLANK(pipe);
	vsync_reg = VSYNC(pipe);
	pipeconf_reg = PIPECONF(pipe);
	pipe_dsl_reg = PIPEDSL(pipe);
703

T
Tvrtko Ursulin 已提交
704 705 706
	save_bclrpat = intel_uncore_read(uncore, bclrpat_reg);
	save_vtotal = intel_uncore_read(uncore, vtotal_reg);
	vblank = intel_uncore_read(uncore, vblank_reg);
707 708 709 710 711 712 713 714

	vtotal = ((save_vtotal >> 16) & 0xfff) + 1;
	vactive = (save_vtotal & 0x7ff) + 1;

	vblank_start = (vblank & 0xfff) + 1;
	vblank_end = ((vblank >> 16) & 0xfff) + 1;

	/* Set the border color to purple. */
T
Tvrtko Ursulin 已提交
715
	intel_uncore_write(uncore, bclrpat_reg, 0x500050);
716

717
	if (DISPLAY_VER(dev_priv) != 2) {
T
Tvrtko Ursulin 已提交
718 719 720 721 722
		u32 pipeconf = intel_uncore_read(uncore, pipeconf_reg);
		intel_uncore_write(uncore,
				   pipeconf_reg,
				   pipeconf | PIPECONF_FORCE_BORDER);
		intel_uncore_posting_read(uncore, pipeconf_reg);
723 724
		/* Wait for next Vblank to substitue
		 * border color for Color info */
725
		intel_wait_for_vblank(dev_priv, pipe);
T
Tvrtko Ursulin 已提交
726
		st00 = intel_uncore_read8(uncore, _VGA_MSR_WRITE);
727 728 729 730
		status = ((st00 & (1 << 4)) != 0) ?
			connector_status_connected :
			connector_status_disconnected;

T
Tvrtko Ursulin 已提交
731
		intel_uncore_write(uncore, pipeconf_reg, pipeconf);
732 733 734 735 736 737 738 739 740
	} else {
		bool restore_vblank = false;
		int count, detect;

		/*
		* If there isn't any border, add some.
		* Yes, this will flicker
		*/
		if (vblank_start <= vactive && vblank_end >= vtotal) {
741
			u32 vsync = intel_de_read(dev_priv, vsync_reg);
742
			u32 vsync_start = (vsync & 0xffff) + 1;
743 744

			vblank_start = vsync_start;
T
Tvrtko Ursulin 已提交
745 746 747 748
			intel_uncore_write(uncore,
					   vblank_reg,
					   (vblank_start - 1) |
					   ((vblank_end - 1) << 16));
749 750 751 752 753 754 755 756 757 758 759
			restore_vblank = true;
		}
		/* sample in the vertical border, selecting the larger one */
		if (vblank_start - vactive >= vtotal - vblank_end)
			vsample = (vblank_start + vactive) >> 1;
		else
			vsample = (vtotal + vblank_end) >> 1;

		/*
		 * Wait for the border to be displayed
		 */
T
Tvrtko Ursulin 已提交
760
		while (intel_uncore_read(uncore, pipe_dsl_reg) >= vactive)
761
			;
T
Tvrtko Ursulin 已提交
762 763
		while ((dsl = intel_uncore_read(uncore, pipe_dsl_reg)) <=
		       vsample)
764 765 766 767 768 769 770 771 772
			;
		/*
		 * Watch ST00 for an entire scanline
		 */
		detect = 0;
		count = 0;
		do {
			count++;
			/* Read the ST00 VGA status register */
T
Tvrtko Ursulin 已提交
773
			st00 = intel_uncore_read8(uncore, _VGA_MSR_WRITE);
774 775
			if (st00 & (1 << 4))
				detect++;
T
Tvrtko Ursulin 已提交
776
		} while ((intel_uncore_read(uncore, pipe_dsl_reg) == dsl));
777 778 779

		/* restore vblank if necessary */
		if (restore_vblank)
T
Tvrtko Ursulin 已提交
780
			intel_uncore_write(uncore, vblank_reg, vblank);
781 782 783 784 785 786 787 788 789 790 791 792
		/*
		 * If more than 3/4 of the scanline detected a monitor,
		 * then it is assumed to be present. This works even on i830,
		 * where there isn't any way to force the border color across
		 * the screen
		 */
		status = detect * 4 > count * 3 ?
			 connector_status_connected :
			 connector_status_disconnected;
	}

	/* Restore previous settings */
T
Tvrtko Ursulin 已提交
793
	intel_uncore_write(uncore, bclrpat_reg, save_bclrpat);
794 795 796 797

	return status;
}

798 799 800 801 802 803 804 805 806 807 808 809 810 811 812
static int intel_spurious_crt_detect_dmi_callback(const struct dmi_system_id *id)
{
	DRM_DEBUG_DRIVER("Skipping CRT detection for %s\n", id->ident);
	return 1;
}

static const struct dmi_system_id intel_spurious_crt_detect[] = {
	{
		.callback = intel_spurious_crt_detect_dmi_callback,
		.ident = "ACER ZGB",
		.matches = {
			DMI_MATCH(DMI_SYS_VENDOR, "ACER"),
			DMI_MATCH(DMI_PRODUCT_NAME, "ZGB"),
		},
	},
813 814 815 816 817 818 819 820
	{
		.callback = intel_spurious_crt_detect_dmi_callback,
		.ident = "Intel DZ77BH-55K",
		.matches = {
			DMI_MATCH(DMI_BOARD_VENDOR, "Intel Corporation"),
			DMI_MATCH(DMI_BOARD_NAME, "DZ77BH-55K"),
		},
	},
821 822 823
	{ }
};

824 825 826 827
static int
intel_crt_detect(struct drm_connector *connector,
		 struct drm_modeset_acquire_ctx *ctx,
		 bool force)
J
Jesse Barnes 已提交
828
{
829
	struct drm_i915_private *dev_priv = to_i915(connector->dev);
830
	struct intel_crt *crt = intel_attached_crt(to_intel_connector(connector));
831
	struct intel_encoder *intel_encoder = &crt->base;
832
	intel_wakeref_t wakeref;
833
	int status, ret;
834
	struct intel_load_detect_pipe tmp;
J
Jesse Barnes 已提交
835

836 837 838
	drm_dbg_kms(&dev_priv->drm, "[CONNECTOR:%d:%s] force=%d\n",
		    connector->base.id, connector->name,
		    force);
839

840 841 842
	if (!INTEL_DISPLAY_ENABLED(dev_priv))
		return connector_status_disconnected;

843
	if (dev_priv->params.load_detect_test) {
844 845
		wakeref = intel_display_power_get(dev_priv,
						  intel_encoder->power_domain);
846 847 848
		goto load_detect;
	}

849 850 851 852
	/* Skip machines without VGA that falsely report hotplug events */
	if (dmi_check_system(intel_spurious_crt_detect))
		return connector_status_disconnected;

853 854
	wakeref = intel_display_power_get(dev_priv,
					  intel_encoder->power_domain);
855

856
	if (I915_HAS_HOTPLUG(dev_priv)) {
857 858 859 860
		/* We can not rely on the HPD pin always being correctly wired
		 * up, for example many KVM do not pass it through, and so
		 * only trust an assertion that the monitor is connected.
		 */
861
		if (intel_crt_detect_hotplug(connector)) {
862 863
			drm_dbg_kms(&dev_priv->drm,
				    "CRT detected via hotplug\n");
864 865
			status = connector_status_connected;
			goto out;
866
		} else
867 868
			drm_dbg_kms(&dev_priv->drm,
				    "CRT not detected via hotplug\n");
J
Jesse Barnes 已提交
869 870
	}

871 872 873 874
	if (intel_crt_detect_ddc(connector)) {
		status = connector_status_connected;
		goto out;
	}
J
Jesse Barnes 已提交
875

876 877 878 879
	/* Load detection is broken on HPD capable machines. Whoever wants a
	 * broken monitor (without edid) to work behind a broken kvm (that fails
	 * to have the right resistors for HP detection) needs to fix this up.
	 * For now just bail out. */
880
	if (I915_HAS_HOTPLUG(dev_priv)) {
881 882 883
		status = connector_status_disconnected;
		goto out;
	}
884

885
load_detect:
886 887 888 889
	if (!force) {
		status = connector->status;
		goto out;
	}
890

891
	/* for pre-945g platforms use load detect */
892
	ret = intel_get_load_detect_pipe(connector, &tmp, ctx);
893
	if (ret > 0) {
894 895
		if (intel_crt_detect_ddc(connector))
			status = connector_status_connected;
896
		else if (DISPLAY_VER(dev_priv) < 4)
897 898
			status = intel_crt_load_detect(crt,
				to_intel_crtc(connector->state->crtc)->pipe);
899
		else if (dev_priv->params.load_detect_test)
900
			status = connector_status_disconnected;
901 902
		else
			status = connector_status_unknown;
903
		intel_release_load_detect_pipe(connector, &tmp, ctx);
904
	} else if (ret == 0) {
905
		status = connector_status_unknown;
906
	} else {
907
		status = ret;
908
	}
909

910
out:
911
	intel_display_power_put(dev_priv, intel_encoder->power_domain, wakeref);
912 913 914 915 916 917 918

	/*
	 * Make sure the refs for power wells enabled during detect are
	 * dropped to avoid a new detect cycle triggered by HPD polling.
	 */
	intel_display_power_flush_work(dev_priv);

919
	return status;
J
Jesse Barnes 已提交
920 921 922 923
}

static int intel_crt_get_modes(struct drm_connector *connector)
{
924
	struct drm_device *dev = connector->dev;
925
	struct drm_i915_private *dev_priv = to_i915(dev);
926
	struct intel_crt *crt = intel_attached_crt(to_intel_connector(connector));
927
	struct intel_encoder *intel_encoder = &crt->base;
928
	intel_wakeref_t wakeref;
929
	struct i2c_adapter *i2c;
930
	int ret;
931

932 933
	wakeref = intel_display_power_get(dev_priv,
					  intel_encoder->power_domain);
934

935
	i2c = intel_gmbus_get_adapter(dev_priv, dev_priv->vbt.crt_ddc_pin);
936
	ret = intel_crt_ddc_get_modes(connector, i2c);
937
	if (ret || !IS_G4X(dev_priv))
938
		goto out;
939 940

	/* Try to probe digital port for output in DVI-I -> VGA mode. */
941
	i2c = intel_gmbus_get_adapter(dev_priv, GMBUS_PIN_DPB);
942 943 944
	ret = intel_crt_ddc_get_modes(connector, i2c);

out:
945
	intel_display_power_put(dev_priv, intel_encoder->power_domain, wakeref);
946 947

	return ret;
J
Jesse Barnes 已提交
948 949
}

950
void intel_crt_reset(struct drm_encoder *encoder)
951
{
952
	struct drm_i915_private *dev_priv = to_i915(encoder->dev);
953
	struct intel_crt *crt = intel_encoder_to_crt(to_intel_encoder(encoder));
954

955
	if (DISPLAY_VER(dev_priv) >= 5) {
956 957
		u32 adpa;

958
		adpa = intel_de_read(dev_priv, crt->adpa_reg);
959 960
		adpa &= ~ADPA_CRT_HOTPLUG_MASK;
		adpa |= ADPA_HOTPLUG_BITS;
961 962
		intel_de_write(dev_priv, crt->adpa_reg, adpa);
		intel_de_posting_read(dev_priv, crt->adpa_reg);
963

964
		drm_dbg_kms(&dev_priv->drm, "crt adpa set to 0x%x\n", adpa);
965
		crt->force_hotplug_required = true;
966 967
	}

968 969
}

J
Jesse Barnes 已提交
970 971 972 973 974 975
/*
 * Routines for controlling stuff on the analog port
 */

static const struct drm_connector_funcs intel_crt_connector_funcs = {
	.fill_modes = drm_helper_probe_single_connector_modes,
976
	.late_register = intel_connector_register,
977
	.early_unregister = intel_connector_unregister,
978
	.destroy = intel_connector_destroy,
979
	.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
980
	.atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
J
Jesse Barnes 已提交
981 982 983
};

static const struct drm_connector_helper_funcs intel_crt_connector_helper_funcs = {
984
	.detect_ctx = intel_crt_detect,
J
Jesse Barnes 已提交
985 986 987 988 989
	.mode_valid = intel_crt_mode_valid,
	.get_modes = intel_crt_get_modes,
};

static const struct drm_encoder_funcs intel_crt_enc_funcs = {
990
	.reset = intel_crt_reset,
C
Chris Wilson 已提交
991
	.destroy = intel_encoder_destroy,
J
Jesse Barnes 已提交
992 993
};

994
void intel_crt_init(struct drm_i915_private *dev_priv)
J
Jesse Barnes 已提交
995 996
{
	struct drm_connector *connector;
997
	struct intel_crt *crt;
998
	struct intel_connector *intel_connector;
999 1000
	i915_reg_t adpa_reg;
	u32 adpa;
J
Jesse Barnes 已提交
1001

1002
	if (HAS_PCH_SPLIT(dev_priv))
1003
		adpa_reg = PCH_ADPA;
1004
	else if (IS_VALLEYVIEW(dev_priv))
1005 1006 1007 1008
		adpa_reg = VLV_ADPA;
	else
		adpa_reg = ADPA;

1009
	adpa = intel_de_read(dev_priv, adpa_reg);
1010 1011 1012 1013 1014 1015 1016 1017 1018
	if ((adpa & ADPA_DAC_ENABLE) == 0) {
		/*
		 * On some machines (some IVB at least) CRT can be
		 * fused off, but there's no known fuse bit to
		 * indicate that. On these machine the ADPA register
		 * works normally, except the DAC enable bit won't
		 * take. So the only way to tell is attempt to enable
		 * it and see what happens.
		 */
1019 1020 1021
		intel_de_write(dev_priv, adpa_reg,
			       adpa | ADPA_DAC_ENABLE | ADPA_HSYNC_CNTL_DISABLE | ADPA_VSYNC_CNTL_DISABLE);
		if ((intel_de_read(dev_priv, adpa_reg) & ADPA_DAC_ENABLE) == 0)
1022
			return;
1023
		intel_de_write(dev_priv, adpa_reg, adpa);
1024 1025
	}

1026 1027
	crt = kzalloc(sizeof(struct intel_crt), GFP_KERNEL);
	if (!crt)
J
Jesse Barnes 已提交
1028 1029
		return;

1030
	intel_connector = intel_connector_alloc();
1031
	if (!intel_connector) {
1032
		kfree(crt);
1033 1034 1035 1036
		return;
	}

	connector = &intel_connector->base;
1037
	crt->connector = intel_connector;
1038
	drm_connector_init(&dev_priv->drm, &intel_connector->base,
J
Jesse Barnes 已提交
1039 1040
			   &intel_crt_connector_funcs, DRM_MODE_CONNECTOR_VGA);

1041
	drm_encoder_init(&dev_priv->drm, &crt->base.base, &intel_crt_enc_funcs,
1042
			 DRM_MODE_ENCODER_DAC, "CRT");
J
Jesse Barnes 已提交
1043

1044
	intel_connector_attach_encoder(intel_connector, &crt->base);
J
Jesse Barnes 已提交
1045

1046
	crt->base.type = INTEL_OUTPUT_ANALOG;
1047
	crt->base.cloneable = (1 << INTEL_OUTPUT_DVO) | (1 << INTEL_OUTPUT_HDMI);
1048
	if (IS_I830(dev_priv))
V
Ville Syrjälä 已提交
1049
		crt->base.pipe_mask = BIT(PIPE_A);
1050
	else
1051
		crt->base.pipe_mask = ~0;
1052

1053
	if (DISPLAY_VER(dev_priv) == 2)
1054 1055 1056
		connector->interlace_allowed = 0;
	else
		connector->interlace_allowed = 1;
J
Jesse Barnes 已提交
1057 1058
	connector->doublescan_allowed = 0;

1059
	crt->adpa_reg = adpa_reg;
D
Daniel Vetter 已提交
1060

1061 1062
	crt->base.power_domain = POWER_DOMAIN_PORT_CRT;

1063
	if (I915_HAS_HOTPLUG(dev_priv) &&
1064
	    !dmi_check_system(intel_spurious_crt_detect)) {
1065
		crt->base.hpd_pin = HPD_CRT;
1066
		crt->base.hotplug = intel_encoder_hotplug;
1067
		intel_connector->polled = DRM_CONNECTOR_POLL_HPD;
1068 1069
	} else {
		intel_connector->polled = DRM_CONNECTOR_POLL_CONNECT;
1070
	}
1071

1072
	if (HAS_DDI(dev_priv)) {
1073
		crt->base.port = PORT_E;
1074
		crt->base.get_config = hsw_crt_get_config;
1075
		crt->base.get_hw_state = intel_ddi_get_hw_state;
1076
		crt->base.compute_config = hsw_crt_compute_config;
1077 1078 1079
		crt->base.pre_pll_enable = hsw_pre_pll_enable_crt;
		crt->base.pre_enable = hsw_pre_enable_crt;
		crt->base.enable = hsw_enable_crt;
1080
		crt->base.disable = hsw_disable_crt;
1081
		crt->base.post_disable = hsw_post_disable_crt;
1082 1083
		crt->base.enable_clock = hsw_ddi_enable_clock;
		crt->base.disable_clock = hsw_ddi_disable_clock;
1084
		crt->base.is_clock_enabled = hsw_ddi_is_clock_enabled;
1085 1086

		intel_ddi_buf_trans_init(&crt->base);
1087
	} else {
1088
		if (HAS_PCH_SPLIT(dev_priv)) {
1089
			crt->base.compute_config = pch_crt_compute_config;
1090 1091 1092
			crt->base.disable = pch_disable_crt;
			crt->base.post_disable = pch_post_disable_crt;
		} else {
1093
			crt->base.compute_config = intel_crt_compute_config;
1094 1095
			crt->base.disable = intel_disable_crt;
		}
1096
		crt->base.port = PORT_NONE;
1097
		crt->base.get_config = intel_crt_get_config;
1098
		crt->base.get_hw_state = intel_crt_get_hw_state;
1099
		crt->base.enable = intel_enable_crt;
1100
	}
1101
	intel_connector->get_hw_state = intel_connector_get_hw_state;
1102

J
Jesse Barnes 已提交
1103 1104
	drm_connector_helper_add(connector, &intel_crt_connector_helper_funcs);

1105
	/*
1106 1107 1108
	 * TODO: find a proper way to discover whether we need to set the the
	 * polarity and link reversal bits or not, instead of relying on the
	 * BIOS.
1109
	 */
1110
	if (HAS_PCH_LPT(dev_priv)) {
1111 1112 1113
		u32 fdi_config = FDI_RX_POLARITY_REVERSED_LPT |
				 FDI_RX_LINK_REVERSAL_OVERRIDE;

1114 1115
		dev_priv->fdi_rx_config = intel_de_read(dev_priv,
							FDI_RX_CTL(PIPE_A)) & fdi_config;
1116
	}
1117

1118
	intel_crt_reset(&crt->base.base);
J
Jesse Barnes 已提交
1119
}