Subversion Repositories Kolibri OS

Rev

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

Rev 4560 Rev 5060
Line 111... Line 111...
111
		return 0;
111
		return 0;
112
	}
112
	}
113
}
113
}
Line 114... Line 114...
114
 
114
 
115
static u32 hsw_infoframe_data_reg(enum hdmi_infoframe_type type,
115
static u32 hsw_infoframe_data_reg(enum hdmi_infoframe_type type,
-
 
116
				  enum transcoder cpu_transcoder,
116
				  enum transcoder cpu_transcoder)
117
				  struct drm_i915_private *dev_priv)
117
{
118
{
118
	switch (type) {
119
	switch (type) {
119
	case HDMI_INFOFRAME_TYPE_AVI:
120
	case HDMI_INFOFRAME_TYPE_AVI:
120
		return HSW_TVIDEO_DIP_AVI_DATA(cpu_transcoder);
121
		return HSW_TVIDEO_DIP_AVI_DATA(cpu_transcoder);
Line 294... Line 295...
294
	u32 data_reg;
295
	u32 data_reg;
295
	int i;
296
	int i;
296
	u32 val = I915_READ(ctl_reg);
297
	u32 val = I915_READ(ctl_reg);
Line 297... Line 298...
297
 
298
 
298
	data_reg = hsw_infoframe_data_reg(type,
299
	data_reg = hsw_infoframe_data_reg(type,
-
 
300
					  intel_crtc->config.cpu_transcoder,
299
					  intel_crtc->config.cpu_transcoder);
301
					  dev_priv);
300
	if (data_reg == 0)
302
	if (data_reg == 0)
Line 301... Line 303...
301
		return;
303
		return;
302
 
304
 
Line 363... Line 365...
363
	struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder);
365
	struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder);
364
	struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc);
366
	struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc);
365
	union hdmi_infoframe frame;
367
	union hdmi_infoframe frame;
366
	int ret;
368
	int ret;
Line -... Line 369...
-
 
369
 
-
 
370
	/* Set user selected PAR to incoming mode's member */
-
 
371
	adjusted_mode->picture_aspect_ratio = intel_hdmi->aspect_ratio;
367
 
372
 
368
	ret = drm_hdmi_avi_infoframe_from_display_mode(&frame.avi,
373
	ret = drm_hdmi_avi_infoframe_from_display_mode(&frame.avi,
369
						       adjusted_mode);
374
						       adjusted_mode);
370
	if (ret < 0) {
375
	if (ret < 0) {
371
		DRM_ERROR("couldn't fill AVI infoframe\n");
376
		DRM_ERROR("couldn't fill AVI infoframe\n");
Line 414... Line 419...
414
 
419
 
415
	intel_write_infoframe(encoder, &frame);
420
	intel_write_infoframe(encoder, &frame);
Line 416... Line 421...
416
}
421
}
-
 
422
 
417
 
423
static void g4x_set_infoframes(struct drm_encoder *encoder,
418
static void g4x_set_infoframes(struct drm_encoder *encoder,
424
			       bool enable,
419
			       struct drm_display_mode *adjusted_mode)
425
			       struct drm_display_mode *adjusted_mode)
420
{
426
{
421
	struct drm_i915_private *dev_priv = encoder->dev->dev_private;
427
	struct drm_i915_private *dev_priv = encoder->dev->dev_private;
422
	struct intel_digital_port *intel_dig_port = enc_to_dig_port(encoder);
428
	struct intel_digital_port *intel_dig_port = enc_to_dig_port(encoder);
423
	struct intel_hdmi *intel_hdmi = &intel_dig_port->hdmi;
429
	struct intel_hdmi *intel_hdmi = &intel_dig_port->hdmi;
424
	u32 reg = VIDEO_DIP_CTL;
430
	u32 reg = VIDEO_DIP_CTL;
Line 425... Line 431...
425
	u32 val = I915_READ(reg);
431
	u32 val = I915_READ(reg);
Line 426... Line 432...
426
	u32 port;
432
	u32 port = VIDEO_DIP_PORT(intel_dig_port->port);
427
 
433
 
Line 436... Line 442...
436
	 * set its frequency to every VSync. Avoiding to write it twice seems to
442
	 * set its frequency to every VSync. Avoiding to write it twice seems to
437
	 * be enough to solve the problem, but being defensive shouldn't hurt us
443
	 * be enough to solve the problem, but being defensive shouldn't hurt us
438
	 * either. */
444
	 * either. */
439
	val |= VIDEO_DIP_SELECT_AVI | VIDEO_DIP_FREQ_VSYNC;
445
	val |= VIDEO_DIP_SELECT_AVI | VIDEO_DIP_FREQ_VSYNC;
Line 440... Line 446...
440
 
446
 
441
	if (!intel_hdmi->has_hdmi_sink) {
447
	if (!enable) {
442
		if (!(val & VIDEO_DIP_ENABLE))
448
		if (!(val & VIDEO_DIP_ENABLE))
443
			return;
449
			return;
444
		val &= ~VIDEO_DIP_ENABLE;
450
		val &= ~VIDEO_DIP_ENABLE;
445
		I915_WRITE(reg, val);
451
		I915_WRITE(reg, val);
446
		POSTING_READ(reg);
452
		POSTING_READ(reg);
447
		return;
453
		return;
Line 448... Line -...
448
	}
-
 
449
 
-
 
450
	switch (intel_dig_port->port) {
-
 
451
	case PORT_B:
-
 
452
		port = VIDEO_DIP_PORT_B;
-
 
453
		break;
-
 
454
	case PORT_C:
-
 
455
		port = VIDEO_DIP_PORT_C;
-
 
456
		break;
-
 
457
	default:
-
 
458
		BUG();
-
 
459
		return;
-
 
460
	}
454
	}
461
 
455
 
462
	if (port != (val & VIDEO_DIP_PORT_MASK)) {
456
	if (port != (val & VIDEO_DIP_PORT_MASK)) {
463
		if (val & VIDEO_DIP_ENABLE) {
457
		if (val & VIDEO_DIP_ENABLE) {
464
			val &= ~VIDEO_DIP_ENABLE;
458
			val &= ~VIDEO_DIP_ENABLE;
Line 479... Line 473...
479
	intel_hdmi_set_spd_infoframe(encoder);
473
	intel_hdmi_set_spd_infoframe(encoder);
480
	intel_hdmi_set_hdmi_infoframe(encoder, adjusted_mode);
474
	intel_hdmi_set_hdmi_infoframe(encoder, adjusted_mode);
481
}
475
}
Line 482... Line 476...
482
 
476
 
-
 
477
static void ibx_set_infoframes(struct drm_encoder *encoder,
483
static void ibx_set_infoframes(struct drm_encoder *encoder,
478
			       bool enable,
484
			       struct drm_display_mode *adjusted_mode)
479
			       struct drm_display_mode *adjusted_mode)
485
{
480
{
486
	struct drm_i915_private *dev_priv = encoder->dev->dev_private;
481
	struct drm_i915_private *dev_priv = encoder->dev->dev_private;
487
	struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc);
482
	struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc);
488
	struct intel_digital_port *intel_dig_port = enc_to_dig_port(encoder);
483
	struct intel_digital_port *intel_dig_port = enc_to_dig_port(encoder);
489
	struct intel_hdmi *intel_hdmi = &intel_dig_port->hdmi;
484
	struct intel_hdmi *intel_hdmi = &intel_dig_port->hdmi;
490
	u32 reg = TVIDEO_DIP_CTL(intel_crtc->pipe);
485
	u32 reg = TVIDEO_DIP_CTL(intel_crtc->pipe);
491
	u32 val = I915_READ(reg);
486
	u32 val = I915_READ(reg);
Line 492... Line 487...
492
	u32 port;
487
	u32 port = VIDEO_DIP_PORT(intel_dig_port->port);
Line 493... Line 488...
493
 
488
 
494
	assert_hdmi_port_disabled(intel_hdmi);
489
	assert_hdmi_port_disabled(intel_hdmi);
Line 495... Line 490...
495
 
490
 
496
	/* See the big comment in g4x_set_infoframes() */
491
	/* See the big comment in g4x_set_infoframes() */
497
	val |= VIDEO_DIP_SELECT_AVI | VIDEO_DIP_FREQ_VSYNC;
492
	val |= VIDEO_DIP_SELECT_AVI | VIDEO_DIP_FREQ_VSYNC;
498
 
493
 
499
	if (!intel_hdmi->has_hdmi_sink) {
494
	if (!enable) {
500
		if (!(val & VIDEO_DIP_ENABLE))
495
		if (!(val & VIDEO_DIP_ENABLE))
501
			return;
496
			return;
502
		val &= ~VIDEO_DIP_ENABLE;
497
		val &= ~VIDEO_DIP_ENABLE;
Line 503... Line -...
503
		I915_WRITE(reg, val);
-
 
504
		POSTING_READ(reg);
-
 
505
		return;
-
 
506
	}
-
 
507
 
-
 
508
	switch (intel_dig_port->port) {
-
 
509
	case PORT_B:
-
 
510
		port = VIDEO_DIP_PORT_B;
-
 
511
		break;
-
 
512
	case PORT_C:
-
 
513
		port = VIDEO_DIP_PORT_C;
-
 
514
		break;
-
 
515
	case PORT_D:
-
 
516
		port = VIDEO_DIP_PORT_D;
-
 
517
		break;
-
 
518
	default:
498
		I915_WRITE(reg, val);
519
		BUG();
499
		POSTING_READ(reg);
520
		return;
500
		return;
521
	}
501
	}
522
 
502
 
Line 541... Line 521...
541
	intel_hdmi_set_spd_infoframe(encoder);
521
	intel_hdmi_set_spd_infoframe(encoder);
542
	intel_hdmi_set_hdmi_infoframe(encoder, adjusted_mode);
522
	intel_hdmi_set_hdmi_infoframe(encoder, adjusted_mode);
543
}
523
}
Line 544... Line 524...
544
 
524
 
-
 
525
static void cpt_set_infoframes(struct drm_encoder *encoder,
545
static void cpt_set_infoframes(struct drm_encoder *encoder,
526
			       bool enable,
546
			       struct drm_display_mode *adjusted_mode)
527
			       struct drm_display_mode *adjusted_mode)
547
{
528
{
548
	struct drm_i915_private *dev_priv = encoder->dev->dev_private;
529
	struct drm_i915_private *dev_priv = encoder->dev->dev_private;
549
	struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc);
530
	struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc);
Line 554... Line 535...
554
	assert_hdmi_port_disabled(intel_hdmi);
535
	assert_hdmi_port_disabled(intel_hdmi);
Line 555... Line 536...
555
 
536
 
556
	/* See the big comment in g4x_set_infoframes() */
537
	/* See the big comment in g4x_set_infoframes() */
Line 557... Line 538...
557
	val |= VIDEO_DIP_SELECT_AVI | VIDEO_DIP_FREQ_VSYNC;
538
	val |= VIDEO_DIP_SELECT_AVI | VIDEO_DIP_FREQ_VSYNC;
558
 
539
 
559
	if (!intel_hdmi->has_hdmi_sink) {
540
	if (!enable) {
560
		if (!(val & VIDEO_DIP_ENABLE))
541
		if (!(val & VIDEO_DIP_ENABLE))
561
			return;
542
			return;
562
		val &= ~(VIDEO_DIP_ENABLE | VIDEO_DIP_ENABLE_AVI);
543
		val &= ~(VIDEO_DIP_ENABLE | VIDEO_DIP_ENABLE_AVI);
Line 577... Line 558...
577
	intel_hdmi_set_spd_infoframe(encoder);
558
	intel_hdmi_set_spd_infoframe(encoder);
578
	intel_hdmi_set_hdmi_infoframe(encoder, adjusted_mode);
559
	intel_hdmi_set_hdmi_infoframe(encoder, adjusted_mode);
579
}
560
}
Line 580... Line 561...
580
 
561
 
-
 
562
static void vlv_set_infoframes(struct drm_encoder *encoder,
581
static void vlv_set_infoframes(struct drm_encoder *encoder,
563
			       bool enable,
582
			       struct drm_display_mode *adjusted_mode)
564
			       struct drm_display_mode *adjusted_mode)
583
{
565
{
-
 
566
	struct drm_i915_private *dev_priv = encoder->dev->dev_private;
584
	struct drm_i915_private *dev_priv = encoder->dev->dev_private;
567
	struct intel_digital_port *intel_dig_port = enc_to_dig_port(encoder);
585
	struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc);
568
	struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc);
586
	struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder);
569
	struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder);
