Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 172834
Collapse All | Expand All

(-)a/alsa-kernel/pci/hda/patch_conexant.c (-191 / +104 lines)
Lines 452-566 static int conexant_ch_mode_put(struct s Link Here
452
	  .put = conexant_ch_mode_put, \
452
	  .put = conexant_ch_mode_put, \
453
	  .private_value = nid | (dir<<16) }
453
	  .private_value = nid | (dir<<16) }
454
454
455
static int cxt_gpio_data_info(struct snd_kcontrol *kcontrol,
456
			      struct snd_ctl_elem_info *uinfo)
457
{
458
	uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
459
	uinfo->count = 1;
460
	uinfo->value.integer.min = 0;
461
	uinfo->value.integer.max = 1;
462
	return 0;
463
}                                
464
465
static int cxt_gpio_data_get(struct snd_kcontrol *kcontrol,
466
			     struct snd_ctl_elem_value *ucontrol)
467
{
468
	struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
469
	hda_nid_t nid = kcontrol->private_value & 0xffff;
470
	unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
471
	long *valp = ucontrol->value.integer.value;
472
	unsigned int val = snd_hda_codec_read(codec, nid, 0,
473
					      AC_VERB_GET_GPIO_DATA, 0x00);
474
475
	*valp = (val & mask) != 0;
476
	return 0;
477
}
478
479
static int cxt_gpio_data_put(struct snd_kcontrol *kcontrol,
480
			     struct snd_ctl_elem_value *ucontrol)
481
{
482
	struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
483
	hda_nid_t nid = kcontrol->private_value & 0xffff;
484
	unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
485
	long val = *ucontrol->value.integer.value;
486
	unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
487
						    AC_VERB_GET_GPIO_DATA,
488
						    0x00);
489
	unsigned int old_data = gpio_data;
490
491
	/* Set/unset the masked GPIO bit(s) as needed */
492
	if (val == 0)
493
		gpio_data &= ~mask;
494
	else
495
		gpio_data |= mask;
496
	if (gpio_data == old_data && !codec->in_resume)
497
		return 0;
498
	snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data);
499
	return 1;
500
}
501
502
#define CXT_GPIO_DATA_SWITCH(xname, nid, mask) \
503
	{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0,  \
504
	  .info = cxt_gpio_data_info, \
505
	  .get = cxt_gpio_data_get, \
506
	  .put = cxt_gpio_data_put, \
507
	  .private_value = nid | (mask<<16) }
508
#if 0
509
static int cxt_spdif_ctrl_info(struct snd_kcontrol *kcontrol,
510
			       struct snd_ctl_elem_info *uinfo)
511
{
512
	uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
513
	uinfo->count = 1;
514
	uinfo->value.integer.min = 0;
515
	uinfo->value.integer.max = 1;
516
	return 0;
517
}                                
518
519
static int cxt_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
520
			      struct snd_ctl_elem_value *ucontrol)
521
{
522
	struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
523
	hda_nid_t nid = kcontrol->private_value & 0xffff;
524
	unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
525
	long *valp = ucontrol->value.integer.value;
526
	unsigned int val = snd_hda_codec_read(codec, nid, 0,
527
					      AC_VERB_GET_DIGI_CONVERT, 0x00);
528
529
	*valp = (val & mask) != 0;
530
	return 0;
531
}
532
533
static int cxt_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
534
			      struct snd_ctl_elem_value *ucontrol)
535
{
536
	struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
537
	hda_nid_t nid = kcontrol->private_value & 0xffff;
538
	unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
539
	long val = *ucontrol->value.integer.value;
540
	unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
541
						    AC_VERB_GET_DIGI_CONVERT,
542
						    0x00);
543
	unsigned int old_data = ctrl_data;
544
545
	/* Set/unset the masked control bit(s) as needed */
546
	if (val == 0)
547
		ctrl_data &= ~mask;
548
	else
549
		ctrl_data |= mask;
550
	if (ctrl_data == old_data && !codec->in_resume)
551
		return 0;
552
	snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
553
			    ctrl_data);
554
	return 1;
