Subversion Repositories Kolibri OS

Rev

Rev 3482 | Rev 4126 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3482 Rev 3746
Line 107... Line 107...
107
    return is_pch_edp(intel_dp);
107
    return is_pch_edp(intel_dp);
108
}
108
}
Line 109... Line 109...
109
 
109
 
Line 110... Line -...
110
static void intel_dp_link_down(struct intel_dp *intel_dp);
-
 
111
 
-
 
112
void
-
 
113
intel_edp_link_config(struct intel_encoder *intel_encoder,
-
 
114
		       int *lane_num, int *link_bw)
-
 
115
{
-
 
116
	struct intel_dp *intel_dp = enc_to_intel_dp(&intel_encoder->base);
-
 
117
 
-
 
118
	*lane_num = intel_dp->lane_count;
-
 
119
	*link_bw = drm_dp_bw_code_to_link_rate(intel_dp->link_bw);
-
 
120
}
-
 
121
 
-
 
122
int
-
 
123
intel_edp_target_clock(struct intel_encoder *intel_encoder,
-
 
124
		       struct drm_display_mode *mode)
-
 
125
{
-
 
126
	struct intel_dp *intel_dp = enc_to_intel_dp(&intel_encoder->base);
-
 
127
	struct intel_connector *intel_connector = intel_dp->attached_connector;
-
 
128
 
-
 
129
	if (intel_connector->panel.fixed_mode)
-
 
130
		return intel_connector->panel.fixed_mode->clock;
-
 
131
	else
-
 
132
		return mode->clock;
-
 
133
}
110
static void intel_dp_link_down(struct intel_dp *intel_dp);
134
 
111
 
135
static int
112
static int
136
intel_dp_max_link_bw(struct intel_dp *intel_dp)
113
intel_dp_max_link_bw(struct intel_dp *intel_dp)
Line 175... Line 152...
175
intel_dp_max_data_rate(int max_link_clock, int max_lanes)
152
intel_dp_max_data_rate(int max_link_clock, int max_lanes)
176
{
153
{
177
	return (max_link_clock * max_lanes * 8) / 10;
154
	return (max_link_clock * max_lanes * 8) / 10;
178
}
155
}
Line 179... Line -...
179
 
-
 
180
static bool
-
 
181
intel_dp_adjust_dithering(struct intel_dp *intel_dp,
-
 
182
			  struct drm_display_mode *mode,
-
 
183
			  bool adjust_mode)
-
 
184
{
-
 
185
	int max_link_clock =
-
 
186
		drm_dp_bw_code_to_link_rate(intel_dp_max_link_bw(intel_dp));
-
 
187
	int max_lanes = drm_dp_max_lane_count(intel_dp->dpcd);
-
 
188
	int max_rate, mode_rate;
-
 
189
 
-
 
190
	mode_rate = intel_dp_link_required(mode->clock, 24);
-
 
191
	max_rate = intel_dp_max_data_rate(max_link_clock, max_lanes);
-
 
192
 
-
 
193
	if (mode_rate > max_rate) {
-
 
194
		mode_rate = intel_dp_link_required(mode->clock, 18);
-
 
195
		if (mode_rate > max_rate)
-
 
196
			return false;
-
 
197
 
-
 
198
		if (adjust_mode)
-
 
199
			mode->private_flags
-
 
200
				|= INTEL_MODE_DP_FORCE_6BPC;
-
 
201
 
-
 
202
		return true;
-
 
203
	}
-
 
204
 
-
 
205
	return true;
-
 
206
}
-
 
207
 
156
 
208
static int
157
static int
209
intel_dp_mode_valid(struct drm_connector *connector,
158
intel_dp_mode_valid(struct drm_connector *connector,
210
		    struct drm_display_mode *mode)
159
		    struct drm_display_mode *mode)