587
	u32 reg = VLV_TVIDEO_DIP_CTL(intel_crtc->pipe);
570
	u32 reg = VLV_TVIDEO_DIP_CTL(intel_crtc->pipe);
-
 
571
	u32 val = I915_READ(reg);
Line 588... Line 572...
588
	u32 val = I915_READ(reg);
572
	u32 port = VIDEO_DIP_PORT(intel_dig_port->port);
Line 589... Line 573...
589
 
573
 
590
	assert_hdmi_port_disabled(intel_hdmi);
574
	assert_hdmi_port_disabled(intel_hdmi);
Line 591... Line 575...
591
 
575
 
592
	/* See the big comment in g4x_set_infoframes() */
576
	/* See the big comment in g4x_set_infoframes() */
593
	val |= VIDEO_DIP_SELECT_AVI | VIDEO_DIP_FREQ_VSYNC;
577
	val |= VIDEO_DIP_SELECT_AVI | VIDEO_DIP_FREQ_VSYNC;
594
 
578
 
595
	if (!intel_hdmi->has_hdmi_sink) {
579
	if (!enable) {
596
		if (!(val & VIDEO_DIP_ENABLE))
580
		if (!(val & VIDEO_DIP_ENABLE))
597
			return;
581
			return;
598
		val &= ~VIDEO_DIP_ENABLE;
582
		val &= ~VIDEO_DIP_ENABLE;
Line -... Line 583...
-
 
583
		I915_WRITE(reg, val);
-
 
584
		POSTING_READ(reg);
-
 
585
		return;
-
 
586
	}
-
 
587
 
-
 
588
	if (port != (val & VIDEO_DIP_PORT_MASK)) {
-
 
589
		if (val & VIDEO_DIP_ENABLE) {
-
 
590
			val &= ~VIDEO_DIP_ENABLE;
-
 
591
			I915_WRITE(reg, val);
-
 
592
			POSTING_READ(reg);
599
		I915_WRITE(reg, val);
593
		}
600
		POSTING_READ(reg);
594
		val &= ~VIDEO_DIP_PORT_MASK;
601
		return;
595
		val |= port;
Line 602... Line 596...
602
	}
596
	}
603
 
597
 
Line 604... Line 598...
604
	val |= VIDEO_DIP_ENABLE;
598
	val |= VIDEO_DIP_ENABLE;
605
	val &= ~(VIDEO_DIP_ENABLE_VENDOR | VIDEO_DIP_ENABLE_GAMUT |
599
	val &= ~(VIDEO_DIP_ENABLE_AVI | VIDEO_DIP_ENABLE_VENDOR |
606
		 VIDEO_DIP_ENABLE_GCP);
600
		 VIDEO_DIP_ENABLE_GAMUT | VIDEO_DIP_ENABLE_GCP);
607
 
601
 
Line 608... Line 602...
608
	I915_WRITE(reg, val);
602
	I915_WRITE(reg, val);
-
 
603
	POSTING_READ(reg);
609
	POSTING_READ(reg);
604
 
610
 
605
	intel_hdmi_set_avi_infoframe(encoder, adjusted_mode);
611
	intel_hdmi_set_avi_infoframe(encoder, adjusted_mode);
606
	intel_hdmi_set_spd_infoframe(encoder);
612
	intel_hdmi_set_spd_infoframe(encoder);
607
	intel_hdmi_set_hdmi_infoframe(encoder, adjusted_mode);
613
	intel_hdmi_set_hdmi_infoframe(encoder, adjusted_mode);
608
}
614
}
609
 
615
 
610
static void hsw_set_infoframes(struct drm_encoder *encoder,
Line 616... Line 611...
616
static void hsw_set_infoframes(struct drm_encoder *encoder,
611
			       bool enable,
Line 617... Line 612...
617
			       struct drm_display_mode *adjusted_mode)
612
			       struct drm_display_mode *adjusted_mode)
618
{
613
{
619
	struct drm_i915_private *dev_priv = encoder->dev->dev_private;
614
	struct drm_i915_private *dev_priv = encoder->dev->dev_private;
620
	struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc);
615
	struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc);
621
	struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder);
616
	struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder);
Line 639... Line 634...
639
	intel_hdmi_set_avi_infoframe(encoder, adjusted_mode);
634
	intel_hdmi_set_avi_infoframe(encoder, adjusted_mode);
640
	intel_hdmi_set_spd_infoframe(encoder);
635
	intel_hdmi_set_spd_infoframe(encoder);
641
	intel_hdmi_set_hdmi_infoframe(encoder, adjusted_mode);
636
	intel_hdmi_set_hdmi_infoframe(encoder, adjusted_mode);
642
}
637
}
Line 643... Line 638...
643
 
638
 