555
}
556
557
#define CXT_SPDIF_CTRL_SWITCH(xname, nid, mask) \
558
	{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0,  \
559
	  .info = cxt_spdif_ctrl_info, \
560
	  .get = cxt_spdif_ctrl_get, \
561
	  .put = cxt_spdif_ctrl_put, \
562
	  .private_value = nid | (mask<<16) }
563
#endif
564
#endif /* CONFIG_SND_DEBUG */
455
#endif /* CONFIG_SND_DEBUG */
565
456
566
/* Conexant 5045 specific */
457
/* Conexant 5045 specific */
Lines 599-604 static int cxt5045_hp_master_sw_put(stru Link Here
599
	bits = (!spec->hp_present && spec->cur_eapd) ? 0 : 0x80;
490
	bits = (!spec->hp_present && spec->cur_eapd) ? 0 : 0x80;
600
	snd_hda_codec_amp_update(codec, 0x10, 0, HDA_OUTPUT, 0, 0x80, bits);
491
	snd_hda_codec_amp_update(codec, 0x10, 0, HDA_OUTPUT, 0, 0x80, bits);
601
	snd_hda_codec_amp_update(codec, 0x10, 1, HDA_OUTPUT, 0, 0x80, bits);
492
	snd_hda_codec_amp_update(codec, 0x10, 1, HDA_OUTPUT, 0, 0x80, bits);
493
602
	bits = spec->cur_eapd ? 0 : 0x80;
494
	bits = spec->cur_eapd ? 0 : 0x80;
603
	snd_hda_codec_amp_update(codec, 0x11, 0, HDA_OUTPUT, 0, 0x80, bits);
495
	snd_hda_codec_amp_update(codec, 0x11, 0, HDA_OUTPUT, 0, 0x80, bits);
604
	snd_hda_codec_amp_update(codec, 0x11, 1, HDA_OUTPUT, 0, 0x80, bits);
496
	snd_hda_codec_amp_update(codec, 0x11, 1, HDA_OUTPUT, 0, 0x80, bits);
Lines 624-638 static int cxt5045_hp_master_vol_put(str Link Here
624
	return change;
516
	return change;
625
}
517
}
626
518
519
/* toggle input of built-in and mic jack appropriately */
520
static void cxt5045_hp_automic(struct hda_codec *codec)
521
{
522
	static struct hda_verb mic_jack_on[] = {
523
		{0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
524
		{0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
525
		{}
526
	};
527
	static struct hda_verb mic_jack_off[] = {
528
		{0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
529
		{0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
530
		{}
531
	};
532
	unsigned int present;
533
534
	present = snd_hda_codec_read(codec, 0x12, 0,
535
				     AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
536
	if (present)
537
		snd_hda_sequence_write(codec, mic_jack_on);
538
	else
539
		snd_hda_sequence_write(codec, mic_jack_off);
540
}
541
627
542
628
/* mute internal speaker if HP is plugged */
543
/* mute internal speaker if HP is plugged */
629
static void cxt5045_hp_automute(struct hda_codec *codec)
544
static void cxt5045_hp_automute(struct hda_codec *codec)
630
{
545
{
631
	struct conexant_spec *spec = codec->spec;
546
	struct conexant_spec *spec = codec->spec;
632
	unsigned int bits = (spec->hp_present || !spec->cur_eapd) ? 0x80 : 0;
547
	unsigned int bits;
633
548
634
	spec->hp_present = snd_hda_codec_read(codec, 0x11, 0,
549
	spec->hp_present = snd_hda_codec_read(codec, 0x11, 0,
635
				     AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
550
				     AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
551
552
	bits = (spec->hp_present || !spec->cur_eapd) ? 0x80 : 0; 
636
	snd_hda_codec_amp_update(codec, 0x10, 0, HDA_OUTPUT, 0, 0x80, bits);
553
	snd_hda_codec_amp_update(codec, 0x10, 0, HDA_OUTPUT, 0, 0x80, bits);
637
	snd_hda_codec_amp_update(codec, 0x10, 1, HDA_OUTPUT, 0, 0x80, bits);
554
	snd_hda_codec_amp_update(codec, 0x10, 1, HDA_OUTPUT, 0, 0x80, bits);
638
}
555
}
Lines 646-651 static void cxt5045_hp_unsol_event(struc Link Here
646
	case CONEXANT_HP_EVENT:
563
	case CONEXANT_HP_EVENT:
647
		cxt5045_hp_automute(codec);
564
		cxt5045_hp_automute(codec);
648
		break;
565
		break;
566
	case CONEXANT_MIC_EVENT:
567
		cxt5045_hp_automic(codec);
568
		break;
569
649
	}
570
	}
650
}
571
}
651
572
Lines 657-668 static struct snd_kcontrol_new cxt5045_m Link Here
657
		.get = conexant_mux_enum_get,
578
		.get = conexant_mux_enum_get,
658
		.put = conexant_mux_enum_put
579
		.put = conexant_mux_enum_put
659
	},
580
	},
660
	HDA_CODEC_VOLUME("Int Mic Volume", 0x17, 0x01, HDA_INPUT),
581
	HDA_CODEC_VOLUME("Int Mic Volume", 0x1a, 0x01, HDA_INPUT),
661
	HDA_CODEC_MUTE("Int Mic Switch", 0x17, 0x01, HDA_INPUT),
582
	HDA_CODEC_MUTE("Int Mic Switch", 0x1a, 0x01, HDA_INPUT),
662
	HDA_CODEC_VOLUME("Ext Mic Volume", 0x17, 0x02, HDA_INPUT),
583
	HDA_CODEC_VOLUME("Ext Mic Volume", 0x1a, 0x02, HDA_INPUT),
663
	HDA_CODEC_MUTE("Ext Mic Switch", 0x17, 0x02, HDA_INPUT),
584
	HDA_CODEC_MUTE("Ext Mic Switch", 0x1a, 0x02, HDA_INPUT),
664
	HDA_CODEC_VOLUME("Capture Volume", 0x1a, 0x0, HDA_INPUT),
665
	HDA_CODEC_MUTE("Capture Switch", 0x1a, 0x0, HDA_INPUT),
666
	{
585
	{
667
		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
586
		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
668
		.name = "Master Playback Volume",
587
		.name = "Master Playback Volume",
Lines 686-692 static struct hda_verb cxt5045_init_verb Link Here
686
static struct hda_verb cxt5045_init_verbs[] = {
605
static struct hda_verb cxt5045_init_verbs[] = {
687
	/* Line in, Mic */
606
	/* Line in, Mic */
688
	{0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
607
	{0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
689
	{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 },
608
	{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 },
690
	/* HP, Amp  */
609
	/* HP, Amp  */
691
	{0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
610
	{0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
692
	{0x17, AC_VERB_SET_CONNECT_SEL,0x01},
611
	{0x17, AC_VERB_SET_CONNECT_SEL,0x01},
Lines 699-713 static struct hda_verb cxt5045_init_verb Link Here
699
	{0x17, AC_VERB_SET_AMP_GAIN_MUTE,
618
	{0x17, AC_VERB_SET_AMP_GAIN_MUTE,
700
	 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x04},
619
	 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x04},
701
	/* Record selector: Int mic */
620
	/* Record selector: Int mic */
702
	{0x1a, AC_VERB_SET_CONNECT_SEL,0x0},
621
	{0x1a, AC_VERB_SET_CONNECT_SEL,0x1},
703
	{0x1a, AC_VERB_SET_AMP_GAIN_MUTE,
622
	{0x1a, AC_VERB_SET_AMP_GAIN_MUTE,
704
	 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
623
	 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
705
	/* SPDIF route: PCM */
624
	/* SPDIF route: PCM */
706
	{ 0x13, AC_VERB_SET_CONNECT_SEL, 0x0 },
625
	{ 0x13, AC_VERB_SET_CONNECT_SEL, 0x0 },
707
	/* pin sensing on HP and Mic jacks */
708
	{0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
709
	/* EAPD */
626
	/* EAPD */
710
	{0x10, AC_VERB_SET_EAPD_BTLENABLE, 0x2 }, /* default on */ 
627
	{0x10, AC_VERB_SET_EAPD_BTLENABLE, 0x2 }, /* default on */ 
628
	{ } /* end */
629
};
630
631
632
static struct hda_verb cxt5045_hp_sense_init_verbs[] = {
633
	/* pin sensing on HP jack */
634
	{0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
635
	{ } /* end */
636
};
637
638
static struct hda_verb cxt5045_mic_sense_init_verbs[] = {
639
	/* pin sensing on HP jack */
640
	{0x12, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
711
	{ } /* end */
641
	{ } /* end */
712
};
642
};
713
643
Lines 731-736 static struct snd_kcontrol_new cxt5045_t Link Here
731
	/* Output controls */
661
	/* Output controls */
732
	HDA_CODEC_VOLUME("Speaker Playback Volume", 0x10, 0x0, HDA_OUTPUT),
662
	HDA_CODEC_VOLUME("Speaker Playback Volume", 0x10, 0x0, HDA_OUTPUT),
733
	HDA_CODEC_MUTE("Speaker Playback Switch", 0x10, 0x0, HDA_OUTPUT),
663
	HDA_CODEC_MUTE("Speaker Playback Switch", 0x10, 0x0, HDA_OUTPUT),
664
	HDA_CODEC_VOLUME("Node 11 Playback Volume", 0x11, 0x0, HDA_OUTPUT),
665
	HDA_CODEC_MUTE("Node 11 Playback Switch", 0x11, 0x0, HDA_OUTPUT),
666
	HDA_CODEC_VOLUME("Node 12 Playback Volume", 0x12, 0x0, HDA_OUTPUT),
667
	HDA_CODEC_MUTE("Node 12 Playback Switch", 0x12, 0x0, HDA_OUTPUT),
734
	
668
	
735
	/* Modes for retasking pin widgets */
669
	/* Modes for retasking pin widgets */
736
	CXT_PIN_MODE("HP-OUT pin mode", 0x11, CXT_PIN_DIR_INOUT),
670
	CXT_PIN_MODE("HP-OUT pin mode", 0x11, CXT_PIN_DIR_INOUT),
Lines 740-764 static struct snd_kcontrol_new cxt5045_t Link Here
740
	CXT_EAPD_SWITCH("External Amplifier", 0x10, 0x0),
674
	CXT_EAPD_SWITCH("External Amplifier", 0x10, 0x0),
741
675
742
	/* Loopback mixer controls */
676
	/* Loopback mixer controls */
743
	HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x17, 0x01, HDA_INPUT),
677
744
	HDA_CODEC_MUTE("MIC1 Playback Switch", 0x17, 0x01, HDA_INPUT),
678
	HDA_CODEC_VOLUME("Mixer-1 Volume", 0x17, 0x0, HDA_INPUT),
745
	HDA_CODEC_VOLUME("LINE loopback Playback Volume", 0x17, 0x02, HDA_INPUT),
679
	HDA_CODEC_MUTE("Mixer-1 Switch", 0x17, 0x0, HDA_INPUT),
746
	HDA_CODEC_MUTE("LINE loopback Playback Switch", 0x17, 0x02, HDA_INPUT),
680
	HDA_CODEC_VOLUME("Mixer-2 Volume", 0x17, 0x1, HDA_INPUT),
747
	HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x17, 0x03, HDA_INPUT),
681
	HDA_CODEC_MUTE("Mixer-2 Switch", 0x17, 0x1, HDA_INPUT),
748
	HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x17, 0x03, HDA_INPUT),
682
	HDA_CODEC_VOLUME("Mixer-3 Volume", 0x17, 0x2, HDA_INPUT),
749
	HDA_CODEC_VOLUME("CD Playback Volume", 0x17, 0x04, HDA_INPUT),
683
	HDA_CODEC_MUTE("Mixer-3 Switch", 0x17, 0x2, HDA_INPUT),
750
	HDA_CODEC_MUTE("CD Playback Switch", 0x17, 0x04, HDA_INPUT),
684
	HDA_CODEC_VOLUME("Mixer-4 Volume", 0x17, 0x3, HDA_INPUT),
751
685
	HDA_CODEC_MUTE("Mixer-4 Switch", 0x17, 0x3, HDA_INPUT),
752
	HDA_CODEC_VOLUME("Capture-1 Volume", 0x17, 0x0, HDA_INPUT),
686
	HDA_CODEC_VOLUME("Mixer-5 Volume", 0x17, 0x4, HDA_INPUT),
753
	HDA_CODEC_MUTE("Capture-1 Switch", 0x17, 0x0, HDA_INPUT),
687
	HDA_CODEC_MUTE("Mixer-5 Switch", 0x17, 0x4, HDA_INPUT),
754
	HDA_CODEC_VOLUME("Capture-2 Volume", 0x17, 0x1, HDA_INPUT),
755
	HDA_CODEC_MUTE("Capture-2 Switch", 0x17, 0x1, HDA_INPUT),
756
	HDA_CODEC_VOLUME("Capture-3 Volume", 0x17, 0x2, HDA_INPUT),
757
	HDA_CODEC_MUTE("Capture-3 Switch", 0x17, 0x2, HDA_INPUT),
758
	HDA_CODEC_VOLUME("Capture-4 Volume", 0x17, 0x3, HDA_INPUT),
759
	HDA_CODEC_MUTE("Capture-4 Switch", 0x17, 0x3, HDA_INPUT),
760
	HDA_CODEC_VOLUME("Capture-5 Volume", 0x17, 0x4, HDA_INPUT),
761
	HDA_CODEC_MUTE("Capture-5 Switch", 0x17, 0x4, HDA_INPUT),
762
	{
688
	{
763
		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
689
		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
764
		.name = "Input Source",
690
		.name = "Input Source",
Lines 766-779 static struct snd_kcontrol_new cxt5045_t Link Here
766
		.get = conexant_mux_enum_get,
692
		.get = conexant_mux_enum_get,
767
		.put = conexant_mux_enum_put,
693
		.put = conexant_mux_enum_put,
768
	},
694
	},
769
770
	{ } /* end */
695
	{ } /* end */
771
};
696
};
772
697
773
static struct hda_verb cxt5045_test_init_verbs[] = {
698
static struct hda_verb cxt5045_test_init_verbs[] = {
699
	/* Set connections */
700
	{ 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 },
701
	{ 0x11, AC_VERB_SET_CONNECT_SEL, 0x0 },
702
	{ 0x12, AC_VERB_SET_CONNECT_SEL, 0x0 },
774
	/* Enable retasking pins as output, initially without power amp */
703
	/* Enable retasking pins as output, initially without power amp */
775
	{0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
704
	{0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
776
	{0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
705
	{0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
777
706
778
	/* Disable digital (SPDIF) pins initially, but users can enable
707
	/* Disable digital (SPDIF) pins initially, but users can enable
779
	 * them via a mixer switch.  In the case of SPDIF-out, this initverb
708
	 * them via a mixer switch.  In the case of SPDIF-out, this initverb
Lines 802-807 static struct hda_verb cxt5045_test_init Link Here
802
	 * pin)
731
	 * pin)
803
	 */
732
	 */
804
	{0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
733
	{0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
734
	{0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
805
735
806
	/* Mute all inputs to mixer widget (even unconnected ones) */
736
	/* Mute all inputs to mixer widget (even unconnected ones) */
807
	{0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* Mixer pin */
737
	{0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* Mixer pin */
Lines 825-831 static int cxt5045_init(struct hda_codec Link Here
825
755
826
756
827
enum {
757
enum {
828
	CXT5045_LAPTOP,	/* Laptops w/ EAPD support */
758
	CXT5045_LAPTOP,	 /* Laptops w/ EAPD support */
759
	CXT5045_FUJITSU, /* Laptops w/ EAPD support */ 
829
#ifdef CONFIG_SND_DEBUG
760
#ifdef CONFIG_SND_DEBUG
830
	CXT5045_TEST,
761
	CXT5045_TEST,
831
#endif
762
#endif
Lines 834-839 enum { Link Here
834
765
835
static const char *cxt5045_models[CXT5045_MODELS] = {
766
static const char *cxt5045_models[CXT5045_MODELS] = {
836
	[CXT5045_LAPTOP]	= "laptop",
767
	[CXT5045_LAPTOP]	= "laptop",
768
	[CXT5045_FUJITSU]	= "fujitsu",
837
#ifdef CONFIG_SND_DEBUG
769
#ifdef CONFIG_SND_DEBUG
838
	[CXT5045_TEST]		= "test",
770
	[CXT5045_TEST]		= "test",
839
#endif
771
#endif
Lines 842-848 static struct snd_pci_quirk cxt5045_cfg_ Link Here
842
static struct snd_pci_quirk cxt5045_cfg_tbl[] = {
774
static struct snd_pci_quirk cxt5045_cfg_tbl[] = {
843
	SND_PCI_QUIRK(0x103c, 0x30b7, "HP DV6000Z", CXT5045_LAPTOP),
775
	SND_PCI_QUIRK(0x103c, 0x30b7, "HP DV6000Z", CXT5045_LAPTOP),
844
	SND_PCI_QUIRK(0x103c, 0x30bb, "HP DV8000", CXT5045_LAPTOP),
776
	SND_PCI_QUIRK(0x103c, 0x30bb, "HP DV8000", CXT5045_LAPTOP),
845
	SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_LAPTOP),
777
	SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_FUJITSU),
778
	SND_PCI_QUIRK(0x8086, 0x2111, "Conexant Reference board", CXT5045_LAPTOP),
846
	{}
779
	{}
847
};
780
};
848
781
Lines 875-890 static int patch_cxt5045(struct hda_code Link Here
875
808
876
809
877
	codec->patch_ops = conexant_patch_ops;
810
	codec->patch_ops = conexant_patch_ops;
878
	codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
879
811
880
	board_config = snd_hda_check_board_config(codec, CXT5045_MODELS,
812
	board_config = snd_hda_check_board_config(codec, CXT5045_MODELS,
881
						  cxt5045_models,
813
						  cxt5045_models,
882
						  cxt5045_cfg_tbl);
814
						  cxt5045_cfg_tbl);
883
	switch (board_config) {
815
	switch (board_config) {
884
	case CXT5045_LAPTOP:
816
	case CXT5045_LAPTOP:
817
		codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
885
		spec->input_mux = &cxt5045_capture_source;
818
		spec->input_mux = &cxt5045_capture_source;
886
		spec->num_init_verbs = 2;
819
		spec->num_init_verbs = 2;
887
		spec->init_verbs[1] = cxt5045_init_verbs;
820
		spec->init_verbs[1] = cxt5045_hp_sense_init_verbs;
821
		spec->mixers[0] = cxt5045_mixers;
822
		codec->patch_ops.init = cxt5045_init;
823
		break;
824
	case CXT5045_FUJITSU:
825
		spec->input_mux = &cxt5045_capture_source;
826
		spec->num_init_verbs = 2;
827
		spec->init_verbs[1] = cxt5045_mic_sense_init_verbs;
888
		spec->mixers[0] = cxt5045_mixers;
828
		spec->mixers[0] = cxt5045_mixers;
889
		codec->patch_ops.init = cxt5045_init;
829
		codec->patch_ops.init = cxt5045_init;
890
		break;
830
		break;
Lines 911-920 static struct hda_channel_mode cxt5047_m Link Here
911
};
851
};
912
852
913
static struct hda_input_mux cxt5047_capture_source = {
853
static struct hda_input_mux cxt5047_capture_source = {
914
	.num_items = 2,
854
	.num_items = 1,
915
	.items = {
855
	.items = {
916
		{ "ExtMic", 0x0 },
856
		{ "Mic", 0x2 },
917
		{ "IntMic", 0x1 },
918
	}
857
	}
919
};
858
};
920
859
Lines 979-988 static void cxt5047_hp_automute(struct h Link Here
979
static void cxt5047_hp_automute(struct hda_codec *codec)
918
static void cxt5047_hp_automute(struct hda_codec *codec)
980
{
919
{
981
	struct conexant_spec *spec = codec->spec;
920
	struct conexant_spec *spec = codec->spec;
982
	unsigned int bits = spec->hp_present || !spec->cur_eapd ? 0x80 : 0;
921
	unsigned int bits;
983
922
984
	spec->hp_present = snd_hda_codec_read(codec, 0x13, 0,
923
	spec->hp_present = snd_hda_codec_read(codec, 0x13, 0,
985
				     AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
924
				     AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
925
926
	bits = (spec->hp_present || !spec->cur_eapd) ? 0x80 : 0;
986
	snd_hda_codec_amp_update(codec, 0x1d, 0, HDA_OUTPUT, 0, 0x80, bits);
927
	snd_hda_codec_amp_update(codec, 0x1d, 0, HDA_OUTPUT, 0, 0x80, bits);
987
	snd_hda_codec_amp_update(codec, 0x1d, 1, HDA_OUTPUT, 0, 0x80, bits);
928
	snd_hda_codec_amp_update(codec, 0x1d, 1, HDA_OUTPUT, 0, 0x80, bits);
988
	/* Mute/Unmute PCM 2 for good measure - some systems need this */
929
	/* Mute/Unmute PCM 2 for good measure - some systems need this */
Lines 1005-1011 static void cxt5047_hp_automic(struct hd Link Here
1005
	};
946
	};
1006
	unsigned int present;
947
	unsigned int present;
1007
948
1008
	present = snd_hda_codec_read(codec, 0x08, 0,
949
	present = snd_hda_codec_read(codec, 0x15, 0,
1009
				     AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
950
				     AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1010
	if (present)
951
	if (present)
1011
		snd_hda_sequence_write(codec, mic_jack_on);
952
		snd_hda_sequence_write(codec, mic_jack_on);
Lines 1029-1065 static void cxt5047_hp_unsol_event(struc Link Here
1029
}
970
}
1030
971
1031
static struct snd_kcontrol_new cxt5047_mixers[] = {
972
static struct snd_kcontrol_new cxt5047_mixers[] = {
1032
	{
1033
		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1034
		.name = "Capture Source",
1035
		.info = conexant_mux_enum_info,
1036
		.get = conexant_mux_enum_get,
1037
		.put = conexant_mux_enum_put
1038
	},
1039
	HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT),
973
	HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT),
1040
	HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19, 0x02, HDA_INPUT),
974
	HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19, 0x02, HDA_INPUT),
975
	HDA_CODEC_VOLUME("Mic Gain Volume", 0x1a, 0x0, HDA_OUTPUT),
976
	HDA_CODEC_MUTE("Mic Gain Switch", 0x1a, 0x0, HDA_OUTPUT),
1041
	HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT),
977
	HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT),
1042
	HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT),
978
	HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT),
1043
	HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT),
979
	HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT),
1044
	HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT),
980
	HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT),
1045
	HDA_CODEC_VOLUME("PCM-2 Volume", 0x1c, 0x00, HDA_OUTPUT),
981
	HDA_CODEC_VOLUME("PCM-2 Volume", 0x1c, 0x00, HDA_OUTPUT),
1046
	HDA_CODEC_MUTE("PCM-2 Switch", 0x1c, 0x00, HDA_OUTPUT),
982
	HDA_CODEC_MUTE("PCM-2 Switch", 0x1c, 0x00, HDA_OUTPUT),
1047
	{
983
	HDA_CODEC_VOLUME("Speaker Volume", 0x1d, 0x00, HDA_OUTPUT),
1048
		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
984
	HDA_CODEC_MUTE("Speaker Switch", 0x1d, 0x00, HDA_OUTPUT),
1049
		.name = "Master Playback Volume",
985
	HDA_CODEC_VOLUME("Headphone Volume", 0x13, 0x00, HDA_OUTPUT),
1050
		.info = snd_hda_mixer_amp_volume_info,
986
	HDA_CODEC_MUTE("Headphone Switch", 0x13, 0x00, HDA_OUTPUT),
1051
		.get = snd_hda_mixer_amp_volume_get,
1052
		.put = cxt5047_hp_master_vol_put,
1053
		.private_value = HDA_COMPOSE_AMP_VAL(0x13, 3, 0, HDA_OUTPUT),
1054
	},
1055
	{
1056
		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1057
		.name = "Master Playback Switch",
1058
		.info = cxt_eapd_info,
1059
		.get = cxt_eapd_get,
1060
		.put = cxt5047_hp_master_sw_put,
1061
		.private_value = 0x13,
1062
	},
1063
987
1064
	{}
988
	{}
1065
};
989
};
Lines 1129-1146 static struct hda_verb cxt5047_init_verb Link Here
1129
	{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1053
	{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1130
	{0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 },
1054
	{0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 },
1131
	{0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 },
1055
	{0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 },
1132
	/* HP, Amp, Speaker  */
1056
	/* HP, Speaker  */
1133
	{0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1057
	{0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1134
	{0x1A, AC_VERB_SET_CONNECT_SEL,0x00},
1058
	{0x1d, AC_VERB_SET_CONNECT_SEL,0x0},
1059
	/* Record selector: Mic */
1060
	{0x12, AC_VERB_SET_CONNECT_SEL,0x03},
1061
	{0x19, AC_VERB_SET_AMP_GAIN_MUTE,
1062
	 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
1063
	{0x1A, AC_VERB_SET_CONNECT_SEL,0x02},
1135
	{0x1A, AC_VERB_SET_AMP_GAIN_MUTE,
1064
	{0x1A, AC_VERB_SET_AMP_GAIN_MUTE,
1136
	 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x00},
1065
	 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x00},
1137
	{0x1A, AC_VERB_SET_AMP_GAIN_MUTE,
1066
	{0x1A, AC_VERB_SET_AMP_GAIN_MUTE,
1138
	 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x03},
1067
	 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x03},
1139
	{0x1d, AC_VERB_SET_CONNECT_SEL,0x0},
1140
	/* Record selector: Front mic */
1141
	{0x12, AC_VERB_SET_CONNECT_SEL,0x03},
1142
	{0x19, AC_VERB_SET_AMP_GAIN_MUTE,
1143
	 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
1144
	/* SPDIF route: PCM */
1068
	/* SPDIF route: PCM */
1145
	{ 0x18, AC_VERB_SET_CONNECT_SEL, 0x0 },
1069
	{ 0x18, AC_VERB_SET_CONNECT_SEL, 0x0 },
1146
	/* Enable unsolicited events */
1070
	/* Enable unsolicited events */
Lines 1157-1164 static struct hda_verb cxt5047_toshiba_i Link Here
1157
	{0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
1081
	{0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
1158
	/* Speaker routing */
1082
	/* Speaker routing */
1159
	{0x1d, AC_VERB_SET_CONNECT_SEL,0x1},
1083
	{0x1d, AC_VERB_SET_CONNECT_SEL,0x1},
1160
	/* Change default to ExtMic for recording */
1161
	{0x1a, AC_VERB_SET_CONNECT_SEL,0x2},
1162
	{}
1084
	{}
1163
};
1085
};
1164
1086
Lines 1168-1174 static struct hda_verb cxt5047_hp_init_v Link Here
1168
	{0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
1090
	{0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
1169
	/* Record selector: Ext Mic */
1091
	/* Record selector: Ext Mic */
1170
	{0x12, AC_VERB_SET_CONNECT_SEL,0x03},
1092
	{0x12, AC_VERB_SET_CONNECT_SEL,0x03},
1171
	{0x1a, AC_VERB_SET_CONNECT_SEL,0x02},
1172
	{0x19, AC_VERB_SET_AMP_GAIN_MUTE,
1093
	{0x19, AC_VERB_SET_AMP_GAIN_MUTE,
1173
	 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
1094
	 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
1174
	/* Speaker routing */
1095
	/* Speaker routing */
Lines 1238-1251 static struct snd_kcontrol_new cxt5047_t Link Here
1238
		.get = conexant_mux_enum_get,
1159
		.get = conexant_mux_enum_get,
1239
		.put = conexant_mux_enum_put,
1160
		.put = conexant_mux_enum_put,
1240
	},
1161
	},
1241
       /* Controls for GPIO pins, assuming they exist and are configured
1242
	* as outputs
1243
	*/
1244
	CXT_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
1245
	CXT_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
1246
	CXT_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
1247
	CXT_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
1248
1249
	{ } /* end */
1162
	{ } /* end */
1250
};
1163
};
1251
1164

Return to bug 172834