211
{
160
{
212
	struct intel_dp *intel_dp = intel_attached_dp(connector);
161
	struct intel_dp *intel_dp = intel_attached_dp(connector);
213
	struct intel_connector *intel_connector = to_intel_connector(connector);
162
	struct intel_connector *intel_connector = to_intel_connector(connector);
-
 
163
	struct drm_display_mode *fixed_mode = intel_connector->panel.fixed_mode;
-
 
164
	int target_clock = mode->clock;
Line 214... Line 165...
214
	struct drm_display_mode *fixed_mode = intel_connector->panel.fixed_mode;
165
	int max_rate, mode_rate, max_lanes, max_link_clock;
215
 
166
 
216
	if (is_edp(intel_dp) && fixed_mode) {
167
	if (is_edp(intel_dp) && fixed_mode) {
Line 217... Line 168...
217
		if (mode->hdisplay > fixed_mode->hdisplay)
168
		if (mode->hdisplay > fixed_mode->hdisplay)
218
			return MODE_PANEL;
169
			return MODE_PANEL;
-
 
170
 
-
 
171
		if (mode->vdisplay > fixed_mode->vdisplay)
219
 
172
			return MODE_PANEL;
Line -... Line 173...
-
 
173
 
-
 
174
		target_clock = fixed_mode->clock;
-
 
175
	}
220
		if (mode->vdisplay > fixed_mode->vdisplay)
176
 
-
 
177
	max_link_clock = drm_dp_bw_code_to_link_rate(intel_dp_max_link_bw(intel_dp));
-
 
178
	max_lanes = drm_dp_max_lane_count(intel_dp->dpcd);
-
 
179
 
221
			return MODE_PANEL;
180
	max_rate = intel_dp_max_data_rate(max_link_clock, max_lanes);
Line 222... Line 181...
222
	}
181
	mode_rate = intel_dp_link_required(target_clock, 18);
223
 
182
 
Line 292... Line 251...
292
 
251
 
293
static bool ironlake_edp_have_panel_power(struct intel_dp *intel_dp)
252
static bool ironlake_edp_have_panel_power(struct intel_dp *intel_dp)
294
{
253
{
295
	struct drm_device *dev = intel_dp_to_dev(intel_dp);
254
	struct drm_device *dev = intel_dp_to_dev(intel_dp);
-
 
255
	struct drm_i915_private *dev_priv = dev->dev_private;
Line -... Line 256...
-
 
256
	u32 pp_stat_reg;
296
	struct drm_i915_private *dev_priv = dev->dev_private;
257
 
297
 
258
	pp_stat_reg = IS_VALLEYVIEW(dev) ? PIPEA_PP_STATUS : PCH_PP_STATUS;
Line 298... Line 259...
298
	return (I915_READ(PCH_PP_STATUS) & PP_ON) != 0;
259
	return (I915_READ(pp_stat_reg) & PP_ON) != 0;
299
}
260
}
300
 
261
 
301
static bool ironlake_edp_have_panel_vdd(struct intel_dp *intel_dp)
262
static bool ironlake_edp_have_panel_vdd(struct intel_dp *intel_dp)
-
 
263
{
Line -... Line 264...
-
 
264
	struct drm_device *dev = intel_dp_to_dev(intel_dp);
302
{
265
	struct drm_i915_private *dev_priv = dev->dev_private;
303
	struct drm_device *dev = intel_dp_to_dev(intel_dp);
266
	u32 pp_ctrl_reg;
Line 304... Line 267...
304
	struct drm_i915_private *dev_priv = dev->dev_private;
267
 
305
 
268
	pp_ctrl_reg = IS_VALLEYVIEW(dev) ? PIPEA_PP_CONTROL : PCH_PP_CONTROL;
306
	return (I915_READ(PCH_PP_CONTROL) & EDP_FORCE_VDD) != 0;
269
	return (I915_READ(pp_ctrl_reg) & EDP_FORCE_VDD) != 0;
307
}
270
}
308
 
271
 
-
 
272
static void
Line 309... Line 273...
309
static void
273
intel_dp_check_edp(struct intel_dp *intel_dp)
310
intel_dp_check_edp(struct intel_dp *intel_dp)
274
{
-
 
275
	struct drm_device *dev = intel_dp_to_dev(intel_dp);
-
 
276
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
277
	u32 pp_stat_reg, pp_ctrl_reg;
-
 
278
 
311
{
279
	if (!is_edp(intel_dp))
312
	struct drm_device *dev = intel_dp_to_dev(intel_dp);
280
		return;
313
	struct drm_i915_private *dev_priv = dev->dev_private;
281
 
314
 
282
	pp_stat_reg = IS_VALLEYVIEW(dev) ? PIPEA_PP_STATUS : PCH_PP_STATUS;
315
	if (!is_edp(intel_dp))
283
	pp_ctrl_reg = IS_VALLEYVIEW(dev) ? PIPEA_PP_CONTROL : PCH_PP_CONTROL;
316
		return;
284
 
317
	if (!ironlake_edp_have_panel_power(intel_dp) && !ironlake_edp_have_panel_vdd(intel_dp)) {
285
	if (!ironlake_edp_have_panel_power(intel_dp) && !ironlake_edp_have_panel_vdd(intel_dp)) {
Line 318... Line 286...
318
		WARN(1, "eDP powered off while attempting aux channel communication.\n");
286
		WARN(1, "eDP powered off while attempting aux channel communication.\n");
319
		DRM_DEBUG_KMS("Status 0x%08x Control 0x%08x\n",
287
		DRM_DEBUG_KMS("Status 0x%08x Control 0x%08x\n",
320
			      I915_READ(PCH_PP_STATUS),
288
				I915_READ(pp_stat_reg),
321
			      I915_READ(PCH_PP_CONTROL));
289
				I915_READ(pp_ctrl_reg));
322
	}
290
	}
323
}
291
}
324
 
292
 
325
static uint32_t
293
static uint32_t
326
intel_dp_aux_wait_done(struct intel_dp *intel_dp, bool has_aux_irq)
294
intel_dp_aux_wait_done(struct intel_dp *intel_dp, bool has_aux_irq)
Line 327... Line -...
327
{
-
 
328
	struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
-
 
329
	struct drm_device *dev = intel_dig_port->base.base.dev;
-
 
330
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
331
	uint32_t ch_ctl = intel_dp->output_reg + 0x10;
-
 
332
	uint32_t status;
-
 
333
	bool done;
-
 
334
 
-
 
335
	if (IS_HASWELL(dev)) {
-
 
336
		switch (intel_dig_port->port) {
-
 
337
		case PORT_A:
-
 
338
			ch_ctl = DPA_AUX_CH_CTL;
-
 
339
			break;
-
 
340
		case PORT_B:
-
 
341
			ch_ctl = PCH_DPB_AUX_CH_CTL;
-
 
342
			break;
-
 
343
		case PORT_C:
-
 
344
			ch_ctl = PCH_DPC_AUX_CH_CTL;
-
 
345
			break;
-
 
346
		case PORT_D:
295
{
347
			ch_ctl = PCH_DPD_AUX_CH_CTL;
296
	struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
348
			break;
297
	struct drm_device *dev = intel_dig_port->base.base.dev;
349
		default:
298
	struct drm_i915_private *dev_priv = dev->dev_private;
350
			BUG();
299
	uint32_t ch_ctl = intel_dp->aux_ch_ctl_reg;
Line 368... Line 317...
368
static int
317
static int
369
intel_dp_aux_ch(struct intel_dp *intel_dp,
318
intel_dp_aux_ch(struct intel_dp *intel_dp,
370
		uint8_t *send, int send_bytes,
319
		uint8_t *send, int send_bytes,
371
		uint8_t *recv, int recv_size)
320
		uint8_t *recv, int recv_size)
372
{
321
{
373
	uint32_t output_reg = intel_dp->output_reg;
-
 
374
	struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
322
	struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
375
	struct drm_device *dev = intel_dig_port->base.base.dev;
323
	struct drm_device *dev = intel_dig_port->base.base.dev;
376
	struct drm_i915_private *dev_priv = dev->dev_private;
324
	struct drm_i915_private *dev_priv = dev->dev_private;
377
	uint32_t ch_ctl = output_reg + 0x10;
325
	uint32_t ch_ctl = intel_dp->aux_ch_ctl_reg;
378
	uint32_t ch_data = ch_ctl + 4;
326
	uint32_t ch_data = ch_ctl + 4;
379
	int i, ret, recv_bytes;
327
	int i, ret, recv_bytes;
380
	uint32_t status;
328
	uint32_t status;
381
	uint32_t aux_clock_divider;
329
	uint32_t aux_clock_divider;
382
	int try, precharge;
330
	int try, precharge;
Line 386... Line 334...
386
	 * lowest possible wakeup latency and so prevent the cpu from going into
334
	 * lowest possible wakeup latency and so prevent the cpu from going into
387
	 * deep sleep states.
335
	 * deep sleep states.
388
	 */
336
	 */
389
//	pm_qos_update_request(&dev_priv->pm_qos, 0);
337
//	pm_qos_update_request(&dev_priv->pm_qos, 0);
Line 390... Line -...
390
 
-
 
391
	if (IS_HASWELL(dev)) {
-
 
392
		switch (intel_dig_port->port) {
-
 
393
		case PORT_A:
-
 
394
			ch_ctl = DPA_AUX_CH_CTL;
-
 
395
			ch_data = DPA_AUX_CH_DATA1;
-
 
396
			break;
-
 
397
		case PORT_B:
-
 
398
			ch_ctl = PCH_DPB_AUX_CH_CTL;
-
 
399
			ch_data = PCH_DPB_AUX_CH_DATA1;
-
 
400
			break;
-
 
401
		case PORT_C:
-
 
402
			ch_ctl = PCH_DPC_AUX_CH_CTL;
-
 
403
			ch_data = PCH_DPC_AUX_CH_DATA1;
-
 
404
			break;
-
 
405
		case PORT_D:
-
 
406
			ch_ctl = PCH_DPD_AUX_CH_CTL;
-
 
407
			ch_data = PCH_DPD_AUX_CH_DATA1;
-
 
408
			break;
-
 
409
		default:
-
 
410
			BUG();
-
 
411
		}
-
 
412
	}
-
 
413
 
338
 
414
	intel_dp_check_edp(intel_dp);
339
	intel_dp_check_edp(intel_dp);
415
	/* The clock divider is based off the hrawclk,
340
	/* The clock divider is based off the hrawclk,
416
	 * and would like to run at 2MHz. So, take the
341
	 * and would like to run at 2MHz. So, take the
417
	 * hrawclk value and divide by 2 and use that
342
	 * hrawclk value and divide by 2 and use that
Line 426... Line 351...
426
			aux_clock_divider = 100;
351
			aux_clock_divider = 100;
427
		else if (IS_GEN6(dev) || IS_GEN7(dev))
352
		else if (IS_GEN6(dev) || IS_GEN7(dev))
428
			aux_clock_divider = 200; /* SNB & IVB eDP input clock at 400Mhz */
353
			aux_clock_divider = 200; /* SNB & IVB eDP input clock at 400Mhz */
429
		else
354
		else
430
			aux_clock_divider = 225; /* eDP input clock at 450Mhz */
355
			aux_clock_divider = 225; /* eDP input clock at 450Mhz */
-
 
356
	} else if (dev_priv->pch_id == INTEL_PCH_LPT_DEVICE_ID_TYPE) {
-
 
357
		/* Workaround for non-ULT HSW */
-
 
358
		aux_clock_divider = 74;
431
	} else if (HAS_PCH_SPLIT(dev))
359
	} else if (HAS_PCH_SPLIT(dev)) {
432
		aux_clock_divider = DIV_ROUND_UP(intel_pch_rawclk(dev), 2);
360
		aux_clock_divider = DIV_ROUND_UP(intel_pch_rawclk(dev), 2);
433
	else
361
	} else {
434
		aux_clock_divider = intel_hrawclk(dev) / 2;
362
		aux_clock_divider = intel_hrawclk(dev) / 2;
-
 
363
	}
Line 435... Line 364...
435
 
364
 
436
	if (IS_GEN6(dev))
365
	if (IS_GEN6(dev))
437
		precharge = 3;
366
		precharge = 3;
438
	else
367
	else
Line 730... Line 659...
730
	ironlake_edp_panel_vdd_off(intel_dp, false);
659
	ironlake_edp_panel_vdd_off(intel_dp, false);
731
	return ret;
660
	return ret;
732
}
661
}
Line 733... Line 662...
733
 
662
 
734
bool
663
bool
735
intel_dp_mode_fixup(struct drm_encoder *encoder,
-
 
736
		    const struct drm_display_mode *mode,
664
intel_dp_compute_config(struct intel_encoder *encoder,
737
		    struct drm_display_mode *adjusted_mode)
665
			struct intel_crtc_config *pipe_config)
738
{
666
{
-
 
667
	struct drm_device *dev = encoder->base.dev;
-
 
668
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
669
	struct drm_display_mode *adjusted_mode = &pipe_config->adjusted_mode;
739
	struct drm_device *dev = encoder->dev;
670
	struct drm_display_mode *mode = &pipe_config->requested_mode;
740
	struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
671
	struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base);
741
	struct intel_connector *intel_connector = intel_dp->attached_connector;
672
	struct intel_connector *intel_connector = intel_dp->attached_connector;
742
	int lane_count, clock;
673
	int lane_count, clock;
743
	int max_lane_count = drm_dp_max_lane_count(intel_dp->dpcd);
674
	int max_lane_count = drm_dp_max_lane_count(intel_dp->dpcd);
744
	int max_clock = intel_dp_max_link_bw(intel_dp) == DP_LINK_BW_2_7 ? 1 : 0;
675
	int max_clock = intel_dp_max_link_bw(intel_dp) == DP_LINK_BW_2_7 ? 1 : 0;
745
	int bpp, mode_rate;
676
	int bpp, mode_rate;
-
 
677
	static int bws[2] = { DP_LINK_BW_1_62, DP_LINK_BW_2_7 };
-
 
678
	int target_clock, link_avail, link_clock;
-
 
679
 
-
 
680
	if (HAS_PCH_SPLIT(dev) && !HAS_DDI(dev) && !is_cpu_edp(intel_dp))
-
 
681
		pipe_config->has_pch_encoder = true;
-
 
682
 
Line 746... Line 683...
746
	static int bws[2] = { DP_LINK_BW_1_62, DP_LINK_BW_2_7 };
683
	pipe_config->has_dp_encoder = true;
747
 
684
 
748
	if (is_edp(intel_dp) && intel_connector->panel.fixed_mode) {
685
	if (is_edp(intel_dp) && intel_connector->panel.fixed_mode) {
749
		intel_fixed_panel_mode(intel_connector->panel.fixed_mode,
686
		intel_fixed_panel_mode(intel_connector->panel.fixed_mode,
750
				       adjusted_mode);
687
				       adjusted_mode);
751
		intel_pch_panel_fitting(dev,
688
		intel_pch_panel_fitting(dev,
752
					intel_connector->panel.fitting_mode,
689
					intel_connector->panel.fitting_mode,
-
 
690
					mode, adjusted_mode);
-
 
691
	}
Line 753... Line 692...
753
					mode, adjusted_mode);
692
	/* We need to take the panel's fixed mode into account. */
754
	}
693
	target_clock = adjusted_mode->clock;
Line 755... Line 694...
755
 
694
 
756
	if (adjusted_mode->flags & DRM_MODE_FLAG_DBLCLK)
695
	if (adjusted_mode->flags & DRM_MODE_FLAG_DBLCLK)
757
		return false;
696
		return false;
Line 758... Line 697...
758
 
697
 
759
	DRM_DEBUG_KMS("DP link computation with max lane count %i "
698
	DRM_DEBUG_KMS("DP link computation with max lane count %i "
-
 
699
		      "max bw %02x pixel clock %iKHz\n",
-
 
700
		      max_lane_count, bws[max_clock], adjusted_mode->clock);
-
 
701
 
Line -... Line 702...
-
 
702
	/* Walk through all bpp values. Luckily they're all nicely spaced with 2
-
 
703
	 * bpc in between. */
-
 
704
	bpp = min_t(int, 8*3, pipe_config->pipe_bpp);
-
 
705
	if (is_edp(intel_dp) && dev_priv->edp.bpp)
760
		      "max bw %02x pixel clock %iKHz\n",
706
		bpp = min_t(int, bpp, dev_priv->edp.bpp);
-
 
707
 
-
 
708
	for (; bpp >= 6*3; bpp -= 2*3) {
-
 
709
		mode_rate = intel_dp_link_required(target_clock, bpp);
Line -... Line 710...
-
 
710
 
-
 
711
		for (clock = 0; clock <= max_clock; clock++) {
-
 
712
			for (lane_count = 1; lane_count <= max_lane_count; lane_count <<= 1) {
-
 
713
				link_clock = drm_dp_bw_code_to_link_rate(bws[clock]);
-
 
714
				link_avail = intel_dp_max_data_rate(link_clock,
-
 
715
								    lane_count);
-
 
716
 
-
 
717
				if (mode_rate <= link_avail) {
-
 
718
					goto found;
-
 
719
				}
761
		      max_lane_count, bws[max_clock], adjusted_mode->clock);
720
			}
762
 
721
		}
763
	if (!intel_dp_adjust_dithering(intel_dp, adjusted_mode, true))
722
	}
764
		return false;
723
 
765
 
724
		return false;
Line 776... Line 735...
776
		else
735
		else
777
			intel_dp->color_range = 0;
736
			intel_dp->color_range = 0;
778
	}
737
	}
Line 779... Line 738...
779
 
738
 
780
	if (intel_dp->color_range)
-
 
781
		adjusted_mode->private_flags |= INTEL_MODE_LIMITED_COLOR_RANGE;
-
 
782
 
739
	if (intel_dp->color_range)
Line 783... Line -...
783
	mode_rate = intel_dp_link_required(adjusted_mode->clock, bpp);
-
 
784
 
-
 
785
	for (clock = 0; clock <= max_clock; clock++) {
-
 
786
	for (lane_count = 1; lane_count <= max_lane_count; lane_count <<= 1) {
-
 
787
			int link_bw_clock =
-
 
788
				drm_dp_bw_code_to_link_rate(bws[clock]);
-
 
789
			int link_avail = intel_dp_max_data_rate(link_bw_clock,
-
 
790
								lane_count);
-
 
791
 
740
		pipe_config->limited_color_range = true;
792
			if (mode_rate <= link_avail) {
741
 
793
				intel_dp->link_bw = bws[clock];
742
				intel_dp->link_bw = bws[clock];
-
 
743
				intel_dp->lane_count = lane_count;
794
				intel_dp->lane_count = lane_count;
744
	adjusted_mode->clock = drm_dp_bw_code_to_link_rate(intel_dp->link_bw);
-
 
745
	pipe_config->pipe_bpp = bpp;
795
				adjusted_mode->clock = link_bw_clock;
746
	pipe_config->pixel_target_clock = target_clock;
796
				DRM_DEBUG_KMS("DP link bw %02x lane "
747
 
797
						"count %d clock %d bpp %d\n",
748
	DRM_DEBUG_KMS("DP link bw %02x lane count %d clock %d bpp %d\n",
798
				       intel_dp->link_bw, intel_dp->lane_count,
749
				       intel_dp->link_bw, intel_dp->lane_count,
799
				       adjusted_mode->clock, bpp);
750
				       adjusted_mode->clock, bpp);
800
				DRM_DEBUG_KMS("DP link bw required %i available %i\n",
-
 
801
					      mode_rate, link_avail);
-
 
802
				return true;
-
 
803
			}
-
 
804
		}
-
 
805
	}
-
 
806
 
-
 
807
	return false;
-
 
808
}
-
 
809
 
-
 
810
void
-
 
811
intel_dp_set_m_n(struct drm_crtc *crtc, struct drm_display_mode *mode,
-
 
812
         struct drm_display_mode *adjusted_mode)
-
 
813
{
-
 
814
    struct drm_device *dev = crtc->dev;
-
 
815
	struct intel_encoder *intel_encoder;
-
 
816
	struct intel_dp *intel_dp;
-
 
817
    struct drm_i915_private *dev_priv = dev->dev_private;
-
 
818
    struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
-
 
819
    int lane_count = 4;
-
 
820
	struct intel_link_m_n m_n;
-
 
821
    int pipe = intel_crtc->pipe;
-
 
822
	enum transcoder cpu_transcoder = intel_crtc->cpu_transcoder;
-
 
823
	int target_clock;
-
 
824
 
-
 
825
    /*
-
 
826
     * Find the lane count in the intel_encoder private
-
 
827
     */
-
 
828
	for_each_encoder_on_crtc(dev, crtc, intel_encoder) {
-
 
829
		intel_dp = enc_to_intel_dp(&intel_encoder->base);
-
 
830
 
-
 
831
		if (intel_encoder->type == INTEL_OUTPUT_DISPLAYPORT ||
-
 
832
		    intel_encoder->type == INTEL_OUTPUT_EDP)
-
 
833
		{
-
 
834
            lane_count = intel_dp->lane_count;
-
 
835
            break;
-
 
Line 836... Line -...
836
        }
-
 
837
    }
-
 
838
 
751
				DRM_DEBUG_KMS("DP link bw required %i available %i\n",
839
	target_clock = mode->clock;
752
					      mode_rate, link_avail);
840
	for_each_encoder_on_crtc(dev, crtc, intel_encoder) {
753
 
841
		if (intel_encoder->type == INTEL_OUTPUT_EDP) {
-
 
842
			target_clock = intel_edp_target_clock(intel_encoder,
-
 
843
							      mode);
-
 
Line 844... Line -...
844
			break;
-
 
845
		}
-
 
846
	}
-
 
847
 
-
 
848
    /*
-
 
849
     * Compute the GMCH and Link ratios. The '3' here is
-
 
850
     * the number of bytes_per_pixel post-LUT, which we always
-
 
851
     * set up for 8-bits of R/G/B, or 3 bytes total.
-
 
852
     */
-
 
853
	intel_link_compute_m_n(intel_crtc->bpp, lane_count,
-
 
854
			       target_clock, adjusted_mode->clock, &m_n);
-
 
855
 
-
 
856
	if (IS_HASWELL(dev)) {
-
 
857
		I915_WRITE(PIPE_DATA_M1(cpu_transcoder),
-
 
858
			   TU_SIZE(m_n.tu) | m_n.gmch_m);
-
 
859
		I915_WRITE(PIPE_DATA_N1(cpu_transcoder), m_n.gmch_n);
-
 
860
		I915_WRITE(PIPE_LINK_M1(cpu_transcoder), m_n.link_m);
-
 
861
		I915_WRITE(PIPE_LINK_N1(cpu_transcoder), m_n.link_n);
-
 
862
	} else if (HAS_PCH_SPLIT(dev)) {
-
 
863
		I915_WRITE(TRANSDATA_M1(pipe), TU_SIZE(m_n.tu) | m_n.gmch_m);
-
 
864
        I915_WRITE(TRANSDATA_N1(pipe), m_n.gmch_n);
-
 
865
        I915_WRITE(TRANSDPLINK_M1(pipe), m_n.link_m);
-
 
866
        I915_WRITE(TRANSDPLINK_N1(pipe), m_n.link_n);
-
 
867
	} else if (IS_VALLEYVIEW(dev)) {
-
 
868
		I915_WRITE(PIPE_DATA_M1(pipe), TU_SIZE(m_n.tu) | m_n.gmch_m);
754
	intel_link_compute_m_n(bpp, lane_count,
869
		I915_WRITE(PIPE_DATA_N1(pipe), m_n.gmch_n);
-
 
870
		I915_WRITE(PIPE_LINK_M1(pipe), m_n.link_m);
-
 
871
		I915_WRITE(PIPE_LINK_N1(pipe), m_n.link_n);
-
 
872
    } else {
-
 
873
        I915_WRITE(PIPE_GMCH_DATA_M(pipe),
-
 
874
			   TU_SIZE(m_n.tu) | m_n.gmch_m);
-
 
875
        I915_WRITE(PIPE_GMCH_DATA_N(pipe), m_n.gmch_n);
755
			       target_clock, adjusted_mode->clock,
Line 876... Line 756...
876
        I915_WRITE(PIPE_DP_LINK_M(pipe), m_n.link_m);
756
			       &pipe_config->dp_m_n);
877
        I915_WRITE(PIPE_DP_LINK_N(pipe), m_n.link_n);
757
 
878
    }
758
	return true;
Line 992... Line 872...
992
		if (adjusted_mode->clock < 200000)
872
		if (adjusted_mode->clock < 200000)
993
			intel_dp->DP |= DP_PLL_FREQ_160MHZ;
873
			intel_dp->DP |= DP_PLL_FREQ_160MHZ;
994
		else
874
		else
995
			intel_dp->DP |= DP_PLL_FREQ_270MHZ;
875
			intel_dp->DP |= DP_PLL_FREQ_270MHZ;
996
	} else if (!HAS_PCH_CPT(dev) || is_cpu_edp(intel_dp)) {
876
	} else if (!HAS_PCH_CPT(dev) || is_cpu_edp(intel_dp)) {
997
		if (!HAS_PCH_SPLIT(dev))
877
		if (!HAS_PCH_SPLIT(dev) && !IS_VALLEYVIEW(dev))
998
		intel_dp->DP |= intel_dp->color_range;
878
		intel_dp->DP |= intel_dp->color_range;
Line 999... Line 879...
999
 
879
 
1000
		if (adjusted_mode->flags & DRM_MODE_FLAG_PHSYNC)
880
		if (adjusted_mode->flags & DRM_MODE_FLAG_PHSYNC)
1001
			intel_dp->DP |= DP_SYNC_HS_HIGH;
881
			intel_dp->DP |= DP_SYNC_HS_HIGH;
Line 1007... Line 887...
1007
		intel_dp->DP |= DP_ENHANCED_FRAMING;
887
		intel_dp->DP |= DP_ENHANCED_FRAMING;
Line 1008... Line 888...
1008
 
888
 
1009
		if (intel_crtc->pipe == 1)
889
		if (intel_crtc->pipe == 1)
Line 1010... Line 890...
1010
		intel_dp->DP |= DP_PIPEB_SELECT;
890
		intel_dp->DP |= DP_PIPEB_SELECT;
1011
 
891
 
1012
		if (is_cpu_edp(intel_dp)) {
892
		if (is_cpu_edp(intel_dp) && !IS_VALLEYVIEW(dev)) {
1013
		/* don't miss out required setting for eDP */
893
		/* don't miss out required setting for eDP */
1014
		if (adjusted_mode->clock < 200000)
894
		if (adjusted_mode->clock < 200000)
1015
			intel_dp->DP |= DP_PLL_FREQ_160MHZ;
895
			intel_dp->DP |= DP_PLL_FREQ_160MHZ;
1016
		else
896
		else
1017
			intel_dp->DP |= DP_PLL_FREQ_270MHZ;
897
			intel_dp->DP |= DP_PLL_FREQ_270MHZ;
1018
	}
898
	}
1019
	} else {
899
	} else {
Line 1020... Line 900...
1020
		intel_dp->DP |= DP_LINK_TRAIN_OFF_CPT;
900
		intel_dp->DP |= DP_LINK_TRAIN_OFF_CPT;
1021
	}
901
	}
1022
 
902
 
Line 1023... Line 903...
1023
	if (is_cpu_edp(intel_dp))
903
	if (is_cpu_edp(intel_dp) && !IS_VALLEYVIEW(dev))
1024
		ironlake_set_pll_edp(crtc, adjusted_mode->clock);
904
		ironlake_set_pll_edp(crtc, adjusted_mode->clock);
Line 1037... Line 917...
1037
				       u32 mask,
917
				       u32 mask,
1038
				       u32 value)