644
static void intel_hdmi_mode_set(struct intel_encoder *encoder)
639
static void intel_hdmi_prepare(struct intel_encoder *encoder)
645
{
640
{
646
	struct drm_device *dev = encoder->base.dev;
641
	struct drm_device *dev = encoder->base.dev;
647
	struct drm_i915_private *dev_priv = dev->dev_private;
642
	struct drm_i915_private *dev_priv = dev->dev_private;
648
	struct intel_crtc *crtc = to_intel_crtc(encoder->base.crtc);
643
	struct intel_crtc *crtc = to_intel_crtc(encoder->base.crtc);
Line 661... Line 656...
661
	if (crtc->config.pipe_bpp > 24)
656
	if (crtc->config.pipe_bpp > 24)
662
		hdmi_val |= HDMI_COLOR_FORMAT_12bpc;
657
		hdmi_val |= HDMI_COLOR_FORMAT_12bpc;
663
	else
658
	else
664
		hdmi_val |= SDVO_COLOR_FORMAT_8bpc;
659
		hdmi_val |= SDVO_COLOR_FORMAT_8bpc;
Line 665... Line -...
665
 
-
 
666
	/* Required on CPT */
660
 
667
	if (intel_hdmi->has_hdmi_sink && HAS_PCH_CPT(dev))
661
	if (crtc->config.has_hdmi_sink)
Line 668... Line 662...
668
		hdmi_val |= HDMI_MODE_SELECT_HDMI;
662
		hdmi_val |= HDMI_MODE_SELECT_HDMI;
-
 
663
 
669
 
664
	if (crtc->config.has_audio) {
670
	if (intel_hdmi->has_audio) {
665
		WARN_ON(!crtc->config.has_hdmi_sink);
671
		DRM_DEBUG_DRIVER("Enabling HDMI audio on pipe %c\n",
666
		DRM_DEBUG_DRIVER("Enabling HDMI audio on pipe %c\n",
672
				 pipe_name(crtc->pipe));
-
 
673
		hdmi_val |= SDVO_AUDIO_ENABLE;
667
				 pipe_name(crtc->pipe));
674
		hdmi_val |= HDMI_MODE_SELECT_HDMI;
668
		hdmi_val |= SDVO_AUDIO_ENABLE;
Line 675... Line 669...
675
		intel_write_eld(&encoder->base, adjusted_mode);
669
		intel_write_eld(&encoder->base, adjusted_mode);
676
	}
670
	}
-
 
671
 
-
 
672
		if (HAS_PCH_CPT(dev))
677
 
673
		hdmi_val |= SDVO_PIPE_SEL_CPT(crtc->pipe);
678
		if (HAS_PCH_CPT(dev))
674
	else if (IS_CHERRYVIEW(dev))
Line 679... Line 675...
679
		hdmi_val |= SDVO_PIPE_SEL_CPT(crtc->pipe);
675
		hdmi_val |= SDVO_PIPE_SEL_CHV(crtc->pipe);
680
	else
676
	else
681
		hdmi_val |= SDVO_PIPE_SEL(crtc->pipe);
-
 
682
 
-
 
683
	I915_WRITE(intel_hdmi->hdmi_reg, hdmi_val);
677
		hdmi_val |= SDVO_PIPE_SEL(crtc->pipe);
Line 684... Line 678...
684
	POSTING_READ(intel_hdmi->hdmi_reg);
678
 
685
 
679
	I915_WRITE(intel_hdmi->hdmi_reg, hdmi_val);
686
	intel_hdmi->set_infoframes(&encoder->base, adjusted_mode);
680
	POSTING_READ(intel_hdmi->hdmi_reg);
687
}
681
}
688
 
682
 
689
static bool intel_hdmi_get_hw_state(struct intel_encoder *encoder,
683
static bool intel_hdmi_get_hw_state(struct intel_encoder *encoder,
-
 
684
				    enum pipe *pipe)
690
				    enum pipe *pipe)
685
{
Line -... Line 686...
-
 
686
	struct drm_device *dev = encoder->base.dev;
-
 
687
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
688
	struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&encoder->base);
-
 
689
	enum intel_display_power_domain power_domain;
691
{
690
	u32 tmp;
Line 692... Line 691...
692
	struct drm_device *dev = encoder->base.dev;
691
 
693
	struct drm_i915_private *dev_priv = dev->dev_private;
692
	power_domain = intel_display_port_power_domain(encoder);
Line 694... Line 693...
694
	struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&encoder->base);
693
	if (!intel_display_power_enabled(dev_priv, power_domain))
695
	u32 tmp;
694
		return false;
-
 
695
 
-
 
696
	tmp = I915_READ(intel_hdmi->hdmi_reg);
696
 
697
 
697
	tmp = I915_READ(intel_hdmi->hdmi_reg);
698
	if (!(tmp & SDVO_ENABLE))
Line 698... Line 699...
698
 
699
		return false;
699
	if (!(tmp & SDVO_ENABLE))
700
 
Line 725... Line 726...
725
	if (tmp & SDVO_VSYNC_ACTIVE_HIGH)
726
	if (tmp & SDVO_VSYNC_ACTIVE_HIGH)
726
		flags |= DRM_MODE_FLAG_PVSYNC;
727
		flags |= DRM_MODE_FLAG_PVSYNC;
727
	else
728
	else
728
		flags |= DRM_MODE_FLAG_NVSYNC;
729
		flags |= DRM_MODE_FLAG_NVSYNC;
Line -... Line 730...
-
 
730
 
-
 
731
	if (tmp & HDMI_MODE_SELECT_HDMI)
-
 
732
		pipe_config->has_hdmi_sink = true;
-
 
733
 
-
 
734
	if (tmp & HDMI_MODE_SELECT_HDMI)
-
 
735
		pipe_config->has_audio = true;
729
 
736
 
Line 730... Line 737...
730
	pipe_config->adjusted_mode.flags |= flags;
737
	pipe_config->adjusted_mode.flags |= flags;
731
 
738
 
732
	if ((tmp & SDVO_COLOR_FORMAT_MASK) == HDMI_COLOR_FORMAT_12bpc)
739
	if ((tmp & SDVO_COLOR_FORMAT_MASK) == HDMI_COLOR_FORMAT_12bpc)
Line 747... Line 754...
747
	struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc);
754
	struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc);
748
	struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&encoder->base);
755
	struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&encoder->base);
749
	u32 temp;
756
	u32 temp;
750
	u32 enable_bits = SDVO_ENABLE;
757
	u32 enable_bits = SDVO_ENABLE;
Line 751... Line 758...
751
 
758
 
752
	if (intel_hdmi->has_audio)
759
	if (intel_crtc->config.has_audio)
Line 753... Line 760...
753
		enable_bits |= SDVO_AUDIO_ENABLE;
760
		enable_bits |= SDVO_AUDIO_ENABLE;
Line 754... Line 761...
754
 
761
 
Line 839... Line 846...
839
		I915_WRITE(intel_hdmi->hdmi_reg, temp);
846
		I915_WRITE(intel_hdmi->hdmi_reg, temp);
840
		POSTING_READ(intel_hdmi->hdmi_reg);
847
		POSTING_READ(intel_hdmi->hdmi_reg);
841
	}
848
	}
842
}
849
}
Line 843... Line 850...
843
 
850
 
