aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/hda/patch_realtek.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/pci/hda/patch_realtek.c')
-rw-r--r--sound/pci/hda/patch_realtek.c141
1 files changed, 3 insertions, 138 deletions
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 371d1e418d5..3b2964e0ce0 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -5714,137 +5714,6 @@ static int patch_alc861(struct hda_codec *codec)
5714#define alc861vd_loopbacks alc880_loopbacks 5714#define alc861vd_loopbacks alc880_loopbacks
5715#endif 5715#endif
5716 5716
5717/*
5718 * BIOS auto configuration
5719 */
5720#define alc861vd_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
5721#define alc861vd_fixed_pin_idx(nid) ((nid) - 0x14)
5722#define alc861vd_is_multi_pin(nid) ((nid) >= 0x18)
5723#define alc861vd_multi_pin_idx(nid) ((nid) - 0x18)
5724#define alc861vd_idx_to_dac(nid) ((nid) + 0x02)
5725#define alc861vd_dac_to_idx(nid) ((nid) - 0x02)
5726#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
5727#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
5728
5729/* add playback controls from the parsed DAC table */
5730/* Based on ALC880 version. But ALC861VD has separate,
5731 * different NIDs for mute/unmute switch and volume control */
5732static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
5733 const struct auto_pin_cfg *cfg)
5734{
5735 hda_nid_t nid_v, nid_s;
5736 int i, err, noutputs;
5737
5738 noutputs = cfg->line_outs;
5739 if (spec->multi_ios > 0)
5740 noutputs += spec->multi_ios;
5741
5742 for (i = 0; i < noutputs; i++) {
5743 const char *name;
5744 int index;
5745 if (!spec->multiout.dac_nids[i])
5746 continue;
5747 nid_v = alc861vd_idx_to_mixer_vol(
5748 alc861vd_dac_to_idx(
5749 spec->multiout.dac_nids[i]));
5750 nid_s = alc861vd_idx_to_mixer_switch(
5751 alc861vd_dac_to_idx(
5752 spec->multiout.dac_nids[i]));
5753
5754 name = alc_get_line_out_pfx(spec, i, true, &index);
5755 if (!name) {
5756 /* Center/LFE */
5757 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
5758 "Center",
5759 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
5760 HDA_OUTPUT));
5761 if (err < 0)
5762 return err;
5763 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
5764 "LFE",
5765 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
5766 HDA_OUTPUT));
5767 if (err < 0)
5768 return err;
5769 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
5770 "Center",
5771 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
5772 HDA_INPUT));
5773 if (err < 0)
5774 return err;
5775 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
5776 "LFE",
5777 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
5778 HDA_INPUT));
5779 if (err < 0)
5780 return err;
5781 } else {
5782 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
5783 name, index,
5784 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
5785 HDA_OUTPUT));
5786 if (err < 0)
5787 return err;
5788 err = __add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
5789 name, index,
5790 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
5791 HDA_INPUT));
5792 if (err < 0)
5793 return err;
5794 }
5795 }
5796 return 0;
5797}
5798
5799/* add playback controls for speaker and HP outputs */
5800/* Based on ALC880 version. But ALC861VD has separate,
5801 * different NIDs for mute/unmute switch and volume control */
5802static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
5803 hda_nid_t pin, const char *pfx)
5804{
5805 hda_nid_t nid_v, nid_s;
5806 int err;
5807
5808 if (!pin)
5809 return 0;
5810
5811 if (alc861vd_is_fixed_pin(pin)) {
5812 nid_v = alc861vd_idx_to_dac(alc861vd_fixed_pin_idx(pin));
5813 /* specify the DAC as the extra output */
5814 if (!spec->multiout.hp_nid)
5815 spec->multiout.hp_nid = nid_v;
5816 else
5817 spec->multiout.extra_out_nid[0] = nid_v;
5818 /* control HP volume/switch on the output mixer amp */
5819 nid_v = alc861vd_idx_to_mixer_vol(
5820 alc861vd_fixed_pin_idx(pin));
5821 nid_s = alc861vd_idx_to_mixer_switch(
5822 alc861vd_fixed_pin_idx(pin));
5823
5824 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
5825 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
5826 if (err < 0)
5827 return err;
5828 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
5829 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
5830 if (err < 0)
5831 return err;
5832 } else if (alc861vd_is_multi_pin(pin)) {
5833 /* set manual connection */
5834 /* we have only a switch on HP-out PIN */
5835 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
5836 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
5837 if (err < 0)
5838 return err;
5839 }
5840 return 0;
5841}
5842
5843/* parse the BIOS configuration and set up the alc_spec
5844 * return 1 if successful, 0 if the proper config is not found,
5845 * or a negative error code
5846 * Based on ALC880 version - had to change it to override
5847 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
5848static int alc861vd_parse_auto_config(struct hda_codec *codec) 5717static int alc861vd_parse_auto_config(struct hda_codec *codec)
5849{ 5718{
5850 struct alc_spec *spec = codec->spec; 5719 struct alc_spec *spec = codec->spec;
@@ -5864,17 +5733,13 @@ static int alc861vd_parse_auto_config(struct hda_codec *codec)
5864 err = alc_auto_add_multi_channel_mode(codec, alc_auto_fill_dac_nids); 5733 err = alc_auto_add_multi_channel_mode(codec, alc_auto_fill_dac_nids);
5865 if (err < 0) 5734 if (err < 0)
5866 return err; 5735 return err;
5867 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg); 5736 err = alc_auto_create_multi_out_ctls(codec, &spec->autocfg);
5868 if (err < 0) 5737 if (err < 0)
5869 return err; 5738 return err;
5870 err = alc861vd_auto_create_extra_out(spec, 5739 err = alc_auto_create_hp_out(codec);
5871 spec->autocfg.speaker_pins[0],
5872 "Speaker");
5873 if (err < 0) 5740 if (err < 0)
5874 return err; 5741 return err;
5875 err = alc861vd_auto_create_extra_out(spec, 5742 err = alc_auto_create_speaker_out(codec);
5876 spec->autocfg.hp_pins[0],
5877 "Headphone");
5878 if (err < 0) 5743 if (err < 0)
5879 return err; 5744 return err;
5880 err = alc_auto_create_input_ctls(codec); 5745 err = alc_auto_create_input_ctls(codec);