Subversion Repositories Kolibri OS

Rev

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

Rev 6084 Rev 6937
Line 159... Line 159...
159
	else
159
	else
160
		return false;
160
		return false;
161
}
161
}
Line 162... Line 162...
162
 
162
 
163
static bool intel_eld_uptodate(struct drm_connector *connector,
163
static bool intel_eld_uptodate(struct drm_connector *connector,
164
			       int reg_eldv, uint32_t bits_eldv,
164
			       i915_reg_t reg_eldv, uint32_t bits_eldv,
165
			       int reg_elda, uint32_t bits_elda,
165
			       i915_reg_t reg_elda, uint32_t bits_elda,
166
			       int reg_edid)
166
			       i915_reg_t reg_edid)
167
{
167
{
168
	struct drm_i915_private *dev_priv = connector->dev->dev_private;
168
	struct drm_i915_private *dev_priv = connector->dev->dev_private;
169
	uint8_t *eld = connector->eld;
169
	uint8_t *eld = connector->eld;
170
	uint32_t tmp;
170
	uint32_t tmp;
Line 362... Line 362...
362
	struct intel_digital_port *intel_dig_port =
362
	struct intel_digital_port *intel_dig_port =
363
		enc_to_dig_port(&encoder->base);
363
		enc_to_dig_port(&encoder->base);
364
	enum port port = intel_dig_port->port;
364
	enum port port = intel_dig_port->port;
365
	enum pipe pipe = intel_crtc->pipe;
365
	enum pipe pipe = intel_crtc->pipe;
366
	uint32_t tmp, eldv;
366
	uint32_t tmp, eldv;
367
	int aud_config;
-
 
368
	int aud_cntrl_st2;
367
	i915_reg_t aud_config, aud_cntrl_st2;
Line 369... Line 368...
369
 
368
 
370
	DRM_DEBUG_KMS("Disable audio codec on port %c, pipe %c\n",
369
	DRM_DEBUG_KMS("Disable audio codec on port %c, pipe %c\n",
Line 371... Line 370...
371
		      port_name(port), pipe_name(pipe));
370
		      port_name(port), pipe_name(pipe));
372
 
371
 
Line 373... Line 372...
373
	if (WARN_ON(port == PORT_A))
372
	if (WARN_ON(port == PORT_A))
374
		return;
373
		return;
375
 
374
 
376
	if (HAS_PCH_IBX(dev_priv->dev)) {
375
	if (HAS_PCH_IBX(dev_priv->dev)) {
377
		aud_config = IBX_AUD_CFG(pipe);
376
		aud_config = IBX_AUD_CFG(pipe);
378
		aud_cntrl_st2 = IBX_AUD_CNTL_ST2;
377
		aud_cntrl_st2 = IBX_AUD_CNTL_ST2;
379
	} else if (IS_VALLEYVIEW(dev_priv)) {
378
	} else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) {
380
		aud_config = VLV_AUD_CFG(pipe);
379
		aud_config = VLV_AUD_CFG(pipe);
381
		aud_cntrl_st2 = VLV_AUD_CNTL_ST2;
380
		aud_cntrl_st2 = VLV_AUD_CNTL_ST2;
Line 414... Line 413...
414
	enum pipe pipe = intel_crtc->pipe;
413
	enum pipe pipe = intel_crtc->pipe;
415
	uint8_t *eld = connector->eld;
414
	uint8_t *eld = connector->eld;
416
	uint32_t eldv;
415
	uint32_t eldv;
417
	uint32_t tmp;
416
	uint32_t tmp;
418
	int len, i;
417
	int len, i;
419
	int hdmiw_hdmiedid;
418
	i915_reg_t hdmiw_hdmiedid, aud_config, aud_cntl_st, aud_cntrl_st2;
420
	int aud_config;
-
 
421
	int aud_cntl_st;
-
 
422
	int aud_cntrl_st2;
-
 
Line 423... Line 419...
423
 
419
 
424
	DRM_DEBUG_KMS("Enable audio codec on port %c, pipe %c, %u bytes ELD\n",
420
	DRM_DEBUG_KMS("Enable audio codec on port %c, pipe %c, %u bytes ELD\n",
Line 425... Line 421...
425
		      port_name(port), pipe_name(pipe), drm_eld_size(eld));
421
		      port_name(port), pipe_name(pipe), drm_eld_size(eld));
Line 437... Line 433...
437
	if (HAS_PCH_IBX(connector->dev)) {
433
	if (HAS_PCH_IBX(connector->dev)) {
438
		hdmiw_hdmiedid = IBX_HDMIW_HDMIEDID(pipe);
434
		hdmiw_hdmiedid = IBX_HDMIW_HDMIEDID(pipe);
439
		aud_config = IBX_AUD_CFG(pipe);
435
		aud_config = IBX_AUD_CFG(pipe);
440
		aud_cntl_st = IBX_AUD_CNTL_ST(pipe);
436
		aud_cntl_st = IBX_AUD_CNTL_ST(pipe);
441
		aud_cntrl_st2 = IBX_AUD_CNTL_ST2;
437
		aud_cntrl_st2 = IBX_AUD_CNTL_ST2;
442
	} else if (IS_VALLEYVIEW(connector->dev)) {
438
	} else if (IS_VALLEYVIEW(connector->dev) ||
-
 
439
		   IS_CHERRYVIEW(connector->dev)) {
443
		hdmiw_hdmiedid = VLV_HDMIW_HDMIEDID(pipe);
440
		hdmiw_hdmiedid = VLV_HDMIW_HDMIEDID(pipe);
444
		aud_config = VLV_AUD_CFG(pipe);
441
		aud_config = VLV_AUD_CFG(pipe);
445
		aud_cntl_st = VLV_AUD_CNTL_ST(pipe);
442
		aud_cntl_st = VLV_AUD_CNTL_ST(pipe);
446
		aud_cntrl_st2 = VLV_AUD_CNTL_ST2;
443
		aud_cntrl_st2 = VLV_AUD_CNTL_ST2;
447
	} else {
444
	} else {
Line 523... Line 520...
523
 
520
 
524
	if (dev_priv->display.audio_codec_enable)
521
	if (dev_priv->display.audio_codec_enable)
525
		dev_priv->display.audio_codec_enable(connector, intel_encoder,
522
		dev_priv->display.audio_codec_enable(connector, intel_encoder,
Line -... Line 523...
-
 
523
						     adjusted_mode);
-
 
524
 
-
 
525
	mutex_lock(&dev_priv->av_mutex);
-
 
526
	intel_dig_port->audio_connector = connector;
-
 
527
	/* referred in audio callbacks */
-
 
528
	dev_priv->dig_port_map[port] = intel_encoder;
526
						     adjusted_mode);
529
	mutex_unlock(&dev_priv->av_mutex);
527
 
530
 
528
	if (acomp && acomp->audio_ops && acomp->audio_ops->pin_eld_notify)
531
	if (acomp && acomp->audio_ops && acomp->audio_ops->pin_eld_notify)
Line 529... Line 532...
529
		acomp->audio_ops->pin_eld_notify(acomp->audio_ops->audio_ptr, (int) port);
532
		acomp->audio_ops->pin_eld_notify(acomp->audio_ops->audio_ptr, (int) port);
Line 546... Line 549...
546
	enum port port = intel_dig_port->port;
549
	enum port port = intel_dig_port->port;
Line 547... Line 550...
547
 
550
 
548
	if (dev_priv->display.audio_codec_disable)
551
	if (dev_priv->display.audio_codec_disable)
Line -... Line 552...
-
 
552
		dev_priv->display.audio_codec_disable(intel_encoder);
-
 
553
 
-
 
554
	mutex_lock(&dev_priv->av_mutex);
-
 
555
	intel_dig_port->audio_connector = NULL;
-
 
556
	dev_priv->dig_port_map[port] = NULL;
549
		dev_priv->display.audio_codec_disable(intel_encoder);
557
	mutex_unlock(&dev_priv->av_mutex);
550
 
558
 
551
	if (acomp && acomp->audio_ops && acomp->audio_ops->pin_eld_notify)
559
	if (acomp && acomp->audio_ops && acomp->audio_ops->pin_eld_notify)
Line 552... Line 560...
552
		acomp->audio_ops->pin_eld_notify(acomp->audio_ops->audio_ptr, (int) port);
560
		acomp->audio_ops->pin_eld_notify(acomp->audio_ops->audio_ptr, (int) port);
Line 589... Line 597...
589
						     bool enable)
597
						     bool enable)
590
{
598
{
591
	struct drm_i915_private *dev_priv = dev_to_i915(dev);
599
	struct drm_i915_private *dev_priv = dev_to_i915(dev);
592
	u32 tmp;
600
	u32 tmp;
Line 593... Line 601...
593
 
601
 
594
	if (!IS_SKYLAKE(dev_priv))
602
	if (!IS_SKYLAKE(dev_priv) && !IS_KABYLAKE(dev_priv))
Line 595... Line 603...
595
		return;
603
		return;
596
 
604
 
597
	/*
605
	/*
Line 630... Line 638...
630
 
638
 
631
static int i915_audio_component_sync_audio_rate(struct device *dev,
639
static int i915_audio_component_sync_audio_rate(struct device *dev,
632
						int port, int rate)
640
						int port, int rate)
633
{
641
{
634
	struct drm_i915_private *dev_priv = dev_to_i915(dev);
-
 
635
	struct drm_device *drm_dev = dev_priv->dev;
642
	struct drm_i915_private *dev_priv = dev_to_i915(dev);
636
	struct intel_encoder *intel_encoder;
-
 
637
	struct intel_digital_port *intel_dig_port;
643
	struct intel_encoder *intel_encoder;
638
	struct intel_crtc *crtc;
644
	struct intel_crtc *crtc;
639
	struct drm_display_mode *mode;
645
	struct drm_display_mode *mode;
640
	struct i915_audio_component *acomp = dev_priv->audio_component;
646
	struct i915_audio_component *acomp = dev_priv->audio_component;
641
	enum pipe pipe = -1;
647
	enum pipe pipe = INVALID_PIPE;
642
	u32 tmp;
648
	u32 tmp;
-
 
649
	int n;
Line 643... Line 650...
643
	int n;
650
	int err = 0;
644
 
651
 
-
 
652
	/* HSW, BDW, SKL, KBL need this fix */
645
	/* HSW, BDW SKL need this fix */
653
	if (!IS_SKYLAKE(dev_priv) &&
646
	if (!IS_SKYLAKE(dev_priv) &&
654
	    !IS_KABYLAKE(dev_priv) &&
647
		!IS_BROADWELL(dev_priv) &&
655
		!IS_BROADWELL(dev_priv) &&
Line 648... Line 656...
648
		!IS_HASWELL(dev_priv))
656
		!IS_HASWELL(dev_priv))
649
		return 0;
657
		return 0;
650
 
658
 
651
	mutex_lock(&dev_priv->av_mutex);
659
	mutex_lock(&dev_priv->av_mutex);
652
	/* 1. get the pipe */
-
 
653
	for_each_intel_encoder(drm_dev, intel_encoder) {
660
	/* 1. get the pipe */
654
		if (intel_encoder->type != INTEL_OUTPUT_HDMI)
661
	intel_encoder = dev_priv->dig_port_map[port];
655
			continue;
662
	/* intel_encoder might be NULL for DP MST */
656
		intel_dig_port = enc_to_dig_port(&intel_encoder->base);
663
	if (!intel_encoder || !intel_encoder->base.crtc ||
657
		if (port == intel_dig_port->port) {
-
 
658
			crtc = to_intel_crtc(intel_encoder->base.crtc);
664
	    intel_encoder->type != INTEL_OUTPUT_HDMI) {
659
			if (!crtc) {
665
		DRM_DEBUG_KMS("no valid port %c\n", port_name(port));
-
 
666
		err = -ENODEV;
660
				DRM_DEBUG_KMS("%s: crtc is NULL\n", __func__);
667
		goto unlock;
661
				continue;
-
 
662
			}
-
 
663
			pipe = crtc->pipe;
-
 
664
			break;
-
 
665
		}
668
	}
666
	}
669
			crtc = to_intel_crtc(intel_encoder->base.crtc);
667
 
670
			pipe = crtc->pipe;
668
	if (pipe == INVALID_PIPE) {
671
	if (pipe == INVALID_PIPE) {
669
		DRM_DEBUG_KMS("no pipe for the port %c\n", port_name(port));
672
		DRM_DEBUG_KMS("no pipe for the port %c\n", port_name(port));
-
 
673
		err = -ENODEV;
670
		mutex_unlock(&dev_priv->av_mutex);
674
		goto unlock;
671
		return -ENODEV;
675
	}
672
	}
676
 
Line 673... Line 677...
673
	DRM_DEBUG_KMS("pipe %c connects port %c\n",
677
	DRM_DEBUG_KMS("pipe %c connects port %c\n",
Line 680... Line 684...
680
	/* 2. check whether to set the N/CTS/M manually or not */
684
	/* 2. check whether to set the N/CTS/M manually or not */
681
	if (!audio_rate_need_prog(crtc, mode)) {
685
	if (!audio_rate_need_prog(crtc, mode)) {
682
		tmp = I915_READ(HSW_AUD_CFG(pipe));
686
		tmp = I915_READ(HSW_AUD_CFG(pipe));
683
		tmp &= ~AUD_CONFIG_N_PROG_ENABLE;
687
		tmp &= ~AUD_CONFIG_N_PROG_ENABLE;
684
		I915_WRITE(HSW_AUD_CFG(pipe), tmp);
688
		I915_WRITE(HSW_AUD_CFG(pipe), tmp);
685
		mutex_unlock(&dev_priv->av_mutex);
-
 
686
		return 0;
689
		goto unlock;
687
	}
690
	}
Line 688... Line 691...
688
 
691
 
689
	n = audio_config_get_n(mode, rate);
692
	n = audio_config_get_n(mode, rate);
690
	if (n == 0) {
693
	if (n == 0) {
691
		DRM_DEBUG_KMS("Using automatic mode for N value on port %c\n",
694
		DRM_DEBUG_KMS("Using automatic mode for N value on port %c\n",
692
					  port_name(port));
695
					  port_name(port));
693
		tmp = I915_READ(HSW_AUD_CFG(pipe));
696
		tmp = I915_READ(HSW_AUD_CFG(pipe));
694
		tmp &= ~AUD_CONFIG_N_PROG_ENABLE;
697
		tmp &= ~AUD_CONFIG_N_PROG_ENABLE;
695
		I915_WRITE(HSW_AUD_CFG(pipe), tmp);
-
 
696
		mutex_unlock(&dev_priv->av_mutex);
698
		I915_WRITE(HSW_AUD_CFG(pipe), tmp);
697
		return 0;
699
		goto unlock;
Line 698... Line 700...
698
	}
700
	}
699
 
701
 
700
	/* 3. set the N/CTS/M */
702
	/* 3. set the N/CTS/M */
701
	tmp = I915_READ(HSW_AUD_CFG(pipe));
703
	tmp = I915_READ(HSW_AUD_CFG(pipe));
Line -... Line 704...
-
 
704
	tmp = audio_config_setup_n_reg(n, tmp);
702
	tmp = audio_config_setup_n_reg(n, tmp);
705
	I915_WRITE(HSW_AUD_CFG(pipe), tmp);
703
	I915_WRITE(HSW_AUD_CFG(pipe), tmp);
706
 
-
 
707
 unlock:
-
 
708
	mutex_unlock(&dev_priv->av_mutex);
-
 
709
	return err;
-
 
710
}
-
 
711
 
-
 
712
static int i915_audio_component_get_eld(struct device *dev, int port,
-
 
713
					bool *enabled,
-
 
714
					unsigned char *buf, int max_bytes)
-
 
715
{
-
 
716
	struct drm_i915_private *dev_priv = dev_to_i915(dev);
-
 
717
	struct intel_encoder *intel_encoder;
-
 
718
	struct intel_digital_port *intel_dig_port;
-
 
719
	const u8 *eld;
-
 
720
	int ret = -EINVAL;
-
 
721
 
-
 
722
	mutex_lock(&dev_priv->av_mutex);
-
 
723
	intel_encoder = dev_priv->dig_port_map[port];
-
 
724
	/* intel_encoder might be NULL for DP MST */
-
 
725
	if (intel_encoder) {
-
 
726
		ret = 0;
-
 
727
		intel_dig_port = enc_to_dig_port(&intel_encoder->base);
-
 
728
		*enabled = intel_dig_port->audio_connector != NULL;
-
 
729
		if (*enabled) {
-
 
730
			eld = intel_dig_port->audio_connector->eld;
-
 
731
			ret = drm_eld_size(eld);
-
 
732
			memcpy(buf, eld, min(max_bytes, ret));
-
 
733
		}
-
 
734
	}
704
 
735
 
Line 705... Line 736...
705
	mutex_unlock(&dev_priv->av_mutex);
736
	mutex_unlock(&dev_priv->av_mutex);
706
	return 0;
737
	return ret;
707
}
738
}
708
 
739
 
709
static const struct i915_audio_component_ops i915_audio_component_ops = {
740
static const struct i915_audio_component_ops i915_audio_component_ops = {
710
	.owner		= THIS_MODULE,
741
	.owner		= THIS_MODULE,
711
	.get_power	= i915_audio_component_get_power,
742
	.get_power	= i915_audio_component_get_power,
-
 
743
	.put_power	= i915_audio_component_put_power,
712
	.put_power	= i915_audio_component_put_power,
744
	.codec_wake_override = i915_audio_component_codec_wake_override,
Line 713... Line 745...
713
	.codec_wake_override = i915_audio_component_codec_wake_override,
745
	.get_cdclk_freq	= i915_audio_component_get_cdclk_freq,
714
	.get_cdclk_freq	= i915_audio_component_get_cdclk_freq,
746
	.sync_audio_rate = i915_audio_component_sync_audio_rate,
715
	.sync_audio_rate = i915_audio_component_sync_audio_rate,
747
	.get_eld	= i915_audio_component_get_eld,
Line 771... Line 803...
771
 * We ignore any error during registration and continue with reduced
803
 * We ignore any error during registration and continue with reduced
772
 * functionality (i.e. without HDMI audio).
804
 * functionality (i.e. without HDMI audio).
773
 */
805
 */
774
void i915_audio_component_init(struct drm_i915_private *dev_priv)
806
void i915_audio_component_init(struct drm_i915_private *dev_priv)
775
{
807
{
-
 
808
	int ret;
-
 
809
 
-
 
810
//	ret = component_add(dev_priv->dev->dev, &i915_audio_component_bind_ops);
-
 
811
//	if (ret < 0) {
-
 
812
//		DRM_ERROR("failed to add audio component (%d)\n", ret);
-
 
813
//		/* continue with reduced functionality */
-
 
814
//		return;
-
 
815
//	}
-
 
816
 
-
 
817
	dev_priv->audio_component_registered = true;
776
}
818
}
Line 777... Line 819...
777
 
819
 
778
/**
820
/**
779
 * i915_audio_component_cleanup - deregister the audio component
821
 * i915_audio_component_cleanup - deregister the audio component
Line 782... Line 824...
782
 * Deregisters the audio component, breaking any existing binding to the
824
 * Deregisters the audio component, breaking any existing binding to the
783
 * corresponding snd_hda_intel driver's master component.
825
 * corresponding snd_hda_intel driver's master component.
784
 */
826
 */
785
void i915_audio_component_cleanup(struct drm_i915_private *dev_priv)
827
void i915_audio_component_cleanup(struct drm_i915_private *dev_priv)
786
{
828
{
-
 
829
	if (!dev_priv->audio_component_registered)
-
 
830
		return;
-
 
831
 
-
 
832
//	component_del(dev_priv->dev->dev, &i915_audio_component_bind_ops);
-
 
833
	dev_priv->audio_component_registered = false;
787
}
834
}