844
static int hdmi_portclock_limit(struct intel_hdmi *hdmi)
851
static int hdmi_portclock_limit(struct intel_hdmi *hdmi, bool respect_dvi_limit)
845
{
852
{
Line 846... Line 853...
846
	struct drm_device *dev = intel_hdmi_to_dev(hdmi);
853
	struct drm_device *dev = intel_hdmi_to_dev(hdmi);
847
 
854
 
848
	if (IS_G4X(dev))
855
	if ((respect_dvi_limit && !hdmi->has_hdmi_sink) || IS_G4X(dev))
849
		return 165000;
856
		return 165000;
850
	else if (IS_HASWELL(dev) || INTEL_INFO(dev)->gen >= 8)
857
	else if (IS_HASWELL(dev) || INTEL_INFO(dev)->gen >= 8)
851
		return 300000;
858
		return 300000;
Line 855... Line 862...
855
 
862
 
856
static enum drm_mode_status
863
static enum drm_mode_status
857
intel_hdmi_mode_valid(struct drm_connector *connector,
864
intel_hdmi_mode_valid(struct drm_connector *connector,
858
				 struct drm_display_mode *mode)
865
				 struct drm_display_mode *mode)
859
{
866
{
-
 
867
	if (mode->clock > hdmi_portclock_limit(intel_attached_hdmi(connector),
860
	if (mode->clock > hdmi_portclock_limit(intel_attached_hdmi(connector)))
868
					       true))
861
		return MODE_CLOCK_HIGH;
869
		return MODE_CLOCK_HIGH;
862
	if (mode->clock < 20000)
870
	if (mode->clock < 20000)
Line 863... Line 871...
863
		return MODE_CLOCK_LOW;
871
		return MODE_CLOCK_LOW;
864
 
872
 
Line 865... Line 873...
865
	if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
873
	if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
866
		return MODE_NO_DBLESCAN;
874
		return MODE_NO_DBLESCAN;
Line -... Line 875...
-
 
875
 
-
 
876
	return MODE_OK;
-
 
877
}
-
 
878
 
-
 
879
static bool hdmi_12bpc_possible(struct intel_crtc *crtc)
-
 
880
{
-
 
881
	struct drm_device *dev = crtc->base.dev;
-
 
882
	struct intel_encoder *encoder;
-
 
883
	int count = 0, count_hdmi = 0;
-
 
884
 
-
 
885
	if (HAS_GMCH_DISPLAY(dev))
-
 
886
		return false;
-
 
887
 
-
 
888
	list_for_each_entry(encoder, &dev->mode_config.encoder_list, base.head) {
-
 
889
		if (encoder->new_crtc != crtc)
-
 
890
			continue;
-
 
891
 
-
 
892
		count_hdmi += encoder->type == INTEL_OUTPUT_HDMI;
-
 
893
		count++;
-
 
894
	}
-
 
895
 
-
 
896
	/*
-
 
897
	 * HDMI 12bpc affects the clocks, so it's only possible
-
 
898
	 * when not cloning with other encoder types.
867
 
899
	 */
868
	return MODE_OK;
900
	return count_hdmi > 0 && count_hdmi == count;
869
}
901
}
870
 
902
 
871
bool intel_hdmi_compute_config(struct intel_encoder *encoder,
903
bool intel_hdmi_compute_config(struct intel_encoder *encoder,
872
			       struct intel_crtc_config *pipe_config)
904
			       struct intel_crtc_config *pipe_config)
873
{
905
{
874
	struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&encoder->base);
906
	struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&encoder->base);
875
	struct drm_device *dev = encoder->base.dev;
907
	struct drm_device *dev = encoder->base.dev;
Line -... Line 908...
-
 
908
	struct drm_display_mode *adjusted_mode = &pipe_config->adjusted_mode;
-
 
909
	int clock_12bpc = pipe_config->adjusted_mode.crtc_clock * 3 / 2;
876
	struct drm_display_mode *adjusted_mode = &pipe_config->adjusted_mode;
910
	int portclock_limit = hdmi_portclock_limit(intel_hdmi, false);
877
	int clock_12bpc = pipe_config->adjusted_mode.crtc_clock * 3 / 2;
911
	int desired_bpp;
878
	int portclock_limit = hdmi_portclock_limit(intel_hdmi);
912
 
879
	int desired_bpp;
913
	pipe_config->has_hdmi_sink = intel_hdmi->has_hdmi_sink;
880
 
914
 
881
	if (intel_hdmi->color_range_auto) {
915
	if (intel_hdmi->color_range_auto) {
882
		/* See CEA-861-E - 5.1 Default Encoding Parameters */
916
		/* See CEA-861-E - 5.1 Default Encoding Parameters */
883
		if (intel_hdmi->has_hdmi_sink &&
917
		if (pipe_config->has_hdmi_sink &&
Line 891... Line 925...
891
		pipe_config->limited_color_range = true;
925
		pipe_config->limited_color_range = true;
Line 892... Line 926...
892
 
926
 
893
	if (HAS_PCH_SPLIT(dev) && !HAS_DDI(dev))
927
	if (HAS_PCH_SPLIT(dev) && !HAS_DDI(dev))
Line -... Line 928...
-
 
928
		pipe_config->has_pch_encoder = true;
-
 
929
 
-
 
930
	if (pipe_config->has_hdmi_sink && intel_hdmi->has_audio)
894
		pipe_config->has_pch_encoder = true;
931
		pipe_config->has_audio = true;
895
 
932
 
896
	/*
933
	/*
897
	 * HDMI is either 12 or 8, so if the display lets 10bpc sneak
934
	 * HDMI is either 12 or 8, so if the display lets 10bpc sneak
898
	 * through, clamp it down. Note that g4x/vlv don't support 12bpc hdmi
935
	 * through, clamp it down. Note that g4x/vlv don't support 12bpc hdmi
899
	 * outputs. We also need to check that the higher clock still fits
936
	 * outputs. We also need to check that the higher clock still fits
900
	 * within limits.
937
	 * within limits.
-
 
938
	 */
901
	 */
939
	if (pipe_config->pipe_bpp > 8*3 && pipe_config->has_hdmi_sink &&
902
	if (pipe_config->pipe_bpp > 8*3 && clock_12bpc <= portclock_limit
940
	    clock_12bpc <= portclock_limit &&
903
	    && HAS_PCH_SPLIT(dev)) {
941
	    hdmi_12bpc_possible(encoder->new_crtc)) {
Line 904... Line 942...
904
		DRM_DEBUG_KMS("picking bpc to 12 for HDMI output\n");
942
		DRM_DEBUG_KMS("picking bpc to 12 for HDMI output\n");
905
		desired_bpp = 12*3;
943
		desired_bpp = 12*3;
Line 932... Line 970...
932
	struct intel_digital_port *intel_dig_port =
970
	struct intel_digital_port *intel_dig_port =
933
		hdmi_to_dig_port(intel_hdmi);
971
		hdmi_to_dig_port(intel_hdmi);
934
	struct intel_encoder *intel_encoder = &intel_dig_port->base;
972
	struct intel_encoder *intel_encoder = &intel_dig_port->base;
935
	struct drm_i915_private *dev_priv = dev->dev_private;
973
	struct drm_i915_private *dev_priv = dev->dev_private;
936
	struct edid *edid;
974
	struct edid *edid;
-
 
975
	enum intel_display_power_domain power_domain;
937
	enum drm_connector_status status = connector_status_disconnected;
976
	enum drm_connector_status status = connector_status_disconnected;
Line 938... Line 977...
938
 
977
 
939
	DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n",
978
	DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n",
-
 
979
		      connector->base.id, connector->name);
-
 
980
 
-
 
981
	power_domain = intel_display_port_power_domain(intel_encoder);
Line 940... Line 982...
940
		      connector->base.id, drm_get_connector_name(connector));
982
	intel_display_power_get(dev_priv, power_domain);
941
 
983
 
942
	intel_hdmi->has_hdmi_sink = false;
984
	intel_hdmi->has_hdmi_sink = false;
943
	intel_hdmi->has_audio = false;
985
	intel_hdmi->has_audio = false;
Line 964... Line 1006...
964
			intel_hdmi->has_audio =
1006
			intel_hdmi->has_audio =
965
				(intel_hdmi->force_audio == HDMI_AUDIO_ON);
1007
				(intel_hdmi->force_audio == HDMI_AUDIO_ON);
966
		intel_encoder->type = INTEL_OUTPUT_HDMI;
1008
		intel_encoder->type = INTEL_OUTPUT_HDMI;
967
	}
1009
	}
Line -... Line 1010...
-
 
1010
 
-
 
1011
	intel_display_power_put(dev_priv, power_domain);
968
 
1012
 
969
	return status;
1013
	return status;
Line 970... Line 1014...
970
}
1014
}
971
 
1015
 
972
static int intel_hdmi_get_modes(struct drm_connector *connector)
1016
static int intel_hdmi_get_modes(struct drm_connector *connector)
-
 
1017
{
973
{
1018
	struct intel_encoder *intel_encoder = intel_attached_encoder(connector);
-
 
1019
	struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&intel_encoder->base);
-
 
1020
	struct drm_i915_private *dev_priv = connector->dev->dev_private;
Line 974... Line 1021...
974
	struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector);
1021
	enum intel_display_power_domain power_domain;
975
	struct drm_i915_private *dev_priv = connector->dev->dev_private;
1022
	int ret;
976
 
1023
 
Line -... Line 1024...
-
 
1024
	/* We should parse the EDID data and find out if it's an HDMI sink so
-
 
1025
	 * we can send audio to it.
-
 
1026
	 */
977
	/* We should parse the EDID data and find out if it's an HDMI sink so
1027
 
978
	 * we can send audio to it.
1028
	power_domain = intel_display_port_power_domain(intel_encoder);
979
	 */
1029
	intel_display_power_get(dev_priv, power_domain);
-
 
1030
 
-
 
1031
	ret = intel_ddc_get_modes(connector,
-
 
1032
				   intel_gmbus_get_adapter(dev_priv,
-
 
1033
							   intel_hdmi->ddc_bus));
980
 
1034
 
Line 981... Line 1035...
981
	return intel_ddc_get_modes(connector,
1035
	intel_display_power_put(dev_priv, power_domain);
982
				   intel_gmbus_get_adapter(dev_priv,
1036
 
983
							   intel_hdmi->ddc_bus));
1037
	return ret;
984
}
1038
}
-
 