918
				       u32 value)
1039
{
919
{
1040
	struct drm_device *dev = intel_dp_to_dev(intel_dp);
920
	struct drm_device *dev = intel_dp_to_dev(intel_dp);
1041
	struct drm_i915_private *dev_priv = dev->dev_private;
921
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
922
	u32 pp_stat_reg, pp_ctrl_reg;
-
 
923
 
-
 
924
	pp_stat_reg = IS_VALLEYVIEW(dev) ? PIPEA_PP_STATUS : PCH_PP_STATUS;
-
 
925
	pp_ctrl_reg = IS_VALLEYVIEW(dev) ? PIPEA_PP_CONTROL : PCH_PP_CONTROL;
Line 1042... Line 926...
1042
 
926
 
1043
	DRM_DEBUG_KMS("mask %08x value %08x status %08x control %08x\n",
927
	DRM_DEBUG_KMS("mask %08x value %08x status %08x control %08x\n",
1044
		      mask, value,
928
		      mask, value,
1045
		      I915_READ(PCH_PP_STATUS),
929
			I915_READ(pp_stat_reg),
Line 1046... Line 930...
1046
		      I915_READ(PCH_PP_CONTROL));
930
			I915_READ(pp_ctrl_reg));
1047
 
931
 
1048
	if (_wait_for((I915_READ(PCH_PP_STATUS) & mask) == value, 5000, 10)) {
932
	if (_wait_for((I915_READ(pp_stat_reg) & mask) == value, 5000, 10)) {
1049
		DRM_ERROR("Panel status timeout: status %08x control %08x\n",
933
		DRM_ERROR("Panel status timeout: status %08x control %08x\n",
1050
			  I915_READ(PCH_PP_STATUS),
934
				I915_READ(pp_stat_reg),
1051
			  I915_READ(PCH_PP_CONTROL));
935
				I915_READ(pp_ctrl_reg));
Line 1052... Line 936...
1052
	}
936
	}
1053
}
937
}
Line 1073... Line 957...
1073
 
