Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Universal Interface for Intel High Definition Audio Codec |
| 3 | * |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4 | * HD audio interface patch for Realtek ALC codecs |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | * |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 6 | * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw> |
| 7 | * PeiSen Hou <pshou@realtek.com.tw> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | * Takashi Iwai <tiwai@suse.de> |
Jonathan Woithe | 7cf51e48 | 2006-02-09 12:01:26 +0100 | [diff] [blame] | 9 | * Jonathan Woithe <jwoithe@physics.adelaide.edu.au> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | * |
| 11 | * This driver is free software; you can redistribute it and/or modify |
| 12 | * it under the terms of the GNU General Public License as published by |
| 13 | * the Free Software Foundation; either version 2 of the License, or |
| 14 | * (at your option) any later version. |
| 15 | * |
| 16 | * This driver is distributed in the hope that it will be useful, |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 | * GNU General Public License for more details. |
| 20 | * |
| 21 | * You should have received a copy of the GNU General Public License |
| 22 | * along with this program; if not, write to the Free Software |
| 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 24 | */ |
| 25 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | #include <linux/init.h> |
| 27 | #include <linux/delay.h> |
| 28 | #include <linux/slab.h> |
| 29 | #include <linux/pci.h> |
Paul Gortmaker | da155d5 | 2011-07-15 12:38:28 -0400 | [diff] [blame] | 30 | #include <linux/module.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | #include <sound/core.h> |
Kailang Yang | 9ad0e49 | 2010-09-14 23:22:00 +0200 | [diff] [blame] | 32 | #include <sound/jack.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | #include "hda_codec.h" |
| 34 | #include "hda_local.h" |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame^] | 35 | #include "hda_auto_parser.h" |
Kusanagi Kouichi | 680cd53 | 2009-02-05 00:00:58 +0900 | [diff] [blame] | 36 | #include "hda_beep.h" |
Takashi Iwai | 1835a0f | 2011-10-27 22:12:46 +0200 | [diff] [blame] | 37 | #include "hda_jack.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 39 | /* unsol event tags */ |
| 40 | #define ALC_FRONT_EVENT 0x01 |
| 41 | #define ALC_DCVOL_EVENT 0x02 |
| 42 | #define ALC_HP_EVENT 0x04 |
| 43 | #define ALC_MIC_EVENT 0x08 |
Takashi Iwai | d4a86d8 | 2010-06-23 17:51:26 +0200 | [diff] [blame] | 44 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 45 | /* for GPIO Poll */ |
| 46 | #define GPIO_MASK 0x03 |
| 47 | |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 48 | /* extra amp-initialization sequence types */ |
| 49 | enum { |
| 50 | ALC_INIT_NONE, |
| 51 | ALC_INIT_DEFAULT, |
| 52 | ALC_INIT_GPIO1, |
| 53 | ALC_INIT_GPIO2, |
| 54 | ALC_INIT_GPIO3, |
| 55 | }; |
| 56 | |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 57 | struct alc_customize_define { |
| 58 | unsigned int sku_cfg; |
| 59 | unsigned char port_connectivity; |
| 60 | unsigned char check_sum; |
| 61 | unsigned char customization; |
| 62 | unsigned char external_amp; |
| 63 | unsigned int enable_pcbeep:1; |
| 64 | unsigned int platform_type:1; |
| 65 | unsigned int swap:1; |
| 66 | unsigned int override:1; |
David Henningsson | 9062291 | 2010-10-14 14:50:18 +0200 | [diff] [blame] | 67 | unsigned int fixup:1; /* Means that this sku is set by driver, not read from hw */ |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 68 | }; |
| 69 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 70 | struct alc_multi_io { |
| 71 | hda_nid_t pin; /* multi-io widget pin NID */ |
| 72 | hda_nid_t dac; /* DAC to be connected */ |
| 73 | unsigned int ctl_in; /* cached input-pin control value */ |
| 74 | }; |
| 75 | |
Takashi Iwai | d922b51 | 2011-04-28 12:18:53 +0200 | [diff] [blame] | 76 | enum { |
Takashi Iwai | 3b8510c | 2011-04-28 14:03:24 +0200 | [diff] [blame] | 77 | ALC_AUTOMUTE_PIN, /* change the pin control */ |
| 78 | ALC_AUTOMUTE_AMP, /* mute/unmute the pin AMP */ |
| 79 | ALC_AUTOMUTE_MIXER, /* mute/unmute mixer widget AMP */ |
Takashi Iwai | d922b51 | 2011-04-28 12:18:53 +0200 | [diff] [blame] | 80 | }; |
| 81 | |
Takashi Iwai | c14c95f | 2012-02-16 16:38:07 +0100 | [diff] [blame] | 82 | #define MAX_VOL_NIDS 0x40 |
| 83 | |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame^] | 84 | /* make compatible with old code */ |
| 85 | #define alc_apply_pincfgs snd_hda_apply_pincfgs |
| 86 | #define alc_apply_fixup snd_hda_apply_fixup |
| 87 | #define alc_pick_fixup snd_hda_pick_fixup |
| 88 | #define alc_fixup hda_fixup |
| 89 | #define alc_pincfg hda_pintbl |
| 90 | #define alc_model_fixup hda_model_fixup |
| 91 | |
| 92 | #define ALC_FIXUP_PINS HDA_FIXUP_PINS |
| 93 | #define ALC_FIXUP_VERBS HDA_FIXUP_VERBS |
| 94 | #define ALC_FIXUP_FUNC HDA_FIXUP_FUNC |
| 95 | |
| 96 | #define ALC_FIXUP_ACT_PRE_PROBE HDA_FIXUP_ACT_PRE_PROBE |
| 97 | #define ALC_FIXUP_ACT_PROBE HDA_FIXUP_ACT_PROBE |
| 98 | #define ALC_FIXUP_ACT_INIT HDA_FIXUP_ACT_INIT |
| 99 | #define ALC_FIXUP_ACT_BUILD HDA_FIXUP_ACT_BUILD |
| 100 | |
| 101 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | struct alc_spec { |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame^] | 103 | struct hda_gen_spec gen; |
| 104 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | /* codec parameterization */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 106 | const struct snd_kcontrol_new *mixers[5]; /* mixer arrays */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | unsigned int num_mixers; |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 108 | const struct snd_kcontrol_new *cap_mixer; /* capture mixer */ |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 109 | unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | |
Takashi Iwai | aa563af | 2009-07-31 10:05:11 +0200 | [diff] [blame] | 111 | char stream_name_analog[32]; /* analog PCM stream */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 112 | const struct hda_pcm_stream *stream_analog_playback; |
| 113 | const struct hda_pcm_stream *stream_analog_capture; |
| 114 | const struct hda_pcm_stream *stream_analog_alt_playback; |
| 115 | const struct hda_pcm_stream *stream_analog_alt_capture; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | |
Takashi Iwai | aa563af | 2009-07-31 10:05:11 +0200 | [diff] [blame] | 117 | char stream_name_digital[32]; /* digital PCM stream */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 118 | const struct hda_pcm_stream *stream_digital_playback; |
| 119 | const struct hda_pcm_stream *stream_digital_capture; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | |
| 121 | /* playback */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 122 | struct hda_multi_out multiout; /* playback set-up |
| 123 | * max_channels, dacs must be set |
| 124 | * dig_out_nid and hp_nid are optional |
| 125 | */ |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 126 | hda_nid_t alt_dac_nid; |
Takashi Iwai | 6a05ac4 | 2009-02-13 11:19:09 +0100 | [diff] [blame] | 127 | hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */ |
Takashi Iwai | 8c44198 | 2009-01-20 18:30:20 +0100 | [diff] [blame] | 128 | int dig_out_type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 129 | |
| 130 | /* capture */ |
| 131 | unsigned int num_adc_nids; |
Takashi Iwai | 4c6d72d | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 132 | const hda_nid_t *adc_nids; |
| 133 | const hda_nid_t *capsrc_nids; |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 134 | hda_nid_t dig_in_nid; /* digital-in NID; optional */ |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 135 | hda_nid_t mixer_nid; /* analog-mixer NID */ |
Takashi Iwai | c14c95f | 2012-02-16 16:38:07 +0100 | [diff] [blame] | 136 | DECLARE_BITMAP(vol_ctls, MAX_VOL_NIDS << 1); |
| 137 | DECLARE_BITMAP(sw_ctls, MAX_VOL_NIDS << 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 139 | /* capture setup for dynamic dual-adc switch */ |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 140 | hda_nid_t cur_adc; |
| 141 | unsigned int cur_adc_stream_tag; |
| 142 | unsigned int cur_adc_format; |
| 143 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 144 | /* capture source */ |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 145 | unsigned int num_mux_defs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | const struct hda_input_mux *input_mux; |
| 147 | unsigned int cur_mux[3]; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 148 | hda_nid_t ext_mic_pin; |
| 149 | hda_nid_t dock_mic_pin; |
| 150 | hda_nid_t int_mic_pin; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 151 | |
| 152 | /* channel model */ |
Takashi Iwai | d2a6d7d | 2005-11-17 11:06:29 +0100 | [diff] [blame] | 153 | const struct hda_channel_mode *channel_mode; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | int num_channel_mode; |
Takashi Iwai | 4e195a7 | 2006-07-28 14:47:34 +0200 | [diff] [blame] | 155 | int need_dac_fix; |
Hector Martin | 3b315d7 | 2009-06-02 10:54:19 +0200 | [diff] [blame] | 156 | int const_channel_count; |
| 157 | int ext_channel_count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | |
| 159 | /* PCM information */ |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 160 | struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */ |
Takashi Iwai | 41e41f1 | 2005-06-08 14:48:49 +0200 | [diff] [blame] | 161 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 162 | /* dynamic controls, init_verbs and input_mux */ |
| 163 | struct auto_pin_cfg autocfg; |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 164 | struct alc_customize_define cdefine; |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 165 | struct snd_array kctls; |
Herton Ronaldo Krzesinski | 61b9b9b | 2009-01-28 09:16:33 -0200 | [diff] [blame] | 166 | struct hda_input_mux private_imux[3]; |
Takashi Iwai | 41923e4 | 2007-10-22 17:20:10 +0200 | [diff] [blame] | 167 | hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 168 | hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS]; |
| 169 | hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS]; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 170 | hda_nid_t imux_pins[HDA_MAX_NUM_INPUTS]; |
| 171 | unsigned int dyn_adc_idx[HDA_MAX_NUM_INPUTS]; |
| 172 | int int_mic_idx, ext_mic_idx, dock_mic_idx; /* for auto-mic */ |
Takashi Iwai | 834be88 | 2006-03-01 14:16:17 +0100 | [diff] [blame] | 173 | |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 174 | /* hooks */ |
| 175 | void (*init_hook)(struct hda_codec *codec); |
| 176 | void (*unsol_event)(struct hda_codec *codec, unsigned int res); |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 177 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 178 | void (*power_hook)(struct hda_codec *codec); |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 179 | #endif |
Takashi Iwai | 1c716153 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 180 | void (*shutup)(struct hda_codec *codec); |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 181 | void (*automute_hook)(struct hda_codec *codec); |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 182 | |
Takashi Iwai | 834be88 | 2006-03-01 14:16:17 +0100 | [diff] [blame] | 183 | /* for pin sensing */ |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 184 | unsigned int hp_jack_present:1; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 185 | unsigned int line_jack_present:1; |
Takashi Iwai | e942796 | 2011-04-28 15:46:07 +0200 | [diff] [blame] | 186 | unsigned int master_mute:1; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 187 | unsigned int auto_mic:1; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 188 | unsigned int auto_mic_valid_imux:1; /* valid imux for auto-mic */ |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 189 | unsigned int automute_speaker:1; /* automute speaker outputs */ |
| 190 | unsigned int automute_lo:1; /* automute LO outputs */ |
| 191 | unsigned int detect_hp:1; /* Headphone detection enabled */ |
| 192 | unsigned int detect_lo:1; /* Line-out detection enabled */ |
| 193 | unsigned int automute_speaker_possible:1; /* there are speakers and either LO or HP */ |
| 194 | unsigned int automute_lo_possible:1; /* there are line outs and HP */ |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 195 | unsigned int keep_vref_in_automute:1; /* Don't clear VREF in automute */ |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 196 | |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 197 | /* other flags */ |
| 198 | unsigned int no_analog :1; /* digital I/O only */ |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 199 | unsigned int dyn_adc_switch:1; /* switch ADCs (for ALC275) */ |
Takashi Iwai | 584c0c4 | 2011-03-10 12:51:11 +0100 | [diff] [blame] | 200 | unsigned int single_input_src:1; |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 201 | unsigned int vol_in_capsrc:1; /* use capsrc volume (ADC has no vol) */ |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 202 | unsigned int parse_flags; /* passed to snd_hda_parse_pin_defcfg() */ |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 203 | unsigned int shared_mic_hp:1; /* HP/Mic-in sharing */ |
Takashi Iwai | d922b51 | 2011-04-28 12:18:53 +0200 | [diff] [blame] | 204 | |
| 205 | /* auto-mute control */ |
| 206 | int automute_mode; |
Takashi Iwai | 3b8510c | 2011-04-28 14:03:24 +0200 | [diff] [blame] | 207 | hda_nid_t automute_mixer_nid[AUTO_CFG_MAX_OUTS]; |
Takashi Iwai | d922b51 | 2011-04-28 12:18:53 +0200 | [diff] [blame] | 208 | |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 209 | int init_amp; |
Takashi Iwai | d433a67 | 2010-09-20 15:11:54 +0200 | [diff] [blame] | 210 | int codec_variant; /* flag for other variants */ |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 211 | |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 212 | /* for virtual master */ |
| 213 | hda_nid_t vmaster_nid; |
Takashi Iwai | d2f344b | 2012-03-12 16:59:58 +0100 | [diff] [blame] | 214 | struct hda_vmaster_mute_hook vmaster_mute; |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 215 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 216 | struct hda_loopback_check loopback; |
Takashi Iwai | 164f73e | 2012-02-21 11:27:09 +0100 | [diff] [blame] | 217 | int num_loopbacks; |
| 218 | struct hda_amp_list loopback_list[8]; |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 219 | #endif |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 220 | |
| 221 | /* for PLL fix */ |
| 222 | hda_nid_t pll_nid; |
| 223 | unsigned int pll_coef_idx, pll_coef_bit; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 224 | unsigned int coef0; |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 225 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 226 | /* multi-io */ |
| 227 | int multi_ios; |
| 228 | struct alc_multi_io multi_io[4]; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 229 | |
| 230 | /* bind volumes */ |
| 231 | struct snd_array bind_ctls; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 232 | }; |
| 233 | |
Takashi Iwai | 44c0240 | 2011-07-08 15:14:19 +0200 | [diff] [blame] | 234 | static bool check_amp_caps(struct hda_codec *codec, hda_nid_t nid, |
| 235 | int dir, unsigned int bits) |
| 236 | { |
| 237 | if (!nid) |
| 238 | return false; |
| 239 | if (get_wcaps(codec, nid) & (1 << (dir + 1))) |
| 240 | if (query_amp_caps(codec, nid, dir) & bits) |
| 241 | return true; |
| 242 | return false; |
| 243 | } |
| 244 | |
| 245 | #define nid_has_mute(codec, nid, dir) \ |
| 246 | check_amp_caps(codec, nid, dir, AC_AMPCAP_MUTE) |
| 247 | #define nid_has_volume(codec, nid, dir) \ |
| 248 | check_amp_caps(codec, nid, dir, AC_AMPCAP_NUM_STEPS) |
| 249 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 250 | /* |
| 251 | * input MUX handling |
| 252 | */ |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 253 | static int alc_mux_enum_info(struct snd_kcontrol *kcontrol, |
| 254 | struct snd_ctl_elem_info *uinfo) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 255 | { |
| 256 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 257 | struct alc_spec *spec = codec->spec; |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 258 | unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id); |
| 259 | if (mux_idx >= spec->num_mux_defs) |
| 260 | mux_idx = 0; |
Takashi Iwai | 5311114 | 2010-03-08 12:13:07 +0100 | [diff] [blame] | 261 | if (!spec->input_mux[mux_idx].num_items && mux_idx > 0) |
| 262 | mux_idx = 0; |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 263 | return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 264 | } |
| 265 | |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 266 | static int alc_mux_enum_get(struct snd_kcontrol *kcontrol, |
| 267 | struct snd_ctl_elem_value *ucontrol) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 268 | { |
| 269 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 270 | struct alc_spec *spec = codec->spec; |
| 271 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 272 | |
| 273 | ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; |
| 274 | return 0; |
| 275 | } |
| 276 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 277 | static bool alc_dyn_adc_pcm_resetup(struct hda_codec *codec, int cur) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 278 | { |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 279 | struct alc_spec *spec = codec->spec; |
| 280 | hda_nid_t new_adc = spec->adc_nids[spec->dyn_adc_idx[cur]]; |
| 281 | |
| 282 | if (spec->cur_adc && spec->cur_adc != new_adc) { |
| 283 | /* stream is running, let's swap the current ADC */ |
| 284 | __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1); |
| 285 | spec->cur_adc = new_adc; |
| 286 | snd_hda_codec_setup_stream(codec, new_adc, |
| 287 | spec->cur_adc_stream_tag, 0, |
| 288 | spec->cur_adc_format); |
| 289 | return true; |
| 290 | } |
| 291 | return false; |
| 292 | } |
| 293 | |
Takashi Iwai | 6107159 | 2011-11-23 07:52:15 +0100 | [diff] [blame] | 294 | static inline hda_nid_t get_capsrc(struct alc_spec *spec, int idx) |
| 295 | { |
| 296 | return spec->capsrc_nids ? |
| 297 | spec->capsrc_nids[idx] : spec->adc_nids[idx]; |
| 298 | } |
| 299 | |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 300 | static void call_update_outputs(struct hda_codec *codec); |
| 301 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 302 | /* select the given imux item; either unmute exclusively or select the route */ |
| 303 | static int alc_mux_select(struct hda_codec *codec, unsigned int adc_idx, |
| 304 | unsigned int idx, bool force) |
| 305 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 306 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | cd896c3 | 2008-11-18 12:36:33 +0100 | [diff] [blame] | 307 | const struct hda_input_mux *imux; |
Takashi Iwai | cd896c3 | 2008-11-18 12:36:33 +0100 | [diff] [blame] | 308 | unsigned int mux_idx; |
Takashi Iwai | dccc181 | 2011-11-08 07:52:19 +0100 | [diff] [blame] | 309 | int i, type, num_conns; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 310 | hda_nid_t nid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 311 | |
Takashi Iwai | 5803a32 | 2012-02-21 11:59:45 +0100 | [diff] [blame] | 312 | if (!spec->input_mux) |
| 313 | return 0; |
| 314 | |
Takashi Iwai | cd896c3 | 2008-11-18 12:36:33 +0100 | [diff] [blame] | 315 | mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx; |
| 316 | imux = &spec->input_mux[mux_idx]; |
Takashi Iwai | 5311114 | 2010-03-08 12:13:07 +0100 | [diff] [blame] | 317 | if (!imux->num_items && mux_idx > 0) |
| 318 | imux = &spec->input_mux[0]; |
Takashi Iwai | cce4aa3 | 2011-12-02 15:29:12 +0100 | [diff] [blame] | 319 | if (!imux->num_items) |
| 320 | return 0; |
Takashi Iwai | cd896c3 | 2008-11-18 12:36:33 +0100 | [diff] [blame] | 321 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 322 | if (idx >= imux->num_items) |
| 323 | idx = imux->num_items - 1; |
| 324 | if (spec->cur_mux[adc_idx] == idx && !force) |
| 325 | return 0; |
| 326 | spec->cur_mux[adc_idx] = idx; |
| 327 | |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 328 | /* for shared I/O, change the pin-control accordingly */ |
| 329 | if (spec->shared_mic_hp) { |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 330 | unsigned int val; |
| 331 | hda_nid_t pin = spec->autocfg.inputs[1].pin; |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 332 | /* NOTE: this assumes that there are only two inputs, the |
| 333 | * first is the real internal mic and the second is HP jack. |
| 334 | */ |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 335 | if (spec->cur_mux[adc_idx]) |
Takashi Iwai | 4740860 | 2012-04-20 13:06:53 +0200 | [diff] [blame] | 336 | val = snd_hda_get_default_vref(codec, pin) | PIN_IN; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 337 | else |
| 338 | val = PIN_HP; |
| 339 | snd_hda_set_pin_ctl(codec, pin, val); |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 340 | spec->automute_speaker = !spec->cur_mux[adc_idx]; |
| 341 | call_update_outputs(codec); |
| 342 | } |
| 343 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 344 | if (spec->dyn_adc_switch) { |
| 345 | alc_dyn_adc_pcm_resetup(codec, idx); |
| 346 | adc_idx = spec->dyn_adc_idx[idx]; |
| 347 | } |
| 348 | |
Takashi Iwai | 6107159 | 2011-11-23 07:52:15 +0100 | [diff] [blame] | 349 | nid = get_capsrc(spec, adc_idx); |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 350 | |
| 351 | /* no selection? */ |
Takashi Iwai | dccc181 | 2011-11-08 07:52:19 +0100 | [diff] [blame] | 352 | num_conns = snd_hda_get_conn_list(codec, nid, NULL); |
| 353 | if (num_conns <= 1) |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 354 | return 1; |
| 355 | |
Takashi Iwai | a22d543 | 2009-07-27 12:54:26 +0200 | [diff] [blame] | 356 | type = get_wcaps_type(get_wcaps(codec, nid)); |
Takashi Iwai | 0169b6b | 2009-06-22 10:50:19 +0200 | [diff] [blame] | 357 | if (type == AC_WID_AUD_MIX) { |
Takashi Iwai | 54cbc9a | 2008-10-31 15:24:04 +0100 | [diff] [blame] | 358 | /* Matrix-mixer style (e.g. ALC882) */ |
Takashi Iwai | dccc181 | 2011-11-08 07:52:19 +0100 | [diff] [blame] | 359 | int active = imux->items[idx].index; |
| 360 | for (i = 0; i < num_conns; i++) { |
| 361 | unsigned int v = (i == active) ? 0 : HDA_AMP_MUTE; |
| 362 | snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, i, |
Takashi Iwai | 54cbc9a | 2008-10-31 15:24:04 +0100 | [diff] [blame] | 363 | HDA_AMP_MUTE, v); |
| 364 | } |
Takashi Iwai | 54cbc9a | 2008-10-31 15:24:04 +0100 | [diff] [blame] | 365 | } else { |
| 366 | /* MUX style (e.g. ALC880) */ |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 367 | snd_hda_codec_write_cache(codec, nid, 0, |
| 368 | AC_VERB_SET_CONNECT_SEL, |
| 369 | imux->items[idx].index); |
Takashi Iwai | 54cbc9a | 2008-10-31 15:24:04 +0100 | [diff] [blame] | 370 | } |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 371 | return 1; |
| 372 | } |
| 373 | |
| 374 | static int alc_mux_enum_put(struct snd_kcontrol *kcontrol, |
| 375 | struct snd_ctl_elem_value *ucontrol) |
| 376 | { |
| 377 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 378 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 379 | return alc_mux_select(codec, adc_idx, |
| 380 | ucontrol->value.enumerated.item[0], false); |
Takashi Iwai | 54cbc9a | 2008-10-31 15:24:04 +0100 | [diff] [blame] | 381 | } |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 382 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 383 | /* |
Takashi Iwai | 23f0c04 | 2009-02-26 13:03:58 +0100 | [diff] [blame] | 384 | * set up the input pin config (depending on the given auto-pin type) |
| 385 | */ |
| 386 | static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid, |
| 387 | int auto_pin_type) |
| 388 | { |
| 389 | unsigned int val = PIN_IN; |
Takashi Iwai | 4740860 | 2012-04-20 13:06:53 +0200 | [diff] [blame] | 390 | if (auto_pin_type == AUTO_PIN_MIC) |
| 391 | val |= snd_hda_get_default_vref(codec, nid); |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 392 | snd_hda_set_pin_ctl(codec, nid, val); |
Takashi Iwai | 23f0c04 | 2009-02-26 13:03:58 +0100 | [diff] [blame] | 393 | } |
| 394 | |
| 395 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 396 | * Append the given mixer and verb elements for the later use |
| 397 | * The mixer array is referred in build_controls(), and init_verbs are |
| 398 | * called in init(). |
Takashi Iwai | d88897e | 2008-10-31 15:01:37 +0100 | [diff] [blame] | 399 | */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 400 | static void add_mixer(struct alc_spec *spec, const struct snd_kcontrol_new *mix) |
Takashi Iwai | d88897e | 2008-10-31 15:01:37 +0100 | [diff] [blame] | 401 | { |
| 402 | if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers))) |
| 403 | return; |
| 404 | spec->mixers[spec->num_mixers++] = mix; |
| 405 | } |
| 406 | |
Takashi Iwai | d88897e | 2008-10-31 15:01:37 +0100 | [diff] [blame] | 407 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 408 | * GPIO setup tables, used in initialization |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 409 | */ |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 410 | /* Enable GPIO mask and set output */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 411 | static const struct hda_verb alc_gpio1_init_verbs[] = { |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 412 | {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, |
| 413 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, |
| 414 | {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, |
| 415 | { } |
| 416 | }; |
| 417 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 418 | static const struct hda_verb alc_gpio2_init_verbs[] = { |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 419 | {0x01, AC_VERB_SET_GPIO_MASK, 0x02}, |
| 420 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02}, |
| 421 | {0x01, AC_VERB_SET_GPIO_DATA, 0x02}, |
| 422 | { } |
| 423 | }; |
| 424 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 425 | static const struct hda_verb alc_gpio3_init_verbs[] = { |
Kailang Yang | bdd148a | 2007-05-08 15:19:08 +0200 | [diff] [blame] | 426 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, |
| 427 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, |
| 428 | {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, |
| 429 | { } |
| 430 | }; |
| 431 | |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 432 | /* |
| 433 | * Fix hardware PLL issue |
| 434 | * On some codecs, the analog PLL gating control must be off while |
| 435 | * the default value is 1. |
| 436 | */ |
| 437 | static void alc_fix_pll(struct hda_codec *codec) |
| 438 | { |
| 439 | struct alc_spec *spec = codec->spec; |
| 440 | unsigned int val; |
| 441 | |
| 442 | if (!spec->pll_nid) |
| 443 | return; |
| 444 | snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX, |
| 445 | spec->pll_coef_idx); |
| 446 | val = snd_hda_codec_read(codec, spec->pll_nid, 0, |
| 447 | AC_VERB_GET_PROC_COEF, 0); |
| 448 | snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX, |
| 449 | spec->pll_coef_idx); |
| 450 | snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF, |
| 451 | val & ~(1 << spec->pll_coef_bit)); |
| 452 | } |
| 453 | |
| 454 | static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid, |
| 455 | unsigned int coef_idx, unsigned int coef_bit) |
| 456 | { |
| 457 | struct alc_spec *spec = codec->spec; |
| 458 | spec->pll_nid = nid; |
| 459 | spec->pll_coef_idx = coef_idx; |
| 460 | spec->pll_coef_bit = coef_bit; |
| 461 | alc_fix_pll(codec); |
| 462 | } |
| 463 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 464 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 465 | * Jack detections for HP auto-mute and mic-switch |
| 466 | */ |
| 467 | |
| 468 | /* check each pin in the given array; returns true if any of them is plugged */ |
| 469 | static bool detect_jacks(struct hda_codec *codec, int num_pins, hda_nid_t *pins) |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 470 | { |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 471 | int i, present = 0; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 472 | |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 473 | for (i = 0; i < num_pins; i++) { |
| 474 | hda_nid_t nid = pins[i]; |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 475 | if (!nid) |
| 476 | break; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 477 | present |= snd_hda_jack_detect(codec, nid); |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 478 | } |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 479 | return present; |
| 480 | } |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 481 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 482 | /* standard HP/line-out auto-mute helper */ |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 483 | static void do_automute(struct hda_codec *codec, int num_pins, hda_nid_t *pins, |
Takashi Iwai | e942796 | 2011-04-28 15:46:07 +0200 | [diff] [blame] | 484 | bool mute, bool hp_out) |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 485 | { |
| 486 | struct alc_spec *spec = codec->spec; |
| 487 | unsigned int mute_bits = mute ? HDA_AMP_MUTE : 0; |
Takashi Iwai | e942796 | 2011-04-28 15:46:07 +0200 | [diff] [blame] | 488 | unsigned int pin_bits = mute ? 0 : (hp_out ? PIN_HP : PIN_OUT); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 489 | int i; |
| 490 | |
| 491 | for (i = 0; i < num_pins; i++) { |
| 492 | hda_nid_t nid = pins[i]; |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 493 | unsigned int val; |
Takashi Iwai | a9fd4f3 | 2009-05-08 15:57:59 +0200 | [diff] [blame] | 494 | if (!nid) |
| 495 | break; |
Takashi Iwai | 3b8510c | 2011-04-28 14:03:24 +0200 | [diff] [blame] | 496 | switch (spec->automute_mode) { |
| 497 | case ALC_AUTOMUTE_PIN: |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 498 | /* don't reset VREF value in case it's controlling |
| 499 | * the amp (see alc861_fixup_asus_amp_vref_0f()) |
| 500 | */ |
| 501 | if (spec->keep_vref_in_automute) { |
| 502 | val = snd_hda_codec_read(codec, nid, 0, |
| 503 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 504 | val &= ~PIN_HP; |
| 505 | } else |
| 506 | val = 0; |
| 507 | val |= pin_bits; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 508 | snd_hda_set_pin_ctl(codec, nid, val); |
Takashi Iwai | 3b8510c | 2011-04-28 14:03:24 +0200 | [diff] [blame] | 509 | break; |
| 510 | case ALC_AUTOMUTE_AMP: |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 511 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 512 | HDA_AMP_MUTE, mute_bits); |
Takashi Iwai | 3b8510c | 2011-04-28 14:03:24 +0200 | [diff] [blame] | 513 | break; |
| 514 | case ALC_AUTOMUTE_MIXER: |
| 515 | nid = spec->automute_mixer_nid[i]; |
| 516 | if (!nid) |
| 517 | break; |
| 518 | snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0, |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 519 | HDA_AMP_MUTE, mute_bits); |
Takashi Iwai | 3b8510c | 2011-04-28 14:03:24 +0200 | [diff] [blame] | 520 | snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 1, |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 521 | HDA_AMP_MUTE, mute_bits); |
Takashi Iwai | 3b8510c | 2011-04-28 14:03:24 +0200 | [diff] [blame] | 522 | break; |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 523 | } |
Takashi Iwai | a9fd4f3 | 2009-05-08 15:57:59 +0200 | [diff] [blame] | 524 | } |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 525 | } |
| 526 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 527 | /* Toggle outputs muting */ |
| 528 | static void update_outputs(struct hda_codec *codec) |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 529 | { |
| 530 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 531 | int on; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 532 | |
Takashi Iwai | c0a2026 | 2011-06-10 15:28:15 +0200 | [diff] [blame] | 533 | /* Control HP pins/amps depending on master_mute state; |
| 534 | * in general, HP pins/amps control should be enabled in all cases, |
| 535 | * but currently set only for master_mute, just to be safe |
| 536 | */ |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 537 | if (!spec->shared_mic_hp) /* don't change HP-pin when shared with mic */ |
| 538 | do_automute(codec, ARRAY_SIZE(spec->autocfg.hp_pins), |
Takashi Iwai | c0a2026 | 2011-06-10 15:28:15 +0200 | [diff] [blame] | 539 | spec->autocfg.hp_pins, spec->master_mute, true); |
| 540 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 541 | if (!spec->automute_speaker) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 542 | on = 0; |
| 543 | else |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 544 | on = spec->hp_jack_present | spec->line_jack_present; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 545 | on |= spec->master_mute; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 546 | do_automute(codec, ARRAY_SIZE(spec->autocfg.speaker_pins), |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 547 | spec->autocfg.speaker_pins, on, false); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 548 | |
| 549 | /* toggle line-out mutes if needed, too */ |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 550 | /* if LO is a copy of either HP or Speaker, don't need to handle it */ |
| 551 | if (spec->autocfg.line_out_pins[0] == spec->autocfg.hp_pins[0] || |
| 552 | spec->autocfg.line_out_pins[0] == spec->autocfg.speaker_pins[0]) |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 553 | return; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 554 | if (!spec->automute_lo) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 555 | on = 0; |
| 556 | else |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 557 | on = spec->hp_jack_present; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 558 | on |= spec->master_mute; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 559 | do_automute(codec, ARRAY_SIZE(spec->autocfg.line_out_pins), |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 560 | spec->autocfg.line_out_pins, on, false); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 561 | } |
| 562 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 563 | static void call_update_outputs(struct hda_codec *codec) |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 564 | { |
| 565 | struct alc_spec *spec = codec->spec; |
| 566 | if (spec->automute_hook) |
| 567 | spec->automute_hook(codec); |
| 568 | else |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 569 | update_outputs(codec); |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 570 | } |
| 571 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 572 | /* standard HP-automute helper */ |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 573 | static void alc_hp_automute(struct hda_codec *codec) |
| 574 | { |
| 575 | struct alc_spec *spec = codec->spec; |
| 576 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 577 | spec->hp_jack_present = |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 578 | detect_jacks(codec, ARRAY_SIZE(spec->autocfg.hp_pins), |
| 579 | spec->autocfg.hp_pins); |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 580 | if (!spec->detect_hp || (!spec->automute_speaker && !spec->automute_lo)) |
Takashi Iwai | 3c715a9 | 2011-08-23 12:41:09 +0200 | [diff] [blame] | 581 | return; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 582 | call_update_outputs(codec); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 583 | } |
| 584 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 585 | /* standard line-out-automute helper */ |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 586 | static void alc_line_automute(struct hda_codec *codec) |
| 587 | { |
| 588 | struct alc_spec *spec = codec->spec; |
| 589 | |
Takashi Iwai | e0d32e3 | 2011-09-26 15:19:55 +0200 | [diff] [blame] | 590 | /* check LO jack only when it's different from HP */ |
| 591 | if (spec->autocfg.line_out_pins[0] == spec->autocfg.hp_pins[0]) |
| 592 | return; |
| 593 | |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 594 | spec->line_jack_present = |
| 595 | detect_jacks(codec, ARRAY_SIZE(spec->autocfg.line_out_pins), |
| 596 | spec->autocfg.line_out_pins); |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 597 | if (!spec->automute_speaker || !spec->detect_lo) |
Takashi Iwai | 3c715a9 | 2011-08-23 12:41:09 +0200 | [diff] [blame] | 598 | return; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 599 | call_update_outputs(codec); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 600 | } |
| 601 | |
Takashi Iwai | 8d087c7 | 2011-06-28 12:45:47 +0200 | [diff] [blame] | 602 | #define get_connection_index(codec, mux, nid) \ |
| 603 | snd_hda_get_conn_index(codec, mux, nid, 0) |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 604 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 605 | /* standard mic auto-switch helper */ |
Kailang Yang | 7fb0d78 | 2008-10-15 11:12:35 +0200 | [diff] [blame] | 606 | static void alc_mic_automute(struct hda_codec *codec) |
| 607 | { |
| 608 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 609 | hda_nid_t *pins = spec->imux_pins; |
Kailang Yang | 7fb0d78 | 2008-10-15 11:12:35 +0200 | [diff] [blame] | 610 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 611 | if (!spec->auto_mic || !spec->auto_mic_valid_imux) |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 612 | return; |
| 613 | if (snd_BUG_ON(!spec->adc_nids)) |
| 614 | return; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 615 | if (snd_BUG_ON(spec->int_mic_idx < 0 || spec->ext_mic_idx < 0)) |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 616 | return; |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 617 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 618 | if (snd_hda_jack_detect(codec, pins[spec->ext_mic_idx])) |
| 619 | alc_mux_select(codec, 0, spec->ext_mic_idx, false); |
| 620 | else if (spec->dock_mic_idx >= 0 && |
| 621 | snd_hda_jack_detect(codec, pins[spec->dock_mic_idx])) |
| 622 | alc_mux_select(codec, 0, spec->dock_mic_idx, false); |
| 623 | else |
| 624 | alc_mux_select(codec, 0, spec->int_mic_idx, false); |
Kailang Yang | 7fb0d78 | 2008-10-15 11:12:35 +0200 | [diff] [blame] | 625 | } |
| 626 | |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 627 | /* handle the specified unsol action (ALC_XXX_EVENT) */ |
| 628 | static void alc_exec_unsol_event(struct hda_codec *codec, int action) |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 629 | { |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 630 | switch (action) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 631 | case ALC_HP_EVENT: |
Takashi Iwai | d922b51 | 2011-04-28 12:18:53 +0200 | [diff] [blame] | 632 | alc_hp_automute(codec); |
Takashi Iwai | a9fd4f3 | 2009-05-08 15:57:59 +0200 | [diff] [blame] | 633 | break; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 634 | case ALC_FRONT_EVENT: |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 635 | alc_line_automute(codec); |
| 636 | break; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 637 | case ALC_MIC_EVENT: |
Kailang Yang | 7fb0d78 | 2008-10-15 11:12:35 +0200 | [diff] [blame] | 638 | alc_mic_automute(codec); |
Takashi Iwai | a9fd4f3 | 2009-05-08 15:57:59 +0200 | [diff] [blame] | 639 | break; |
| 640 | } |
Takashi Iwai | 01a61e1 | 2011-10-28 00:03:22 +0200 | [diff] [blame] | 641 | snd_hda_jack_report_sync(codec); |
Kailang Yang | 7fb0d78 | 2008-10-15 11:12:35 +0200 | [diff] [blame] | 642 | } |
| 643 | |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 644 | /* update the master volume per volume-knob's unsol event */ |
| 645 | static void alc_update_knob_master(struct hda_codec *codec, hda_nid_t nid) |
| 646 | { |
| 647 | unsigned int val; |
| 648 | struct snd_kcontrol *kctl; |
| 649 | struct snd_ctl_elem_value *uctl; |
| 650 | |
| 651 | kctl = snd_hda_find_mixer_ctl(codec, "Master Playback Volume"); |
| 652 | if (!kctl) |
| 653 | return; |
| 654 | uctl = kzalloc(sizeof(*uctl), GFP_KERNEL); |
| 655 | if (!uctl) |
| 656 | return; |
| 657 | val = snd_hda_codec_read(codec, nid, 0, |
| 658 | AC_VERB_GET_VOLUME_KNOB_CONTROL, 0); |
| 659 | val &= HDA_AMP_VOLMASK; |
| 660 | uctl->value.integer.value[0] = val; |
| 661 | uctl->value.integer.value[1] = val; |
| 662 | kctl->put(kctl, uctl); |
| 663 | kfree(uctl); |
| 664 | } |
| 665 | |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 666 | /* unsolicited event for HP jack sensing */ |
| 667 | static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res) |
| 668 | { |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 669 | int action; |
| 670 | |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 671 | if (codec->vendor_id == 0x10ec0880) |
| 672 | res >>= 28; |
| 673 | else |
| 674 | res >>= 26; |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 675 | action = snd_hda_jack_get_action(codec, res); |
David Henningsson | e21af48 | 2012-03-05 11:38:46 +0100 | [diff] [blame] | 676 | if (action == ALC_DCVOL_EVENT) { |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 677 | /* Execute the dc-vol event here as it requires the NID |
| 678 | * but we don't pass NID to alc_exec_unsol_event(). |
| 679 | * Once when we convert all static quirks to the auto-parser, |
| 680 | * this can be integerated into there. |
| 681 | */ |
| 682 | struct hda_jack_tbl *jack; |
| 683 | jack = snd_hda_jack_tbl_get_from_tag(codec, res); |
| 684 | if (jack) |
| 685 | alc_update_knob_master(codec, jack->nid); |
| 686 | return; |
| 687 | } |
| 688 | alc_exec_unsol_event(codec, action); |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 689 | } |
| 690 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 691 | /* call init functions of standard auto-mute helpers */ |
Kailang Yang | 7fb0d78 | 2008-10-15 11:12:35 +0200 | [diff] [blame] | 692 | static void alc_inithook(struct hda_codec *codec) |
| 693 | { |
Takashi Iwai | d922b51 | 2011-04-28 12:18:53 +0200 | [diff] [blame] | 694 | alc_hp_automute(codec); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 695 | alc_line_automute(codec); |
Kailang Yang | 7fb0d78 | 2008-10-15 11:12:35 +0200 | [diff] [blame] | 696 | alc_mic_automute(codec); |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 697 | } |
| 698 | |
Kailang Yang | f9423e7 | 2008-05-27 12:32:25 +0200 | [diff] [blame] | 699 | /* additional initialization for ALC888 variants */ |
| 700 | static void alc888_coef_init(struct hda_codec *codec) |
| 701 | { |
| 702 | unsigned int tmp; |
| 703 | |
| 704 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0); |
| 705 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); |
| 706 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7); |
Takashi Iwai | 37db623 | 2009-03-05 09:40:16 +0100 | [diff] [blame] | 707 | if ((tmp & 0xf0) == 0x20) |
Kailang Yang | f9423e7 | 2008-05-27 12:32:25 +0200 | [diff] [blame] | 708 | /* alc888S-VC */ |
| 709 | snd_hda_codec_read(codec, 0x20, 0, |
| 710 | AC_VERB_SET_PROC_COEF, 0x830); |
| 711 | else |
| 712 | /* alc888-VB */ |
| 713 | snd_hda_codec_read(codec, 0x20, 0, |
| 714 | AC_VERB_SET_PROC_COEF, 0x3030); |
| 715 | } |
| 716 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 717 | /* additional initialization for ALC889 variants */ |
Jaroslav Kysela | 87a8c37 | 2009-07-23 10:58:29 +0200 | [diff] [blame] | 718 | static void alc889_coef_init(struct hda_codec *codec) |
| 719 | { |
| 720 | unsigned int tmp; |
| 721 | |
| 722 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7); |
| 723 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); |
| 724 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7); |
| 725 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010); |
| 726 | } |
| 727 | |
Takashi Iwai | 3fb4a50 | 2010-01-19 15:46:37 +0100 | [diff] [blame] | 728 | /* turn on/off EAPD control (only if available) */ |
| 729 | static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on) |
| 730 | { |
| 731 | if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN) |
| 732 | return; |
| 733 | if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD) |
| 734 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE, |
| 735 | on ? 2 : 0); |
| 736 | } |
| 737 | |
Takashi Iwai | 691f1fc | 2011-04-07 10:31:43 +0200 | [diff] [blame] | 738 | /* turn on/off EAPD controls of the codec */ |
| 739 | static void alc_auto_setup_eapd(struct hda_codec *codec, bool on) |
| 740 | { |
| 741 | /* We currently only handle front, HP */ |
Takashi Iwai | 39fa84e | 2011-06-27 15:28:57 +0200 | [diff] [blame] | 742 | static hda_nid_t pins[] = { |
| 743 | 0x0f, 0x10, 0x14, 0x15, 0 |
| 744 | }; |
| 745 | hda_nid_t *p; |
| 746 | for (p = pins; *p; p++) |
| 747 | set_eapd(codec, *p, on); |
Takashi Iwai | 691f1fc | 2011-04-07 10:31:43 +0200 | [diff] [blame] | 748 | } |
| 749 | |
Takashi Iwai | 1c716153 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 750 | /* generic shutup callback; |
| 751 | * just turning off EPAD and a little pause for avoiding pop-noise |
| 752 | */ |
| 753 | static void alc_eapd_shutup(struct hda_codec *codec) |
| 754 | { |
| 755 | alc_auto_setup_eapd(codec, false); |
| 756 | msleep(200); |
| 757 | } |
| 758 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 759 | /* generic EAPD initialization */ |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 760 | static void alc_auto_init_amp(struct hda_codec *codec, int type) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 761 | { |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 762 | unsigned int tmp; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 763 | |
Takashi Iwai | 39fa84e | 2011-06-27 15:28:57 +0200 | [diff] [blame] | 764 | alc_auto_setup_eapd(codec, true); |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 765 | switch (type) { |
| 766 | case ALC_INIT_GPIO1: |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 767 | snd_hda_sequence_write(codec, alc_gpio1_init_verbs); |
| 768 | break; |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 769 | case ALC_INIT_GPIO2: |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 770 | snd_hda_sequence_write(codec, alc_gpio2_init_verbs); |
| 771 | break; |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 772 | case ALC_INIT_GPIO3: |
Kailang Yang | bdd148a | 2007-05-08 15:19:08 +0200 | [diff] [blame] | 773 | snd_hda_sequence_write(codec, alc_gpio3_init_verbs); |
| 774 | break; |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 775 | case ALC_INIT_DEFAULT: |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 776 | switch (codec->vendor_id) { |
| 777 | case 0x10ec0260: |
| 778 | snd_hda_codec_write(codec, 0x1a, 0, |
| 779 | AC_VERB_SET_COEF_INDEX, 7); |
| 780 | tmp = snd_hda_codec_read(codec, 0x1a, 0, |
| 781 | AC_VERB_GET_PROC_COEF, 0); |
| 782 | snd_hda_codec_write(codec, 0x1a, 0, |
| 783 | AC_VERB_SET_COEF_INDEX, 7); |
| 784 | snd_hda_codec_write(codec, 0x1a, 0, |
| 785 | AC_VERB_SET_PROC_COEF, |
| 786 | tmp | 0x2010); |
| 787 | break; |
| 788 | case 0x10ec0262: |
| 789 | case 0x10ec0880: |
| 790 | case 0x10ec0882: |
| 791 | case 0x10ec0883: |
| 792 | case 0x10ec0885: |
Takashi Iwai | 4a5a4c5 | 2009-02-06 12:46:59 +0100 | [diff] [blame] | 793 | case 0x10ec0887: |
Takashi Iwai | 20b67dd | 2011-03-23 22:54:32 +0100 | [diff] [blame] | 794 | /*case 0x10ec0889:*/ /* this causes an SPDIF problem */ |
Jaroslav Kysela | 87a8c37 | 2009-07-23 10:58:29 +0200 | [diff] [blame] | 795 | alc889_coef_init(codec); |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 796 | break; |
Kailang Yang | f9423e7 | 2008-05-27 12:32:25 +0200 | [diff] [blame] | 797 | case 0x10ec0888: |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 798 | alc888_coef_init(codec); |
Kailang Yang | f9423e7 | 2008-05-27 12:32:25 +0200 | [diff] [blame] | 799 | break; |
Takashi Iwai | 0aea778 | 2010-01-25 15:44:11 +0100 | [diff] [blame] | 800 | #if 0 /* XXX: This may cause the silent output on speaker on some machines */ |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 801 | case 0x10ec0267: |
| 802 | case 0x10ec0268: |
| 803 | snd_hda_codec_write(codec, 0x20, 0, |
| 804 | AC_VERB_SET_COEF_INDEX, 7); |
| 805 | tmp = snd_hda_codec_read(codec, 0x20, 0, |
| 806 | AC_VERB_GET_PROC_COEF, 0); |
| 807 | snd_hda_codec_write(codec, 0x20, 0, |
Kailang Yang | ea1fb29 | 2008-08-26 12:58:38 +0200 | [diff] [blame] | 808 | AC_VERB_SET_COEF_INDEX, 7); |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 809 | snd_hda_codec_write(codec, 0x20, 0, |
| 810 | AC_VERB_SET_PROC_COEF, |
| 811 | tmp | 0x3000); |
| 812 | break; |
Takashi Iwai | 0aea778 | 2010-01-25 15:44:11 +0100 | [diff] [blame] | 813 | #endif /* XXX */ |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 814 | } |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 815 | break; |
| 816 | } |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 817 | } |
Kailang Yang | ea1fb29 | 2008-08-26 12:58:38 +0200 | [diff] [blame] | 818 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 819 | /* |
| 820 | * Auto-Mute mode mixer enum support |
| 821 | */ |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 822 | static int alc_automute_mode_info(struct snd_kcontrol *kcontrol, |
| 823 | struct snd_ctl_elem_info *uinfo) |
| 824 | { |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 825 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 826 | struct alc_spec *spec = codec->spec; |
| 827 | static const char * const texts2[] = { |
| 828 | "Disabled", "Enabled" |
| 829 | }; |
| 830 | static const char * const texts3[] = { |
Takashi Iwai | e49a343 | 2012-03-01 18:14:41 +0100 | [diff] [blame] | 831 | "Disabled", "Speaker Only", "Line Out+Speaker" |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 832 | }; |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 833 | const char * const *texts; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 834 | |
| 835 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
| 836 | uinfo->count = 1; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 837 | if (spec->automute_speaker_possible && spec->automute_lo_possible) { |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 838 | uinfo->value.enumerated.items = 3; |
| 839 | texts = texts3; |
| 840 | } else { |
| 841 | uinfo->value.enumerated.items = 2; |
| 842 | texts = texts2; |
| 843 | } |
| 844 | if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) |
| 845 | uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 846 | strcpy(uinfo->value.enumerated.name, |
| 847 | texts[uinfo->value.enumerated.item]); |
| 848 | return 0; |
| 849 | } |
| 850 | |
| 851 | static int alc_automute_mode_get(struct snd_kcontrol *kcontrol, |
| 852 | struct snd_ctl_elem_value *ucontrol) |
| 853 | { |
| 854 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 855 | struct alc_spec *spec = codec->spec; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 856 | unsigned int val = 0; |
| 857 | if (spec->automute_speaker) |
| 858 | val++; |
| 859 | if (spec->automute_lo) |
| 860 | val++; |
| 861 | |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 862 | ucontrol->value.enumerated.item[0] = val; |
| 863 | return 0; |
| 864 | } |
| 865 | |
| 866 | static int alc_automute_mode_put(struct snd_kcontrol *kcontrol, |
| 867 | struct snd_ctl_elem_value *ucontrol) |
| 868 | { |
| 869 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 870 | struct alc_spec *spec = codec->spec; |
| 871 | |
| 872 | switch (ucontrol->value.enumerated.item[0]) { |
| 873 | case 0: |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 874 | if (!spec->automute_speaker && !spec->automute_lo) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 875 | return 0; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 876 | spec->automute_speaker = 0; |
| 877 | spec->automute_lo = 0; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 878 | break; |
| 879 | case 1: |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 880 | if (spec->automute_speaker_possible) { |
| 881 | if (!spec->automute_lo && spec->automute_speaker) |
| 882 | return 0; |
| 883 | spec->automute_speaker = 1; |
| 884 | spec->automute_lo = 0; |
| 885 | } else if (spec->automute_lo_possible) { |
| 886 | if (spec->automute_lo) |
| 887 | return 0; |
| 888 | spec->automute_lo = 1; |
| 889 | } else |
| 890 | return -EINVAL; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 891 | break; |
| 892 | case 2: |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 893 | if (!spec->automute_lo_possible || !spec->automute_speaker_possible) |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 894 | return -EINVAL; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 895 | if (spec->automute_speaker && spec->automute_lo) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 896 | return 0; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 897 | spec->automute_speaker = 1; |
| 898 | spec->automute_lo = 1; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 899 | break; |
| 900 | default: |
| 901 | return -EINVAL; |
| 902 | } |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 903 | call_update_outputs(codec); |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 904 | return 1; |
| 905 | } |
| 906 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 907 | static const struct snd_kcontrol_new alc_automute_mode_enum = { |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 908 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 909 | .name = "Auto-Mute Mode", |
| 910 | .info = alc_automute_mode_info, |
| 911 | .get = alc_automute_mode_get, |
| 912 | .put = alc_automute_mode_put, |
| 913 | }; |
| 914 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 915 | static struct snd_kcontrol_new *alc_kcontrol_new(struct alc_spec *spec) |
| 916 | { |
| 917 | snd_array_init(&spec->kctls, sizeof(struct snd_kcontrol_new), 32); |
| 918 | return snd_array_new(&spec->kctls); |
| 919 | } |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 920 | |
| 921 | static int alc_add_automute_mode_enum(struct hda_codec *codec) |
| 922 | { |
| 923 | struct alc_spec *spec = codec->spec; |
| 924 | struct snd_kcontrol_new *knew; |
| 925 | |
| 926 | knew = alc_kcontrol_new(spec); |
| 927 | if (!knew) |
| 928 | return -ENOMEM; |
| 929 | *knew = alc_automute_mode_enum; |
| 930 | knew->name = kstrdup("Auto-Mute Mode", GFP_KERNEL); |
| 931 | if (!knew->name) |
| 932 | return -ENOMEM; |
| 933 | return 0; |
| 934 | } |
| 935 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 936 | /* |
| 937 | * Check the availability of HP/line-out auto-mute; |
| 938 | * Set up appropriately if really supported |
| 939 | */ |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 940 | static void alc_init_automute(struct hda_codec *codec) |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 941 | { |
| 942 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 943 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | 1daf5f4 | 2011-04-28 17:57:46 +0200 | [diff] [blame] | 944 | int present = 0; |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 945 | int i; |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 946 | |
Takashi Iwai | 1daf5f4 | 2011-04-28 17:57:46 +0200 | [diff] [blame] | 947 | if (cfg->hp_pins[0]) |
| 948 | present++; |
| 949 | if (cfg->line_out_pins[0]) |
| 950 | present++; |
| 951 | if (cfg->speaker_pins[0]) |
| 952 | present++; |
| 953 | if (present < 2) /* need two different output types */ |
| 954 | return; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 955 | |
Takashi Iwai | c48a8fb | 2011-07-27 16:41:57 +0200 | [diff] [blame] | 956 | if (!cfg->speaker_pins[0] && |
| 957 | cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) { |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 958 | memcpy(cfg->speaker_pins, cfg->line_out_pins, |
| 959 | sizeof(cfg->speaker_pins)); |
| 960 | cfg->speaker_outs = cfg->line_outs; |
| 961 | } |
| 962 | |
Takashi Iwai | c48a8fb | 2011-07-27 16:41:57 +0200 | [diff] [blame] | 963 | if (!cfg->hp_pins[0] && |
| 964 | cfg->line_out_type == AUTO_PIN_HP_OUT) { |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 965 | memcpy(cfg->hp_pins, cfg->line_out_pins, |
| 966 | sizeof(cfg->hp_pins)); |
| 967 | cfg->hp_outs = cfg->line_outs; |
| 968 | } |
| 969 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 970 | spec->automute_mode = ALC_AUTOMUTE_PIN; |
| 971 | |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 972 | for (i = 0; i < cfg->hp_outs; i++) { |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 973 | hda_nid_t nid = cfg->hp_pins[i]; |
Takashi Iwai | 06dec22 | 2011-05-17 10:00:16 +0200 | [diff] [blame] | 974 | if (!is_jack_detectable(codec, nid)) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 975 | continue; |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 976 | snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n", |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 977 | nid); |
Takashi Iwai | 1835a0f | 2011-10-27 22:12:46 +0200 | [diff] [blame] | 978 | snd_hda_jack_detect_enable(codec, nid, ALC_HP_EVENT); |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 979 | spec->detect_hp = 1; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 980 | } |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 981 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 982 | if (cfg->line_out_type == AUTO_PIN_LINE_OUT && cfg->line_outs) { |
| 983 | if (cfg->speaker_outs) |
| 984 | for (i = 0; i < cfg->line_outs; i++) { |
| 985 | hda_nid_t nid = cfg->line_out_pins[i]; |
| 986 | if (!is_jack_detectable(codec, nid)) |
| 987 | continue; |
| 988 | snd_printdd("realtek: Enable Line-Out " |
| 989 | "auto-muting on NID 0x%x\n", nid); |
Takashi Iwai | 1835a0f | 2011-10-27 22:12:46 +0200 | [diff] [blame] | 990 | snd_hda_jack_detect_enable(codec, nid, |
| 991 | ALC_FRONT_EVENT); |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 992 | spec->detect_lo = 1; |
| 993 | } |
| 994 | spec->automute_lo_possible = spec->detect_hp; |
| 995 | } |
| 996 | |
| 997 | spec->automute_speaker_possible = cfg->speaker_outs && |
| 998 | (spec->detect_hp || spec->detect_lo); |
| 999 | |
| 1000 | spec->automute_lo = spec->automute_lo_possible; |
| 1001 | spec->automute_speaker = spec->automute_speaker_possible; |
| 1002 | |
| 1003 | if (spec->automute_speaker_possible || spec->automute_lo_possible) { |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 1004 | /* create a control for automute mode */ |
| 1005 | alc_add_automute_mode_enum(codec); |
| 1006 | spec->unsol_event = alc_sku_unsol_event; |
| 1007 | } |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1008 | } |
| 1009 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1010 | /* return the position of NID in the list, or -1 if not found */ |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1011 | static int find_idx_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums) |
| 1012 | { |
| 1013 | int i; |
| 1014 | for (i = 0; i < nums; i++) |
| 1015 | if (list[i] == nid) |
| 1016 | return i; |
| 1017 | return -1; |
| 1018 | } |
| 1019 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1020 | /* check whether dynamic ADC-switching is available */ |
| 1021 | static bool alc_check_dyn_adc_switch(struct hda_codec *codec) |
| 1022 | { |
| 1023 | struct alc_spec *spec = codec->spec; |
| 1024 | struct hda_input_mux *imux = &spec->private_imux[0]; |
| 1025 | int i, n, idx; |
| 1026 | hda_nid_t cap, pin; |
| 1027 | |
| 1028 | if (imux != spec->input_mux) /* no dynamic imux? */ |
| 1029 | return false; |
| 1030 | |
| 1031 | for (n = 0; n < spec->num_adc_nids; n++) { |
| 1032 | cap = spec->private_capsrc_nids[n]; |
| 1033 | for (i = 0; i < imux->num_items; i++) { |
| 1034 | pin = spec->imux_pins[i]; |
| 1035 | if (!pin) |
| 1036 | return false; |
| 1037 | if (get_connection_index(codec, cap, pin) < 0) |
| 1038 | break; |
| 1039 | } |
| 1040 | if (i >= imux->num_items) |
Takashi Iwai | 268ff6f | 2011-07-08 14:37:35 +0200 | [diff] [blame] | 1041 | return true; /* no ADC-switch is needed */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1042 | } |
| 1043 | |
| 1044 | for (i = 0; i < imux->num_items; i++) { |
| 1045 | pin = spec->imux_pins[i]; |
| 1046 | for (n = 0; n < spec->num_adc_nids; n++) { |
| 1047 | cap = spec->private_capsrc_nids[n]; |
| 1048 | idx = get_connection_index(codec, cap, pin); |
| 1049 | if (idx >= 0) { |
| 1050 | imux->items[i].index = idx; |
| 1051 | spec->dyn_adc_idx[i] = n; |
| 1052 | break; |
| 1053 | } |
| 1054 | } |
| 1055 | } |
| 1056 | |
| 1057 | snd_printdd("realtek: enabling ADC switching\n"); |
| 1058 | spec->dyn_adc_switch = 1; |
| 1059 | return true; |
| 1060 | } |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1061 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1062 | /* check whether all auto-mic pins are valid; setup indices if OK */ |
| 1063 | static bool alc_auto_mic_check_imux(struct hda_codec *codec) |
| 1064 | { |
| 1065 | struct alc_spec *spec = codec->spec; |
| 1066 | const struct hda_input_mux *imux; |
| 1067 | |
| 1068 | if (!spec->auto_mic) |
| 1069 | return false; |
| 1070 | if (spec->auto_mic_valid_imux) |
| 1071 | return true; /* already checked */ |
| 1072 | |
| 1073 | /* fill up imux indices */ |
| 1074 | if (!alc_check_dyn_adc_switch(codec)) { |
| 1075 | spec->auto_mic = 0; |
| 1076 | return false; |
| 1077 | } |
| 1078 | |
| 1079 | imux = spec->input_mux; |
| 1080 | spec->ext_mic_idx = find_idx_in_nid_list(spec->ext_mic_pin, |
| 1081 | spec->imux_pins, imux->num_items); |
| 1082 | spec->int_mic_idx = find_idx_in_nid_list(spec->int_mic_pin, |
| 1083 | spec->imux_pins, imux->num_items); |
| 1084 | spec->dock_mic_idx = find_idx_in_nid_list(spec->dock_mic_pin, |
| 1085 | spec->imux_pins, imux->num_items); |
| 1086 | if (spec->ext_mic_idx < 0 || spec->int_mic_idx < 0) { |
| 1087 | spec->auto_mic = 0; |
| 1088 | return false; /* no corresponding imux */ |
| 1089 | } |
| 1090 | |
Takashi Iwai | 1835a0f | 2011-10-27 22:12:46 +0200 | [diff] [blame] | 1091 | snd_hda_jack_detect_enable(codec, spec->ext_mic_pin, ALC_MIC_EVENT); |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1092 | if (spec->dock_mic_pin) |
Takashi Iwai | 1835a0f | 2011-10-27 22:12:46 +0200 | [diff] [blame] | 1093 | snd_hda_jack_detect_enable(codec, spec->dock_mic_pin, |
| 1094 | ALC_MIC_EVENT); |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1095 | |
| 1096 | spec->auto_mic_valid_imux = 1; |
| 1097 | spec->auto_mic = 1; |
| 1098 | return true; |
| 1099 | } |
| 1100 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1101 | /* |
| 1102 | * Check the availability of auto-mic switch; |
| 1103 | * Set up if really supported |
| 1104 | */ |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1105 | static void alc_init_auto_mic(struct hda_codec *codec) |
| 1106 | { |
| 1107 | struct alc_spec *spec = codec->spec; |
| 1108 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1109 | hda_nid_t fixed, ext, dock; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1110 | int i; |
| 1111 | |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 1112 | if (spec->shared_mic_hp) |
| 1113 | return; /* no auto-mic for the shared I/O */ |
| 1114 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1115 | spec->ext_mic_idx = spec->int_mic_idx = spec->dock_mic_idx = -1; |
| 1116 | |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1117 | fixed = ext = dock = 0; |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 1118 | for (i = 0; i < cfg->num_inputs; i++) { |
| 1119 | hda_nid_t nid = cfg->inputs[i].pin; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1120 | unsigned int defcfg; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1121 | defcfg = snd_hda_codec_get_pincfg(codec, nid); |
Takashi Iwai | 99ae28b | 2010-09-17 14:42:34 +0200 | [diff] [blame] | 1122 | switch (snd_hda_get_input_pin_attr(defcfg)) { |
| 1123 | case INPUT_PIN_ATTR_INT: |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1124 | if (fixed) |
| 1125 | return; /* already occupied */ |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1126 | if (cfg->inputs[i].type != AUTO_PIN_MIC) |
| 1127 | return; /* invalid type */ |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1128 | fixed = nid; |
| 1129 | break; |
Takashi Iwai | 99ae28b | 2010-09-17 14:42:34 +0200 | [diff] [blame] | 1130 | case INPUT_PIN_ATTR_UNUSED: |
| 1131 | return; /* invalid entry */ |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1132 | case INPUT_PIN_ATTR_DOCK: |
| 1133 | if (dock) |
| 1134 | return; /* already occupied */ |
| 1135 | if (cfg->inputs[i].type > AUTO_PIN_LINE_IN) |
| 1136 | return; /* invalid type */ |
| 1137 | dock = nid; |
| 1138 | break; |
Takashi Iwai | 99ae28b | 2010-09-17 14:42:34 +0200 | [diff] [blame] | 1139 | default: |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1140 | if (ext) |
| 1141 | return; /* already occupied */ |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1142 | if (cfg->inputs[i].type != AUTO_PIN_MIC) |
| 1143 | return; /* invalid type */ |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1144 | ext = nid; |
| 1145 | break; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1146 | } |
| 1147 | } |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1148 | if (!ext && dock) { |
| 1149 | ext = dock; |
| 1150 | dock = 0; |
| 1151 | } |
Takashi Iwai | eaa9b3a | 2010-01-17 13:09:33 +0100 | [diff] [blame] | 1152 | if (!ext || !fixed) |
| 1153 | return; |
Takashi Iwai | e35d9d6 | 2011-05-17 11:28:16 +0200 | [diff] [blame] | 1154 | if (!is_jack_detectable(codec, ext)) |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1155 | return; /* no unsol support */ |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1156 | if (dock && !is_jack_detectable(codec, dock)) |
| 1157 | return; /* no unsol support */ |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1158 | |
| 1159 | /* check imux indices */ |
| 1160 | spec->ext_mic_pin = ext; |
| 1161 | spec->int_mic_pin = fixed; |
| 1162 | spec->dock_mic_pin = dock; |
| 1163 | |
| 1164 | spec->auto_mic = 1; |
| 1165 | if (!alc_auto_mic_check_imux(codec)) |
| 1166 | return; |
| 1167 | |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1168 | snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x/0x%x\n", |
| 1169 | ext, fixed, dock); |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1170 | spec->unsol_event = alc_sku_unsol_event; |
| 1171 | } |
| 1172 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1173 | /* check the availabilities of auto-mute and auto-mic switches */ |
| 1174 | static void alc_auto_check_switches(struct hda_codec *codec) |
| 1175 | { |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 1176 | alc_init_automute(codec); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1177 | alc_init_auto_mic(codec); |
| 1178 | } |
| 1179 | |
| 1180 | /* |
| 1181 | * Realtek SSID verification |
| 1182 | */ |
| 1183 | |
David Henningsson | 9062291 | 2010-10-14 14:50:18 +0200 | [diff] [blame] | 1184 | /* Could be any non-zero and even value. When used as fixup, tells |
| 1185 | * the driver to ignore any present sku defines. |
| 1186 | */ |
| 1187 | #define ALC_FIXUP_SKU_IGNORE (2) |
| 1188 | |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame^] | 1189 | static void alc_fixup_sku_ignore(struct hda_codec *codec, |
| 1190 | const struct hda_fixup *fix, int action) |
| 1191 | { |
| 1192 | struct alc_spec *spec = codec->spec; |
| 1193 | if (action == HDA_FIXUP_ACT_PRE_PROBE) { |
| 1194 | spec->cdefine.fixup = 1; |
| 1195 | spec->cdefine.sku_cfg = ALC_FIXUP_SKU_IGNORE; |
| 1196 | } |
| 1197 | } |
| 1198 | |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 1199 | static int alc_auto_parse_customize_define(struct hda_codec *codec) |
| 1200 | { |
| 1201 | unsigned int ass, tmp, i; |
Takashi Iwai | 7fb5622 | 2010-03-22 17:09:47 +0100 | [diff] [blame] | 1202 | unsigned nid = 0; |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 1203 | struct alc_spec *spec = codec->spec; |
| 1204 | |
Takashi Iwai | b6cbe51 | 2010-07-28 17:43:36 +0200 | [diff] [blame] | 1205 | spec->cdefine.enable_pcbeep = 1; /* assume always enabled */ |
| 1206 | |
David Henningsson | 9062291 | 2010-10-14 14:50:18 +0200 | [diff] [blame] | 1207 | if (spec->cdefine.fixup) { |
| 1208 | ass = spec->cdefine.sku_cfg; |
| 1209 | if (ass == ALC_FIXUP_SKU_IGNORE) |
| 1210 | return -1; |
| 1211 | goto do_sku; |
| 1212 | } |
| 1213 | |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 1214 | ass = codec->subsystem_id & 0xffff; |
Takashi Iwai | b6cbe51 | 2010-07-28 17:43:36 +0200 | [diff] [blame] | 1215 | if (ass != codec->bus->pci->subsystem_device && (ass & 1)) |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 1216 | goto do_sku; |
| 1217 | |
| 1218 | nid = 0x1d; |
| 1219 | if (codec->vendor_id == 0x10ec0260) |
| 1220 | nid = 0x17; |
| 1221 | ass = snd_hda_codec_get_pincfg(codec, nid); |
| 1222 | |
| 1223 | if (!(ass & 1)) { |
| 1224 | printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n", |
| 1225 | codec->chip_name, ass); |
| 1226 | return -1; |
| 1227 | } |
| 1228 | |
| 1229 | /* check sum */ |
| 1230 | tmp = 0; |
| 1231 | for (i = 1; i < 16; i++) { |
| 1232 | if ((ass >> i) & 1) |
| 1233 | tmp++; |
| 1234 | } |
| 1235 | if (((ass >> 16) & 0xf) != tmp) |
| 1236 | return -1; |
| 1237 | |
| 1238 | spec->cdefine.port_connectivity = ass >> 30; |
| 1239 | spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20; |
| 1240 | spec->cdefine.check_sum = (ass >> 16) & 0xf; |
| 1241 | spec->cdefine.customization = ass >> 8; |
| 1242 | do_sku: |
| 1243 | spec->cdefine.sku_cfg = ass; |
| 1244 | spec->cdefine.external_amp = (ass & 0x38) >> 3; |
| 1245 | spec->cdefine.platform_type = (ass & 0x4) >> 2; |
| 1246 | spec->cdefine.swap = (ass & 0x2) >> 1; |
| 1247 | spec->cdefine.override = ass & 0x1; |
| 1248 | |
| 1249 | snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n", |
| 1250 | nid, spec->cdefine.sku_cfg); |
| 1251 | snd_printd("SKU: port_connectivity=0x%x\n", |
| 1252 | spec->cdefine.port_connectivity); |
| 1253 | snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep); |
| 1254 | snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum); |
| 1255 | snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization); |
| 1256 | snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp); |
| 1257 | snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type); |
| 1258 | snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap); |
| 1259 | snd_printd("SKU: override=0x%x\n", spec->cdefine.override); |
| 1260 | |
| 1261 | return 0; |
| 1262 | } |
| 1263 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1264 | /* return true if the given NID is found in the list */ |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 1265 | static bool found_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums) |
| 1266 | { |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1267 | return find_idx_in_nid_list(nid, list, nums) >= 0; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 1268 | } |
| 1269 | |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1270 | /* check subsystem ID and set up device-specific initialization; |
| 1271 | * return 1 if initialized, 0 if invalid SSID |
| 1272 | */ |
| 1273 | /* 32-bit subsystem ID for BIOS loading in HD Audio codec. |
| 1274 | * 31 ~ 16 : Manufacture ID |
| 1275 | * 15 ~ 8 : SKU ID |
| 1276 | * 7 ~ 0 : Assembly ID |
| 1277 | * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36 |
| 1278 | */ |
| 1279 | static int alc_subsystem_id(struct hda_codec *codec, |
| 1280 | hda_nid_t porta, hda_nid_t porte, |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 1281 | hda_nid_t portd, hda_nid_t porti) |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1282 | { |
| 1283 | unsigned int ass, tmp, i; |
| 1284 | unsigned nid; |
| 1285 | struct alc_spec *spec = codec->spec; |
| 1286 | |
David Henningsson | 9062291 | 2010-10-14 14:50:18 +0200 | [diff] [blame] | 1287 | if (spec->cdefine.fixup) { |
| 1288 | ass = spec->cdefine.sku_cfg; |
| 1289 | if (ass == ALC_FIXUP_SKU_IGNORE) |
| 1290 | return 0; |
| 1291 | goto do_sku; |
| 1292 | } |
| 1293 | |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1294 | ass = codec->subsystem_id & 0xffff; |
| 1295 | if ((ass != codec->bus->pci->subsystem_device) && (ass & 1)) |
| 1296 | goto do_sku; |
| 1297 | |
| 1298 | /* invalid SSID, check the special NID pin defcfg instead */ |
| 1299 | /* |
Sasha Alexandr | def319f | 2009-06-16 16:00:15 -0400 | [diff] [blame] | 1300 | * 31~30 : port connectivity |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1301 | * 29~21 : reserve |
| 1302 | * 20 : PCBEEP input |
| 1303 | * 19~16 : Check sum (15:1) |
| 1304 | * 15~1 : Custom |
| 1305 | * 0 : override |
| 1306 | */ |
| 1307 | nid = 0x1d; |
| 1308 | if (codec->vendor_id == 0x10ec0260) |
| 1309 | nid = 0x17; |
| 1310 | ass = snd_hda_codec_get_pincfg(codec, nid); |
| 1311 | snd_printd("realtek: No valid SSID, " |
| 1312 | "checking pincfg 0x%08x for NID 0x%x\n", |
Takashi Iwai | cb6605c | 2009-04-28 13:03:19 +0200 | [diff] [blame] | 1313 | ass, nid); |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 1314 | if (!(ass & 1)) |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1315 | return 0; |
| 1316 | if ((ass >> 30) != 1) /* no physical connection */ |
| 1317 | return 0; |
| 1318 | |
| 1319 | /* check sum */ |
| 1320 | tmp = 0; |
| 1321 | for (i = 1; i < 16; i++) { |
| 1322 | if ((ass >> i) & 1) |
| 1323 | tmp++; |
| 1324 | } |
| 1325 | if (((ass >> 16) & 0xf) != tmp) |
| 1326 | return 0; |
| 1327 | do_sku: |
| 1328 | snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n", |
| 1329 | ass & 0xffff, codec->vendor_id); |
| 1330 | /* |
| 1331 | * 0 : override |
| 1332 | * 1 : Swap Jack |
| 1333 | * 2 : 0 --> Desktop, 1 --> Laptop |
| 1334 | * 3~5 : External Amplifier control |
| 1335 | * 7~6 : Reserved |
| 1336 | */ |
| 1337 | tmp = (ass & 0x38) >> 3; /* external Amp control */ |
| 1338 | switch (tmp) { |
| 1339 | case 1: |
| 1340 | spec->init_amp = ALC_INIT_GPIO1; |
| 1341 | break; |
| 1342 | case 3: |
| 1343 | spec->init_amp = ALC_INIT_GPIO2; |
| 1344 | break; |
| 1345 | case 7: |
| 1346 | spec->init_amp = ALC_INIT_GPIO3; |
| 1347 | break; |
| 1348 | case 5: |
Takashi Iwai | 5a8cfb4 | 2010-11-26 17:11:18 +0100 | [diff] [blame] | 1349 | default: |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1350 | spec->init_amp = ALC_INIT_DEFAULT; |
| 1351 | break; |
| 1352 | } |
| 1353 | |
| 1354 | /* is laptop or Desktop and enable the function "Mute internal speaker |
| 1355 | * when the external headphone out jack is plugged" |
| 1356 | */ |
| 1357 | if (!(ass & 0x8000)) |
| 1358 | return 1; |
| 1359 | /* |
| 1360 | * 10~8 : Jack location |
| 1361 | * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered |
| 1362 | * 14~13: Resvered |
| 1363 | * 15 : 1 --> enable the function "Mute internal speaker |
| 1364 | * when the external headphone out jack is plugged" |
| 1365 | */ |
Takashi Iwai | 5fe6e01 | 2011-09-26 10:41:21 +0200 | [diff] [blame] | 1366 | if (!spec->autocfg.hp_pins[0] && |
| 1367 | !(spec->autocfg.line_out_pins[0] && |
| 1368 | spec->autocfg.line_out_type == AUTO_PIN_HP_OUT)) { |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1369 | hda_nid_t nid; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1370 | tmp = (ass >> 11) & 0x3; /* HP to chassis */ |
| 1371 | if (tmp == 0) |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1372 | nid = porta; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1373 | else if (tmp == 1) |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1374 | nid = porte; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1375 | else if (tmp == 2) |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1376 | nid = portd; |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 1377 | else if (tmp == 3) |
| 1378 | nid = porti; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1379 | else |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1380 | return 1; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 1381 | if (found_in_nid_list(nid, spec->autocfg.line_out_pins, |
| 1382 | spec->autocfg.line_outs)) |
| 1383 | return 1; |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1384 | spec->autocfg.hp_pins[0] = nid; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1385 | } |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1386 | return 1; |
| 1387 | } |
Kailang Yang | ea1fb29 | 2008-08-26 12:58:38 +0200 | [diff] [blame] | 1388 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 1389 | /* Check the validity of ALC subsystem-id |
| 1390 | * ports contains an array of 4 pin NIDs for port-A, E, D and I */ |
| 1391 | static void alc_ssid_check(struct hda_codec *codec, const hda_nid_t *ports) |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1392 | { |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 1393 | if (!alc_subsystem_id(codec, ports[0], ports[1], ports[2], ports[3])) { |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1394 | struct alc_spec *spec = codec->spec; |
| 1395 | snd_printd("realtek: " |
| 1396 | "Enable default setup for auto mode as fallback\n"); |
| 1397 | spec->init_amp = ALC_INIT_DEFAULT; |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1398 | } |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1399 | } |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 1400 | |
Takashi Iwai | 41e41f1 | 2005-06-08 14:48:49 +0200 | [diff] [blame] | 1401 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1402 | * COEF access helper functions |
| 1403 | */ |
Kailang Yang | 274693f | 2009-12-03 10:07:50 +0100 | [diff] [blame] | 1404 | static int alc_read_coef_idx(struct hda_codec *codec, |
| 1405 | unsigned int coef_idx) |
| 1406 | { |
| 1407 | unsigned int val; |
| 1408 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, |
| 1409 | coef_idx); |
| 1410 | val = snd_hda_codec_read(codec, 0x20, 0, |
| 1411 | AC_VERB_GET_PROC_COEF, 0); |
| 1412 | return val; |
| 1413 | } |
| 1414 | |
Kailang Yang | 977ddd6 | 2010-09-15 10:02:29 +0200 | [diff] [blame] | 1415 | static void alc_write_coef_idx(struct hda_codec *codec, unsigned int coef_idx, |
| 1416 | unsigned int coef_val) |
| 1417 | { |
| 1418 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, |
| 1419 | coef_idx); |
| 1420 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, |
| 1421 | coef_val); |
| 1422 | } |
| 1423 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 1424 | /* a special bypass for COEF 0; read the cached value at the second time */ |
| 1425 | static unsigned int alc_get_coef0(struct hda_codec *codec) |
| 1426 | { |
| 1427 | struct alc_spec *spec = codec->spec; |
| 1428 | if (!spec->coef0) |
| 1429 | spec->coef0 = alc_read_coef_idx(codec, 0); |
| 1430 | return spec->coef0; |
| 1431 | } |
| 1432 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1433 | /* |
| 1434 | * Digital I/O handling |
| 1435 | */ |
| 1436 | |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1437 | /* set right pin controls for digital I/O */ |
| 1438 | static void alc_auto_init_digital(struct hda_codec *codec) |
| 1439 | { |
| 1440 | struct alc_spec *spec = codec->spec; |
| 1441 | int i; |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 1442 | hda_nid_t pin, dac; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1443 | |
| 1444 | for (i = 0; i < spec->autocfg.dig_outs; i++) { |
| 1445 | pin = spec->autocfg.dig_out_pins[i]; |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 1446 | if (!pin) |
| 1447 | continue; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 1448 | snd_hda_set_pin_ctl(codec, pin, PIN_OUT); |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 1449 | if (!i) |
| 1450 | dac = spec->multiout.dig_out_nid; |
| 1451 | else |
| 1452 | dac = spec->slave_dig_outs[i - 1]; |
| 1453 | if (!dac || !(get_wcaps(codec, dac) & AC_WCAP_OUT_AMP)) |
| 1454 | continue; |
| 1455 | snd_hda_codec_write(codec, dac, 0, |
| 1456 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 1457 | AMP_OUT_UNMUTE); |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1458 | } |
| 1459 | pin = spec->autocfg.dig_in_pin; |
| 1460 | if (pin) |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 1461 | snd_hda_set_pin_ctl(codec, pin, PIN_IN); |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1462 | } |
| 1463 | |
| 1464 | /* parse digital I/Os and set up NIDs in BIOS auto-parse mode */ |
| 1465 | static void alc_auto_parse_digital(struct hda_codec *codec) |
| 1466 | { |
| 1467 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1468 | int i, err, nums; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1469 | hda_nid_t dig_nid; |
| 1470 | |
| 1471 | /* support multiple SPDIFs; the secondary is set up as a slave */ |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1472 | nums = 0; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1473 | for (i = 0; i < spec->autocfg.dig_outs; i++) { |
Takashi Iwai | a926757 | 2011-07-07 15:12:55 +0200 | [diff] [blame] | 1474 | hda_nid_t conn[4]; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1475 | err = snd_hda_get_connections(codec, |
| 1476 | spec->autocfg.dig_out_pins[i], |
Takashi Iwai | a926757 | 2011-07-07 15:12:55 +0200 | [diff] [blame] | 1477 | conn, ARRAY_SIZE(conn)); |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1478 | if (err <= 0) |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1479 | continue; |
Takashi Iwai | a926757 | 2011-07-07 15:12:55 +0200 | [diff] [blame] | 1480 | dig_nid = conn[0]; /* assume the first element is audio-out */ |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1481 | if (!nums) { |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1482 | spec->multiout.dig_out_nid = dig_nid; |
| 1483 | spec->dig_out_type = spec->autocfg.dig_out_type[0]; |
| 1484 | } else { |
| 1485 | spec->multiout.slave_dig_outs = spec->slave_dig_outs; |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1486 | if (nums >= ARRAY_SIZE(spec->slave_dig_outs) - 1) |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1487 | break; |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1488 | spec->slave_dig_outs[nums - 1] = dig_nid; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1489 | } |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1490 | nums++; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1491 | } |
| 1492 | |
| 1493 | if (spec->autocfg.dig_in_pin) { |
Takashi Iwai | 01fdf18 | 2010-09-24 09:09:42 +0200 | [diff] [blame] | 1494 | dig_nid = codec->start_nid; |
| 1495 | for (i = 0; i < codec->num_nodes; i++, dig_nid++) { |
| 1496 | unsigned int wcaps = get_wcaps(codec, dig_nid); |
| 1497 | if (get_wcaps_type(wcaps) != AC_WID_AUD_IN) |
| 1498 | continue; |
| 1499 | if (!(wcaps & AC_WCAP_DIGITAL)) |
| 1500 | continue; |
| 1501 | if (!(wcaps & AC_WCAP_CONN_LIST)) |
| 1502 | continue; |
| 1503 | err = get_connection_index(codec, dig_nid, |
| 1504 | spec->autocfg.dig_in_pin); |
| 1505 | if (err >= 0) { |
| 1506 | spec->dig_in_nid = dig_nid; |
| 1507 | break; |
| 1508 | } |
| 1509 | } |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1510 | } |
| 1511 | } |
| 1512 | |
Takashi Iwai | f95474e | 2007-07-10 00:47:43 +0200 | [diff] [blame] | 1513 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1514 | * capture mixer elements |
Vincent Petry | ef8ef5f | 2008-11-23 11:31:41 +0800 | [diff] [blame] | 1515 | */ |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1516 | static int alc_cap_vol_info(struct snd_kcontrol *kcontrol, |
| 1517 | struct snd_ctl_elem_info *uinfo) |
| 1518 | { |
| 1519 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1520 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 1521 | unsigned long val; |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1522 | int err; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1523 | |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1524 | mutex_lock(&codec->control_mutex); |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 1525 | if (spec->vol_in_capsrc) |
| 1526 | val = HDA_COMPOSE_AMP_VAL(spec->capsrc_nids[0], 3, 0, HDA_OUTPUT); |
| 1527 | else |
| 1528 | val = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0, HDA_INPUT); |
| 1529 | kcontrol->private_value = val; |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1530 | err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo); |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1531 | mutex_unlock(&codec->control_mutex); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1532 | return err; |
| 1533 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1534 | |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1535 | static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag, |
| 1536 | unsigned int size, unsigned int __user *tlv) |
| 1537 | { |
| 1538 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1539 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 1540 | unsigned long val; |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1541 | int err; |
| 1542 | |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1543 | mutex_lock(&codec->control_mutex); |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 1544 | if (spec->vol_in_capsrc) |
| 1545 | val = HDA_COMPOSE_AMP_VAL(spec->capsrc_nids[0], 3, 0, HDA_OUTPUT); |
| 1546 | else |
| 1547 | val = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0, HDA_INPUT); |
| 1548 | kcontrol->private_value = val; |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1549 | err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv); |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1550 | mutex_unlock(&codec->control_mutex); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1551 | return err; |
| 1552 | } |
| 1553 | |
| 1554 | typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol, |
| 1555 | struct snd_ctl_elem_value *ucontrol); |
| 1556 | |
| 1557 | static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol, |
| 1558 | struct snd_ctl_elem_value *ucontrol, |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1559 | getput_call_t func, bool check_adc_switch) |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1560 | { |
| 1561 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1562 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1563 | int i, err = 0; |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1564 | |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1565 | mutex_lock(&codec->control_mutex); |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1566 | if (check_adc_switch && spec->dyn_adc_switch) { |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1567 | for (i = 0; i < spec->num_adc_nids; i++) { |
| 1568 | kcontrol->private_value = |
| 1569 | HDA_COMPOSE_AMP_VAL(spec->adc_nids[i], |
| 1570 | 3, 0, HDA_INPUT); |
| 1571 | err = func(kcontrol, ucontrol); |
| 1572 | if (err < 0) |
| 1573 | goto error; |
| 1574 | } |
| 1575 | } else { |
| 1576 | i = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 1577 | if (spec->vol_in_capsrc) |
| 1578 | kcontrol->private_value = |
| 1579 | HDA_COMPOSE_AMP_VAL(spec->capsrc_nids[i], |
| 1580 | 3, 0, HDA_OUTPUT); |
| 1581 | else |
| 1582 | kcontrol->private_value = |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1583 | HDA_COMPOSE_AMP_VAL(spec->adc_nids[i], |
| 1584 | 3, 0, HDA_INPUT); |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1585 | err = func(kcontrol, ucontrol); |
| 1586 | } |
| 1587 | error: |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1588 | mutex_unlock(&codec->control_mutex); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1589 | return err; |
| 1590 | } |
| 1591 | |
| 1592 | static int alc_cap_vol_get(struct snd_kcontrol *kcontrol, |
| 1593 | struct snd_ctl_elem_value *ucontrol) |
| 1594 | { |
| 1595 | return alc_cap_getput_caller(kcontrol, ucontrol, |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1596 | snd_hda_mixer_amp_volume_get, false); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1597 | } |
| 1598 | |
| 1599 | static int alc_cap_vol_put(struct snd_kcontrol *kcontrol, |
| 1600 | struct snd_ctl_elem_value *ucontrol) |
| 1601 | { |
| 1602 | return alc_cap_getput_caller(kcontrol, ucontrol, |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1603 | snd_hda_mixer_amp_volume_put, true); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1604 | } |
| 1605 | |
| 1606 | /* capture mixer elements */ |
| 1607 | #define alc_cap_sw_info snd_ctl_boolean_stereo_info |
| 1608 | |
| 1609 | static int alc_cap_sw_get(struct snd_kcontrol *kcontrol, |
| 1610 | struct snd_ctl_elem_value *ucontrol) |
| 1611 | { |
| 1612 | return alc_cap_getput_caller(kcontrol, ucontrol, |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1613 | snd_hda_mixer_amp_switch_get, false); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1614 | } |
| 1615 | |
| 1616 | static int alc_cap_sw_put(struct snd_kcontrol *kcontrol, |
| 1617 | struct snd_ctl_elem_value *ucontrol) |
| 1618 | { |
| 1619 | return alc_cap_getput_caller(kcontrol, ucontrol, |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1620 | snd_hda_mixer_amp_switch_put, true); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1621 | } |
| 1622 | |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1623 | #define _DEFINE_CAPMIX(num) \ |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1624 | { \ |
| 1625 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1626 | .name = "Capture Switch", \ |
| 1627 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \ |
| 1628 | .count = num, \ |
| 1629 | .info = alc_cap_sw_info, \ |
| 1630 | .get = alc_cap_sw_get, \ |
| 1631 | .put = alc_cap_sw_put, \ |
| 1632 | }, \ |
| 1633 | { \ |
| 1634 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1635 | .name = "Capture Volume", \ |
| 1636 | .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \ |
| 1637 | SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ |
| 1638 | SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \ |
| 1639 | .count = num, \ |
| 1640 | .info = alc_cap_vol_info, \ |
| 1641 | .get = alc_cap_vol_get, \ |
| 1642 | .put = alc_cap_vol_put, \ |
| 1643 | .tlv = { .c = alc_cap_vol_tlv }, \ |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1644 | } |
| 1645 | |
| 1646 | #define _DEFINE_CAPSRC(num) \ |
Takashi Iwai | 3c3e989 | 2008-10-31 17:48:56 +0100 | [diff] [blame] | 1647 | { \ |
| 1648 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1649 | /* .name = "Capture Source", */ \ |
| 1650 | .name = "Input Source", \ |
| 1651 | .count = num, \ |
| 1652 | .info = alc_mux_enum_info, \ |
| 1653 | .get = alc_mux_enum_get, \ |
| 1654 | .put = alc_mux_enum_put, \ |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1655 | } |
| 1656 | |
| 1657 | #define DEFINE_CAPMIX(num) \ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 1658 | static const struct snd_kcontrol_new alc_capture_mixer ## num[] = { \ |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1659 | _DEFINE_CAPMIX(num), \ |
| 1660 | _DEFINE_CAPSRC(num), \ |
| 1661 | { } /* end */ \ |
| 1662 | } |
| 1663 | |
| 1664 | #define DEFINE_CAPMIX_NOSRC(num) \ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 1665 | static const struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \ |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1666 | _DEFINE_CAPMIX(num), \ |
| 1667 | { } /* end */ \ |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1668 | } |
| 1669 | |
| 1670 | /* up to three ADCs */ |
| 1671 | DEFINE_CAPMIX(1); |
| 1672 | DEFINE_CAPMIX(2); |
| 1673 | DEFINE_CAPMIX(3); |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1674 | DEFINE_CAPMIX_NOSRC(1); |
| 1675 | DEFINE_CAPMIX_NOSRC(2); |
| 1676 | DEFINE_CAPMIX_NOSRC(3); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1677 | |
| 1678 | /* |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1679 | * virtual master controls |
| 1680 | */ |
| 1681 | |
| 1682 | /* |
| 1683 | * slave controls for virtual master |
| 1684 | */ |
Takashi Iwai | 9322ca5 | 2012-02-03 14:28:01 +0100 | [diff] [blame] | 1685 | static const char * const alc_slave_pfxs[] = { |
| 1686 | "Front", "Surround", "Center", "LFE", "Side", |
Takashi Iwai | 7c58975 | 2012-03-02 09:00:33 +0100 | [diff] [blame] | 1687 | "Headphone", "Speaker", "Mono", "Line Out", |
Takashi Iwai | 9322ca5 | 2012-02-03 14:28:01 +0100 | [diff] [blame] | 1688 | "CLFE", "Bass Speaker", "PCM", |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1689 | NULL, |
| 1690 | }; |
| 1691 | |
| 1692 | /* |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1693 | * build control elements |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1694 | */ |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 1695 | |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 1696 | #define NID_MAPPING (-1) |
| 1697 | |
| 1698 | #define SUBDEV_SPEAKER_ (0 << 6) |
| 1699 | #define SUBDEV_HP_ (1 << 6) |
| 1700 | #define SUBDEV_LINE_ (2 << 6) |
| 1701 | #define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f)) |
| 1702 | #define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f)) |
| 1703 | #define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f)) |
| 1704 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 1705 | static void alc_free_kctls(struct hda_codec *codec); |
| 1706 | |
Takashi Iwai | 67d634c | 2009-11-16 15:35:59 +0100 | [diff] [blame] | 1707 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1708 | /* additional beep mixers; the actual parameters are overwritten at build */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 1709 | static const struct snd_kcontrol_new alc_beep_mixer[] = { |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1710 | HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT), |
Jaroslav Kysela | 123c07a | 2009-10-21 14:48:23 +0200 | [diff] [blame] | 1711 | HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT), |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1712 | { } /* end */ |
| 1713 | }; |
Takashi Iwai | 67d634c | 2009-11-16 15:35:59 +0100 | [diff] [blame] | 1714 | #endif |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1715 | |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 1716 | static int __alc_build_controls(struct hda_codec *codec) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1717 | { |
| 1718 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 2f44f84 | 2010-06-22 11:12:32 +0200 | [diff] [blame] | 1719 | struct snd_kcontrol *kctl = NULL; |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 1720 | const struct snd_kcontrol_new *knew; |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 1721 | int i, j, err; |
| 1722 | unsigned int u; |
| 1723 | hda_nid_t nid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1724 | |
| 1725 | for (i = 0; i < spec->num_mixers; i++) { |
| 1726 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); |
| 1727 | if (err < 0) |
| 1728 | return err; |
| 1729 | } |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1730 | if (spec->cap_mixer) { |
| 1731 | err = snd_hda_add_new_ctls(codec, spec->cap_mixer); |
| 1732 | if (err < 0) |
| 1733 | return err; |
| 1734 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1735 | if (spec->multiout.dig_out_nid) { |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 1736 | err = snd_hda_create_spdif_out_ctls(codec, |
Stephen Warren | 74b654c | 2011-06-01 11:14:18 -0600 | [diff] [blame] | 1737 | spec->multiout.dig_out_nid, |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 1738 | spec->multiout.dig_out_nid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1739 | if (err < 0) |
| 1740 | return err; |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 1741 | if (!spec->no_analog) { |
| 1742 | err = snd_hda_create_spdif_share_sw(codec, |
| 1743 | &spec->multiout); |
| 1744 | if (err < 0) |
| 1745 | return err; |
| 1746 | spec->multiout.share_spdif = 1; |
| 1747 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1748 | } |
| 1749 | if (spec->dig_in_nid) { |
| 1750 | err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); |
| 1751 | if (err < 0) |
| 1752 | return err; |
| 1753 | } |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1754 | |
Takashi Iwai | 67d634c | 2009-11-16 15:35:59 +0100 | [diff] [blame] | 1755 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1756 | /* create beep controls if needed */ |
| 1757 | if (spec->beep_amp) { |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 1758 | const struct snd_kcontrol_new *knew; |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1759 | for (knew = alc_beep_mixer; knew->name; knew++) { |
| 1760 | struct snd_kcontrol *kctl; |
| 1761 | kctl = snd_ctl_new1(knew, codec); |
| 1762 | if (!kctl) |
| 1763 | return -ENOMEM; |
| 1764 | kctl->private_value = spec->beep_amp; |
Jaroslav Kysela | 5e26dfd | 2009-12-10 13:57:01 +0100 | [diff] [blame] | 1765 | err = snd_hda_ctl_add(codec, 0, kctl); |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1766 | if (err < 0) |
| 1767 | return err; |
| 1768 | } |
| 1769 | } |
Takashi Iwai | 67d634c | 2009-11-16 15:35:59 +0100 | [diff] [blame] | 1770 | #endif |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1771 | |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1772 | /* if we have no master control, let's create it */ |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 1773 | if (!spec->no_analog && |
| 1774 | !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1775 | unsigned int vmaster_tlv[4]; |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1776 | snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid, |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1777 | HDA_OUTPUT, vmaster_tlv); |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1778 | err = snd_hda_add_vmaster(codec, "Master Playback Volume", |
Takashi Iwai | 9322ca5 | 2012-02-03 14:28:01 +0100 | [diff] [blame] | 1779 | vmaster_tlv, alc_slave_pfxs, |
| 1780 | "Playback Volume"); |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1781 | if (err < 0) |
| 1782 | return err; |
| 1783 | } |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 1784 | if (!spec->no_analog && |
| 1785 | !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) { |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 1786 | err = __snd_hda_add_vmaster(codec, "Master Playback Switch", |
| 1787 | NULL, alc_slave_pfxs, |
| 1788 | "Playback Switch", |
Takashi Iwai | d2f344b | 2012-03-12 16:59:58 +0100 | [diff] [blame] | 1789 | true, &spec->vmaster_mute.sw_kctl); |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1790 | if (err < 0) |
| 1791 | return err; |
| 1792 | } |
| 1793 | |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 1794 | /* assign Capture Source enums to NID */ |
Takashi Iwai | fbe618f | 2010-06-11 11:24:58 +0200 | [diff] [blame] | 1795 | if (spec->capsrc_nids || spec->adc_nids) { |
| 1796 | kctl = snd_hda_find_mixer_ctl(codec, "Capture Source"); |
| 1797 | if (!kctl) |
| 1798 | kctl = snd_hda_find_mixer_ctl(codec, "Input Source"); |
| 1799 | for (i = 0; kctl && i < kctl->count; i++) { |
Takashi Iwai | 6107159 | 2011-11-23 07:52:15 +0100 | [diff] [blame] | 1800 | err = snd_hda_add_nid(codec, kctl, i, |
| 1801 | get_capsrc(spec, i)); |
Takashi Iwai | fbe618f | 2010-06-11 11:24:58 +0200 | [diff] [blame] | 1802 | if (err < 0) |
| 1803 | return err; |
| 1804 | } |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 1805 | } |
Takashi Iwai | 60a6a84 | 2011-07-27 14:01:24 +0200 | [diff] [blame] | 1806 | if (spec->cap_mixer && spec->adc_nids) { |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 1807 | const char *kname = kctl ? kctl->id.name : NULL; |
| 1808 | for (knew = spec->cap_mixer; knew->name; knew++) { |
| 1809 | if (kname && strcmp(knew->name, kname) == 0) |
| 1810 | continue; |
| 1811 | kctl = snd_hda_find_mixer_ctl(codec, knew->name); |
| 1812 | for (i = 0; kctl && i < kctl->count; i++) { |
| 1813 | err = snd_hda_add_nid(codec, kctl, i, |
| 1814 | spec->adc_nids[i]); |
| 1815 | if (err < 0) |
| 1816 | return err; |
| 1817 | } |
| 1818 | } |
| 1819 | } |
| 1820 | |
| 1821 | /* other nid->control mapping */ |
| 1822 | for (i = 0; i < spec->num_mixers; i++) { |
| 1823 | for (knew = spec->mixers[i]; knew->name; knew++) { |
| 1824 | if (knew->iface != NID_MAPPING) |
| 1825 | continue; |
| 1826 | kctl = snd_hda_find_mixer_ctl(codec, knew->name); |
| 1827 | if (kctl == NULL) |
| 1828 | continue; |
| 1829 | u = knew->subdevice; |
| 1830 | for (j = 0; j < 4; j++, u >>= 8) { |
| 1831 | nid = u & 0x3f; |
| 1832 | if (nid == 0) |
| 1833 | continue; |
| 1834 | switch (u & 0xc0) { |
| 1835 | case SUBDEV_SPEAKER_: |
| 1836 | nid = spec->autocfg.speaker_pins[nid]; |
| 1837 | break; |
| 1838 | case SUBDEV_LINE_: |
| 1839 | nid = spec->autocfg.line_out_pins[nid]; |
| 1840 | break; |
| 1841 | case SUBDEV_HP_: |
| 1842 | nid = spec->autocfg.hp_pins[nid]; |
| 1843 | break; |
| 1844 | default: |
| 1845 | continue; |
| 1846 | } |
| 1847 | err = snd_hda_add_nid(codec, kctl, 0, nid); |
| 1848 | if (err < 0) |
| 1849 | return err; |
| 1850 | } |
| 1851 | u = knew->private_value; |
| 1852 | for (j = 0; j < 4; j++, u >>= 8) { |
| 1853 | nid = u & 0xff; |
| 1854 | if (nid == 0) |
| 1855 | continue; |
| 1856 | err = snd_hda_add_nid(codec, kctl, 0, nid); |
| 1857 | if (err < 0) |
| 1858 | return err; |
| 1859 | } |
| 1860 | } |
| 1861 | } |
Takashi Iwai | bae84e7 | 2010-03-22 08:30:20 +0100 | [diff] [blame] | 1862 | |
| 1863 | alc_free_kctls(codec); /* no longer needed */ |
| 1864 | |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 1865 | return 0; |
| 1866 | } |
| 1867 | |
| 1868 | static int alc_build_controls(struct hda_codec *codec) |
| 1869 | { |
| 1870 | struct alc_spec *spec = codec->spec; |
| 1871 | int err = __alc_build_controls(codec); |
Takashi Iwai | 01a61e1 | 2011-10-28 00:03:22 +0200 | [diff] [blame] | 1872 | if (err < 0) |
| 1873 | return err; |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 1874 | err = snd_hda_jack_add_kctls(codec, &spec->autocfg); |
| 1875 | if (err < 0) |
| 1876 | return err; |
| 1877 | alc_apply_fixup(codec, ALC_FIXUP_ACT_BUILD); |
| 1878 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1879 | } |
| 1880 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1881 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1882 | /* |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 1883 | * Common callbacks |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1884 | */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1885 | |
Takashi Iwai | 584c0c4 | 2011-03-10 12:51:11 +0100 | [diff] [blame] | 1886 | static void alc_init_special_input_src(struct hda_codec *codec); |
Takashi Iwai | 070cff4 | 2012-02-21 12:54:17 +0100 | [diff] [blame] | 1887 | static void alc_auto_init_std(struct hda_codec *codec); |
Takashi Iwai | 584c0c4 | 2011-03-10 12:51:11 +0100 | [diff] [blame] | 1888 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1889 | static int alc_init(struct hda_codec *codec) |
| 1890 | { |
| 1891 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1892 | |
Takashi Iwai | 546bb67 | 2012-03-07 08:37:19 +0100 | [diff] [blame] | 1893 | if (spec->init_hook) |
| 1894 | spec->init_hook(codec); |
Kailang Yang | 526af6e | 2012-03-07 08:25:20 +0100 | [diff] [blame] | 1895 | |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 1896 | alc_fix_pll(codec); |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1897 | alc_auto_init_amp(codec, spec->init_amp); |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 1898 | |
Takashi Iwai | 584c0c4 | 2011-03-10 12:51:11 +0100 | [diff] [blame] | 1899 | alc_init_special_input_src(codec); |
Takashi Iwai | 070cff4 | 2012-02-21 12:54:17 +0100 | [diff] [blame] | 1900 | alc_auto_init_std(codec); |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 1901 | |
Takashi Iwai | 5870112 | 2011-01-13 15:41:45 +0100 | [diff] [blame] | 1902 | alc_apply_fixup(codec, ALC_FIXUP_ACT_INIT); |
| 1903 | |
Takashi Iwai | 01a61e1 | 2011-10-28 00:03:22 +0200 | [diff] [blame] | 1904 | snd_hda_jack_report_sync(codec); |
| 1905 | |
Takashi Iwai | 9e5341b | 2010-09-21 09:57:06 +0200 | [diff] [blame] | 1906 | hda_call_check_power_status(codec, 0x01); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1907 | return 0; |
| 1908 | } |
| 1909 | |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 1910 | static void alc_unsol_event(struct hda_codec *codec, unsigned int res) |
| 1911 | { |
| 1912 | struct alc_spec *spec = codec->spec; |
| 1913 | |
| 1914 | if (spec->unsol_event) |
| 1915 | spec->unsol_event(codec, res); |
| 1916 | } |
| 1917 | |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 1918 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 1919 | static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid) |
| 1920 | { |
| 1921 | struct alc_spec *spec = codec->spec; |
| 1922 | return snd_hda_check_amp_list_power(codec, &spec->loopback, nid); |
| 1923 | } |
| 1924 | #endif |
| 1925 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1926 | /* |
| 1927 | * Analog playback callbacks |
| 1928 | */ |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1929 | static int alc_playback_pcm_open(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1930 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1931 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1932 | { |
| 1933 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 9a08160 | 2008-02-12 18:37:26 +0100 | [diff] [blame] | 1934 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, |
| 1935 | hinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1936 | } |
| 1937 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1938 | static int alc_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1939 | struct hda_codec *codec, |
| 1940 | unsigned int stream_tag, |
| 1941 | unsigned int format, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1942 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1943 | { |
| 1944 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 1945 | return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, |
| 1946 | stream_tag, format, substream); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1947 | } |
| 1948 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1949 | static int alc_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1950 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1951 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1952 | { |
| 1953 | struct alc_spec *spec = codec->spec; |
| 1954 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); |
| 1955 | } |
| 1956 | |
| 1957 | /* |
| 1958 | * Digital out |
| 1959 | */ |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1960 | static int alc_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1961 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1962 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1963 | { |
| 1964 | struct alc_spec *spec = codec->spec; |
| 1965 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); |
| 1966 | } |
| 1967 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1968 | static int alc_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
Takashi Iwai | 6b97eb4 | 2007-04-05 14:51:48 +0200 | [diff] [blame] | 1969 | struct hda_codec *codec, |
| 1970 | unsigned int stream_tag, |
| 1971 | unsigned int format, |
| 1972 | struct snd_pcm_substream *substream) |
| 1973 | { |
| 1974 | struct alc_spec *spec = codec->spec; |
| 1975 | return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, |
| 1976 | stream_tag, format, substream); |
| 1977 | } |
| 1978 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1979 | static int alc_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
Takashi Iwai | 9b5f12e | 2009-02-13 11:47:37 +0100 | [diff] [blame] | 1980 | struct hda_codec *codec, |
| 1981 | struct snd_pcm_substream *substream) |
| 1982 | { |
| 1983 | struct alc_spec *spec = codec->spec; |
| 1984 | return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout); |
| 1985 | } |
| 1986 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1987 | static int alc_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1988 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1989 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1990 | { |
| 1991 | struct alc_spec *spec = codec->spec; |
| 1992 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); |
| 1993 | } |
| 1994 | |
| 1995 | /* |
| 1996 | * Analog capture |
| 1997 | */ |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1998 | static int alc_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1999 | struct hda_codec *codec, |
| 2000 | unsigned int stream_tag, |
| 2001 | unsigned int format, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2002 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2003 | { |
| 2004 | struct alc_spec *spec = codec->spec; |
| 2005 | |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2006 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1], |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2007 | stream_tag, 0, format); |
| 2008 | return 0; |
| 2009 | } |
| 2010 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2011 | static int alc_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2012 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2013 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2014 | { |
| 2015 | struct alc_spec *spec = codec->spec; |
| 2016 | |
Takashi Iwai | 888afa1 | 2008-03-18 09:57:50 +0100 | [diff] [blame] | 2017 | snd_hda_codec_cleanup_stream(codec, |
| 2018 | spec->adc_nids[substream->number + 1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2019 | return 0; |
| 2020 | } |
| 2021 | |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 2022 | /* analog capture with dynamic dual-adc changes */ |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2023 | static int dyn_adc_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 2024 | struct hda_codec *codec, |
| 2025 | unsigned int stream_tag, |
| 2026 | unsigned int format, |
| 2027 | struct snd_pcm_substream *substream) |
| 2028 | { |
| 2029 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2030 | spec->cur_adc = spec->adc_nids[spec->dyn_adc_idx[spec->cur_mux[0]]]; |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 2031 | spec->cur_adc_stream_tag = stream_tag; |
| 2032 | spec->cur_adc_format = format; |
| 2033 | snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format); |
| 2034 | return 0; |
| 2035 | } |
| 2036 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2037 | static int dyn_adc_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 2038 | struct hda_codec *codec, |
| 2039 | struct snd_pcm_substream *substream) |
| 2040 | { |
| 2041 | struct alc_spec *spec = codec->spec; |
| 2042 | snd_hda_codec_cleanup_stream(codec, spec->cur_adc); |
| 2043 | spec->cur_adc = 0; |
| 2044 | return 0; |
| 2045 | } |
| 2046 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2047 | static const struct hda_pcm_stream dyn_adc_pcm_analog_capture = { |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 2048 | .substreams = 1, |
| 2049 | .channels_min = 2, |
| 2050 | .channels_max = 2, |
| 2051 | .nid = 0, /* fill later */ |
| 2052 | .ops = { |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2053 | .prepare = dyn_adc_capture_pcm_prepare, |
| 2054 | .cleanup = dyn_adc_capture_pcm_cleanup |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 2055 | }, |
| 2056 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2057 | |
| 2058 | /* |
| 2059 | */ |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2060 | static const struct hda_pcm_stream alc_pcm_analog_playback = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2061 | .substreams = 1, |
| 2062 | .channels_min = 2, |
| 2063 | .channels_max = 8, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2064 | /* NID is set in alc_build_pcms */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2065 | .ops = { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2066 | .open = alc_playback_pcm_open, |
| 2067 | .prepare = alc_playback_pcm_prepare, |
| 2068 | .cleanup = alc_playback_pcm_cleanup |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2069 | }, |
| 2070 | }; |
| 2071 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2072 | static const struct hda_pcm_stream alc_pcm_analog_capture = { |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2073 | .substreams = 1, |
| 2074 | .channels_min = 2, |
| 2075 | .channels_max = 2, |
| 2076 | /* NID is set in alc_build_pcms */ |
| 2077 | }; |
| 2078 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2079 | static const struct hda_pcm_stream alc_pcm_analog_alt_playback = { |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2080 | .substreams = 1, |
| 2081 | .channels_min = 2, |
| 2082 | .channels_max = 2, |
| 2083 | /* NID is set in alc_build_pcms */ |
| 2084 | }; |
| 2085 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2086 | static const struct hda_pcm_stream alc_pcm_analog_alt_capture = { |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2087 | .substreams = 2, /* can be overridden */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2088 | .channels_min = 2, |
| 2089 | .channels_max = 2, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2090 | /* NID is set in alc_build_pcms */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2091 | .ops = { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2092 | .prepare = alc_alt_capture_pcm_prepare, |
| 2093 | .cleanup = alc_alt_capture_pcm_cleanup |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2094 | }, |
| 2095 | }; |
| 2096 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2097 | static const struct hda_pcm_stream alc_pcm_digital_playback = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2098 | .substreams = 1, |
| 2099 | .channels_min = 2, |
| 2100 | .channels_max = 2, |
| 2101 | /* NID is set in alc_build_pcms */ |
| 2102 | .ops = { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2103 | .open = alc_dig_playback_pcm_open, |
| 2104 | .close = alc_dig_playback_pcm_close, |
| 2105 | .prepare = alc_dig_playback_pcm_prepare, |
| 2106 | .cleanup = alc_dig_playback_pcm_cleanup |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2107 | }, |
| 2108 | }; |
| 2109 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2110 | static const struct hda_pcm_stream alc_pcm_digital_capture = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2111 | .substreams = 1, |
| 2112 | .channels_min = 2, |
| 2113 | .channels_max = 2, |
| 2114 | /* NID is set in alc_build_pcms */ |
| 2115 | }; |
| 2116 | |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 2117 | /* Used by alc_build_pcms to flag that a PCM has no playback stream */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 2118 | static const struct hda_pcm_stream alc_pcm_null_stream = { |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 2119 | .substreams = 0, |
| 2120 | .channels_min = 0, |
| 2121 | .channels_max = 0, |
| 2122 | }; |
| 2123 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2124 | static int alc_build_pcms(struct hda_codec *codec) |
| 2125 | { |
| 2126 | struct alc_spec *spec = codec->spec; |
| 2127 | struct hda_pcm *info = spec->pcm_rec; |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2128 | const struct hda_pcm_stream *p; |
Takashi Iwai | 1fa1757 | 2011-11-02 21:30:51 +0100 | [diff] [blame] | 2129 | bool have_multi_adcs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2130 | int i; |
| 2131 | |
| 2132 | codec->num_pcms = 1; |
| 2133 | codec->pcm_info = info; |
| 2134 | |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 2135 | if (spec->no_analog) |
| 2136 | goto skip_analog; |
| 2137 | |
Takashi Iwai | 812a2cc | 2009-05-16 10:00:49 +0200 | [diff] [blame] | 2138 | snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog), |
| 2139 | "%s Analog", codec->chip_name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2140 | info->name = spec->stream_name_analog; |
Kailang Yang | 274693f | 2009-12-03 10:07:50 +0100 | [diff] [blame] | 2141 | |
Takashi Iwai | eedec3d | 2012-02-06 10:24:04 +0100 | [diff] [blame] | 2142 | if (spec->multiout.num_dacs > 0) { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2143 | p = spec->stream_analog_playback; |
| 2144 | if (!p) |
| 2145 | p = &alc_pcm_analog_playback; |
| 2146 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *p; |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 2147 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0]; |
| 2148 | } |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2149 | if (spec->adc_nids) { |
| 2150 | p = spec->stream_analog_capture; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2151 | if (!p) { |
| 2152 | if (spec->dyn_adc_switch) |
| 2153 | p = &dyn_adc_pcm_analog_capture; |
| 2154 | else |
| 2155 | p = &alc_pcm_analog_capture; |
| 2156 | } |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2157 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *p; |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 2158 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; |
| 2159 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2160 | |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 2161 | if (spec->channel_mode) { |
| 2162 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0; |
| 2163 | for (i = 0; i < spec->num_channel_mode; i++) { |
| 2164 | if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) { |
| 2165 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels; |
| 2166 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2167 | } |
| 2168 | } |
| 2169 | |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 2170 | skip_analog: |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2171 | /* SPDIF for stream index #1 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2172 | if (spec->multiout.dig_out_nid || spec->dig_in_nid) { |
Takashi Iwai | 812a2cc | 2009-05-16 10:00:49 +0200 | [diff] [blame] | 2173 | snprintf(spec->stream_name_digital, |
| 2174 | sizeof(spec->stream_name_digital), |
| 2175 | "%s Digital", codec->chip_name); |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2176 | codec->num_pcms = 2; |
Wu Fengguang | b25c9da | 2009-02-06 15:02:27 +0800 | [diff] [blame] | 2177 | codec->slave_dig_outs = spec->multiout.slave_dig_outs; |
Takashi Iwai | c06134d | 2006-10-11 18:49:13 +0200 | [diff] [blame] | 2178 | info = spec->pcm_rec + 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2179 | info->name = spec->stream_name_digital; |
Takashi Iwai | 8c44198 | 2009-01-20 18:30:20 +0100 | [diff] [blame] | 2180 | if (spec->dig_out_type) |
| 2181 | info->pcm_type = spec->dig_out_type; |
| 2182 | else |
| 2183 | info->pcm_type = HDA_PCM_TYPE_SPDIF; |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2184 | if (spec->multiout.dig_out_nid) { |
| 2185 | p = spec->stream_digital_playback; |
| 2186 | if (!p) |
| 2187 | p = &alc_pcm_digital_playback; |
| 2188 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2189 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; |
| 2190 | } |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2191 | if (spec->dig_in_nid) { |
| 2192 | p = spec->stream_digital_capture; |
| 2193 | if (!p) |
| 2194 | p = &alc_pcm_digital_capture; |
| 2195 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2196 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; |
| 2197 | } |
Takashi Iwai | 963f803 | 2008-08-11 10:04:40 +0200 | [diff] [blame] | 2198 | /* FIXME: do we need this for all Realtek codec models? */ |
| 2199 | codec->spdif_status_reset = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2200 | } |
| 2201 | |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 2202 | if (spec->no_analog) |
| 2203 | return 0; |
| 2204 | |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2205 | /* If the use of more than one ADC is requested for the current |
| 2206 | * model, configure a second analog capture-only PCM. |
| 2207 | */ |
Takashi Iwai | 1fa1757 | 2011-11-02 21:30:51 +0100 | [diff] [blame] | 2208 | have_multi_adcs = (spec->num_adc_nids > 1) && |
| 2209 | !spec->dyn_adc_switch && !spec->auto_mic && |
| 2210 | (!spec->input_mux || spec->input_mux->num_items > 1); |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2211 | /* Additional Analaog capture for index #2 */ |
Takashi Iwai | 1fa1757 | 2011-11-02 21:30:51 +0100 | [diff] [blame] | 2212 | if (spec->alt_dac_nid || have_multi_adcs) { |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2213 | codec->num_pcms = 3; |
Takashi Iwai | c06134d | 2006-10-11 18:49:13 +0200 | [diff] [blame] | 2214 | info = spec->pcm_rec + 2; |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2215 | info->name = spec->stream_name_analog; |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2216 | if (spec->alt_dac_nid) { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2217 | p = spec->stream_analog_alt_playback; |
| 2218 | if (!p) |
| 2219 | p = &alc_pcm_analog_alt_playback; |
| 2220 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *p; |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2221 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = |
| 2222 | spec->alt_dac_nid; |
| 2223 | } else { |
| 2224 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = |
| 2225 | alc_pcm_null_stream; |
| 2226 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0; |
| 2227 | } |
Takashi Iwai | 1fa1757 | 2011-11-02 21:30:51 +0100 | [diff] [blame] | 2228 | if (have_multi_adcs) { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2229 | p = spec->stream_analog_alt_capture; |
| 2230 | if (!p) |
| 2231 | p = &alc_pcm_analog_alt_capture; |
| 2232 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *p; |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2233 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = |
| 2234 | spec->adc_nids[1]; |
| 2235 | info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = |
| 2236 | spec->num_adc_nids - 1; |
| 2237 | } else { |
| 2238 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = |
| 2239 | alc_pcm_null_stream; |
| 2240 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0; |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2241 | } |
| 2242 | } |
| 2243 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2244 | return 0; |
| 2245 | } |
| 2246 | |
Takashi Iwai | a4e09aa | 2009-12-27 11:22:24 +0100 | [diff] [blame] | 2247 | static inline void alc_shutup(struct hda_codec *codec) |
| 2248 | { |
Takashi Iwai | 1c716153 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 2249 | struct alc_spec *spec = codec->spec; |
| 2250 | |
| 2251 | if (spec && spec->shutup) |
| 2252 | spec->shutup(codec); |
Takashi Iwai | a4e09aa | 2009-12-27 11:22:24 +0100 | [diff] [blame] | 2253 | snd_hda_shutup_pins(codec); |
| 2254 | } |
| 2255 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 2256 | static void alc_free_kctls(struct hda_codec *codec) |
| 2257 | { |
| 2258 | struct alc_spec *spec = codec->spec; |
| 2259 | |
| 2260 | if (spec->kctls.list) { |
| 2261 | struct snd_kcontrol_new *kctl = spec->kctls.list; |
| 2262 | int i; |
| 2263 | for (i = 0; i < spec->kctls.used; i++) |
| 2264 | kfree(kctl[i].name); |
| 2265 | } |
| 2266 | snd_array_free(&spec->kctls); |
| 2267 | } |
| 2268 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2269 | static void alc_free_bind_ctls(struct hda_codec *codec) |
| 2270 | { |
| 2271 | struct alc_spec *spec = codec->spec; |
| 2272 | if (spec->bind_ctls.list) { |
| 2273 | struct hda_bind_ctls **ctl = spec->bind_ctls.list; |
| 2274 | int i; |
| 2275 | for (i = 0; i < spec->bind_ctls.used; i++) |
| 2276 | kfree(ctl[i]); |
| 2277 | } |
| 2278 | snd_array_free(&spec->bind_ctls); |
| 2279 | } |
| 2280 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2281 | static void alc_free(struct hda_codec *codec) |
| 2282 | { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2283 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2284 | |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2285 | if (!spec) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2286 | return; |
| 2287 | |
Takashi Iwai | a4e09aa | 2009-12-27 11:22:24 +0100 | [diff] [blame] | 2288 | alc_shutup(codec); |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 2289 | alc_free_kctls(codec); |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2290 | alc_free_bind_ctls(codec); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2291 | kfree(spec); |
Kusanagi Kouichi | 680cd53 | 2009-02-05 00:00:58 +0900 | [diff] [blame] | 2292 | snd_hda_detach_beep_device(codec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2293 | } |
| 2294 | |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 2295 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 2296 | static void alc_power_eapd(struct hda_codec *codec) |
| 2297 | { |
Takashi Iwai | 691f1fc | 2011-04-07 10:31:43 +0200 | [diff] [blame] | 2298 | alc_auto_setup_eapd(codec, false); |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 2299 | } |
| 2300 | |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 2301 | static int alc_suspend(struct hda_codec *codec, pm_message_t state) |
| 2302 | { |
| 2303 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | a4e09aa | 2009-12-27 11:22:24 +0100 | [diff] [blame] | 2304 | alc_shutup(codec); |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 2305 | if (spec && spec->power_hook) |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 2306 | spec->power_hook(codec); |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 2307 | return 0; |
| 2308 | } |
| 2309 | #endif |
| 2310 | |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 2311 | #ifdef CONFIG_PM |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2312 | static int alc_resume(struct hda_codec *codec) |
| 2313 | { |
Takashi Iwai | 1c716153 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 2314 | msleep(150); /* to avoid pop noise */ |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2315 | codec->patch_ops.init(codec); |
| 2316 | snd_hda_codec_resume_amp(codec); |
| 2317 | snd_hda_codec_resume_cache(codec); |
Takashi Iwai | 9e5341b | 2010-09-21 09:57:06 +0200 | [diff] [blame] | 2318 | hda_call_check_power_status(codec, 0x01); |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2319 | return 0; |
| 2320 | } |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2321 | #endif |
| 2322 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2323 | /* |
| 2324 | */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 2325 | static const struct hda_codec_ops alc_patch_ops = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2326 | .build_controls = alc_build_controls, |
| 2327 | .build_pcms = alc_build_pcms, |
| 2328 | .init = alc_init, |
| 2329 | .free = alc_free, |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 2330 | .unsol_event = alc_unsol_event, |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 2331 | #ifdef CONFIG_PM |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2332 | .resume = alc_resume, |
| 2333 | #endif |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 2334 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 2335 | .suspend = alc_suspend, |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 2336 | .check_power_status = alc_check_power_status, |
| 2337 | #endif |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 2338 | .reboot_notify = alc_shutup, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2339 | }; |
| 2340 | |
Kailang Yang | c027ddc | 2010-03-19 11:33:06 +0100 | [diff] [blame] | 2341 | /* replace the codec chip_name with the given string */ |
| 2342 | static int alc_codec_rename(struct hda_codec *codec, const char *name) |
| 2343 | { |
| 2344 | kfree(codec->chip_name); |
| 2345 | codec->chip_name = kstrdup(name, GFP_KERNEL); |
| 2346 | if (!codec->chip_name) { |
| 2347 | alc_free(codec); |
| 2348 | return -ENOMEM; |
| 2349 | } |
| 2350 | return 0; |
| 2351 | } |
| 2352 | |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 2353 | /* |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 2354 | * Rename codecs appropriately from COEF value |
| 2355 | */ |
| 2356 | struct alc_codec_rename_table { |
| 2357 | unsigned int vendor_id; |
| 2358 | unsigned short coef_mask; |
| 2359 | unsigned short coef_bits; |
| 2360 | const char *name; |
| 2361 | }; |
| 2362 | |
| 2363 | static struct alc_codec_rename_table rename_tbl[] = { |
| 2364 | { 0x10ec0269, 0xfff0, 0x3010, "ALC277" }, |
| 2365 | { 0x10ec0269, 0xf0f0, 0x2010, "ALC259" }, |
| 2366 | { 0x10ec0269, 0xf0f0, 0x3010, "ALC258" }, |
| 2367 | { 0x10ec0269, 0x00f0, 0x0010, "ALC269VB" }, |
| 2368 | { 0x10ec0269, 0xffff, 0xa023, "ALC259" }, |
| 2369 | { 0x10ec0269, 0xffff, 0x6023, "ALC281X" }, |
| 2370 | { 0x10ec0269, 0x00f0, 0x0020, "ALC269VC" }, |
| 2371 | { 0x10ec0887, 0x00f0, 0x0030, "ALC887-VD" }, |
| 2372 | { 0x10ec0888, 0x00f0, 0x0030, "ALC888-VD" }, |
| 2373 | { 0x10ec0888, 0xf0f0, 0x3020, "ALC886" }, |
| 2374 | { 0x10ec0899, 0x2000, 0x2000, "ALC899" }, |
| 2375 | { 0x10ec0892, 0xffff, 0x8020, "ALC661" }, |
| 2376 | { 0x10ec0892, 0xffff, 0x8011, "ALC661" }, |
| 2377 | { 0x10ec0892, 0xffff, 0x4011, "ALC656" }, |
| 2378 | { } /* terminator */ |
| 2379 | }; |
| 2380 | |
| 2381 | static int alc_codec_rename_from_preset(struct hda_codec *codec) |
| 2382 | { |
| 2383 | const struct alc_codec_rename_table *p; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 2384 | |
| 2385 | for (p = rename_tbl; p->vendor_id; p++) { |
| 2386 | if (p->vendor_id != codec->vendor_id) |
| 2387 | continue; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 2388 | if ((alc_get_coef0(codec) & p->coef_mask) == p->coef_bits) |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 2389 | return alc_codec_rename(codec, p->name); |
| 2390 | } |
| 2391 | return 0; |
| 2392 | } |
| 2393 | |
| 2394 | /* |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2395 | * Automatic parse of I/O pins from the BIOS configuration |
| 2396 | */ |
| 2397 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2398 | enum { |
| 2399 | ALC_CTL_WIDGET_VOL, |
| 2400 | ALC_CTL_WIDGET_MUTE, |
| 2401 | ALC_CTL_BIND_MUTE, |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2402 | ALC_CTL_BIND_VOL, |
| 2403 | ALC_CTL_BIND_SW, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2404 | }; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 2405 | static const struct snd_kcontrol_new alc_control_templates[] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2406 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), |
| 2407 | HDA_CODEC_MUTE(NULL, 0, 0, 0), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 2408 | HDA_BIND_MUTE(NULL, 0, 0, 0), |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2409 | HDA_BIND_VOL(NULL, 0), |
| 2410 | HDA_BIND_SW(NULL, 0), |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2411 | }; |
| 2412 | |
| 2413 | /* add dynamic controls */ |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2414 | static int add_control(struct alc_spec *spec, int type, const char *name, |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2415 | int cidx, unsigned long val) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2416 | { |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2417 | struct snd_kcontrol_new *knew; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2418 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 2419 | knew = alc_kcontrol_new(spec); |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 2420 | if (!knew) |
| 2421 | return -ENOMEM; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 2422 | *knew = alc_control_templates[type]; |
Paulo Marques | 543537b | 2005-06-23 00:09:02 -0700 | [diff] [blame] | 2423 | knew->name = kstrdup(name, GFP_KERNEL); |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2424 | if (!knew->name) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2425 | return -ENOMEM; |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2426 | knew->index = cidx; |
Jaroslav Kysela | 4d02d1b | 2009-11-12 10:15:48 +0100 | [diff] [blame] | 2427 | if (get_amp_nid_(val)) |
Jaroslav Kysela | 5e26dfd | 2009-12-10 13:57:01 +0100 | [diff] [blame] | 2428 | knew->subdevice = HDA_SUBDEV_AMP_FLAG; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2429 | knew->private_value = val; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2430 | return 0; |
| 2431 | } |
| 2432 | |
Takashi Iwai | 0afe5f8 | 2009-10-02 09:20:00 +0200 | [diff] [blame] | 2433 | static int add_control_with_pfx(struct alc_spec *spec, int type, |
| 2434 | const char *pfx, const char *dir, |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2435 | const char *sfx, int cidx, unsigned long val) |
Takashi Iwai | 0afe5f8 | 2009-10-02 09:20:00 +0200 | [diff] [blame] | 2436 | { |
| 2437 | char name[32]; |
| 2438 | snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx); |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2439 | return add_control(spec, type, name, cidx, val); |
Takashi Iwai | 0afe5f8 | 2009-10-02 09:20:00 +0200 | [diff] [blame] | 2440 | } |
| 2441 | |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2442 | #define add_pb_vol_ctrl(spec, type, pfx, val) \ |
| 2443 | add_control_with_pfx(spec, type, pfx, "Playback", "Volume", 0, val) |
| 2444 | #define add_pb_sw_ctrl(spec, type, pfx, val) \ |
| 2445 | add_control_with_pfx(spec, type, pfx, "Playback", "Switch", 0, val) |
| 2446 | #define __add_pb_vol_ctrl(spec, type, pfx, cidx, val) \ |
| 2447 | add_control_with_pfx(spec, type, pfx, "Playback", "Volume", cidx, val) |
| 2448 | #define __add_pb_sw_ctrl(spec, type, pfx, cidx, val) \ |
| 2449 | add_control_with_pfx(spec, type, pfx, "Playback", "Switch", cidx, val) |
Takashi Iwai | 0afe5f8 | 2009-10-02 09:20:00 +0200 | [diff] [blame] | 2450 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2451 | static const char * const channel_name[4] = { |
| 2452 | "Front", "Surround", "CLFE", "Side" |
| 2453 | }; |
| 2454 | |
Takashi Iwai | 6843ca1 | 2011-06-24 11:03:58 +0200 | [diff] [blame] | 2455 | static const char *alc_get_line_out_pfx(struct alc_spec *spec, int ch, |
| 2456 | bool can_be_master, int *index) |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2457 | { |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 2458 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2459 | |
Takashi Iwai | 6843ca1 | 2011-06-24 11:03:58 +0200 | [diff] [blame] | 2460 | *index = 0; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 2461 | if (cfg->line_outs == 1 && !spec->multi_ios && |
| 2462 | !cfg->hp_outs && !cfg->speaker_outs && can_be_master) |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2463 | return "Master"; |
| 2464 | |
| 2465 | switch (cfg->line_out_type) { |
| 2466 | case AUTO_PIN_SPEAKER_OUT: |
David Henningsson | ebbeb3d | 2011-03-04 14:08:30 +0100 | [diff] [blame] | 2467 | if (cfg->line_outs == 1) |
| 2468 | return "Speaker"; |
Takashi Iwai | fbabc24 | 2011-12-07 17:14:20 +0100 | [diff] [blame] | 2469 | if (cfg->line_outs == 2) |
| 2470 | return ch ? "Bass Speaker" : "Speaker"; |
David Henningsson | ebbeb3d | 2011-03-04 14:08:30 +0100 | [diff] [blame] | 2471 | break; |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2472 | case AUTO_PIN_HP_OUT: |
Takashi Iwai | 6843ca1 | 2011-06-24 11:03:58 +0200 | [diff] [blame] | 2473 | /* for multi-io case, only the primary out */ |
| 2474 | if (ch && spec->multi_ios) |
| 2475 | break; |
| 2476 | *index = ch; |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2477 | return "Headphone"; |
| 2478 | default: |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 2479 | if (cfg->line_outs == 1 && !spec->multi_ios) |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2480 | return "PCM"; |
| 2481 | break; |
| 2482 | } |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2483 | if (snd_BUG_ON(ch >= ARRAY_SIZE(channel_name))) |
| 2484 | return "PCM"; |
| 2485 | |
| 2486 | return channel_name[ch]; |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2487 | } |
| 2488 | |
Takashi Iwai | 164f73e | 2012-02-21 11:27:09 +0100 | [diff] [blame] | 2489 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 2490 | /* add the powersave loopback-list entry */ |
| 2491 | static void add_loopback_list(struct alc_spec *spec, hda_nid_t mix, int idx) |
| 2492 | { |
| 2493 | struct hda_amp_list *list; |
| 2494 | |
| 2495 | if (spec->num_loopbacks >= ARRAY_SIZE(spec->loopback_list) - 1) |
| 2496 | return; |
| 2497 | list = spec->loopback_list + spec->num_loopbacks; |
| 2498 | list->nid = mix; |
| 2499 | list->dir = HDA_INPUT; |
| 2500 | list->idx = idx; |
| 2501 | spec->num_loopbacks++; |
| 2502 | spec->loopback.amplist = spec->loopback_list; |
| 2503 | } |
| 2504 | #else |
| 2505 | #define add_loopback_list(spec, mix, idx) /* NOP */ |
| 2506 | #endif |
| 2507 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2508 | /* create input playback/capture controls for the given pin */ |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2509 | static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2510 | const char *ctlname, int ctlidx, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2511 | int idx, hda_nid_t mix_nid) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2512 | { |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2513 | int err; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2514 | |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2515 | err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname, ctlidx, |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2516 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); |
| 2517 | if (err < 0) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2518 | return err; |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2519 | err = __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname, ctlidx, |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2520 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); |
| 2521 | if (err < 0) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2522 | return err; |
Takashi Iwai | 164f73e | 2012-02-21 11:27:09 +0100 | [diff] [blame] | 2523 | add_loopback_list(spec, mix_nid, idx); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2524 | return 0; |
| 2525 | } |
| 2526 | |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2527 | static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2528 | { |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2529 | unsigned int pincap = snd_hda_query_pin_caps(codec, nid); |
| 2530 | return (pincap & AC_PINCAP_IN) != 0; |
| 2531 | } |
| 2532 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 2533 | /* Parse the codec tree and retrieve ADCs and corresponding capsrc MUXs */ |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2534 | static int alc_auto_fill_adc_caps(struct hda_codec *codec) |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2535 | { |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2536 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2537 | hda_nid_t nid; |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2538 | hda_nid_t *adc_nids = spec->private_adc_nids; |
| 2539 | hda_nid_t *cap_nids = spec->private_capsrc_nids; |
| 2540 | int max_nums = ARRAY_SIZE(spec->private_adc_nids); |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2541 | int i, nums = 0; |
| 2542 | |
| 2543 | nid = codec->start_nid; |
| 2544 | for (i = 0; i < codec->num_nodes; i++, nid++) { |
| 2545 | hda_nid_t src; |
| 2546 | const hda_nid_t *list; |
| 2547 | unsigned int caps = get_wcaps(codec, nid); |
| 2548 | int type = get_wcaps_type(caps); |
| 2549 | |
| 2550 | if (type != AC_WID_AUD_IN || (caps & AC_WCAP_DIGITAL)) |
| 2551 | continue; |
| 2552 | adc_nids[nums] = nid; |
| 2553 | cap_nids[nums] = nid; |
| 2554 | src = nid; |
| 2555 | for (;;) { |
| 2556 | int n; |
| 2557 | type = get_wcaps_type(get_wcaps(codec, src)); |
| 2558 | if (type == AC_WID_PIN) |
| 2559 | break; |
| 2560 | if (type == AC_WID_AUD_SEL) { |
| 2561 | cap_nids[nums] = src; |
| 2562 | break; |
| 2563 | } |
| 2564 | n = snd_hda_get_conn_list(codec, src, &list); |
| 2565 | if (n > 1) { |
| 2566 | cap_nids[nums] = src; |
| 2567 | break; |
| 2568 | } else if (n != 1) |
| 2569 | break; |
| 2570 | src = *list; |
| 2571 | } |
| 2572 | if (++nums >= max_nums) |
| 2573 | break; |
| 2574 | } |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2575 | spec->adc_nids = spec->private_adc_nids; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2576 | spec->capsrc_nids = spec->private_capsrc_nids; |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2577 | spec->num_adc_nids = nums; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2578 | return nums; |
| 2579 | } |
| 2580 | |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2581 | /* create playback/capture controls for input pins */ |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2582 | static int alc_auto_create_input_ctls(struct hda_codec *codec) |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2583 | { |
| 2584 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2585 | const struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2586 | hda_nid_t mixer = spec->mixer_nid; |
Herton Ronaldo Krzesinski | 61b9b9b | 2009-01-28 09:16:33 -0200 | [diff] [blame] | 2587 | struct hda_input_mux *imux = &spec->private_imux[0]; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2588 | int num_adcs; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2589 | int i, c, err, idx, type_idx = 0; |
David Henningsson | 5322bf2 | 2011-01-05 11:03:56 +0100 | [diff] [blame] | 2590 | const char *prev_label = NULL; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2591 | |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2592 | num_adcs = alc_auto_fill_adc_caps(codec); |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2593 | if (num_adcs < 0) |
| 2594 | return 0; |
| 2595 | |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2596 | for (i = 0; i < cfg->num_inputs; i++) { |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2597 | hda_nid_t pin; |
Takashi Iwai | 10a20af | 2010-09-09 16:28:02 +0200 | [diff] [blame] | 2598 | const char *label; |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2599 | |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2600 | pin = cfg->inputs[i].pin; |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2601 | if (!alc_is_input_pin(codec, pin)) |
| 2602 | continue; |
| 2603 | |
David Henningsson | 5322bf2 | 2011-01-05 11:03:56 +0100 | [diff] [blame] | 2604 | label = hda_get_autocfg_input_label(codec, cfg, i); |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 2605 | if (spec->shared_mic_hp && !strcmp(label, "Misc")) |
| 2606 | label = "Headphone Mic"; |
David Henningsson | 5322bf2 | 2011-01-05 11:03:56 +0100 | [diff] [blame] | 2607 | if (prev_label && !strcmp(label, prev_label)) |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2608 | type_idx++; |
| 2609 | else |
| 2610 | type_idx = 0; |
David Henningsson | 5322bf2 | 2011-01-05 11:03:56 +0100 | [diff] [blame] | 2611 | prev_label = label; |
| 2612 | |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2613 | if (mixer) { |
| 2614 | idx = get_connection_index(codec, mixer, pin); |
| 2615 | if (idx >= 0) { |
| 2616 | err = new_analog_input(spec, pin, |
Takashi Iwai | 10a20af | 2010-09-09 16:28:02 +0200 | [diff] [blame] | 2617 | label, type_idx, |
| 2618 | idx, mixer); |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2619 | if (err < 0) |
| 2620 | return err; |
| 2621 | } |
| 2622 | } |
| 2623 | |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2624 | for (c = 0; c < num_adcs; c++) { |
Takashi Iwai | 6107159 | 2011-11-23 07:52:15 +0100 | [diff] [blame] | 2625 | hda_nid_t cap = get_capsrc(spec, c); |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2626 | idx = get_connection_index(codec, cap, pin); |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2627 | if (idx >= 0) { |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2628 | spec->imux_pins[imux->num_items] = pin; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2629 | snd_hda_add_imux_item(imux, label, idx, NULL); |
| 2630 | break; |
| 2631 | } |
| 2632 | } |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2633 | } |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2634 | |
| 2635 | spec->num_mux_defs = 1; |
| 2636 | spec->input_mux = imux; |
| 2637 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2638 | return 0; |
| 2639 | } |
| 2640 | |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 2641 | /* create a shared input with the headphone out */ |
| 2642 | static int alc_auto_create_shared_input(struct hda_codec *codec) |
| 2643 | { |
| 2644 | struct alc_spec *spec = codec->spec; |
| 2645 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2646 | unsigned int defcfg; |
| 2647 | hda_nid_t nid; |
| 2648 | |
| 2649 | /* only one internal input pin? */ |
| 2650 | if (cfg->num_inputs != 1) |
| 2651 | return 0; |
| 2652 | defcfg = snd_hda_codec_get_pincfg(codec, cfg->inputs[0].pin); |
| 2653 | if (snd_hda_get_input_pin_attr(defcfg) != INPUT_PIN_ATTR_INT) |
| 2654 | return 0; |
| 2655 | |
| 2656 | if (cfg->hp_outs == 1 && cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) |
| 2657 | nid = cfg->hp_pins[0]; /* OK, we have a single HP-out */ |
| 2658 | else if (cfg->line_outs == 1 && cfg->line_out_type == AUTO_PIN_HP_OUT) |
| 2659 | nid = cfg->line_out_pins[0]; /* OK, we have a single line-out */ |
| 2660 | else |
| 2661 | return 0; /* both not available */ |
| 2662 | |
| 2663 | if (!(snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_IN)) |
| 2664 | return 0; /* no input */ |
| 2665 | |
| 2666 | cfg->inputs[1].pin = nid; |
| 2667 | cfg->inputs[1].type = AUTO_PIN_MIC; |
| 2668 | cfg->num_inputs = 2; |
| 2669 | spec->shared_mic_hp = 1; |
| 2670 | snd_printdd("realtek: Enable shared I/O jack on NID 0x%x\n", nid); |
| 2671 | return 0; |
| 2672 | } |
| 2673 | |
Takashi Iwai | f6c7e54 | 2008-02-12 18:32:23 +0100 | [diff] [blame] | 2674 | static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid, |
| 2675 | unsigned int pin_type) |
| 2676 | { |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 2677 | snd_hda_set_pin_ctl(codec, nid, pin_type); |
Takashi Iwai | f6c7e54 | 2008-02-12 18:32:23 +0100 | [diff] [blame] | 2678 | /* unmute pin */ |
Takashi Iwai | 44c0240 | 2011-07-08 15:14:19 +0200 | [diff] [blame] | 2679 | if (nid_has_mute(codec, nid, HDA_OUTPUT)) |
| 2680 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
Takashi Iwai | d260cdf | 2008-02-13 17:19:35 +0100 | [diff] [blame] | 2681 | AMP_OUT_UNMUTE); |
Takashi Iwai | f6c7e54 | 2008-02-12 18:32:23 +0100 | [diff] [blame] | 2682 | } |
| 2683 | |
Takashi Iwai | baba8ee | 2007-04-23 17:17:48 +0200 | [diff] [blame] | 2684 | static int get_pin_type(int line_out_type) |
| 2685 | { |
| 2686 | if (line_out_type == AUTO_PIN_HP_OUT) |
| 2687 | return PIN_HP; |
| 2688 | else |
| 2689 | return PIN_OUT; |
| 2690 | } |
| 2691 | |
Takashi Iwai | 0a7f532 | 2011-07-06 15:15:12 +0200 | [diff] [blame] | 2692 | static void alc_auto_init_analog_input(struct hda_codec *codec) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2693 | { |
| 2694 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2695 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2696 | int i; |
| 2697 | |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2698 | for (i = 0; i < cfg->num_inputs; i++) { |
| 2699 | hda_nid_t nid = cfg->inputs[i].pin; |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2700 | if (alc_is_input_pin(codec, nid)) { |
Takashi Iwai | 30ea098 | 2010-09-16 18:47:56 +0200 | [diff] [blame] | 2701 | alc_set_input_pin(codec, nid, cfg->inputs[i].type); |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 2702 | if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2703 | snd_hda_codec_write(codec, nid, 0, |
| 2704 | AC_VERB_SET_AMP_GAIN_MUTE, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2705 | AMP_OUT_MUTE); |
| 2706 | } |
| 2707 | } |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 2708 | |
| 2709 | /* mute all loopback inputs */ |
| 2710 | if (spec->mixer_nid) { |
| 2711 | int nums = snd_hda_get_conn_list(codec, spec->mixer_nid, NULL); |
| 2712 | for (i = 0; i < nums; i++) |
| 2713 | snd_hda_codec_write(codec, spec->mixer_nid, 0, |
| 2714 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 2715 | AMP_IN_MUTE(i)); |
| 2716 | } |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2717 | } |
| 2718 | |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2719 | /* convert from MIX nid to DAC */ |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2720 | static hda_nid_t alc_auto_mix_to_dac(struct hda_codec *codec, hda_nid_t nid) |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2721 | { |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2722 | hda_nid_t list[5]; |
Takashi Iwai | 1304ac8 | 2011-04-06 15:16:21 +0200 | [diff] [blame] | 2723 | int i, num; |
| 2724 | |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 2725 | if (get_wcaps_type(get_wcaps(codec, nid)) == AC_WID_AUD_OUT) |
| 2726 | return nid; |
Takashi Iwai | 1304ac8 | 2011-04-06 15:16:21 +0200 | [diff] [blame] | 2727 | num = snd_hda_get_connections(codec, nid, list, ARRAY_SIZE(list)); |
| 2728 | for (i = 0; i < num; i++) { |
| 2729 | if (get_wcaps_type(get_wcaps(codec, list[i])) == AC_WID_AUD_OUT) |
| 2730 | return list[i]; |
| 2731 | } |
| 2732 | return 0; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2733 | } |
| 2734 | |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2735 | /* go down to the selector widget before the mixer */ |
| 2736 | static hda_nid_t alc_go_down_to_selector(struct hda_codec *codec, hda_nid_t pin) |
| 2737 | { |
| 2738 | hda_nid_t srcs[5]; |
| 2739 | int num = snd_hda_get_connections(codec, pin, srcs, |
| 2740 | ARRAY_SIZE(srcs)); |
| 2741 | if (num != 1 || |
| 2742 | get_wcaps_type(get_wcaps(codec, srcs[0])) != AC_WID_AUD_SEL) |
| 2743 | return pin; |
| 2744 | return srcs[0]; |
| 2745 | } |
| 2746 | |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2747 | /* get MIX nid connected to the given pin targeted to DAC */ |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2748 | static hda_nid_t alc_auto_dac_to_mix(struct hda_codec *codec, hda_nid_t pin, |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2749 | hda_nid_t dac) |
| 2750 | { |
David Henningsson | cc1c452 | 2010-11-24 14:17:47 +0100 | [diff] [blame] | 2751 | hda_nid_t mix[5]; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2752 | int i, num; |
| 2753 | |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2754 | pin = alc_go_down_to_selector(codec, pin); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2755 | num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix)); |
| 2756 | for (i = 0; i < num; i++) { |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2757 | if (alc_auto_mix_to_dac(codec, mix[i]) == dac) |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2758 | return mix[i]; |
| 2759 | } |
| 2760 | return 0; |
| 2761 | } |
| 2762 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 2763 | /* select the connection from pin to DAC if needed */ |
| 2764 | static int alc_auto_select_dac(struct hda_codec *codec, hda_nid_t pin, |
| 2765 | hda_nid_t dac) |
| 2766 | { |
| 2767 | hda_nid_t mix[5]; |
| 2768 | int i, num; |
| 2769 | |
| 2770 | pin = alc_go_down_to_selector(codec, pin); |
| 2771 | num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix)); |
| 2772 | if (num < 2) |
| 2773 | return 0; |
| 2774 | for (i = 0; i < num; i++) { |
| 2775 | if (alc_auto_mix_to_dac(codec, mix[i]) == dac) { |
| 2776 | snd_hda_codec_update_cache(codec, pin, 0, |
| 2777 | AC_VERB_SET_CONNECT_SEL, i); |
| 2778 | return 0; |
| 2779 | } |
| 2780 | } |
| 2781 | return 0; |
| 2782 | } |
| 2783 | |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 2784 | static bool alc_is_dac_already_used(struct hda_codec *codec, hda_nid_t nid) |
| 2785 | { |
| 2786 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 2787 | int i; |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 2788 | if (found_in_nid_list(nid, spec->multiout.dac_nids, |
| 2789 | ARRAY_SIZE(spec->private_dac_nids)) || |
| 2790 | found_in_nid_list(nid, spec->multiout.hp_out_nid, |
| 2791 | ARRAY_SIZE(spec->multiout.hp_out_nid)) || |
| 2792 | found_in_nid_list(nid, spec->multiout.extra_out_nid, |
| 2793 | ARRAY_SIZE(spec->multiout.extra_out_nid))) |
| 2794 | return true; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 2795 | for (i = 0; i < spec->multi_ios; i++) { |
| 2796 | if (spec->multi_io[i].dac == nid) |
| 2797 | return true; |
| 2798 | } |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 2799 | return false; |
| 2800 | } |
| 2801 | |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2802 | /* look for an empty DAC slot */ |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2803 | static hda_nid_t alc_auto_look_for_dac(struct hda_codec *codec, hda_nid_t pin) |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2804 | { |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2805 | hda_nid_t srcs[5]; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 2806 | int i, num; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2807 | |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2808 | pin = alc_go_down_to_selector(codec, pin); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2809 | num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs)); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2810 | for (i = 0; i < num; i++) { |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2811 | hda_nid_t nid = alc_auto_mix_to_dac(codec, srcs[i]); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2812 | if (!nid) |
| 2813 | continue; |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 2814 | if (!alc_is_dac_already_used(codec, nid)) |
| 2815 | return nid; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2816 | } |
| 2817 | return 0; |
| 2818 | } |
| 2819 | |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 2820 | /* check whether the DAC is reachable from the pin */ |
| 2821 | static bool alc_auto_is_dac_reachable(struct hda_codec *codec, |
| 2822 | hda_nid_t pin, hda_nid_t dac) |
| 2823 | { |
| 2824 | hda_nid_t srcs[5]; |
| 2825 | int i, num; |
| 2826 | |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 2827 | if (!pin || !dac) |
| 2828 | return false; |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 2829 | pin = alc_go_down_to_selector(codec, pin); |
| 2830 | num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs)); |
| 2831 | for (i = 0; i < num; i++) { |
| 2832 | hda_nid_t nid = alc_auto_mix_to_dac(codec, srcs[i]); |
| 2833 | if (nid == dac) |
| 2834 | return true; |
| 2835 | } |
| 2836 | return false; |
| 2837 | } |
| 2838 | |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 2839 | static hda_nid_t get_dac_if_single(struct hda_codec *codec, hda_nid_t pin) |
| 2840 | { |
Takashi Iwai | 140547e | 2012-02-16 17:23:46 +0100 | [diff] [blame] | 2841 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 2842 | hda_nid_t sel = alc_go_down_to_selector(codec, pin); |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 2843 | hda_nid_t nid, nid_found, srcs[5]; |
| 2844 | int i, num = snd_hda_get_connections(codec, sel, srcs, |
Takashi Iwai | 140547e | 2012-02-16 17:23:46 +0100 | [diff] [blame] | 2845 | ARRAY_SIZE(srcs)); |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 2846 | if (num == 1) |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 2847 | return alc_auto_look_for_dac(codec, pin); |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 2848 | nid_found = 0; |
| 2849 | for (i = 0; i < num; i++) { |
| 2850 | if (srcs[i] == spec->mixer_nid) |
| 2851 | continue; |
| 2852 | nid = alc_auto_mix_to_dac(codec, srcs[i]); |
| 2853 | if (nid && !alc_is_dac_already_used(codec, nid)) { |
| 2854 | if (nid_found) |
| 2855 | return 0; |
| 2856 | nid_found = nid; |
| 2857 | } |
| 2858 | } |
| 2859 | return nid_found; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 2860 | } |
| 2861 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 2862 | /* mark up volume and mute control NIDs: used during badness parsing and |
| 2863 | * at creating actual controls |
| 2864 | */ |
| 2865 | static inline unsigned int get_ctl_pos(unsigned int data) |
| 2866 | { |
| 2867 | hda_nid_t nid = get_amp_nid_(data); |
| 2868 | unsigned int dir; |
| 2869 | if (snd_BUG_ON(nid >= MAX_VOL_NIDS)) |
| 2870 | return 0; |
| 2871 | dir = get_amp_direction_(data); |
| 2872 | return (nid << 1) | dir; |
| 2873 | } |
| 2874 | |
| 2875 | #define is_ctl_used(bits, data) \ |
| 2876 | test_bit(get_ctl_pos(data), bits) |
| 2877 | #define mark_ctl_usage(bits, data) \ |
| 2878 | set_bit(get_ctl_pos(data), bits) |
| 2879 | |
| 2880 | static void clear_vol_marks(struct hda_codec *codec) |
| 2881 | { |
| 2882 | struct alc_spec *spec = codec->spec; |
| 2883 | memset(spec->vol_ctls, 0, sizeof(spec->vol_ctls)); |
| 2884 | memset(spec->sw_ctls, 0, sizeof(spec->sw_ctls)); |
| 2885 | } |
| 2886 | |
| 2887 | /* badness definition */ |
| 2888 | enum { |
| 2889 | /* No primary DAC is found for the main output */ |
| 2890 | BAD_NO_PRIMARY_DAC = 0x10000, |
| 2891 | /* No DAC is found for the extra output */ |
| 2892 | BAD_NO_DAC = 0x4000, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 2893 | /* No possible multi-ios */ |
| 2894 | BAD_MULTI_IO = 0x103, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 2895 | /* No individual DAC for extra output */ |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 2896 | BAD_NO_EXTRA_DAC = 0x102, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 2897 | /* No individual DAC for extra surrounds */ |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 2898 | BAD_NO_EXTRA_SURR_DAC = 0x101, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 2899 | /* Primary DAC shared with main surrounds */ |
| 2900 | BAD_SHARED_SURROUND = 0x100, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 2901 | /* Primary DAC shared with main CLFE */ |
| 2902 | BAD_SHARED_CLFE = 0x10, |
| 2903 | /* Primary DAC shared with extra surrounds */ |
| 2904 | BAD_SHARED_EXTRA_SURROUND = 0x10, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 2905 | /* Volume widget is shared */ |
| 2906 | BAD_SHARED_VOL = 0x10, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 2907 | }; |
| 2908 | |
| 2909 | static hda_nid_t alc_look_for_out_mute_nid(struct hda_codec *codec, |
| 2910 | hda_nid_t pin, hda_nid_t dac); |
| 2911 | static hda_nid_t alc_look_for_out_vol_nid(struct hda_codec *codec, |
| 2912 | hda_nid_t pin, hda_nid_t dac); |
| 2913 | |
| 2914 | static int eval_shared_vol_badness(struct hda_codec *codec, hda_nid_t pin, |
| 2915 | hda_nid_t dac) |
| 2916 | { |
| 2917 | struct alc_spec *spec = codec->spec; |
| 2918 | hda_nid_t nid; |
| 2919 | unsigned int val; |
| 2920 | int badness = 0; |
| 2921 | |
| 2922 | nid = alc_look_for_out_vol_nid(codec, pin, dac); |
| 2923 | if (nid) { |
| 2924 | val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); |
| 2925 | if (is_ctl_used(spec->vol_ctls, nid)) |
| 2926 | badness += BAD_SHARED_VOL; |
| 2927 | else |
| 2928 | mark_ctl_usage(spec->vol_ctls, val); |
| 2929 | } else |
| 2930 | badness += BAD_SHARED_VOL; |
| 2931 | nid = alc_look_for_out_mute_nid(codec, pin, dac); |
| 2932 | if (nid) { |
| 2933 | unsigned int wid_type = get_wcaps_type(get_wcaps(codec, nid)); |
| 2934 | if (wid_type == AC_WID_PIN || wid_type == AC_WID_AUD_OUT) |
| 2935 | val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); |
| 2936 | else |
| 2937 | val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT); |
| 2938 | if (is_ctl_used(spec->sw_ctls, val)) |
| 2939 | badness += BAD_SHARED_VOL; |
| 2940 | else |
| 2941 | mark_ctl_usage(spec->sw_ctls, val); |
| 2942 | } else |
| 2943 | badness += BAD_SHARED_VOL; |
| 2944 | return badness; |
| 2945 | } |
| 2946 | |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 2947 | struct badness_table { |
| 2948 | int no_primary_dac; /* no primary DAC */ |
| 2949 | int no_dac; /* no secondary DACs */ |
| 2950 | int shared_primary; /* primary DAC is shared with main output */ |
| 2951 | int shared_surr; /* secondary DAC shared with main or primary */ |
| 2952 | int shared_clfe; /* third DAC shared with main or primary */ |
| 2953 | int shared_surr_main; /* secondary DAC sahred with main/DAC0 */ |
| 2954 | }; |
| 2955 | |
| 2956 | static struct badness_table main_out_badness = { |
| 2957 | .no_primary_dac = BAD_NO_PRIMARY_DAC, |
| 2958 | .no_dac = BAD_NO_DAC, |
| 2959 | .shared_primary = BAD_NO_PRIMARY_DAC, |
| 2960 | .shared_surr = BAD_SHARED_SURROUND, |
| 2961 | .shared_clfe = BAD_SHARED_CLFE, |
| 2962 | .shared_surr_main = BAD_SHARED_SURROUND, |
| 2963 | }; |
| 2964 | |
| 2965 | static struct badness_table extra_out_badness = { |
| 2966 | .no_primary_dac = BAD_NO_DAC, |
| 2967 | .no_dac = BAD_NO_DAC, |
| 2968 | .shared_primary = BAD_NO_EXTRA_DAC, |
| 2969 | .shared_surr = BAD_SHARED_EXTRA_SURROUND, |
| 2970 | .shared_clfe = BAD_SHARED_EXTRA_SURROUND, |
| 2971 | .shared_surr_main = BAD_NO_EXTRA_SURR_DAC, |
| 2972 | }; |
| 2973 | |
| 2974 | /* try to assign DACs to pins and return the resultant badness */ |
| 2975 | static int alc_auto_fill_dacs(struct hda_codec *codec, int num_outs, |
| 2976 | const hda_nid_t *pins, hda_nid_t *dacs, |
| 2977 | const struct badness_table *bad) |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 2978 | { |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 2979 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 2980 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2981 | int i, j; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 2982 | int badness = 0; |
| 2983 | hda_nid_t dac; |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 2984 | |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 2985 | if (!num_outs) |
| 2986 | return 0; |
| 2987 | |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 2988 | for (i = 0; i < num_outs; i++) { |
| 2989 | hda_nid_t pin = pins[i]; |
| 2990 | if (!dacs[i]) |
| 2991 | dacs[i] = alc_auto_look_for_dac(codec, pin); |
| 2992 | if (!dacs[i] && !i) { |
| 2993 | for (j = 1; j < num_outs; j++) { |
| 2994 | if (alc_auto_is_dac_reachable(codec, pin, dacs[j])) { |
| 2995 | dacs[0] = dacs[j]; |
| 2996 | dacs[j] = 0; |
| 2997 | break; |
| 2998 | } |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 2999 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3000 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3001 | dac = dacs[i]; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3002 | if (!dac) { |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3003 | if (alc_auto_is_dac_reachable(codec, pin, dacs[0])) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3004 | dac = dacs[0]; |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3005 | else if (cfg->line_outs > i && |
| 3006 | alc_auto_is_dac_reachable(codec, pin, |
| 3007 | spec->private_dac_nids[i])) |
| 3008 | dac = spec->private_dac_nids[i]; |
| 3009 | if (dac) { |
| 3010 | if (!i) |
| 3011 | badness += bad->shared_primary; |
| 3012 | else if (i == 1) |
| 3013 | badness += bad->shared_surr; |
| 3014 | else |
| 3015 | badness += bad->shared_clfe; |
| 3016 | } else if (alc_auto_is_dac_reachable(codec, pin, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3017 | spec->private_dac_nids[0])) { |
| 3018 | dac = spec->private_dac_nids[0]; |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3019 | badness += bad->shared_surr_main; |
| 3020 | } else if (!i) |
| 3021 | badness += bad->no_primary_dac; |
| 3022 | else |
| 3023 | badness += bad->no_dac; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3024 | } |
| 3025 | if (dac) |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3026 | badness += eval_shared_vol_badness(codec, pin, dac); |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3027 | } |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3028 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3029 | return badness; |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3030 | } |
| 3031 | |
| 3032 | static int alc_auto_fill_multi_ios(struct hda_codec *codec, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3033 | hda_nid_t reference_pin, |
| 3034 | bool hardwired, int offset); |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3035 | |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3036 | static bool alc_map_singles(struct hda_codec *codec, int outs, |
| 3037 | const hda_nid_t *pins, hda_nid_t *dacs) |
| 3038 | { |
| 3039 | int i; |
| 3040 | bool found = false; |
| 3041 | for (i = 0; i < outs; i++) { |
| 3042 | if (dacs[i]) |
| 3043 | continue; |
| 3044 | dacs[i] = get_dac_if_single(codec, pins[i]); |
| 3045 | if (dacs[i]) |
| 3046 | found = true; |
| 3047 | } |
| 3048 | return found; |
| 3049 | } |
| 3050 | |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3051 | /* fill in the dac_nids table from the parsed pin configuration */ |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3052 | static int fill_and_eval_dacs(struct hda_codec *codec, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3053 | bool fill_hardwired, |
| 3054 | bool fill_mio_first) |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3055 | { |
| 3056 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3057 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3058 | int i, err, badness; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3059 | |
Takashi Iwai | 8f398ae | 2011-07-23 18:57:11 +0200 | [diff] [blame] | 3060 | /* set num_dacs once to full for alc_auto_look_for_dac() */ |
| 3061 | spec->multiout.num_dacs = cfg->line_outs; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3062 | spec->multiout.dac_nids = spec->private_dac_nids; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3063 | memset(spec->private_dac_nids, 0, sizeof(spec->private_dac_nids)); |
| 3064 | memset(spec->multiout.hp_out_nid, 0, sizeof(spec->multiout.hp_out_nid)); |
| 3065 | memset(spec->multiout.extra_out_nid, 0, sizeof(spec->multiout.extra_out_nid)); |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3066 | spec->multi_ios = 0; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3067 | clear_vol_marks(codec); |
| 3068 | badness = 0; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3069 | |
| 3070 | /* fill hard-wired DACs first */ |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3071 | if (fill_hardwired) { |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3072 | bool mapped; |
| 3073 | do { |
| 3074 | mapped = alc_map_singles(codec, cfg->line_outs, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3075 | cfg->line_out_pins, |
| 3076 | spec->private_dac_nids); |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3077 | mapped |= alc_map_singles(codec, cfg->hp_outs, |
| 3078 | cfg->hp_pins, |
| 3079 | spec->multiout.hp_out_nid); |
| 3080 | mapped |= alc_map_singles(codec, cfg->speaker_outs, |
| 3081 | cfg->speaker_pins, |
| 3082 | spec->multiout.extra_out_nid); |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3083 | if (fill_mio_first && cfg->line_outs == 1 && |
| 3084 | cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { |
| 3085 | err = alc_auto_fill_multi_ios(codec, cfg->line_out_pins[0], true, 0); |
| 3086 | if (!err) |
| 3087 | mapped = true; |
| 3088 | } |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3089 | } while (mapped); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3090 | } |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3091 | |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3092 | badness += alc_auto_fill_dacs(codec, cfg->line_outs, cfg->line_out_pins, |
| 3093 | spec->private_dac_nids, |
| 3094 | &main_out_badness); |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3095 | |
Takashi Iwai | 8f398ae | 2011-07-23 18:57:11 +0200 | [diff] [blame] | 3096 | /* re-count num_dacs and squash invalid entries */ |
| 3097 | spec->multiout.num_dacs = 0; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3098 | for (i = 0; i < cfg->line_outs; i++) { |
| 3099 | if (spec->private_dac_nids[i]) |
| 3100 | spec->multiout.num_dacs++; |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3101 | else { |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3102 | memmove(spec->private_dac_nids + i, |
| 3103 | spec->private_dac_nids + i + 1, |
| 3104 | sizeof(hda_nid_t) * (cfg->line_outs - i - 1)); |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3105 | spec->private_dac_nids[cfg->line_outs - 1] = 0; |
| 3106 | } |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3107 | } |
| 3108 | |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3109 | if (fill_mio_first && |
| 3110 | cfg->line_outs == 1 && cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3111 | /* try to fill multi-io first */ |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3112 | err = alc_auto_fill_multi_ios(codec, cfg->line_out_pins[0], false, 0); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3113 | if (err < 0) |
| 3114 | return err; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3115 | /* we don't count badness at this stage yet */ |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3116 | } |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3117 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3118 | if (cfg->line_out_type != AUTO_PIN_HP_OUT) { |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3119 | err = alc_auto_fill_dacs(codec, cfg->hp_outs, cfg->hp_pins, |
| 3120 | spec->multiout.hp_out_nid, |
| 3121 | &extra_out_badness); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3122 | if (err < 0) |
| 3123 | return err; |
| 3124 | badness += err; |
| 3125 | } |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3126 | if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3127 | err = alc_auto_fill_dacs(codec, cfg->speaker_outs, |
| 3128 | cfg->speaker_pins, |
| 3129 | spec->multiout.extra_out_nid, |
| 3130 | &extra_out_badness); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3131 | if (err < 0) |
| 3132 | return err; |
| 3133 | badness += err; |
| 3134 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3135 | if (cfg->line_outs == 1 && cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { |
| 3136 | err = alc_auto_fill_multi_ios(codec, cfg->line_out_pins[0], false, 0); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3137 | if (err < 0) |
| 3138 | return err; |
| 3139 | badness += err; |
| 3140 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3141 | if (cfg->hp_outs && cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) { |
| 3142 | /* try multi-ios with HP + inputs */ |
Takashi Iwai | f568291 | 2012-02-21 12:37:00 +0100 | [diff] [blame] | 3143 | int offset = 0; |
| 3144 | if (cfg->line_outs >= 3) |
| 3145 | offset = 1; |
| 3146 | err = alc_auto_fill_multi_ios(codec, cfg->hp_pins[0], false, |
| 3147 | offset); |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3148 | if (err < 0) |
| 3149 | return err; |
| 3150 | badness += err; |
| 3151 | } |
| 3152 | |
| 3153 | if (spec->multi_ios == 2) { |
| 3154 | for (i = 0; i < 2; i++) |
| 3155 | spec->private_dac_nids[spec->multiout.num_dacs++] = |
| 3156 | spec->multi_io[i].dac; |
| 3157 | spec->ext_channel_count = 2; |
| 3158 | } else if (spec->multi_ios) { |
| 3159 | spec->multi_ios = 0; |
| 3160 | badness += BAD_MULTI_IO; |
| 3161 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3162 | |
| 3163 | return badness; |
| 3164 | } |
| 3165 | |
| 3166 | #define DEBUG_BADNESS |
| 3167 | |
| 3168 | #ifdef DEBUG_BADNESS |
| 3169 | #define debug_badness snd_printdd |
| 3170 | #else |
| 3171 | #define debug_badness(...) |
| 3172 | #endif |
| 3173 | |
| 3174 | static void debug_show_configs(struct alc_spec *spec, struct auto_pin_cfg *cfg) |
| 3175 | { |
| 3176 | debug_badness("multi_outs = %x/%x/%x/%x : %x/%x/%x/%x\n", |
| 3177 | cfg->line_out_pins[0], cfg->line_out_pins[1], |
| 3178 | cfg->line_out_pins[2], cfg->line_out_pins[2], |
| 3179 | spec->multiout.dac_nids[0], |
| 3180 | spec->multiout.dac_nids[1], |
| 3181 | spec->multiout.dac_nids[2], |
| 3182 | spec->multiout.dac_nids[3]); |
Takashi Iwai | 6f45304 | 2012-02-17 14:09:20 +0100 | [diff] [blame] | 3183 | if (spec->multi_ios > 0) |
| 3184 | debug_badness("multi_ios(%d) = %x/%x : %x/%x\n", |
| 3185 | spec->multi_ios, |
| 3186 | spec->multi_io[0].pin, spec->multi_io[1].pin, |
| 3187 | spec->multi_io[0].dac, spec->multi_io[1].dac); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3188 | debug_badness("hp_outs = %x/%x/%x/%x : %x/%x/%x/%x\n", |
| 3189 | cfg->hp_pins[0], cfg->hp_pins[1], |
| 3190 | cfg->hp_pins[2], cfg->hp_pins[2], |
| 3191 | spec->multiout.hp_out_nid[0], |
| 3192 | spec->multiout.hp_out_nid[1], |
| 3193 | spec->multiout.hp_out_nid[2], |
| 3194 | spec->multiout.hp_out_nid[3]); |
| 3195 | debug_badness("spk_outs = %x/%x/%x/%x : %x/%x/%x/%x\n", |
| 3196 | cfg->speaker_pins[0], cfg->speaker_pins[1], |
| 3197 | cfg->speaker_pins[2], cfg->speaker_pins[3], |
| 3198 | spec->multiout.extra_out_nid[0], |
| 3199 | spec->multiout.extra_out_nid[1], |
| 3200 | spec->multiout.extra_out_nid[2], |
| 3201 | spec->multiout.extra_out_nid[3]); |
| 3202 | } |
| 3203 | |
| 3204 | static int alc_auto_fill_dac_nids(struct hda_codec *codec) |
| 3205 | { |
| 3206 | struct alc_spec *spec = codec->spec; |
| 3207 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 3208 | struct auto_pin_cfg *best_cfg; |
| 3209 | int best_badness = INT_MAX; |
| 3210 | int badness; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3211 | bool fill_hardwired = true, fill_mio_first = true; |
| 3212 | bool best_wired = true, best_mio = true; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3213 | bool hp_spk_swapped = false; |
| 3214 | |
| 3215 | best_cfg = kmalloc(sizeof(*best_cfg), GFP_KERNEL); |
| 3216 | if (!best_cfg) |
| 3217 | return -ENOMEM; |
| 3218 | *best_cfg = *cfg; |
| 3219 | |
| 3220 | for (;;) { |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3221 | badness = fill_and_eval_dacs(codec, fill_hardwired, |
| 3222 | fill_mio_first); |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 3223 | if (badness < 0) { |
| 3224 | kfree(best_cfg); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3225 | return badness; |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 3226 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3227 | debug_badness("==> lo_type=%d, wired=%d, mio=%d, badness=0x%x\n", |
| 3228 | cfg->line_out_type, fill_hardwired, fill_mio_first, |
| 3229 | badness); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3230 | debug_show_configs(spec, cfg); |
| 3231 | if (badness < best_badness) { |
| 3232 | best_badness = badness; |
| 3233 | *best_cfg = *cfg; |
| 3234 | best_wired = fill_hardwired; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3235 | best_mio = fill_mio_first; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3236 | } |
| 3237 | if (!badness) |
| 3238 | break; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3239 | fill_mio_first = !fill_mio_first; |
| 3240 | if (!fill_mio_first) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3241 | continue; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3242 | fill_hardwired = !fill_hardwired; |
| 3243 | if (!fill_hardwired) |
| 3244 | continue; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3245 | if (hp_spk_swapped) |
| 3246 | break; |
| 3247 | hp_spk_swapped = true; |
| 3248 | if (cfg->speaker_outs > 0 && |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3249 | cfg->line_out_type == AUTO_PIN_HP_OUT) { |
| 3250 | cfg->hp_outs = cfg->line_outs; |
| 3251 | memcpy(cfg->hp_pins, cfg->line_out_pins, |
| 3252 | sizeof(cfg->hp_pins)); |
| 3253 | cfg->line_outs = cfg->speaker_outs; |
| 3254 | memcpy(cfg->line_out_pins, cfg->speaker_pins, |
| 3255 | sizeof(cfg->speaker_pins)); |
| 3256 | cfg->speaker_outs = 0; |
| 3257 | memset(cfg->speaker_pins, 0, sizeof(cfg->speaker_pins)); |
| 3258 | cfg->line_out_type = AUTO_PIN_SPEAKER_OUT; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3259 | fill_hardwired = true; |
| 3260 | continue; |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 3261 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3262 | if (cfg->hp_outs > 0 && |
| 3263 | cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) { |
| 3264 | cfg->speaker_outs = cfg->line_outs; |
| 3265 | memcpy(cfg->speaker_pins, cfg->line_out_pins, |
| 3266 | sizeof(cfg->speaker_pins)); |
| 3267 | cfg->line_outs = cfg->hp_outs; |
| 3268 | memcpy(cfg->line_out_pins, cfg->hp_pins, |
| 3269 | sizeof(cfg->hp_pins)); |
| 3270 | cfg->hp_outs = 0; |
| 3271 | memset(cfg->hp_pins, 0, sizeof(cfg->hp_pins)); |
| 3272 | cfg->line_out_type = AUTO_PIN_HP_OUT; |
| 3273 | fill_hardwired = true; |
| 3274 | continue; |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 3275 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3276 | break; |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3277 | } |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3278 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3279 | if (badness) { |
| 3280 | *cfg = *best_cfg; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3281 | fill_and_eval_dacs(codec, best_wired, best_mio); |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 3282 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3283 | debug_badness("==> Best config: lo_type=%d, wired=%d, mio=%d\n", |
| 3284 | cfg->line_out_type, best_wired, best_mio); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3285 | debug_show_configs(spec, cfg); |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 3286 | |
David Henningsson | fde48a1 | 2011-12-09 18:27:42 +0800 | [diff] [blame] | 3287 | if (cfg->line_out_pins[0]) |
| 3288 | spec->vmaster_nid = |
| 3289 | alc_look_for_out_vol_nid(codec, cfg->line_out_pins[0], |
| 3290 | spec->multiout.dac_nids[0]); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3291 | |
| 3292 | /* clear the bitmap flags for creating controls */ |
| 3293 | clear_vol_marks(codec); |
| 3294 | kfree(best_cfg); |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3295 | return 0; |
| 3296 | } |
| 3297 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3298 | static int alc_auto_add_vol_ctl(struct hda_codec *codec, |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3299 | const char *pfx, int cidx, |
| 3300 | hda_nid_t nid, unsigned int chs) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3301 | { |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3302 | struct alc_spec *spec = codec->spec; |
| 3303 | unsigned int val; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3304 | if (!nid) |
| 3305 | return 0; |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3306 | val = HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT); |
| 3307 | if (is_ctl_used(spec->vol_ctls, val) && chs != 2) /* exclude LFE */ |
| 3308 | return 0; |
| 3309 | mark_ctl_usage(spec->vol_ctls, val); |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3310 | return __add_pb_vol_ctrl(codec->spec, ALC_CTL_WIDGET_VOL, pfx, cidx, |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3311 | val); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3312 | } |
| 3313 | |
Takashi Iwai | e29d377 | 2011-11-14 17:13:23 +0100 | [diff] [blame] | 3314 | static int alc_auto_add_stereo_vol(struct hda_codec *codec, |
| 3315 | const char *pfx, int cidx, |
| 3316 | hda_nid_t nid) |
| 3317 | { |
| 3318 | int chs = 1; |
| 3319 | if (get_wcaps(codec, nid) & AC_WCAP_STEREO) |
| 3320 | chs = 3; |
| 3321 | return alc_auto_add_vol_ctl(codec, pfx, cidx, nid, chs); |
| 3322 | } |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3323 | |
| 3324 | /* create a mute-switch for the given mixer widget; |
| 3325 | * if it has multiple sources (e.g. DAC and loopback), create a bind-mute |
| 3326 | */ |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3327 | static int alc_auto_add_sw_ctl(struct hda_codec *codec, |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3328 | const char *pfx, int cidx, |
| 3329 | hda_nid_t nid, unsigned int chs) |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3330 | { |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3331 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3332 | int wid_type; |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3333 | int type; |
| 3334 | unsigned long val; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3335 | if (!nid) |
| 3336 | return 0; |
| 3337 | wid_type = get_wcaps_type(get_wcaps(codec, nid)); |
| 3338 | if (wid_type == AC_WID_PIN || wid_type == AC_WID_AUD_OUT) { |
| 3339 | type = ALC_CTL_WIDGET_MUTE; |
| 3340 | val = HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT); |
| 3341 | } else if (snd_hda_get_conn_list(codec, nid, NULL) == 1) { |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3342 | type = ALC_CTL_WIDGET_MUTE; |
| 3343 | val = HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT); |
| 3344 | } else { |
| 3345 | type = ALC_CTL_BIND_MUTE; |
| 3346 | val = HDA_COMPOSE_AMP_VAL(nid, chs, 2, HDA_INPUT); |
| 3347 | } |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3348 | if (is_ctl_used(spec->sw_ctls, val) && chs != 2) /* exclude LFE */ |
| 3349 | return 0; |
| 3350 | mark_ctl_usage(spec->sw_ctls, val); |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3351 | return __add_pb_sw_ctrl(codec->spec, type, pfx, cidx, val); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3352 | } |
| 3353 | |
Takashi Iwai | e29d377 | 2011-11-14 17:13:23 +0100 | [diff] [blame] | 3354 | static int alc_auto_add_stereo_sw(struct hda_codec *codec, const char *pfx, |
| 3355 | int cidx, hda_nid_t nid) |
| 3356 | { |
| 3357 | int chs = 1; |
| 3358 | if (get_wcaps(codec, nid) & AC_WCAP_STEREO) |
| 3359 | chs = 3; |
| 3360 | return alc_auto_add_sw_ctl(codec, pfx, cidx, nid, chs); |
| 3361 | } |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3362 | |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3363 | static hda_nid_t alc_look_for_out_mute_nid(struct hda_codec *codec, |
| 3364 | hda_nid_t pin, hda_nid_t dac) |
| 3365 | { |
| 3366 | hda_nid_t mix = alc_auto_dac_to_mix(codec, pin, dac); |
| 3367 | if (nid_has_mute(codec, pin, HDA_OUTPUT)) |
| 3368 | return pin; |
| 3369 | else if (mix && nid_has_mute(codec, mix, HDA_INPUT)) |
| 3370 | return mix; |
| 3371 | else if (nid_has_mute(codec, dac, HDA_OUTPUT)) |
| 3372 | return dac; |
| 3373 | return 0; |
| 3374 | } |
| 3375 | |
| 3376 | static hda_nid_t alc_look_for_out_vol_nid(struct hda_codec *codec, |
| 3377 | hda_nid_t pin, hda_nid_t dac) |
| 3378 | { |
| 3379 | hda_nid_t mix = alc_auto_dac_to_mix(codec, pin, dac); |
| 3380 | if (nid_has_volume(codec, dac, HDA_OUTPUT)) |
| 3381 | return dac; |
| 3382 | else if (nid_has_volume(codec, mix, HDA_OUTPUT)) |
| 3383 | return mix; |
| 3384 | else if (nid_has_volume(codec, pin, HDA_OUTPUT)) |
| 3385 | return pin; |
| 3386 | return 0; |
| 3387 | } |
| 3388 | |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3389 | /* add playback controls from the parsed DAC table */ |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3390 | static int alc_auto_create_multi_out_ctls(struct hda_codec *codec, |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3391 | const struct auto_pin_cfg *cfg) |
| 3392 | { |
| 3393 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3394 | int i, err, noutputs; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3395 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3396 | noutputs = cfg->line_outs; |
Takashi Iwai | b90bf1d | 2012-01-19 11:42:55 +0100 | [diff] [blame] | 3397 | if (spec->multi_ios > 0 && cfg->line_outs < 3) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3398 | noutputs += spec->multi_ios; |
| 3399 | |
| 3400 | for (i = 0; i < noutputs; i++) { |
Takashi Iwai | 6843ca1 | 2011-06-24 11:03:58 +0200 | [diff] [blame] | 3401 | const char *name; |
| 3402 | int index; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3403 | hda_nid_t dac, pin; |
| 3404 | hda_nid_t sw, vol; |
| 3405 | |
| 3406 | dac = spec->multiout.dac_nids[i]; |
| 3407 | if (!dac) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3408 | continue; |
Takashi Iwai | 689cabf | 2012-02-21 12:35:27 +0100 | [diff] [blame] | 3409 | if (i >= cfg->line_outs) { |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3410 | pin = spec->multi_io[i - 1].pin; |
Takashi Iwai | 689cabf | 2012-02-21 12:35:27 +0100 | [diff] [blame] | 3411 | index = 0; |
| 3412 | name = channel_name[i]; |
| 3413 | } else { |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3414 | pin = cfg->line_out_pins[i]; |
Takashi Iwai | 689cabf | 2012-02-21 12:35:27 +0100 | [diff] [blame] | 3415 | name = alc_get_line_out_pfx(spec, i, true, &index); |
| 3416 | } |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3417 | |
| 3418 | sw = alc_look_for_out_mute_nid(codec, pin, dac); |
| 3419 | vol = alc_look_for_out_vol_nid(codec, pin, dac); |
Takashi Iwai | 9c4e84d | 2011-08-24 17:27:52 +0200 | [diff] [blame] | 3420 | if (!name || !strcmp(name, "CLFE")) { |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3421 | /* Center/LFE */ |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3422 | err = alc_auto_add_vol_ctl(codec, "Center", 0, vol, 1); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3423 | if (err < 0) |
| 3424 | return err; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3425 | err = alc_auto_add_vol_ctl(codec, "LFE", 0, vol, 2); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3426 | if (err < 0) |
| 3427 | return err; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3428 | err = alc_auto_add_sw_ctl(codec, "Center", 0, sw, 1); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3429 | if (err < 0) |
| 3430 | return err; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3431 | err = alc_auto_add_sw_ctl(codec, "LFE", 0, sw, 2); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3432 | if (err < 0) |
| 3433 | return err; |
| 3434 | } else { |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3435 | err = alc_auto_add_stereo_vol(codec, name, index, vol); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3436 | if (err < 0) |
| 3437 | return err; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3438 | err = alc_auto_add_stereo_sw(codec, name, index, sw); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3439 | if (err < 0) |
| 3440 | return err; |
| 3441 | } |
| 3442 | } |
| 3443 | return 0; |
| 3444 | } |
| 3445 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3446 | static int alc_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin, |
Takashi Iwai | 766ddee | 2011-12-07 16:55:19 +0100 | [diff] [blame] | 3447 | hda_nid_t dac, const char *pfx, |
| 3448 | int cidx) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3449 | { |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3450 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3451 | hda_nid_t sw, vol; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3452 | int err; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3453 | |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3454 | if (!dac) { |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3455 | unsigned int val; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3456 | /* the corresponding DAC is already occupied */ |
| 3457 | if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP)) |
| 3458 | return 0; /* no way */ |
| 3459 | /* create a switch only */ |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3460 | val = HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT); |
| 3461 | if (is_ctl_used(spec->sw_ctls, val)) |
| 3462 | return 0; /* already created */ |
| 3463 | mark_ctl_usage(spec->sw_ctls, val); |
Takashi Iwai | 766ddee | 2011-12-07 16:55:19 +0100 | [diff] [blame] | 3464 | return __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, cidx, val); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3465 | } |
| 3466 | |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3467 | sw = alc_look_for_out_mute_nid(codec, pin, dac); |
| 3468 | vol = alc_look_for_out_vol_nid(codec, pin, dac); |
Takashi Iwai | 766ddee | 2011-12-07 16:55:19 +0100 | [diff] [blame] | 3469 | err = alc_auto_add_stereo_vol(codec, pfx, cidx, vol); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3470 | if (err < 0) |
Takashi Iwai | 24fb917 | 2008-09-02 14:48:20 +0200 | [diff] [blame] | 3471 | return err; |
Takashi Iwai | 766ddee | 2011-12-07 16:55:19 +0100 | [diff] [blame] | 3472 | err = alc_auto_add_stereo_sw(codec, pfx, cidx, sw); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3473 | if (err < 0) |
| 3474 | return err; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3475 | return 0; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3476 | } |
| 3477 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3478 | static struct hda_bind_ctls *new_bind_ctl(struct hda_codec *codec, |
| 3479 | unsigned int nums, |
| 3480 | struct hda_ctl_ops *ops) |
| 3481 | { |
| 3482 | struct alc_spec *spec = codec->spec; |
| 3483 | struct hda_bind_ctls **ctlp, *ctl; |
| 3484 | snd_array_init(&spec->bind_ctls, sizeof(ctl), 8); |
| 3485 | ctlp = snd_array_new(&spec->bind_ctls); |
| 3486 | if (!ctlp) |
| 3487 | return NULL; |
| 3488 | ctl = kzalloc(sizeof(*ctl) + sizeof(long) * (nums + 1), GFP_KERNEL); |
| 3489 | *ctlp = ctl; |
| 3490 | if (ctl) |
| 3491 | ctl->ops = ops; |
| 3492 | return ctl; |
| 3493 | } |
| 3494 | |
| 3495 | /* add playback controls for speaker and HP outputs */ |
| 3496 | static int alc_auto_create_extra_outs(struct hda_codec *codec, int num_pins, |
| 3497 | const hda_nid_t *pins, |
| 3498 | const hda_nid_t *dacs, |
| 3499 | const char *pfx) |
| 3500 | { |
| 3501 | struct alc_spec *spec = codec->spec; |
| 3502 | struct hda_bind_ctls *ctl; |
| 3503 | char name[32]; |
| 3504 | int i, n, err; |
| 3505 | |
| 3506 | if (!num_pins || !pins[0]) |
| 3507 | return 0; |
| 3508 | |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3509 | if (num_pins == 1) { |
| 3510 | hda_nid_t dac = *dacs; |
| 3511 | if (!dac) |
| 3512 | dac = spec->multiout.dac_nids[0]; |
Takashi Iwai | 766ddee | 2011-12-07 16:55:19 +0100 | [diff] [blame] | 3513 | return alc_auto_create_extra_out(codec, *pins, dac, pfx, 0); |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3514 | } |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3515 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3516 | for (i = 0; i < num_pins; i++) { |
Takashi Iwai | c96f0bf | 2012-02-21 12:12:57 +0100 | [diff] [blame] | 3517 | hda_nid_t dac; |
| 3518 | if (dacs[num_pins - 1]) |
| 3519 | dac = dacs[i]; /* with individual volumes */ |
| 3520 | else |
| 3521 | dac = 0; |
| 3522 | if (num_pins == 2 && i == 1 && !strcmp(pfx, "Speaker")) { |
| 3523 | err = alc_auto_create_extra_out(codec, pins[i], dac, |
| 3524 | "Bass Speaker", 0); |
| 3525 | } else if (num_pins >= 3) { |
| 3526 | snprintf(name, sizeof(name), "%s %s", |
| 3527 | pfx, channel_name[i]); |
| 3528 | err = alc_auto_create_extra_out(codec, pins[i], dac, |
| 3529 | name, 0); |
| 3530 | } else { |
| 3531 | err = alc_auto_create_extra_out(codec, pins[i], dac, |
| 3532 | pfx, i); |
| 3533 | } |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3534 | if (err < 0) |
| 3535 | return err; |
| 3536 | } |
Takashi Iwai | c96f0bf | 2012-02-21 12:12:57 +0100 | [diff] [blame] | 3537 | if (dacs[num_pins - 1]) |
| 3538 | return 0; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3539 | |
Takashi Iwai | c96f0bf | 2012-02-21 12:12:57 +0100 | [diff] [blame] | 3540 | /* Let's create a bind-controls for volumes */ |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3541 | ctl = new_bind_ctl(codec, num_pins, &snd_hda_bind_vol); |
| 3542 | if (!ctl) |
| 3543 | return -ENOMEM; |
| 3544 | n = 0; |
| 3545 | for (i = 0; i < num_pins; i++) { |
| 3546 | hda_nid_t vol; |
| 3547 | if (!pins[i] || !dacs[i]) |
| 3548 | continue; |
| 3549 | vol = alc_look_for_out_vol_nid(codec, pins[i], dacs[i]); |
| 3550 | if (vol) |
| 3551 | ctl->values[n++] = |
| 3552 | HDA_COMPOSE_AMP_VAL(vol, 3, 0, HDA_OUTPUT); |
| 3553 | } |
| 3554 | if (n) { |
| 3555 | snprintf(name, sizeof(name), "%s Playback Volume", pfx); |
| 3556 | err = add_control(spec, ALC_CTL_BIND_VOL, name, 0, (long)ctl); |
| 3557 | if (err < 0) |
| 3558 | return err; |
| 3559 | } |
| 3560 | return 0; |
| 3561 | } |
| 3562 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3563 | static int alc_auto_create_hp_out(struct hda_codec *codec) |
| 3564 | { |
| 3565 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | e23832a | 2011-08-23 18:16:56 +0200 | [diff] [blame] | 3566 | return alc_auto_create_extra_outs(codec, spec->autocfg.hp_outs, |
| 3567 | spec->autocfg.hp_pins, |
| 3568 | spec->multiout.hp_out_nid, |
| 3569 | "Headphone"); |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3570 | } |
| 3571 | |
| 3572 | static int alc_auto_create_speaker_out(struct hda_codec *codec) |
| 3573 | { |
| 3574 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3575 | return alc_auto_create_extra_outs(codec, spec->autocfg.speaker_outs, |
| 3576 | spec->autocfg.speaker_pins, |
| 3577 | spec->multiout.extra_out_nid, |
| 3578 | "Speaker"); |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3579 | } |
| 3580 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3581 | static void alc_auto_set_output_and_unmute(struct hda_codec *codec, |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3582 | hda_nid_t pin, int pin_type, |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3583 | hda_nid_t dac) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3584 | { |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3585 | int i, num; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3586 | hda_nid_t nid, mix = 0; |
Takashi Iwai | ce503f3 | 2010-07-30 10:37:29 +0200 | [diff] [blame] | 3587 | hda_nid_t srcs[HDA_MAX_CONNECTIONS]; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3588 | |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3589 | alc_set_pin_output(codec, pin, pin_type); |
| 3590 | nid = alc_go_down_to_selector(codec, pin); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3591 | num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs)); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3592 | for (i = 0; i < num; i++) { |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 3593 | if (alc_auto_mix_to_dac(codec, srcs[i]) != dac) |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3594 | continue; |
Takashi Iwai | cd51155 | 2011-07-06 13:10:42 +0200 | [diff] [blame] | 3595 | mix = srcs[i]; |
| 3596 | break; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3597 | } |
Takashi Iwai | cd51155 | 2011-07-06 13:10:42 +0200 | [diff] [blame] | 3598 | if (!mix) |
| 3599 | return; |
| 3600 | |
| 3601 | /* need the manual connection? */ |
| 3602 | if (num > 1) |
| 3603 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i); |
| 3604 | /* unmute mixer widget inputs */ |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3605 | if (nid_has_mute(codec, mix, HDA_INPUT)) { |
| 3606 | snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
Takashi Iwai | cd51155 | 2011-07-06 13:10:42 +0200 | [diff] [blame] | 3607 | AMP_IN_UNMUTE(0)); |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3608 | snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
Takashi Iwai | cd51155 | 2011-07-06 13:10:42 +0200 | [diff] [blame] | 3609 | AMP_IN_UNMUTE(1)); |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3610 | } |
Takashi Iwai | cd51155 | 2011-07-06 13:10:42 +0200 | [diff] [blame] | 3611 | /* initialize volume */ |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3612 | nid = alc_look_for_out_vol_nid(codec, pin, dac); |
| 3613 | if (nid) |
| 3614 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
| 3615 | AMP_OUT_ZERO); |
Takashi Iwai | 43dea22 | 2011-11-06 11:25:34 +0100 | [diff] [blame] | 3616 | |
| 3617 | /* unmute DAC if it's not assigned to a mixer */ |
| 3618 | nid = alc_look_for_out_mute_nid(codec, pin, dac); |
| 3619 | if (nid == mix && nid_has_mute(codec, dac, HDA_OUTPUT)) |
| 3620 | snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
| 3621 | AMP_OUT_ZERO); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3622 | } |
| 3623 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3624 | static void alc_auto_init_multi_out(struct hda_codec *codec) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3625 | { |
| 3626 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3627 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3628 | int i; |
| 3629 | |
| 3630 | for (i = 0; i <= HDA_SIDE; i++) { |
| 3631 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
| 3632 | if (nid) |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3633 | alc_auto_set_output_and_unmute(codec, nid, pin_type, |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3634 | spec->multiout.dac_nids[i]); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3635 | } |
| 3636 | } |
| 3637 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3638 | static void alc_auto_init_extra_out(struct hda_codec *codec) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3639 | { |
| 3640 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 8cd0775 | 2011-08-23 15:16:22 +0200 | [diff] [blame] | 3641 | int i; |
Takashi Iwai | 675c1aa | 2011-08-23 12:36:28 +0200 | [diff] [blame] | 3642 | hda_nid_t pin, dac; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3643 | |
David Henningsson | 636030e | 2011-10-12 19:26:03 +0200 | [diff] [blame] | 3644 | for (i = 0; i < spec->autocfg.hp_outs; i++) { |
Takashi Iwai | 716eef0 | 2011-10-21 15:07:42 +0200 | [diff] [blame] | 3645 | if (spec->autocfg.line_out_type == AUTO_PIN_HP_OUT) |
| 3646 | break; |
Takashi Iwai | e23832a | 2011-08-23 18:16:56 +0200 | [diff] [blame] | 3647 | pin = spec->autocfg.hp_pins[i]; |
| 3648 | if (!pin) |
| 3649 | break; |
| 3650 | dac = spec->multiout.hp_out_nid[i]; |
| 3651 | if (!dac) { |
| 3652 | if (i > 0 && spec->multiout.hp_out_nid[0]) |
| 3653 | dac = spec->multiout.hp_out_nid[0]; |
| 3654 | else |
| 3655 | dac = spec->multiout.dac_nids[0]; |
| 3656 | } |
Takashi Iwai | 675c1aa | 2011-08-23 12:36:28 +0200 | [diff] [blame] | 3657 | alc_auto_set_output_and_unmute(codec, pin, PIN_HP, dac); |
| 3658 | } |
Takashi Iwai | 8cd0775 | 2011-08-23 15:16:22 +0200 | [diff] [blame] | 3659 | for (i = 0; i < spec->autocfg.speaker_outs; i++) { |
Takashi Iwai | 716eef0 | 2011-10-21 15:07:42 +0200 | [diff] [blame] | 3660 | if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT) |
| 3661 | break; |
Takashi Iwai | 8cd0775 | 2011-08-23 15:16:22 +0200 | [diff] [blame] | 3662 | pin = spec->autocfg.speaker_pins[i]; |
| 3663 | if (!pin) |
| 3664 | break; |
| 3665 | dac = spec->multiout.extra_out_nid[i]; |
| 3666 | if (!dac) { |
| 3667 | if (i > 0 && spec->multiout.extra_out_nid[0]) |
| 3668 | dac = spec->multiout.extra_out_nid[0]; |
| 3669 | else |
| 3670 | dac = spec->multiout.dac_nids[0]; |
| 3671 | } |
Takashi Iwai | 675c1aa | 2011-08-23 12:36:28 +0200 | [diff] [blame] | 3672 | alc_auto_set_output_and_unmute(codec, pin, PIN_OUT, dac); |
| 3673 | } |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3674 | } |
| 3675 | |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3676 | /* check whether the given pin can be a multi-io pin */ |
| 3677 | static bool can_be_multiio_pin(struct hda_codec *codec, |
| 3678 | unsigned int location, hda_nid_t nid) |
| 3679 | { |
| 3680 | unsigned int defcfg, caps; |
| 3681 | |
| 3682 | defcfg = snd_hda_codec_get_pincfg(codec, nid); |
| 3683 | if (get_defcfg_connect(defcfg) != AC_JACK_PORT_COMPLEX) |
| 3684 | return false; |
| 3685 | if (location && get_defcfg_location(defcfg) != location) |
| 3686 | return false; |
| 3687 | caps = snd_hda_query_pin_caps(codec, nid); |
| 3688 | if (!(caps & AC_PINCAP_OUT)) |
| 3689 | return false; |
| 3690 | return true; |
| 3691 | } |
| 3692 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3693 | /* |
| 3694 | * multi-io helper |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3695 | * |
| 3696 | * When hardwired is set, try to fill ony hardwired pins, and returns |
| 3697 | * zero if any pins are filled, non-zero if nothing found. |
| 3698 | * When hardwired is off, try to fill possible input pins, and returns |
| 3699 | * the badness value. |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3700 | */ |
| 3701 | static int alc_auto_fill_multi_ios(struct hda_codec *codec, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3702 | hda_nid_t reference_pin, |
| 3703 | bool hardwired, int offset) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3704 | { |
| 3705 | struct alc_spec *spec = codec->spec; |
| 3706 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3707 | int type, i, j, dacs, num_pins, old_pins; |
| 3708 | unsigned int defcfg = snd_hda_codec_get_pincfg(codec, reference_pin); |
| 3709 | unsigned int location = get_defcfg_location(defcfg); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3710 | int badness = 0; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3711 | |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3712 | old_pins = spec->multi_ios; |
| 3713 | if (old_pins >= 2) |
| 3714 | goto end_fill; |
| 3715 | |
| 3716 | num_pins = 0; |
| 3717 | for (type = AUTO_PIN_LINE_IN; type >= AUTO_PIN_MIC; type--) { |
| 3718 | for (i = 0; i < cfg->num_inputs; i++) { |
| 3719 | if (cfg->inputs[i].type != type) |
| 3720 | continue; |
| 3721 | if (can_be_multiio_pin(codec, location, |
| 3722 | cfg->inputs[i].pin)) |
| 3723 | num_pins++; |
| 3724 | } |
| 3725 | } |
| 3726 | if (num_pins < 2) |
| 3727 | goto end_fill; |
| 3728 | |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 3729 | dacs = spec->multiout.num_dacs; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3730 | for (type = AUTO_PIN_LINE_IN; type >= AUTO_PIN_MIC; type--) { |
| 3731 | for (i = 0; i < cfg->num_inputs; i++) { |
| 3732 | hda_nid_t nid = cfg->inputs[i].pin; |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 3733 | hda_nid_t dac = 0; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3734 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3735 | if (cfg->inputs[i].type != type) |
| 3736 | continue; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3737 | if (!can_be_multiio_pin(codec, location, nid)) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3738 | continue; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3739 | for (j = 0; j < spec->multi_ios; j++) { |
| 3740 | if (nid == spec->multi_io[j].pin) |
| 3741 | break; |
| 3742 | } |
| 3743 | if (j < spec->multi_ios) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3744 | continue; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3745 | |
| 3746 | if (offset && offset + spec->multi_ios < dacs) { |
| 3747 | dac = spec->private_dac_nids[offset + spec->multi_ios]; |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 3748 | if (!alc_auto_is_dac_reachable(codec, nid, dac)) |
| 3749 | dac = 0; |
| 3750 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3751 | if (hardwired) |
| 3752 | dac = get_dac_if_single(codec, nid); |
| 3753 | else if (!dac) |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 3754 | dac = alc_auto_look_for_dac(codec, nid); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3755 | if (!dac) { |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3756 | badness++; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3757 | continue; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3758 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3759 | spec->multi_io[spec->multi_ios].pin = nid; |
| 3760 | spec->multi_io[spec->multi_ios].dac = dac; |
| 3761 | spec->multi_ios++; |
| 3762 | if (spec->multi_ios >= 2) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3763 | break; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3764 | } |
| 3765 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3766 | end_fill: |
| 3767 | if (badness) |
| 3768 | badness = BAD_MULTI_IO; |
| 3769 | if (old_pins == spec->multi_ios) { |
| 3770 | if (hardwired) |
| 3771 | return 1; /* nothing found */ |
| 3772 | else |
| 3773 | return badness; /* no badness if nothing found */ |
| 3774 | } |
| 3775 | if (!hardwired && spec->multi_ios < 2) { |
| 3776 | spec->multi_ios = old_pins; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3777 | return badness; |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3778 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3779 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3780 | return 0; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3781 | } |
| 3782 | |
| 3783 | static int alc_auto_ch_mode_info(struct snd_kcontrol *kcontrol, |
| 3784 | struct snd_ctl_elem_info *uinfo) |
| 3785 | { |
| 3786 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3787 | struct alc_spec *spec = codec->spec; |
| 3788 | |
| 3789 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
| 3790 | uinfo->count = 1; |
| 3791 | uinfo->value.enumerated.items = spec->multi_ios + 1; |
| 3792 | if (uinfo->value.enumerated.item > spec->multi_ios) |
| 3793 | uinfo->value.enumerated.item = spec->multi_ios; |
| 3794 | sprintf(uinfo->value.enumerated.name, "%dch", |
| 3795 | (uinfo->value.enumerated.item + 1) * 2); |
| 3796 | return 0; |
| 3797 | } |
| 3798 | |
| 3799 | static int alc_auto_ch_mode_get(struct snd_kcontrol *kcontrol, |
| 3800 | struct snd_ctl_elem_value *ucontrol) |
| 3801 | { |
| 3802 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3803 | struct alc_spec *spec = codec->spec; |
| 3804 | ucontrol->value.enumerated.item[0] = (spec->ext_channel_count - 1) / 2; |
| 3805 | return 0; |
| 3806 | } |
| 3807 | |
| 3808 | static int alc_set_multi_io(struct hda_codec *codec, int idx, bool output) |
| 3809 | { |
| 3810 | struct alc_spec *spec = codec->spec; |
| 3811 | hda_nid_t nid = spec->multi_io[idx].pin; |
| 3812 | |
| 3813 | if (!spec->multi_io[idx].ctl_in) |
| 3814 | spec->multi_io[idx].ctl_in = |
| 3815 | snd_hda_codec_read(codec, nid, 0, |
| 3816 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 3817 | if (output) { |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 3818 | snd_hda_set_pin_ctl_cache(codec, nid, PIN_OUT); |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3819 | if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) |
| 3820 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, |
| 3821 | HDA_AMP_MUTE, 0); |
| 3822 | alc_auto_select_dac(codec, nid, spec->multi_io[idx].dac); |
| 3823 | } else { |
| 3824 | if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) |
| 3825 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, |
| 3826 | HDA_AMP_MUTE, HDA_AMP_MUTE); |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 3827 | snd_hda_set_pin_ctl_cache(codec, nid, |
| 3828 | spec->multi_io[idx].ctl_in); |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3829 | } |
| 3830 | return 0; |
| 3831 | } |
| 3832 | |
| 3833 | static int alc_auto_ch_mode_put(struct snd_kcontrol *kcontrol, |
| 3834 | struct snd_ctl_elem_value *ucontrol) |
| 3835 | { |
| 3836 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3837 | struct alc_spec *spec = codec->spec; |
| 3838 | int i, ch; |
| 3839 | |
| 3840 | ch = ucontrol->value.enumerated.item[0]; |
| 3841 | if (ch < 0 || ch > spec->multi_ios) |
| 3842 | return -EINVAL; |
| 3843 | if (ch == (spec->ext_channel_count - 1) / 2) |
| 3844 | return 0; |
| 3845 | spec->ext_channel_count = (ch + 1) * 2; |
| 3846 | for (i = 0; i < spec->multi_ios; i++) |
| 3847 | alc_set_multi_io(codec, i, i < ch); |
| 3848 | spec->multiout.max_channels = spec->ext_channel_count; |
Takashi Iwai | 7b1655f | 2011-07-14 15:31:21 +0200 | [diff] [blame] | 3849 | if (spec->need_dac_fix && !spec->const_channel_count) |
| 3850 | spec->multiout.num_dacs = spec->multiout.max_channels / 2; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3851 | return 1; |
| 3852 | } |
| 3853 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 3854 | static const struct snd_kcontrol_new alc_auto_channel_mode_enum = { |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3855 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 3856 | .name = "Channel Mode", |
| 3857 | .info = alc_auto_ch_mode_info, |
| 3858 | .get = alc_auto_ch_mode_get, |
| 3859 | .put = alc_auto_ch_mode_put, |
| 3860 | }; |
| 3861 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3862 | static int alc_auto_add_multi_channel_mode(struct hda_codec *codec) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3863 | { |
| 3864 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3865 | |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3866 | if (spec->multi_ios > 0) { |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3867 | struct snd_kcontrol_new *knew; |
| 3868 | |
| 3869 | knew = alc_kcontrol_new(spec); |
| 3870 | if (!knew) |
| 3871 | return -ENOMEM; |
| 3872 | *knew = alc_auto_channel_mode_enum; |
| 3873 | knew->name = kstrdup("Channel Mode", GFP_KERNEL); |
| 3874 | if (!knew->name) |
| 3875 | return -ENOMEM; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3876 | } |
| 3877 | return 0; |
| 3878 | } |
| 3879 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 3880 | /* filter out invalid adc_nids (and capsrc_nids) that don't give all |
| 3881 | * active input pins |
| 3882 | */ |
| 3883 | static void alc_remove_invalid_adc_nids(struct hda_codec *codec) |
| 3884 | { |
| 3885 | struct alc_spec *spec = codec->spec; |
| 3886 | const struct hda_input_mux *imux; |
| 3887 | hda_nid_t adc_nids[ARRAY_SIZE(spec->private_adc_nids)]; |
| 3888 | hda_nid_t capsrc_nids[ARRAY_SIZE(spec->private_adc_nids)]; |
| 3889 | int i, n, nums; |
| 3890 | |
| 3891 | imux = spec->input_mux; |
| 3892 | if (!imux) |
| 3893 | return; |
| 3894 | if (spec->dyn_adc_switch) |
| 3895 | return; |
| 3896 | |
Takashi Iwai | 26acaf0 | 2012-03-22 14:36:50 +0100 | [diff] [blame] | 3897 | again: |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 3898 | nums = 0; |
| 3899 | for (n = 0; n < spec->num_adc_nids; n++) { |
| 3900 | hda_nid_t cap = spec->private_capsrc_nids[n]; |
| 3901 | int num_conns = snd_hda_get_conn_list(codec, cap, NULL); |
| 3902 | for (i = 0; i < imux->num_items; i++) { |
| 3903 | hda_nid_t pin = spec->imux_pins[i]; |
| 3904 | if (pin) { |
| 3905 | if (get_connection_index(codec, cap, pin) < 0) |
| 3906 | break; |
| 3907 | } else if (num_conns <= imux->items[i].index) |
| 3908 | break; |
| 3909 | } |
| 3910 | if (i >= imux->num_items) { |
| 3911 | adc_nids[nums] = spec->private_adc_nids[n]; |
| 3912 | capsrc_nids[nums++] = cap; |
| 3913 | } |
| 3914 | } |
| 3915 | if (!nums) { |
| 3916 | /* check whether ADC-switch is possible */ |
| 3917 | if (!alc_check_dyn_adc_switch(codec)) { |
Takashi Iwai | 26acaf0 | 2012-03-22 14:36:50 +0100 | [diff] [blame] | 3918 | if (spec->shared_mic_hp) { |
| 3919 | spec->shared_mic_hp = 0; |
| 3920 | spec->private_imux[0].num_items = 1; |
| 3921 | goto again; |
| 3922 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 3923 | printk(KERN_WARNING "hda_codec: %s: no valid ADC found;" |
| 3924 | " using fallback 0x%x\n", |
| 3925 | codec->chip_name, spec->private_adc_nids[0]); |
| 3926 | spec->num_adc_nids = 1; |
| 3927 | spec->auto_mic = 0; |
| 3928 | return; |
| 3929 | } |
| 3930 | } else if (nums != spec->num_adc_nids) { |
| 3931 | memcpy(spec->private_adc_nids, adc_nids, |
| 3932 | nums * sizeof(hda_nid_t)); |
| 3933 | memcpy(spec->private_capsrc_nids, capsrc_nids, |
| 3934 | nums * sizeof(hda_nid_t)); |
| 3935 | spec->num_adc_nids = nums; |
| 3936 | } |
| 3937 | |
| 3938 | if (spec->auto_mic) |
| 3939 | alc_auto_mic_check_imux(codec); /* check auto-mic setups */ |
Takashi Iwai | 26acaf0 | 2012-03-22 14:36:50 +0100 | [diff] [blame] | 3940 | else if (spec->input_mux->num_items == 1 || spec->shared_mic_hp) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 3941 | spec->num_adc_nids = 1; /* reduce to a single ADC */ |
| 3942 | } |
| 3943 | |
| 3944 | /* |
| 3945 | * initialize ADC paths |
| 3946 | */ |
| 3947 | static void alc_auto_init_adc(struct hda_codec *codec, int adc_idx) |
| 3948 | { |
| 3949 | struct alc_spec *spec = codec->spec; |
| 3950 | hda_nid_t nid; |
| 3951 | |
| 3952 | nid = spec->adc_nids[adc_idx]; |
| 3953 | /* mute ADC */ |
Takashi Iwai | 44c0240 | 2011-07-08 15:14:19 +0200 | [diff] [blame] | 3954 | if (nid_has_mute(codec, nid, HDA_INPUT)) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 3955 | snd_hda_codec_write(codec, nid, 0, |
| 3956 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 3957 | AMP_IN_MUTE(0)); |
| 3958 | return; |
| 3959 | } |
| 3960 | if (!spec->capsrc_nids) |
| 3961 | return; |
| 3962 | nid = spec->capsrc_nids[adc_idx]; |
Takashi Iwai | 44c0240 | 2011-07-08 15:14:19 +0200 | [diff] [blame] | 3963 | if (nid_has_mute(codec, nid, HDA_OUTPUT)) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 3964 | snd_hda_codec_write(codec, nid, 0, |
| 3965 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 3966 | AMP_OUT_MUTE); |
| 3967 | } |
| 3968 | |
| 3969 | static void alc_auto_init_input_src(struct hda_codec *codec) |
| 3970 | { |
| 3971 | struct alc_spec *spec = codec->spec; |
| 3972 | int c, nums; |
| 3973 | |
| 3974 | for (c = 0; c < spec->num_adc_nids; c++) |
| 3975 | alc_auto_init_adc(codec, c); |
| 3976 | if (spec->dyn_adc_switch) |
| 3977 | nums = 1; |
| 3978 | else |
| 3979 | nums = spec->num_adc_nids; |
| 3980 | for (c = 0; c < nums; c++) |
Takashi Iwai | 068b939 | 2012-02-25 11:13:16 +0100 | [diff] [blame] | 3981 | alc_mux_select(codec, c, spec->cur_mux[c], true); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 3982 | } |
| 3983 | |
| 3984 | /* add mic boosts if needed */ |
| 3985 | static int alc_auto_add_mic_boost(struct hda_codec *codec) |
| 3986 | { |
| 3987 | struct alc_spec *spec = codec->spec; |
| 3988 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 3989 | int i, err; |
| 3990 | int type_idx = 0; |
| 3991 | hda_nid_t nid; |
| 3992 | const char *prev_label = NULL; |
| 3993 | |
| 3994 | for (i = 0; i < cfg->num_inputs; i++) { |
| 3995 | if (cfg->inputs[i].type > AUTO_PIN_MIC) |
| 3996 | break; |
| 3997 | nid = cfg->inputs[i].pin; |
| 3998 | if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) { |
| 3999 | const char *label; |
| 4000 | char boost_label[32]; |
| 4001 | |
| 4002 | label = hda_get_autocfg_input_label(codec, cfg, i); |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 4003 | if (spec->shared_mic_hp && !strcmp(label, "Misc")) |
| 4004 | label = "Headphone Mic"; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4005 | if (prev_label && !strcmp(label, prev_label)) |
| 4006 | type_idx++; |
| 4007 | else |
| 4008 | type_idx = 0; |
| 4009 | prev_label = label; |
| 4010 | |
| 4011 | snprintf(boost_label, sizeof(boost_label), |
| 4012 | "%s Boost Volume", label); |
| 4013 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
| 4014 | boost_label, type_idx, |
| 4015 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); |
| 4016 | if (err < 0) |
| 4017 | return err; |
| 4018 | } |
| 4019 | } |
| 4020 | return 0; |
| 4021 | } |
| 4022 | |
| 4023 | /* select or unmute the given capsrc route */ |
| 4024 | static void select_or_unmute_capsrc(struct hda_codec *codec, hda_nid_t cap, |
| 4025 | int idx) |
| 4026 | { |
| 4027 | if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) { |
| 4028 | snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx, |
| 4029 | HDA_AMP_MUTE, 0); |
| 4030 | } else if (snd_hda_get_conn_list(codec, cap, NULL) > 1) { |
| 4031 | snd_hda_codec_write_cache(codec, cap, 0, |
| 4032 | AC_VERB_SET_CONNECT_SEL, idx); |
| 4033 | } |
| 4034 | } |
| 4035 | |
| 4036 | /* set the default connection to that pin */ |
| 4037 | static int init_capsrc_for_pin(struct hda_codec *codec, hda_nid_t pin) |
| 4038 | { |
| 4039 | struct alc_spec *spec = codec->spec; |
| 4040 | int i; |
| 4041 | |
| 4042 | if (!pin) |
| 4043 | return 0; |
| 4044 | for (i = 0; i < spec->num_adc_nids; i++) { |
Takashi Iwai | 6107159 | 2011-11-23 07:52:15 +0100 | [diff] [blame] | 4045 | hda_nid_t cap = get_capsrc(spec, i); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4046 | int idx; |
| 4047 | |
| 4048 | idx = get_connection_index(codec, cap, pin); |
| 4049 | if (idx < 0) |
| 4050 | continue; |
| 4051 | select_or_unmute_capsrc(codec, cap, idx); |
| 4052 | return i; /* return the found index */ |
| 4053 | } |
| 4054 | return -1; /* not found */ |
| 4055 | } |
| 4056 | |
| 4057 | /* initialize some special cases for input sources */ |
| 4058 | static void alc_init_special_input_src(struct hda_codec *codec) |
| 4059 | { |
| 4060 | struct alc_spec *spec = codec->spec; |
| 4061 | int i; |
| 4062 | |
| 4063 | for (i = 0; i < spec->autocfg.num_inputs; i++) |
| 4064 | init_capsrc_for_pin(codec, spec->autocfg.inputs[i].pin); |
| 4065 | } |
| 4066 | |
| 4067 | /* assign appropriate capture mixers */ |
| 4068 | static void set_capture_mixer(struct hda_codec *codec) |
| 4069 | { |
| 4070 | struct alc_spec *spec = codec->spec; |
| 4071 | static const struct snd_kcontrol_new *caps[2][3] = { |
| 4072 | { alc_capture_mixer_nosrc1, |
| 4073 | alc_capture_mixer_nosrc2, |
| 4074 | alc_capture_mixer_nosrc3 }, |
| 4075 | { alc_capture_mixer1, |
| 4076 | alc_capture_mixer2, |
| 4077 | alc_capture_mixer3 }, |
| 4078 | }; |
| 4079 | |
| 4080 | /* check whether either of ADC or MUX has a volume control */ |
Takashi Iwai | 44c0240 | 2011-07-08 15:14:19 +0200 | [diff] [blame] | 4081 | if (!nid_has_volume(codec, spec->adc_nids[0], HDA_INPUT)) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4082 | if (!spec->capsrc_nids) |
| 4083 | return; /* no volume */ |
Takashi Iwai | 44c0240 | 2011-07-08 15:14:19 +0200 | [diff] [blame] | 4084 | if (!nid_has_volume(codec, spec->capsrc_nids[0], HDA_OUTPUT)) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4085 | return; /* no volume in capsrc, too */ |
| 4086 | spec->vol_in_capsrc = 1; |
| 4087 | } |
| 4088 | |
| 4089 | if (spec->num_adc_nids > 0) { |
| 4090 | int mux = 0; |
| 4091 | int num_adcs = 0; |
| 4092 | |
| 4093 | if (spec->input_mux && spec->input_mux->num_items > 1) |
| 4094 | mux = 1; |
| 4095 | if (spec->auto_mic) { |
| 4096 | num_adcs = 1; |
| 4097 | mux = 0; |
| 4098 | } else if (spec->dyn_adc_switch) |
| 4099 | num_adcs = 1; |
| 4100 | if (!num_adcs) { |
| 4101 | if (spec->num_adc_nids > 3) |
| 4102 | spec->num_adc_nids = 3; |
| 4103 | else if (!spec->num_adc_nids) |
| 4104 | return; |
| 4105 | num_adcs = spec->num_adc_nids; |
| 4106 | } |
| 4107 | spec->cap_mixer = caps[mux][num_adcs - 1]; |
| 4108 | } |
| 4109 | } |
| 4110 | |
| 4111 | /* |
Takashi Iwai | e477062 | 2011-07-08 11:11:35 +0200 | [diff] [blame] | 4112 | * standard auto-parser initializations |
| 4113 | */ |
| 4114 | static void alc_auto_init_std(struct hda_codec *codec) |
| 4115 | { |
| 4116 | struct alc_spec *spec = codec->spec; |
| 4117 | alc_auto_init_multi_out(codec); |
| 4118 | alc_auto_init_extra_out(codec); |
| 4119 | alc_auto_init_analog_input(codec); |
| 4120 | alc_auto_init_input_src(codec); |
| 4121 | alc_auto_init_digital(codec); |
| 4122 | if (spec->unsol_event) |
| 4123 | alc_inithook(codec); |
| 4124 | } |
| 4125 | |
| 4126 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4127 | * Digital-beep handlers |
| 4128 | */ |
| 4129 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
| 4130 | #define set_beep_amp(spec, nid, idx, dir) \ |
| 4131 | ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir)) |
| 4132 | |
| 4133 | static const struct snd_pci_quirk beep_white_list[] = { |
| 4134 | SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1), |
| 4135 | SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1), |
| 4136 | SND_PCI_QUIRK(0x1043, 0x831a, "EeePC", 1), |
| 4137 | SND_PCI_QUIRK(0x1043, 0x834a, "EeePC", 1), |
Takashi Iwai | 78f8baf | 2012-03-06 14:02:32 +0100 | [diff] [blame] | 4138 | SND_PCI_QUIRK(0x1458, 0xa002, "GA-MA790X", 1), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4139 | SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1), |
| 4140 | {} |
| 4141 | }; |
| 4142 | |
| 4143 | static inline int has_cdefine_beep(struct hda_codec *codec) |
| 4144 | { |
| 4145 | struct alc_spec *spec = codec->spec; |
| 4146 | const struct snd_pci_quirk *q; |
| 4147 | q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list); |
| 4148 | if (q) |
| 4149 | return q->value; |
| 4150 | return spec->cdefine.enable_pcbeep; |
| 4151 | } |
| 4152 | #else |
| 4153 | #define set_beep_amp(spec, nid, idx, dir) /* NOP */ |
| 4154 | #define has_cdefine_beep(codec) 0 |
| 4155 | #endif |
| 4156 | |
| 4157 | /* parse the BIOS configuration and set up the alc_spec */ |
| 4158 | /* return 1 if successful, 0 if the proper config is not found, |
| 4159 | * or a negative error code |
| 4160 | */ |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4161 | static int alc_parse_auto_config(struct hda_codec *codec, |
| 4162 | const hda_nid_t *ignore_nids, |
| 4163 | const hda_nid_t *ssid_nids) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4164 | { |
| 4165 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4166 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4167 | int err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4168 | |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 4169 | err = snd_hda_parse_pin_defcfg(codec, cfg, ignore_nids, |
| 4170 | spec->parse_flags); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4171 | if (err < 0) |
| 4172 | return err; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4173 | if (!cfg->line_outs) { |
| 4174 | if (cfg->dig_outs || cfg->dig_in_pin) { |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4175 | spec->multiout.max_channels = 2; |
| 4176 | spec->no_analog = 1; |
| 4177 | goto dig_only; |
| 4178 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4179 | return 0; /* can't find valid BIOS pin config */ |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4180 | } |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4181 | |
Takashi Iwai | 0650367 | 2011-10-06 08:27:19 +0200 | [diff] [blame] | 4182 | if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT && |
| 4183 | cfg->line_outs <= cfg->hp_outs) { |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4184 | /* use HP as primary out */ |
| 4185 | cfg->speaker_outs = cfg->line_outs; |
| 4186 | memcpy(cfg->speaker_pins, cfg->line_out_pins, |
| 4187 | sizeof(cfg->speaker_pins)); |
| 4188 | cfg->line_outs = cfg->hp_outs; |
| 4189 | memcpy(cfg->line_out_pins, cfg->hp_pins, sizeof(cfg->hp_pins)); |
| 4190 | cfg->hp_outs = 0; |
| 4191 | memset(cfg->hp_pins, 0, sizeof(cfg->hp_pins)); |
| 4192 | cfg->line_out_type = AUTO_PIN_HP_OUT; |
| 4193 | } |
| 4194 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4195 | err = alc_auto_fill_dac_nids(codec); |
| 4196 | if (err < 0) |
| 4197 | return err; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4198 | err = alc_auto_add_multi_channel_mode(codec); |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4199 | if (err < 0) |
| 4200 | return err; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4201 | err = alc_auto_create_multi_out_ctls(codec, cfg); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4202 | if (err < 0) |
| 4203 | return err; |
| 4204 | err = alc_auto_create_hp_out(codec); |
| 4205 | if (err < 0) |
| 4206 | return err; |
| 4207 | err = alc_auto_create_speaker_out(codec); |
| 4208 | if (err < 0) |
| 4209 | return err; |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 4210 | err = alc_auto_create_shared_input(codec); |
| 4211 | if (err < 0) |
| 4212 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4213 | err = alc_auto_create_input_ctls(codec); |
| 4214 | if (err < 0) |
| 4215 | return err; |
| 4216 | |
| 4217 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; |
| 4218 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4219 | dig_only: |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4220 | alc_auto_parse_digital(codec); |
| 4221 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4222 | if (!spec->no_analog) |
| 4223 | alc_remove_invalid_adc_nids(codec); |
| 4224 | |
| 4225 | if (ssid_nids) |
| 4226 | alc_ssid_check(codec, ssid_nids); |
| 4227 | |
| 4228 | if (!spec->no_analog) { |
| 4229 | alc_auto_check_switches(codec); |
| 4230 | err = alc_auto_add_mic_boost(codec); |
| 4231 | if (err < 0) |
| 4232 | return err; |
| 4233 | } |
| 4234 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4235 | if (spec->kctls.list) |
| 4236 | add_mixer(spec, spec->kctls.list); |
| 4237 | |
Takashi Iwai | 070cff4 | 2012-02-21 12:54:17 +0100 | [diff] [blame] | 4238 | if (!spec->no_analog && !spec->cap_mixer) |
| 4239 | set_capture_mixer(codec); |
| 4240 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4241 | return 1; |
| 4242 | } |
| 4243 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 4244 | /* common preparation job for alc_spec */ |
| 4245 | static int alc_alloc_spec(struct hda_codec *codec, hda_nid_t mixer_nid) |
| 4246 | { |
| 4247 | struct alc_spec *spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 4248 | int err; |
| 4249 | |
| 4250 | if (!spec) |
| 4251 | return -ENOMEM; |
| 4252 | codec->spec = spec; |
| 4253 | spec->mixer_nid = mixer_nid; |
| 4254 | |
| 4255 | err = alc_codec_rename_from_preset(codec); |
| 4256 | if (err < 0) { |
| 4257 | kfree(spec); |
| 4258 | return err; |
| 4259 | } |
| 4260 | return 0; |
| 4261 | } |
| 4262 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4263 | static int alc880_parse_auto_config(struct hda_codec *codec) |
| 4264 | { |
| 4265 | static const hda_nid_t alc880_ignore[] = { 0x1d, 0 }; |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 4266 | static const hda_nid_t alc880_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4267 | return alc_parse_auto_config(codec, alc880_ignore, alc880_ssids); |
| 4268 | } |
| 4269 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4270 | /* |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4271 | * ALC880 fix-ups |
| 4272 | */ |
| 4273 | enum { |
Takashi Iwai | 411225a | 2012-02-20 17:48:19 +0100 | [diff] [blame] | 4274 | ALC880_FIXUP_GPIO1, |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4275 | ALC880_FIXUP_GPIO2, |
| 4276 | ALC880_FIXUP_MEDION_RIM, |
Takashi Iwai | dc6af52 | 2012-02-17 16:18:59 +0100 | [diff] [blame] | 4277 | ALC880_FIXUP_LG, |
Takashi Iwai | f02aab5 | 2012-02-17 16:33:56 +0100 | [diff] [blame] | 4278 | ALC880_FIXUP_W810, |
Takashi Iwai | 27e917f | 2012-02-17 17:49:54 +0100 | [diff] [blame] | 4279 | ALC880_FIXUP_EAPD_COEF, |
Takashi Iwai | b9368f5 | 2012-02-17 17:54:44 +0100 | [diff] [blame] | 4280 | ALC880_FIXUP_TCL_S700, |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 4281 | ALC880_FIXUP_VOL_KNOB, |
| 4282 | ALC880_FIXUP_FUJITSU, |
Takashi Iwai | ba53381 | 2012-02-20 16:36:52 +0100 | [diff] [blame] | 4283 | ALC880_FIXUP_F1734, |
Takashi Iwai | 817de92 | 2012-02-20 17:20:48 +0100 | [diff] [blame] | 4284 | ALC880_FIXUP_UNIWILL, |
Takashi Iwai | 967b88c | 2012-02-20 17:31:02 +0100 | [diff] [blame] | 4285 | ALC880_FIXUP_UNIWILL_DIG, |
Takashi Iwai | 96e225f | 2012-02-20 17:41:51 +0100 | [diff] [blame] | 4286 | ALC880_FIXUP_Z71V, |
Takashi Iwai | 67b6ec3 | 2012-02-20 18:20:42 +0100 | [diff] [blame] | 4287 | ALC880_FIXUP_3ST_BASE, |
| 4288 | ALC880_FIXUP_3ST, |
| 4289 | ALC880_FIXUP_3ST_DIG, |
| 4290 | ALC880_FIXUP_5ST_BASE, |
| 4291 | ALC880_FIXUP_5ST, |
| 4292 | ALC880_FIXUP_5ST_DIG, |
| 4293 | ALC880_FIXUP_6ST_BASE, |
| 4294 | ALC880_FIXUP_6ST, |
| 4295 | ALC880_FIXUP_6ST_DIG, |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4296 | }; |
| 4297 | |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 4298 | /* enable the volume-knob widget support on NID 0x21 */ |
| 4299 | static void alc880_fixup_vol_knob(struct hda_codec *codec, |
| 4300 | const struct alc_fixup *fix, int action) |
| 4301 | { |
| 4302 | if (action == ALC_FIXUP_ACT_PROBE) |
| 4303 | snd_hda_jack_detect_enable(codec, 0x21, ALC_DCVOL_EVENT); |
| 4304 | } |
| 4305 | |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4306 | static const struct alc_fixup alc880_fixups[] = { |
Takashi Iwai | 411225a | 2012-02-20 17:48:19 +0100 | [diff] [blame] | 4307 | [ALC880_FIXUP_GPIO1] = { |
| 4308 | .type = ALC_FIXUP_VERBS, |
| 4309 | .v.verbs = alc_gpio1_init_verbs, |
| 4310 | }, |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4311 | [ALC880_FIXUP_GPIO2] = { |
| 4312 | .type = ALC_FIXUP_VERBS, |
| 4313 | .v.verbs = alc_gpio2_init_verbs, |
| 4314 | }, |
| 4315 | [ALC880_FIXUP_MEDION_RIM] = { |
| 4316 | .type = ALC_FIXUP_VERBS, |
| 4317 | .v.verbs = (const struct hda_verb[]) { |
| 4318 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 4319 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 }, |
| 4320 | { } |
| 4321 | }, |
| 4322 | .chained = true, |
| 4323 | .chain_id = ALC880_FIXUP_GPIO2, |
| 4324 | }, |
Takashi Iwai | dc6af52 | 2012-02-17 16:18:59 +0100 | [diff] [blame] | 4325 | [ALC880_FIXUP_LG] = { |
| 4326 | .type = ALC_FIXUP_PINS, |
| 4327 | .v.pins = (const struct alc_pincfg[]) { |
| 4328 | /* disable bogus unused pins */ |
| 4329 | { 0x16, 0x411111f0 }, |
| 4330 | { 0x18, 0x411111f0 }, |
| 4331 | { 0x1a, 0x411111f0 }, |
| 4332 | { } |
| 4333 | } |
| 4334 | }, |
Takashi Iwai | f02aab5 | 2012-02-17 16:33:56 +0100 | [diff] [blame] | 4335 | [ALC880_FIXUP_W810] = { |
| 4336 | .type = ALC_FIXUP_PINS, |
| 4337 | .v.pins = (const struct alc_pincfg[]) { |
| 4338 | /* disable bogus unused pins */ |
| 4339 | { 0x17, 0x411111f0 }, |
| 4340 | { } |
| 4341 | }, |
| 4342 | .chained = true, |
| 4343 | .chain_id = ALC880_FIXUP_GPIO2, |
| 4344 | }, |
Takashi Iwai | 27e917f | 2012-02-17 17:49:54 +0100 | [diff] [blame] | 4345 | [ALC880_FIXUP_EAPD_COEF] = { |
| 4346 | .type = ALC_FIXUP_VERBS, |
| 4347 | .v.verbs = (const struct hda_verb[]) { |
| 4348 | /* change to EAPD mode */ |
| 4349 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 4350 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 }, |
| 4351 | {} |
| 4352 | }, |
| 4353 | }, |
Takashi Iwai | b9368f5 | 2012-02-17 17:54:44 +0100 | [diff] [blame] | 4354 | [ALC880_FIXUP_TCL_S700] = { |
| 4355 | .type = ALC_FIXUP_VERBS, |
| 4356 | .v.verbs = (const struct hda_verb[]) { |
| 4357 | /* change to EAPD mode */ |
| 4358 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 4359 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 }, |
| 4360 | {} |
| 4361 | }, |
| 4362 | .chained = true, |
| 4363 | .chain_id = ALC880_FIXUP_GPIO2, |
| 4364 | }, |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 4365 | [ALC880_FIXUP_VOL_KNOB] = { |
| 4366 | .type = ALC_FIXUP_FUNC, |
| 4367 | .v.func = alc880_fixup_vol_knob, |
| 4368 | }, |
| 4369 | [ALC880_FIXUP_FUJITSU] = { |
| 4370 | /* override all pins as BIOS on old Amilo is broken */ |
| 4371 | .type = ALC_FIXUP_PINS, |
| 4372 | .v.pins = (const struct alc_pincfg[]) { |
| 4373 | { 0x14, 0x0121411f }, /* HP */ |
| 4374 | { 0x15, 0x99030120 }, /* speaker */ |
| 4375 | { 0x16, 0x99030130 }, /* bass speaker */ |
| 4376 | { 0x17, 0x411111f0 }, /* N/A */ |
| 4377 | { 0x18, 0x411111f0 }, /* N/A */ |
| 4378 | { 0x19, 0x01a19950 }, /* mic-in */ |
| 4379 | { 0x1a, 0x411111f0 }, /* N/A */ |
| 4380 | { 0x1b, 0x411111f0 }, /* N/A */ |
| 4381 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4382 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4383 | { 0x1e, 0x01454140 }, /* SPDIF out */ |
| 4384 | { } |
| 4385 | }, |
| 4386 | .chained = true, |
| 4387 | .chain_id = ALC880_FIXUP_VOL_KNOB, |
| 4388 | }, |
Takashi Iwai | ba53381 | 2012-02-20 16:36:52 +0100 | [diff] [blame] | 4389 | [ALC880_FIXUP_F1734] = { |
| 4390 | /* almost compatible with FUJITSU, but no bass and SPDIF */ |
| 4391 | .type = ALC_FIXUP_PINS, |
| 4392 | .v.pins = (const struct alc_pincfg[]) { |
| 4393 | { 0x14, 0x0121411f }, /* HP */ |
| 4394 | { 0x15, 0x99030120 }, /* speaker */ |
| 4395 | { 0x16, 0x411111f0 }, /* N/A */ |
| 4396 | { 0x17, 0x411111f0 }, /* N/A */ |
| 4397 | { 0x18, 0x411111f0 }, /* N/A */ |
| 4398 | { 0x19, 0x01a19950 }, /* mic-in */ |
| 4399 | { 0x1a, 0x411111f0 }, /* N/A */ |
| 4400 | { 0x1b, 0x411111f0 }, /* N/A */ |
| 4401 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4402 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4403 | { 0x1e, 0x411111f0 }, /* N/A */ |
| 4404 | { } |
| 4405 | }, |
| 4406 | .chained = true, |
| 4407 | .chain_id = ALC880_FIXUP_VOL_KNOB, |
| 4408 | }, |
Takashi Iwai | 817de92 | 2012-02-20 17:20:48 +0100 | [diff] [blame] | 4409 | [ALC880_FIXUP_UNIWILL] = { |
| 4410 | /* need to fix HP and speaker pins to be parsed correctly */ |
| 4411 | .type = ALC_FIXUP_PINS, |
| 4412 | .v.pins = (const struct alc_pincfg[]) { |
| 4413 | { 0x14, 0x0121411f }, /* HP */ |
| 4414 | { 0x15, 0x99030120 }, /* speaker */ |
| 4415 | { 0x16, 0x99030130 }, /* bass speaker */ |
| 4416 | { } |
| 4417 | }, |
| 4418 | }, |
Takashi Iwai | 967b88c | 2012-02-20 17:31:02 +0100 | [diff] [blame] | 4419 | [ALC880_FIXUP_UNIWILL_DIG] = { |
| 4420 | .type = ALC_FIXUP_PINS, |
| 4421 | .v.pins = (const struct alc_pincfg[]) { |
| 4422 | /* disable bogus unused pins */ |
| 4423 | { 0x17, 0x411111f0 }, |
| 4424 | { 0x19, 0x411111f0 }, |
| 4425 | { 0x1b, 0x411111f0 }, |
| 4426 | { 0x1f, 0x411111f0 }, |
| 4427 | { } |
| 4428 | } |
| 4429 | }, |
Takashi Iwai | 96e225f | 2012-02-20 17:41:51 +0100 | [diff] [blame] | 4430 | [ALC880_FIXUP_Z71V] = { |
| 4431 | .type = ALC_FIXUP_PINS, |
| 4432 | .v.pins = (const struct alc_pincfg[]) { |
| 4433 | /* set up the whole pins as BIOS is utterly broken */ |
| 4434 | { 0x14, 0x99030120 }, /* speaker */ |
| 4435 | { 0x15, 0x0121411f }, /* HP */ |
| 4436 | { 0x16, 0x411111f0 }, /* N/A */ |
| 4437 | { 0x17, 0x411111f0 }, /* N/A */ |
| 4438 | { 0x18, 0x01a19950 }, /* mic-in */ |
| 4439 | { 0x19, 0x411111f0 }, /* N/A */ |
| 4440 | { 0x1a, 0x01813031 }, /* line-in */ |
| 4441 | { 0x1b, 0x411111f0 }, /* N/A */ |
| 4442 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4443 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4444 | { 0x1e, 0x0144111e }, /* SPDIF */ |
| 4445 | { } |
| 4446 | } |
| 4447 | }, |
Takashi Iwai | 67b6ec3 | 2012-02-20 18:20:42 +0100 | [diff] [blame] | 4448 | [ALC880_FIXUP_3ST_BASE] = { |
| 4449 | .type = ALC_FIXUP_PINS, |
| 4450 | .v.pins = (const struct alc_pincfg[]) { |
| 4451 | { 0x14, 0x01014010 }, /* line-out */ |
| 4452 | { 0x15, 0x411111f0 }, /* N/A */ |
| 4453 | { 0x16, 0x411111f0 }, /* N/A */ |
| 4454 | { 0x17, 0x411111f0 }, /* N/A */ |
| 4455 | { 0x18, 0x01a19c30 }, /* mic-in */ |
| 4456 | { 0x19, 0x0121411f }, /* HP */ |
| 4457 | { 0x1a, 0x01813031 }, /* line-in */ |
| 4458 | { 0x1b, 0x02a19c40 }, /* front-mic */ |
| 4459 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4460 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4461 | /* 0x1e is filled in below */ |
| 4462 | { 0x1f, 0x411111f0 }, /* N/A */ |
| 4463 | { } |
| 4464 | } |
| 4465 | }, |
| 4466 | [ALC880_FIXUP_3ST] = { |
| 4467 | .type = ALC_FIXUP_PINS, |
| 4468 | .v.pins = (const struct alc_pincfg[]) { |
| 4469 | { 0x1e, 0x411111f0 }, /* N/A */ |
| 4470 | { } |
| 4471 | }, |
| 4472 | .chained = true, |
| 4473 | .chain_id = ALC880_FIXUP_3ST_BASE, |
| 4474 | }, |
| 4475 | [ALC880_FIXUP_3ST_DIG] = { |
| 4476 | .type = ALC_FIXUP_PINS, |
| 4477 | .v.pins = (const struct alc_pincfg[]) { |
| 4478 | { 0x1e, 0x0144111e }, /* SPDIF */ |
| 4479 | { } |
| 4480 | }, |
| 4481 | .chained = true, |
| 4482 | .chain_id = ALC880_FIXUP_3ST_BASE, |
| 4483 | }, |
| 4484 | [ALC880_FIXUP_5ST_BASE] = { |
| 4485 | .type = ALC_FIXUP_PINS, |
| 4486 | .v.pins = (const struct alc_pincfg[]) { |
| 4487 | { 0x14, 0x01014010 }, /* front */ |
| 4488 | { 0x15, 0x411111f0 }, /* N/A */ |
| 4489 | { 0x16, 0x01011411 }, /* CLFE */ |
| 4490 | { 0x17, 0x01016412 }, /* surr */ |
| 4491 | { 0x18, 0x01a19c30 }, /* mic-in */ |
| 4492 | { 0x19, 0x0121411f }, /* HP */ |
| 4493 | { 0x1a, 0x01813031 }, /* line-in */ |
| 4494 | { 0x1b, 0x02a19c40 }, /* front-mic */ |
| 4495 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4496 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4497 | /* 0x1e is filled in below */ |
| 4498 | { 0x1f, 0x411111f0 }, /* N/A */ |
| 4499 | { } |
| 4500 | } |
| 4501 | }, |
| 4502 | [ALC880_FIXUP_5ST] = { |
| 4503 | .type = ALC_FIXUP_PINS, |
| 4504 | .v.pins = (const struct alc_pincfg[]) { |
| 4505 | { 0x1e, 0x411111f0 }, /* N/A */ |
| 4506 | { } |
| 4507 | }, |
| 4508 | .chained = true, |
| 4509 | .chain_id = ALC880_FIXUP_5ST_BASE, |
| 4510 | }, |
| 4511 | [ALC880_FIXUP_5ST_DIG] = { |
| 4512 | .type = ALC_FIXUP_PINS, |
| 4513 | .v.pins = (const struct alc_pincfg[]) { |
| 4514 | { 0x1e, 0x0144111e }, /* SPDIF */ |
| 4515 | { } |
| 4516 | }, |
| 4517 | .chained = true, |
| 4518 | .chain_id = ALC880_FIXUP_5ST_BASE, |
| 4519 | }, |
| 4520 | [ALC880_FIXUP_6ST_BASE] = { |
| 4521 | .type = ALC_FIXUP_PINS, |
| 4522 | .v.pins = (const struct alc_pincfg[]) { |
| 4523 | { 0x14, 0x01014010 }, /* front */ |
| 4524 | { 0x15, 0x01016412 }, /* surr */ |
| 4525 | { 0x16, 0x01011411 }, /* CLFE */ |
| 4526 | { 0x17, 0x01012414 }, /* side */ |
| 4527 | { 0x18, 0x01a19c30 }, /* mic-in */ |
| 4528 | { 0x19, 0x02a19c40 }, /* front-mic */ |
| 4529 | { 0x1a, 0x01813031 }, /* line-in */ |
| 4530 | { 0x1b, 0x0121411f }, /* HP */ |
| 4531 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4532 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4533 | /* 0x1e is filled in below */ |
| 4534 | { 0x1f, 0x411111f0 }, /* N/A */ |
| 4535 | { } |
| 4536 | } |
| 4537 | }, |
| 4538 | [ALC880_FIXUP_6ST] = { |
| 4539 | .type = ALC_FIXUP_PINS, |
| 4540 | .v.pins = (const struct alc_pincfg[]) { |
| 4541 | { 0x1e, 0x411111f0 }, /* N/A */ |
| 4542 | { } |
| 4543 | }, |
| 4544 | .chained = true, |
| 4545 | .chain_id = ALC880_FIXUP_6ST_BASE, |
| 4546 | }, |
| 4547 | [ALC880_FIXUP_6ST_DIG] = { |
| 4548 | .type = ALC_FIXUP_PINS, |
| 4549 | .v.pins = (const struct alc_pincfg[]) { |
| 4550 | { 0x1e, 0x0144111e }, /* SPDIF */ |
| 4551 | { } |
| 4552 | }, |
| 4553 | .chained = true, |
| 4554 | .chain_id = ALC880_FIXUP_6ST_BASE, |
| 4555 | }, |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4556 | }; |
| 4557 | |
| 4558 | static const struct snd_pci_quirk alc880_fixup_tbl[] = { |
Takashi Iwai | f02aab5 | 2012-02-17 16:33:56 +0100 | [diff] [blame] | 4559 | SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_FIXUP_W810), |
Takashi Iwai | 96e225f | 2012-02-20 17:41:51 +0100 | [diff] [blame] | 4560 | SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_FIXUP_Z71V), |
Takashi Iwai | 29e3fdc | 2012-02-20 17:56:57 +0100 | [diff] [blame] | 4561 | SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_FIXUP_GPIO1), |
| 4562 | SND_PCI_QUIRK(0x1558, 0x5401, "Clevo GPIO2", ALC880_FIXUP_GPIO2), |
Takashi Iwai | 27e917f | 2012-02-17 17:49:54 +0100 | [diff] [blame] | 4563 | SND_PCI_QUIRK_VENDOR(0x1558, "Clevo", ALC880_FIXUP_EAPD_COEF), |
Takashi Iwai | 967b88c | 2012-02-20 17:31:02 +0100 | [diff] [blame] | 4564 | SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_FIXUP_UNIWILL_DIG), |
Takashi Iwai | ba53381 | 2012-02-20 16:36:52 +0100 | [diff] [blame] | 4565 | SND_PCI_QUIRK(0x1584, 0x9054, "Uniwill", ALC880_FIXUP_F1734), |
Takashi Iwai | 817de92 | 2012-02-20 17:20:48 +0100 | [diff] [blame] | 4566 | SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_FIXUP_UNIWILL), |
Takashi Iwai | 7833c7e | 2012-02-20 17:11:38 +0100 | [diff] [blame] | 4567 | SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_FIXUP_VOL_KNOB), |
Takashi Iwai | f02aab5 | 2012-02-17 16:33:56 +0100 | [diff] [blame] | 4568 | SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_FIXUP_W810), |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4569 | SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_FIXUP_MEDION_RIM), |
Takashi Iwai | ba53381 | 2012-02-20 16:36:52 +0100 | [diff] [blame] | 4570 | SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_FIXUP_F1734), |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 4571 | SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FIXUP_FUJITSU), |
Takashi Iwai | ba53381 | 2012-02-20 16:36:52 +0100 | [diff] [blame] | 4572 | SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_FIXUP_F1734), |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 4573 | SND_PCI_QUIRK(0x1734, 0x10b0, "FSC Amilo Pi1556", ALC880_FIXUP_FUJITSU), |
Takashi Iwai | dc6af52 | 2012-02-17 16:18:59 +0100 | [diff] [blame] | 4574 | SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_FIXUP_LG), |
| 4575 | SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_FIXUP_LG), |
| 4576 | SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_FIXUP_LG), |
Takashi Iwai | b9368f5 | 2012-02-17 17:54:44 +0100 | [diff] [blame] | 4577 | SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_FIXUP_TCL_S700), |
Takashi Iwai | 67b6ec3 | 2012-02-20 18:20:42 +0100 | [diff] [blame] | 4578 | |
| 4579 | /* Below is the copied entries from alc880_quirks.c. |
| 4580 | * It's not quite sure whether BIOS sets the correct pin-config table |
| 4581 | * on these machines, thus they are kept to be compatible with |
| 4582 | * the old static quirks. Once when it's confirmed to work without |
| 4583 | * these overrides, it'd be better to remove. |
| 4584 | */ |
| 4585 | SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_FIXUP_5ST_DIG), |
| 4586 | SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_FIXUP_6ST), |
| 4587 | SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_FIXUP_3ST_DIG), |
| 4588 | SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_FIXUP_6ST_DIG), |
| 4589 | SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_FIXUP_6ST_DIG), |
| 4590 | SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_FIXUP_6ST_DIG), |
| 4591 | SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_FIXUP_3ST_DIG), |
| 4592 | SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_FIXUP_3ST), |
| 4593 | SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_FIXUP_6ST_DIG), |
| 4594 | SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_FIXUP_3ST), |
| 4595 | SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_FIXUP_3ST), |
| 4596 | SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_FIXUP_5ST), |
| 4597 | SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_FIXUP_5ST), |
| 4598 | SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_FIXUP_5ST), |
| 4599 | SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_FIXUP_6ST_DIG), |
| 4600 | SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_FIXUP_6ST_DIG), |
| 4601 | SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_FIXUP_6ST_DIG), |
| 4602 | SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_FIXUP_6ST_DIG), |
| 4603 | SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_FIXUP_5ST_DIG), |
| 4604 | SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_FIXUP_5ST_DIG), |
| 4605 | SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_FIXUP_5ST_DIG), |
| 4606 | SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_FIXUP_6ST_DIG), /* broken BIOS */ |
| 4607 | SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_FIXUP_6ST_DIG), |
| 4608 | SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4609 | SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4610 | SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4611 | SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_FIXUP_3ST_DIG), |
| 4612 | SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4613 | SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_FIXUP_3ST_DIG), |
| 4614 | SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_FIXUP_3ST_DIG), |
| 4615 | SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4616 | SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4617 | SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4618 | /* default Intel */ |
| 4619 | SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_FIXUP_3ST), |
| 4620 | SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_FIXUP_5ST_DIG), |
| 4621 | SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_FIXUP_6ST_DIG), |
| 4622 | {} |
| 4623 | }; |
| 4624 | |
| 4625 | static const struct alc_model_fixup alc880_fixup_models[] = { |
| 4626 | {.id = ALC880_FIXUP_3ST, .name = "3stack"}, |
| 4627 | {.id = ALC880_FIXUP_3ST_DIG, .name = "3stack-digout"}, |
| 4628 | {.id = ALC880_FIXUP_5ST, .name = "5stack"}, |
| 4629 | {.id = ALC880_FIXUP_5ST_DIG, .name = "5stack-digout"}, |
| 4630 | {.id = ALC880_FIXUP_6ST, .name = "6stack"}, |
| 4631 | {.id = ALC880_FIXUP_6ST_DIG, .name = "6stack-digout"}, |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4632 | {} |
| 4633 | }; |
| 4634 | |
| 4635 | |
| 4636 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4637 | * OK, here we have finally the patch for ALC880 |
| 4638 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4639 | static int patch_alc880(struct hda_codec *codec) |
| 4640 | { |
| 4641 | struct alc_spec *spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4642 | int err; |
| 4643 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 4644 | err = alc_alloc_spec(codec, 0x0b); |
| 4645 | if (err < 0) |
| 4646 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4647 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 4648 | spec = codec->spec; |
Takashi Iwai | 7b1655f | 2011-07-14 15:31:21 +0200 | [diff] [blame] | 4649 | spec->need_dac_fix = 1; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4650 | |
Takashi Iwai | 67b6ec3 | 2012-02-20 18:20:42 +0100 | [diff] [blame] | 4651 | alc_pick_fixup(codec, alc880_fixup_models, alc880_fixup_tbl, |
| 4652 | alc880_fixups); |
| 4653 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4654 | |
Takashi Iwai | 67b6ec3 | 2012-02-20 18:20:42 +0100 | [diff] [blame] | 4655 | /* automatic parse from the BIOS config */ |
| 4656 | err = alc880_parse_auto_config(codec); |
| 4657 | if (err < 0) |
| 4658 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4659 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4660 | if (!spec->no_analog) { |
| 4661 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 4662 | if (err < 0) |
| 4663 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4664 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
| 4665 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4666 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4667 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4668 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 4669 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 4670 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4671 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 4672 | |
| 4673 | error: |
| 4674 | alc_free(codec); |
| 4675 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4676 | } |
| 4677 | |
| 4678 | |
| 4679 | /* |
| 4680 | * ALC260 support |
| 4681 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4682 | static int alc260_parse_auto_config(struct hda_codec *codec) |
| 4683 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4684 | static const hda_nid_t alc260_ignore[] = { 0x17, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4685 | static const hda_nid_t alc260_ssids[] = { 0x10, 0x15, 0x0f, 0 }; |
| 4686 | return alc_parse_auto_config(codec, alc260_ignore, alc260_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4687 | } |
| 4688 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4689 | /* |
| 4690 | * Pin config fixes |
| 4691 | */ |
| 4692 | enum { |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 4693 | ALC260_FIXUP_HP_DC5750, |
| 4694 | ALC260_FIXUP_HP_PIN_0F, |
| 4695 | ALC260_FIXUP_COEF, |
Takashi Iwai | 15317ab | 2012-02-16 12:02:53 +0100 | [diff] [blame] | 4696 | ALC260_FIXUP_GPIO1, |
Takashi Iwai | 20f7d92 | 2012-02-16 12:35:16 +0100 | [diff] [blame] | 4697 | ALC260_FIXUP_GPIO1_TOGGLE, |
| 4698 | ALC260_FIXUP_REPLACER, |
Takashi Iwai | 0a1c4fa | 2012-02-16 12:42:30 +0100 | [diff] [blame] | 4699 | ALC260_FIXUP_HP_B1900, |
Takashi Iwai | 118cb4a | 2012-04-19 07:33:27 +0200 | [diff] [blame] | 4700 | ALC260_FIXUP_KN1, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4701 | }; |
| 4702 | |
Takashi Iwai | 20f7d92 | 2012-02-16 12:35:16 +0100 | [diff] [blame] | 4703 | static void alc260_gpio1_automute(struct hda_codec *codec) |
| 4704 | { |
| 4705 | struct alc_spec *spec = codec->spec; |
| 4706 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, |
| 4707 | spec->hp_jack_present); |
| 4708 | } |
| 4709 | |
| 4710 | static void alc260_fixup_gpio1_toggle(struct hda_codec *codec, |
| 4711 | const struct alc_fixup *fix, int action) |
| 4712 | { |
| 4713 | struct alc_spec *spec = codec->spec; |
| 4714 | if (action == ALC_FIXUP_ACT_PROBE) { |
| 4715 | /* although the machine has only one output pin, we need to |
| 4716 | * toggle GPIO1 according to the jack state |
| 4717 | */ |
| 4718 | spec->automute_hook = alc260_gpio1_automute; |
| 4719 | spec->detect_hp = 1; |
| 4720 | spec->automute_speaker = 1; |
| 4721 | spec->autocfg.hp_pins[0] = 0x0f; /* copy it for automute */ |
| 4722 | snd_hda_jack_detect_enable(codec, 0x0f, ALC_HP_EVENT); |
| 4723 | spec->unsol_event = alc_sku_unsol_event; |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame^] | 4724 | snd_hda_gen_add_verbs(&spec->gen, alc_gpio1_init_verbs); |
Takashi Iwai | 20f7d92 | 2012-02-16 12:35:16 +0100 | [diff] [blame] | 4725 | } |
| 4726 | } |
| 4727 | |
Takashi Iwai | 118cb4a | 2012-04-19 07:33:27 +0200 | [diff] [blame] | 4728 | static void alc260_fixup_kn1(struct hda_codec *codec, |
| 4729 | const struct alc_fixup *fix, int action) |
| 4730 | { |
| 4731 | struct alc_spec *spec = codec->spec; |
| 4732 | static const struct alc_pincfg pincfgs[] = { |
| 4733 | { 0x0f, 0x02214000 }, /* HP/speaker */ |
| 4734 | { 0x12, 0x90a60160 }, /* int mic */ |
| 4735 | { 0x13, 0x02a19000 }, /* ext mic */ |
| 4736 | { 0x18, 0x01446000 }, /* SPDIF out */ |
| 4737 | /* disable bogus I/O pins */ |
| 4738 | { 0x10, 0x411111f0 }, |
| 4739 | { 0x11, 0x411111f0 }, |
| 4740 | { 0x14, 0x411111f0 }, |
| 4741 | { 0x15, 0x411111f0 }, |
| 4742 | { 0x16, 0x411111f0 }, |
| 4743 | { 0x17, 0x411111f0 }, |
| 4744 | { 0x19, 0x411111f0 }, |
| 4745 | { } |
| 4746 | }; |
| 4747 | |
| 4748 | switch (action) { |
| 4749 | case ALC_FIXUP_ACT_PRE_PROBE: |
| 4750 | alc_apply_pincfgs(codec, pincfgs); |
| 4751 | break; |
| 4752 | case ALC_FIXUP_ACT_PROBE: |
| 4753 | spec->init_amp = ALC_INIT_NONE; |
| 4754 | break; |
| 4755 | } |
| 4756 | } |
| 4757 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4758 | static const struct alc_fixup alc260_fixups[] = { |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 4759 | [ALC260_FIXUP_HP_DC5750] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4760 | .type = ALC_FIXUP_PINS, |
| 4761 | .v.pins = (const struct alc_pincfg[]) { |
| 4762 | { 0x11, 0x90130110 }, /* speaker */ |
| 4763 | { } |
| 4764 | } |
| 4765 | }, |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 4766 | [ALC260_FIXUP_HP_PIN_0F] = { |
| 4767 | .type = ALC_FIXUP_PINS, |
| 4768 | .v.pins = (const struct alc_pincfg[]) { |
| 4769 | { 0x0f, 0x01214000 }, /* HP */ |
| 4770 | { } |
| 4771 | } |
| 4772 | }, |
| 4773 | [ALC260_FIXUP_COEF] = { |
| 4774 | .type = ALC_FIXUP_VERBS, |
| 4775 | .v.verbs = (const struct hda_verb[]) { |
| 4776 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 4777 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3040 }, |
| 4778 | { } |
| 4779 | }, |
| 4780 | .chained = true, |
| 4781 | .chain_id = ALC260_FIXUP_HP_PIN_0F, |
| 4782 | }, |
Takashi Iwai | 15317ab | 2012-02-16 12:02:53 +0100 | [diff] [blame] | 4783 | [ALC260_FIXUP_GPIO1] = { |
| 4784 | .type = ALC_FIXUP_VERBS, |
| 4785 | .v.verbs = alc_gpio1_init_verbs, |
| 4786 | }, |
Takashi Iwai | 20f7d92 | 2012-02-16 12:35:16 +0100 | [diff] [blame] | 4787 | [ALC260_FIXUP_GPIO1_TOGGLE] = { |
| 4788 | .type = ALC_FIXUP_FUNC, |
| 4789 | .v.func = alc260_fixup_gpio1_toggle, |
| 4790 | .chained = true, |
| 4791 | .chain_id = ALC260_FIXUP_HP_PIN_0F, |
| 4792 | }, |
| 4793 | [ALC260_FIXUP_REPLACER] = { |
| 4794 | .type = ALC_FIXUP_VERBS, |
| 4795 | .v.verbs = (const struct hda_verb[]) { |
| 4796 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 4797 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 }, |
| 4798 | { } |
| 4799 | }, |
| 4800 | .chained = true, |
| 4801 | .chain_id = ALC260_FIXUP_GPIO1_TOGGLE, |
| 4802 | }, |
Takashi Iwai | 0a1c4fa | 2012-02-16 12:42:30 +0100 | [diff] [blame] | 4803 | [ALC260_FIXUP_HP_B1900] = { |
| 4804 | .type = ALC_FIXUP_FUNC, |
| 4805 | .v.func = alc260_fixup_gpio1_toggle, |
| 4806 | .chained = true, |
| 4807 | .chain_id = ALC260_FIXUP_COEF, |
Takashi Iwai | 118cb4a | 2012-04-19 07:33:27 +0200 | [diff] [blame] | 4808 | }, |
| 4809 | [ALC260_FIXUP_KN1] = { |
| 4810 | .type = ALC_FIXUP_FUNC, |
| 4811 | .v.func = alc260_fixup_kn1, |
| 4812 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4813 | }; |
| 4814 | |
| 4815 | static const struct snd_pci_quirk alc260_fixup_tbl[] = { |
Takashi Iwai | 15317ab | 2012-02-16 12:02:53 +0100 | [diff] [blame] | 4816 | SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_FIXUP_GPIO1), |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 4817 | SND_PCI_QUIRK(0x1025, 0x007f, "Acer Aspire 9500", ALC260_FIXUP_COEF), |
Takashi Iwai | 15317ab | 2012-02-16 12:02:53 +0100 | [diff] [blame] | 4818 | SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_FIXUP_GPIO1), |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 4819 | SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", ALC260_FIXUP_HP_DC5750), |
Takashi Iwai | 0a1c4fa | 2012-02-16 12:42:30 +0100 | [diff] [blame] | 4820 | SND_PCI_QUIRK(0x103c, 0x30ba, "HP Presario B1900", ALC260_FIXUP_HP_B1900), |
Takashi Iwai | b1f5808 | 2012-02-16 12:45:03 +0100 | [diff] [blame] | 4821 | SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FIXUP_GPIO1), |
Takashi Iwai | 118cb4a | 2012-04-19 07:33:27 +0200 | [diff] [blame] | 4822 | SND_PCI_QUIRK(0x152d, 0x0729, "Quanta KN1", ALC260_FIXUP_KN1), |
Takashi Iwai | 20f7d92 | 2012-02-16 12:35:16 +0100 | [diff] [blame] | 4823 | SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_FIXUP_REPLACER), |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 4824 | SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_FIXUP_COEF), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4825 | {} |
| 4826 | }; |
| 4827 | |
| 4828 | /* |
| 4829 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4830 | static int patch_alc260(struct hda_codec *codec) |
| 4831 | { |
| 4832 | struct alc_spec *spec; |
Takashi Iwai | c3c2c9e | 2012-02-16 12:59:55 +0100 | [diff] [blame] | 4833 | int err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4834 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 4835 | err = alc_alloc_spec(codec, 0x07); |
| 4836 | if (err < 0) |
| 4837 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4838 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 4839 | spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4840 | |
Takashi Iwai | c3c2c9e | 2012-02-16 12:59:55 +0100 | [diff] [blame] | 4841 | alc_pick_fixup(codec, NULL, alc260_fixup_tbl, alc260_fixups); |
| 4842 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4843 | |
Takashi Iwai | c3c2c9e | 2012-02-16 12:59:55 +0100 | [diff] [blame] | 4844 | /* automatic parse from the BIOS config */ |
| 4845 | err = alc260_parse_auto_config(codec); |
| 4846 | if (err < 0) |
| 4847 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4848 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4849 | if (!spec->no_analog) { |
| 4850 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 4851 | if (err < 0) |
| 4852 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4853 | set_beep_amp(spec, 0x07, 0x05, HDA_INPUT); |
| 4854 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4855 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4856 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4857 | spec->shutup = alc_eapd_shutup; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4858 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 4859 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 4860 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4861 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 4862 | |
| 4863 | error: |
| 4864 | alc_free(codec); |
| 4865 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4866 | } |
| 4867 | |
| 4868 | |
| 4869 | /* |
| 4870 | * ALC882/883/885/888/889 support |
| 4871 | * |
| 4872 | * ALC882 is almost identical with ALC880 but has cleaner and more flexible |
| 4873 | * configuration. Each pin widget can choose any input DACs and a mixer. |
| 4874 | * Each ADC is connected from a mixer of all inputs. This makes possible |
| 4875 | * 6-channel independent captures. |
| 4876 | * |
| 4877 | * In addition, an independent DAC for the multi-playback (not used in this |
| 4878 | * driver yet). |
| 4879 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4880 | |
| 4881 | /* |
| 4882 | * Pin config fixes |
| 4883 | */ |
| 4884 | enum { |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 4885 | ALC882_FIXUP_ABIT_AW9D_MAX, |
| 4886 | ALC882_FIXUP_LENOVO_Y530, |
| 4887 | ALC882_FIXUP_PB_M5210, |
| 4888 | ALC882_FIXUP_ACER_ASPIRE_7736, |
| 4889 | ALC882_FIXUP_ASUS_W90V, |
Marton Balint | 8f23921 | 2012-03-05 21:33:23 +0100 | [diff] [blame] | 4890 | ALC889_FIXUP_CD, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 4891 | ALC889_FIXUP_VAIO_TT, |
Takashi Iwai | 0e7cc2e | 2011-11-09 12:42:48 +0100 | [diff] [blame] | 4892 | ALC888_FIXUP_EEE1601, |
Takashi Iwai | 177943a | 2011-11-09 12:55:18 +0100 | [diff] [blame] | 4893 | ALC882_FIXUP_EAPD, |
Takashi Iwai | 7a6069b | 2011-11-09 15:22:01 +0100 | [diff] [blame] | 4894 | ALC883_FIXUP_EAPD, |
Takashi Iwai | 8812c4f | 2011-11-09 17:39:15 +0100 | [diff] [blame] | 4895 | ALC883_FIXUP_ACER_EAPD, |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 4896 | ALC882_FIXUP_GPIO1, |
| 4897 | ALC882_FIXUP_GPIO2, |
Takashi Iwai | eb844d5 | 2011-11-09 18:03:07 +0100 | [diff] [blame] | 4898 | ALC882_FIXUP_GPIO3, |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 4899 | ALC889_FIXUP_COEF, |
| 4900 | ALC882_FIXUP_ASUS_W2JC, |
Takashi Iwai | c3e837b | 2011-11-10 16:01:47 +0100 | [diff] [blame] | 4901 | ALC882_FIXUP_ACER_ASPIRE_4930G, |
| 4902 | ALC882_FIXUP_ACER_ASPIRE_8930G, |
| 4903 | ALC882_FIXUP_ASPIRE_8930G_VERBS, |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 4904 | ALC885_FIXUP_MACPRO_GPIO, |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 4905 | ALC889_FIXUP_DAC_ROUTE, |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 4906 | ALC889_FIXUP_MBP_VREF, |
| 4907 | ALC889_FIXUP_IMAC91_VREF, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4908 | }; |
| 4909 | |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 4910 | static void alc889_fixup_coef(struct hda_codec *codec, |
| 4911 | const struct alc_fixup *fix, int action) |
| 4912 | { |
| 4913 | if (action != ALC_FIXUP_ACT_INIT) |
| 4914 | return; |
| 4915 | alc889_coef_init(codec); |
| 4916 | } |
| 4917 | |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 4918 | /* toggle speaker-output according to the hp-jack state */ |
| 4919 | static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted) |
| 4920 | { |
| 4921 | unsigned int gpiostate, gpiomask, gpiodir; |
| 4922 | |
| 4923 | gpiostate = snd_hda_codec_read(codec, codec->afg, 0, |
| 4924 | AC_VERB_GET_GPIO_DATA, 0); |
| 4925 | |
| 4926 | if (!muted) |
| 4927 | gpiostate |= (1 << pin); |
| 4928 | else |
| 4929 | gpiostate &= ~(1 << pin); |
| 4930 | |
| 4931 | gpiomask = snd_hda_codec_read(codec, codec->afg, 0, |
| 4932 | AC_VERB_GET_GPIO_MASK, 0); |
| 4933 | gpiomask |= (1 << pin); |
| 4934 | |
| 4935 | gpiodir = snd_hda_codec_read(codec, codec->afg, 0, |
| 4936 | AC_VERB_GET_GPIO_DIRECTION, 0); |
| 4937 | gpiodir |= (1 << pin); |
| 4938 | |
| 4939 | |
| 4940 | snd_hda_codec_write(codec, codec->afg, 0, |
| 4941 | AC_VERB_SET_GPIO_MASK, gpiomask); |
| 4942 | snd_hda_codec_write(codec, codec->afg, 0, |
| 4943 | AC_VERB_SET_GPIO_DIRECTION, gpiodir); |
| 4944 | |
| 4945 | msleep(1); |
| 4946 | |
| 4947 | snd_hda_codec_write(codec, codec->afg, 0, |
| 4948 | AC_VERB_SET_GPIO_DATA, gpiostate); |
| 4949 | } |
| 4950 | |
| 4951 | /* set up GPIO at initialization */ |
| 4952 | static void alc885_fixup_macpro_gpio(struct hda_codec *codec, |
| 4953 | const struct alc_fixup *fix, int action) |
| 4954 | { |
| 4955 | if (action != ALC_FIXUP_ACT_INIT) |
| 4956 | return; |
| 4957 | alc882_gpio_mute(codec, 0, 0); |
| 4958 | alc882_gpio_mute(codec, 1, 0); |
| 4959 | } |
| 4960 | |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 4961 | /* Fix the connection of some pins for ALC889: |
| 4962 | * At least, Acer Aspire 5935 shows the connections to DAC3/4 don't |
| 4963 | * work correctly (bko#42740) |
| 4964 | */ |
| 4965 | static void alc889_fixup_dac_route(struct hda_codec *codec, |
| 4966 | const struct alc_fixup *fix, int action) |
| 4967 | { |
| 4968 | if (action == ALC_FIXUP_ACT_PRE_PROBE) { |
Takashi Iwai | ef8d60f | 2012-02-17 10:12:38 +0100 | [diff] [blame] | 4969 | /* fake the connections during parsing the tree */ |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 4970 | hda_nid_t conn1[2] = { 0x0c, 0x0d }; |
| 4971 | hda_nid_t conn2[2] = { 0x0e, 0x0f }; |
| 4972 | snd_hda_override_conn_list(codec, 0x14, 2, conn1); |
| 4973 | snd_hda_override_conn_list(codec, 0x15, 2, conn1); |
| 4974 | snd_hda_override_conn_list(codec, 0x18, 2, conn2); |
| 4975 | snd_hda_override_conn_list(codec, 0x1a, 2, conn2); |
Takashi Iwai | ef8d60f | 2012-02-17 10:12:38 +0100 | [diff] [blame] | 4976 | } else if (action == ALC_FIXUP_ACT_PROBE) { |
| 4977 | /* restore the connections */ |
| 4978 | hda_nid_t conn[5] = { 0x0c, 0x0d, 0x0e, 0x0f, 0x26 }; |
| 4979 | snd_hda_override_conn_list(codec, 0x14, 5, conn); |
| 4980 | snd_hda_override_conn_list(codec, 0x15, 5, conn); |
| 4981 | snd_hda_override_conn_list(codec, 0x18, 5, conn); |
| 4982 | snd_hda_override_conn_list(codec, 0x1a, 5, conn); |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 4983 | } |
| 4984 | } |
| 4985 | |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 4986 | /* Set VREF on HP pin */ |
| 4987 | static void alc889_fixup_mbp_vref(struct hda_codec *codec, |
| 4988 | const struct alc_fixup *fix, int action) |
| 4989 | { |
| 4990 | struct alc_spec *spec = codec->spec; |
| 4991 | static hda_nid_t nids[2] = { 0x14, 0x15 }; |
| 4992 | int i; |
| 4993 | |
| 4994 | if (action != ALC_FIXUP_ACT_INIT) |
| 4995 | return; |
| 4996 | for (i = 0; i < ARRAY_SIZE(nids); i++) { |
| 4997 | unsigned int val = snd_hda_codec_get_pincfg(codec, nids[i]); |
| 4998 | if (get_defcfg_device(val) != AC_JACK_HP_OUT) |
| 4999 | continue; |
| 5000 | val = snd_hda_codec_read(codec, nids[i], 0, |
| 5001 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 5002 | val |= AC_PINCTL_VREF_80; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 5003 | snd_hda_set_pin_ctl(codec, nids[i], val); |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5004 | spec->keep_vref_in_automute = 1; |
| 5005 | break; |
| 5006 | } |
| 5007 | } |
| 5008 | |
| 5009 | /* Set VREF on speaker pins on imac91 */ |
| 5010 | static void alc889_fixup_imac91_vref(struct hda_codec *codec, |
| 5011 | const struct alc_fixup *fix, int action) |
| 5012 | { |
| 5013 | struct alc_spec *spec = codec->spec; |
| 5014 | static hda_nid_t nids[2] = { 0x18, 0x1a }; |
| 5015 | int i; |
| 5016 | |
| 5017 | if (action != ALC_FIXUP_ACT_INIT) |
| 5018 | return; |
| 5019 | for (i = 0; i < ARRAY_SIZE(nids); i++) { |
| 5020 | unsigned int val; |
| 5021 | val = snd_hda_codec_read(codec, nids[i], 0, |
| 5022 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 5023 | val |= AC_PINCTL_VREF_50; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 5024 | snd_hda_set_pin_ctl(codec, nids[i], val); |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5025 | } |
| 5026 | spec->keep_vref_in_automute = 1; |
| 5027 | } |
| 5028 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5029 | static const struct alc_fixup alc882_fixups[] = { |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5030 | [ALC882_FIXUP_ABIT_AW9D_MAX] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5031 | .type = ALC_FIXUP_PINS, |
| 5032 | .v.pins = (const struct alc_pincfg[]) { |
| 5033 | { 0x15, 0x01080104 }, /* side */ |
| 5034 | { 0x16, 0x01011012 }, /* rear */ |
| 5035 | { 0x17, 0x01016011 }, /* clfe */ |
| 5036 | { } |
| 5037 | } |
| 5038 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5039 | [ALC882_FIXUP_LENOVO_Y530] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5040 | .type = ALC_FIXUP_PINS, |
| 5041 | .v.pins = (const struct alc_pincfg[]) { |
| 5042 | { 0x15, 0x99130112 }, /* rear int speakers */ |
| 5043 | { 0x16, 0x99130111 }, /* subwoofer */ |
| 5044 | { } |
| 5045 | } |
| 5046 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5047 | [ALC882_FIXUP_PB_M5210] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5048 | .type = ALC_FIXUP_VERBS, |
| 5049 | .v.verbs = (const struct hda_verb[]) { |
| 5050 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 }, |
| 5051 | {} |
| 5052 | } |
| 5053 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5054 | [ALC882_FIXUP_ACER_ASPIRE_7736] = { |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame^] | 5055 | .type = ALC_FIXUP_FUNC, |
| 5056 | .v.func = alc_fixup_sku_ignore, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5057 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5058 | [ALC882_FIXUP_ASUS_W90V] = { |
Takashi Iwai | 5cdf745 | 2011-10-26 23:04:08 +0200 | [diff] [blame] | 5059 | .type = ALC_FIXUP_PINS, |
| 5060 | .v.pins = (const struct alc_pincfg[]) { |
| 5061 | { 0x16, 0x99130110 }, /* fix sequence for CLFE */ |
| 5062 | { } |
| 5063 | } |
| 5064 | }, |
Marton Balint | 8f23921 | 2012-03-05 21:33:23 +0100 | [diff] [blame] | 5065 | [ALC889_FIXUP_CD] = { |
| 5066 | .type = ALC_FIXUP_PINS, |
| 5067 | .v.pins = (const struct alc_pincfg[]) { |
| 5068 | { 0x1c, 0x993301f0 }, /* CD */ |
| 5069 | { } |
| 5070 | } |
| 5071 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5072 | [ALC889_FIXUP_VAIO_TT] = { |
| 5073 | .type = ALC_FIXUP_PINS, |
| 5074 | .v.pins = (const struct alc_pincfg[]) { |
| 5075 | { 0x17, 0x90170111 }, /* hidden surround speaker */ |
| 5076 | { } |
| 5077 | } |
| 5078 | }, |
Takashi Iwai | 0e7cc2e | 2011-11-09 12:42:48 +0100 | [diff] [blame] | 5079 | [ALC888_FIXUP_EEE1601] = { |
| 5080 | .type = ALC_FIXUP_VERBS, |
| 5081 | .v.verbs = (const struct hda_verb[]) { |
| 5082 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b }, |
| 5083 | { 0x20, AC_VERB_SET_PROC_COEF, 0x0838 }, |
| 5084 | { } |
| 5085 | } |
Takashi Iwai | 177943a | 2011-11-09 12:55:18 +0100 | [diff] [blame] | 5086 | }, |
| 5087 | [ALC882_FIXUP_EAPD] = { |
| 5088 | .type = ALC_FIXUP_VERBS, |
| 5089 | .v.verbs = (const struct hda_verb[]) { |
| 5090 | /* change to EAPD mode */ |
| 5091 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5092 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 }, |
| 5093 | { } |
| 5094 | } |
| 5095 | }, |
Takashi Iwai | 7a6069b | 2011-11-09 15:22:01 +0100 | [diff] [blame] | 5096 | [ALC883_FIXUP_EAPD] = { |
| 5097 | .type = ALC_FIXUP_VERBS, |
| 5098 | .v.verbs = (const struct hda_verb[]) { |
| 5099 | /* change to EAPD mode */ |
| 5100 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5101 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 }, |
| 5102 | { } |
| 5103 | } |
| 5104 | }, |
Takashi Iwai | 8812c4f | 2011-11-09 17:39:15 +0100 | [diff] [blame] | 5105 | [ALC883_FIXUP_ACER_EAPD] = { |
| 5106 | .type = ALC_FIXUP_VERBS, |
| 5107 | .v.verbs = (const struct hda_verb[]) { |
| 5108 | /* eanable EAPD on Acer laptops */ |
| 5109 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5110 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 }, |
| 5111 | { } |
| 5112 | } |
| 5113 | }, |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5114 | [ALC882_FIXUP_GPIO1] = { |
| 5115 | .type = ALC_FIXUP_VERBS, |
| 5116 | .v.verbs = alc_gpio1_init_verbs, |
| 5117 | }, |
| 5118 | [ALC882_FIXUP_GPIO2] = { |
| 5119 | .type = ALC_FIXUP_VERBS, |
| 5120 | .v.verbs = alc_gpio2_init_verbs, |
| 5121 | }, |
Takashi Iwai | eb844d5 | 2011-11-09 18:03:07 +0100 | [diff] [blame] | 5122 | [ALC882_FIXUP_GPIO3] = { |
| 5123 | .type = ALC_FIXUP_VERBS, |
| 5124 | .v.verbs = alc_gpio3_init_verbs, |
| 5125 | }, |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 5126 | [ALC882_FIXUP_ASUS_W2JC] = { |
| 5127 | .type = ALC_FIXUP_VERBS, |
| 5128 | .v.verbs = alc_gpio1_init_verbs, |
| 5129 | .chained = true, |
| 5130 | .chain_id = ALC882_FIXUP_EAPD, |
| 5131 | }, |
| 5132 | [ALC889_FIXUP_COEF] = { |
| 5133 | .type = ALC_FIXUP_FUNC, |
| 5134 | .v.func = alc889_fixup_coef, |
| 5135 | }, |
Takashi Iwai | c3e837b | 2011-11-10 16:01:47 +0100 | [diff] [blame] | 5136 | [ALC882_FIXUP_ACER_ASPIRE_4930G] = { |
| 5137 | .type = ALC_FIXUP_PINS, |
| 5138 | .v.pins = (const struct alc_pincfg[]) { |
| 5139 | { 0x16, 0x99130111 }, /* CLFE speaker */ |
| 5140 | { 0x17, 0x99130112 }, /* surround speaker */ |
| 5141 | { } |
Takashi Iwai | 038d4fe | 2012-04-11 17:18:12 +0200 | [diff] [blame] | 5142 | }, |
| 5143 | .chained = true, |
| 5144 | .chain_id = ALC882_FIXUP_GPIO1, |
Takashi Iwai | c3e837b | 2011-11-10 16:01:47 +0100 | [diff] [blame] | 5145 | }, |
| 5146 | [ALC882_FIXUP_ACER_ASPIRE_8930G] = { |
| 5147 | .type = ALC_FIXUP_PINS, |
| 5148 | .v.pins = (const struct alc_pincfg[]) { |
| 5149 | { 0x16, 0x99130111 }, /* CLFE speaker */ |
| 5150 | { 0x1b, 0x99130112 }, /* surround speaker */ |
| 5151 | { } |
| 5152 | }, |
| 5153 | .chained = true, |
| 5154 | .chain_id = ALC882_FIXUP_ASPIRE_8930G_VERBS, |
| 5155 | }, |
| 5156 | [ALC882_FIXUP_ASPIRE_8930G_VERBS] = { |
| 5157 | /* additional init verbs for Acer Aspire 8930G */ |
| 5158 | .type = ALC_FIXUP_VERBS, |
| 5159 | .v.verbs = (const struct hda_verb[]) { |
| 5160 | /* Enable all DACs */ |
| 5161 | /* DAC DISABLE/MUTE 1? */ |
| 5162 | /* setting bits 1-5 disables DAC nids 0x02-0x06 |
| 5163 | * apparently. Init=0x38 */ |
| 5164 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x03 }, |
| 5165 | { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 }, |
| 5166 | /* DAC DISABLE/MUTE 2? */ |
| 5167 | /* some bit here disables the other DACs. |
| 5168 | * Init=0x4900 */ |
| 5169 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x08 }, |
| 5170 | { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 }, |
| 5171 | /* DMIC fix |
| 5172 | * This laptop has a stereo digital microphone. |
| 5173 | * The mics are only 1cm apart which makes the stereo |
| 5174 | * useless. However, either the mic or the ALC889 |
| 5175 | * makes the signal become a difference/sum signal |
| 5176 | * instead of standard stereo, which is annoying. |
| 5177 | * So instead we flip this bit which makes the |
| 5178 | * codec replicate the sum signal to both channels, |
| 5179 | * turning it into a normal mono mic. |
| 5180 | */ |
| 5181 | /* DMIC_CONTROL? Init value = 0x0001 */ |
| 5182 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b }, |
| 5183 | { 0x20, AC_VERB_SET_PROC_COEF, 0x0003 }, |
| 5184 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5185 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 }, |
| 5186 | { } |
Takashi Iwai | 038d4fe | 2012-04-11 17:18:12 +0200 | [diff] [blame] | 5187 | }, |
| 5188 | .chained = true, |
| 5189 | .chain_id = ALC882_FIXUP_GPIO1, |
Takashi Iwai | c3e837b | 2011-11-10 16:01:47 +0100 | [diff] [blame] | 5190 | }, |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5191 | [ALC885_FIXUP_MACPRO_GPIO] = { |
| 5192 | .type = ALC_FIXUP_FUNC, |
| 5193 | .v.func = alc885_fixup_macpro_gpio, |
| 5194 | }, |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5195 | [ALC889_FIXUP_DAC_ROUTE] = { |
| 5196 | .type = ALC_FIXUP_FUNC, |
| 5197 | .v.func = alc889_fixup_dac_route, |
| 5198 | }, |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5199 | [ALC889_FIXUP_MBP_VREF] = { |
| 5200 | .type = ALC_FIXUP_FUNC, |
| 5201 | .v.func = alc889_fixup_mbp_vref, |
| 5202 | .chained = true, |
| 5203 | .chain_id = ALC882_FIXUP_GPIO1, |
| 5204 | }, |
| 5205 | [ALC889_FIXUP_IMAC91_VREF] = { |
| 5206 | .type = ALC_FIXUP_FUNC, |
| 5207 | .v.func = alc889_fixup_imac91_vref, |
| 5208 | .chained = true, |
| 5209 | .chain_id = ALC882_FIXUP_GPIO1, |
| 5210 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5211 | }; |
| 5212 | |
| 5213 | static const struct snd_pci_quirk alc882_fixup_tbl[] = { |
Takashi Iwai | 8812c4f | 2011-11-09 17:39:15 +0100 | [diff] [blame] | 5214 | SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_FIXUP_ACER_EAPD), |
| 5215 | SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_FIXUP_ACER_EAPD), |
| 5216 | SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_FIXUP_ACER_EAPD), |
| 5217 | SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_FIXUP_ACER_EAPD), |
| 5218 | SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_FIXUP_ACER_EAPD), |
| 5219 | SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_FIXUP_ACER_EAPD), |
Takashi Iwai | c3e837b | 2011-11-10 16:01:47 +0100 | [diff] [blame] | 5220 | SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G", |
| 5221 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
| 5222 | SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G", |
| 5223 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
| 5224 | SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G", |
| 5225 | ALC882_FIXUP_ACER_ASPIRE_8930G), |
| 5226 | SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G", |
| 5227 | ALC882_FIXUP_ACER_ASPIRE_8930G), |
| 5228 | SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G", |
| 5229 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
| 5230 | SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G", |
| 5231 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
| 5232 | SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G", |
| 5233 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5234 | SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", ALC882_FIXUP_PB_M5210), |
Takashi Iwai | f5c53d8 | 2012-05-07 10:07:33 +0200 | [diff] [blame] | 5235 | SND_PCI_QUIRK(0x1025, 0x021e, "Acer Aspire 5739G", |
| 5236 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5237 | SND_PCI_QUIRK(0x1025, 0x0259, "Acer Aspire 5935", ALC889_FIXUP_DAC_ROUTE), |
Takashi Iwai | fe97da1 | 2012-04-12 08:00:19 +0200 | [diff] [blame] | 5238 | SND_PCI_QUIRK(0x1025, 0x026b, "Acer Aspire 8940G", ALC882_FIXUP_ACER_ASPIRE_8930G), |
Takashi Iwai | ac9b1cd | 2011-11-09 17:45:55 +0100 | [diff] [blame] | 5239 | SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", ALC882_FIXUP_ACER_ASPIRE_7736), |
Takashi Iwai | 177943a | 2011-11-09 12:55:18 +0100 | [diff] [blame] | 5240 | SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_FIXUP_EAPD), |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5241 | SND_PCI_QUIRK(0x1043, 0x1873, "ASUS W90V", ALC882_FIXUP_ASUS_W90V), |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 5242 | SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_FIXUP_ASUS_W2JC), |
Takashi Iwai | 0e7cc2e | 2011-11-09 12:42:48 +0100 | [diff] [blame] | 5243 | SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601), |
Takashi Iwai | ac9b1cd | 2011-11-09 17:45:55 +0100 | [diff] [blame] | 5244 | SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT), |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5245 | |
| 5246 | /* All Apple entries are in codec SSIDs */ |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5247 | SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC889_FIXUP_MBP_VREF), |
| 5248 | SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC889_FIXUP_MBP_VREF), |
| 5249 | SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF), |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5250 | SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_FIXUP_MACPRO_GPIO), |
| 5251 | SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_FIXUP_MACPRO_GPIO), |
| 5252 | SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_FIXUP_MACPRO_GPIO), |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5253 | SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC889_FIXUP_MBP_VREF), |
| 5254 | SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889_FIXUP_MBP_VREF), |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5255 | SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_FIXUP_EAPD), |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5256 | SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC889_FIXUP_MBP_VREF), |
| 5257 | SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC889_FIXUP_MBP_VREF), |
| 5258 | SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889_FIXUP_MBP_VREF), |
| 5259 | SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF), |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5260 | SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_FIXUP_MACPRO_GPIO), |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5261 | SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC889_FIXUP_IMAC91_VREF), |
| 5262 | SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC889_FIXUP_IMAC91_VREF), |
| 5263 | SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC889_FIXUP_IMAC91_VREF), |
Josh Boyer | 29ebe40 | 2012-04-12 13:55:36 -0400 | [diff] [blame] | 5264 | SND_PCI_QUIRK(0x106b, 0x4200, "Mac Pro 5,1", ALC885_FIXUP_MACPRO_GPIO), |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5265 | SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC889_FIXUP_IMAC91_VREF), |
| 5266 | SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC889_FIXUP_IMAC91_VREF), |
| 5267 | SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC889_FIXUP_IMAC91_VREF), |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5268 | |
Takashi Iwai | 7a6069b | 2011-11-09 15:22:01 +0100 | [diff] [blame] | 5269 | SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC882_FIXUP_EAPD), |
Takashi Iwai | bca4013 | 2012-05-07 11:13:14 +0200 | [diff] [blame] | 5270 | SND_PCI_QUIRK(0x1462, 0x7350, "MSI-7350", ALC889_FIXUP_CD), |
Takashi Iwai | eb844d5 | 2011-11-09 18:03:07 +0100 | [diff] [blame] | 5271 | SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3), |
Marton Balint | 8f23921 | 2012-03-05 21:33:23 +0100 | [diff] [blame] | 5272 | SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte EP45-DS3", ALC889_FIXUP_CD), |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5273 | SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", ALC882_FIXUP_ABIT_AW9D_MAX), |
Takashi Iwai | 7a6069b | 2011-11-09 15:22:01 +0100 | [diff] [blame] | 5274 | SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC882_FIXUP_EAPD), |
| 5275 | SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_FIXUP_EAPD), |
Takashi Iwai | ac9b1cd | 2011-11-09 17:45:55 +0100 | [diff] [blame] | 5276 | SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", ALC882_FIXUP_LENOVO_Y530), |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 5277 | SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_FIXUP_COEF), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5278 | {} |
| 5279 | }; |
| 5280 | |
Takashi Iwai | 912093b | 2012-04-11 14:03:41 +0200 | [diff] [blame] | 5281 | static const struct alc_model_fixup alc882_fixup_models[] = { |
| 5282 | {.id = ALC882_FIXUP_ACER_ASPIRE_4930G, .name = "acer-aspire-4930g"}, |
| 5283 | {.id = ALC882_FIXUP_ACER_ASPIRE_8930G, .name = "acer-aspire-8930g"}, |
| 5284 | {.id = ALC883_FIXUP_ACER_EAPD, .name = "acer-aspire"}, |
| 5285 | {} |
| 5286 | }; |
| 5287 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5288 | /* |
| 5289 | * BIOS auto configuration |
| 5290 | */ |
| 5291 | /* almost identical with ALC880 parser... */ |
| 5292 | static int alc882_parse_auto_config(struct hda_codec *codec) |
| 5293 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5294 | static const hda_nid_t alc882_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5295 | static const hda_nid_t alc882_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 5296 | return alc_parse_auto_config(codec, alc882_ignore, alc882_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5297 | } |
| 5298 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5299 | /* |
| 5300 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5301 | static int patch_alc882(struct hda_codec *codec) |
| 5302 | { |
| 5303 | struct alc_spec *spec; |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5304 | int err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5305 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 5306 | err = alc_alloc_spec(codec, 0x0b); |
| 5307 | if (err < 0) |
| 5308 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5309 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 5310 | spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5311 | |
| 5312 | switch (codec->vendor_id) { |
| 5313 | case 0x10ec0882: |
| 5314 | case 0x10ec0885: |
| 5315 | break; |
| 5316 | default: |
| 5317 | /* ALC883 and variants */ |
| 5318 | alc_fix_pll_init(codec, 0x20, 0x0a, 10); |
| 5319 | break; |
| 5320 | } |
| 5321 | |
Takashi Iwai | 912093b | 2012-04-11 14:03:41 +0200 | [diff] [blame] | 5322 | alc_pick_fixup(codec, alc882_fixup_models, alc882_fixup_tbl, |
| 5323 | alc882_fixups); |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5324 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5325 | |
| 5326 | alc_auto_parse_customize_define(codec); |
| 5327 | |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5328 | /* automatic parse from the BIOS config */ |
| 5329 | err = alc882_parse_auto_config(codec); |
| 5330 | if (err < 0) |
| 5331 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5332 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5333 | if (!spec->no_analog && has_cdefine_beep(codec)) { |
| 5334 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5335 | if (err < 0) |
| 5336 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5337 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5338 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5339 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5340 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5341 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 5342 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 5343 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5344 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5345 | |
| 5346 | error: |
| 5347 | alc_free(codec); |
| 5348 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5349 | } |
| 5350 | |
| 5351 | |
| 5352 | /* |
| 5353 | * ALC262 support |
| 5354 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5355 | static int alc262_parse_auto_config(struct hda_codec *codec) |
| 5356 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5357 | static const hda_nid_t alc262_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5358 | static const hda_nid_t alc262_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 5359 | return alc_parse_auto_config(codec, alc262_ignore, alc262_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5360 | } |
| 5361 | |
| 5362 | /* |
| 5363 | * Pin config fixes |
| 5364 | */ |
| 5365 | enum { |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5366 | ALC262_FIXUP_FSC_H270, |
| 5367 | ALC262_FIXUP_HP_Z200, |
| 5368 | ALC262_FIXUP_TYAN, |
Takashi Iwai | c470150 | 2011-11-07 14:20:07 +0100 | [diff] [blame] | 5369 | ALC262_FIXUP_LENOVO_3000, |
Takashi Iwai | b42590b | 2011-11-07 14:41:01 +0100 | [diff] [blame] | 5370 | ALC262_FIXUP_BENQ, |
| 5371 | ALC262_FIXUP_BENQ_T31, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5372 | }; |
| 5373 | |
| 5374 | static const struct alc_fixup alc262_fixups[] = { |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5375 | [ALC262_FIXUP_FSC_H270] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5376 | .type = ALC_FIXUP_PINS, |
| 5377 | .v.pins = (const struct alc_pincfg[]) { |
| 5378 | { 0x14, 0x99130110 }, /* speaker */ |
| 5379 | { 0x15, 0x0221142f }, /* front HP */ |
| 5380 | { 0x1b, 0x0121141f }, /* rear HP */ |
| 5381 | { } |
| 5382 | } |
| 5383 | }, |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5384 | [ALC262_FIXUP_HP_Z200] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5385 | .type = ALC_FIXUP_PINS, |
| 5386 | .v.pins = (const struct alc_pincfg[]) { |
| 5387 | { 0x16, 0x99130120 }, /* internal speaker */ |
| 5388 | { } |
| 5389 | } |
| 5390 | }, |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5391 | [ALC262_FIXUP_TYAN] = { |
| 5392 | .type = ALC_FIXUP_PINS, |
| 5393 | .v.pins = (const struct alc_pincfg[]) { |
| 5394 | { 0x14, 0x1993e1f0 }, /* int AUX */ |
| 5395 | { } |
| 5396 | } |
| 5397 | }, |
Takashi Iwai | c470150 | 2011-11-07 14:20:07 +0100 | [diff] [blame] | 5398 | [ALC262_FIXUP_LENOVO_3000] = { |
| 5399 | .type = ALC_FIXUP_VERBS, |
| 5400 | .v.verbs = (const struct hda_verb[]) { |
| 5401 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 }, |
Takashi Iwai | b42590b | 2011-11-07 14:41:01 +0100 | [diff] [blame] | 5402 | {} |
| 5403 | }, |
| 5404 | .chained = true, |
| 5405 | .chain_id = ALC262_FIXUP_BENQ, |
| 5406 | }, |
| 5407 | [ALC262_FIXUP_BENQ] = { |
| 5408 | .type = ALC_FIXUP_VERBS, |
| 5409 | .v.verbs = (const struct hda_verb[]) { |
Takashi Iwai | c470150 | 2011-11-07 14:20:07 +0100 | [diff] [blame] | 5410 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5411 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 }, |
| 5412 | {} |
| 5413 | } |
| 5414 | }, |
Takashi Iwai | b42590b | 2011-11-07 14:41:01 +0100 | [diff] [blame] | 5415 | [ALC262_FIXUP_BENQ_T31] = { |
| 5416 | .type = ALC_FIXUP_VERBS, |
| 5417 | .v.verbs = (const struct hda_verb[]) { |
| 5418 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5419 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 }, |
| 5420 | {} |
| 5421 | } |
| 5422 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5423 | }; |
| 5424 | |
| 5425 | static const struct snd_pci_quirk alc262_fixup_tbl[] = { |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5426 | SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200", ALC262_FIXUP_HP_Z200), |
Takashi Iwai | 3dcd3be | 2011-11-07 14:59:40 +0100 | [diff] [blame] | 5427 | SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FIXUP_BENQ), |
| 5428 | SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FIXUP_BENQ), |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5429 | SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_FIXUP_TYAN), |
| 5430 | SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", ALC262_FIXUP_FSC_H270), |
Takashi Iwai | c470150 | 2011-11-07 14:20:07 +0100 | [diff] [blame] | 5431 | SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000", ALC262_FIXUP_LENOVO_3000), |
Takashi Iwai | b42590b | 2011-11-07 14:41:01 +0100 | [diff] [blame] | 5432 | SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_FIXUP_BENQ), |
| 5433 | SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_FIXUP_BENQ_T31), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5434 | {} |
| 5435 | }; |
| 5436 | |
| 5437 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5438 | /* |
| 5439 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5440 | static int patch_alc262(struct hda_codec *codec) |
| 5441 | { |
| 5442 | struct alc_spec *spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5443 | int err; |
| 5444 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 5445 | err = alc_alloc_spec(codec, 0x0b); |
| 5446 | if (err < 0) |
| 5447 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5448 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 5449 | spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5450 | |
| 5451 | #if 0 |
| 5452 | /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is |
| 5453 | * under-run |
| 5454 | */ |
| 5455 | { |
| 5456 | int tmp; |
| 5457 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); |
| 5458 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); |
| 5459 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); |
| 5460 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80); |
| 5461 | } |
| 5462 | #endif |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5463 | alc_fix_pll_init(codec, 0x20, 0x0a, 10); |
| 5464 | |
Takashi Iwai | 42399f7 | 2011-11-07 17:18:44 +0100 | [diff] [blame] | 5465 | alc_pick_fixup(codec, NULL, alc262_fixup_tbl, alc262_fixups); |
| 5466 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5467 | |
Takashi Iwai | af741c1 | 2012-05-07 18:09:48 +0200 | [diff] [blame] | 5468 | alc_auto_parse_customize_define(codec); |
| 5469 | |
Takashi Iwai | 42399f7 | 2011-11-07 17:18:44 +0100 | [diff] [blame] | 5470 | /* automatic parse from the BIOS config */ |
| 5471 | err = alc262_parse_auto_config(codec); |
| 5472 | if (err < 0) |
| 5473 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5474 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5475 | if (!spec->no_analog && has_cdefine_beep(codec)) { |
| 5476 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5477 | if (err < 0) |
| 5478 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5479 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5480 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5481 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5482 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5483 | spec->shutup = alc_eapd_shutup; |
| 5484 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 5485 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 5486 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5487 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5488 | |
| 5489 | error: |
| 5490 | alc_free(codec); |
| 5491 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5492 | } |
| 5493 | |
| 5494 | /* |
| 5495 | * ALC268 |
| 5496 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5497 | /* bind Beep switches of both NID 0x0f and 0x10 */ |
| 5498 | static const struct hda_bind_ctls alc268_bind_beep_sw = { |
| 5499 | .ops = &snd_hda_bind_sw, |
| 5500 | .values = { |
| 5501 | HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT), |
| 5502 | HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT), |
| 5503 | 0 |
| 5504 | }, |
| 5505 | }; |
| 5506 | |
| 5507 | static const struct snd_kcontrol_new alc268_beep_mixer[] = { |
| 5508 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT), |
| 5509 | HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw), |
| 5510 | { } |
| 5511 | }; |
| 5512 | |
| 5513 | /* set PCBEEP vol = 0, mute connections */ |
| 5514 | static const struct hda_verb alc268_beep_init_verbs[] = { |
| 5515 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5516 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 5517 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 5518 | { } |
| 5519 | }; |
| 5520 | |
| 5521 | /* |
| 5522 | * BIOS auto configuration |
| 5523 | */ |
| 5524 | static int alc268_parse_auto_config(struct hda_codec *codec) |
| 5525 | { |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5526 | static const hda_nid_t alc268_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5527 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5528 | int err = alc_parse_auto_config(codec, NULL, alc268_ssids); |
| 5529 | if (err > 0) { |
| 5530 | if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d) { |
| 5531 | add_mixer(spec, alc268_beep_mixer); |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame^] | 5532 | snd_hda_gen_add_verbs(&spec->gen, alc268_beep_init_verbs); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5533 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5534 | } |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5535 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5536 | } |
| 5537 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5538 | /* |
| 5539 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5540 | static int patch_alc268(struct hda_codec *codec) |
| 5541 | { |
| 5542 | struct alc_spec *spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5543 | int i, has_beep, err; |
| 5544 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5545 | /* ALC268 has no aa-loopback mixer */ |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 5546 | err = alc_alloc_spec(codec, 0); |
| 5547 | if (err < 0) |
| 5548 | return err; |
| 5549 | |
| 5550 | spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5551 | |
Takashi Iwai | 6ebb805 | 2011-08-16 15:15:40 +0200 | [diff] [blame] | 5552 | /* automatic parse from the BIOS config */ |
| 5553 | err = alc268_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5554 | if (err < 0) |
| 5555 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5556 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5557 | has_beep = 0; |
| 5558 | for (i = 0; i < spec->num_mixers; i++) { |
| 5559 | if (spec->mixers[i] == alc268_beep_mixer) { |
| 5560 | has_beep = 1; |
| 5561 | break; |
| 5562 | } |
| 5563 | } |
| 5564 | |
| 5565 | if (has_beep) { |
| 5566 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5567 | if (err < 0) |
| 5568 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5569 | if (!query_amp_caps(codec, 0x1d, HDA_INPUT)) |
| 5570 | /* override the amp caps for beep generator */ |
| 5571 | snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT, |
| 5572 | (0x0c << AC_AMPCAP_OFFSET_SHIFT) | |
| 5573 | (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) | |
| 5574 | (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) | |
| 5575 | (0 << AC_AMPCAP_MUTE_SHIFT)); |
| 5576 | } |
| 5577 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5578 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5579 | spec->shutup = alc_eapd_shutup; |
| 5580 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5581 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5582 | |
| 5583 | error: |
| 5584 | alc_free(codec); |
| 5585 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5586 | } |
| 5587 | |
| 5588 | /* |
| 5589 | * ALC269 |
| 5590 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5591 | static const struct hda_pcm_stream alc269_44k_pcm_analog_playback = { |
| 5592 | .substreams = 1, |
| 5593 | .channels_min = 2, |
| 5594 | .channels_max = 8, |
| 5595 | .rates = SNDRV_PCM_RATE_44100, /* fixed rate */ |
| 5596 | /* NID is set in alc_build_pcms */ |
| 5597 | .ops = { |
| 5598 | .open = alc_playback_pcm_open, |
| 5599 | .prepare = alc_playback_pcm_prepare, |
| 5600 | .cleanup = alc_playback_pcm_cleanup |
| 5601 | }, |
| 5602 | }; |
| 5603 | |
| 5604 | static const struct hda_pcm_stream alc269_44k_pcm_analog_capture = { |
| 5605 | .substreams = 1, |
| 5606 | .channels_min = 2, |
| 5607 | .channels_max = 2, |
| 5608 | .rates = SNDRV_PCM_RATE_44100, /* fixed rate */ |
| 5609 | /* NID is set in alc_build_pcms */ |
| 5610 | }; |
| 5611 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5612 | /* different alc269-variants */ |
| 5613 | enum { |
| 5614 | ALC269_TYPE_ALC269VA, |
| 5615 | ALC269_TYPE_ALC269VB, |
| 5616 | ALC269_TYPE_ALC269VC, |
| 5617 | }; |
| 5618 | |
| 5619 | /* |
| 5620 | * BIOS auto configuration |
| 5621 | */ |
| 5622 | static int alc269_parse_auto_config(struct hda_codec *codec) |
| 5623 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5624 | static const hda_nid_t alc269_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5625 | static const hda_nid_t alc269_ssids[] = { 0, 0x1b, 0x14, 0x21 }; |
| 5626 | static const hda_nid_t alc269va_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 5627 | struct alc_spec *spec = codec->spec; |
| 5628 | const hda_nid_t *ssids = spec->codec_variant == ALC269_TYPE_ALC269VA ? |
| 5629 | alc269va_ssids : alc269_ssids; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5630 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5631 | return alc_parse_auto_config(codec, alc269_ignore, ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5632 | } |
| 5633 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5634 | static void alc269_toggle_power_output(struct hda_codec *codec, int power_up) |
| 5635 | { |
| 5636 | int val = alc_read_coef_idx(codec, 0x04); |
| 5637 | if (power_up) |
| 5638 | val |= 1 << 11; |
| 5639 | else |
| 5640 | val &= ~(1 << 11); |
| 5641 | alc_write_coef_idx(codec, 0x04, val); |
| 5642 | } |
| 5643 | |
| 5644 | static void alc269_shutup(struct hda_codec *codec) |
| 5645 | { |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 5646 | if ((alc_get_coef0(codec) & 0x00ff) == 0x017) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5647 | alc269_toggle_power_output(codec, 0); |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 5648 | if ((alc_get_coef0(codec) & 0x00ff) == 0x018) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5649 | alc269_toggle_power_output(codec, 0); |
| 5650 | msleep(150); |
| 5651 | } |
| 5652 | } |
| 5653 | |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 5654 | #ifdef CONFIG_PM |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5655 | static int alc269_resume(struct hda_codec *codec) |
| 5656 | { |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 5657 | if ((alc_get_coef0(codec) & 0x00ff) == 0x018) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5658 | alc269_toggle_power_output(codec, 0); |
| 5659 | msleep(150); |
| 5660 | } |
| 5661 | |
| 5662 | codec->patch_ops.init(codec); |
| 5663 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 5664 | if ((alc_get_coef0(codec) & 0x00ff) == 0x017) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5665 | alc269_toggle_power_output(codec, 1); |
| 5666 | msleep(200); |
| 5667 | } |
| 5668 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 5669 | if ((alc_get_coef0(codec) & 0x00ff) == 0x018) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5670 | alc269_toggle_power_output(codec, 1); |
| 5671 | |
| 5672 | snd_hda_codec_resume_amp(codec); |
| 5673 | snd_hda_codec_resume_cache(codec); |
| 5674 | hda_call_check_power_status(codec, 0x01); |
| 5675 | return 0; |
| 5676 | } |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 5677 | #endif /* CONFIG_PM */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5678 | |
| 5679 | static void alc269_fixup_hweq(struct hda_codec *codec, |
| 5680 | const struct alc_fixup *fix, int action) |
| 5681 | { |
| 5682 | int coef; |
| 5683 | |
| 5684 | if (action != ALC_FIXUP_ACT_INIT) |
| 5685 | return; |
| 5686 | coef = alc_read_coef_idx(codec, 0x1e); |
| 5687 | alc_write_coef_idx(codec, 0x1e, coef | 0x80); |
| 5688 | } |
| 5689 | |
| 5690 | static void alc271_fixup_dmic(struct hda_codec *codec, |
| 5691 | const struct alc_fixup *fix, int action) |
| 5692 | { |
| 5693 | static const struct hda_verb verbs[] = { |
| 5694 | {0x20, AC_VERB_SET_COEF_INDEX, 0x0d}, |
| 5695 | {0x20, AC_VERB_SET_PROC_COEF, 0x4000}, |
| 5696 | {} |
| 5697 | }; |
| 5698 | unsigned int cfg; |
| 5699 | |
| 5700 | if (strcmp(codec->chip_name, "ALC271X")) |
| 5701 | return; |
| 5702 | cfg = snd_hda_codec_get_pincfg(codec, 0x12); |
| 5703 | if (get_defcfg_connect(cfg) == AC_JACK_PORT_FIXED) |
| 5704 | snd_hda_sequence_write(codec, verbs); |
| 5705 | } |
| 5706 | |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 5707 | static void alc269_fixup_pcm_44k(struct hda_codec *codec, |
| 5708 | const struct alc_fixup *fix, int action) |
| 5709 | { |
| 5710 | struct alc_spec *spec = codec->spec; |
| 5711 | |
| 5712 | if (action != ALC_FIXUP_ACT_PROBE) |
| 5713 | return; |
| 5714 | |
| 5715 | /* Due to a hardware problem on Lenovo Ideadpad, we need to |
| 5716 | * fix the sample rate of analog I/O to 44.1kHz |
| 5717 | */ |
| 5718 | spec->stream_analog_playback = &alc269_44k_pcm_analog_playback; |
| 5719 | spec->stream_analog_capture = &alc269_44k_pcm_analog_capture; |
| 5720 | } |
| 5721 | |
Takashi Iwai | adabb3e | 2011-08-03 07:48:37 +0200 | [diff] [blame] | 5722 | static void alc269_fixup_stereo_dmic(struct hda_codec *codec, |
| 5723 | const struct alc_fixup *fix, int action) |
| 5724 | { |
| 5725 | int coef; |
| 5726 | |
| 5727 | if (action != ALC_FIXUP_ACT_INIT) |
| 5728 | return; |
| 5729 | /* The digital-mic unit sends PDM (differential signal) instead of |
| 5730 | * the standard PCM, thus you can't record a valid mono stream as is. |
| 5731 | * Below is a workaround specific to ALC269 to control the dmic |
| 5732 | * signal source as mono. |
| 5733 | */ |
| 5734 | coef = alc_read_coef_idx(codec, 0x07); |
| 5735 | alc_write_coef_idx(codec, 0x07, coef | 0x80); |
| 5736 | } |
| 5737 | |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 5738 | static void alc269_quanta_automute(struct hda_codec *codec) |
| 5739 | { |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 5740 | update_outputs(codec); |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 5741 | |
| 5742 | snd_hda_codec_write(codec, 0x20, 0, |
| 5743 | AC_VERB_SET_COEF_INDEX, 0x0c); |
| 5744 | snd_hda_codec_write(codec, 0x20, 0, |
| 5745 | AC_VERB_SET_PROC_COEF, 0x680); |
| 5746 | |
| 5747 | snd_hda_codec_write(codec, 0x20, 0, |
| 5748 | AC_VERB_SET_COEF_INDEX, 0x0c); |
| 5749 | snd_hda_codec_write(codec, 0x20, 0, |
| 5750 | AC_VERB_SET_PROC_COEF, 0x480); |
| 5751 | } |
| 5752 | |
| 5753 | static void alc269_fixup_quanta_mute(struct hda_codec *codec, |
| 5754 | const struct alc_fixup *fix, int action) |
| 5755 | { |
| 5756 | struct alc_spec *spec = codec->spec; |
| 5757 | if (action != ALC_FIXUP_ACT_PROBE) |
| 5758 | return; |
| 5759 | spec->automute_hook = alc269_quanta_automute; |
| 5760 | } |
| 5761 | |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 5762 | /* update mute-LED according to the speaker mute state via mic2 VREF pin */ |
| 5763 | static void alc269_fixup_mic2_mute_hook(void *private_data, int enabled) |
| 5764 | { |
| 5765 | struct hda_codec *codec = private_data; |
| 5766 | unsigned int pinval = enabled ? 0x20 : 0x24; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 5767 | snd_hda_set_pin_ctl_cache(codec, 0x19, pinval); |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 5768 | } |
| 5769 | |
| 5770 | static void alc269_fixup_mic2_mute(struct hda_codec *codec, |
| 5771 | const struct alc_fixup *fix, int action) |
| 5772 | { |
| 5773 | struct alc_spec *spec = codec->spec; |
| 5774 | switch (action) { |
| 5775 | case ALC_FIXUP_ACT_BUILD: |
Takashi Iwai | d2f344b | 2012-03-12 16:59:58 +0100 | [diff] [blame] | 5776 | spec->vmaster_mute.hook = alc269_fixup_mic2_mute_hook; |
Takashi Iwai | f29735c | 2012-03-13 07:55:10 +0100 | [diff] [blame] | 5777 | snd_hda_add_vmaster_hook(codec, &spec->vmaster_mute, true); |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 5778 | /* fallthru */ |
| 5779 | case ALC_FIXUP_ACT_INIT: |
Takashi Iwai | d2f344b | 2012-03-12 16:59:58 +0100 | [diff] [blame] | 5780 | snd_hda_sync_vmaster_hook(&spec->vmaster_mute); |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 5781 | break; |
| 5782 | } |
| 5783 | } |
| 5784 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5785 | enum { |
| 5786 | ALC269_FIXUP_SONY_VAIO, |
| 5787 | ALC275_FIXUP_SONY_VAIO_GPIO2, |
| 5788 | ALC269_FIXUP_DELL_M101Z, |
| 5789 | ALC269_FIXUP_SKU_IGNORE, |
| 5790 | ALC269_FIXUP_ASUS_G73JW, |
| 5791 | ALC269_FIXUP_LENOVO_EAPD, |
| 5792 | ALC275_FIXUP_SONY_HWEQ, |
| 5793 | ALC271_FIXUP_DMIC, |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 5794 | ALC269_FIXUP_PCM_44K, |
Takashi Iwai | adabb3e | 2011-08-03 07:48:37 +0200 | [diff] [blame] | 5795 | ALC269_FIXUP_STEREO_DMIC, |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 5796 | ALC269_FIXUP_QUANTA_MUTE, |
| 5797 | ALC269_FIXUP_LIFEBOOK, |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 5798 | ALC269_FIXUP_AMIC, |
| 5799 | ALC269_FIXUP_DMIC, |
| 5800 | ALC269VB_FIXUP_AMIC, |
| 5801 | ALC269VB_FIXUP_DMIC, |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 5802 | ALC269_FIXUP_MIC2_MUTE_LED, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5803 | }; |
| 5804 | |
| 5805 | static const struct alc_fixup alc269_fixups[] = { |
| 5806 | [ALC269_FIXUP_SONY_VAIO] = { |
| 5807 | .type = ALC_FIXUP_VERBS, |
| 5808 | .v.verbs = (const struct hda_verb[]) { |
| 5809 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREFGRD}, |
| 5810 | {} |
| 5811 | } |
| 5812 | }, |
| 5813 | [ALC275_FIXUP_SONY_VAIO_GPIO2] = { |
| 5814 | .type = ALC_FIXUP_VERBS, |
| 5815 | .v.verbs = (const struct hda_verb[]) { |
| 5816 | {0x01, AC_VERB_SET_GPIO_MASK, 0x04}, |
| 5817 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04}, |
| 5818 | {0x01, AC_VERB_SET_GPIO_DATA, 0x00}, |
| 5819 | { } |
| 5820 | }, |
| 5821 | .chained = true, |
| 5822 | .chain_id = ALC269_FIXUP_SONY_VAIO |
| 5823 | }, |
| 5824 | [ALC269_FIXUP_DELL_M101Z] = { |
| 5825 | .type = ALC_FIXUP_VERBS, |
| 5826 | .v.verbs = (const struct hda_verb[]) { |
| 5827 | /* Enables internal speaker */ |
| 5828 | {0x20, AC_VERB_SET_COEF_INDEX, 13}, |
| 5829 | {0x20, AC_VERB_SET_PROC_COEF, 0x4040}, |
| 5830 | {} |
| 5831 | } |
| 5832 | }, |
| 5833 | [ALC269_FIXUP_SKU_IGNORE] = { |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame^] | 5834 | .type = ALC_FIXUP_FUNC, |
| 5835 | .v.func = alc_fixup_sku_ignore, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5836 | }, |
| 5837 | [ALC269_FIXUP_ASUS_G73JW] = { |
| 5838 | .type = ALC_FIXUP_PINS, |
| 5839 | .v.pins = (const struct alc_pincfg[]) { |
| 5840 | { 0x17, 0x99130111 }, /* subwoofer */ |
| 5841 | { } |
| 5842 | } |
| 5843 | }, |
| 5844 | [ALC269_FIXUP_LENOVO_EAPD] = { |
| 5845 | .type = ALC_FIXUP_VERBS, |
| 5846 | .v.verbs = (const struct hda_verb[]) { |
| 5847 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0}, |
| 5848 | {} |
| 5849 | } |
| 5850 | }, |
| 5851 | [ALC275_FIXUP_SONY_HWEQ] = { |
| 5852 | .type = ALC_FIXUP_FUNC, |
| 5853 | .v.func = alc269_fixup_hweq, |
| 5854 | .chained = true, |
| 5855 | .chain_id = ALC275_FIXUP_SONY_VAIO_GPIO2 |
| 5856 | }, |
| 5857 | [ALC271_FIXUP_DMIC] = { |
| 5858 | .type = ALC_FIXUP_FUNC, |
| 5859 | .v.func = alc271_fixup_dmic, |
| 5860 | }, |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 5861 | [ALC269_FIXUP_PCM_44K] = { |
| 5862 | .type = ALC_FIXUP_FUNC, |
| 5863 | .v.func = alc269_fixup_pcm_44k, |
| 5864 | }, |
Takashi Iwai | adabb3e | 2011-08-03 07:48:37 +0200 | [diff] [blame] | 5865 | [ALC269_FIXUP_STEREO_DMIC] = { |
| 5866 | .type = ALC_FIXUP_FUNC, |
| 5867 | .v.func = alc269_fixup_stereo_dmic, |
| 5868 | }, |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 5869 | [ALC269_FIXUP_QUANTA_MUTE] = { |
| 5870 | .type = ALC_FIXUP_FUNC, |
| 5871 | .v.func = alc269_fixup_quanta_mute, |
| 5872 | }, |
| 5873 | [ALC269_FIXUP_LIFEBOOK] = { |
| 5874 | .type = ALC_FIXUP_PINS, |
| 5875 | .v.pins = (const struct alc_pincfg[]) { |
| 5876 | { 0x1a, 0x2101103f }, /* dock line-out */ |
| 5877 | { 0x1b, 0x23a11040 }, /* dock mic-in */ |
| 5878 | { } |
| 5879 | }, |
| 5880 | .chained = true, |
| 5881 | .chain_id = ALC269_FIXUP_QUANTA_MUTE |
| 5882 | }, |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 5883 | [ALC269_FIXUP_AMIC] = { |
| 5884 | .type = ALC_FIXUP_PINS, |
| 5885 | .v.pins = (const struct alc_pincfg[]) { |
| 5886 | { 0x14, 0x99130110 }, /* speaker */ |
| 5887 | { 0x15, 0x0121401f }, /* HP out */ |
| 5888 | { 0x18, 0x01a19c20 }, /* mic */ |
| 5889 | { 0x19, 0x99a3092f }, /* int-mic */ |
| 5890 | { } |
| 5891 | }, |
| 5892 | }, |
| 5893 | [ALC269_FIXUP_DMIC] = { |
| 5894 | .type = ALC_FIXUP_PINS, |
| 5895 | .v.pins = (const struct alc_pincfg[]) { |
| 5896 | { 0x12, 0x99a3092f }, /* int-mic */ |
| 5897 | { 0x14, 0x99130110 }, /* speaker */ |
| 5898 | { 0x15, 0x0121401f }, /* HP out */ |
| 5899 | { 0x18, 0x01a19c20 }, /* mic */ |
| 5900 | { } |
| 5901 | }, |
| 5902 | }, |
| 5903 | [ALC269VB_FIXUP_AMIC] = { |
| 5904 | .type = ALC_FIXUP_PINS, |
| 5905 | .v.pins = (const struct alc_pincfg[]) { |
| 5906 | { 0x14, 0x99130110 }, /* speaker */ |
| 5907 | { 0x18, 0x01a19c20 }, /* mic */ |
| 5908 | { 0x19, 0x99a3092f }, /* int-mic */ |
| 5909 | { 0x21, 0x0121401f }, /* HP out */ |
| 5910 | { } |
| 5911 | }, |
| 5912 | }, |
David Henningsson | 2267ea9 | 2012-01-03 08:45:56 +0100 | [diff] [blame] | 5913 | [ALC269VB_FIXUP_DMIC] = { |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 5914 | .type = ALC_FIXUP_PINS, |
| 5915 | .v.pins = (const struct alc_pincfg[]) { |
| 5916 | { 0x12, 0x99a3092f }, /* int-mic */ |
| 5917 | { 0x14, 0x99130110 }, /* speaker */ |
| 5918 | { 0x18, 0x01a19c20 }, /* mic */ |
| 5919 | { 0x21, 0x0121401f }, /* HP out */ |
| 5920 | { } |
| 5921 | }, |
| 5922 | }, |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 5923 | [ALC269_FIXUP_MIC2_MUTE_LED] = { |
| 5924 | .type = ALC_FIXUP_FUNC, |
| 5925 | .v.func = alc269_fixup_mic2_mute, |
| 5926 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5927 | }; |
| 5928 | |
| 5929 | static const struct snd_pci_quirk alc269_fixup_tbl[] = { |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 5930 | SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_MIC2_MUTE_LED), |
David Henningsson | 5ac5755 | 2012-04-20 10:01:46 +0200 | [diff] [blame] | 5931 | SND_PCI_QUIRK(0x1043, 0x1427, "Asus Zenbook UX31E", ALC269VB_FIXUP_DMIC), |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 5932 | SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW), |
Takashi Iwai | adabb3e | 2011-08-03 07:48:37 +0200 | [diff] [blame] | 5933 | SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC), |
| 5934 | SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC), |
| 5935 | SND_PCI_QUIRK(0x1043, 0x834a, "ASUS S101", ALC269_FIXUP_STEREO_DMIC), |
| 5936 | SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC), |
| 5937 | SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5938 | SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2), |
| 5939 | SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ), |
| 5940 | SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ), |
| 5941 | SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO), |
| 5942 | SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z), |
| 5943 | SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC), |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 5944 | SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook", ALC269_FIXUP_LIFEBOOK), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5945 | SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE), |
| 5946 | SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE), |
| 5947 | SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE), |
| 5948 | SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE), |
| 5949 | SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE), |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 5950 | SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_QUANTA_MUTE), |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 5951 | SND_PCI_QUIRK(0x17aa, 0x3bf8, "Lenovo Ideapd", ALC269_FIXUP_PCM_44K), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5952 | SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD), |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 5953 | |
Takashi Iwai | a7f3eed | 2012-02-16 13:03:18 +0100 | [diff] [blame] | 5954 | #if 0 |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 5955 | /* Below is a quirk table taken from the old code. |
| 5956 | * Basically the device should work as is without the fixup table. |
| 5957 | * If BIOS doesn't give a proper info, enable the corresponding |
| 5958 | * fixup entry. |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 5959 | */ |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 5960 | SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A", |
| 5961 | ALC269_FIXUP_AMIC), |
| 5962 | SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269_FIXUP_AMIC), |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 5963 | SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269_FIXUP_AMIC), |
| 5964 | SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_FIXUP_AMIC), |
| 5965 | SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269_FIXUP_AMIC), |
| 5966 | SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269_FIXUP_AMIC), |
| 5967 | SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269_FIXUP_AMIC), |
| 5968 | SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269_FIXUP_AMIC), |
| 5969 | SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_FIXUP_AMIC), |
| 5970 | SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269_FIXUP_AMIC), |
| 5971 | SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_FIXUP_AMIC), |
| 5972 | SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_FIXUP_AMIC), |
| 5973 | SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_FIXUP_AMIC), |
| 5974 | SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_FIXUP_AMIC), |
| 5975 | SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_FIXUP_AMIC), |
| 5976 | SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_FIXUP_AMIC), |
| 5977 | SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_FIXUP_AMIC), |
| 5978 | SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_FIXUP_AMIC), |
| 5979 | SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_FIXUP_AMIC), |
| 5980 | SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_FIXUP_AMIC), |
| 5981 | SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_FIXUP_AMIC), |
| 5982 | SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_FIXUP_AMIC), |
| 5983 | SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_FIXUP_AMIC), |
| 5984 | SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_FIXUP_AMIC), |
| 5985 | SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_FIXUP_AMIC), |
| 5986 | SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_FIXUP_AMIC), |
| 5987 | SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_FIXUP_AMIC), |
| 5988 | SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_FIXUP_AMIC), |
| 5989 | SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_FIXUP_AMIC), |
| 5990 | SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_FIXUP_AMIC), |
| 5991 | SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_FIXUP_AMIC), |
| 5992 | SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_FIXUP_AMIC), |
| 5993 | SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_FIXUP_AMIC), |
| 5994 | SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_FIXUP_AMIC), |
| 5995 | SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_FIXUP_AMIC), |
| 5996 | SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_FIXUP_DMIC), |
| 5997 | SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_FIXUP_AMIC), |
| 5998 | SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_AMIC), |
| 5999 | SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_FIXUP_DMIC), |
| 6000 | SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_FIXUP_DMIC), |
| 6001 | #endif |
| 6002 | {} |
| 6003 | }; |
| 6004 | |
| 6005 | static const struct alc_model_fixup alc269_fixup_models[] = { |
| 6006 | {.id = ALC269_FIXUP_AMIC, .name = "laptop-amic"}, |
| 6007 | {.id = ALC269_FIXUP_DMIC, .name = "laptop-dmic"}, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6008 | {} |
| 6009 | }; |
| 6010 | |
| 6011 | |
Takashi Iwai | 546bb67 | 2012-03-07 08:37:19 +0100 | [diff] [blame] | 6012 | static void alc269_fill_coef(struct hda_codec *codec) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6013 | { |
Kailang Yang | 526af6e | 2012-03-07 08:25:20 +0100 | [diff] [blame] | 6014 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6015 | int val; |
| 6016 | |
Kailang Yang | 526af6e | 2012-03-07 08:25:20 +0100 | [diff] [blame] | 6017 | if (spec->codec_variant != ALC269_TYPE_ALC269VB) |
Takashi Iwai | 546bb67 | 2012-03-07 08:37:19 +0100 | [diff] [blame] | 6018 | return; |
Kailang Yang | 526af6e | 2012-03-07 08:25:20 +0100 | [diff] [blame] | 6019 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6020 | if ((alc_get_coef0(codec) & 0x00ff) < 0x015) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6021 | alc_write_coef_idx(codec, 0xf, 0x960b); |
| 6022 | alc_write_coef_idx(codec, 0xe, 0x8817); |
| 6023 | } |
| 6024 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6025 | if ((alc_get_coef0(codec) & 0x00ff) == 0x016) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6026 | alc_write_coef_idx(codec, 0xf, 0x960b); |
| 6027 | alc_write_coef_idx(codec, 0xe, 0x8814); |
| 6028 | } |
| 6029 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6030 | if ((alc_get_coef0(codec) & 0x00ff) == 0x017) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6031 | val = alc_read_coef_idx(codec, 0x04); |
| 6032 | /* Power up output pin */ |
| 6033 | alc_write_coef_idx(codec, 0x04, val | (1<<11)); |
| 6034 | } |
| 6035 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6036 | if ((alc_get_coef0(codec) & 0x00ff) == 0x018) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6037 | val = alc_read_coef_idx(codec, 0xd); |
| 6038 | if ((val & 0x0c00) >> 10 != 0x1) { |
| 6039 | /* Capless ramp up clock control */ |
| 6040 | alc_write_coef_idx(codec, 0xd, val | (1<<10)); |
| 6041 | } |
| 6042 | val = alc_read_coef_idx(codec, 0x17); |
| 6043 | if ((val & 0x01c0) >> 6 != 0x4) { |
| 6044 | /* Class D power on reset */ |
| 6045 | alc_write_coef_idx(codec, 0x17, val | (1<<7)); |
| 6046 | } |
| 6047 | } |
| 6048 | |
| 6049 | val = alc_read_coef_idx(codec, 0xd); /* Class D */ |
| 6050 | alc_write_coef_idx(codec, 0xd, val | (1<<14)); |
| 6051 | |
| 6052 | val = alc_read_coef_idx(codec, 0x4); /* HP */ |
| 6053 | alc_write_coef_idx(codec, 0x4, val | (1<<11)); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6054 | } |
| 6055 | |
| 6056 | /* |
| 6057 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6058 | static int patch_alc269(struct hda_codec *codec) |
| 6059 | { |
| 6060 | struct alc_spec *spec; |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6061 | int err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6062 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6063 | err = alc_alloc_spec(codec, 0x0b); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6064 | if (err < 0) |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6065 | return err; |
| 6066 | |
| 6067 | spec = codec->spec; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6068 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6069 | if (codec->vendor_id == 0x10ec0269) { |
| 6070 | spec->codec_variant = ALC269_TYPE_ALC269VA; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6071 | switch (alc_get_coef0(codec) & 0x00f0) { |
| 6072 | case 0x0010: |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6073 | if (codec->bus->pci->subsystem_vendor == 0x1025 && |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6074 | spec->cdefine.platform_type == 1) |
Takashi Iwai | 20ca0c3 | 2011-10-17 16:00:35 +0200 | [diff] [blame] | 6075 | err = alc_codec_rename(codec, "ALC271X"); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6076 | spec->codec_variant = ALC269_TYPE_ALC269VB; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6077 | break; |
| 6078 | case 0x0020: |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6079 | if (codec->bus->pci->subsystem_vendor == 0x17aa && |
| 6080 | codec->bus->pci->subsystem_device == 0x21f3) |
Takashi Iwai | 20ca0c3 | 2011-10-17 16:00:35 +0200 | [diff] [blame] | 6081 | err = alc_codec_rename(codec, "ALC3202"); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6082 | spec->codec_variant = ALC269_TYPE_ALC269VC; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6083 | break; |
| 6084 | default: |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6085 | alc_fix_pll_init(codec, 0x20, 0x04, 15); |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6086 | } |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6087 | if (err < 0) |
| 6088 | goto error; |
Takashi Iwai | 546bb67 | 2012-03-07 08:37:19 +0100 | [diff] [blame] | 6089 | spec->init_hook = alc269_fill_coef; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6090 | alc269_fill_coef(codec); |
| 6091 | } |
| 6092 | |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6093 | alc_pick_fixup(codec, alc269_fixup_models, |
| 6094 | alc269_fixup_tbl, alc269_fixups); |
| 6095 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6096 | |
Takashi Iwai | af741c1 | 2012-05-07 18:09:48 +0200 | [diff] [blame] | 6097 | alc_auto_parse_customize_define(codec); |
| 6098 | |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6099 | /* automatic parse from the BIOS config */ |
| 6100 | err = alc269_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6101 | if (err < 0) |
| 6102 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6103 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6104 | if (!spec->no_analog && has_cdefine_beep(codec)) { |
| 6105 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6106 | if (err < 0) |
| 6107 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6108 | set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6109 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6110 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6111 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 6112 | #ifdef CONFIG_PM |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6113 | codec->patch_ops.resume = alc269_resume; |
| 6114 | #endif |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6115 | spec->shutup = alc269_shutup; |
| 6116 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 6117 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 6118 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6119 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6120 | |
| 6121 | error: |
| 6122 | alc_free(codec); |
| 6123 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6124 | } |
| 6125 | |
| 6126 | /* |
| 6127 | * ALC861 |
| 6128 | */ |
| 6129 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6130 | static int alc861_parse_auto_config(struct hda_codec *codec) |
| 6131 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6132 | static const hda_nid_t alc861_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6133 | static const hda_nid_t alc861_ssids[] = { 0x0e, 0x0f, 0x0b, 0 }; |
| 6134 | return alc_parse_auto_config(codec, alc861_ignore, alc861_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6135 | } |
| 6136 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6137 | /* Pin config fixes */ |
| 6138 | enum { |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6139 | ALC861_FIXUP_FSC_AMILO_PI1505, |
| 6140 | ALC861_FIXUP_AMP_VREF_0F, |
| 6141 | ALC861_FIXUP_NO_JACK_DETECT, |
| 6142 | ALC861_FIXUP_ASUS_A6RP, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6143 | }; |
| 6144 | |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 6145 | /* On some laptops, VREF of pin 0x0f is abused for controlling the main amp */ |
| 6146 | static void alc861_fixup_asus_amp_vref_0f(struct hda_codec *codec, |
| 6147 | const struct alc_fixup *fix, int action) |
| 6148 | { |
| 6149 | struct alc_spec *spec = codec->spec; |
| 6150 | unsigned int val; |
| 6151 | |
| 6152 | if (action != ALC_FIXUP_ACT_INIT) |
| 6153 | return; |
| 6154 | val = snd_hda_codec_read(codec, 0x0f, 0, |
| 6155 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 6156 | if (!(val & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))) |
| 6157 | val |= AC_PINCTL_IN_EN; |
| 6158 | val |= AC_PINCTL_VREF_50; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 6159 | snd_hda_set_pin_ctl(codec, 0x0f, val); |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 6160 | spec->keep_vref_in_automute = 1; |
| 6161 | } |
| 6162 | |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6163 | /* suppress the jack-detection */ |
| 6164 | static void alc_fixup_no_jack_detect(struct hda_codec *codec, |
| 6165 | const struct alc_fixup *fix, int action) |
| 6166 | { |
| 6167 | if (action == ALC_FIXUP_ACT_PRE_PROBE) |
| 6168 | codec->no_jack_detect = 1; |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 6169 | } |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6170 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6171 | static const struct alc_fixup alc861_fixups[] = { |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6172 | [ALC861_FIXUP_FSC_AMILO_PI1505] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6173 | .type = ALC_FIXUP_PINS, |
| 6174 | .v.pins = (const struct alc_pincfg[]) { |
| 6175 | { 0x0b, 0x0221101f }, /* HP */ |
| 6176 | { 0x0f, 0x90170310 }, /* speaker */ |
| 6177 | { } |
| 6178 | } |
| 6179 | }, |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6180 | [ALC861_FIXUP_AMP_VREF_0F] = { |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 6181 | .type = ALC_FIXUP_FUNC, |
| 6182 | .v.func = alc861_fixup_asus_amp_vref_0f, |
Takashi Iwai | 3b25eb6 | 2012-01-25 09:55:46 +0100 | [diff] [blame] | 6183 | }, |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6184 | [ALC861_FIXUP_NO_JACK_DETECT] = { |
| 6185 | .type = ALC_FIXUP_FUNC, |
| 6186 | .v.func = alc_fixup_no_jack_detect, |
| 6187 | }, |
| 6188 | [ALC861_FIXUP_ASUS_A6RP] = { |
| 6189 | .type = ALC_FIXUP_FUNC, |
| 6190 | .v.func = alc861_fixup_asus_amp_vref_0f, |
| 6191 | .chained = true, |
| 6192 | .chain_id = ALC861_FIXUP_NO_JACK_DETECT, |
| 6193 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6194 | }; |
| 6195 | |
| 6196 | static const struct snd_pci_quirk alc861_fixup_tbl[] = { |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6197 | SND_PCI_QUIRK(0x1043, 0x1393, "ASUS A6Rp", ALC861_FIXUP_ASUS_A6RP), |
| 6198 | SND_PCI_QUIRK_VENDOR(0x1043, "ASUS laptop", ALC861_FIXUP_AMP_VREF_0F), |
| 6199 | SND_PCI_QUIRK(0x1462, 0x7254, "HP DX2200", ALC861_FIXUP_NO_JACK_DETECT), |
| 6200 | SND_PCI_QUIRK(0x1584, 0x2b01, "Haier W18", ALC861_FIXUP_AMP_VREF_0F), |
| 6201 | SND_PCI_QUIRK(0x1584, 0x0000, "Uniwill ECS M31EI", ALC861_FIXUP_AMP_VREF_0F), |
| 6202 | SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", ALC861_FIXUP_FSC_AMILO_PI1505), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6203 | {} |
| 6204 | }; |
| 6205 | |
| 6206 | /* |
| 6207 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6208 | static int patch_alc861(struct hda_codec *codec) |
| 6209 | { |
| 6210 | struct alc_spec *spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6211 | int err; |
| 6212 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6213 | err = alc_alloc_spec(codec, 0x15); |
| 6214 | if (err < 0) |
| 6215 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6216 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6217 | spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6218 | |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6219 | alc_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups); |
| 6220 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6221 | |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6222 | /* automatic parse from the BIOS config */ |
| 6223 | err = alc861_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6224 | if (err < 0) |
| 6225 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6226 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6227 | if (!spec->no_analog) { |
| 6228 | err = snd_hda_attach_beep_device(codec, 0x23); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6229 | if (err < 0) |
| 6230 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6231 | set_beep_amp(spec, 0x23, 0, HDA_OUTPUT); |
| 6232 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6233 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6234 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6235 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6236 | spec->power_hook = alc_power_eapd; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6237 | #endif |
| 6238 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 6239 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 6240 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6241 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6242 | |
| 6243 | error: |
| 6244 | alc_free(codec); |
| 6245 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6246 | } |
| 6247 | |
| 6248 | /* |
| 6249 | * ALC861-VD support |
| 6250 | * |
| 6251 | * Based on ALC882 |
| 6252 | * |
| 6253 | * In addition, an independent DAC |
| 6254 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6255 | static int alc861vd_parse_auto_config(struct hda_codec *codec) |
| 6256 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6257 | static const hda_nid_t alc861vd_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6258 | static const hda_nid_t alc861vd_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 6259 | return alc_parse_auto_config(codec, alc861vd_ignore, alc861vd_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6260 | } |
| 6261 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6262 | enum { |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6263 | ALC660VD_FIX_ASUS_GPIO1, |
| 6264 | ALC861VD_FIX_DALLAS, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6265 | }; |
| 6266 | |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6267 | /* exclude VREF80 */ |
| 6268 | static void alc861vd_fixup_dallas(struct hda_codec *codec, |
| 6269 | const struct alc_fixup *fix, int action) |
| 6270 | { |
| 6271 | if (action == ALC_FIXUP_ACT_PRE_PROBE) { |
| 6272 | snd_hda_override_pin_caps(codec, 0x18, 0x00001714); |
| 6273 | snd_hda_override_pin_caps(codec, 0x19, 0x0000171c); |
| 6274 | } |
| 6275 | } |
| 6276 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6277 | static const struct alc_fixup alc861vd_fixups[] = { |
| 6278 | [ALC660VD_FIX_ASUS_GPIO1] = { |
| 6279 | .type = ALC_FIXUP_VERBS, |
| 6280 | .v.verbs = (const struct hda_verb[]) { |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6281 | /* reset GPIO1 */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6282 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, |
| 6283 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, |
| 6284 | {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, |
| 6285 | { } |
| 6286 | } |
| 6287 | }, |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6288 | [ALC861VD_FIX_DALLAS] = { |
| 6289 | .type = ALC_FIXUP_FUNC, |
| 6290 | .v.func = alc861vd_fixup_dallas, |
| 6291 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6292 | }; |
| 6293 | |
| 6294 | static const struct snd_pci_quirk alc861vd_fixup_tbl[] = { |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6295 | SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_FIX_DALLAS), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6296 | SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1), |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6297 | SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_FIX_DALLAS), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6298 | {} |
| 6299 | }; |
| 6300 | |
| 6301 | static const struct hda_verb alc660vd_eapd_verbs[] = { |
| 6302 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, |
| 6303 | {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2}, |
| 6304 | { } |
| 6305 | }; |
| 6306 | |
| 6307 | /* |
| 6308 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6309 | static int patch_alc861vd(struct hda_codec *codec) |
| 6310 | { |
| 6311 | struct alc_spec *spec; |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6312 | int err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6313 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6314 | err = alc_alloc_spec(codec, 0x0b); |
| 6315 | if (err < 0) |
| 6316 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6317 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6318 | spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6319 | |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6320 | alc_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups); |
| 6321 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6322 | |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6323 | /* automatic parse from the BIOS config */ |
| 6324 | err = alc861vd_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6325 | if (err < 0) |
| 6326 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6327 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6328 | if (codec->vendor_id == 0x10ec0660) { |
| 6329 | /* always turn on EAPD */ |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame^] | 6330 | snd_hda_gen_add_verbs(&spec->gen, alc660vd_eapd_verbs); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6331 | } |
| 6332 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6333 | if (!spec->no_analog) { |
| 6334 | err = snd_hda_attach_beep_device(codec, 0x23); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6335 | if (err < 0) |
| 6336 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6337 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
| 6338 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6339 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6340 | codec->patch_ops = alc_patch_ops; |
| 6341 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6342 | spec->shutup = alc_eapd_shutup; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6343 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 6344 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 6345 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6346 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6347 | |
| 6348 | error: |
| 6349 | alc_free(codec); |
| 6350 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6351 | } |
| 6352 | |
| 6353 | /* |
| 6354 | * ALC662 support |
| 6355 | * |
| 6356 | * ALC662 is almost identical with ALC880 but has cleaner and more flexible |
| 6357 | * configuration. Each pin widget can choose any input DACs and a mixer. |
| 6358 | * Each ADC is connected from a mixer of all inputs. This makes possible |
| 6359 | * 6-channel independent captures. |
| 6360 | * |
| 6361 | * In addition, an independent DAC for the multi-playback (not used in this |
| 6362 | * driver yet). |
| 6363 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6364 | |
| 6365 | /* |
| 6366 | * BIOS auto configuration |
| 6367 | */ |
| 6368 | |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6369 | static int alc662_parse_auto_config(struct hda_codec *codec) |
| 6370 | { |
Takashi Iwai | 4c6d72d | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 6371 | static const hda_nid_t alc662_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6372 | static const hda_nid_t alc663_ssids[] = { 0x15, 0x1b, 0x14, 0x21 }; |
| 6373 | static const hda_nid_t alc662_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 6374 | const hda_nid_t *ssids; |
Takashi Iwai | ee979a14 | 2008-09-02 15:42:20 +0200 | [diff] [blame] | 6375 | |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 6376 | if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 || |
| 6377 | codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670) |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6378 | ssids = alc663_ssids; |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 6379 | else |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6380 | ssids = alc662_ssids; |
| 6381 | return alc_parse_auto_config(codec, alc662_ignore, ssids); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6382 | } |
| 6383 | |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 6384 | static void alc272_fixup_mario(struct hda_codec *codec, |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 6385 | const struct alc_fixup *fix, int action) |
Takashi Iwai | 6fc398c | 2011-01-13 14:36:37 +0100 | [diff] [blame] | 6386 | { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 6387 | if (action != ALC_FIXUP_ACT_PROBE) |
Takashi Iwai | 6fc398c | 2011-01-13 14:36:37 +0100 | [diff] [blame] | 6388 | return; |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 6389 | if (snd_hda_override_amp_caps(codec, 0x2, HDA_OUTPUT, |
| 6390 | (0x3b << AC_AMPCAP_OFFSET_SHIFT) | |
| 6391 | (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT) | |
| 6392 | (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT) | |
| 6393 | (0 << AC_AMPCAP_MUTE_SHIFT))) |
| 6394 | printk(KERN_WARNING |
| 6395 | "hda_codec: failed to override amp caps for NID 0x2\n"); |
| 6396 | } |
| 6397 | |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6398 | enum { |
Daniel T Chen | 2df0351 | 2010-10-10 22:39:28 -0400 | [diff] [blame] | 6399 | ALC662_FIXUP_ASPIRE, |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6400 | ALC662_FIXUP_IDEAPAD, |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 6401 | ALC272_FIXUP_MARIO, |
Anisse Astier | d2ebd47 | 2011-01-20 12:36:21 +0100 | [diff] [blame] | 6402 | ALC662_FIXUP_CZC_P10T, |
David Henningsson | 94024cd | 2011-04-29 14:10:55 +0200 | [diff] [blame] | 6403 | ALC662_FIXUP_SKU_IGNORE, |
Takashi Iwai | e59ea3e | 2011-06-29 17:21:00 +0200 | [diff] [blame] | 6404 | ALC662_FIXUP_HP_RP5800, |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6405 | ALC662_FIXUP_ASUS_MODE1, |
| 6406 | ALC662_FIXUP_ASUS_MODE2, |
| 6407 | ALC662_FIXUP_ASUS_MODE3, |
| 6408 | ALC662_FIXUP_ASUS_MODE4, |
| 6409 | ALC662_FIXUP_ASUS_MODE5, |
| 6410 | ALC662_FIXUP_ASUS_MODE6, |
| 6411 | ALC662_FIXUP_ASUS_MODE7, |
| 6412 | ALC662_FIXUP_ASUS_MODE8, |
Takashi Iwai | 1565cc3 | 2012-02-13 12:03:25 +0100 | [diff] [blame] | 6413 | ALC662_FIXUP_NO_JACK_DETECT, |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6414 | }; |
| 6415 | |
| 6416 | static const struct alc_fixup alc662_fixups[] = { |
Daniel T Chen | 2df0351 | 2010-10-10 22:39:28 -0400 | [diff] [blame] | 6417 | [ALC662_FIXUP_ASPIRE] = { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 6418 | .type = ALC_FIXUP_PINS, |
| 6419 | .v.pins = (const struct alc_pincfg[]) { |
Daniel T Chen | 2df0351 | 2010-10-10 22:39:28 -0400 | [diff] [blame] | 6420 | { 0x15, 0x99130112 }, /* subwoofer */ |
| 6421 | { } |
| 6422 | } |
| 6423 | }, |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6424 | [ALC662_FIXUP_IDEAPAD] = { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 6425 | .type = ALC_FIXUP_PINS, |
| 6426 | .v.pins = (const struct alc_pincfg[]) { |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6427 | { 0x17, 0x99130112 }, /* subwoofer */ |
| 6428 | { } |
| 6429 | } |
| 6430 | }, |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 6431 | [ALC272_FIXUP_MARIO] = { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 6432 | .type = ALC_FIXUP_FUNC, |
| 6433 | .v.func = alc272_fixup_mario, |
Anisse Astier | d2ebd47 | 2011-01-20 12:36:21 +0100 | [diff] [blame] | 6434 | }, |
| 6435 | [ALC662_FIXUP_CZC_P10T] = { |
| 6436 | .type = ALC_FIXUP_VERBS, |
| 6437 | .v.verbs = (const struct hda_verb[]) { |
| 6438 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0}, |
| 6439 | {} |
| 6440 | } |
| 6441 | }, |
David Henningsson | 94024cd | 2011-04-29 14:10:55 +0200 | [diff] [blame] | 6442 | [ALC662_FIXUP_SKU_IGNORE] = { |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame^] | 6443 | .type = ALC_FIXUP_FUNC, |
| 6444 | .v.func = alc_fixup_sku_ignore, |
Takashi Iwai | c6b3587 | 2011-03-28 12:05:31 +0200 | [diff] [blame] | 6445 | }, |
Takashi Iwai | e59ea3e | 2011-06-29 17:21:00 +0200 | [diff] [blame] | 6446 | [ALC662_FIXUP_HP_RP5800] = { |
| 6447 | .type = ALC_FIXUP_PINS, |
| 6448 | .v.pins = (const struct alc_pincfg[]) { |
| 6449 | { 0x14, 0x0221201f }, /* HP out */ |
| 6450 | { } |
| 6451 | }, |
| 6452 | .chained = true, |
| 6453 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6454 | }, |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6455 | [ALC662_FIXUP_ASUS_MODE1] = { |
| 6456 | .type = ALC_FIXUP_PINS, |
| 6457 | .v.pins = (const struct alc_pincfg[]) { |
| 6458 | { 0x14, 0x99130110 }, /* speaker */ |
| 6459 | { 0x18, 0x01a19c20 }, /* mic */ |
| 6460 | { 0x19, 0x99a3092f }, /* int-mic */ |
| 6461 | { 0x21, 0x0121401f }, /* HP out */ |
| 6462 | { } |
| 6463 | }, |
| 6464 | .chained = true, |
| 6465 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6466 | }, |
| 6467 | [ALC662_FIXUP_ASUS_MODE2] = { |
Takashi Iwai | 2996bdb | 2011-08-18 16:02:24 +0200 | [diff] [blame] | 6468 | .type = ALC_FIXUP_PINS, |
| 6469 | .v.pins = (const struct alc_pincfg[]) { |
| 6470 | { 0x14, 0x99130110 }, /* speaker */ |
| 6471 | { 0x18, 0x01a19820 }, /* mic */ |
| 6472 | { 0x19, 0x99a3092f }, /* int-mic */ |
| 6473 | { 0x1b, 0x0121401f }, /* HP out */ |
| 6474 | { } |
| 6475 | }, |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6476 | .chained = true, |
| 6477 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6478 | }, |
| 6479 | [ALC662_FIXUP_ASUS_MODE3] = { |
| 6480 | .type = ALC_FIXUP_PINS, |
| 6481 | .v.pins = (const struct alc_pincfg[]) { |
| 6482 | { 0x14, 0x99130110 }, /* speaker */ |
| 6483 | { 0x15, 0x0121441f }, /* HP */ |
| 6484 | { 0x18, 0x01a19840 }, /* mic */ |
| 6485 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 6486 | { 0x21, 0x01211420 }, /* HP2 */ |
| 6487 | { } |
| 6488 | }, |
| 6489 | .chained = true, |
| 6490 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6491 | }, |
| 6492 | [ALC662_FIXUP_ASUS_MODE4] = { |
| 6493 | .type = ALC_FIXUP_PINS, |
| 6494 | .v.pins = (const struct alc_pincfg[]) { |
| 6495 | { 0x14, 0x99130110 }, /* speaker */ |
| 6496 | { 0x16, 0x99130111 }, /* speaker */ |
| 6497 | { 0x18, 0x01a19840 }, /* mic */ |
| 6498 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 6499 | { 0x21, 0x0121441f }, /* HP */ |
| 6500 | { } |
| 6501 | }, |
| 6502 | .chained = true, |
| 6503 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6504 | }, |
| 6505 | [ALC662_FIXUP_ASUS_MODE5] = { |
| 6506 | .type = ALC_FIXUP_PINS, |
| 6507 | .v.pins = (const struct alc_pincfg[]) { |
| 6508 | { 0x14, 0x99130110 }, /* speaker */ |
| 6509 | { 0x15, 0x0121441f }, /* HP */ |
| 6510 | { 0x16, 0x99130111 }, /* speaker */ |
| 6511 | { 0x18, 0x01a19840 }, /* mic */ |
| 6512 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 6513 | { } |
| 6514 | }, |
| 6515 | .chained = true, |
| 6516 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6517 | }, |
| 6518 | [ALC662_FIXUP_ASUS_MODE6] = { |
| 6519 | .type = ALC_FIXUP_PINS, |
| 6520 | .v.pins = (const struct alc_pincfg[]) { |
| 6521 | { 0x14, 0x99130110 }, /* speaker */ |
| 6522 | { 0x15, 0x01211420 }, /* HP2 */ |
| 6523 | { 0x18, 0x01a19840 }, /* mic */ |
| 6524 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 6525 | { 0x1b, 0x0121441f }, /* HP */ |
| 6526 | { } |
| 6527 | }, |
| 6528 | .chained = true, |
| 6529 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6530 | }, |
| 6531 | [ALC662_FIXUP_ASUS_MODE7] = { |
| 6532 | .type = ALC_FIXUP_PINS, |
| 6533 | .v.pins = (const struct alc_pincfg[]) { |
| 6534 | { 0x14, 0x99130110 }, /* speaker */ |
| 6535 | { 0x17, 0x99130111 }, /* speaker */ |
| 6536 | { 0x18, 0x01a19840 }, /* mic */ |
| 6537 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 6538 | { 0x1b, 0x01214020 }, /* HP */ |
| 6539 | { 0x21, 0x0121401f }, /* HP */ |
| 6540 | { } |
| 6541 | }, |
| 6542 | .chained = true, |
| 6543 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6544 | }, |
| 6545 | [ALC662_FIXUP_ASUS_MODE8] = { |
| 6546 | .type = ALC_FIXUP_PINS, |
| 6547 | .v.pins = (const struct alc_pincfg[]) { |
| 6548 | { 0x14, 0x99130110 }, /* speaker */ |
| 6549 | { 0x12, 0x99a30970 }, /* int-mic */ |
| 6550 | { 0x15, 0x01214020 }, /* HP */ |
| 6551 | { 0x17, 0x99130111 }, /* speaker */ |
| 6552 | { 0x18, 0x01a19840 }, /* mic */ |
| 6553 | { 0x21, 0x0121401f }, /* HP */ |
| 6554 | { } |
| 6555 | }, |
| 6556 | .chained = true, |
| 6557 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
Takashi Iwai | 2996bdb | 2011-08-18 16:02:24 +0200 | [diff] [blame] | 6558 | }, |
Takashi Iwai | 1565cc3 | 2012-02-13 12:03:25 +0100 | [diff] [blame] | 6559 | [ALC662_FIXUP_NO_JACK_DETECT] = { |
| 6560 | .type = ALC_FIXUP_FUNC, |
| 6561 | .v.func = alc_fixup_no_jack_detect, |
| 6562 | }, |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6563 | }; |
| 6564 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 6565 | static const struct snd_pci_quirk alc662_fixup_tbl[] = { |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6566 | SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_FIXUP_ASUS_MODE2), |
David Henningsson | a6c47a8 | 2011-02-10 15:39:19 +0100 | [diff] [blame] | 6567 | SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE), |
David Henningsson | 94024cd | 2011-04-29 14:10:55 +0200 | [diff] [blame] | 6568 | SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE), |
Daniel T Chen | 2df0351 | 2010-10-10 22:39:28 -0400 | [diff] [blame] | 6569 | SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE), |
Takashi Iwai | e59ea3e | 2011-06-29 17:21:00 +0200 | [diff] [blame] | 6570 | SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800), |
Takashi Iwai | 1565cc3 | 2012-02-13 12:03:25 +0100 | [diff] [blame] | 6571 | SND_PCI_QUIRK(0x1043, 0x8469, "ASUS mobo", ALC662_FIXUP_NO_JACK_DETECT), |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6572 | SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2), |
Daniel T Chen | a0e90ac | 2010-11-20 10:20:35 -0500 | [diff] [blame] | 6573 | SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD), |
Valentine Sinitsyn | d411858 | 2010-10-01 22:24:08 +0600 | [diff] [blame] | 6574 | SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD), |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6575 | SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD), |
Anisse Astier | d2ebd47 | 2011-01-20 12:36:21 +0100 | [diff] [blame] | 6576 | SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T), |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6577 | |
| 6578 | #if 0 |
| 6579 | /* Below is a quirk table taken from the old code. |
| 6580 | * Basically the device should work as is without the fixup table. |
| 6581 | * If BIOS doesn't give a proper info, enable the corresponding |
| 6582 | * fixup entry. |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 6583 | */ |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6584 | SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC662_FIXUP_ASUS_MODE1), |
| 6585 | SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC662_FIXUP_ASUS_MODE3), |
| 6586 | SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC662_FIXUP_ASUS_MODE1), |
| 6587 | SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC662_FIXUP_ASUS_MODE3), |
| 6588 | SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), |
| 6589 | SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6590 | SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), |
| 6591 | SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC662_FIXUP_ASUS_MODE1), |
| 6592 | SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC662_FIXUP_ASUS_MODE1), |
| 6593 | SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6594 | SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC662_FIXUP_ASUS_MODE7), |
| 6595 | SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC662_FIXUP_ASUS_MODE7), |
| 6596 | SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC662_FIXUP_ASUS_MODE8), |
| 6597 | SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC662_FIXUP_ASUS_MODE3), |
| 6598 | SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC662_FIXUP_ASUS_MODE1), |
| 6599 | SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6600 | SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_FIXUP_ASUS_MODE2), |
| 6601 | SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC662_FIXUP_ASUS_MODE1), |
| 6602 | SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6603 | SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC662_FIXUP_ASUS_MODE6), |
| 6604 | SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC662_FIXUP_ASUS_MODE6), |
| 6605 | SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6606 | SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC662_FIXUP_ASUS_MODE1), |
| 6607 | SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC662_FIXUP_ASUS_MODE3), |
| 6608 | SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_FIXUP_ASUS_MODE2), |
| 6609 | SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6610 | SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC662_FIXUP_ASUS_MODE5), |
| 6611 | SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC662_FIXUP_ASUS_MODE6), |
| 6612 | SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6613 | SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC662_FIXUP_ASUS_MODE1), |
| 6614 | SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6615 | SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6616 | SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC662_FIXUP_ASUS_MODE3), |
| 6617 | SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC662_FIXUP_ASUS_MODE3), |
| 6618 | SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC662_FIXUP_ASUS_MODE1), |
| 6619 | SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC662_FIXUP_ASUS_MODE1), |
| 6620 | SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC662_FIXUP_ASUS_MODE1), |
| 6621 | SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC662_FIXUP_ASUS_MODE1), |
| 6622 | SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC662_FIXUP_ASUS_MODE1), |
| 6623 | SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6624 | SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_FIXUP_ASUS_MODE2), |
| 6625 | SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC662_FIXUP_ASUS_MODE1), |
| 6626 | SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), |
| 6627 | SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC662_FIXUP_ASUS_MODE3), |
| 6628 | SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC662_FIXUP_ASUS_MODE1), |
| 6629 | SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC662_FIXUP_ASUS_MODE1), |
| 6630 | SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC662_FIXUP_ASUS_MODE1), |
| 6631 | SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_FIXUP_ASUS_MODE2), |
| 6632 | SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), |
| 6633 | SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE4), |
| 6634 | #endif |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6635 | {} |
| 6636 | }; |
| 6637 | |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 6638 | static const struct alc_model_fixup alc662_fixup_models[] = { |
| 6639 | {.id = ALC272_FIXUP_MARIO, .name = "mario"}, |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6640 | {.id = ALC662_FIXUP_ASUS_MODE1, .name = "asus-mode1"}, |
| 6641 | {.id = ALC662_FIXUP_ASUS_MODE2, .name = "asus-mode2"}, |
| 6642 | {.id = ALC662_FIXUP_ASUS_MODE3, .name = "asus-mode3"}, |
| 6643 | {.id = ALC662_FIXUP_ASUS_MODE4, .name = "asus-mode4"}, |
| 6644 | {.id = ALC662_FIXUP_ASUS_MODE5, .name = "asus-mode5"}, |
| 6645 | {.id = ALC662_FIXUP_ASUS_MODE6, .name = "asus-mode6"}, |
| 6646 | {.id = ALC662_FIXUP_ASUS_MODE7, .name = "asus-mode7"}, |
| 6647 | {.id = ALC662_FIXUP_ASUS_MODE8, .name = "asus-mode8"}, |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 6648 | {} |
| 6649 | }; |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6650 | |
| 6651 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6652 | /* |
| 6653 | */ |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6654 | static int patch_alc662(struct hda_codec *codec) |
| 6655 | { |
| 6656 | struct alc_spec *spec; |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6657 | int err; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6658 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6659 | err = alc_alloc_spec(codec, 0x0b); |
| 6660 | if (err < 0) |
| 6661 | return err; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6662 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6663 | spec = codec->spec; |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 6664 | |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6665 | /* handle multiple HPs as is */ |
| 6666 | spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP; |
| 6667 | |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 6668 | alc_fix_pll_init(codec, 0x20, 0x04, 15); |
| 6669 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6670 | if ((alc_get_coef0(codec) & (1 << 14)) && |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6671 | codec->bus->pci->subsystem_vendor == 0x1025 && |
| 6672 | spec->cdefine.platform_type == 1) { |
| 6673 | if (alc_codec_rename(codec, "ALC272X") < 0) |
| 6674 | goto error; |
Takashi Iwai | 20ca0c3 | 2011-10-17 16:00:35 +0200 | [diff] [blame] | 6675 | } |
Kailang Yang | 274693f | 2009-12-03 10:07:50 +0100 | [diff] [blame] | 6676 | |
Takashi Iwai | b9c5106 | 2011-08-24 18:08:07 +0200 | [diff] [blame] | 6677 | alc_pick_fixup(codec, alc662_fixup_models, |
| 6678 | alc662_fixup_tbl, alc662_fixups); |
| 6679 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | af741c1 | 2012-05-07 18:09:48 +0200 | [diff] [blame] | 6680 | |
| 6681 | alc_auto_parse_customize_define(codec); |
| 6682 | |
Takashi Iwai | b9c5106 | 2011-08-24 18:08:07 +0200 | [diff] [blame] | 6683 | /* automatic parse from the BIOS config */ |
| 6684 | err = alc662_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6685 | if (err < 0) |
| 6686 | goto error; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6687 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6688 | if (!spec->no_analog && has_cdefine_beep(codec)) { |
| 6689 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6690 | if (err < 0) |
| 6691 | goto error; |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 6692 | switch (codec->vendor_id) { |
| 6693 | case 0x10ec0662: |
| 6694 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
| 6695 | break; |
| 6696 | case 0x10ec0272: |
| 6697 | case 0x10ec0663: |
| 6698 | case 0x10ec0665: |
| 6699 | set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); |
| 6700 | break; |
| 6701 | case 0x10ec0273: |
| 6702 | set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT); |
| 6703 | break; |
| 6704 | } |
Kailang Yang | cec27c8 | 2010-02-04 14:18:18 +0100 | [diff] [blame] | 6705 | } |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 6706 | |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6707 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1c716153 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 6708 | spec->shutup = alc_eapd_shutup; |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6709 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 6710 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 6711 | |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6712 | return 0; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6713 | |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6714 | error: |
| 6715 | alc_free(codec); |
| 6716 | return err; |
Kailang Yang | b478b99 | 2011-05-18 11:51:15 +0200 | [diff] [blame] | 6717 | } |
| 6718 | |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6719 | /* |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6720 | * ALC680 support |
| 6721 | */ |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6722 | |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6723 | static int alc680_parse_auto_config(struct hda_codec *codec) |
| 6724 | { |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6725 | return alc_parse_auto_config(codec, NULL, NULL); |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6726 | } |
| 6727 | |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6728 | /* |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6729 | */ |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6730 | static int patch_alc680(struct hda_codec *codec) |
| 6731 | { |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6732 | int err; |
| 6733 | |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 6734 | /* ALC680 has no aa-loopback mixer */ |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6735 | err = alc_alloc_spec(codec, 0); |
| 6736 | if (err < 0) |
| 6737 | return err; |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 6738 | |
Takashi Iwai | 1ebec5f | 2011-08-15 13:21:48 +0200 | [diff] [blame] | 6739 | /* automatic parse from the BIOS config */ |
| 6740 | err = alc680_parse_auto_config(codec); |
| 6741 | if (err < 0) { |
| 6742 | alc_free(codec); |
| 6743 | return err; |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6744 | } |
| 6745 | |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6746 | codec->patch_ops = alc_patch_ops; |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6747 | |
| 6748 | return 0; |
| 6749 | } |
| 6750 | |
| 6751 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6752 | * patch entries |
| 6753 | */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 6754 | static const struct hda_codec_preset snd_hda_preset_realtek[] = { |
Kailang Yang | 296f033 | 2011-05-18 11:52:36 +0200 | [diff] [blame] | 6755 | { .id = 0x10ec0221, .name = "ALC221", .patch = patch_alc269 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6756 | { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 6757 | { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 }, |
Kailang Yang | f6a9224 | 2007-12-13 16:52:54 +0100 | [diff] [blame] | 6758 | { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 }, |
Kailang Yang | a361d84 | 2007-06-05 12:30:55 +0200 | [diff] [blame] | 6759 | { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 }, |
Kailang Yang | f6a9224 | 2007-12-13 16:52:54 +0100 | [diff] [blame] | 6760 | { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 }, |
Kailang Yang | ebb83ee | 2009-12-17 12:23:00 +0100 | [diff] [blame] | 6761 | { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 }, |
Kailang Yang | 01afd41 | 2008-10-15 11:22:09 +0200 | [diff] [blame] | 6762 | { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 }, |
Kailang Yang | ebb83ee | 2009-12-17 12:23:00 +0100 | [diff] [blame] | 6763 | { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 }, |
Kailang Yang | 296f033 | 2011-05-18 11:52:36 +0200 | [diff] [blame] | 6764 | { .id = 0x10ec0276, .name = "ALC276", .patch = patch_alc269 }, |
Jakub Schmidtke | f32610e | 2007-02-02 18:17:27 +0100 | [diff] [blame] | 6765 | { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660", |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6766 | .patch = patch_alc861 }, |
Jakub Schmidtke | f32610e | 2007-02-02 18:17:27 +0100 | [diff] [blame] | 6767 | { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd }, |
| 6768 | { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 }, |
| 6769 | { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd }, |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6770 | { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2", |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 6771 | .patch = patch_alc882 }, |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6772 | { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1", |
| 6773 | .patch = patch_alc662 }, |
David Henningsson | cc667a7 | 2011-10-18 14:07:51 +0200 | [diff] [blame] | 6774 | { .id = 0x10ec0662, .rev = 0x100300, .name = "ALC662 rev3", |
| 6775 | .patch = patch_alc662 }, |
Kailang Yang | 6dda9f4 | 2008-05-27 12:05:31 +0200 | [diff] [blame] | 6776 | { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 }, |
Kailang Yang | cec27c8 | 2010-02-04 14:18:18 +0100 | [diff] [blame] | 6777 | { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 }, |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 6778 | { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 }, |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6779 | { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 }, |
Jakub Schmidtke | f32610e | 2007-02-02 18:17:27 +0100 | [diff] [blame] | 6780 | { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6781 | { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 }, |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 6782 | { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 }, |
Clive Messer | 669faba | 2008-09-30 15:49:13 +0200 | [diff] [blame] | 6783 | { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A", |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 6784 | .patch = patch_alc882 }, |
Takashi Iwai | cb308f9 | 2008-04-16 14:13:29 +0200 | [diff] [blame] | 6785 | { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A", |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 6786 | .patch = patch_alc882 }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 6787 | { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 }, |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6788 | { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 }, |
Kailang Yang | 4442608 | 2008-10-15 11:18:05 +0200 | [diff] [blame] | 6789 | { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200", |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 6790 | .patch = patch_alc882 }, |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6791 | { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc882 }, |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 6792 | { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 }, |
Kailang Yang | 274693f | 2009-12-03 10:07:50 +0100 | [diff] [blame] | 6793 | { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 }, |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6794 | { .id = 0x10ec0899, .name = "ALC898", .patch = patch_alc882 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6795 | {} /* terminator */ |
| 6796 | }; |
Takashi Iwai | 1289e9e | 2008-11-27 15:47:11 +0100 | [diff] [blame] | 6797 | |
| 6798 | MODULE_ALIAS("snd-hda-codec-id:10ec*"); |
| 6799 | |
| 6800 | MODULE_LICENSE("GPL"); |
| 6801 | MODULE_DESCRIPTION("Realtek HD-audio codec"); |
| 6802 | |
| 6803 | static struct hda_codec_preset_list realtek_list = { |
| 6804 | .preset = snd_hda_preset_realtek, |
| 6805 | .owner = THIS_MODULE, |
| 6806 | }; |
| 6807 | |
| 6808 | static int __init patch_realtek_init(void) |
| 6809 | { |
| 6810 | return snd_hda_add_codec_preset(&realtek_list); |
| 6811 | } |
| 6812 | |
| 6813 | static void __exit patch_realtek_exit(void) |
| 6814 | { |
| 6815 | snd_hda_delete_codec_preset(&realtek_list); |
| 6816 | } |
| 6817 | |
| 6818 | module_init(patch_realtek_init) |
| 6819 | module_exit(patch_realtek_exit) |