1039
 
985
 
1040
static bool
-
 
1041
intel_hdmi_detect_audio(struct drm_connector *connector)
986
static bool
1042
{
987
intel_hdmi_detect_audio(struct drm_connector *connector)
1043
	struct intel_encoder *intel_encoder = intel_attached_encoder(connector);
Line -... Line 1044...
-
 
1044
	struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&intel_encoder->base);
-
 
1045
	struct drm_i915_private *dev_priv = connector->dev->dev_private;
-
 
1046
	enum intel_display_power_domain power_domain;
988
{
1047
	struct edid *edid;
989
	struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector);
1048
	bool has_audio = false;
990
	struct drm_i915_private *dev_priv = connector->dev->dev_private;
1049
 
991
	struct edid *edid;
1050
	power_domain = intel_display_port_power_domain(intel_encoder);
992
	bool has_audio = false;
1051
	intel_display_power_get(dev_priv, power_domain);
993
 
1052
 
994
	edid = drm_get_edid(connector,
1053
	edid = drm_get_edid(connector,
995
			    intel_gmbus_get_adapter(dev_priv,
1054
			    intel_gmbus_get_adapter(dev_priv,
Line -... Line 1055...
-
 
1055
						    intel_hdmi->ddc_bus));
-
 
1056
	if (edid) {
996
						    intel_hdmi->ddc_bus));
1057
		if (edid->input & DRM_EDID_INPUT_DIGITAL)
997
	if (edid) {
1058
			has_audio = drm_detect_monitor_audio(edid);
Line 998... Line 1059...
998
		if (edid->input & DRM_EDID_INPUT_DIGITAL)
1059
		kfree(edid);
999
			has_audio = drm_detect_monitor_audio(edid);
1060
	}
Line 1064... Line 1125...
1064
			return 0;
1125
			return 0;
Line 1065... Line 1126...
1065
 
1126
 
1066
		goto done;
1127
		goto done;
Line -... Line 1128...
-
 
1128
	}
-
 
1129
 
-
 
1130
	if (property == connector->dev->mode_config.aspect_ratio_property) {
-
 
1131
		switch (val) {
-
 
1132
		case DRM_MODE_PICTURE_ASPECT_NONE:
-
 
1133
			intel_hdmi->aspect_ratio = HDMI_PICTURE_ASPECT_NONE;
-
 
1134
			break;
-
 
1135
		case DRM_MODE_PICTURE_ASPECT_4_3:
-
 
1136
			intel_hdmi->aspect_ratio = HDMI_PICTURE_ASPECT_4_3;
-
 
1137
			break;
-
 
1138
		case DRM_MODE_PICTURE_ASPECT_16_9:
-
 
1139
			intel_hdmi->aspect_ratio = HDMI_PICTURE_ASPECT_16_9;
-
 
1140
			break;
-
 
1141
		default:
-
 
1142
			return -EINVAL;
-
 
1143
		}
-
 
1144
		goto done;
1067
	}
1145
	}
Line 1068... Line 1146...
1068
 
1146
 
1069
	return -EINVAL;
1147
	return -EINVAL;
1070
 
1148
 
Line 1071... Line 1149...
1071
done:
1149
done:
1072
	if (intel_dig_port->base.base.crtc)
1150
	if (intel_dig_port->base.base.crtc)
Line -... Line 1151...
-
 
1151
		intel_crtc_restore_mode(intel_dig_port->base.base.crtc);
-
 
1152
 
-
 
1153
	return 0;
-
 
1154
}
-
 
1155
 
-
 
1156
static void intel_hdmi_pre_enable(struct intel_encoder *encoder)
-
 
1157
{
-
 
1158
	struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&encoder->base);
-
 
1159
	struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc);
-
 
1160
	struct drm_display_mode *adjusted_mode =
-
 
1161
		&intel_crtc->config.adjusted_mode;
-
 
1162
 
-
 
1163
	intel_hdmi_prepare(encoder);
-
 
1164
 
1073
		intel_crtc_restore_mode(intel_dig_port->base.base.crtc);
1165
	intel_hdmi->set_infoframes(&encoder->base,
1074
 
1166
				   intel_crtc->config.has_hdmi_sink,
1075
	return 0;
1167
				   adjusted_mode);
-
 
1168
}
1076
}
1169
 
1077
 
1170
static void vlv_hdmi_pre_enable(struct intel_encoder *encoder)
1078
static void vlv_hdmi_pre_enable(struct intel_encoder *encoder)
1171
{
1079
{
1172
	struct intel_digital_port *dport = enc_to_dig_port(&encoder->base);
-
 
1173
	struct intel_hdmi *intel_hdmi = &dport->hdmi;
-
 
1174
	struct drm_device *dev = encoder->base.dev;
1080
	struct intel_digital_port *dport = enc_to_dig_port(&encoder->base);
1175
	struct drm_i915_private *dev_priv = dev->dev_private;
1081
	struct drm_device *dev = encoder->base.dev;
1176
	struct intel_crtc *intel_crtc =
1082
	struct drm_i915_private *dev_priv = dev->dev_private;
1177
		to_intel_crtc(encoder->base.crtc);
Line 1083... Line -...
1083
	struct intel_crtc *intel_crtc =
-
 
1084
		to_intel_crtc(encoder->base.crtc);
-
 
1085
	enum dpio_channel port = vlv_dport_to_channel(dport);
-
 
1086
	int pipe = intel_crtc->pipe;
1178
	struct drm_display_mode *adjusted_mode =
1087
	u32 val;
1179
		&intel_crtc->config.adjusted_mode;
1088
 
1180
	enum dpio_channel port = vlv_dport_to_channel(dport);
1089
	if (!IS_VALLEYVIEW(dev))
1181
	int pipe = intel_crtc->pipe;
1090
		return;
1182
	u32 val;
Line 1113... Line 1205...
1113
	/* Program lane clock */
1205
	/* Program lane clock */
1114
	vlv_dpio_write(dev_priv, pipe, VLV_PCS_DW14(port), 0x00760018);
1206
	vlv_dpio_write(dev_priv, pipe, VLV_PCS_DW14(port), 0x00760018);
1115
	vlv_dpio_write(dev_priv, pipe, VLV_PCS_DW23(port), 0x00400888);
1207
	vlv_dpio_write(dev_priv, pipe, VLV_PCS_DW23(port), 0x00400888);
1116
	mutex_unlock(&dev_priv->dpio_lock);
1208
	mutex_unlock(&dev_priv->dpio_lock);
Line -... Line 1209...
-
 
1209
 
-
 
1210
	intel_hdmi->set_infoframes(&encoder->base,
-
 
1211
				   intel_crtc->config.has_hdmi_sink,
-
 
1212
				   adjusted_mode);
1117
 
1213
 
Line 1118... Line 1214...
1118
	intel_enable_hdmi(encoder);
1214
	intel_enable_hdmi(encoder);
1119
 
1215
 
Line 1128... Line 1224...
1128
	struct intel_crtc *intel_crtc =
1224
	struct intel_crtc *intel_crtc =
1129
		to_intel_crtc(encoder->base.crtc);
1225
		to_intel_crtc(encoder->base.crtc);
1130
	enum dpio_channel port = vlv_dport_to_channel(dport);
1226
	enum dpio_channel port = vlv_dport_to_channel(dport);
1131
	int pipe = intel_crtc->pipe;
1227
	int pipe = intel_crtc->pipe;
Line 1132... Line 1228...
1132
 
1228
 
1133
	if (!IS_VALLEYVIEW(dev))
-
 
Line 1134... Line 1229...
1134
		return;
1229
	intel_hdmi_prepare(encoder);
1135
 
1230
 
1136
	/* Program Tx lane resets to default */
1231
	/* Program Tx lane resets to default */
1137
	mutex_lock(&dev_priv->dpio_lock);
1232
	mutex_lock(&dev_priv->dpio_lock);
Line 1152... Line 1247...
1152
	vlv_dpio_write(dev_priv, pipe, VLV_PCS_DW9(port), 0x00002000);
1247
	vlv_dpio_write(dev_priv, pipe, VLV_PCS_DW9(port), 0x00002000);
1153
	vlv_dpio_write(dev_priv, pipe, VLV_TX_DW5(port), DPIO_TX_OCALINIT_EN);
1248
	vlv_dpio_write(dev_priv, pipe, VLV_TX_DW5(port), DPIO_TX_OCALINIT_EN);
1154
	mutex_unlock(&dev_priv->dpio_lock);
1249
	mutex_unlock(&dev_priv->dpio_lock);
1155
}
1250
}
Line -... Line 1251...
-
 