957
 
1074
/* Read the current pp_control value, unlocking the register if it
958
/* Read the current pp_control value, unlocking the register if it
1075
 * is locked
959
 * is locked
Line 1076... Line 960...
1076
 */
960
 */
1077
 
961
 
-
 
962
static  u32 ironlake_get_pp_control(struct intel_dp *intel_dp)
-
 
963
{
-
 
964
	struct drm_device *dev = intel_dp_to_dev(intel_dp);
-
 
965
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
966
	u32 control;
-
 
967
	u32 pp_ctrl_reg;
1078
static  u32 ironlake_get_pp_control(struct drm_i915_private *dev_priv)
968
 
Line 1079... Line 969...
1079
{
969
	pp_ctrl_reg = IS_VALLEYVIEW(dev) ? PIPEA_PP_CONTROL : PCH_PP_CONTROL;
1080
	u32	control = I915_READ(PCH_PP_CONTROL);
970
	control = I915_READ(pp_ctrl_reg);
1081
 
971
 
1082
	control &= ~PANEL_UNLOCK_MASK;
972
	control &= ~PANEL_UNLOCK_MASK;
Line 1087... Line 977...
1087
void ironlake_edp_panel_vdd_on(struct intel_dp *intel_dp)
977
void ironlake_edp_panel_vdd_on(struct intel_dp *intel_dp)
1088
{
978
{
1089
	struct drm_device *dev = intel_dp_to_dev(intel_dp);
979
	struct drm_device *dev = intel_dp_to_dev(intel_dp);
1090
	struct drm_i915_private *dev_priv = dev->dev_private;
980
	struct drm_i915_private *dev_priv = dev->dev_private;
1091
	u32 pp;
981
	u32 pp;
-
 
982
	u32 pp_stat_reg, pp_ctrl_reg;
Line 1092... Line 983...
1092
 
983
 
1093
	if (!is_edp(intel_dp))
984
	if (!is_edp(intel_dp))
1094
		return;
985
		return;
Line 1105... Line 996...
1105
	}
996
	}
Line 1106... Line 997...
1106
 
997
 
1107
	if (!ironlake_edp_have_panel_power(intel_dp))
998
	if (!ironlake_edp_have_panel_power(intel_dp))
Line 1108... Line 999...
1108
		ironlake_wait_panel_power_cycle(intel_dp);
999
		ironlake_wait_panel_power_cycle(intel_dp);
1109
 
1000
 
1110
	pp = ironlake_get_pp_control(dev_priv);
-
 
1111
	pp |= EDP_FORCE_VDD;
-
 
1112
	I915_WRITE(PCH_PP_CONTROL, pp);
-
 
1113
	POSTING_READ(PCH_PP_CONTROL);
-
 
Line -... Line 1001...
-
 
1001
	pp = ironlake_get_pp_control(intel_dp);
-
 
1002
	pp |= EDP_FORCE_VDD;
-
 
1003
 
-
 
1004
	pp_stat_reg = IS_VALLEYVIEW(dev) ? PIPEA_PP_STATUS : PCH_PP_STATUS;
-
 
1005
	pp_ctrl_reg = IS_VALLEYVIEW(dev) ? PIPEA_PP_CONTROL : PCH_PP_CONTROL;
-
 
1006
 
-
 
1007
	I915_WRITE(pp_ctrl_reg, pp);
1114
	DRM_DEBUG_KMS("PCH_PP_STATUS: 0x%08x PCH_PP_CONTROL: 0x%08x\n",
1008
	POSTING_READ(pp_ctrl_reg);
1115
		      I915_READ(PCH_PP_STATUS), I915_READ(PCH_PP_CONTROL));
1009
	DRM_DEBUG_KMS("PP_STATUS: 0x%08x PP_CONTROL: 0x%08x\n",
1116
 
1010
			I915_READ(pp_stat_reg), I915_READ(pp_ctrl_reg));
1117
	/*
1011
	/*
1118
	 * If the panel wasn't on, delay before accessing aux channel
1012
	 * If the panel wasn't on, delay before accessing aux channel
Line 1126... Line 1020...
1126
static void ironlake_panel_vdd_off_sync(struct intel_dp *intel_dp)
1020
static void ironlake_panel_vdd_off_sync(struct intel_dp *intel_dp)
1127
{
1021
{
1128
	struct drm_device *dev = intel_dp_to_dev(intel_dp);
1022
	struct drm_device *dev = intel_dp_to_dev(intel_dp);
1129
	struct drm_i915_private *dev_priv = dev->dev_private;
1023
	struct drm_i915_private *dev_priv = dev->dev_private;
1130
	u32 pp;
1024
	u32 pp;
-
 
1025
	u32 pp_stat_reg, pp_ctrl_reg;
Line 1131... Line 1026...
1131
 
1026
 
Line 1132... Line 1027...
1132
	WARN_ON(!mutex_is_locked(&dev->mode_config.mutex));
1027
	WARN_ON(!mutex_is_locked(&dev->mode_config.mutex));
1133
 
1028
 
1134
	if (!intel_dp->want_panel_vdd && ironlake_edp_have_panel_vdd(intel_dp)) {
1029
	if (!intel_dp->want_panel_vdd && ironlake_edp_have_panel_vdd(intel_dp)) {
1135
		pp = ironlake_get_pp_control(dev_priv);
-
 
1136
	pp &= ~EDP_FORCE_VDD;
-
 
Line 1137... Line 1030...
1137
	I915_WRITE(PCH_PP_CONTROL, pp);
1030
		pp = ironlake_get_pp_control(intel_dp);
1138
	POSTING_READ(PCH_PP_CONTROL);
1031
	pp &= ~EDP_FORCE_VDD;
-
 
1032
 
-
 
1033
		pp_stat_reg = IS_VALLEYVIEW(dev) ? PIPEA_PP_STATUS : PCH_PP_STATUS;
1139
 
1034
		pp_ctrl_reg = IS_VALLEYVIEW(dev) ? PIPEA_PP_CONTROL : PCH_PP_CONTROL;
Line -... Line 1035...
-
 
1035
 
-
 
1036
		I915_WRITE(pp_ctrl_reg, pp);
-
 
1037
		POSTING_READ(pp_ctrl_reg);
1140
	/* Make sure sequencer is idle before allowing subsequent activity */
1038
 
1141
		DRM_DEBUG_KMS("PCH_PP_STATUS: 0x%08x PCH_PP_CONTROL: 0x%08x\n",
1039
	/* Make sure sequencer is idle before allowing subsequent activity */
1142
			      I915_READ(PCH_PP_STATUS), I915_READ(PCH_PP_CONTROL));
1040
		DRM_DEBUG_KMS("PP_STATUS: 0x%08x PP_CONTROL: 0x%08x\n",
Line 1143... Line 1041...
1143
 
1041
		I915_READ(pp_stat_reg), I915_READ(pp_ctrl_reg));
Line 1182... Line 1080...
1182
void ironlake_edp_panel_on(struct intel_dp *intel_dp)
1080
void ironlake_edp_panel_on(struct intel_dp *intel_dp)
1183
{
1081
{
1184
	struct drm_device *dev = intel_dp_to_dev(intel_dp);
1082
	struct drm_device *dev = intel_dp_to_dev(intel_dp);
1185
	struct drm_i915_private *dev_priv = dev->dev_private;
1083
	struct drm_i915_private *dev_priv = dev->dev_private;
1186
	u32 pp;
1084
	u32 pp;
-
 
1085
	u32 pp_ctrl_reg;
Line 1187... Line 1086...
1187
 
1086
 
1188
	if (!is_edp(intel_dp))
1087
	if (!is_edp(intel_dp))
Line 1189... Line 1088...
1189
		return;
1088
		return;
Line 1195... Line 1094...
1195
		return;
1094
		return;
1196
	}
1095
	}
Line 1197... Line 1096...
1197
 
1096
 
Line 1198... Line 1097...
1198
	ironlake_wait_panel_power_cycle(intel_dp);
1097
	ironlake_wait_panel_power_cycle(intel_dp);
1199
 
1098
 
1200
	pp = ironlake_get_pp_control(dev_priv);
1099
	pp = ironlake_get_pp_control(intel_dp);
1201
	if (IS_GEN5(dev)) {
1100
	if (IS_GEN5(dev)) {
1202
	/* ILK workaround: disable reset around power sequence */
1101
	/* ILK workaround: disable reset around power sequence */
1203
	pp &= ~PANEL_POWER_RESET;
1102
	pp &= ~PANEL_POWER_RESET;
Line 1207... Line 1106...
1207
 
1106
 
1208
	pp |= POWER_TARGET_ON;
1107
	pp |= POWER_TARGET_ON;
1209
	if (!IS_GEN5(dev))
1108
	if (!IS_GEN5(dev))
Line -... Line 1109...
-
 
1109
		pp |= PANEL_POWER_RESET;
-
 
1110
 
1210
		pp |= PANEL_POWER_RESET;
1111
	pp_ctrl_reg = IS_VALLEYVIEW(dev) ? PIPEA_PP_CONTROL : PCH_PP_CONTROL;
1211
 
1112
 
Line 1212... Line 1113...
1212
	I915_WRITE(PCH_PP_CONTROL, pp);
1113
	I915_WRITE(pp_ctrl_reg, pp);
Line 1213... Line 1114...
1213
	POSTING_READ(PCH_PP_CONTROL);
1114
	POSTING_READ(pp_ctrl_reg);
1214
 
1115
 
Line 1224... Line 1125...
1224
void ironlake_edp_panel_off(struct intel_dp *intel_dp)
1125
void ironlake_edp_panel_off(struct intel_dp *intel_dp)
1225
{
1126
{
1226
	struct drm_device *dev = intel_dp_to_dev(intel_dp);
1127
	struct drm_device *dev = intel_dp_to_dev(intel_dp);
1227
	struct drm_i915_private *dev_priv = dev->dev_private;
1128
	struct drm_i915_private *dev_priv = dev->dev_private;
1228
	u32 pp;
1129
	u32 pp;
-
 
1130
	u32 pp_ctrl_reg;
Line 1229... Line 1131...
1229
 
1131
 
1230
	if (!is_edp(intel_dp))
1132
	if (!is_edp(intel_dp))
Line 1231... Line 1133...
1231
		return;
1133
		return;
Line 1232... Line 1134...
1232
 
1134
 
Line 1233... Line 1135...
1233
	DRM_DEBUG_KMS("Turn eDP power off\n");
1135
	DRM_DEBUG_KMS("Turn eDP power off\n");
1234
 
1136
 
1235
	WARN(!intel_dp->want_panel_vdd, "Need VDD to turn off panel\n");
1137
	WARN(!intel_dp->want_panel_vdd, "Need VDD to turn off panel\n");
1236
 
1138
 
-
 
1139
	pp = ironlake_get_pp_control(intel_dp);
-
 
1140
	/* We need to switch off panel power _and_ force vdd, for otherwise some
-
 
1141
	 * panels get very unhappy and cease to work. */
1237
	pp = ironlake_get_pp_control(dev_priv);
1142
	pp &= ~(POWER_TARGET_ON | EDP_FORCE_VDD | PANEL_POWER_RESET | EDP_BLC_ENABLE);
1238
	/* We need to switch off panel power _and_ force vdd, for otherwise some
1143
 
Line 1239... Line 1144...
1239
	 * panels get very unhappy and cease to work. */
1144
	pp_ctrl_reg = IS_VALLEYVIEW(dev) ? PIPEA_PP_CONTROL : PCH_PP_CONTROL;
Line 1240... Line 1145...
1240
	pp &= ~(POWER_TARGET_ON | EDP_FORCE_VDD | PANEL_POWER_RESET | EDP_BLC_ENABLE);
1145
 
1241
	I915_WRITE(PCH_PP_CONTROL, pp);
1146
	I915_WRITE(pp_ctrl_reg, pp);
Line 1251... Line 1156...
1251
	struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
1156
	struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
1252
	struct drm_device *dev = intel_dig_port->base.base.dev;
1157
	struct drm_device *dev = intel_dig_port->base.base.dev;
1253
	struct drm_i915_private *dev_priv = dev->dev_private;
1158
	struct drm_i915_private *dev_priv = dev->dev_private;
1254
	int pipe = to_intel_crtc(intel_dig_port->base.base.crtc)->pipe;
1159
	int pipe = to_intel_crtc(intel_dig_port->base.base.crtc)->pipe;
1255
	u32 pp;
1160
	u32 pp;
-
 
1161
	u32 pp_ctrl_reg;
Line 1256... Line 1162...
1256
 
1162
 
1257
	if (!is_edp(intel_dp))
1163
	if (!is_edp(intel_dp))
Line 1258... Line 1164...
1258
		return;
1164
		return;
Line 1263... Line 1169...
1263
	 * on, we may see slight flicker as the panel syncs with the eDP
1169
	 * on, we may see slight flicker as the panel syncs with the eDP
1264
	 * link.  So delay a bit to make sure the image is solid before
1170
	 * link.  So delay a bit to make sure the image is solid before
1265
	 * allowing it to appear.
1171
	 * allowing it to appear.
1266
	 */
1172
	 */
1267
	msleep(intel_dp->backlight_on_delay);
1173
	msleep(intel_dp->backlight_on_delay);
1268
	pp = ironlake_get_pp_control(dev_priv);
1174
	pp = ironlake_get_pp_control(intel_dp);
1269
	pp |= EDP_BLC_ENABLE;
1175
	pp |= EDP_BLC_ENABLE;
-
 
1176
 
-
 
1177
	pp_ctrl_reg = IS_VALLEYVIEW(dev) ? PIPEA_PP_CONTROL : PCH_PP_CONTROL;
-
 
1178
 
1270
	I915_WRITE(PCH_PP_CONTROL, pp);
1179
	I915_WRITE(pp_ctrl_reg, pp);
1271
	POSTING_READ(PCH_PP_CONTROL);
1180
	POSTING_READ(pp_ctrl_reg);
Line 1272... Line 1181...
1272
 
1181
 
1273
	intel_panel_enable_backlight(dev, pipe);
1182
	intel_panel_enable_backlight(dev, pipe);
Line 1274... Line 1183...
1274
}
1183
}
1275
 
1184
 
1276
void ironlake_edp_backlight_off(struct intel_dp *intel_dp)
1185
void ironlake_edp_backlight_off(struct intel_dp *intel_dp)
1277
{
1186
{
1278
	struct drm_device *dev = intel_dp_to_dev(intel_dp);
1187
	struct drm_device *dev = intel_dp_to_dev(intel_dp);
-
 
1188
	struct drm_i915_private *dev_priv = dev->dev_private;
Line 1279... Line 1189...
1279
	struct drm_i915_private *dev_priv = dev->dev_private;
1189
	u32 pp;
1280
	u32 pp;
1190
	u32 pp_ctrl_reg;
Line 1281... Line 1191...
1281
 
1191
 
Line 1282... Line 1192...
1282
	if (!is_edp(intel_dp))
1192
	if (!is_edp(intel_dp))
1283
		return;
1193
		return;
1284
 
1194
 
-
 
1195
	intel_panel_disable_backlight(dev);
-
 
1196
 
-
 
1197
	DRM_DEBUG_KMS("\n");
1285
	intel_panel_disable_backlight(dev);
1198
	pp = ironlake_get_pp_control(intel_dp);
1286
 
1199
	pp &= ~EDP_BLC_ENABLE;
1287
	DRM_DEBUG_KMS("\n");
1200
 
1288
	pp = ironlake_get_pp_control(dev_priv);
1201
	pp_ctrl_reg = IS_VALLEYVIEW(dev) ? PIPEA_PP_CONTROL : PCH_PP_CONTROL;
Line 1289... Line 1202...
1289
	pp &= ~EDP_BLC_ENABLE;
1202
 
1290
	I915_WRITE(PCH_PP_CONTROL, pp);
1203
	I915_WRITE(pp_ctrl_reg, pp);
Line 1382... Line 1295...
1382
	u32 tmp = I915_READ(intel_dp->output_reg);
1295
	u32 tmp = I915_READ(intel_dp->output_reg);
Line 1383... Line 1296...
1383
 
1296
 
1384
	if (!(tmp & DP_PORT_EN))
1297
	if (!(tmp & DP_PORT_EN))
Line 1385... Line 1298...
1385
		return false;
1298
		return false;
1386
 
1299
 
1387
	if (is_cpu_edp(intel_dp) && IS_GEN7(dev)) {
1300
	if (is_cpu_edp(intel_dp) && IS_GEN7(dev) && !IS_VALLEYVIEW(dev)) {
1388
		*pipe = PORT_TO_PIPE_CPT(tmp);
1301
		*pipe = PORT_TO_PIPE_CPT(tmp);
1389
	} else if (!HAS_PCH_CPT(dev) || is_cpu_edp(intel_dp)) {
1302
	} else if (!HAS_PCH_CPT(dev) || is_cpu_edp(intel_dp)) {
1390
		*pipe = PORT_TO_PIPE(tmp);
1303
		*pipe = PORT_TO_PIPE(tmp);
Line 1439... Line 1352...
1439
}
1352
}
Line 1440... Line 1353...
1440
 
1353
 
1441
static void intel_post_disable_dp(struct intel_encoder *encoder)
1354
static void intel_post_disable_dp(struct intel_encoder *encoder)
1442
{
1355
{
-
 
1356
	struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base);
Line 1443... Line 1357...
1443
	struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base);
1357
	struct drm_device *dev = encoder->base.dev;
1444
 
1358
 
-
 
1359
	if (is_cpu_edp(intel_dp)) {
1445
	if (is_cpu_edp(intel_dp)) {
1360
		intel_dp_link_down(intel_dp);
1446
		intel_dp_link_down(intel_dp);
1361
		if (!IS_VALLEYVIEW(dev))
1447
		ironlake_edp_pll_off(intel_dp);
1362
		ironlake_edp_pll_off(intel_dp);
Line 1448... Line 1363...
1448
	}
1363
	}
Line 1462... Line 1377...
1462
	intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON);
1377
	intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON);
1463
			intel_dp_start_link_train(intel_dp);
1378
			intel_dp_start_link_train(intel_dp);
1464
				ironlake_edp_panel_on(intel_dp);
1379
				ironlake_edp_panel_on(intel_dp);
1465
			ironlake_edp_panel_vdd_off(intel_dp, true);
1380
			ironlake_edp_panel_vdd_off(intel_dp, true);
1466
			intel_dp_complete_link_train(intel_dp);
1381
			intel_dp_complete_link_train(intel_dp);
-
 
1382
	intel_dp_stop_link_train(intel_dp);
1467
		ironlake_edp_backlight_on(intel_dp);
1383
		ironlake_edp_backlight_on(intel_dp);
1468
}
1384
}
Line 1469... Line 1385...
1469
 
1385
 
1470
static void intel_pre_enable_dp(struct intel_encoder *encoder)
1386
static void intel_pre_enable_dp(struct intel_encoder *encoder)
1471
{
1387
{
-
 
1388
	struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base);
Line 1472... Line 1389...
1472
	struct intel_dp *intel_dp = enc_to_intel_dp(&encoder->base);
1389
	struct drm_device *dev = encoder->base.dev;
1473
 
1390
 
1474
	if (is_cpu_edp(intel_dp))
1391
	if (is_cpu_edp(intel_dp) && !IS_VALLEYVIEW(dev))
Line 1475... Line 1392...
1475
		ironlake_edp_pll_on(intel_dp);
1392
		ironlake_edp_pll_on(intel_dp);
1476
}
1393
}
Line 1546... Line 1463...
1546
static uint8_t
1463
static uint8_t
1547
intel_dp_pre_emphasis_max(struct intel_dp *intel_dp, uint8_t voltage_swing)
1464
intel_dp_pre_emphasis_max(struct intel_dp *intel_dp, uint8_t voltage_swing)
1548
{
1465
{
1549
	struct drm_device *dev = intel_dp_to_dev(intel_dp);
1466
	struct drm_device *dev = intel_dp_to_dev(intel_dp);
Line 1550... Line 1467...
1550
 
1467
 
1551
	if (IS_HASWELL(dev)) {
1468
	if (HAS_DDI(dev)) {
1552
		switch (voltage_swing & DP_TRAIN_VOLTAGE_SWING_MASK) {
1469
		switch (voltage_swing & DP_TRAIN_VOLTAGE_SWING_MASK) {
1553
		case DP_TRAIN_VOLTAGE_SWING_400:
1470
		case DP_TRAIN_VOLTAGE_SWING_400:
1554
			return DP_TRAIN_PRE_EMPHASIS_9_5;
1471
			return DP_TRAIN_PRE_EMPHASIS_9_5;
1555
		case DP_TRAIN_VOLTAGE_SWING_600:
1472
		case DP_TRAIN_VOLTAGE_SWING_600:
Line 1754... Line 1671...
1754
	struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
1671
	struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
1755
	struct drm_device *dev = intel_dig_port->base.base.dev;
1672
	struct drm_device *dev = intel_dig_port->base.base.dev;
1756
	uint32_t signal_levels, mask;
1673
	uint32_t signal_levels, mask;
1757
	uint8_t train_set = intel_dp->train_set[0];
1674
	uint8_t train_set = intel_dp->train_set[0];
Line 1758... Line 1675...
1758
 
1675
 
1759
	if (IS_HASWELL(dev)) {
1676
	if (HAS_DDI(dev)) {
1760
		signal_levels = intel_hsw_signal_levels(train_set);
1677
		signal_levels = intel_hsw_signal_levels(train_set);
1761
		mask = DDI_BUF_EMP_MASK;
1678
		mask = DDI_BUF_EMP_MASK;
1762
	} else if (IS_GEN7(dev) && is_cpu_edp(intel_dp) && !IS_VALLEYVIEW(dev)) {
1679
	} else if (IS_GEN7(dev) && is_cpu_edp(intel_dp) && !IS_VALLEYVIEW(dev)) {
1763
		signal_levels = intel_gen7_edp_signal_levels(train_set);
1680
		signal_levels = intel_gen7_edp_signal_levels(train_set);
Line 1783... Line 1700...
1783
	struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
1700
	struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
1784
	struct drm_device *dev = intel_dig_port->base.base.dev;
1701
	struct drm_device *dev = intel_dig_port->base.base.dev;
1785
	struct drm_i915_private *dev_priv = dev->dev_private;
1702
	struct drm_i915_private *dev_priv = dev->dev_private;
1786
	enum port port = intel_dig_port->port;
1703
	enum port port = intel_dig_port->port;
1787
	int ret;
1704
	int ret;
1788
	uint32_t temp;
-
 
Line 1789... Line 1705...
1789
 
1705
 
1790
	if (IS_HASWELL(dev)) {
1706
	if (HAS_DDI(dev)) {
Line 1791... Line 1707...
1791
		temp = I915_READ(DP_TP_CTL(port));
1707
		uint32_t temp = I915_READ(DP_TP_CTL(port));
1792
 
1708
 
1793
		if (dp_train_pat & DP_LINK_SCRAMBLING_DISABLE)
1709
		if (dp_train_pat & DP_LINK_SCRAMBLING_DISABLE)
1794
			temp |= DP_TP_CTL_SCRAMBLE_DISABLE;
1710
			temp |= DP_TP_CTL_SCRAMBLE_DISABLE;
Line 1795... Line 1711...
1795
		else
1711
		else
1796
			temp &= ~DP_TP_CTL_SCRAMBLE_DISABLE;
1712
			temp &= ~DP_TP_CTL_SCRAMBLE_DISABLE;
1797
 
1713
 
1798
		temp &= ~DP_TP_CTL_LINK_TRAIN_MASK;
-
 
1799
		switch (dp_train_pat & DP_TRAINING_PATTERN_MASK) {
-
 
1800
		case DP_TRAINING_PATTERN_DISABLE:
-
 
1801
 
-
 
1802
			if (port != PORT_A) {
-
 
1803
			temp |= DP_TP_CTL_LINK_TRAIN_IDLE;
-
 
1804
			I915_WRITE(DP_TP_CTL(port), temp);
-
 
1805
 
-
 
1806
			if (wait_for((I915_READ(DP_TP_STATUS(port)) &
-
 
1807
				      DP_TP_STATUS_IDLE_DONE), 1))
-
 
1808
				DRM_ERROR("Timed out waiting for DP idle patterns\n");
-
 
1809
 
-
 
1810
			temp &= ~DP_TP_CTL_LINK_TRAIN_MASK;
1714
		temp &= ~DP_TP_CTL_LINK_TRAIN_MASK;
Line 1811... Line 1715...
1811
			}
1715
		switch (dp_train_pat & DP_TRAINING_PATTERN_MASK) {
1812
 
1716
		case DP_TRAINING_PATTERN_DISABLE:
1813
			temp |= DP_TP_CTL_LINK_TRAIN_NORMAL;
1717
			temp |= DP_TP_CTL_LINK_TRAIN_NORMAL;
Line 1883... Line 1787...
1883
	}
1787
	}
Line 1884... Line 1788...
1884
 
1788
 
1885
	return true;
1789
	return true;
Line -... Line 1790...
-
 
1790
}
-
 
1791
 
-
 
1792
static void intel_dp_set_idle_link_train(struct intel_dp *intel_dp)
-
 
1793
{
-
 
1794
	struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
-
 
1795
	struct drm_device *dev = intel_dig_port->base.base.dev;
-
 
1796
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
1797
	enum port port = intel_dig_port->port;
-
 
1798
	uint32_t val;
-
 
1799
 
-
 
1800
	if (!HAS_DDI(dev))
-
 
1801
		return;
-
 
1802
 
-
 
1803
	val = I915_READ(DP_TP_CTL(port));
-
 
1804
	val &= ~DP_TP_CTL_LINK_TRAIN_MASK;
-
 
1805
	val |= DP_TP_CTL_LINK_TRAIN_IDLE;
-
 
1806
	I915_WRITE(DP_TP_CTL(port), val);
-
 
1807
 
-
 
1808
	/*
-
 
1809
	 * On PORT_A we can have only eDP in SST mode. There the only reason
-
 
1810
	 * we need to set idle transmission mode is to work around a HW issue
-
 
1811
	 * where we enable the pipe while not in idle link-training mode.
-
 
1812
	 * In this case there is requirement to wait for a minimum number of
-
 
1813
	 * idle patterns to be sent.
-
 
1814
	 */
-
 
1815
	if (port == PORT_A)
-
 
1816
		return;
-
 
1817
 
-
 
1818
	if (wait_for((I915_READ(DP_TP_STATUS(port)) & DP_TP_STATUS_IDLE_DONE),
-
 
1819
		     1))
-
 
1820
		DRM_ERROR("Timed out waiting for DP idle patterns\n");
1886
}
1821
}
1887
 
1822
 
1888
/* Enable corresponding port and start training pattern 1 */
1823
/* Enable corresponding port and start training pattern 1 */
1889
void
1824
void
1890
intel_dp_start_link_train(struct intel_dp *intel_dp)
1825
intel_dp_start_link_train(struct intel_dp *intel_dp)
Line 2025... Line 1960...
2025
		/* Compute new intel_dp->train_set as requested by target */
1960
		/* Compute new intel_dp->train_set as requested by target */
2026
		intel_get_adjust_train(intel_dp, link_status);
1961
		intel_get_adjust_train(intel_dp, link_status);
2027
		++tries;
1962
		++tries;
2028
	}
1963
	}
Line -... Line 1964...
-
 
1964
 
-
 
1965
	intel_dp_set_idle_link_train(intel_dp);
-
 
1966
 
-
 
1967
	intel_dp->DP = DP;
2029
 
1968
 
2030
	if (channel_eq)
1969
	if (channel_eq)
-
 
1970
		DRM_DEBUG_KMS("Channel EQ done. DP Training successful\n");
-
 
1971
 
Line -... Line 1972...
-
 
1972
}
-
 
1973
 
2031
		DRM_DEBUG_KMS("Channel EQ done. DP Training successfull\n");
1974
void intel_dp_stop_link_train(struct intel_dp *intel_dp)
-
 
1975
{
2032
 
1976
	intel_dp_set_link_train(intel_dp, intel_dp->DP,
Line 2033... Line 1977...
2033
	intel_dp_set_link_train(intel_dp, DP, DP_TRAINING_PATTERN_DISABLE);
1977
				DP_TRAINING_PATTERN_DISABLE);
2034
}
1978
}
2035
 
1979
 
Line 2236... Line 2180...
2236
	if (!drm_dp_channel_eq_ok(link_status, intel_dp->lane_count)) {
2180
	if (!drm_dp_channel_eq_ok(link_status, intel_dp->lane_count)) {
2237
		DRM_DEBUG_KMS("%s: channel EQ not ok, retraining\n",
2181
		DRM_DEBUG_KMS("%s: channel EQ not ok, retraining\n",
2238
			      drm_get_encoder_name(&intel_encoder->base));
2182
			      drm_get_encoder_name(&intel_encoder->base));
2239
		intel_dp_start_link_train(intel_dp);
2183
		intel_dp_start_link_train(intel_dp);
2240
		intel_dp_complete_link_train(intel_dp);
2184
		intel_dp_complete_link_train(intel_dp);
-
 
2185
		intel_dp_stop_link_train(intel_dp);
2241
	}
2186
	}
2242
}
2187
}
Line 2243... Line 2188...
2243
 
2188
 
2244
/* XXX this is probably wrong for multiple downstream ports */
2189
/* XXX this is probably wrong for multiple downstream ports */
Line 2309... Line 2254...
2309
	struct drm_device *dev = intel_dp_to_dev(intel_dp);
2254
	struct drm_device *dev = intel_dp_to_dev(intel_dp);
2310
	struct drm_i915_private *dev_priv = dev->dev_private;
2255
	struct drm_i915_private *dev_priv = dev->dev_private;
2311
	struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
2256
	struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
2312
	uint32_t bit;
2257
	uint32_t bit;
Line -... Line 2258...
-
 
2258
 
-
 
2259
	/* Can't disconnect eDP, but you can close the lid... */
-
 
2260
	if (is_edp(intel_dp)) {
-
 
2261
		enum drm_connector_status status;
-
 
2262
 
-
 
2263
		status = intel_panel_detect(dev);
-
 
2264
		if (status == connector_status_unknown)
-
 
2265
			status = connector_status_connected;
-
 
2266
		return status;
-
 
2267
	}
2313
 
2268
 
2314
	switch (intel_dig_port->port) {
2269
	switch (intel_dig_port->port) {
2315
	case PORT_B:
2270
	case PORT_B:
2316
		bit = PORTB_HOTPLUG_LIVE_STATUS;
2271
		bit = PORTB_HOTPLUG_LIVE_STATUS;
2317
		break;
2272
		break;
Line 2490... Line 2445...
2490
		intel_dp->has_audio = has_audio;
2445
		intel_dp->has_audio = has_audio;
2491
		goto done;
2446
		goto done;
2492
	}
2447
	}
Line 2493... Line 2448...
2493
 
2448
 
-
 
2449
	if (property == dev_priv->broadcast_rgb_property) {
-
 
2450
		bool old_auto = intel_dp->color_range_auto;
-
 
2451
		uint32_t old_range = intel_dp->color_range;
2494
	if (property == dev_priv->broadcast_rgb_property) {
2452
 
2495
		switch (val) {
2453
		switch (val) {
2496
		case INTEL_BROADCAST_RGB_AUTO:
2454
		case INTEL_BROADCAST_RGB_AUTO:
2497
			intel_dp->color_range_auto = true;
2455
			intel_dp->color_range_auto = true;
2498
			break;
2456
			break;
Line 2505... Line 2463...
2505
			intel_dp->color_range = DP_COLOR_RANGE_16_235;
2463
			intel_dp->color_range = DP_COLOR_RANGE_16_235;
2506
			break;
2464
			break;
2507
		default:
2465
		default:
2508
			return -EINVAL;
2466
			return -EINVAL;
2509
		}
2467
		}
-
 
2468
 
-
 
2469
		if (old_auto == intel_dp->color_range_auto &&
-
 
2470
		    old_range == intel_dp->color_range)
-
 
2471
			return 0;
-
 
2472
 
2510
	goto done;
2473
	goto done;
2511
	}
2474
	}
Line 2512... Line 2475...
2512
 
2475
 
2513
	if (is_edp(intel_dp) &&
2476
	if (is_edp(intel_dp) &&
Line 2536... Line 2499...
2536
}
2499
}
Line 2537... Line 2500...
2537
 
2500
 
2538
static void
2501
static void
2539
intel_dp_destroy(struct drm_connector *connector)
2502
intel_dp_destroy(struct drm_connector *connector)
2540
{
-
 
2541
	struct drm_device *dev = connector->dev;
2503
{
2542
	struct intel_dp *intel_dp = intel_attached_dp(connector);
2504
	struct intel_dp *intel_dp = intel_attached_dp(connector);
Line 2543... Line 2505...
2543
	struct intel_connector *intel_connector = to_intel_connector(connector);
2505
	struct intel_connector *intel_connector = to_intel_connector(connector);
2544
 
2506
 
Line 2545... Line 2507...
2545
	if (!IS_ERR_OR_NULL(intel_connector->edid))
2507
	if (!IS_ERR_OR_NULL(intel_connector->edid))
2546
		kfree(intel_connector->edid);
-
 
2547
 
2508
		kfree(intel_connector->edid);
2548
	if (is_edp(intel_dp)) {
-
 
Line 2549... Line 2509...
2549
		intel_panel_destroy_backlight(dev);
2509
 
2550
		intel_panel_fini(&intel_connector->panel);
2510
	if (is_edp(intel_dp))
2551
	}
2511
		intel_panel_fini(&intel_connector->panel);
2552
 
2512
 
Line 2571... Line 2531...
2571
	}
2531
	}
2572
	kfree(intel_dig_port);
2532
	kfree(intel_dig_port);
2573
}
2533
}
Line 2574... Line 2534...
2574
 
2534
 
2575
static const struct drm_encoder_helper_funcs intel_dp_helper_funcs = {
-
 
2576
	.mode_fixup = intel_dp_mode_fixup,
2535
static const struct drm_encoder_helper_funcs intel_dp_helper_funcs = {
2577
	.mode_set = intel_dp_mode_set,
2536
	.mode_set = intel_dp_mode_set,
Line 2578... Line 2537...
2578
};
2537
};
2579
 
2538
 
Line 2667... Line 2626...
2667
				    struct edp_power_seq *out)
