aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sound/pci/hda/patch_realtek.c265
1 files changed, 26 insertions, 239 deletions
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index b9e0c73cbd76..8f1bd80e6027 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -3543,9 +3543,6 @@ static int alc880_parse_auto_config(struct hda_codec *codec)
3543 err = alc_auto_fill_dac_nids(codec); 3543 err = alc_auto_fill_dac_nids(codec);
3544 if (err < 0) 3544 if (err < 0)
3545 return err; 3545 return err;
3546 err = alc_auto_add_multi_channel_mode(codec, alc_auto_fill_dac_nids);
3547 if (err < 0)
3548 return err;
3549 err = alc_auto_create_multi_out_ctls(codec, &spec->autocfg); 3546 err = alc_auto_create_multi_out_ctls(codec, &spec->autocfg);
3550 if (err < 0) 3547 if (err < 0)
3551 return err; 3548 return err;
@@ -4501,204 +4498,6 @@ static int patch_alc262(struct hda_codec *codec)
4501/* 4498/*
4502 * ALC268 4499 * ALC268
4503 */ 4500 */
4504/* create input playback/capture controls for the given pin */
4505static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
4506 const char *ctlname, int idx)
4507{
4508 hda_nid_t dac;
4509 int err;
4510
4511 switch (nid) {
4512 case 0x14:
4513 case 0x16:
4514 dac = 0x02;
4515 break;
4516 case 0x15:
4517 case 0x1a: /* ALC259/269 only */
4518 case 0x1b: /* ALC259/269 only */
4519 case 0x21: /* ALC269vb has this pin, too */
4520 dac = 0x03;
4521 break;
4522 default:
4523 snd_printd(KERN_WARNING "hda_codec: "
4524 "ignoring pin 0x%x as unknown\n", nid);
4525 return 0;
4526 }
4527 if (spec->multiout.dac_nids[0] != dac &&
4528 spec->multiout.dac_nids[1] != dac) {
4529 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
4530 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
4531 HDA_OUTPUT));
4532 if (err < 0)
4533 return err;
4534 spec->private_dac_nids[spec->multiout.num_dacs++] = dac;
4535 }
4536
4537 if (nid != 0x16)
4538 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
4539 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
4540 else /* mono */
4541 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
4542 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
4543 if (err < 0)
4544 return err;
4545 return 0;
4546}
4547
4548/* add playback controls from the parsed DAC table */
4549static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
4550 const struct auto_pin_cfg *cfg)
4551{
4552 hda_nid_t nid;
4553 int err;
4554
4555 spec->multiout.dac_nids = spec->private_dac_nids;
4556
4557 nid = cfg->line_out_pins[0];
4558 if (nid) {
4559 const char *name;
4560 int index;
4561 name = alc_get_line_out_pfx(spec, 0, true, &index);
4562 err = alc268_new_analog_output(spec, nid, name, 0);
4563 if (err < 0)
4564 return err;
4565 }
4566
4567 nid = cfg->speaker_pins[0];
4568 if (nid == 0x1d) {
4569 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, "Speaker",
4570 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
4571 if (err < 0)
4572 return err;
4573 } else if (nid) {
4574 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
4575 if (err < 0)
4576 return err;
4577 }
4578 nid = cfg->hp_pins[0];
4579 if (nid) {
4580 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
4581 if (err < 0)
4582 return err;
4583 }
4584
4585 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
4586 if (nid == 0x16) {
4587 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, "Mono",
4588 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
4589 if (err < 0)
4590 return err;
4591 }
4592 return 0;
4593}
4594
4595static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
4596 hda_nid_t nid, int pin_type)
4597{
4598 int idx;
4599
4600 alc_set_pin_output(codec, nid, pin_type);
4601 if (snd_hda_get_conn_list(codec, nid, NULL) <= 1)
4602 return;
4603 if (nid == 0x14 || nid == 0x16)
4604 idx = 0;
4605 else
4606 idx = 1;
4607 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
4608}
4609
4610static void alc268_auto_init_dac(struct hda_codec *codec, hda_nid_t nid)
4611{
4612 if (!nid)
4613 return;
4614 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4615 AMP_OUT_ZERO);
4616}
4617
4618static void alc268_auto_init_multi_out(struct hda_codec *codec)
4619{
4620 struct alc_spec *spec = codec->spec;
4621 int i;
4622
4623 for (i = 0; i < spec->autocfg.line_outs; i++) {
4624 hda_nid_t nid = spec->autocfg.line_out_pins[i];
4625 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4626 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
4627 }
4628 /* mute DACs */
4629 for (i = 0; i < spec->multiout.num_dacs; i++)
4630 alc268_auto_init_dac(codec, spec->multiout.dac_nids[i]);
4631}
4632
4633static void alc268_auto_init_hp_out(struct hda_codec *codec)
4634{
4635 struct alc_spec *spec = codec->spec;
4636 hda_nid_t pin;
4637 int i;
4638
4639 for (i = 0; i < spec->autocfg.hp_outs; i++) {
4640 pin = spec->autocfg.hp_pins[i];
4641 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
4642 }
4643 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
4644 pin = spec->autocfg.speaker_pins[i];
4645 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
4646 }
4647 if (spec->autocfg.mono_out_pin)
4648 snd_hda_codec_write(codec, spec->autocfg.mono_out_pin, 0,
4649 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
4650 /* mute DACs */
4651 alc268_auto_init_dac(codec, spec->multiout.hp_nid);
4652 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++)
4653 alc268_auto_init_dac(codec, spec->multiout.extra_out_nid[i]);
4654}
4655
4656static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
4657{
4658 struct alc_spec *spec = codec->spec;
4659 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
4660 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
4661 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
4662 unsigned int dac_vol1, dac_vol2;
4663
4664 if (line_nid == 0x1d || speaker_nid == 0x1d) {
4665 snd_hda_codec_write(codec, speaker_nid, 0,
4666 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
4667 /* mute mixer inputs from 0x1d */
4668 snd_hda_codec_write(codec, 0x0f, 0,
4669 AC_VERB_SET_AMP_GAIN_MUTE,
4670 AMP_IN_UNMUTE(1));
4671 snd_hda_codec_write(codec, 0x10, 0,
4672 AC_VERB_SET_AMP_GAIN_MUTE,
4673 AMP_IN_UNMUTE(1));
4674 } else {
4675 /* unmute mixer inputs from 0x1d */
4676 snd_hda_codec_write(codec, 0x0f, 0,
4677 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
4678 snd_hda_codec_write(codec, 0x10, 0,
4679 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
4680 }
4681
4682 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
4683 if (line_nid == 0x14)
4684 dac_vol2 = AMP_OUT_ZERO;
4685 else if (line_nid == 0x15)
4686 dac_vol1 = AMP_OUT_ZERO;
4687 if (hp_nid == 0x14)
4688 dac_vol2 = AMP_OUT_ZERO;
4689 else if (hp_nid == 0x15)
4690 dac_vol1 = AMP_OUT_ZERO;
4691 if (line_nid != 0x16 || hp_nid != 0x16 ||
4692 spec->autocfg.line_out_pins[1] != 0x16 ||
4693 spec->autocfg.line_out_pins[2] != 0x16)
4694 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
4695
4696 snd_hda_codec_write(codec, 0x02, 0,
4697 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
4698 snd_hda_codec_write(codec, 0x03, 0,
4699 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
4700}
4701
4702/* bind Beep switches of both NID 0x0f and 0x10 */ 4501/* bind Beep switches of both NID 0x0f and 0x10 */
4703static const struct hda_bind_ctls alc268_bind_beep_sw = { 4502static const struct hda_bind_ctls alc268_bind_beep_sw = {
4704 .ops = &snd_hda_bind_sw, 4503 .ops = &snd_hda_bind_sw,
@@ -4744,7 +4543,20 @@ static int alc268_parse_auto_config(struct hda_codec *codec)
4744 } 4543 }
4745 return 0; /* can't find valid BIOS pin config */ 4544 return 0; /* can't find valid BIOS pin config */
4746 } 4545 }
4747 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg); 4546
4547 err = alc_auto_fill_dac_nids(codec);
4548 if (err < 0)
4549 return err;
4550 err = alc_auto_add_multi_channel_mode(codec, alc_auto_fill_dac_nids);
4551 if (err < 0)
4552 return err;
4553 err = alc_auto_create_multi_out_ctls(codec, &spec->autocfg);
4554 if (err < 0)
4555 return err;
4556 err = alc_auto_create_hp_out(codec);
4557 if (err < 0)
4558 return err;
4559 err = alc_auto_create_speaker_out(codec);
4748 if (err < 0) 4560 if (err < 0)
4749 return err; 4561 return err;
4750 err = alc_auto_create_input_ctls(codec); 4562 err = alc_auto_create_input_ctls(codec);
@@ -4776,20 +4588,6 @@ static int alc268_parse_auto_config(struct hda_codec *codec)
4776 return 1; 4588 return 1;
4777} 4589}
4778 4590
4779/* init callback for auto-configuration model -- overriding the default init */
4780static void alc268_auto_init(struct hda_codec *codec)
4781{
4782 struct alc_spec *spec = codec->spec;
4783 alc268_auto_init_multi_out(codec);
4784 alc268_auto_init_hp_out(codec);
4785 alc268_auto_init_mono_speaker_out(codec);
4786 alc_auto_init_analog_input(codec);
4787 alc_auto_init_input_src(codec);
4788 alc_auto_init_digital(codec);
4789 if (spec->unsol_event)
4790 alc_inithook(codec);
4791}
4792
4793/* 4591/*
4794 */ 4592 */
4795#ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS 4593#ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS
@@ -4879,7 +4677,7 @@ static int patch_alc268(struct hda_codec *codec)
4879 4677
4880 codec->patch_ops = alc_patch_ops; 4678 codec->patch_ops = alc_patch_ops;
4881 if (board_config == ALC_MODEL_AUTO) 4679 if (board_config == ALC_MODEL_AUTO)
4882 spec->init_hook = alc268_auto_init; 4680 spec->init_hook = alc_auto_init_std;
4883 spec->shutup = alc_eapd_shutup; 4681 spec->shutup = alc_eapd_shutup;
4884 4682
4885 alc_init_jacks(codec); 4683 alc_init_jacks(codec);
@@ -4890,9 +4688,6 @@ static int patch_alc268(struct hda_codec *codec)
4890/* 4688/*
4891 * ALC269 4689 * ALC269
4892 */ 4690 */
4893#define alc269_auto_create_multi_out_ctls \
4894 alc268_auto_create_multi_out_ctls
4895
4896#ifdef CONFIG_SND_HDA_POWER_SAVE 4691#ifdef CONFIG_SND_HDA_POWER_SAVE
4897#define alc269_loopbacks alc880_loopbacks 4692#define alc269_loopbacks alc880_loopbacks
4898#endif 4693#endif
@@ -4968,7 +4763,16 @@ static int alc269_parse_auto_config(struct hda_codec *codec)
4968 if (err < 0) 4763 if (err < 0)
4969 return err; 4764 return err;
4970 4765
4971 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg); 4766 err = alc_auto_fill_dac_nids(codec);
4767 if (err < 0)
4768 return err;
4769 err = alc_auto_create_multi_out_ctls(codec, &spec->autocfg);
4770 if (err < 0)
4771 return err;
4772 err = alc_auto_create_hp_out(codec);
4773 if (err < 0)
4774 return err;
4775 err = alc_auto_create_speaker_out(codec);
4972 if (err < 0) 4776 if (err < 0)
4973 return err; 4777 return err;
4974 err = alc_auto_create_input_ctls(codec); 4778 err = alc_auto_create_input_ctls(codec);
@@ -5000,23 +4804,6 @@ static int alc269_parse_auto_config(struct hda_codec *codec)
5000 return 1; 4804 return 1;
5001} 4805}
5002 4806
5003#define alc269_auto_init_multi_out alc268_auto_init_multi_out
5004#define alc269_auto_init_hp_out alc268_auto_init_hp_out
5005
5006
5007/* init callback for auto-configuration model -- overriding the default init */
5008static void alc269_auto_init(struct hda_codec *codec)
5009{
5010 struct alc_spec *spec = codec->spec;
5011 alc269_auto_init_multi_out(codec);
5012 alc269_auto_init_hp_out(codec);
5013 alc_auto_init_analog_input(codec);
5014 alc_auto_init_input_src(codec);
5015 alc_auto_init_digital(codec);
5016 if (spec->unsol_event)
5017 alc_inithook(codec);
5018}
5019
5020static void alc269_toggle_power_output(struct hda_codec *codec, int power_up) 4807static void alc269_toggle_power_output(struct hda_codec *codec, int power_up)
5021{ 4808{
5022 int val = alc_read_coef_idx(codec, 0x04); 4809 int val = alc_read_coef_idx(codec, 0x04);
@@ -5346,7 +5133,7 @@ static int patch_alc269(struct hda_codec *codec)
5346 codec->patch_ops.resume = alc269_resume; 5133 codec->patch_ops.resume = alc269_resume;
5347#endif 5134#endif
5348 if (board_config == ALC_MODEL_AUTO) 5135 if (board_config == ALC_MODEL_AUTO)
5349 spec->init_hook = alc269_auto_init; 5136 spec->init_hook = alc_auto_init_std;
5350 spec->shutup = alc269_shutup; 5137 spec->shutup = alc269_shutup;
5351 5138
5352 alc_init_jacks(codec); 5139 alc_init_jacks(codec);