1251
 
-
 
1252
static void chv_hdmi_pre_pll_enable(struct intel_encoder *encoder)
-
 
1253
{
-
 
1254
	struct intel_digital_port *dport = enc_to_dig_port(&encoder->base);
-
 
1255
	struct drm_device *dev = encoder->base.dev;
-
 
1256
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
1257
	struct intel_crtc *intel_crtc =
-
 
1258
		to_intel_crtc(encoder->base.crtc);
-
 
1259
	enum dpio_channel ch = vlv_dport_to_channel(dport);
-
 
1260
	enum pipe pipe = intel_crtc->pipe;
-
 
1261
	u32 val;
-
 
1262
 
-
 
1263
	mutex_lock(&dev_priv->dpio_lock);
-
 
1264
 
-
 
1265
	/* program left/right clock distribution */
-
 
1266
	if (pipe != PIPE_B) {
-
 
1267
		val = vlv_dpio_read(dev_priv, pipe, _CHV_CMN_DW5_CH0);
-
 
1268
		val &= ~(CHV_BUFLEFTENA1_MASK | CHV_BUFRIGHTENA1_MASK);
-
 
1269
		if (ch == DPIO_CH0)
-
 
1270
			val |= CHV_BUFLEFTENA1_FORCE;
-
 
1271
		if (ch == DPIO_CH1)
-
 
1272
			val |= CHV_BUFRIGHTENA1_FORCE;
-
 
1273
		vlv_dpio_write(dev_priv, pipe, _CHV_CMN_DW5_CH0, val);
-
 
1274
	} else {
-
 
1275
		val = vlv_dpio_read(dev_priv, pipe, _CHV_CMN_DW1_CH1);
-
 
1276
		val &= ~(CHV_BUFLEFTENA2_MASK | CHV_BUFRIGHTENA2_MASK);
-
 
1277
		if (ch == DPIO_CH0)
-
 
1278
			val |= CHV_BUFLEFTENA2_FORCE;
-
 
1279
		if (ch == DPIO_CH1)
-
 
1280
			val |= CHV_BUFRIGHTENA2_FORCE;
-
 
1281
		vlv_dpio_write(dev_priv, pipe, _CHV_CMN_DW1_CH1, val);
-
 
1282
	}
-
 
1283
 
-
 
1284
	/* program clock channel usage */
-
 
1285
	val = vlv_dpio_read(dev_priv, pipe, VLV_PCS01_DW8(ch));
-
 
1286
	val |= CHV_PCS_USEDCLKCHANNEL_OVRRIDE;
-
 
1287
	if (pipe != PIPE_B)
-
 
1288
		val &= ~CHV_PCS_USEDCLKCHANNEL;
-
 
1289
	else
-
 
1290
		val |= CHV_PCS_USEDCLKCHANNEL;
-
 
1291
	vlv_dpio_write(dev_priv, pipe, VLV_PCS01_DW8(ch), val);
-
 
1292
 
-
 
1293
	val = vlv_dpio_read(dev_priv, pipe, VLV_PCS23_DW8(ch));
-
 
1294
	val |= CHV_PCS_USEDCLKCHANNEL_OVRRIDE;
-
 
1295
	if (pipe != PIPE_B)
-
 
1296
		val &= ~CHV_PCS_USEDCLKCHANNEL;
-
 
1297
	else
-
 
1298
		val |= CHV_PCS_USEDCLKCHANNEL;
-
 
1299
	vlv_dpio_write(dev_priv, pipe, VLV_PCS23_DW8(ch), val);
-
 
1300
 
-
 
1301
	/*
-
 
1302
	 * This a a bit weird since generally CL
-
 
1303
	 * matches the pipe, but here we need to
-
 
1304
	 * pick the CL based on the port.
-
 
1305
	 */
-
 
1306
	val = vlv_dpio_read(dev_priv, pipe, CHV_CMN_DW19(ch));
-
 
1307
	if (pipe != PIPE_B)
-
 
1308
		val &= ~CHV_CMN_USEDCLKCHANNEL;
-
 
1309
	else
-
 
1310
		val |= CHV_CMN_USEDCLKCHANNEL;
-
 
1311
	vlv_dpio_write(dev_priv, pipe, CHV_CMN_DW19(ch), val);
-
 
1312
 
-
 
1313
	mutex_unlock(&dev_priv->dpio_lock);
-
 
1314
}
1156
 
1315
 
1157
static void vlv_hdmi_post_disable(struct intel_encoder *encoder)
1316
static void vlv_hdmi_post_disable(struct intel_encoder *encoder)
1158
{
1317
{
1159
	struct intel_digital_port *dport = enc_to_dig_port(&encoder->base);
1318
	struct intel_digital_port *dport = enc_to_dig_port(&encoder->base);
1160
	struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
1319
	struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
Line 1168... Line 1327...
1168
	vlv_dpio_write(dev_priv, pipe, VLV_PCS_DW0(port), 0x00000000);
1327
	vlv_dpio_write(dev_priv, pipe, VLV_PCS_DW0(port), 0x00000000);
1169
	vlv_dpio_write(dev_priv, pipe, VLV_PCS_DW1(port), 0x00e00060);
1328
	vlv_dpio_write(dev_priv, pipe, VLV_PCS_DW1(port), 0x00e00060);
1170
	mutex_unlock(&dev_priv->dpio_lock);
1329
	mutex_unlock(&dev_priv->dpio_lock);
1171
}
1330
}
Line -... Line 1331...
-
 
1331
 
-
 
1332
static void chv_hdmi_post_disable(struct intel_encoder *encoder)
-
 
1333
{
-
 
1334
	struct intel_digital_port *dport = enc_to_dig_port(&encoder->base);
-
 
1335
	struct drm_device *dev = encoder->base.dev;
-
 
1336
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
1337
	struct intel_crtc *intel_crtc =
-
 
1338
		to_intel_crtc(encoder->base.crtc);
-
 
1339
	enum dpio_channel ch = vlv_dport_to_channel(dport);
-
 
1340
	enum pipe pipe = intel_crtc->pipe;
-
 
1341
	u32 val;
-
 
1342
 
-
 
1343
	mutex_lock(&dev_priv->dpio_lock);
-
 
1344
 
-
 
1345
	/* Propagate soft reset to data lane reset */
-
 
1346
	val = vlv_dpio_read(dev_priv, pipe, VLV_PCS01_DW1(ch));
-
 
1347
	val |= CHV_PCS_REQ_SOFTRESET_EN;
-
 
1348
	vlv_dpio_write(dev_priv, pipe, VLV_PCS01_DW1(ch), val);
-
 
1349
 
-
 
1350
	val = vlv_dpio_read(dev_priv, pipe, VLV_PCS23_DW1(ch));
-
 
1351
	val |= CHV_PCS_REQ_SOFTRESET_EN;
-
 
1352
	vlv_dpio_write(dev_priv, pipe, VLV_PCS23_DW1(ch), val);
-
 
1353
 
-
 
1354
	val = vlv_dpio_read(dev_priv, pipe, VLV_PCS01_DW0(ch));
-
 
1355
	val &= ~(DPIO_PCS_TX_LANE2_RESET | DPIO_PCS_TX_LANE1_RESET);
-
 
1356
	vlv_dpio_write(dev_priv, pipe, VLV_PCS01_DW0(ch), val);
-
 
1357
 
-
 
1358
	val = vlv_dpio_read(dev_priv, pipe, VLV_PCS23_DW0(ch));
-
 
1359
	val &= ~(DPIO_PCS_TX_LANE2_RESET | DPIO_PCS_TX_LANE1_RESET);
-
 
1360
	vlv_dpio_write(dev_priv, pipe, VLV_PCS23_DW0(ch), val);
-
 
1361
 
-
 
1362
	mutex_unlock(&dev_priv->dpio_lock);
-
 
1363
}
-
 
1364
 
-
 
1365
static void chv_hdmi_pre_enable(struct intel_encoder *encoder)
-
 