2626
				    struct edp_power_seq *out)
2668
{
2627
{
2669
	struct drm_i915_private *dev_priv = dev->dev_private;
2628
	struct drm_i915_private *dev_priv = dev->dev_private;
2670
	struct edp_power_seq cur, vbt, spec, final;
2629
	struct edp_power_seq cur, vbt, spec, final;
2671
	u32 pp_on, pp_off, pp_div, pp;
2630
	u32 pp_on, pp_off, pp_div, pp;
-
 
2631
	int pp_control_reg, pp_on_reg, pp_off_reg, pp_div_reg;
-
 
2632
 
-
 
2633
	if (HAS_PCH_SPLIT(dev)) {
-
 
2634
		pp_control_reg = PCH_PP_CONTROL;
-
 
2635
		pp_on_reg = PCH_PP_ON_DELAYS;
-
 
2636
		pp_off_reg = PCH_PP_OFF_DELAYS;
-
 
2637
		pp_div_reg = PCH_PP_DIVISOR;
-
 
2638
	} else {
-
 
2639
		pp_control_reg = PIPEA_PP_CONTROL;
-
 
2640
		pp_on_reg = PIPEA_PP_ON_DELAYS;
-
 
2641
		pp_off_reg = PIPEA_PP_OFF_DELAYS;
-
 
2642
		pp_div_reg = PIPEA_PP_DIVISOR;
-
 
2643
	}
Line 2672... Line 2644...
2672
 
2644
 
2673
	/* Workaround: Need to write PP_CONTROL with the unlock key as
2645
	/* Workaround: Need to write PP_CONTROL with the unlock key as
2674
	 * the very first thing. */
2646
	 * the very first thing. */
2675
	pp = ironlake_get_pp_control(dev_priv);
2647
	pp = ironlake_get_pp_control(intel_dp);
Line 2676... Line 2648...
2676
	I915_WRITE(PCH_PP_CONTROL, pp);
2648
	I915_WRITE(pp_control_reg, pp);
2677
 
2649
 
2678
	pp_on = I915_READ(PCH_PP_ON_DELAYS);
2650
	pp_on = I915_READ(pp_on_reg);
Line 2679... Line 2651...
2679
	pp_off = I915_READ(PCH_PP_OFF_DELAYS);
2651
	pp_off = I915_READ(pp_off_reg);
2680
	pp_div = I915_READ(PCH_PP_DIVISOR);
2652
	pp_div = I915_READ(pp_div_reg);
2681
 
2653
 
Line 2750... Line 2722...
2750
intel_dp_init_panel_power_sequencer_registers(struct drm_device *dev,
2722
intel_dp_init_panel_power_sequencer_registers(struct drm_device *dev,
2751
					      struct intel_dp *intel_dp,
2723
					      struct intel_dp *intel_dp,
2752
					      struct edp_power_seq *seq)
2724
					      struct edp_power_seq *seq)
2753
{
2725
{
2754
	struct drm_i915_private *dev_priv = dev->dev_private;
2726
	struct drm_i915_private *dev_priv = dev->dev_private;
2755
	u32 pp_on, pp_off, pp_div;
2727
	u32 pp_on, pp_off, pp_div, port_sel = 0;
-
 
2728
	int div = HAS_PCH_SPLIT(dev) ? intel_pch_rawclk(dev) : intel_hrawclk(dev);
-
 
2729
	int pp_on_reg, pp_off_reg, pp_div_reg;
-
 
2730
 
-
 
2731
	if (HAS_PCH_SPLIT(dev)) {
-
 
2732
		pp_on_reg = PCH_PP_ON_DELAYS;
-
 
2733
		pp_off_reg = PCH_PP_OFF_DELAYS;
-
 
2734
		pp_div_reg = PCH_PP_DIVISOR;
-
 
2735
	} else {
-
 
2736
		pp_on_reg = PIPEA_PP_ON_DELAYS;
-
 
2737
		pp_off_reg = PIPEA_PP_OFF_DELAYS;
-
 
2738
		pp_div_reg = PIPEA_PP_DIVISOR;
-
 
2739
	}
-
 
2740
 
-
 
2741
	if (IS_VALLEYVIEW(dev))
-
 
2742
		port_sel = I915_READ(pp_on_reg) & 0xc0000000;
Line 2756... Line 2743...
2756
 
2743
 
2757
	/* And finally store the new values in the power sequencer. */
2744
	/* And finally store the new values in the power sequencer. */
2758
	pp_on = (seq->t1_t3 << PANEL_POWER_UP_DELAY_SHIFT) |
2745
	pp_on = (seq->t1_t3 << PANEL_POWER_UP_DELAY_SHIFT) |
2759
		(seq->t8 << PANEL_LIGHT_ON_DELAY_SHIFT);
2746
		(seq->t8 << PANEL_LIGHT_ON_DELAY_SHIFT);
2760
	pp_off = (seq->t9 << PANEL_LIGHT_OFF_DELAY_SHIFT) |
2747
	pp_off = (seq->t9 << PANEL_LIGHT_OFF_DELAY_SHIFT) |
2761
		 (seq->t10 << PANEL_POWER_DOWN_DELAY_SHIFT);
2748
		 (seq->t10 << PANEL_POWER_DOWN_DELAY_SHIFT);
2762
	/* Compute the divisor for the pp clock, simply match the Bspec
2749
	/* Compute the divisor for the pp clock, simply match the Bspec
2763
	 * formula. */
-
 
2764
	pp_div = ((100 * intel_pch_rawclk(dev))/2 - 1)
2750
	 * formula. */
2765
			<< PP_REFERENCE_DIVIDER_SHIFT;
2751
	pp_div = ((100 * div)/2 - 1) << PP_REFERENCE_DIVIDER_SHIFT;
2766
	pp_div |= (DIV_ROUND_UP(seq->t11_t12, 1000)
2752
	pp_div |= (DIV_ROUND_UP(seq->t11_t12, 1000)
Line 2767... Line 2753...
2767
			<< PANEL_POWER_CYCLE_DELAY_SHIFT);
2753
			<< PANEL_POWER_CYCLE_DELAY_SHIFT);
2768
 
2754
 
2769
	/* Haswell doesn't have any port selection bits for the panel
2755
	/* Haswell doesn't have any port selection bits for the panel
2770
	 * power sequencer any more. */
2756
	 * power sequencer any more. */
2771
	if (HAS_PCH_IBX(dev) || HAS_PCH_CPT(dev)) {
2757
	if (HAS_PCH_IBX(dev) || HAS_PCH_CPT(dev)) {
2772
		if (is_cpu_edp(intel_dp))
2758
		if (is_cpu_edp(intel_dp))
2773
			pp_on |= PANEL_POWER_PORT_DP_A;
2759
			port_sel = PANEL_POWER_PORT_DP_A;
2774
		else
2760
		else
Line -... Line 2761...
-
 
2761
			port_sel = PANEL_POWER_PORT_DP_D;
-
 
2762
	}
2775
			pp_on |= PANEL_POWER_PORT_DP_D;
2763
 
2776
	}
2764
	pp_on |= port_sel;
2777
 
2765
 
Line 2778... Line 2766...
2778
	I915_WRITE(PCH_PP_ON_DELAYS, pp_on);
2766
	I915_WRITE(pp_on_reg, pp_on);
2779
	I915_WRITE(PCH_PP_OFF_DELAYS, pp_off);
2767
	I915_WRITE(pp_off_reg, pp_off);
2780
	I915_WRITE(PCH_PP_DIVISOR, pp_div);
2768
	I915_WRITE(pp_div_reg, pp_div);
2781
 
2769
 
2782
	DRM_DEBUG_KMS("panel power sequencer register settings: PP_ON %#x, PP_OFF %#x, PP_DIV %#x\n",
2770
	DRM_DEBUG_KMS("panel power sequencer register settings: PP_ON %#x, PP_OFF %#x, PP_DIV %#x\n",
Line 2783... Line 2771...
2783
		      I915_READ(PCH_PP_ON_DELAYS),
2771
		      I915_READ(pp_on_reg),
2784
		      I915_READ(PCH_PP_OFF_DELAYS),
2772
		      I915_READ(pp_off_reg),
2785
		      I915_READ(PCH_PP_DIVISOR));
2773
		      I915_READ(pp_div_reg));
Line 2827... Line 2815...
2827
	}
2815
	}
Line 2828... Line 2816...
2828
 
2816
 
2829
	drm_connector_init(dev, connector, &intel_dp_connector_funcs, type);
2817
	drm_connector_init(dev, connector, &intel_dp_connector_funcs, type);
Line 2830... Line -...
2830
	drm_connector_helper_add(connector, &intel_dp_connector_helper_funcs);
-
 
2831
 
2818
	drm_connector_helper_add(connector, &intel_dp_connector_helper_funcs);
2832
	connector->polled = DRM_CONNECTOR_POLL_HPD;
2819
 
Line 2833... Line 2820...
2833
	connector->interlace_allowed = true;
2820
	connector->interlace_allowed = true;
2834
	connector->doublescan_allowed = 0;
2821
	connector->doublescan_allowed = 0;
Line 2842... Line 2829...
2842
	if (HAS_DDI(dev))
2829
	if (HAS_DDI(dev))
2843
		intel_connector->get_hw_state = intel_ddi_connector_get_hw_state;
2830
		intel_connector->get_hw_state = intel_ddi_connector_get_hw_state;
2844
	else
2831
	else
2845
	intel_connector->get_hw_state = intel_connector_get_hw_state;
2832
	intel_connector->get_hw_state = intel_connector_get_hw_state;
Line -... Line 2833...
-
 
2833
 
-
 
2834
	intel_dp->aux_ch_ctl_reg = intel_dp->output_reg + 0x10;
-
 
2835
	if (HAS_DDI(dev)) {
-
 
2836
		switch (intel_dig_port->port) {
-
 
2837
		case PORT_A:
-
 
2838
			intel_dp->aux_ch_ctl_reg = DPA_AUX_CH_CTL;
-
 
2839
			break;
-
 
2840
		case PORT_B:
-
 
2841
			intel_dp->aux_ch_ctl_reg = PCH_DPB_AUX_CH_CTL;
-
 
2842
			break;
-
 
2843
		case PORT_C:
-
 
2844
			intel_dp->aux_ch_ctl_reg = PCH_DPC_AUX_CH_CTL;
-
 
2845
			break;
-
 
2846
		case PORT_D:
-
 
2847
			intel_dp->aux_ch_ctl_reg = PCH_DPD_AUX_CH_CTL;
-
 
2848
			break;
-
 
2849
		default:
-
 
2850
			BUG();
-
 
2851
		}
Line 2846... Line 2852...
2846
 
2852
	}
2847
 
2853
 
2848
	/* Set up the DDC bus. */
2854
	/* Set up the DDC bus. */
-
 
2855
	switch (port) {
2849
	switch (port) {
2856
	case PORT_A:
2850
	case PORT_A:
2857
		intel_encoder->hpd_pin = HPD_PORT_A;
2851
			name = "DPDDC-A";
2858
			name = "DPDDC-A";
2852
			break;
2859
			break;
2853
	case PORT_B:
2860
	case PORT_B:
2854
		dev_priv->hotplug_supported_mask |= PORTB_HOTPLUG_INT_STATUS;
2861
		intel_encoder->hpd_pin = HPD_PORT_B;
2855
			name = "DPDDC-B";
2862
			name = "DPDDC-B";
2856
			break;
2863
			break;
2857
	case PORT_C:
2864
	case PORT_C:
2858
		dev_priv->hotplug_supported_mask |= PORTC_HOTPLUG_INT_STATUS;
2865
		intel_encoder->hpd_pin = HPD_PORT_C;
2859
			name = "DPDDC-C";
2866
			name = "DPDDC-C";
2860
			break;
2867
			break;
2861
	case PORT_D:
2868
	case PORT_D:
2862
		dev_priv->hotplug_supported_mask |= PORTD_HOTPLUG_INT_STATUS;
2869
		intel_encoder->hpd_pin = HPD_PORT_D;
2863
			name = "DPDDC-D";
2870
			name = "DPDDC-D";
2864
			break;
-
 
2865
	default:
2871
			break;
2866
		WARN(1, "Invalid port %c\n", port_name(port));
2872
	default:
Line 2867... Line 2873...
2867
		break;
2873
		BUG();
2868
	}
2874
	}
Line 2972... Line 2978...
2972
 
2978
 
2973
	drm_encoder_init(dev, &intel_encoder->base, &intel_dp_enc_funcs,
2979
	drm_encoder_init(dev, &intel_encoder->base, &intel_dp_enc_funcs,
2974
			 DRM_MODE_ENCODER_TMDS);
2980
			 DRM_MODE_ENCODER_TMDS);
Line -... Line 2981...
-
 
2981
	drm_encoder_helper_add(&intel_encoder->base, &intel_dp_helper_funcs);
2975
	drm_encoder_helper_add(&intel_encoder->base, &intel_dp_helper_funcs);
2982
 
2976
 
2983
	intel_encoder->compute_config = intel_dp_compute_config;
2977
	intel_encoder->enable = intel_enable_dp;
2984
	intel_encoder->enable = intel_enable_dp;
2978
	intel_encoder->pre_enable = intel_pre_enable_dp;
2985
	intel_encoder->pre_enable = intel_pre_enable_dp;
2979
	intel_encoder->disable = intel_disable_dp;
2986
	intel_encoder->disable = intel_disable_dp;