1366
{
-
 
1367
	struct intel_digital_port *dport = enc_to_dig_port(&encoder->base);
-
 
1368
	struct drm_device *dev = encoder->base.dev;
-
 
1369
	struct drm_i915_private *dev_priv = dev->dev_private;
-
 
1370
	struct intel_crtc *intel_crtc =
-
 
1371
		to_intel_crtc(encoder->base.crtc);
-
 
1372
	enum dpio_channel ch = vlv_dport_to_channel(dport);
-
 
1373
	int pipe = intel_crtc->pipe;
-
 
1374
	int data, i;
-
 
1375
	u32 val;
-
 
1376
 
-
 
1377
	mutex_lock(&dev_priv->dpio_lock);
-
 
1378
 
-
 
1379
	/* Deassert soft data lane reset*/
-
 
1380
	val = vlv_dpio_read(dev_priv, pipe, VLV_PCS01_DW1(ch));
-
 
1381
	val |= CHV_PCS_REQ_SOFTRESET_EN;
-
 
1382
	vlv_dpio_write(dev_priv, pipe, VLV_PCS01_DW1(ch), val);
-
 
1383
 
-
 
1384
	val = vlv_dpio_read(dev_priv, pipe, VLV_PCS23_DW1(ch));
-
 
1385
	val |= CHV_PCS_REQ_SOFTRESET_EN;
-
 
1386
	vlv_dpio_write(dev_priv, pipe, VLV_PCS23_DW1(ch), val);
-
 
1387
 
-
 
1388
	val = vlv_dpio_read(dev_priv, pipe, VLV_PCS01_DW0(ch));
-
 
1389
	val |= (DPIO_PCS_TX_LANE2_RESET | DPIO_PCS_TX_LANE1_RESET);
-
 
1390
	vlv_dpio_write(dev_priv, pipe, VLV_PCS01_DW0(ch), val);
-
 
1391
 
-
 
1392
	val = vlv_dpio_read(dev_priv, pipe, VLV_PCS23_DW0(ch));
-
 
1393
	val |= (DPIO_PCS_TX_LANE2_RESET | DPIO_PCS_TX_LANE1_RESET);
-
 
1394
	vlv_dpio_write(dev_priv, pipe, VLV_PCS23_DW0(ch), val);
-
 
1395
 
-
 
1396
	/* Program Tx latency optimal setting */
-
 
1397
	for (i = 0; i < 4; i++) {
-
 
1398
		/* Set the latency optimal bit */
-
 
1399
		data = (i == 1) ? 0x0 : 0x6;
-
 
1400
		vlv_dpio_write(dev_priv, pipe, CHV_TX_DW11(ch, i),
-
 
1401
				data << DPIO_FRC_LATENCY_SHFIT);
-
 
1402
 
-
 
1403
		/* Set the upar bit */
-
 
1404
		data = (i == 1) ? 0x0 : 0x1;
-
 
1405
		vlv_dpio_write(dev_priv, pipe, CHV_TX_DW14(ch, i),
-
 
1406
				data << DPIO_UPAR_SHIFT);
-
 
1407
	}
-
 
1408
 
-
 
1409
	/* Data lane stagger programming */
-
 
1410
	/* FIXME: Fix up value only after power analysis */
-
 
1411
 
-
 
1412
	/* Clear calc init */
-
 
1413
	val = vlv_dpio_read(dev_priv, pipe, VLV_PCS01_DW10(ch));
-
 
1414
	val &= ~(DPIO_PCS_SWING_CALC_TX0_TX2 | DPIO_PCS_SWING_CALC_TX1_TX3);
-
 
1415
	vlv_dpio_write(dev_priv, pipe, VLV_PCS01_DW10(ch), val);
-
 
1416
 
-
 
1417
	val = vlv_dpio_read(dev_priv, pipe, VLV_PCS23_DW10(ch));
-
 
1418
	val &= ~(DPIO_PCS_SWING_CALC_TX0_TX2 | DPIO_PCS_SWING_CALC_TX1_TX3);
-
 
1419
	vlv_dpio_write(dev_priv, pipe, VLV_PCS23_DW10(ch), val);
-
 
1420
 
-
 
1421
	/* FIXME: Program the support xxx V-dB */
-
 
1422
	/* Use 800mV-0dB */
-
 
1423
	for (i = 0; i < 4; i++) {
-
 
1424
		val = vlv_dpio_read(dev_priv, pipe, CHV_TX_DW4(ch, i));
-
 
1425
		val &= ~DPIO_SWING_DEEMPH9P5_MASK;
-
 
1426
		val |= 128 << DPIO_SWING_DEEMPH9P5_SHIFT;
-
 
1427
		vlv_dpio_write(dev_priv, pipe, CHV_TX_DW4(ch, i), val);
-
 
1428
	}
-
 
1429
 
-
 
1430
	for (i = 0; i < 4; i++) {
-
 
1431
		val = vlv_dpio_read(dev_priv, pipe, CHV_TX_DW2(ch, i));
-
 
1432
		val &= ~DPIO_SWING_MARGIN_MASK;
-
 
1433
		val |= 102 << DPIO_SWING_MARGIN_SHIFT;
-
 
1434
		vlv_dpio_write(dev_priv, pipe, CHV_TX_DW2(ch, i), val);
-
 
1435
	}
-
 
1436
 
-
 
1437
	/* Disable unique transition scale */
-
 
1438
	for (i = 0; i < 4; i++) {
-
 
1439
		val = vlv_dpio_read(dev_priv, pipe, CHV_TX_DW3(ch, i));
-
 
1440
		val &= ~DPIO_TX_UNIQ_TRANS_SCALE_EN;
-
 
1441
		vlv_dpio_write(dev_priv, pipe, CHV_TX_DW3(ch, i), val);
-
 
1442
	}
-
 
1443
 
-
 
1444
	/* Additional steps for 1200mV-0dB */
-
 
1445
#if 0
-
 
1446
	val = vlv_dpio_read(dev_priv, pipe, VLV_TX_DW3(ch));
-
 
1447
	if (ch)
-
 
1448
		val |= DPIO_TX_UNIQ_TRANS_SCALE_CH1;
-
 
1449
	else
-
 
1450
		val |= DPIO_TX_UNIQ_TRANS_SCALE_CH0;
-
 
1451
	vlv_dpio_write(dev_priv, pipe, VLV_TX_DW3(ch), val);
-
 
1452
 
-
 
1453
	vlv_dpio_write(dev_priv, pipe, VLV_TX_DW2(ch),
-
 
1454
			vlv_dpio_read(dev_priv, pipe, VLV_TX_DW2(ch)) |
-
 
1455
				(0x9a << DPIO_UNIQ_TRANS_SCALE_SHIFT));
-
 
1456
#endif
-
 
1457
	/* Start swing calculation */
-
 
1458
	val = vlv_dpio_read(dev_priv, pipe, VLV_PCS01_DW10(ch));
-
 
1459
	val |= DPIO_PCS_SWING_CALC_TX0_TX2 | DPIO_PCS_SWING_CALC_TX1_TX3;
-
 
1460
	vlv_dpio_write(dev_priv, pipe, VLV_PCS01_DW10(ch), val);
-
 
1461
 
-
 
1462
	val = vlv_dpio_read(dev_priv, pipe, VLV_PCS23_DW10(ch));
-
 
1463
	val |= DPIO_PCS_SWING_CALC_TX0_TX2 | DPIO_PCS_SWING_CALC_TX1_TX3;
-
 
1464
	vlv_dpio_write(dev_priv, pipe, VLV_PCS23_DW10(ch), val);
-
 
1465
 
-
 
1466
	/* LRC Bypass */
-
 
1467
	val = vlv_dpio_read(dev_priv, pipe, CHV_CMN_DW30);
-
 
1468
	val |= DPIO_LRC_BYPASS;
-
 
1469
	vlv_dpio_write(dev_priv, pipe, CHV_CMN_DW30, val);
-
 
1470
 
-
 
1471
	mutex_unlock(&dev_priv->dpio_lock);
-
 
1472
 
-
 
1473
	intel_enable_hdmi(encoder);
-
 
1474
 
-
 
1475
	vlv_wait_port_ready(dev_priv, dport);
-
 
1476
}
1172
 
1477
 
1173
static void intel_hdmi_destroy(struct drm_connector *connector)
1478
static void intel_hdmi_destroy(struct drm_connector *connector)
1174
{
1479
{
1175
	drm_connector_cleanup(connector);
1480
	drm_connector_cleanup(connector);
1176
	kfree(connector);
1481
	kfree(connector);
Line 1193... Line 1498...
1193
static const struct drm_encoder_funcs intel_hdmi_enc_funcs = {
1498
static const struct drm_encoder_funcs intel_hdmi_enc_funcs = {
1194
	.destroy = intel_encoder_destroy,
1499
	.destroy = intel_encoder_destroy,
1195
};
1500
};
Line 1196... Line 1501...
1196
 
1501
 
-
 
1502
static void
-
 
1503
intel_attach_aspect_ratio_property(struct drm_connector *connector)
-
 
1504
{
-
 
1505
	if (!drm_mode_create_aspect_ratio_property(connector->dev))
-
 
1506
		drm_object_attach_property(&connector->base,
-
 
1507
			connector->dev->mode_config.aspect_ratio_property,
-
 
1508
			DRM_MODE_PICTURE_ASPECT_NONE);
-
 
1509
}
-
 
1510
 
1197
static void
1511
static void
1198
intel_hdmi_add_properties(struct intel_hdmi *intel_hdmi, struct drm_connector *connector)
1512
intel_hdmi_add_properties(struct intel_hdmi *intel_hdmi, struct drm_connector *connector)
1199
{
1513
{
1200
	intel_attach_force_audio_property(connector);
1514
	intel_attach_force_audio_property(connector);
1201
	intel_attach_broadcast_rgb_property(connector);
1515
	intel_attach_broadcast_rgb_property(connector);
-
 
1516
	intel_hdmi->color_range_auto = true;
-
 
1517
	intel_attach_aspect_ratio_property(connector);
1202
	intel_hdmi->color_range_auto = true;
1518
	intel_hdmi->aspect_ratio = HDMI_PICTURE_ASPECT_NONE;
Line 1203... Line 1519...
1203
}
1519
}
1204
 
1520
 
1205
void intel_hdmi_init_connector(struct intel_digital_port *intel_dig_port,
1521
void intel_hdmi_init_connector(struct intel_digital_port *intel_dig_port,
Line 1228... Line 1544...
1228
	case PORT_C:
1544
	case PORT_C:
1229
		intel_hdmi->ddc_bus = GMBUS_PORT_DPC;
1545
		intel_hdmi->ddc_bus = GMBUS_PORT_DPC;
1230
		intel_encoder->hpd_pin = HPD_PORT_C;
1546
		intel_encoder->hpd_pin = HPD_PORT_C;
1231
		break;
1547
		break;
1232
	case PORT_D:
1548
	case PORT_D:
-
 
1549
		if (IS_CHERRYVIEW(dev))
-
 
1550
			intel_hdmi->ddc_bus = GMBUS_PORT_DPD_CHV;
-
 
1551
		else
1233
		intel_hdmi->ddc_bus = GMBUS_PORT_DPD;
1552
		intel_hdmi->ddc_bus = GMBUS_PORT_DPD;
1234
		intel_encoder->hpd_pin = HPD_PORT_D;
1553
		intel_encoder->hpd_pin = HPD_PORT_D;
1235
		break;
1554
		break;
1236
	case PORT_A:
1555
	case PORT_A:
1237
		intel_encoder->hpd_pin = HPD_PORT_A;
1556
		intel_encoder->hpd_pin = HPD_PORT_A;
Line 1241... Line 1560...
1241
	}
1560
	}
Line 1242... Line 1561...
1242
 
1561
 
1243
	if (IS_VALLEYVIEW(dev)) {
1562
	if (IS_VALLEYVIEW(dev)) {
1244
		intel_hdmi->write_infoframe = vlv_write_infoframe;
1563
		intel_hdmi->write_infoframe = vlv_write_infoframe;
1245
		intel_hdmi->set_infoframes = vlv_set_infoframes;
1564
		intel_hdmi->set_infoframes = vlv_set_infoframes;
1246
	} else if (!HAS_PCH_SPLIT(dev)) {
1565
	} else if (IS_G4X(dev)) {
1247
		intel_hdmi->write_infoframe = g4x_write_infoframe;
1566
		intel_hdmi->write_infoframe = g4x_write_infoframe;
1248
		intel_hdmi->set_infoframes = g4x_set_infoframes;
1567
		intel_hdmi->set_infoframes = g4x_set_infoframes;
1249
	} else if (HAS_DDI(dev)) {
1568
	} else if (HAS_DDI(dev)) {
1250
		intel_hdmi->write_infoframe = hsw_write_infoframe;
1569
		intel_hdmi->write_infoframe = hsw_write_infoframe;
Line 1259... Line 1578...
1259
 
1578
 
1260
	if (HAS_DDI(dev))
1579
	if (HAS_DDI(dev))
1261
		intel_connector->get_hw_state = intel_ddi_connector_get_hw_state;
1580
		intel_connector->get_hw_state = intel_ddi_connector_get_hw_state;
1262
	else
1581
	else
-
 
1582
	intel_connector->get_hw_state = intel_connector_get_hw_state;
Line 1263... Line 1583...
1263
	intel_connector->get_hw_state = intel_connector_get_hw_state;
1583
	intel_connector->unregister = intel_connector_unregister;
Line 1264... Line 1584...
1264
 
1584
 
1265
	intel_hdmi_add_properties(intel_hdmi, connector);
1585
	intel_hdmi_add_properties(intel_hdmi, connector);
Line 1266... Line 1586...
1266
 
1586
 
1267
	intel_connector_attach_encoder(intel_connector, intel_encoder);
1587
	intel_connector_attach_encoder(intel_connector, intel_encoder);
1268
	drm_sysfs_connector_add(connector);
1588
	drm_connector_register(connector);
1269
 
1589
 
Line 1297... Line 1617...
1297
 
1617
 
1298
	drm_encoder_init(dev, &intel_encoder->base, &intel_hdmi_enc_funcs,
1618
	drm_encoder_init(dev, &intel_encoder->base, &intel_hdmi_enc_funcs,
Line 1299... Line 1619...
1299
			 DRM_MODE_ENCODER_TMDS);
1619
			 DRM_MODE_ENCODER_TMDS);
1300
 
-
 
1301
	intel_encoder->compute_config = intel_hdmi_compute_config;
1620
 
1302
	intel_encoder->mode_set = intel_hdmi_mode_set;
1621
	intel_encoder->compute_config = intel_hdmi_compute_config;
1303
	intel_encoder->disable = intel_disable_hdmi;
1622
	intel_encoder->disable = intel_disable_hdmi;
1304
	intel_encoder->get_hw_state = intel_hdmi_get_hw_state;
1623
	intel_encoder->get_hw_state = intel_hdmi_get_hw_state;
-
 
1624
	intel_encoder->get_config = intel_hdmi_get_config;
-
 
1625
	if (IS_CHERRYVIEW(dev)) {
-
 
1626
		intel_encoder->pre_pll_enable = chv_hdmi_pre_pll_enable;
-
 
1627
		intel_encoder->pre_enable = chv_hdmi_pre_enable;
-
 
1628
		intel_encoder->enable = vlv_enable_hdmi;
1305
	intel_encoder->get_config = intel_hdmi_get_config;
1629
		intel_encoder->post_disable = chv_hdmi_post_disable;
1306
	if (IS_VALLEYVIEW(dev)) {
1630
	} else if (IS_VALLEYVIEW(dev)) {
1307
		intel_encoder->pre_pll_enable = vlv_hdmi_pre_pll_enable;
1631
		intel_encoder->pre_pll_enable = vlv_hdmi_pre_pll_enable;
1308
		intel_encoder->pre_enable = vlv_hdmi_pre_enable;
1632
		intel_encoder->pre_enable = vlv_hdmi_pre_enable;
1309
		intel_encoder->enable = vlv_enable_hdmi;
1633
		intel_encoder->enable = vlv_enable_hdmi;
-
 
1634
		intel_encoder->post_disable = vlv_hdmi_post_disable;
1310
		intel_encoder->post_disable = vlv_hdmi_post_disable;
1635
	} else {
1311
	} else {
1636
		intel_encoder->pre_enable = intel_hdmi_pre_enable;
Line 1312... Line 1637...
1312
		intel_encoder->enable = intel_enable_hdmi;
1637
		intel_encoder->enable = intel_enable_hdmi;
-
 
1638
	}
-
 
1639
 
-
 
1640
	intel_encoder->type = INTEL_OUTPUT_HDMI;
-
 
1641
	if (IS_CHERRYVIEW(dev)) {
-
 
1642
		if (port == PORT_D)
-
 
1643
			intel_encoder->crtc_mask = 1 << 2;
1313
	}
1644
		else
-
 
1645
			intel_encoder->crtc_mask = (1 << 0) | (1 << 1);
1314
 
1646
	} else {
-
 
1647
	intel_encoder->crtc_mask = (1 << 0) | (1 << 1) | (1 << 2);
-
 
1648
	}
-
 
1649
	intel_encoder->cloneable = 1 << INTEL_OUTPUT_ANALOG;
-
 
1650
	/*
-
 
1651
	 * BSpec is unclear about HDMI+HDMI cloning on g4x, but it seems
-
 
1652
	 * to work on real hardware. And since g4x can send infoframes to
-
 
1653
	 * only one port anyway, nothing is lost by allowing it.
Line 1315... Line 1654...
1315
	intel_encoder->type = INTEL_OUTPUT_HDMI;
1654
	 */
1316
	intel_encoder->crtc_mask = (1 << 0) | (1 << 1) | (1 << 2);
1655
	if (IS_G4X(dev))
1317
	intel_encoder->cloneable = false;
1656
		intel_encoder->cloneable |= 1 << INTEL_OUTPUT_HDMI;