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 | 409a3e9 | 2012-03-27 13:01:01 +1030 | [diff] [blame] | 9 | * Jonathan Woithe <jwoithe@just42.net> |
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> |
Takashi Iwai | ab16c6d | 2012-11-29 09:56:50 +0100 | [diff] [blame^] | 31 | #include <linux/sort.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | #include <sound/core.h> |
Kailang Yang | 9ad0e49 | 2010-09-14 23:22:00 +0200 | [diff] [blame] | 33 | #include <sound/jack.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | #include "hda_codec.h" |
| 35 | #include "hda_local.h" |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 36 | #include "hda_auto_parser.h" |
Kusanagi Kouichi | 680cd53 | 2009-02-05 00:00:58 +0900 | [diff] [blame] | 37 | #include "hda_beep.h" |
Takashi Iwai | 1835a0f | 2011-10-27 22:12:46 +0200 | [diff] [blame] | 38 | #include "hda_jack.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 40 | /* unsol event tags */ |
| 41 | #define ALC_FRONT_EVENT 0x01 |
| 42 | #define ALC_DCVOL_EVENT 0x02 |
| 43 | #define ALC_HP_EVENT 0x04 |
| 44 | #define ALC_MIC_EVENT 0x08 |
Takashi Iwai | d4a86d8 | 2010-06-23 17:51:26 +0200 | [diff] [blame] | 45 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 46 | /* for GPIO Poll */ |
| 47 | #define GPIO_MASK 0x03 |
| 48 | |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 49 | /* extra amp-initialization sequence types */ |
| 50 | enum { |
| 51 | ALC_INIT_NONE, |
| 52 | ALC_INIT_DEFAULT, |
| 53 | ALC_INIT_GPIO1, |
| 54 | ALC_INIT_GPIO2, |
| 55 | ALC_INIT_GPIO3, |
| 56 | }; |
| 57 | |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 58 | struct alc_customize_define { |
| 59 | unsigned int sku_cfg; |
| 60 | unsigned char port_connectivity; |
| 61 | unsigned char check_sum; |
| 62 | unsigned char customization; |
| 63 | unsigned char external_amp; |
| 64 | unsigned int enable_pcbeep:1; |
| 65 | unsigned int platform_type:1; |
| 66 | unsigned int swap:1; |
| 67 | unsigned int override:1; |
David Henningsson | 9062291 | 2010-10-14 14:50:18 +0200 | [diff] [blame] | 68 | 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] | 69 | }; |
| 70 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 71 | struct alc_multi_io { |
| 72 | hda_nid_t pin; /* multi-io widget pin NID */ |
| 73 | hda_nid_t dac; /* DAC to be connected */ |
| 74 | unsigned int ctl_in; /* cached input-pin control value */ |
| 75 | }; |
| 76 | |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 77 | /* make compatible with old code */ |
| 78 | #define alc_apply_pincfgs snd_hda_apply_pincfgs |
| 79 | #define alc_apply_fixup snd_hda_apply_fixup |
| 80 | #define alc_pick_fixup snd_hda_pick_fixup |
| 81 | #define alc_fixup hda_fixup |
| 82 | #define alc_pincfg hda_pintbl |
| 83 | #define alc_model_fixup hda_model_fixup |
| 84 | |
| 85 | #define ALC_FIXUP_PINS HDA_FIXUP_PINS |
| 86 | #define ALC_FIXUP_VERBS HDA_FIXUP_VERBS |
| 87 | #define ALC_FIXUP_FUNC HDA_FIXUP_FUNC |
| 88 | |
| 89 | #define ALC_FIXUP_ACT_PRE_PROBE HDA_FIXUP_ACT_PRE_PROBE |
| 90 | #define ALC_FIXUP_ACT_PROBE HDA_FIXUP_ACT_PROBE |
| 91 | #define ALC_FIXUP_ACT_INIT HDA_FIXUP_ACT_INIT |
| 92 | #define ALC_FIXUP_ACT_BUILD HDA_FIXUP_ACT_BUILD |
| 93 | |
Takashi Iwai | ab16c6d | 2012-11-29 09:56:50 +0100 | [diff] [blame^] | 94 | #define MAX_AUTO_MIC_PINS 3 |
| 95 | |
| 96 | struct alc_automic_entry { |
| 97 | hda_nid_t pin; /* pin */ |
| 98 | int idx; /* imux index, -1 = invalid */ |
| 99 | unsigned int attr; /* pin attribute (INPUT_PIN_ATTR_*) */ |
| 100 | }; |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 101 | |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 102 | #define MAX_NID_PATH_DEPTH 5 |
| 103 | |
Takashi Iwai | 8dd4867 | 2012-12-14 18:19:04 +0100 | [diff] [blame] | 104 | enum { |
| 105 | NID_PATH_VOL_CTL, |
| 106 | NID_PATH_MUTE_CTL, |
| 107 | NID_PATH_BOOST_CTL, |
| 108 | NID_PATH_NUM_CTLS |
| 109 | }; |
| 110 | |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 111 | /* Widget connection path |
| 112 | * |
| 113 | * For output, stored in the order of DAC -> ... -> pin, |
| 114 | * for input, pin -> ... -> ADC. |
| 115 | * |
Takashi Iwai | 95e960c | 2012-12-10 17:27:57 +0100 | [diff] [blame] | 116 | * idx[i] contains the source index number to select on of the widget path[i]; |
| 117 | * e.g. idx[1] is the index of the DAC (path[0]) selected by path[1] widget |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 118 | * multi[] indicates whether it's a selector widget with multi-connectors |
| 119 | * (i.e. the connection selection is mandatory) |
| 120 | * vol_ctl and mute_ctl contains the NIDs for the assigned mixers |
| 121 | */ |
| 122 | struct nid_path { |
| 123 | int depth; |
| 124 | hda_nid_t path[MAX_NID_PATH_DEPTH]; |
| 125 | unsigned char idx[MAX_NID_PATH_DEPTH]; |
| 126 | unsigned char multi[MAX_NID_PATH_DEPTH]; |
Takashi Iwai | 8dd4867 | 2012-12-14 18:19:04 +0100 | [diff] [blame] | 127 | unsigned int ctls[NID_PATH_NUM_CTLS]; /* NID_PATH_XXX_CTL */ |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 128 | bool active; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 129 | }; |
| 130 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | struct alc_spec { |
| 132 | /* codec parameterization */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 133 | const struct snd_kcontrol_new *mixers[5]; /* mixer arrays */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | unsigned int num_mixers; |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 135 | unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | |
Takashi Iwai | aa563af | 2009-07-31 10:05:11 +0200 | [diff] [blame] | 137 | char stream_name_analog[32]; /* analog PCM stream */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 138 | const struct hda_pcm_stream *stream_analog_playback; |
| 139 | const struct hda_pcm_stream *stream_analog_capture; |
| 140 | const struct hda_pcm_stream *stream_analog_alt_playback; |
| 141 | const struct hda_pcm_stream *stream_analog_alt_capture; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 142 | |
Takashi Iwai | aa563af | 2009-07-31 10:05:11 +0200 | [diff] [blame] | 143 | char stream_name_digital[32]; /* digital PCM stream */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 144 | const struct hda_pcm_stream *stream_digital_playback; |
| 145 | const struct hda_pcm_stream *stream_digital_capture; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | |
| 147 | /* playback */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 148 | struct hda_multi_out multiout; /* playback set-up |
| 149 | * max_channels, dacs must be set |
| 150 | * dig_out_nid and hp_nid are optional |
| 151 | */ |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 152 | hda_nid_t alt_dac_nid; |
Takashi Iwai | 6a05ac4 | 2009-02-13 11:19:09 +0100 | [diff] [blame] | 153 | hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */ |
Takashi Iwai | 8c44198 | 2009-01-20 18:30:20 +0100 | [diff] [blame] | 154 | int dig_out_type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 155 | |
| 156 | /* capture */ |
| 157 | unsigned int num_adc_nids; |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 158 | hda_nid_t adc_nids[AUTO_CFG_MAX_OUTS]; |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 159 | hda_nid_t dig_in_nid; /* digital-in NID; optional */ |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 160 | hda_nid_t mixer_nid; /* analog-mixer NID */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 162 | /* capture setup for dynamic dual-adc switch */ |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 163 | hda_nid_t cur_adc; |
| 164 | unsigned int cur_adc_stream_tag; |
| 165 | unsigned int cur_adc_format; |
| 166 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | /* capture source */ |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 168 | struct hda_input_mux input_mux; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 169 | unsigned int cur_mux[3]; |
| 170 | |
| 171 | /* channel model */ |
Takashi Iwai | d2a6d7d | 2005-11-17 11:06:29 +0100 | [diff] [blame] | 172 | const struct hda_channel_mode *channel_mode; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 173 | int num_channel_mode; |
Takashi Iwai | b6adb57 | 2012-12-03 10:30:58 +0100 | [diff] [blame] | 174 | int const_channel_count; /* min. channel count (for speakers) */ |
| 175 | int ext_channel_count; /* current channel count for multi-io */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 | |
| 177 | /* PCM information */ |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 178 | struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */ |
Takashi Iwai | 41e41f1 | 2005-06-08 14:48:49 +0200 | [diff] [blame] | 179 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 180 | /* dynamic controls, init_verbs and input_mux */ |
| 181 | struct auto_pin_cfg autocfg; |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 182 | struct alc_customize_define cdefine; |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 183 | struct snd_array kctls; |
Takashi Iwai | 41923e4 | 2007-10-22 17:20:10 +0200 | [diff] [blame] | 184 | hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 185 | hda_nid_t imux_pins[HDA_MAX_NUM_INPUTS]; |
| 186 | unsigned int dyn_adc_idx[HDA_MAX_NUM_INPUTS]; |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 187 | hda_nid_t inv_dmic_pin; |
Takashi Iwai | 37c0420 | 2012-12-18 14:22:45 +0100 | [diff] [blame] | 188 | hda_nid_t shared_mic_vref_pin; |
Takashi Iwai | 834be88 | 2006-03-01 14:16:17 +0100 | [diff] [blame] | 189 | |
Takashi Iwai | 463419d | 2012-12-05 14:17:37 +0100 | [diff] [blame] | 190 | /* DAC list */ |
| 191 | int num_all_dacs; |
| 192 | hda_nid_t all_dacs[16]; |
| 193 | |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 194 | /* path list */ |
| 195 | struct snd_array paths; |
Takashi Iwai | c2fd19c | 2012-12-12 18:02:41 +0100 | [diff] [blame] | 196 | |
Takashi Iwai | ab16c6d | 2012-11-29 09:56:50 +0100 | [diff] [blame^] | 197 | /* auto-mic stuff */ |
| 198 | int am_num_entries; |
| 199 | struct alc_automic_entry am_entry[MAX_AUTO_MIC_PINS]; |
| 200 | |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 201 | /* hooks */ |
| 202 | void (*init_hook)(struct hda_codec *codec); |
Takashi Iwai | 83012a7 | 2012-08-24 18:38:08 +0200 | [diff] [blame] | 203 | #ifdef CONFIG_PM |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 204 | void (*power_hook)(struct hda_codec *codec); |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 205 | #endif |
Takashi Iwai | 1c71615 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 206 | void (*shutup)(struct hda_codec *codec); |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 207 | void (*automute_hook)(struct hda_codec *codec); |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 208 | |
Takashi Iwai | 834be88 | 2006-03-01 14:16:17 +0100 | [diff] [blame] | 209 | /* for pin sensing */ |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 210 | unsigned int hp_jack_present:1; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 211 | unsigned int line_jack_present:1; |
Takashi Iwai | e942796 | 2011-04-28 15:46:07 +0200 | [diff] [blame] | 212 | unsigned int master_mute:1; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 213 | unsigned int auto_mic:1; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 214 | unsigned int automute_speaker:1; /* automute speaker outputs */ |
| 215 | unsigned int automute_lo:1; /* automute LO outputs */ |
| 216 | unsigned int detect_hp:1; /* Headphone detection enabled */ |
| 217 | unsigned int detect_lo:1; /* Line-out detection enabled */ |
| 218 | unsigned int automute_speaker_possible:1; /* there are speakers and either LO or HP */ |
| 219 | unsigned int automute_lo_possible:1; /* there are line outs and HP */ |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 220 | unsigned int keep_vref_in_automute:1; /* Don't clear VREF in automute */ |
Takashi Iwai | ab16c6d | 2012-11-29 09:56:50 +0100 | [diff] [blame^] | 221 | unsigned int line_in_auto_switch:1; /* allow line-in auto switch */ |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 222 | |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 223 | /* other flags */ |
Takashi Iwai | 20c18f5 | 2012-12-18 14:33:21 +0100 | [diff] [blame] | 224 | unsigned int need_dac_fix:1; /* need to limit DACs for multi channels */ |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 225 | unsigned int no_analog :1; /* digital I/O only */ |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 226 | unsigned int dyn_adc_switch:1; /* switch ADCs (for ALC275) */ |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 227 | unsigned int shared_mic_hp:1; /* HP/Mic-in sharing */ |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 228 | unsigned int inv_dmic_fixup:1; /* has inverted digital-mic workaround */ |
| 229 | unsigned int inv_dmic_muted:1; /* R-ch of inv d-mic is muted? */ |
Takashi Iwai | e427c23 | 2012-07-29 10:04:08 +0200 | [diff] [blame] | 230 | unsigned int no_primary_hp:1; /* Don't prefer HP pins to speaker pins */ |
Takashi Iwai | 9bf387b | 2012-12-18 17:18:21 +0100 | [diff] [blame] | 231 | unsigned int multi_cap_vol:1; /* allow multiple capture xxx volumes */ |
Takashi Iwai | 81fede8 | 2012-12-18 17:24:25 +0100 | [diff] [blame] | 232 | unsigned int inv_dmic_split:1; /* inverted dmic w/a for conexant */ |
Takashi Iwai | d922b51 | 2011-04-28 12:18:53 +0200 | [diff] [blame] | 233 | |
Takashi Iwai | 20c18f5 | 2012-12-18 14:33:21 +0100 | [diff] [blame] | 234 | unsigned int parse_flags; /* passed to snd_hda_parse_pin_defcfg() */ |
Takashi Iwai | d922b51 | 2011-04-28 12:18:53 +0200 | [diff] [blame] | 235 | |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 236 | int init_amp; |
Takashi Iwai | d433a67 | 2010-09-20 15:11:54 +0200 | [diff] [blame] | 237 | int codec_variant; /* flag for other variants */ |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 238 | |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 239 | /* for virtual master */ |
| 240 | hda_nid_t vmaster_nid; |
Takashi Iwai | d2f344b | 2012-03-12 16:59:58 +0100 | [diff] [blame] | 241 | struct hda_vmaster_mute_hook vmaster_mute; |
Takashi Iwai | 83012a7 | 2012-08-24 18:38:08 +0200 | [diff] [blame] | 242 | #ifdef CONFIG_PM |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 243 | struct hda_loopback_check loopback; |
Takashi Iwai | 164f73e | 2012-02-21 11:27:09 +0100 | [diff] [blame] | 244 | int num_loopbacks; |
| 245 | struct hda_amp_list loopback_list[8]; |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 246 | #endif |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 247 | |
| 248 | /* for PLL fix */ |
| 249 | hda_nid_t pll_nid; |
| 250 | unsigned int pll_coef_idx, pll_coef_bit; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 251 | unsigned int coef0; |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 252 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 253 | /* multi-io */ |
| 254 | int multi_ios; |
| 255 | struct alc_multi_io multi_io[4]; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 256 | |
| 257 | /* bind volumes */ |
| 258 | struct snd_array bind_ctls; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 259 | }; |
| 260 | |
Takashi Iwai | 44c0240 | 2011-07-08 15:14:19 +0200 | [diff] [blame] | 261 | static bool check_amp_caps(struct hda_codec *codec, hda_nid_t nid, |
| 262 | int dir, unsigned int bits) |
| 263 | { |
| 264 | if (!nid) |
| 265 | return false; |
| 266 | if (get_wcaps(codec, nid) & (1 << (dir + 1))) |
| 267 | if (query_amp_caps(codec, nid, dir) & bits) |
| 268 | return true; |
| 269 | return false; |
| 270 | } |
| 271 | |
| 272 | #define nid_has_mute(codec, nid, dir) \ |
| 273 | check_amp_caps(codec, nid, dir, AC_AMPCAP_MUTE) |
| 274 | #define nid_has_volume(codec, nid, dir) \ |
| 275 | check_amp_caps(codec, nid, dir, AC_AMPCAP_NUM_STEPS) |
| 276 | |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 277 | static struct nid_path * |
| 278 | get_nid_path(struct hda_codec *codec, hda_nid_t from_nid, hda_nid_t to_nid); |
| 279 | static void activate_path(struct hda_codec *codec, struct nid_path *path, |
| 280 | bool enable, bool add_aamix); |
| 281 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 282 | /* |
| 283 | * input MUX handling |
| 284 | */ |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 285 | static int alc_mux_enum_info(struct snd_kcontrol *kcontrol, |
| 286 | struct snd_ctl_elem_info *uinfo) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 287 | { |
| 288 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 289 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 290 | return snd_hda_input_mux_info(&spec->input_mux, uinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | } |
| 292 | |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 293 | static int alc_mux_enum_get(struct snd_kcontrol *kcontrol, |
| 294 | struct snd_ctl_elem_value *ucontrol) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 295 | { |
| 296 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 297 | struct alc_spec *spec = codec->spec; |
| 298 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 299 | |
| 300 | ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; |
| 301 | return 0; |
| 302 | } |
| 303 | |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 304 | static hda_nid_t get_adc_nid(struct hda_codec *codec, int adc_idx, int imux_idx) |
| 305 | { |
| 306 | struct alc_spec *spec = codec->spec; |
| 307 | if (spec->dyn_adc_switch) |
| 308 | adc_idx = spec->dyn_adc_idx[imux_idx]; |
| 309 | return spec->adc_nids[adc_idx]; |
| 310 | } |
| 311 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 312 | 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] | 313 | { |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 314 | struct alc_spec *spec = codec->spec; |
| 315 | hda_nid_t new_adc = spec->adc_nids[spec->dyn_adc_idx[cur]]; |
| 316 | |
| 317 | if (spec->cur_adc && spec->cur_adc != new_adc) { |
| 318 | /* stream is running, let's swap the current ADC */ |
| 319 | __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1); |
| 320 | spec->cur_adc = new_adc; |
| 321 | snd_hda_codec_setup_stream(codec, new_adc, |
| 322 | spec->cur_adc_stream_tag, 0, |
| 323 | spec->cur_adc_format); |
| 324 | return true; |
| 325 | } |
| 326 | return false; |
| 327 | } |
| 328 | |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 329 | static void call_update_outputs(struct hda_codec *codec); |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 330 | static void alc_inv_dmic_sync(struct hda_codec *codec, bool force); |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 331 | static void alc_inv_dmic_sync_adc(struct hda_codec *codec, int adc_idx); |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 332 | |
David Henningsson | 00227f1 | 2012-06-27 18:45:44 +0200 | [diff] [blame] | 333 | /* for shared I/O, change the pin-control accordingly */ |
| 334 | static void update_shared_mic_hp(struct hda_codec *codec, bool set_as_mic) |
| 335 | { |
| 336 | struct alc_spec *spec = codec->spec; |
| 337 | unsigned int val; |
| 338 | hda_nid_t pin = spec->autocfg.inputs[1].pin; |
| 339 | /* NOTE: this assumes that there are only two inputs, the |
| 340 | * first is the real internal mic and the second is HP/mic jack. |
| 341 | */ |
| 342 | |
| 343 | val = snd_hda_get_default_vref(codec, pin); |
| 344 | |
| 345 | /* This pin does not have vref caps - let's enable vref on pin 0x18 |
| 346 | instead, as suggested by Realtek */ |
Takashi Iwai | 37c0420 | 2012-12-18 14:22:45 +0100 | [diff] [blame] | 347 | if (val == AC_PINCTL_VREF_HIZ && spec->shared_mic_vref_pin) { |
| 348 | const hda_nid_t vref_pin = spec->shared_mic_vref_pin; |
| 349 | unsigned int vref_val = snd_hda_get_default_vref(codec, vref_pin); |
| 350 | if (vref_val != AC_PINCTL_VREF_HIZ) |
| 351 | snd_hda_set_pin_ctl(codec, vref_pin, PIN_IN | (set_as_mic ? vref_val : 0)); |
David Henningsson | 00227f1 | 2012-06-27 18:45:44 +0200 | [diff] [blame] | 352 | } |
| 353 | |
| 354 | val = set_as_mic ? val | PIN_IN : PIN_HP; |
| 355 | snd_hda_set_pin_ctl(codec, pin, val); |
| 356 | |
| 357 | spec->automute_speaker = !set_as_mic; |
| 358 | call_update_outputs(codec); |
| 359 | } |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 360 | |
| 361 | /* select the given imux item; either unmute exclusively or select the route */ |
| 362 | static int alc_mux_select(struct hda_codec *codec, unsigned int adc_idx, |
| 363 | unsigned int idx, bool force) |
| 364 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 365 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | cd896c3 | 2008-11-18 12:36:33 +0100 | [diff] [blame] | 366 | const struct hda_input_mux *imux; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 367 | struct nid_path *path; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 368 | |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 369 | imux = &spec->input_mux; |
| 370 | if (!imux->num_items) |
Takashi Iwai | cce4aa3 | 2011-12-02 15:29:12 +0100 | [diff] [blame] | 371 | return 0; |
Takashi Iwai | cd896c3 | 2008-11-18 12:36:33 +0100 | [diff] [blame] | 372 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 373 | if (idx >= imux->num_items) |
| 374 | idx = imux->num_items - 1; |
| 375 | if (spec->cur_mux[adc_idx] == idx && !force) |
| 376 | return 0; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 377 | |
| 378 | path = get_nid_path(codec, spec->imux_pins[spec->cur_mux[adc_idx]], |
| 379 | spec->adc_nids[adc_idx]); |
| 380 | if (!path) |
| 381 | return 0; |
| 382 | if (path->active) |
| 383 | activate_path(codec, path, false, false); |
| 384 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 385 | spec->cur_mux[adc_idx] = idx; |
| 386 | |
David Henningsson | 00227f1 | 2012-06-27 18:45:44 +0200 | [diff] [blame] | 387 | if (spec->shared_mic_hp) |
| 388 | update_shared_mic_hp(codec, spec->cur_mux[adc_idx]); |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 389 | |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 390 | if (spec->dyn_adc_switch) |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 391 | alc_dyn_adc_pcm_resetup(codec, idx); |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 392 | |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 393 | path = get_nid_path(codec, spec->imux_pins[idx], |
| 394 | get_adc_nid(codec, adc_idx, idx)); |
| 395 | if (!path) |
| 396 | return 0; |
| 397 | if (path->active) |
| 398 | return 0; |
| 399 | activate_path(codec, path, true, false); |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 400 | alc_inv_dmic_sync(codec, true); |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 401 | return 1; |
| 402 | } |
| 403 | |
| 404 | static int alc_mux_enum_put(struct snd_kcontrol *kcontrol, |
| 405 | struct snd_ctl_elem_value *ucontrol) |
| 406 | { |
| 407 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 408 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 409 | return alc_mux_select(codec, adc_idx, |
| 410 | ucontrol->value.enumerated.item[0], false); |
Takashi Iwai | 54cbc9a | 2008-10-31 15:24:04 +0100 | [diff] [blame] | 411 | } |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 412 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 413 | /* |
Takashi Iwai | 23f0c04 | 2009-02-26 13:03:58 +0100 | [diff] [blame] | 414 | * set up the input pin config (depending on the given auto-pin type) |
| 415 | */ |
| 416 | static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid, |
| 417 | int auto_pin_type) |
| 418 | { |
| 419 | unsigned int val = PIN_IN; |
Takashi Iwai | 4740860 | 2012-04-20 13:06:53 +0200 | [diff] [blame] | 420 | if (auto_pin_type == AUTO_PIN_MIC) |
| 421 | val |= snd_hda_get_default_vref(codec, nid); |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 422 | snd_hda_set_pin_ctl(codec, nid, val); |
Takashi Iwai | 23f0c04 | 2009-02-26 13:03:58 +0100 | [diff] [blame] | 423 | } |
| 424 | |
| 425 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 426 | * Append the given mixer and verb elements for the later use |
| 427 | * The mixer array is referred in build_controls(), and init_verbs are |
| 428 | * called in init(). |
Takashi Iwai | d88897e | 2008-10-31 15:01:37 +0100 | [diff] [blame] | 429 | */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 430 | 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] | 431 | { |
| 432 | if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers))) |
| 433 | return; |
| 434 | spec->mixers[spec->num_mixers++] = mix; |
| 435 | } |
| 436 | |
Takashi Iwai | d88897e | 2008-10-31 15:01:37 +0100 | [diff] [blame] | 437 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 438 | * GPIO setup tables, used in initialization |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 439 | */ |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 440 | /* Enable GPIO mask and set output */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 441 | static const struct hda_verb alc_gpio1_init_verbs[] = { |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 442 | {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, |
| 443 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, |
| 444 | {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, |
| 445 | { } |
| 446 | }; |
| 447 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 448 | static const struct hda_verb alc_gpio2_init_verbs[] = { |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 449 | {0x01, AC_VERB_SET_GPIO_MASK, 0x02}, |
| 450 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02}, |
| 451 | {0x01, AC_VERB_SET_GPIO_DATA, 0x02}, |
| 452 | { } |
| 453 | }; |
| 454 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 455 | static const struct hda_verb alc_gpio3_init_verbs[] = { |
Kailang Yang | bdd148a | 2007-05-08 15:19:08 +0200 | [diff] [blame] | 456 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, |
| 457 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, |
| 458 | {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, |
| 459 | { } |
| 460 | }; |
| 461 | |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 462 | /* |
| 463 | * Fix hardware PLL issue |
| 464 | * On some codecs, the analog PLL gating control must be off while |
| 465 | * the default value is 1. |
| 466 | */ |
| 467 | static void alc_fix_pll(struct hda_codec *codec) |
| 468 | { |
| 469 | struct alc_spec *spec = codec->spec; |
| 470 | unsigned int val; |
| 471 | |
| 472 | if (!spec->pll_nid) |
| 473 | return; |
| 474 | snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX, |
| 475 | spec->pll_coef_idx); |
| 476 | val = snd_hda_codec_read(codec, spec->pll_nid, 0, |
| 477 | AC_VERB_GET_PROC_COEF, 0); |
| 478 | snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX, |
| 479 | spec->pll_coef_idx); |
| 480 | snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF, |
| 481 | val & ~(1 << spec->pll_coef_bit)); |
| 482 | } |
| 483 | |
| 484 | static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid, |
| 485 | unsigned int coef_idx, unsigned int coef_bit) |
| 486 | { |
| 487 | struct alc_spec *spec = codec->spec; |
| 488 | spec->pll_nid = nid; |
| 489 | spec->pll_coef_idx = coef_idx; |
| 490 | spec->pll_coef_bit = coef_bit; |
| 491 | alc_fix_pll(codec); |
| 492 | } |
| 493 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 494 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 495 | * Jack detections for HP auto-mute and mic-switch |
| 496 | */ |
| 497 | |
| 498 | /* check each pin in the given array; returns true if any of them is plugged */ |
| 499 | 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] | 500 | { |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 501 | int i, present = 0; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 502 | |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 503 | for (i = 0; i < num_pins; i++) { |
| 504 | hda_nid_t nid = pins[i]; |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 505 | if (!nid) |
| 506 | break; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 507 | present |= snd_hda_jack_detect(codec, nid); |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 508 | } |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 509 | return present; |
| 510 | } |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 511 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 512 | /* standard HP/line-out auto-mute helper */ |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 513 | 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] | 514 | bool mute, bool hp_out) |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 515 | { |
| 516 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | e942796 | 2011-04-28 15:46:07 +0200 | [diff] [blame] | 517 | unsigned int pin_bits = mute ? 0 : (hp_out ? PIN_HP : PIN_OUT); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 518 | int i; |
| 519 | |
| 520 | for (i = 0; i < num_pins; i++) { |
| 521 | hda_nid_t nid = pins[i]; |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 522 | unsigned int val; |
Takashi Iwai | a9fd4f3 | 2009-05-08 15:57:59 +0200 | [diff] [blame] | 523 | if (!nid) |
| 524 | break; |
Takashi Iwai | b8a47c7 | 2012-12-14 14:20:34 +0100 | [diff] [blame] | 525 | /* don't reset VREF value in case it's controlling |
| 526 | * the amp (see alc861_fixup_asus_amp_vref_0f()) |
| 527 | */ |
| 528 | if (spec->keep_vref_in_automute) { |
| 529 | val = snd_hda_codec_read(codec, nid, 0, |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 530 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
Takashi Iwai | b8a47c7 | 2012-12-14 14:20:34 +0100 | [diff] [blame] | 531 | val &= ~PIN_HP; |
| 532 | } else |
| 533 | val = 0; |
| 534 | val |= pin_bits; |
| 535 | snd_hda_set_pin_ctl(codec, nid, val); |
Takashi Iwai | a9fd4f3 | 2009-05-08 15:57:59 +0200 | [diff] [blame] | 536 | } |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 537 | } |
| 538 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 539 | /* Toggle outputs muting */ |
| 540 | static void update_outputs(struct hda_codec *codec) |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 541 | { |
| 542 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 543 | int on; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 544 | |
Takashi Iwai | c0a2026 | 2011-06-10 15:28:15 +0200 | [diff] [blame] | 545 | /* Control HP pins/amps depending on master_mute state; |
| 546 | * in general, HP pins/amps control should be enabled in all cases, |
| 547 | * but currently set only for master_mute, just to be safe |
| 548 | */ |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 549 | if (!spec->shared_mic_hp) /* don't change HP-pin when shared with mic */ |
| 550 | do_automute(codec, ARRAY_SIZE(spec->autocfg.hp_pins), |
Takashi Iwai | c0a2026 | 2011-06-10 15:28:15 +0200 | [diff] [blame] | 551 | spec->autocfg.hp_pins, spec->master_mute, true); |
| 552 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 553 | if (!spec->automute_speaker) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 554 | on = 0; |
| 555 | else |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 556 | on = spec->hp_jack_present | spec->line_jack_present; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 557 | on |= spec->master_mute; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 558 | do_automute(codec, ARRAY_SIZE(spec->autocfg.speaker_pins), |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 559 | spec->autocfg.speaker_pins, on, false); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 560 | |
| 561 | /* toggle line-out mutes if needed, too */ |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 562 | /* if LO is a copy of either HP or Speaker, don't need to handle it */ |
| 563 | if (spec->autocfg.line_out_pins[0] == spec->autocfg.hp_pins[0] || |
| 564 | spec->autocfg.line_out_pins[0] == spec->autocfg.speaker_pins[0]) |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 565 | return; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 566 | if (!spec->automute_lo) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 567 | on = 0; |
| 568 | else |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 569 | on = spec->hp_jack_present; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 570 | on |= spec->master_mute; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 571 | do_automute(codec, ARRAY_SIZE(spec->autocfg.line_out_pins), |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 572 | spec->autocfg.line_out_pins, on, false); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 573 | } |
| 574 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 575 | static void call_update_outputs(struct hda_codec *codec) |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 576 | { |
| 577 | struct alc_spec *spec = codec->spec; |
| 578 | if (spec->automute_hook) |
| 579 | spec->automute_hook(codec); |
| 580 | else |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 581 | update_outputs(codec); |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 582 | } |
| 583 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 584 | /* standard HP-automute helper */ |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 585 | static void alc_hp_automute(struct hda_codec *codec, struct hda_jack_tbl *jack) |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 586 | { |
| 587 | struct alc_spec *spec = codec->spec; |
| 588 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 589 | spec->hp_jack_present = |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 590 | detect_jacks(codec, ARRAY_SIZE(spec->autocfg.hp_pins), |
| 591 | spec->autocfg.hp_pins); |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 592 | if (!spec->detect_hp || (!spec->automute_speaker && !spec->automute_lo)) |
Takashi Iwai | 3c715a9 | 2011-08-23 12:41:09 +0200 | [diff] [blame] | 593 | return; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 594 | call_update_outputs(codec); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 595 | } |
| 596 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 597 | /* standard line-out-automute helper */ |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 598 | static void alc_line_automute(struct hda_codec *codec, struct hda_jack_tbl *jack) |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 599 | { |
| 600 | struct alc_spec *spec = codec->spec; |
| 601 | |
David Henningsson | f7f4b232 | 2012-10-10 16:32:09 +0200 | [diff] [blame] | 602 | if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT) |
| 603 | return; |
Takashi Iwai | e0d32e3 | 2011-09-26 15:19:55 +0200 | [diff] [blame] | 604 | /* check LO jack only when it's different from HP */ |
| 605 | if (spec->autocfg.line_out_pins[0] == spec->autocfg.hp_pins[0]) |
| 606 | return; |
| 607 | |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 608 | spec->line_jack_present = |
| 609 | detect_jacks(codec, ARRAY_SIZE(spec->autocfg.line_out_pins), |
| 610 | spec->autocfg.line_out_pins); |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 611 | if (!spec->automute_speaker || !spec->detect_lo) |
Takashi Iwai | 3c715a9 | 2011-08-23 12:41:09 +0200 | [diff] [blame] | 612 | return; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 613 | call_update_outputs(codec); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 614 | } |
| 615 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 616 | /* standard mic auto-switch helper */ |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 617 | static void alc_mic_automute(struct hda_codec *codec, struct hda_jack_tbl *jack) |
Kailang Yang | 7fb0d78 | 2008-10-15 11:12:35 +0200 | [diff] [blame] | 618 | { |
| 619 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | ab16c6d | 2012-11-29 09:56:50 +0100 | [diff] [blame^] | 620 | int i; |
Kailang Yang | 7fb0d78 | 2008-10-15 11:12:35 +0200 | [diff] [blame] | 621 | |
Takashi Iwai | 480967d | 2012-12-18 14:29:52 +0100 | [diff] [blame] | 622 | if (!spec->auto_mic) |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 623 | return; |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 624 | |
Takashi Iwai | ab16c6d | 2012-11-29 09:56:50 +0100 | [diff] [blame^] | 625 | for (i = spec->am_num_entries - 1; i > 0; i--) { |
| 626 | if (snd_hda_jack_detect(codec, spec->am_entry[i].pin)) { |
| 627 | alc_mux_select(codec, 0, spec->am_entry[i].idx, false); |
| 628 | return; |
| 629 | } |
| 630 | } |
| 631 | alc_mux_select(codec, 0, spec->am_entry[0].idx, false); |
Kailang Yang | 7fb0d78 | 2008-10-15 11:12:35 +0200 | [diff] [blame] | 632 | } |
| 633 | |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 634 | /* update the master volume per volume-knob's unsol event */ |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 635 | static void alc_update_knob_master(struct hda_codec *codec, struct hda_jack_tbl *jack) |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 636 | { |
| 637 | unsigned int val; |
| 638 | struct snd_kcontrol *kctl; |
| 639 | struct snd_ctl_elem_value *uctl; |
| 640 | |
| 641 | kctl = snd_hda_find_mixer_ctl(codec, "Master Playback Volume"); |
| 642 | if (!kctl) |
| 643 | return; |
| 644 | uctl = kzalloc(sizeof(*uctl), GFP_KERNEL); |
| 645 | if (!uctl) |
| 646 | return; |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 647 | val = snd_hda_codec_read(codec, jack->nid, 0, |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 648 | AC_VERB_GET_VOLUME_KNOB_CONTROL, 0); |
| 649 | val &= HDA_AMP_VOLMASK; |
| 650 | uctl->value.integer.value[0] = val; |
| 651 | uctl->value.integer.value[1] = val; |
| 652 | kctl->put(kctl, uctl); |
| 653 | kfree(uctl); |
| 654 | } |
| 655 | |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 656 | static void alc880_unsol_event(struct hda_codec *codec, unsigned int res) |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 657 | { |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 658 | /* For some reason, the res given from ALC880 is broken. |
| 659 | Here we adjust it properly. */ |
| 660 | snd_hda_jack_unsol_event(codec, res >> 2); |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 661 | } |
| 662 | |
Kailang Yang | f9423e7 | 2008-05-27 12:32:25 +0200 | [diff] [blame] | 663 | /* additional initialization for ALC888 variants */ |
| 664 | static void alc888_coef_init(struct hda_codec *codec) |
| 665 | { |
| 666 | unsigned int tmp; |
| 667 | |
| 668 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0); |
| 669 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); |
| 670 | 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] | 671 | if ((tmp & 0xf0) == 0x20) |
Kailang Yang | f9423e7 | 2008-05-27 12:32:25 +0200 | [diff] [blame] | 672 | /* alc888S-VC */ |
| 673 | snd_hda_codec_read(codec, 0x20, 0, |
| 674 | AC_VERB_SET_PROC_COEF, 0x830); |
| 675 | else |
| 676 | /* alc888-VB */ |
| 677 | snd_hda_codec_read(codec, 0x20, 0, |
| 678 | AC_VERB_SET_PROC_COEF, 0x3030); |
| 679 | } |
| 680 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 681 | /* additional initialization for ALC889 variants */ |
Jaroslav Kysela | 87a8c37 | 2009-07-23 10:58:29 +0200 | [diff] [blame] | 682 | static void alc889_coef_init(struct hda_codec *codec) |
| 683 | { |
| 684 | unsigned int tmp; |
| 685 | |
| 686 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7); |
| 687 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); |
| 688 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7); |
| 689 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010); |
| 690 | } |
| 691 | |
Takashi Iwai | 3fb4a50 | 2010-01-19 15:46:37 +0100 | [diff] [blame] | 692 | /* turn on/off EAPD control (only if available) */ |
| 693 | static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on) |
| 694 | { |
| 695 | if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN) |
| 696 | return; |
| 697 | if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD) |
| 698 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE, |
| 699 | on ? 2 : 0); |
| 700 | } |
| 701 | |
Takashi Iwai | 691f1fc | 2011-04-07 10:31:43 +0200 | [diff] [blame] | 702 | /* turn on/off EAPD controls of the codec */ |
| 703 | static void alc_auto_setup_eapd(struct hda_codec *codec, bool on) |
| 704 | { |
| 705 | /* We currently only handle front, HP */ |
Takashi Iwai | 39fa84e | 2011-06-27 15:28:57 +0200 | [diff] [blame] | 706 | static hda_nid_t pins[] = { |
| 707 | 0x0f, 0x10, 0x14, 0x15, 0 |
| 708 | }; |
| 709 | hda_nid_t *p; |
| 710 | for (p = pins; *p; p++) |
| 711 | set_eapd(codec, *p, on); |
Takashi Iwai | 691f1fc | 2011-04-07 10:31:43 +0200 | [diff] [blame] | 712 | } |
| 713 | |
Takashi Iwai | 1c71615 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 714 | /* generic shutup callback; |
| 715 | * just turning off EPAD and a little pause for avoiding pop-noise |
| 716 | */ |
| 717 | static void alc_eapd_shutup(struct hda_codec *codec) |
| 718 | { |
| 719 | alc_auto_setup_eapd(codec, false); |
| 720 | msleep(200); |
| 721 | } |
| 722 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 723 | /* generic EAPD initialization */ |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 724 | static void alc_auto_init_amp(struct hda_codec *codec, int type) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 725 | { |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 726 | unsigned int tmp; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 727 | |
Takashi Iwai | 39fa84e | 2011-06-27 15:28:57 +0200 | [diff] [blame] | 728 | alc_auto_setup_eapd(codec, true); |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 729 | switch (type) { |
| 730 | case ALC_INIT_GPIO1: |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 731 | snd_hda_sequence_write(codec, alc_gpio1_init_verbs); |
| 732 | break; |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 733 | case ALC_INIT_GPIO2: |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 734 | snd_hda_sequence_write(codec, alc_gpio2_init_verbs); |
| 735 | break; |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 736 | case ALC_INIT_GPIO3: |
Kailang Yang | bdd148a | 2007-05-08 15:19:08 +0200 | [diff] [blame] | 737 | snd_hda_sequence_write(codec, alc_gpio3_init_verbs); |
| 738 | break; |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 739 | case ALC_INIT_DEFAULT: |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 740 | switch (codec->vendor_id) { |
| 741 | case 0x10ec0260: |
| 742 | snd_hda_codec_write(codec, 0x1a, 0, |
| 743 | AC_VERB_SET_COEF_INDEX, 7); |
| 744 | tmp = snd_hda_codec_read(codec, 0x1a, 0, |
| 745 | AC_VERB_GET_PROC_COEF, 0); |
| 746 | snd_hda_codec_write(codec, 0x1a, 0, |
| 747 | AC_VERB_SET_COEF_INDEX, 7); |
| 748 | snd_hda_codec_write(codec, 0x1a, 0, |
| 749 | AC_VERB_SET_PROC_COEF, |
| 750 | tmp | 0x2010); |
| 751 | break; |
| 752 | case 0x10ec0262: |
| 753 | case 0x10ec0880: |
| 754 | case 0x10ec0882: |
| 755 | case 0x10ec0883: |
| 756 | case 0x10ec0885: |
Takashi Iwai | 4a5a4c5 | 2009-02-06 12:46:59 +0100 | [diff] [blame] | 757 | case 0x10ec0887: |
Takashi Iwai | 20b67dd | 2011-03-23 22:54:32 +0100 | [diff] [blame] | 758 | /*case 0x10ec0889:*/ /* this causes an SPDIF problem */ |
Jaroslav Kysela | 87a8c37 | 2009-07-23 10:58:29 +0200 | [diff] [blame] | 759 | alc889_coef_init(codec); |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 760 | break; |
Kailang Yang | f9423e7 | 2008-05-27 12:32:25 +0200 | [diff] [blame] | 761 | case 0x10ec0888: |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 762 | alc888_coef_init(codec); |
Kailang Yang | f9423e7 | 2008-05-27 12:32:25 +0200 | [diff] [blame] | 763 | break; |
Takashi Iwai | 0aea778 | 2010-01-25 15:44:11 +0100 | [diff] [blame] | 764 | #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] | 765 | case 0x10ec0267: |
| 766 | case 0x10ec0268: |
| 767 | snd_hda_codec_write(codec, 0x20, 0, |
| 768 | AC_VERB_SET_COEF_INDEX, 7); |
| 769 | tmp = snd_hda_codec_read(codec, 0x20, 0, |
| 770 | AC_VERB_GET_PROC_COEF, 0); |
| 771 | snd_hda_codec_write(codec, 0x20, 0, |
Kailang Yang | ea1fb29 | 2008-08-26 12:58:38 +0200 | [diff] [blame] | 772 | AC_VERB_SET_COEF_INDEX, 7); |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 773 | snd_hda_codec_write(codec, 0x20, 0, |
| 774 | AC_VERB_SET_PROC_COEF, |
| 775 | tmp | 0x3000); |
| 776 | break; |
Takashi Iwai | 0aea778 | 2010-01-25 15:44:11 +0100 | [diff] [blame] | 777 | #endif /* XXX */ |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 778 | } |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 779 | break; |
| 780 | } |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 781 | } |
Kailang Yang | ea1fb29 | 2008-08-26 12:58:38 +0200 | [diff] [blame] | 782 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 783 | /* |
| 784 | * Auto-Mute mode mixer enum support |
| 785 | */ |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 786 | static int alc_automute_mode_info(struct snd_kcontrol *kcontrol, |
| 787 | struct snd_ctl_elem_info *uinfo) |
| 788 | { |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 789 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 790 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 791 | static const char * const texts3[] = { |
Takashi Iwai | e49a343 | 2012-03-01 18:14:41 +0100 | [diff] [blame] | 792 | "Disabled", "Speaker Only", "Line Out+Speaker" |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 793 | }; |
| 794 | |
Takashi Iwai | dda415d | 2012-11-30 18:34:38 +0100 | [diff] [blame] | 795 | if (spec->automute_speaker_possible && spec->automute_lo_possible) |
| 796 | return snd_hda_enum_helper_info(kcontrol, uinfo, 3, texts3); |
| 797 | return snd_hda_enum_bool_helper_info(kcontrol, uinfo); |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 798 | } |
| 799 | |
| 800 | static int alc_automute_mode_get(struct snd_kcontrol *kcontrol, |
| 801 | struct snd_ctl_elem_value *ucontrol) |
| 802 | { |
| 803 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 804 | struct alc_spec *spec = codec->spec; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 805 | unsigned int val = 0; |
| 806 | if (spec->automute_speaker) |
| 807 | val++; |
| 808 | if (spec->automute_lo) |
| 809 | val++; |
| 810 | |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 811 | ucontrol->value.enumerated.item[0] = val; |
| 812 | return 0; |
| 813 | } |
| 814 | |
| 815 | static int alc_automute_mode_put(struct snd_kcontrol *kcontrol, |
| 816 | struct snd_ctl_elem_value *ucontrol) |
| 817 | { |
| 818 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 819 | struct alc_spec *spec = codec->spec; |
| 820 | |
| 821 | switch (ucontrol->value.enumerated.item[0]) { |
| 822 | case 0: |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 823 | if (!spec->automute_speaker && !spec->automute_lo) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 824 | return 0; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 825 | spec->automute_speaker = 0; |
| 826 | spec->automute_lo = 0; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 827 | break; |
| 828 | case 1: |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 829 | if (spec->automute_speaker_possible) { |
| 830 | if (!spec->automute_lo && spec->automute_speaker) |
| 831 | return 0; |
| 832 | spec->automute_speaker = 1; |
| 833 | spec->automute_lo = 0; |
| 834 | } else if (spec->automute_lo_possible) { |
| 835 | if (spec->automute_lo) |
| 836 | return 0; |
| 837 | spec->automute_lo = 1; |
| 838 | } else |
| 839 | return -EINVAL; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 840 | break; |
| 841 | case 2: |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 842 | if (!spec->automute_lo_possible || !spec->automute_speaker_possible) |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 843 | return -EINVAL; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 844 | if (spec->automute_speaker && spec->automute_lo) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 845 | return 0; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 846 | spec->automute_speaker = 1; |
| 847 | spec->automute_lo = 1; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 848 | break; |
| 849 | default: |
| 850 | return -EINVAL; |
| 851 | } |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 852 | call_update_outputs(codec); |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 853 | return 1; |
| 854 | } |
| 855 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 856 | static const struct snd_kcontrol_new alc_automute_mode_enum = { |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 857 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 858 | .name = "Auto-Mute Mode", |
| 859 | .info = alc_automute_mode_info, |
| 860 | .get = alc_automute_mode_get, |
| 861 | .put = alc_automute_mode_put, |
| 862 | }; |
| 863 | |
Takashi Iwai | 668d1e9 | 2012-11-29 14:10:17 +0100 | [diff] [blame] | 864 | static struct snd_kcontrol_new * |
| 865 | alc_kcontrol_new(struct alc_spec *spec, const char *name, |
| 866 | const struct snd_kcontrol_new *temp) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 867 | { |
Takashi Iwai | 668d1e9 | 2012-11-29 14:10:17 +0100 | [diff] [blame] | 868 | struct snd_kcontrol_new *knew = snd_array_new(&spec->kctls); |
| 869 | if (!knew) |
| 870 | return NULL; |
| 871 | *knew = *temp; |
Takashi Iwai | bc54976 | 2012-12-18 15:35:11 +0100 | [diff] [blame] | 872 | if (name) |
| 873 | knew->name = kstrdup(name, GFP_KERNEL); |
| 874 | else if (knew->name) |
| 875 | knew->name = kstrdup(knew->name, GFP_KERNEL); |
Takashi Iwai | 668d1e9 | 2012-11-29 14:10:17 +0100 | [diff] [blame] | 876 | if (!knew->name) |
| 877 | return NULL; |
| 878 | return knew; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 879 | } |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 880 | |
| 881 | static int alc_add_automute_mode_enum(struct hda_codec *codec) |
| 882 | { |
| 883 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 884 | |
Takashi Iwai | bc54976 | 2012-12-18 15:35:11 +0100 | [diff] [blame] | 885 | if (!alc_kcontrol_new(spec, NULL, &alc_automute_mode_enum)) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 886 | return -ENOMEM; |
| 887 | return 0; |
| 888 | } |
| 889 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 890 | /* |
| 891 | * Check the availability of HP/line-out auto-mute; |
| 892 | * Set up appropriately if really supported |
| 893 | */ |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 894 | static int alc_init_automute(struct hda_codec *codec) |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 895 | { |
| 896 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 897 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | 1daf5f4 | 2011-04-28 17:57:46 +0200 | [diff] [blame] | 898 | int present = 0; |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 899 | int i, err; |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 900 | |
Takashi Iwai | 1daf5f4 | 2011-04-28 17:57:46 +0200 | [diff] [blame] | 901 | if (cfg->hp_pins[0]) |
| 902 | present++; |
| 903 | if (cfg->line_out_pins[0]) |
| 904 | present++; |
| 905 | if (cfg->speaker_pins[0]) |
| 906 | present++; |
| 907 | if (present < 2) /* need two different output types */ |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 908 | return 0; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 909 | |
Takashi Iwai | c48a8fb | 2011-07-27 16:41:57 +0200 | [diff] [blame] | 910 | if (!cfg->speaker_pins[0] && |
| 911 | cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) { |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 912 | memcpy(cfg->speaker_pins, cfg->line_out_pins, |
| 913 | sizeof(cfg->speaker_pins)); |
| 914 | cfg->speaker_outs = cfg->line_outs; |
| 915 | } |
| 916 | |
Takashi Iwai | c48a8fb | 2011-07-27 16:41:57 +0200 | [diff] [blame] | 917 | if (!cfg->hp_pins[0] && |
| 918 | cfg->line_out_type == AUTO_PIN_HP_OUT) { |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 919 | memcpy(cfg->hp_pins, cfg->line_out_pins, |
| 920 | sizeof(cfg->hp_pins)); |
| 921 | cfg->hp_outs = cfg->line_outs; |
| 922 | } |
| 923 | |
| 924 | for (i = 0; i < cfg->hp_outs; i++) { |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 925 | hda_nid_t nid = cfg->hp_pins[i]; |
Takashi Iwai | 06dec22 | 2011-05-17 10:00:16 +0200 | [diff] [blame] | 926 | if (!is_jack_detectable(codec, nid)) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 927 | continue; |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 928 | snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n", |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 929 | nid); |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 930 | snd_hda_jack_detect_enable_callback(codec, nid, ALC_HP_EVENT, |
| 931 | alc_hp_automute); |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 932 | spec->detect_hp = 1; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 933 | } |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 934 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 935 | if (cfg->line_out_type == AUTO_PIN_LINE_OUT && cfg->line_outs) { |
| 936 | if (cfg->speaker_outs) |
| 937 | for (i = 0; i < cfg->line_outs; i++) { |
| 938 | hda_nid_t nid = cfg->line_out_pins[i]; |
| 939 | if (!is_jack_detectable(codec, nid)) |
| 940 | continue; |
| 941 | snd_printdd("realtek: Enable Line-Out " |
| 942 | "auto-muting on NID 0x%x\n", nid); |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 943 | snd_hda_jack_detect_enable_callback(codec, nid, ALC_FRONT_EVENT, |
| 944 | alc_line_automute); |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 945 | spec->detect_lo = 1; |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 946 | } |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 947 | spec->automute_lo_possible = spec->detect_hp; |
| 948 | } |
| 949 | |
| 950 | spec->automute_speaker_possible = cfg->speaker_outs && |
| 951 | (spec->detect_hp || spec->detect_lo); |
| 952 | |
| 953 | spec->automute_lo = spec->automute_lo_possible; |
| 954 | spec->automute_speaker = spec->automute_speaker_possible; |
| 955 | |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 956 | if (spec->automute_speaker_possible || spec->automute_lo_possible) { |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 957 | /* create a control for automute mode */ |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 958 | err = alc_add_automute_mode_enum(codec); |
| 959 | if (err < 0) |
| 960 | return err; |
| 961 | } |
| 962 | return 0; |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 963 | } |
| 964 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 965 | /* 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] | 966 | static int find_idx_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums) |
| 967 | { |
| 968 | int i; |
| 969 | for (i = 0; i < nums; i++) |
| 970 | if (list[i] == nid) |
| 971 | return i; |
| 972 | return -1; |
| 973 | } |
| 974 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 975 | /* check whether all auto-mic pins are valid; setup indices if OK */ |
| 976 | static bool alc_auto_mic_check_imux(struct hda_codec *codec) |
| 977 | { |
| 978 | struct alc_spec *spec = codec->spec; |
| 979 | const struct hda_input_mux *imux; |
Takashi Iwai | ab16c6d | 2012-11-29 09:56:50 +0100 | [diff] [blame^] | 980 | int i; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 981 | |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 982 | imux = &spec->input_mux; |
Takashi Iwai | ab16c6d | 2012-11-29 09:56:50 +0100 | [diff] [blame^] | 983 | for (i = 0; i < spec->am_num_entries; i++) { |
| 984 | spec->am_entry[i].idx = |
| 985 | find_idx_in_nid_list(spec->am_entry[i].pin, |
| 986 | spec->imux_pins, imux->num_items); |
| 987 | if (spec->am_entry[i].idx < 0) |
| 988 | return false; /* no corresponding imux */ |
| 989 | } |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 990 | |
Takashi Iwai | ab16c6d | 2012-11-29 09:56:50 +0100 | [diff] [blame^] | 991 | /* we don't need the jack detection for the first pin */ |
| 992 | for (i = 1; i < spec->am_num_entries; i++) |
| 993 | snd_hda_jack_detect_enable_callback(codec, |
| 994 | spec->am_entry[i].pin, |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 995 | ALC_MIC_EVENT, |
| 996 | alc_mic_automute); |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 997 | return true; |
| 998 | } |
| 999 | |
Takashi Iwai | ab16c6d | 2012-11-29 09:56:50 +0100 | [diff] [blame^] | 1000 | static int compare_attr(const void *ap, const void *bp) |
| 1001 | { |
| 1002 | const struct alc_automic_entry *a = ap; |
| 1003 | const struct alc_automic_entry *b = bp; |
| 1004 | return (int)(a->attr - b->attr); |
| 1005 | } |
| 1006 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1007 | /* |
| 1008 | * Check the availability of auto-mic switch; |
| 1009 | * Set up if really supported |
| 1010 | */ |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1011 | static int alc_init_auto_mic(struct hda_codec *codec) |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1012 | { |
| 1013 | struct alc_spec *spec = codec->spec; |
| 1014 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | ab16c6d | 2012-11-29 09:56:50 +0100 | [diff] [blame^] | 1015 | unsigned int types; |
| 1016 | int i, num_pins; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1017 | |
Takashi Iwai | ab16c6d | 2012-11-29 09:56:50 +0100 | [diff] [blame^] | 1018 | types = 0; |
| 1019 | num_pins = 0; |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 1020 | for (i = 0; i < cfg->num_inputs; i++) { |
| 1021 | hda_nid_t nid = cfg->inputs[i].pin; |
Takashi Iwai | ab16c6d | 2012-11-29 09:56:50 +0100 | [diff] [blame^] | 1022 | unsigned int attr; |
| 1023 | attr = snd_hda_codec_get_pincfg(codec, nid); |
| 1024 | attr = snd_hda_get_input_pin_attr(attr); |
| 1025 | if (types & (1 << attr)) |
| 1026 | return 0; /* already occupied */ |
| 1027 | switch (attr) { |
Takashi Iwai | 99ae28b | 2010-09-17 14:42:34 +0200 | [diff] [blame] | 1028 | case INPUT_PIN_ATTR_INT: |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1029 | if (cfg->inputs[i].type != AUTO_PIN_MIC) |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1030 | return 0; /* invalid type */ |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1031 | break; |
Takashi Iwai | 99ae28b | 2010-09-17 14:42:34 +0200 | [diff] [blame] | 1032 | case INPUT_PIN_ATTR_UNUSED: |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1033 | return 0; /* invalid entry */ |
Takashi Iwai | ab16c6d | 2012-11-29 09:56:50 +0100 | [diff] [blame^] | 1034 | default: |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1035 | if (cfg->inputs[i].type > AUTO_PIN_LINE_IN) |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1036 | return 0; /* invalid type */ |
Takashi Iwai | ab16c6d | 2012-11-29 09:56:50 +0100 | [diff] [blame^] | 1037 | if (!spec->line_in_auto_switch && |
| 1038 | cfg->inputs[i].type != AUTO_PIN_MIC) |
| 1039 | return 0; /* only mic is allowed */ |
| 1040 | if (!is_jack_detectable(codec, nid)) |
| 1041 | return 0; /* no unsol support */ |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1042 | break; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1043 | } |
Takashi Iwai | ab16c6d | 2012-11-29 09:56:50 +0100 | [diff] [blame^] | 1044 | if (num_pins >= MAX_AUTO_MIC_PINS) |
| 1045 | return 0; |
| 1046 | types |= (1 << attr); |
| 1047 | spec->am_entry[num_pins].pin = nid; |
| 1048 | spec->am_entry[num_pins].attr = attr; |
| 1049 | num_pins++; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1050 | } |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1051 | |
Takashi Iwai | ab16c6d | 2012-11-29 09:56:50 +0100 | [diff] [blame^] | 1052 | if (num_pins < 2) |
| 1053 | return 0; |
| 1054 | |
| 1055 | spec->am_num_entries = num_pins; |
| 1056 | /* sort the am_entry in the order of attr so that the pin with a |
| 1057 | * higher attr will be selected when the jack is plugged. |
| 1058 | */ |
| 1059 | sort(spec->am_entry, num_pins, sizeof(spec->am_entry[0]), |
| 1060 | compare_attr, NULL); |
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 | if (!alc_auto_mic_check_imux(codec)) |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1063 | return 0; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1064 | |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1065 | spec->auto_mic = 1; |
| 1066 | spec->num_adc_nids = 1; |
Takashi Iwai | ab16c6d | 2012-11-29 09:56:50 +0100 | [diff] [blame^] | 1067 | spec->cur_mux[0] = spec->am_entry[0].idx; |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1068 | snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x/0x%x\n", |
Takashi Iwai | ab16c6d | 2012-11-29 09:56:50 +0100 | [diff] [blame^] | 1069 | spec->am_entry[0].pin, |
| 1070 | spec->am_entry[1].pin, |
| 1071 | spec->am_entry[2].pin); |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1072 | |
| 1073 | return 0; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1074 | } |
| 1075 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1076 | /* |
| 1077 | * Realtek SSID verification |
| 1078 | */ |
| 1079 | |
David Henningsson | 9062291 | 2010-10-14 14:50:18 +0200 | [diff] [blame] | 1080 | /* Could be any non-zero and even value. When used as fixup, tells |
| 1081 | * the driver to ignore any present sku defines. |
| 1082 | */ |
| 1083 | #define ALC_FIXUP_SKU_IGNORE (2) |
| 1084 | |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 1085 | static void alc_fixup_sku_ignore(struct hda_codec *codec, |
| 1086 | const struct hda_fixup *fix, int action) |
| 1087 | { |
| 1088 | struct alc_spec *spec = codec->spec; |
| 1089 | if (action == HDA_FIXUP_ACT_PRE_PROBE) { |
| 1090 | spec->cdefine.fixup = 1; |
| 1091 | spec->cdefine.sku_cfg = ALC_FIXUP_SKU_IGNORE; |
| 1092 | } |
| 1093 | } |
| 1094 | |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 1095 | static int alc_auto_parse_customize_define(struct hda_codec *codec) |
| 1096 | { |
| 1097 | unsigned int ass, tmp, i; |
Takashi Iwai | 7fb5622 | 2010-03-22 17:09:47 +0100 | [diff] [blame] | 1098 | unsigned nid = 0; |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 1099 | struct alc_spec *spec = codec->spec; |
| 1100 | |
Takashi Iwai | b6cbe51 | 2010-07-28 17:43:36 +0200 | [diff] [blame] | 1101 | spec->cdefine.enable_pcbeep = 1; /* assume always enabled */ |
| 1102 | |
David Henningsson | 9062291 | 2010-10-14 14:50:18 +0200 | [diff] [blame] | 1103 | if (spec->cdefine.fixup) { |
| 1104 | ass = spec->cdefine.sku_cfg; |
| 1105 | if (ass == ALC_FIXUP_SKU_IGNORE) |
| 1106 | return -1; |
| 1107 | goto do_sku; |
| 1108 | } |
| 1109 | |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 1110 | ass = codec->subsystem_id & 0xffff; |
Takashi Iwai | b6cbe51 | 2010-07-28 17:43:36 +0200 | [diff] [blame] | 1111 | if (ass != codec->bus->pci->subsystem_device && (ass & 1)) |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 1112 | goto do_sku; |
| 1113 | |
| 1114 | nid = 0x1d; |
| 1115 | if (codec->vendor_id == 0x10ec0260) |
| 1116 | nid = 0x17; |
| 1117 | ass = snd_hda_codec_get_pincfg(codec, nid); |
| 1118 | |
| 1119 | if (!(ass & 1)) { |
| 1120 | printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n", |
| 1121 | codec->chip_name, ass); |
| 1122 | return -1; |
| 1123 | } |
| 1124 | |
| 1125 | /* check sum */ |
| 1126 | tmp = 0; |
| 1127 | for (i = 1; i < 16; i++) { |
| 1128 | if ((ass >> i) & 1) |
| 1129 | tmp++; |
| 1130 | } |
| 1131 | if (((ass >> 16) & 0xf) != tmp) |
| 1132 | return -1; |
| 1133 | |
| 1134 | spec->cdefine.port_connectivity = ass >> 30; |
| 1135 | spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20; |
| 1136 | spec->cdefine.check_sum = (ass >> 16) & 0xf; |
| 1137 | spec->cdefine.customization = ass >> 8; |
| 1138 | do_sku: |
| 1139 | spec->cdefine.sku_cfg = ass; |
| 1140 | spec->cdefine.external_amp = (ass & 0x38) >> 3; |
| 1141 | spec->cdefine.platform_type = (ass & 0x4) >> 2; |
| 1142 | spec->cdefine.swap = (ass & 0x2) >> 1; |
| 1143 | spec->cdefine.override = ass & 0x1; |
| 1144 | |
| 1145 | snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n", |
| 1146 | nid, spec->cdefine.sku_cfg); |
| 1147 | snd_printd("SKU: port_connectivity=0x%x\n", |
| 1148 | spec->cdefine.port_connectivity); |
| 1149 | snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep); |
| 1150 | snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum); |
| 1151 | snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization); |
| 1152 | snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp); |
| 1153 | snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type); |
| 1154 | snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap); |
| 1155 | snd_printd("SKU: override=0x%x\n", spec->cdefine.override); |
| 1156 | |
| 1157 | return 0; |
| 1158 | } |
| 1159 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1160 | /* return true if the given NID is found in the list */ |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 1161 | static bool found_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums) |
| 1162 | { |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1163 | return find_idx_in_nid_list(nid, list, nums) >= 0; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 1164 | } |
| 1165 | |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1166 | /* check subsystem ID and set up device-specific initialization; |
| 1167 | * return 1 if initialized, 0 if invalid SSID |
| 1168 | */ |
| 1169 | /* 32-bit subsystem ID for BIOS loading in HD Audio codec. |
| 1170 | * 31 ~ 16 : Manufacture ID |
| 1171 | * 15 ~ 8 : SKU ID |
| 1172 | * 7 ~ 0 : Assembly ID |
| 1173 | * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36 |
| 1174 | */ |
| 1175 | static int alc_subsystem_id(struct hda_codec *codec, |
| 1176 | hda_nid_t porta, hda_nid_t porte, |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 1177 | hda_nid_t portd, hda_nid_t porti) |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1178 | { |
| 1179 | unsigned int ass, tmp, i; |
| 1180 | unsigned nid; |
| 1181 | struct alc_spec *spec = codec->spec; |
| 1182 | |
David Henningsson | 9062291 | 2010-10-14 14:50:18 +0200 | [diff] [blame] | 1183 | if (spec->cdefine.fixup) { |
| 1184 | ass = spec->cdefine.sku_cfg; |
| 1185 | if (ass == ALC_FIXUP_SKU_IGNORE) |
| 1186 | return 0; |
| 1187 | goto do_sku; |
| 1188 | } |
| 1189 | |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1190 | ass = codec->subsystem_id & 0xffff; |
| 1191 | if ((ass != codec->bus->pci->subsystem_device) && (ass & 1)) |
| 1192 | goto do_sku; |
| 1193 | |
| 1194 | /* invalid SSID, check the special NID pin defcfg instead */ |
| 1195 | /* |
Sasha Alexandr | def319f | 2009-06-16 16:00:15 -0400 | [diff] [blame] | 1196 | * 31~30 : port connectivity |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1197 | * 29~21 : reserve |
| 1198 | * 20 : PCBEEP input |
| 1199 | * 19~16 : Check sum (15:1) |
| 1200 | * 15~1 : Custom |
| 1201 | * 0 : override |
| 1202 | */ |
| 1203 | nid = 0x1d; |
| 1204 | if (codec->vendor_id == 0x10ec0260) |
| 1205 | nid = 0x17; |
| 1206 | ass = snd_hda_codec_get_pincfg(codec, nid); |
| 1207 | snd_printd("realtek: No valid SSID, " |
| 1208 | "checking pincfg 0x%08x for NID 0x%x\n", |
Takashi Iwai | cb6605c | 2009-04-28 13:03:19 +0200 | [diff] [blame] | 1209 | ass, nid); |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 1210 | if (!(ass & 1)) |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1211 | return 0; |
| 1212 | if ((ass >> 30) != 1) /* no physical connection */ |
| 1213 | return 0; |
| 1214 | |
| 1215 | /* check sum */ |
| 1216 | tmp = 0; |
| 1217 | for (i = 1; i < 16; i++) { |
| 1218 | if ((ass >> i) & 1) |
| 1219 | tmp++; |
| 1220 | } |
| 1221 | if (((ass >> 16) & 0xf) != tmp) |
| 1222 | return 0; |
| 1223 | do_sku: |
| 1224 | snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n", |
| 1225 | ass & 0xffff, codec->vendor_id); |
| 1226 | /* |
| 1227 | * 0 : override |
| 1228 | * 1 : Swap Jack |
| 1229 | * 2 : 0 --> Desktop, 1 --> Laptop |
| 1230 | * 3~5 : External Amplifier control |
| 1231 | * 7~6 : Reserved |
| 1232 | */ |
| 1233 | tmp = (ass & 0x38) >> 3; /* external Amp control */ |
| 1234 | switch (tmp) { |
| 1235 | case 1: |
| 1236 | spec->init_amp = ALC_INIT_GPIO1; |
| 1237 | break; |
| 1238 | case 3: |
| 1239 | spec->init_amp = ALC_INIT_GPIO2; |
| 1240 | break; |
| 1241 | case 7: |
| 1242 | spec->init_amp = ALC_INIT_GPIO3; |
| 1243 | break; |
| 1244 | case 5: |
Takashi Iwai | 5a8cfb4 | 2010-11-26 17:11:18 +0100 | [diff] [blame] | 1245 | default: |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1246 | spec->init_amp = ALC_INIT_DEFAULT; |
| 1247 | break; |
| 1248 | } |
| 1249 | |
| 1250 | /* is laptop or Desktop and enable the function "Mute internal speaker |
| 1251 | * when the external headphone out jack is plugged" |
| 1252 | */ |
| 1253 | if (!(ass & 0x8000)) |
| 1254 | return 1; |
| 1255 | /* |
| 1256 | * 10~8 : Jack location |
| 1257 | * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered |
| 1258 | * 14~13: Resvered |
| 1259 | * 15 : 1 --> enable the function "Mute internal speaker |
| 1260 | * when the external headphone out jack is plugged" |
| 1261 | */ |
Takashi Iwai | 5fe6e01 | 2011-09-26 10:41:21 +0200 | [diff] [blame] | 1262 | if (!spec->autocfg.hp_pins[0] && |
| 1263 | !(spec->autocfg.line_out_pins[0] && |
| 1264 | spec->autocfg.line_out_type == AUTO_PIN_HP_OUT)) { |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1265 | hda_nid_t nid; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1266 | tmp = (ass >> 11) & 0x3; /* HP to chassis */ |
| 1267 | if (tmp == 0) |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1268 | nid = porta; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1269 | else if (tmp == 1) |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1270 | nid = porte; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1271 | else if (tmp == 2) |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1272 | nid = portd; |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 1273 | else if (tmp == 3) |
| 1274 | nid = porti; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1275 | else |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1276 | return 1; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 1277 | if (found_in_nid_list(nid, spec->autocfg.line_out_pins, |
| 1278 | spec->autocfg.line_outs)) |
| 1279 | return 1; |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1280 | spec->autocfg.hp_pins[0] = nid; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1281 | } |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1282 | return 1; |
| 1283 | } |
Kailang Yang | ea1fb29 | 2008-08-26 12:58:38 +0200 | [diff] [blame] | 1284 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 1285 | /* Check the validity of ALC subsystem-id |
| 1286 | * ports contains an array of 4 pin NIDs for port-A, E, D and I */ |
| 1287 | 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] | 1288 | { |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 1289 | 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] | 1290 | struct alc_spec *spec = codec->spec; |
| 1291 | snd_printd("realtek: " |
| 1292 | "Enable default setup for auto mode as fallback\n"); |
| 1293 | spec->init_amp = ALC_INIT_DEFAULT; |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1294 | } |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1295 | } |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 1296 | |
Takashi Iwai | 41e41f1 | 2005-06-08 14:48:49 +0200 | [diff] [blame] | 1297 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1298 | * COEF access helper functions |
| 1299 | */ |
Kailang Yang | 274693f | 2009-12-03 10:07:50 +0100 | [diff] [blame] | 1300 | static int alc_read_coef_idx(struct hda_codec *codec, |
| 1301 | unsigned int coef_idx) |
| 1302 | { |
| 1303 | unsigned int val; |
| 1304 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, |
| 1305 | coef_idx); |
| 1306 | val = snd_hda_codec_read(codec, 0x20, 0, |
| 1307 | AC_VERB_GET_PROC_COEF, 0); |
| 1308 | return val; |
| 1309 | } |
| 1310 | |
Kailang Yang | 977ddd6 | 2010-09-15 10:02:29 +0200 | [diff] [blame] | 1311 | static void alc_write_coef_idx(struct hda_codec *codec, unsigned int coef_idx, |
| 1312 | unsigned int coef_val) |
| 1313 | { |
| 1314 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, |
| 1315 | coef_idx); |
| 1316 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, |
| 1317 | coef_val); |
| 1318 | } |
| 1319 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 1320 | /* a special bypass for COEF 0; read the cached value at the second time */ |
| 1321 | static unsigned int alc_get_coef0(struct hda_codec *codec) |
| 1322 | { |
| 1323 | struct alc_spec *spec = codec->spec; |
| 1324 | if (!spec->coef0) |
| 1325 | spec->coef0 = alc_read_coef_idx(codec, 0); |
| 1326 | return spec->coef0; |
| 1327 | } |
| 1328 | |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 1329 | static void alc_auto_set_output_and_unmute(struct hda_codec *codec, |
| 1330 | hda_nid_t pin, int pin_type, |
| 1331 | hda_nid_t dac); |
| 1332 | static hda_nid_t alc_auto_look_for_dac(struct hda_codec *codec, hda_nid_t pin, |
| 1333 | bool is_digital); |
Takashi Iwai | 965cceb | 2012-12-18 11:46:37 +0100 | [diff] [blame] | 1334 | static bool parse_nid_path(struct hda_codec *codec, hda_nid_t from_nid, |
| 1335 | hda_nid_t to_nid, int with_aa_mix, |
| 1336 | struct nid_path *path); |
| 1337 | static struct nid_path *add_new_nid_path(struct hda_codec *codec, |
| 1338 | hda_nid_t from_nid, hda_nid_t to_nid, |
| 1339 | int with_aa_mix); |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 1340 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1341 | /* |
| 1342 | * Digital I/O handling |
| 1343 | */ |
| 1344 | |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1345 | /* set right pin controls for digital I/O */ |
| 1346 | static void alc_auto_init_digital(struct hda_codec *codec) |
| 1347 | { |
| 1348 | struct alc_spec *spec = codec->spec; |
| 1349 | int i; |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 1350 | hda_nid_t pin; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1351 | |
| 1352 | for (i = 0; i < spec->autocfg.dig_outs; i++) { |
| 1353 | pin = spec->autocfg.dig_out_pins[i]; |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 1354 | if (!pin) |
| 1355 | continue; |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 1356 | alc_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1357 | } |
| 1358 | pin = spec->autocfg.dig_in_pin; |
| 1359 | if (pin) |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 1360 | snd_hda_set_pin_ctl(codec, pin, PIN_IN); |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1361 | } |
| 1362 | |
| 1363 | /* parse digital I/Os and set up NIDs in BIOS auto-parse mode */ |
| 1364 | static void alc_auto_parse_digital(struct hda_codec *codec) |
| 1365 | { |
| 1366 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 965cceb | 2012-12-18 11:46:37 +0100 | [diff] [blame] | 1367 | int i, nums; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1368 | hda_nid_t dig_nid; |
| 1369 | |
| 1370 | /* support multiple SPDIFs; the secondary is set up as a slave */ |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1371 | nums = 0; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1372 | for (i = 0; i < spec->autocfg.dig_outs; i++) { |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 1373 | hda_nid_t pin = spec->autocfg.dig_out_pins[i]; |
| 1374 | dig_nid = alc_auto_look_for_dac(codec, pin, true); |
| 1375 | if (!dig_nid) |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1376 | continue; |
Takashi Iwai | 965cceb | 2012-12-18 11:46:37 +0100 | [diff] [blame] | 1377 | if (!add_new_nid_path(codec, dig_nid, pin, 2)) |
| 1378 | continue; |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1379 | if (!nums) { |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1380 | spec->multiout.dig_out_nid = dig_nid; |
| 1381 | spec->dig_out_type = spec->autocfg.dig_out_type[0]; |
| 1382 | } else { |
| 1383 | spec->multiout.slave_dig_outs = spec->slave_dig_outs; |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1384 | if (nums >= ARRAY_SIZE(spec->slave_dig_outs) - 1) |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1385 | break; |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1386 | spec->slave_dig_outs[nums - 1] = dig_nid; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1387 | } |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1388 | nums++; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1389 | } |
| 1390 | |
| 1391 | if (spec->autocfg.dig_in_pin) { |
Takashi Iwai | 01fdf18 | 2010-09-24 09:09:42 +0200 | [diff] [blame] | 1392 | dig_nid = codec->start_nid; |
| 1393 | for (i = 0; i < codec->num_nodes; i++, dig_nid++) { |
Takashi Iwai | df1d1fb | 2012-12-18 11:55:53 +0100 | [diff] [blame] | 1394 | struct nid_path *path; |
Takashi Iwai | 01fdf18 | 2010-09-24 09:09:42 +0200 | [diff] [blame] | 1395 | unsigned int wcaps = get_wcaps(codec, dig_nid); |
| 1396 | if (get_wcaps_type(wcaps) != AC_WID_AUD_IN) |
| 1397 | continue; |
| 1398 | if (!(wcaps & AC_WCAP_DIGITAL)) |
| 1399 | continue; |
Takashi Iwai | df1d1fb | 2012-12-18 11:55:53 +0100 | [diff] [blame] | 1400 | path = add_new_nid_path(codec, spec->autocfg.dig_in_pin, |
| 1401 | dig_nid, 2); |
| 1402 | if (path) { |
| 1403 | path->active = true; |
Takashi Iwai | 01fdf18 | 2010-09-24 09:09:42 +0200 | [diff] [blame] | 1404 | spec->dig_in_nid = dig_nid; |
| 1405 | break; |
| 1406 | } |
| 1407 | } |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1408 | } |
| 1409 | } |
| 1410 | |
Takashi Iwai | f95474e | 2007-07-10 00:47:43 +0200 | [diff] [blame] | 1411 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1412 | * capture mixer elements |
Vincent Petry | ef8ef5f | 2008-11-23 11:31:41 +0800 | [diff] [blame] | 1413 | */ |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1414 | #define alc_cap_vol_info snd_hda_mixer_amp_volume_info |
| 1415 | #define alc_cap_vol_get snd_hda_mixer_amp_volume_get |
| 1416 | #define alc_cap_vol_tlv snd_hda_mixer_amp_tlv |
| 1417 | |
| 1418 | typedef int (*put_call_t)(struct snd_kcontrol *kcontrol, |
| 1419 | struct snd_ctl_elem_value *ucontrol); |
| 1420 | |
| 1421 | static int alc_cap_put_caller(struct snd_kcontrol *kcontrol, |
| 1422 | struct snd_ctl_elem_value *ucontrol, |
| 1423 | put_call_t func, int type) |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1424 | { |
| 1425 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1426 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1427 | const struct hda_input_mux *imux; |
| 1428 | struct nid_path *path; |
| 1429 | int i, adc_idx, err = 0; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1430 | |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 1431 | imux = &spec->input_mux; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1432 | adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1433 | mutex_lock(&codec->control_mutex); |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1434 | codec->cached_write = 1; |
| 1435 | for (i = 0; i < imux->num_items; i++) { |
| 1436 | path = get_nid_path(codec, spec->imux_pins[i], |
| 1437 | get_adc_nid(codec, adc_idx, i)); |
| 1438 | if (!path->ctls[type]) |
| 1439 | continue; |
| 1440 | kcontrol->private_value = path->ctls[type]; |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1441 | err = func(kcontrol, ucontrol); |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1442 | if (err < 0) |
| 1443 | goto error; |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1444 | } |
| 1445 | error: |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1446 | codec->cached_write = 0; |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1447 | mutex_unlock(&codec->control_mutex); |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1448 | snd_hda_codec_resume_amp(codec); |
| 1449 | if (err >= 0 && type == NID_PATH_MUTE_CTL && |
| 1450 | spec->inv_dmic_fixup && spec->inv_dmic_muted) |
| 1451 | alc_inv_dmic_sync_adc(codec, adc_idx); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1452 | return err; |
| 1453 | } |
| 1454 | |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1455 | static int alc_cap_vol_put(struct snd_kcontrol *kcontrol, |
| 1456 | struct snd_ctl_elem_value *ucontrol) |
| 1457 | { |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1458 | return alc_cap_put_caller(kcontrol, ucontrol, |
| 1459 | snd_hda_mixer_amp_volume_put, |
| 1460 | NID_PATH_VOL_CTL); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1461 | } |
| 1462 | |
| 1463 | /* capture mixer elements */ |
| 1464 | #define alc_cap_sw_info snd_ctl_boolean_stereo_info |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1465 | #define alc_cap_sw_get snd_hda_mixer_amp_switch_get |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1466 | |
| 1467 | static int alc_cap_sw_put(struct snd_kcontrol *kcontrol, |
| 1468 | struct snd_ctl_elem_value *ucontrol) |
| 1469 | { |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1470 | return alc_cap_put_caller(kcontrol, ucontrol, |
| 1471 | snd_hda_mixer_amp_switch_put, |
| 1472 | NID_PATH_MUTE_CTL); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1473 | } |
| 1474 | |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1475 | static void alc_inv_dmic_sync_adc(struct hda_codec *codec, int adc_idx) |
| 1476 | { |
| 1477 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 1478 | struct hda_input_mux *imux = &spec->input_mux; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1479 | struct nid_path *path; |
| 1480 | hda_nid_t nid; |
| 1481 | int i, dir, parm; |
| 1482 | unsigned int val; |
| 1483 | |
| 1484 | for (i = 0; i < imux->num_items; i++) { |
| 1485 | if (spec->imux_pins[i] == spec->inv_dmic_pin) |
| 1486 | break; |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1487 | } |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1488 | if (i >= imux->num_items) |
| 1489 | return; |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1490 | |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1491 | path = get_nid_path(codec, spec->inv_dmic_pin, |
| 1492 | get_adc_nid(codec, adc_idx, i)); |
| 1493 | val = path->ctls[NID_PATH_MUTE_CTL]; |
| 1494 | if (!val) |
| 1495 | return; |
| 1496 | nid = get_amp_nid_(val); |
| 1497 | dir = get_amp_direction_(val); |
| 1498 | parm = AC_AMP_SET_RIGHT | |
| 1499 | (dir == HDA_OUTPUT ? AC_AMP_SET_OUTPUT : AC_AMP_SET_INPUT); |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1500 | |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1501 | /* we care only right channel */ |
| 1502 | val = snd_hda_codec_amp_read(codec, nid, 1, dir, 0); |
| 1503 | if (val & 0x80) /* if already muted, we don't need to touch */ |
| 1504 | return; |
| 1505 | val |= 0x80; |
| 1506 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
| 1507 | parm | val); |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1508 | } |
| 1509 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1510 | /* |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 1511 | * Inverted digital-mic handling |
| 1512 | * |
| 1513 | * First off, it's a bit tricky. The "Inverted Internal Mic Capture Switch" |
| 1514 | * gives the additional mute only to the right channel of the digital mic |
| 1515 | * capture stream. This is a workaround for avoiding the almost silence |
| 1516 | * by summing the stereo stream from some (known to be ForteMedia) |
| 1517 | * digital mic unit. |
| 1518 | * |
| 1519 | * The logic is to call alc_inv_dmic_sync() after each action (possibly) |
| 1520 | * modifying ADC amp. When the mute flag is set, it mutes the R-channel |
| 1521 | * without caching so that the cache can still keep the original value. |
| 1522 | * The cached value is then restored when the flag is set off or any other |
| 1523 | * than d-mic is used as the current input source. |
| 1524 | */ |
| 1525 | static void alc_inv_dmic_sync(struct hda_codec *codec, bool force) |
| 1526 | { |
| 1527 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1528 | int src, nums; |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 1529 | |
| 1530 | if (!spec->inv_dmic_fixup) |
| 1531 | return; |
| 1532 | if (!spec->inv_dmic_muted && !force) |
| 1533 | return; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1534 | nums = spec->dyn_adc_switch ? 1 : spec->num_adc_nids; |
| 1535 | for (src = 0; src < nums; src++) { |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 1536 | bool dmic_fixup = false; |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 1537 | |
| 1538 | if (spec->inv_dmic_muted && |
| 1539 | spec->imux_pins[spec->cur_mux[src]] == spec->inv_dmic_pin) |
| 1540 | dmic_fixup = true; |
| 1541 | if (!dmic_fixup && !force) |
| 1542 | continue; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1543 | alc_inv_dmic_sync_adc(codec, src); |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 1544 | } |
| 1545 | } |
| 1546 | |
| 1547 | static int alc_inv_dmic_sw_get(struct snd_kcontrol *kcontrol, |
| 1548 | struct snd_ctl_elem_value *ucontrol) |
| 1549 | { |
| 1550 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1551 | struct alc_spec *spec = codec->spec; |
| 1552 | |
| 1553 | ucontrol->value.integer.value[0] = !spec->inv_dmic_muted; |
| 1554 | return 0; |
| 1555 | } |
| 1556 | |
| 1557 | static int alc_inv_dmic_sw_put(struct snd_kcontrol *kcontrol, |
| 1558 | struct snd_ctl_elem_value *ucontrol) |
| 1559 | { |
| 1560 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1561 | struct alc_spec *spec = codec->spec; |
| 1562 | unsigned int val = !ucontrol->value.integer.value[0]; |
| 1563 | |
| 1564 | if (val == spec->inv_dmic_muted) |
| 1565 | return 0; |
| 1566 | spec->inv_dmic_muted = val; |
| 1567 | alc_inv_dmic_sync(codec, true); |
| 1568 | return 0; |
| 1569 | } |
| 1570 | |
| 1571 | static const struct snd_kcontrol_new alc_inv_dmic_sw = { |
| 1572 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
Takashi Iwai | bc54976 | 2012-12-18 15:35:11 +0100 | [diff] [blame] | 1573 | .name = "Inverted Internal Mic Capture Switch", |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 1574 | .info = snd_ctl_boolean_mono_info, |
| 1575 | .get = alc_inv_dmic_sw_get, |
| 1576 | .put = alc_inv_dmic_sw_put, |
| 1577 | }; |
| 1578 | |
| 1579 | static int alc_add_inv_dmic_mixer(struct hda_codec *codec, hda_nid_t nid) |
| 1580 | { |
| 1581 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 668d1e9 | 2012-11-29 14:10:17 +0100 | [diff] [blame] | 1582 | |
Takashi Iwai | bc54976 | 2012-12-18 15:35:11 +0100 | [diff] [blame] | 1583 | if (!alc_kcontrol_new(spec, NULL, &alc_inv_dmic_sw)) |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 1584 | return -ENOMEM; |
| 1585 | spec->inv_dmic_fixup = 1; |
| 1586 | spec->inv_dmic_muted = 0; |
| 1587 | spec->inv_dmic_pin = nid; |
| 1588 | return 0; |
| 1589 | } |
| 1590 | |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 1591 | /* typically the digital mic is put at node 0x12 */ |
| 1592 | static void alc_fixup_inv_dmic_0x12(struct hda_codec *codec, |
| 1593 | const struct alc_fixup *fix, int action) |
| 1594 | { |
| 1595 | if (action == ALC_FIXUP_ACT_PROBE) |
| 1596 | alc_add_inv_dmic_mixer(codec, 0x12); |
| 1597 | } |
| 1598 | |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 1599 | /* |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1600 | * virtual master controls |
| 1601 | */ |
| 1602 | |
| 1603 | /* |
| 1604 | * slave controls for virtual master |
| 1605 | */ |
Takashi Iwai | 9322ca5 | 2012-02-03 14:28:01 +0100 | [diff] [blame] | 1606 | static const char * const alc_slave_pfxs[] = { |
| 1607 | "Front", "Surround", "Center", "LFE", "Side", |
Takashi Iwai | 7c58975 | 2012-03-02 09:00:33 +0100 | [diff] [blame] | 1608 | "Headphone", "Speaker", "Mono", "Line Out", |
Takashi Iwai | 9322ca5 | 2012-02-03 14:28:01 +0100 | [diff] [blame] | 1609 | "CLFE", "Bass Speaker", "PCM", |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1610 | NULL, |
| 1611 | }; |
| 1612 | |
| 1613 | /* |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1614 | * build control elements |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1615 | */ |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 1616 | |
| 1617 | static void alc_free_kctls(struct hda_codec *codec); |
| 1618 | |
Takashi Iwai | 67d634c | 2009-11-16 15:35:59 +0100 | [diff] [blame] | 1619 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1620 | /* additional beep mixers; the actual parameters are overwritten at build */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 1621 | static const struct snd_kcontrol_new alc_beep_mixer[] = { |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1622 | HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT), |
Jaroslav Kysela | 123c07a | 2009-10-21 14:48:23 +0200 | [diff] [blame] | 1623 | HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT), |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1624 | { } /* end */ |
| 1625 | }; |
Takashi Iwai | 67d634c | 2009-11-16 15:35:59 +0100 | [diff] [blame] | 1626 | #endif |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1627 | |
Takashi Iwai | 2eab694 | 2012-12-18 15:30:41 +0100 | [diff] [blame] | 1628 | static int alc_build_controls(struct hda_codec *codec) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1629 | { |
| 1630 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1631 | int i, err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1632 | |
| 1633 | for (i = 0; i < spec->num_mixers; i++) { |
| 1634 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); |
| 1635 | if (err < 0) |
| 1636 | return err; |
| 1637 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1638 | if (spec->multiout.dig_out_nid) { |
Takashi Iwai | dcda580 | 2012-10-12 17:24:51 +0200 | [diff] [blame] | 1639 | err = snd_hda_create_dig_out_ctls(codec, |
| 1640 | spec->multiout.dig_out_nid, |
| 1641 | spec->multiout.dig_out_nid, |
| 1642 | spec->pcm_rec[1].pcm_type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1643 | if (err < 0) |
| 1644 | return err; |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 1645 | if (!spec->no_analog) { |
| 1646 | err = snd_hda_create_spdif_share_sw(codec, |
| 1647 | &spec->multiout); |
| 1648 | if (err < 0) |
| 1649 | return err; |
| 1650 | spec->multiout.share_spdif = 1; |
| 1651 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1652 | } |
| 1653 | if (spec->dig_in_nid) { |
| 1654 | err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); |
| 1655 | if (err < 0) |
| 1656 | return err; |
| 1657 | } |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1658 | |
Takashi Iwai | 67d634c | 2009-11-16 15:35:59 +0100 | [diff] [blame] | 1659 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1660 | /* create beep controls if needed */ |
| 1661 | if (spec->beep_amp) { |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 1662 | const struct snd_kcontrol_new *knew; |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1663 | for (knew = alc_beep_mixer; knew->name; knew++) { |
| 1664 | struct snd_kcontrol *kctl; |
| 1665 | kctl = snd_ctl_new1(knew, codec); |
| 1666 | if (!kctl) |
| 1667 | return -ENOMEM; |
| 1668 | kctl->private_value = spec->beep_amp; |
Jaroslav Kysela | 5e26dfd | 2009-12-10 13:57:01 +0100 | [diff] [blame] | 1669 | err = snd_hda_ctl_add(codec, 0, kctl); |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1670 | if (err < 0) |
| 1671 | return err; |
| 1672 | } |
| 1673 | } |
Takashi Iwai | 67d634c | 2009-11-16 15:35:59 +0100 | [diff] [blame] | 1674 | #endif |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1675 | |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1676 | /* if we have no master control, let's create it */ |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 1677 | if (!spec->no_analog && |
| 1678 | !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1679 | unsigned int vmaster_tlv[4]; |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1680 | snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid, |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1681 | HDA_OUTPUT, vmaster_tlv); |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1682 | err = snd_hda_add_vmaster(codec, "Master Playback Volume", |
Takashi Iwai | 9322ca5 | 2012-02-03 14:28:01 +0100 | [diff] [blame] | 1683 | vmaster_tlv, alc_slave_pfxs, |
| 1684 | "Playback Volume"); |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1685 | if (err < 0) |
| 1686 | return err; |
| 1687 | } |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 1688 | if (!spec->no_analog && |
| 1689 | !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) { |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 1690 | err = __snd_hda_add_vmaster(codec, "Master Playback Switch", |
| 1691 | NULL, alc_slave_pfxs, |
| 1692 | "Playback Switch", |
Takashi Iwai | d2f344b | 2012-03-12 16:59:58 +0100 | [diff] [blame] | 1693 | true, &spec->vmaster_mute.sw_kctl); |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1694 | if (err < 0) |
| 1695 | return err; |
Takashi Iwai | 3bd7b64 | 2012-12-18 14:57:09 +0100 | [diff] [blame] | 1696 | if (spec->vmaster_mute.hook) |
| 1697 | snd_hda_add_vmaster_hook(codec, &spec->vmaster_mute, true); |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1698 | } |
| 1699 | |
Takashi Iwai | bae84e7 | 2010-03-22 08:30:20 +0100 | [diff] [blame] | 1700 | alc_free_kctls(codec); /* no longer needed */ |
| 1701 | |
David Henningsson | 5780b62 | 2012-06-27 18:45:45 +0200 | [diff] [blame] | 1702 | if (spec->shared_mic_hp) { |
| 1703 | int err; |
| 1704 | int nid = spec->autocfg.inputs[1].pin; |
| 1705 | err = snd_hda_jack_add_kctl(codec, nid, "Headphone Mic", 0); |
| 1706 | if (err < 0) |
| 1707 | return err; |
| 1708 | err = snd_hda_jack_detect_enable(codec, nid, 0); |
| 1709 | if (err < 0) |
| 1710 | return err; |
| 1711 | } |
| 1712 | |
Takashi Iwai | 2eab694 | 2012-12-18 15:30:41 +0100 | [diff] [blame] | 1713 | err = snd_hda_jack_add_kctls(codec, &spec->autocfg); |
Takashi Iwai | 01a61e1 | 2011-10-28 00:03:22 +0200 | [diff] [blame] | 1714 | if (err < 0) |
| 1715 | return err; |
David Henningsson | 5780b62 | 2012-06-27 18:45:45 +0200 | [diff] [blame] | 1716 | |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 1717 | alc_apply_fixup(codec, ALC_FIXUP_ACT_BUILD); |
| 1718 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1719 | } |
| 1720 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1721 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1722 | /* |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 1723 | * Common callbacks |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1724 | */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1725 | |
Takashi Iwai | 070cff4 | 2012-02-21 12:54:17 +0100 | [diff] [blame] | 1726 | static void alc_auto_init_std(struct hda_codec *codec); |
Takashi Iwai | 584c0c4 | 2011-03-10 12:51:11 +0100 | [diff] [blame] | 1727 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1728 | static int alc_init(struct hda_codec *codec) |
| 1729 | { |
| 1730 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1731 | |
Takashi Iwai | 546bb67 | 2012-03-07 08:37:19 +0100 | [diff] [blame] | 1732 | if (spec->init_hook) |
| 1733 | spec->init_hook(codec); |
Kailang Yang | 526af6e | 2012-03-07 08:25:20 +0100 | [diff] [blame] | 1734 | |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 1735 | alc_fix_pll(codec); |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1736 | alc_auto_init_amp(codec, spec->init_amp); |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 1737 | |
Takashi Iwai | c9ce6b2 | 2012-12-18 18:12:44 +0100 | [diff] [blame] | 1738 | snd_hda_apply_verbs(codec); |
Takashi Iwai | 070cff4 | 2012-02-21 12:54:17 +0100 | [diff] [blame] | 1739 | alc_auto_init_std(codec); |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 1740 | |
Takashi Iwai | 3bd7b64 | 2012-12-18 14:57:09 +0100 | [diff] [blame] | 1741 | if (spec->vmaster_mute.sw_kctl && spec->vmaster_mute.hook) |
| 1742 | snd_hda_sync_vmaster_hook(&spec->vmaster_mute); |
| 1743 | |
Takashi Iwai | 5870112 | 2011-01-13 15:41:45 +0100 | [diff] [blame] | 1744 | alc_apply_fixup(codec, ALC_FIXUP_ACT_INIT); |
| 1745 | |
Takashi Iwai | 9e5341b | 2010-09-21 09:57:06 +0200 | [diff] [blame] | 1746 | hda_call_check_power_status(codec, 0x01); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1747 | return 0; |
| 1748 | } |
| 1749 | |
Takashi Iwai | 83012a7 | 2012-08-24 18:38:08 +0200 | [diff] [blame] | 1750 | #ifdef CONFIG_PM |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 1751 | static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid) |
| 1752 | { |
| 1753 | struct alc_spec *spec = codec->spec; |
| 1754 | return snd_hda_check_amp_list_power(codec, &spec->loopback, nid); |
| 1755 | } |
| 1756 | #endif |
| 1757 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1758 | /* |
| 1759 | * Analog playback callbacks |
| 1760 | */ |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1761 | static int alc_playback_pcm_open(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1762 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1763 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1764 | { |
| 1765 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 9a08160 | 2008-02-12 18:37:26 +0100 | [diff] [blame] | 1766 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, |
| 1767 | hinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1768 | } |
| 1769 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1770 | static int alc_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1771 | struct hda_codec *codec, |
| 1772 | unsigned int stream_tag, |
| 1773 | unsigned int format, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1774 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1775 | { |
| 1776 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 1777 | return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, |
| 1778 | stream_tag, format, substream); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1779 | } |
| 1780 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1781 | static int alc_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1782 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1783 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1784 | { |
| 1785 | struct alc_spec *spec = codec->spec; |
| 1786 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); |
| 1787 | } |
| 1788 | |
| 1789 | /* |
| 1790 | * Digital out |
| 1791 | */ |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1792 | static int alc_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1793 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1794 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1795 | { |
| 1796 | struct alc_spec *spec = codec->spec; |
| 1797 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); |
| 1798 | } |
| 1799 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1800 | static int alc_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
Takashi Iwai | 6b97eb4 | 2007-04-05 14:51:48 +0200 | [diff] [blame] | 1801 | struct hda_codec *codec, |
| 1802 | unsigned int stream_tag, |
| 1803 | unsigned int format, |
| 1804 | struct snd_pcm_substream *substream) |
| 1805 | { |
| 1806 | struct alc_spec *spec = codec->spec; |
| 1807 | return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, |
| 1808 | stream_tag, format, substream); |
| 1809 | } |
| 1810 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1811 | static int alc_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
Takashi Iwai | 9b5f12e | 2009-02-13 11:47:37 +0100 | [diff] [blame] | 1812 | struct hda_codec *codec, |
| 1813 | struct snd_pcm_substream *substream) |
| 1814 | { |
| 1815 | struct alc_spec *spec = codec->spec; |
| 1816 | return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout); |
| 1817 | } |
| 1818 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1819 | static int alc_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1820 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1821 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1822 | { |
| 1823 | struct alc_spec *spec = codec->spec; |
| 1824 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); |
| 1825 | } |
| 1826 | |
| 1827 | /* |
| 1828 | * Analog capture |
| 1829 | */ |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1830 | static int alc_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1831 | struct hda_codec *codec, |
| 1832 | unsigned int stream_tag, |
| 1833 | unsigned int format, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1834 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1835 | { |
| 1836 | struct alc_spec *spec = codec->spec; |
| 1837 | |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 1838 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1], |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1839 | stream_tag, 0, format); |
| 1840 | return 0; |
| 1841 | } |
| 1842 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1843 | static int alc_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1844 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1845 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1846 | { |
| 1847 | struct alc_spec *spec = codec->spec; |
| 1848 | |
Takashi Iwai | 888afa1 | 2008-03-18 09:57:50 +0100 | [diff] [blame] | 1849 | snd_hda_codec_cleanup_stream(codec, |
| 1850 | spec->adc_nids[substream->number + 1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1851 | return 0; |
| 1852 | } |
| 1853 | |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 1854 | /* analog capture with dynamic dual-adc changes */ |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1855 | static int dyn_adc_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 1856 | struct hda_codec *codec, |
| 1857 | unsigned int stream_tag, |
| 1858 | unsigned int format, |
| 1859 | struct snd_pcm_substream *substream) |
| 1860 | { |
| 1861 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1862 | 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] | 1863 | spec->cur_adc_stream_tag = stream_tag; |
| 1864 | spec->cur_adc_format = format; |
| 1865 | snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format); |
| 1866 | return 0; |
| 1867 | } |
| 1868 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1869 | static int dyn_adc_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 1870 | struct hda_codec *codec, |
| 1871 | struct snd_pcm_substream *substream) |
| 1872 | { |
| 1873 | struct alc_spec *spec = codec->spec; |
| 1874 | snd_hda_codec_cleanup_stream(codec, spec->cur_adc); |
| 1875 | spec->cur_adc = 0; |
| 1876 | return 0; |
| 1877 | } |
| 1878 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1879 | static const struct hda_pcm_stream dyn_adc_pcm_analog_capture = { |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 1880 | .substreams = 1, |
| 1881 | .channels_min = 2, |
| 1882 | .channels_max = 2, |
| 1883 | .nid = 0, /* fill later */ |
| 1884 | .ops = { |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1885 | .prepare = dyn_adc_capture_pcm_prepare, |
| 1886 | .cleanup = dyn_adc_capture_pcm_cleanup |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 1887 | }, |
| 1888 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1889 | |
| 1890 | /* |
| 1891 | */ |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1892 | static const struct hda_pcm_stream alc_pcm_analog_playback = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1893 | .substreams = 1, |
| 1894 | .channels_min = 2, |
| 1895 | .channels_max = 8, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1896 | /* NID is set in alc_build_pcms */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1897 | .ops = { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1898 | .open = alc_playback_pcm_open, |
| 1899 | .prepare = alc_playback_pcm_prepare, |
| 1900 | .cleanup = alc_playback_pcm_cleanup |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1901 | }, |
| 1902 | }; |
| 1903 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1904 | static const struct hda_pcm_stream alc_pcm_analog_capture = { |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 1905 | .substreams = 1, |
| 1906 | .channels_min = 2, |
| 1907 | .channels_max = 2, |
| 1908 | /* NID is set in alc_build_pcms */ |
| 1909 | }; |
| 1910 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1911 | static const struct hda_pcm_stream alc_pcm_analog_alt_playback = { |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 1912 | .substreams = 1, |
| 1913 | .channels_min = 2, |
| 1914 | .channels_max = 2, |
| 1915 | /* NID is set in alc_build_pcms */ |
| 1916 | }; |
| 1917 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1918 | static const struct hda_pcm_stream alc_pcm_analog_alt_capture = { |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 1919 | .substreams = 2, /* can be overridden */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1920 | .channels_min = 2, |
| 1921 | .channels_max = 2, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1922 | /* NID is set in alc_build_pcms */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1923 | .ops = { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1924 | .prepare = alc_alt_capture_pcm_prepare, |
| 1925 | .cleanup = alc_alt_capture_pcm_cleanup |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1926 | }, |
| 1927 | }; |
| 1928 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1929 | static const struct hda_pcm_stream alc_pcm_digital_playback = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1930 | .substreams = 1, |
| 1931 | .channels_min = 2, |
| 1932 | .channels_max = 2, |
| 1933 | /* NID is set in alc_build_pcms */ |
| 1934 | .ops = { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1935 | .open = alc_dig_playback_pcm_open, |
| 1936 | .close = alc_dig_playback_pcm_close, |
| 1937 | .prepare = alc_dig_playback_pcm_prepare, |
| 1938 | .cleanup = alc_dig_playback_pcm_cleanup |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1939 | }, |
| 1940 | }; |
| 1941 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1942 | static const struct hda_pcm_stream alc_pcm_digital_capture = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1943 | .substreams = 1, |
| 1944 | .channels_min = 2, |
| 1945 | .channels_max = 2, |
| 1946 | /* NID is set in alc_build_pcms */ |
| 1947 | }; |
| 1948 | |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 1949 | /* 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] | 1950 | static const struct hda_pcm_stream alc_pcm_null_stream = { |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 1951 | .substreams = 0, |
| 1952 | .channels_min = 0, |
| 1953 | .channels_max = 0, |
| 1954 | }; |
| 1955 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1956 | static int alc_build_pcms(struct hda_codec *codec) |
| 1957 | { |
| 1958 | struct alc_spec *spec = codec->spec; |
| 1959 | struct hda_pcm *info = spec->pcm_rec; |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1960 | const struct hda_pcm_stream *p; |
Takashi Iwai | 1fa1757 | 2011-11-02 21:30:51 +0100 | [diff] [blame] | 1961 | bool have_multi_adcs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1962 | int i; |
| 1963 | |
| 1964 | codec->num_pcms = 1; |
| 1965 | codec->pcm_info = info; |
| 1966 | |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 1967 | if (spec->no_analog) |
| 1968 | goto skip_analog; |
| 1969 | |
Takashi Iwai | 812a2cc | 2009-05-16 10:00:49 +0200 | [diff] [blame] | 1970 | snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog), |
| 1971 | "%s Analog", codec->chip_name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1972 | info->name = spec->stream_name_analog; |
Kailang Yang | 274693f | 2009-12-03 10:07:50 +0100 | [diff] [blame] | 1973 | |
Takashi Iwai | eedec3d | 2012-02-06 10:24:04 +0100 | [diff] [blame] | 1974 | if (spec->multiout.num_dacs > 0) { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1975 | p = spec->stream_analog_playback; |
| 1976 | if (!p) |
| 1977 | p = &alc_pcm_analog_playback; |
| 1978 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *p; |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 1979 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0]; |
Takashi Iwai | 9c9a517 | 2012-07-31 11:35:35 +0200 | [diff] [blame] | 1980 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = |
| 1981 | spec->multiout.max_channels; |
Takashi Iwai | ee81abb | 2012-11-08 17:12:10 +0100 | [diff] [blame] | 1982 | if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT && |
| 1983 | spec->autocfg.line_outs == 2) |
| 1984 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].chmap = |
| 1985 | snd_pcm_2_1_chmaps; |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 1986 | } |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 1987 | if (spec->num_adc_nids) { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1988 | p = spec->stream_analog_capture; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1989 | if (!p) { |
| 1990 | if (spec->dyn_adc_switch) |
| 1991 | p = &dyn_adc_pcm_analog_capture; |
| 1992 | else |
| 1993 | p = &alc_pcm_analog_capture; |
| 1994 | } |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1995 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *p; |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 1996 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; |
| 1997 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1998 | |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 1999 | if (spec->channel_mode) { |
| 2000 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0; |
| 2001 | for (i = 0; i < spec->num_channel_mode; i++) { |
| 2002 | if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) { |
| 2003 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels; |
| 2004 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2005 | } |
| 2006 | } |
| 2007 | |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 2008 | skip_analog: |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2009 | /* SPDIF for stream index #1 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2010 | if (spec->multiout.dig_out_nid || spec->dig_in_nid) { |
Takashi Iwai | 812a2cc | 2009-05-16 10:00:49 +0200 | [diff] [blame] | 2011 | snprintf(spec->stream_name_digital, |
| 2012 | sizeof(spec->stream_name_digital), |
| 2013 | "%s Digital", codec->chip_name); |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2014 | codec->num_pcms = 2; |
Wu Fengguang | b25c9da | 2009-02-06 15:02:27 +0800 | [diff] [blame] | 2015 | codec->slave_dig_outs = spec->multiout.slave_dig_outs; |
Takashi Iwai | c06134d | 2006-10-11 18:49:13 +0200 | [diff] [blame] | 2016 | info = spec->pcm_rec + 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2017 | info->name = spec->stream_name_digital; |
Takashi Iwai | 8c44198 | 2009-01-20 18:30:20 +0100 | [diff] [blame] | 2018 | if (spec->dig_out_type) |
| 2019 | info->pcm_type = spec->dig_out_type; |
| 2020 | else |
| 2021 | info->pcm_type = HDA_PCM_TYPE_SPDIF; |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2022 | if (spec->multiout.dig_out_nid) { |
| 2023 | p = spec->stream_digital_playback; |
| 2024 | if (!p) |
| 2025 | p = &alc_pcm_digital_playback; |
| 2026 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2027 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; |
| 2028 | } |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2029 | if (spec->dig_in_nid) { |
| 2030 | p = spec->stream_digital_capture; |
| 2031 | if (!p) |
| 2032 | p = &alc_pcm_digital_capture; |
| 2033 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2034 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; |
| 2035 | } |
Takashi Iwai | 963f803 | 2008-08-11 10:04:40 +0200 | [diff] [blame] | 2036 | /* FIXME: do we need this for all Realtek codec models? */ |
| 2037 | codec->spdif_status_reset = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2038 | } |
| 2039 | |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 2040 | if (spec->no_analog) |
| 2041 | return 0; |
| 2042 | |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2043 | /* If the use of more than one ADC is requested for the current |
| 2044 | * model, configure a second analog capture-only PCM. |
| 2045 | */ |
Takashi Iwai | 1fa1757 | 2011-11-02 21:30:51 +0100 | [diff] [blame] | 2046 | have_multi_adcs = (spec->num_adc_nids > 1) && |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 2047 | !spec->dyn_adc_switch && !spec->auto_mic; |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2048 | /* Additional Analaog capture for index #2 */ |
Takashi Iwai | 1fa1757 | 2011-11-02 21:30:51 +0100 | [diff] [blame] | 2049 | if (spec->alt_dac_nid || have_multi_adcs) { |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2050 | codec->num_pcms = 3; |
Takashi Iwai | c06134d | 2006-10-11 18:49:13 +0200 | [diff] [blame] | 2051 | info = spec->pcm_rec + 2; |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2052 | info->name = spec->stream_name_analog; |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2053 | if (spec->alt_dac_nid) { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2054 | p = spec->stream_analog_alt_playback; |
| 2055 | if (!p) |
| 2056 | p = &alc_pcm_analog_alt_playback; |
| 2057 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *p; |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2058 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = |
| 2059 | spec->alt_dac_nid; |
| 2060 | } else { |
| 2061 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = |
| 2062 | alc_pcm_null_stream; |
| 2063 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0; |
| 2064 | } |
Takashi Iwai | 1fa1757 | 2011-11-02 21:30:51 +0100 | [diff] [blame] | 2065 | if (have_multi_adcs) { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2066 | p = spec->stream_analog_alt_capture; |
| 2067 | if (!p) |
| 2068 | p = &alc_pcm_analog_alt_capture; |
| 2069 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *p; |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2070 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = |
| 2071 | spec->adc_nids[1]; |
| 2072 | info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = |
| 2073 | spec->num_adc_nids - 1; |
| 2074 | } else { |
| 2075 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = |
| 2076 | alc_pcm_null_stream; |
| 2077 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0; |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2078 | } |
| 2079 | } |
| 2080 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2081 | return 0; |
| 2082 | } |
| 2083 | |
Takashi Iwai | a4e09aa | 2009-12-27 11:22:24 +0100 | [diff] [blame] | 2084 | static inline void alc_shutup(struct hda_codec *codec) |
| 2085 | { |
Takashi Iwai | 1c71615 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 2086 | struct alc_spec *spec = codec->spec; |
| 2087 | |
| 2088 | if (spec && spec->shutup) |
| 2089 | spec->shutup(codec); |
Takashi Iwai | a4e09aa | 2009-12-27 11:22:24 +0100 | [diff] [blame] | 2090 | snd_hda_shutup_pins(codec); |
| 2091 | } |
| 2092 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 2093 | static void alc_free_kctls(struct hda_codec *codec) |
| 2094 | { |
| 2095 | struct alc_spec *spec = codec->spec; |
| 2096 | |
| 2097 | if (spec->kctls.list) { |
| 2098 | struct snd_kcontrol_new *kctl = spec->kctls.list; |
| 2099 | int i; |
| 2100 | for (i = 0; i < spec->kctls.used; i++) |
| 2101 | kfree(kctl[i].name); |
| 2102 | } |
| 2103 | snd_array_free(&spec->kctls); |
| 2104 | } |
| 2105 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2106 | static void alc_free_bind_ctls(struct hda_codec *codec) |
| 2107 | { |
| 2108 | struct alc_spec *spec = codec->spec; |
| 2109 | if (spec->bind_ctls.list) { |
| 2110 | struct hda_bind_ctls **ctl = spec->bind_ctls.list; |
| 2111 | int i; |
| 2112 | for (i = 0; i < spec->bind_ctls.used; i++) |
| 2113 | kfree(ctl[i]); |
| 2114 | } |
| 2115 | snd_array_free(&spec->bind_ctls); |
| 2116 | } |
| 2117 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2118 | static void alc_free(struct hda_codec *codec) |
| 2119 | { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2120 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2121 | |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2122 | if (!spec) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2123 | return; |
| 2124 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 2125 | alc_free_kctls(codec); |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2126 | alc_free_bind_ctls(codec); |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 2127 | snd_array_free(&spec->paths); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2128 | kfree(spec); |
Kusanagi Kouichi | 680cd53 | 2009-02-05 00:00:58 +0900 | [diff] [blame] | 2129 | snd_hda_detach_beep_device(codec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2130 | } |
| 2131 | |
Takashi Iwai | 83012a7 | 2012-08-24 18:38:08 +0200 | [diff] [blame] | 2132 | #ifdef CONFIG_PM |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 2133 | static void alc_power_eapd(struct hda_codec *codec) |
| 2134 | { |
Takashi Iwai | 691f1fc | 2011-04-07 10:31:43 +0200 | [diff] [blame] | 2135 | alc_auto_setup_eapd(codec, false); |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 2136 | } |
| 2137 | |
Takashi Iwai | 68cb2b5 | 2012-07-02 15:20:37 +0200 | [diff] [blame] | 2138 | static int alc_suspend(struct hda_codec *codec) |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 2139 | { |
| 2140 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | a4e09aa | 2009-12-27 11:22:24 +0100 | [diff] [blame] | 2141 | alc_shutup(codec); |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 2142 | if (spec && spec->power_hook) |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 2143 | spec->power_hook(codec); |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 2144 | return 0; |
| 2145 | } |
| 2146 | #endif |
| 2147 | |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 2148 | #ifdef CONFIG_PM |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2149 | static int alc_resume(struct hda_codec *codec) |
| 2150 | { |
Takashi Iwai | 1c71615 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 2151 | msleep(150); /* to avoid pop noise */ |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2152 | codec->patch_ops.init(codec); |
| 2153 | snd_hda_codec_resume_amp(codec); |
| 2154 | snd_hda_codec_resume_cache(codec); |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 2155 | alc_inv_dmic_sync(codec, true); |
Takashi Iwai | 9e5341b | 2010-09-21 09:57:06 +0200 | [diff] [blame] | 2156 | hda_call_check_power_status(codec, 0x01); |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2157 | return 0; |
| 2158 | } |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2159 | #endif |
| 2160 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2161 | /* |
| 2162 | */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 2163 | static const struct hda_codec_ops alc_patch_ops = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2164 | .build_controls = alc_build_controls, |
| 2165 | .build_pcms = alc_build_pcms, |
| 2166 | .init = alc_init, |
| 2167 | .free = alc_free, |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 2168 | .unsol_event = snd_hda_jack_unsol_event, |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 2169 | #ifdef CONFIG_PM |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2170 | .resume = alc_resume, |
| 2171 | #endif |
Takashi Iwai | 83012a7 | 2012-08-24 18:38:08 +0200 | [diff] [blame] | 2172 | #ifdef CONFIG_PM |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 2173 | .suspend = alc_suspend, |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 2174 | .check_power_status = alc_check_power_status, |
| 2175 | #endif |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 2176 | .reboot_notify = alc_shutup, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2177 | }; |
| 2178 | |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 2179 | |
Kailang Yang | c027ddc | 2010-03-19 11:33:06 +0100 | [diff] [blame] | 2180 | /* replace the codec chip_name with the given string */ |
| 2181 | static int alc_codec_rename(struct hda_codec *codec, const char *name) |
| 2182 | { |
| 2183 | kfree(codec->chip_name); |
| 2184 | codec->chip_name = kstrdup(name, GFP_KERNEL); |
| 2185 | if (!codec->chip_name) { |
| 2186 | alc_free(codec); |
| 2187 | return -ENOMEM; |
| 2188 | } |
| 2189 | return 0; |
| 2190 | } |
| 2191 | |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 2192 | /* |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 2193 | * Rename codecs appropriately from COEF value |
| 2194 | */ |
| 2195 | struct alc_codec_rename_table { |
| 2196 | unsigned int vendor_id; |
| 2197 | unsigned short coef_mask; |
| 2198 | unsigned short coef_bits; |
| 2199 | const char *name; |
| 2200 | }; |
| 2201 | |
| 2202 | static struct alc_codec_rename_table rename_tbl[] = { |
| 2203 | { 0x10ec0269, 0xfff0, 0x3010, "ALC277" }, |
| 2204 | { 0x10ec0269, 0xf0f0, 0x2010, "ALC259" }, |
| 2205 | { 0x10ec0269, 0xf0f0, 0x3010, "ALC258" }, |
| 2206 | { 0x10ec0269, 0x00f0, 0x0010, "ALC269VB" }, |
| 2207 | { 0x10ec0269, 0xffff, 0xa023, "ALC259" }, |
| 2208 | { 0x10ec0269, 0xffff, 0x6023, "ALC281X" }, |
| 2209 | { 0x10ec0269, 0x00f0, 0x0020, "ALC269VC" }, |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 2210 | { 0x10ec0269, 0x00f0, 0x0030, "ALC269VD" }, |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 2211 | { 0x10ec0887, 0x00f0, 0x0030, "ALC887-VD" }, |
| 2212 | { 0x10ec0888, 0x00f0, 0x0030, "ALC888-VD" }, |
| 2213 | { 0x10ec0888, 0xf0f0, 0x3020, "ALC886" }, |
| 2214 | { 0x10ec0899, 0x2000, 0x2000, "ALC899" }, |
| 2215 | { 0x10ec0892, 0xffff, 0x8020, "ALC661" }, |
| 2216 | { 0x10ec0892, 0xffff, 0x8011, "ALC661" }, |
| 2217 | { 0x10ec0892, 0xffff, 0x4011, "ALC656" }, |
| 2218 | { } /* terminator */ |
| 2219 | }; |
| 2220 | |
| 2221 | static int alc_codec_rename_from_preset(struct hda_codec *codec) |
| 2222 | { |
| 2223 | const struct alc_codec_rename_table *p; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 2224 | |
| 2225 | for (p = rename_tbl; p->vendor_id; p++) { |
| 2226 | if (p->vendor_id != codec->vendor_id) |
| 2227 | continue; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 2228 | if ((alc_get_coef0(codec) & p->coef_mask) == p->coef_bits) |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 2229 | return alc_codec_rename(codec, p->name); |
| 2230 | } |
| 2231 | return 0; |
| 2232 | } |
| 2233 | |
| 2234 | /* |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2235 | * Automatic parse of I/O pins from the BIOS configuration |
| 2236 | */ |
| 2237 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2238 | enum { |
| 2239 | ALC_CTL_WIDGET_VOL, |
| 2240 | ALC_CTL_WIDGET_MUTE, |
| 2241 | ALC_CTL_BIND_MUTE, |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2242 | ALC_CTL_BIND_VOL, |
| 2243 | ALC_CTL_BIND_SW, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2244 | }; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 2245 | static const struct snd_kcontrol_new alc_control_templates[] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2246 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), |
| 2247 | HDA_CODEC_MUTE(NULL, 0, 0, 0), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 2248 | HDA_BIND_MUTE(NULL, 0, 0, 0), |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2249 | HDA_BIND_VOL(NULL, 0), |
| 2250 | HDA_BIND_SW(NULL, 0), |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2251 | }; |
| 2252 | |
| 2253 | /* add dynamic controls */ |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2254 | 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] | 2255 | int cidx, unsigned long val) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2256 | { |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2257 | struct snd_kcontrol_new *knew; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2258 | |
Takashi Iwai | 668d1e9 | 2012-11-29 14:10:17 +0100 | [diff] [blame] | 2259 | knew = alc_kcontrol_new(spec, name, &alc_control_templates[type]); |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 2260 | if (!knew) |
| 2261 | return -ENOMEM; |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2262 | knew->index = cidx; |
Jaroslav Kysela | 4d02d1b | 2009-11-12 10:15:48 +0100 | [diff] [blame] | 2263 | if (get_amp_nid_(val)) |
Jaroslav Kysela | 5e26dfd | 2009-12-10 13:57:01 +0100 | [diff] [blame] | 2264 | knew->subdevice = HDA_SUBDEV_AMP_FLAG; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2265 | knew->private_value = val; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2266 | return 0; |
| 2267 | } |
| 2268 | |
Takashi Iwai | 0afe5f8 | 2009-10-02 09:20:00 +0200 | [diff] [blame] | 2269 | static int add_control_with_pfx(struct alc_spec *spec, int type, |
| 2270 | const char *pfx, const char *dir, |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2271 | const char *sfx, int cidx, unsigned long val) |
Takashi Iwai | 0afe5f8 | 2009-10-02 09:20:00 +0200 | [diff] [blame] | 2272 | { |
| 2273 | char name[32]; |
| 2274 | snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx); |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2275 | return add_control(spec, type, name, cidx, val); |
Takashi Iwai | 0afe5f8 | 2009-10-02 09:20:00 +0200 | [diff] [blame] | 2276 | } |
| 2277 | |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2278 | #define add_pb_vol_ctrl(spec, type, pfx, val) \ |
| 2279 | add_control_with_pfx(spec, type, pfx, "Playback", "Volume", 0, val) |
| 2280 | #define add_pb_sw_ctrl(spec, type, pfx, val) \ |
| 2281 | add_control_with_pfx(spec, type, pfx, "Playback", "Switch", 0, val) |
| 2282 | #define __add_pb_vol_ctrl(spec, type, pfx, cidx, val) \ |
| 2283 | add_control_with_pfx(spec, type, pfx, "Playback", "Volume", cidx, val) |
| 2284 | #define __add_pb_sw_ctrl(spec, type, pfx, cidx, val) \ |
| 2285 | add_control_with_pfx(spec, type, pfx, "Playback", "Switch", cidx, val) |
Takashi Iwai | 0afe5f8 | 2009-10-02 09:20:00 +0200 | [diff] [blame] | 2286 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2287 | static const char * const channel_name[4] = { |
| 2288 | "Front", "Surround", "CLFE", "Side" |
| 2289 | }; |
| 2290 | |
Takashi Iwai | 6843ca1 | 2011-06-24 11:03:58 +0200 | [diff] [blame] | 2291 | static const char *alc_get_line_out_pfx(struct alc_spec *spec, int ch, |
| 2292 | bool can_be_master, int *index) |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2293 | { |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 2294 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2295 | |
Takashi Iwai | 6843ca1 | 2011-06-24 11:03:58 +0200 | [diff] [blame] | 2296 | *index = 0; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 2297 | if (cfg->line_outs == 1 && !spec->multi_ios && |
| 2298 | !cfg->hp_outs && !cfg->speaker_outs && can_be_master) |
Takashi Iwai | 52a8efa | 2012-12-18 17:33:04 +0100 | [diff] [blame] | 2299 | return spec->vmaster_mute.hook ? "PCM" : "Master"; |
| 2300 | |
| 2301 | /* if there is really a single DAC used in the whole output paths, |
| 2302 | * use it master (or "PCM" if a vmaster hook is present) |
| 2303 | */ |
| 2304 | if (spec->multiout.num_dacs == 1 && !spec->mixer_nid && |
| 2305 | !spec->multiout.hp_out_nid[0] && !spec->multiout.extra_out_nid[0]) |
| 2306 | return spec->vmaster_mute.hook ? "PCM" : "Master"; |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2307 | |
| 2308 | switch (cfg->line_out_type) { |
| 2309 | case AUTO_PIN_SPEAKER_OUT: |
David Henningsson | ebbeb3d | 2011-03-04 14:08:30 +0100 | [diff] [blame] | 2310 | if (cfg->line_outs == 1) |
| 2311 | return "Speaker"; |
Takashi Iwai | fbabc24 | 2011-12-07 17:14:20 +0100 | [diff] [blame] | 2312 | if (cfg->line_outs == 2) |
| 2313 | return ch ? "Bass Speaker" : "Speaker"; |
David Henningsson | ebbeb3d | 2011-03-04 14:08:30 +0100 | [diff] [blame] | 2314 | break; |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2315 | case AUTO_PIN_HP_OUT: |
Takashi Iwai | 6843ca1 | 2011-06-24 11:03:58 +0200 | [diff] [blame] | 2316 | /* for multi-io case, only the primary out */ |
| 2317 | if (ch && spec->multi_ios) |
| 2318 | break; |
| 2319 | *index = ch; |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2320 | return "Headphone"; |
| 2321 | default: |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 2322 | if (cfg->line_outs == 1 && !spec->multi_ios) |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2323 | return "PCM"; |
| 2324 | break; |
| 2325 | } |
David Henningsson | 71aa5eb | 2012-10-17 12:43:44 +0200 | [diff] [blame] | 2326 | if (ch >= ARRAY_SIZE(channel_name)) { |
| 2327 | snd_BUG(); |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2328 | return "PCM"; |
David Henningsson | 71aa5eb | 2012-10-17 12:43:44 +0200 | [diff] [blame] | 2329 | } |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2330 | |
| 2331 | return channel_name[ch]; |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2332 | } |
| 2333 | |
Takashi Iwai | 83012a7 | 2012-08-24 18:38:08 +0200 | [diff] [blame] | 2334 | #ifdef CONFIG_PM |
Takashi Iwai | 164f73e | 2012-02-21 11:27:09 +0100 | [diff] [blame] | 2335 | /* add the powersave loopback-list entry */ |
| 2336 | static void add_loopback_list(struct alc_spec *spec, hda_nid_t mix, int idx) |
| 2337 | { |
| 2338 | struct hda_amp_list *list; |
| 2339 | |
| 2340 | if (spec->num_loopbacks >= ARRAY_SIZE(spec->loopback_list) - 1) |
| 2341 | return; |
| 2342 | list = spec->loopback_list + spec->num_loopbacks; |
| 2343 | list->nid = mix; |
| 2344 | list->dir = HDA_INPUT; |
| 2345 | list->idx = idx; |
| 2346 | spec->num_loopbacks++; |
| 2347 | spec->loopback.amplist = spec->loopback_list; |
| 2348 | } |
| 2349 | #else |
| 2350 | #define add_loopback_list(spec, mix, idx) /* NOP */ |
| 2351 | #endif |
| 2352 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2353 | /* create input playback/capture controls for the given pin */ |
Takashi Iwai | c2fd19c | 2012-12-12 18:02:41 +0100 | [diff] [blame] | 2354 | static int new_analog_input(struct hda_codec *codec, hda_nid_t pin, |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2355 | const char *ctlname, int ctlidx, |
Takashi Iwai | c2fd19c | 2012-12-12 18:02:41 +0100 | [diff] [blame] | 2356 | hda_nid_t mix_nid) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2357 | { |
Takashi Iwai | c2fd19c | 2012-12-12 18:02:41 +0100 | [diff] [blame] | 2358 | struct alc_spec *spec = codec->spec; |
| 2359 | struct nid_path *path; |
Takashi Iwai | 829f69e | 2012-12-14 18:26:02 +0100 | [diff] [blame] | 2360 | unsigned int val; |
Takashi Iwai | c2fd19c | 2012-12-12 18:02:41 +0100 | [diff] [blame] | 2361 | int err, idx; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2362 | |
Takashi Iwai | bd32f78 | 2012-12-12 18:08:52 +0100 | [diff] [blame] | 2363 | if (!nid_has_volume(codec, mix_nid, HDA_INPUT) && |
| 2364 | !nid_has_mute(codec, mix_nid, HDA_INPUT)) |
| 2365 | return 0; /* no need for analog loopback */ |
| 2366 | |
Takashi Iwai | 965cceb | 2012-12-18 11:46:37 +0100 | [diff] [blame] | 2367 | path = add_new_nid_path(codec, pin, mix_nid, 2); |
Takashi Iwai | c2fd19c | 2012-12-12 18:02:41 +0100 | [diff] [blame] | 2368 | if (!path) |
Takashi Iwai | c2fd19c | 2012-12-12 18:02:41 +0100 | [diff] [blame] | 2369 | return -EINVAL; |
| 2370 | |
| 2371 | idx = path->idx[path->depth - 1]; |
Takashi Iwai | bd32f78 | 2012-12-12 18:08:52 +0100 | [diff] [blame] | 2372 | if (nid_has_volume(codec, mix_nid, HDA_INPUT)) { |
Takashi Iwai | 829f69e | 2012-12-14 18:26:02 +0100 | [diff] [blame] | 2373 | val = HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT); |
| 2374 | err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname, ctlidx, val); |
Takashi Iwai | bd32f78 | 2012-12-12 18:08:52 +0100 | [diff] [blame] | 2375 | if (err < 0) |
| 2376 | return err; |
Takashi Iwai | 829f69e | 2012-12-14 18:26:02 +0100 | [diff] [blame] | 2377 | path->ctls[NID_PATH_VOL_CTL] = val; |
Takashi Iwai | bd32f78 | 2012-12-12 18:08:52 +0100 | [diff] [blame] | 2378 | } |
| 2379 | |
| 2380 | if (nid_has_mute(codec, mix_nid, HDA_INPUT)) { |
Takashi Iwai | 829f69e | 2012-12-14 18:26:02 +0100 | [diff] [blame] | 2381 | val = HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT); |
| 2382 | err = __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname, ctlidx, val); |
Takashi Iwai | bd32f78 | 2012-12-12 18:08:52 +0100 | [diff] [blame] | 2383 | if (err < 0) |
| 2384 | return err; |
Takashi Iwai | 829f69e | 2012-12-14 18:26:02 +0100 | [diff] [blame] | 2385 | path->ctls[NID_PATH_MUTE_CTL] = val; |
Takashi Iwai | bd32f78 | 2012-12-12 18:08:52 +0100 | [diff] [blame] | 2386 | } |
| 2387 | |
Takashi Iwai | 829f69e | 2012-12-14 18:26:02 +0100 | [diff] [blame] | 2388 | path->active = true; |
Takashi Iwai | 164f73e | 2012-02-21 11:27:09 +0100 | [diff] [blame] | 2389 | add_loopback_list(spec, mix_nid, idx); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2390 | return 0; |
| 2391 | } |
| 2392 | |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2393 | 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] | 2394 | { |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2395 | unsigned int pincap = snd_hda_query_pin_caps(codec, nid); |
| 2396 | return (pincap & AC_PINCAP_IN) != 0; |
| 2397 | } |
| 2398 | |
Takashi Iwai | c2fd19c | 2012-12-12 18:02:41 +0100 | [diff] [blame] | 2399 | /* check whether the given two widgets can be connected */ |
| 2400 | static bool is_reachable_path(struct hda_codec *codec, |
| 2401 | hda_nid_t from_nid, hda_nid_t to_nid) |
| 2402 | { |
| 2403 | if (!from_nid || !to_nid) |
| 2404 | return false; |
| 2405 | return snd_hda_get_conn_index(codec, to_nid, from_nid, true) >= 0; |
| 2406 | } |
| 2407 | |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2408 | /* Parse the codec tree and retrieve ADCs */ |
| 2409 | static int alc_auto_fill_adc_nids(struct hda_codec *codec) |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2410 | { |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2411 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2412 | hda_nid_t nid; |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 2413 | hda_nid_t *adc_nids = spec->adc_nids; |
| 2414 | int max_nums = ARRAY_SIZE(spec->adc_nids); |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2415 | int i, nums = 0; |
| 2416 | |
| 2417 | nid = codec->start_nid; |
| 2418 | for (i = 0; i < codec->num_nodes; i++, nid++) { |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2419 | unsigned int caps = get_wcaps(codec, nid); |
| 2420 | int type = get_wcaps_type(caps); |
| 2421 | |
| 2422 | if (type != AC_WID_AUD_IN || (caps & AC_WCAP_DIGITAL)) |
| 2423 | continue; |
| 2424 | adc_nids[nums] = nid; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2425 | if (++nums >= max_nums) |
| 2426 | break; |
| 2427 | } |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2428 | spec->num_adc_nids = nums; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2429 | return nums; |
| 2430 | } |
| 2431 | |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2432 | /* filter out invalid adc_nids that don't give all active input pins; |
| 2433 | * if needed, check whether dynamic ADC-switching is available |
| 2434 | */ |
| 2435 | static int check_dyn_adc_switch(struct hda_codec *codec) |
| 2436 | { |
| 2437 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 2438 | struct hda_input_mux *imux = &spec->input_mux; |
| 2439 | hda_nid_t adc_nids[ARRAY_SIZE(spec->adc_nids)]; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2440 | int i, n, nums; |
| 2441 | hda_nid_t pin, adc; |
| 2442 | |
| 2443 | again: |
| 2444 | nums = 0; |
| 2445 | for (n = 0; n < spec->num_adc_nids; n++) { |
| 2446 | adc = spec->adc_nids[n]; |
| 2447 | for (i = 0; i < imux->num_items; i++) { |
| 2448 | pin = spec->imux_pins[i]; |
| 2449 | if (!is_reachable_path(codec, pin, adc)) |
| 2450 | break; |
| 2451 | } |
| 2452 | if (i >= imux->num_items) |
| 2453 | adc_nids[nums++] = adc; |
| 2454 | } |
| 2455 | |
| 2456 | if (!nums) { |
| 2457 | if (spec->shared_mic_hp) { |
| 2458 | spec->shared_mic_hp = 0; |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 2459 | imux->num_items = 1; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2460 | goto again; |
| 2461 | } |
| 2462 | |
| 2463 | /* check whether ADC-switch is possible */ |
| 2464 | for (i = 0; i < imux->num_items; i++) { |
| 2465 | pin = spec->imux_pins[i]; |
| 2466 | for (n = 0; n < spec->num_adc_nids; n++) { |
| 2467 | adc = spec->adc_nids[n]; |
| 2468 | if (is_reachable_path(codec, pin, adc)) { |
| 2469 | spec->dyn_adc_idx[i] = n; |
| 2470 | break; |
| 2471 | } |
| 2472 | } |
| 2473 | } |
| 2474 | |
| 2475 | snd_printdd("realtek: enabling ADC switching\n"); |
| 2476 | spec->dyn_adc_switch = 1; |
| 2477 | } else if (nums != spec->num_adc_nids) { |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 2478 | memcpy(spec->adc_nids, adc_nids, nums * sizeof(hda_nid_t)); |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2479 | spec->num_adc_nids = nums; |
| 2480 | } |
| 2481 | |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 2482 | if (imux->num_items == 1 || spec->shared_mic_hp) { |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2483 | snd_printdd("realtek: reducing to a single ADC\n"); |
| 2484 | spec->num_adc_nids = 1; /* reduce to a single ADC */ |
| 2485 | } |
| 2486 | |
Takashi Iwai | 9bf387b | 2012-12-18 17:18:21 +0100 | [diff] [blame] | 2487 | /* single index for individual volumes ctls */ |
| 2488 | if (!spec->dyn_adc_switch && spec->multi_cap_vol) |
| 2489 | spec->num_adc_nids = 1; |
| 2490 | |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2491 | return 0; |
| 2492 | } |
| 2493 | |
| 2494 | /* templates for capture controls */ |
| 2495 | static const struct snd_kcontrol_new cap_src_temp = { |
| 2496 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 2497 | .name = "Input Source", |
| 2498 | .info = alc_mux_enum_info, |
| 2499 | .get = alc_mux_enum_get, |
| 2500 | .put = alc_mux_enum_put, |
| 2501 | }; |
| 2502 | |
| 2503 | static const struct snd_kcontrol_new cap_vol_temp = { |
| 2504 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 2505 | .name = "Capture Volume", |
| 2506 | .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | |
| 2507 | SNDRV_CTL_ELEM_ACCESS_TLV_READ | |
| 2508 | SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), |
| 2509 | .info = alc_cap_vol_info, |
| 2510 | .get = alc_cap_vol_get, |
| 2511 | .put = alc_cap_vol_put, |
| 2512 | .tlv = { .c = alc_cap_vol_tlv }, |
| 2513 | }; |
| 2514 | |
| 2515 | static const struct snd_kcontrol_new cap_sw_temp = { |
| 2516 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 2517 | .name = "Capture Switch", |
| 2518 | .info = alc_cap_sw_info, |
| 2519 | .get = alc_cap_sw_get, |
| 2520 | .put = alc_cap_sw_put, |
| 2521 | }; |
| 2522 | |
| 2523 | static int parse_capvol_in_path(struct hda_codec *codec, struct nid_path *path) |
| 2524 | { |
| 2525 | hda_nid_t nid; |
| 2526 | int i, depth; |
| 2527 | |
| 2528 | path->ctls[NID_PATH_VOL_CTL] = path->ctls[NID_PATH_MUTE_CTL] = 0; |
| 2529 | for (depth = 0; depth < 3; depth++) { |
| 2530 | if (depth >= path->depth) |
| 2531 | return -EINVAL; |
| 2532 | i = path->depth - depth - 1; |
| 2533 | nid = path->path[i]; |
| 2534 | if (!path->ctls[NID_PATH_VOL_CTL]) { |
| 2535 | if (nid_has_volume(codec, nid, HDA_OUTPUT)) |
| 2536 | path->ctls[NID_PATH_VOL_CTL] = |
| 2537 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); |
| 2538 | else if (nid_has_volume(codec, nid, HDA_INPUT)) { |
| 2539 | int idx = path->idx[i]; |
| 2540 | if (!depth && codec->single_adc_amp) |
| 2541 | idx = 0; |
| 2542 | path->ctls[NID_PATH_VOL_CTL] = |
| 2543 | HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_INPUT); |
| 2544 | } |
| 2545 | } |
| 2546 | if (!path->ctls[NID_PATH_MUTE_CTL]) { |
| 2547 | if (nid_has_mute(codec, nid, HDA_OUTPUT)) |
| 2548 | path->ctls[NID_PATH_MUTE_CTL] = |
| 2549 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); |
| 2550 | else if (nid_has_mute(codec, nid, HDA_INPUT)) { |
| 2551 | int idx = path->idx[i]; |
| 2552 | if (!depth && codec->single_adc_amp) |
| 2553 | idx = 0; |
| 2554 | path->ctls[NID_PATH_MUTE_CTL] = |
| 2555 | HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_INPUT); |
| 2556 | } |
| 2557 | } |
| 2558 | } |
| 2559 | return 0; |
| 2560 | } |
| 2561 | |
Takashi Iwai | 81fede8 | 2012-12-18 17:24:25 +0100 | [diff] [blame] | 2562 | static unsigned int amp_val_replace_channels(unsigned int val, unsigned int chs); |
| 2563 | |
Takashi Iwai | 9bf387b | 2012-12-18 17:18:21 +0100 | [diff] [blame] | 2564 | static int add_single_cap_ctl(struct hda_codec *codec, const char *label, |
Takashi Iwai | 7e35dd3 | 2012-12-19 11:39:00 +0100 | [diff] [blame] | 2565 | int idx, bool is_switch, unsigned int ctl, |
| 2566 | bool inv_dmic) |
Takashi Iwai | 9bf387b | 2012-12-18 17:18:21 +0100 | [diff] [blame] | 2567 | { |
| 2568 | struct alc_spec *spec = codec->spec; |
| 2569 | char tmpname[44]; |
| 2570 | int type = is_switch ? ALC_CTL_WIDGET_MUTE : ALC_CTL_WIDGET_VOL; |
| 2571 | const char *sfx = is_switch ? "Switch" : "Volume"; |
Takashi Iwai | 7e35dd3 | 2012-12-19 11:39:00 +0100 | [diff] [blame] | 2572 | unsigned int chs = inv_dmic ? 1 : 3; |
Takashi Iwai | 81fede8 | 2012-12-18 17:24:25 +0100 | [diff] [blame] | 2573 | int err; |
Takashi Iwai | 9bf387b | 2012-12-18 17:18:21 +0100 | [diff] [blame] | 2574 | |
| 2575 | if (!ctl) |
| 2576 | return 0; |
| 2577 | |
| 2578 | if (label) |
| 2579 | snprintf(tmpname, sizeof(tmpname), |
| 2580 | "%s Capture %s", label, sfx); |
| 2581 | else |
| 2582 | snprintf(tmpname, sizeof(tmpname), |
| 2583 | "Capture %s", sfx); |
Takashi Iwai | 81fede8 | 2012-12-18 17:24:25 +0100 | [diff] [blame] | 2584 | err = add_control(spec, type, tmpname, idx, |
| 2585 | amp_val_replace_channels(ctl, chs)); |
| 2586 | if (err < 0 || chs == 3) |
| 2587 | return err; |
| 2588 | |
| 2589 | /* Make independent right kcontrol */ |
| 2590 | if (label) |
| 2591 | snprintf(tmpname, sizeof(tmpname), |
| 2592 | "Inverted %s Capture %s", label, sfx); |
| 2593 | else |
| 2594 | snprintf(tmpname, sizeof(tmpname), |
| 2595 | "Inverted Capture %s", sfx); |
| 2596 | return add_control(spec, type, tmpname, idx, |
| 2597 | amp_val_replace_channels(ctl, 2)); |
Takashi Iwai | 9bf387b | 2012-12-18 17:18:21 +0100 | [diff] [blame] | 2598 | } |
| 2599 | |
Takashi Iwai | 7e35dd3 | 2012-12-19 11:39:00 +0100 | [diff] [blame] | 2600 | static bool is_inv_dmic_pin(struct hda_codec *codec, hda_nid_t nid) |
| 2601 | { |
| 2602 | struct alc_spec *spec = codec->spec; |
| 2603 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2604 | unsigned int val; |
| 2605 | int i; |
| 2606 | |
| 2607 | if (!spec->inv_dmic_split) |
| 2608 | return false; |
| 2609 | for (i = 0; i < cfg->num_inputs; i++) { |
| 2610 | if (cfg->inputs[i].pin != nid) |
| 2611 | continue; |
| 2612 | if (cfg->inputs[i].type != AUTO_PIN_MIC) |
| 2613 | return false; |
| 2614 | val = snd_hda_codec_get_pincfg(codec, nid); |
| 2615 | return snd_hda_get_input_pin_attr(val) == INPUT_PIN_ATTR_INT; |
| 2616 | } |
| 2617 | return false; |
| 2618 | } |
| 2619 | |
Takashi Iwai | 9bf387b | 2012-12-18 17:18:21 +0100 | [diff] [blame] | 2620 | /* create single (and simple) capture volume and switch controls */ |
| 2621 | static int create_single_cap_vol_ctl(struct hda_codec *codec, int idx, |
Takashi Iwai | 7e35dd3 | 2012-12-19 11:39:00 +0100 | [diff] [blame] | 2622 | unsigned int vol_ctl, unsigned int sw_ctl, |
| 2623 | bool inv_dmic) |
Takashi Iwai | 9bf387b | 2012-12-18 17:18:21 +0100 | [diff] [blame] | 2624 | { |
| 2625 | int err; |
Takashi Iwai | 7e35dd3 | 2012-12-19 11:39:00 +0100 | [diff] [blame] | 2626 | err = add_single_cap_ctl(codec, NULL, idx, false, vol_ctl, inv_dmic); |
Takashi Iwai | 9bf387b | 2012-12-18 17:18:21 +0100 | [diff] [blame] | 2627 | if (err < 0) |
| 2628 | return err; |
Takashi Iwai | 7e35dd3 | 2012-12-19 11:39:00 +0100 | [diff] [blame] | 2629 | err = add_single_cap_ctl(codec, NULL, idx, true, sw_ctl, inv_dmic); |
Takashi Iwai | 9bf387b | 2012-12-18 17:18:21 +0100 | [diff] [blame] | 2630 | if (err < 0) |
| 2631 | return err; |
| 2632 | return 0; |
| 2633 | } |
| 2634 | |
| 2635 | /* create bound capture volume and switch controls */ |
| 2636 | static int create_bind_cap_vol_ctl(struct hda_codec *codec, int idx, |
| 2637 | unsigned int vol_ctl, unsigned int sw_ctl) |
| 2638 | { |
| 2639 | struct alc_spec *spec = codec->spec; |
| 2640 | struct snd_kcontrol_new *knew; |
| 2641 | |
| 2642 | if (vol_ctl) { |
| 2643 | knew = alc_kcontrol_new(spec, NULL, &cap_vol_temp); |
| 2644 | if (!knew) |
| 2645 | return -ENOMEM; |
| 2646 | knew->index = idx; |
| 2647 | knew->private_value = vol_ctl; |
| 2648 | knew->subdevice = HDA_SUBDEV_AMP_FLAG; |
| 2649 | } |
| 2650 | if (sw_ctl) { |
| 2651 | knew = alc_kcontrol_new(spec, NULL, &cap_sw_temp); |
| 2652 | if (!knew) |
| 2653 | return -ENOMEM; |
| 2654 | knew->index = idx; |
| 2655 | knew->private_value = sw_ctl; |
| 2656 | knew->subdevice = HDA_SUBDEV_AMP_FLAG; |
| 2657 | } |
| 2658 | return 0; |
| 2659 | } |
| 2660 | |
| 2661 | /* return the vol ctl when used first in the imux list */ |
| 2662 | static unsigned int get_first_cap_ctl(struct hda_codec *codec, int idx, int type) |
| 2663 | { |
| 2664 | struct alc_spec *spec = codec->spec; |
| 2665 | struct nid_path *path; |
| 2666 | unsigned int ctl; |
| 2667 | int i; |
| 2668 | |
| 2669 | path = get_nid_path(codec, spec->imux_pins[idx], |
| 2670 | get_adc_nid(codec, 0, idx)); |
| 2671 | if (!path) |
| 2672 | return 0; |
| 2673 | ctl = path->ctls[type]; |
| 2674 | if (!ctl) |
| 2675 | return 0; |
| 2676 | for (i = 0; i < idx - 1; i++) { |
| 2677 | path = get_nid_path(codec, spec->imux_pins[i], |
| 2678 | get_adc_nid(codec, 0, i)); |
| 2679 | if (path && path->ctls[type] == ctl) |
| 2680 | return 0; |
| 2681 | } |
| 2682 | return ctl; |
| 2683 | } |
| 2684 | |
| 2685 | /* create individual capture volume and switch controls per input */ |
| 2686 | static int create_multi_cap_vol_ctl(struct hda_codec *codec) |
| 2687 | { |
| 2688 | struct alc_spec *spec = codec->spec; |
| 2689 | struct hda_input_mux *imux = &spec->input_mux; |
| 2690 | int i, err, type, type_idx = 0; |
| 2691 | const char *prev_label = NULL; |
| 2692 | |
| 2693 | for (i = 0; i < imux->num_items; i++) { |
| 2694 | const char *label; |
Takashi Iwai | 7e35dd3 | 2012-12-19 11:39:00 +0100 | [diff] [blame] | 2695 | bool inv_dmic; |
Takashi Iwai | 9bf387b | 2012-12-18 17:18:21 +0100 | [diff] [blame] | 2696 | label = hda_get_autocfg_input_label(codec, &spec->autocfg, i); |
| 2697 | if (prev_label && !strcmp(label, prev_label)) |
| 2698 | type_idx++; |
| 2699 | else |
| 2700 | type_idx = 0; |
| 2701 | prev_label = label; |
Takashi Iwai | 7e35dd3 | 2012-12-19 11:39:00 +0100 | [diff] [blame] | 2702 | inv_dmic = is_inv_dmic_pin(codec, spec->imux_pins[i]); |
Takashi Iwai | 9bf387b | 2012-12-18 17:18:21 +0100 | [diff] [blame] | 2703 | |
| 2704 | for (type = 0; type < 2; type++) { |
| 2705 | err = add_single_cap_ctl(codec, label, type_idx, type, |
Takashi Iwai | 7e35dd3 | 2012-12-19 11:39:00 +0100 | [diff] [blame] | 2706 | get_first_cap_ctl(codec, i, type), |
| 2707 | inv_dmic); |
Takashi Iwai | 9bf387b | 2012-12-18 17:18:21 +0100 | [diff] [blame] | 2708 | if (err < 0) |
| 2709 | return err; |
| 2710 | } |
| 2711 | } |
| 2712 | return 0; |
| 2713 | } |
| 2714 | |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2715 | static int create_capture_mixers(struct hda_codec *codec) |
| 2716 | { |
| 2717 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 2718 | struct hda_input_mux *imux = &spec->input_mux; |
Takashi Iwai | 9bf387b | 2012-12-18 17:18:21 +0100 | [diff] [blame] | 2719 | int i, n, nums, err; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2720 | |
| 2721 | if (spec->dyn_adc_switch) |
| 2722 | nums = 1; |
| 2723 | else |
| 2724 | nums = spec->num_adc_nids; |
| 2725 | |
| 2726 | if (!spec->auto_mic && imux->num_items > 1) { |
Takashi Iwai | 9bf387b | 2012-12-18 17:18:21 +0100 | [diff] [blame] | 2727 | struct snd_kcontrol_new *knew; |
Takashi Iwai | bc54976 | 2012-12-18 15:35:11 +0100 | [diff] [blame] | 2728 | knew = alc_kcontrol_new(spec, NULL, &cap_src_temp); |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2729 | if (!knew) |
| 2730 | return -ENOMEM; |
| 2731 | knew->count = nums; |
| 2732 | } |
| 2733 | |
| 2734 | for (n = 0; n < nums; n++) { |
Takashi Iwai | 9bf387b | 2012-12-18 17:18:21 +0100 | [diff] [blame] | 2735 | bool multi = false; |
Takashi Iwai | 7e35dd3 | 2012-12-19 11:39:00 +0100 | [diff] [blame] | 2736 | bool inv_dmic = false; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2737 | int vol, sw; |
| 2738 | |
| 2739 | vol = sw = 0; |
| 2740 | for (i = 0; i < imux->num_items; i++) { |
| 2741 | struct nid_path *path; |
| 2742 | path = get_nid_path(codec, spec->imux_pins[i], |
| 2743 | get_adc_nid(codec, n, i)); |
| 2744 | if (!path) |
| 2745 | continue; |
| 2746 | parse_capvol_in_path(codec, path); |
| 2747 | if (!vol) |
| 2748 | vol = path->ctls[NID_PATH_VOL_CTL]; |
Takashi Iwai | 9bf387b | 2012-12-18 17:18:21 +0100 | [diff] [blame] | 2749 | else if (vol != path->ctls[NID_PATH_VOL_CTL]) |
| 2750 | multi = true; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2751 | if (!sw) |
| 2752 | sw = path->ctls[NID_PATH_MUTE_CTL]; |
Takashi Iwai | 9bf387b | 2012-12-18 17:18:21 +0100 | [diff] [blame] | 2753 | else if (sw != path->ctls[NID_PATH_MUTE_CTL]) |
| 2754 | multi = true; |
Takashi Iwai | 7e35dd3 | 2012-12-19 11:39:00 +0100 | [diff] [blame] | 2755 | if (is_inv_dmic_pin(codec, spec->imux_pins[i])) |
| 2756 | inv_dmic = true; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2757 | } |
| 2758 | |
Takashi Iwai | 9bf387b | 2012-12-18 17:18:21 +0100 | [diff] [blame] | 2759 | if (!multi) |
Takashi Iwai | 7e35dd3 | 2012-12-19 11:39:00 +0100 | [diff] [blame] | 2760 | err = create_single_cap_vol_ctl(codec, n, vol, sw, |
| 2761 | inv_dmic); |
Takashi Iwai | 9bf387b | 2012-12-18 17:18:21 +0100 | [diff] [blame] | 2762 | else if (!spec->multi_cap_vol) |
| 2763 | err = create_bind_cap_vol_ctl(codec, n, vol, sw); |
| 2764 | else |
| 2765 | err = create_multi_cap_vol_ctl(codec); |
| 2766 | if (err < 0) |
| 2767 | return err; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2768 | } |
| 2769 | |
| 2770 | return 0; |
| 2771 | } |
| 2772 | |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2773 | /* create playback/capture controls for input pins */ |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2774 | static int alc_auto_create_input_ctls(struct hda_codec *codec) |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2775 | { |
| 2776 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2777 | const struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2778 | hda_nid_t mixer = spec->mixer_nid; |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 2779 | struct hda_input_mux *imux = &spec->input_mux; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2780 | int num_adcs; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2781 | int i, c, err, type_idx = 0; |
David Henningsson | 5322bf2 | 2011-01-05 11:03:56 +0100 | [diff] [blame] | 2782 | const char *prev_label = NULL; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2783 | |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2784 | num_adcs = alc_auto_fill_adc_nids(codec); |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2785 | if (num_adcs < 0) |
| 2786 | return 0; |
| 2787 | |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2788 | for (i = 0; i < cfg->num_inputs; i++) { |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2789 | hda_nid_t pin; |
Takashi Iwai | 10a20af | 2010-09-09 16:28:02 +0200 | [diff] [blame] | 2790 | const char *label; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2791 | bool imux_added; |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2792 | |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2793 | pin = cfg->inputs[i].pin; |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2794 | if (!alc_is_input_pin(codec, pin)) |
| 2795 | continue; |
| 2796 | |
David Henningsson | 5322bf2 | 2011-01-05 11:03:56 +0100 | [diff] [blame] | 2797 | label = hda_get_autocfg_input_label(codec, cfg, i); |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 2798 | if (spec->shared_mic_hp && !strcmp(label, "Misc")) |
| 2799 | label = "Headphone Mic"; |
David Henningsson | 5322bf2 | 2011-01-05 11:03:56 +0100 | [diff] [blame] | 2800 | if (prev_label && !strcmp(label, prev_label)) |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2801 | type_idx++; |
| 2802 | else |
| 2803 | type_idx = 0; |
David Henningsson | 5322bf2 | 2011-01-05 11:03:56 +0100 | [diff] [blame] | 2804 | prev_label = label; |
| 2805 | |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2806 | if (mixer) { |
Takashi Iwai | c2fd19c | 2012-12-12 18:02:41 +0100 | [diff] [blame] | 2807 | if (is_reachable_path(codec, pin, mixer)) { |
| 2808 | err = new_analog_input(codec, pin, |
| 2809 | label, type_idx, mixer); |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2810 | if (err < 0) |
| 2811 | return err; |
| 2812 | } |
| 2813 | } |
| 2814 | |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2815 | imux_added = false; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2816 | for (c = 0; c < num_adcs; c++) { |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2817 | struct nid_path *path; |
| 2818 | hda_nid_t adc = spec->adc_nids[c]; |
| 2819 | |
| 2820 | if (!is_reachable_path(codec, pin, adc)) |
| 2821 | continue; |
| 2822 | path = snd_array_new(&spec->paths); |
| 2823 | if (!path) |
| 2824 | return -ENOMEM; |
| 2825 | memset(path, 0, sizeof(*path)); |
| 2826 | if (!parse_nid_path(codec, pin, adc, 2, path)) { |
| 2827 | snd_printd(KERN_ERR |
| 2828 | "invalid input path 0x%x -> 0x%x\n", |
| 2829 | pin, adc); |
| 2830 | spec->paths.used--; |
| 2831 | continue; |
| 2832 | } |
| 2833 | |
| 2834 | if (!imux_added) { |
| 2835 | spec->imux_pins[imux->num_items] = pin; |
| 2836 | snd_hda_add_imux_item(imux, label, |
| 2837 | imux->num_items, NULL); |
| 2838 | imux_added = true; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2839 | } |
| 2840 | } |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2841 | } |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2842 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2843 | return 0; |
| 2844 | } |
| 2845 | |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 2846 | /* create a shared input with the headphone out */ |
| 2847 | static int alc_auto_create_shared_input(struct hda_codec *codec) |
| 2848 | { |
| 2849 | struct alc_spec *spec = codec->spec; |
| 2850 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2851 | unsigned int defcfg; |
| 2852 | hda_nid_t nid; |
| 2853 | |
| 2854 | /* only one internal input pin? */ |
| 2855 | if (cfg->num_inputs != 1) |
| 2856 | return 0; |
| 2857 | defcfg = snd_hda_codec_get_pincfg(codec, cfg->inputs[0].pin); |
| 2858 | if (snd_hda_get_input_pin_attr(defcfg) != INPUT_PIN_ATTR_INT) |
| 2859 | return 0; |
| 2860 | |
| 2861 | if (cfg->hp_outs == 1 && cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) |
| 2862 | nid = cfg->hp_pins[0]; /* OK, we have a single HP-out */ |
| 2863 | else if (cfg->line_outs == 1 && cfg->line_out_type == AUTO_PIN_HP_OUT) |
| 2864 | nid = cfg->line_out_pins[0]; /* OK, we have a single line-out */ |
| 2865 | else |
| 2866 | return 0; /* both not available */ |
| 2867 | |
| 2868 | if (!(snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_IN)) |
| 2869 | return 0; /* no input */ |
| 2870 | |
| 2871 | cfg->inputs[1].pin = nid; |
| 2872 | cfg->inputs[1].type = AUTO_PIN_MIC; |
| 2873 | cfg->num_inputs = 2; |
| 2874 | spec->shared_mic_hp = 1; |
| 2875 | snd_printdd("realtek: Enable shared I/O jack on NID 0x%x\n", nid); |
| 2876 | return 0; |
| 2877 | } |
| 2878 | |
Takashi Iwai | baba8ee | 2007-04-23 17:17:48 +0200 | [diff] [blame] | 2879 | static int get_pin_type(int line_out_type) |
| 2880 | { |
| 2881 | if (line_out_type == AUTO_PIN_HP_OUT) |
| 2882 | return PIN_HP; |
| 2883 | else |
| 2884 | return PIN_OUT; |
| 2885 | } |
| 2886 | |
Takashi Iwai | 0a7f532 | 2011-07-06 15:15:12 +0200 | [diff] [blame] | 2887 | static void alc_auto_init_analog_input(struct hda_codec *codec) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2888 | { |
| 2889 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2890 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2891 | int i; |
| 2892 | |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2893 | for (i = 0; i < cfg->num_inputs; i++) { |
| 2894 | hda_nid_t nid = cfg->inputs[i].pin; |
Takashi Iwai | 6234399 | 2012-12-18 09:06:01 +0100 | [diff] [blame] | 2895 | if (alc_is_input_pin(codec, nid)) |
Takashi Iwai | 30ea098 | 2010-09-16 18:47:56 +0200 | [diff] [blame] | 2896 | alc_set_input_pin(codec, nid, cfg->inputs[i].type); |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 2897 | |
Takashi Iwai | 829f69e | 2012-12-14 18:26:02 +0100 | [diff] [blame] | 2898 | /* mute loopback inputs */ |
| 2899 | if (spec->mixer_nid) { |
| 2900 | struct nid_path *path; |
| 2901 | path = get_nid_path(codec, nid, spec->mixer_nid); |
| 2902 | if (path) |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2903 | activate_path(codec, path, path->active, false); |
Takashi Iwai | 829f69e | 2012-12-14 18:26:02 +0100 | [diff] [blame] | 2904 | } |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 2905 | } |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2906 | } |
| 2907 | |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 2908 | static bool alc_is_dac_already_used(struct hda_codec *codec, hda_nid_t nid) |
| 2909 | { |
| 2910 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 2911 | int i; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2912 | |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 2913 | for (i = 0; i < spec->paths.used; i++) { |
| 2914 | struct nid_path *path = snd_array_elem(&spec->paths, i); |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2915 | if (path->path[0] == nid) |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 2916 | return true; |
| 2917 | } |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 2918 | return false; |
| 2919 | } |
| 2920 | |
Takashi Iwai | 463419d | 2012-12-05 14:17:37 +0100 | [diff] [blame] | 2921 | /* look for an empty DAC slot */ |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 2922 | static hda_nid_t alc_auto_look_for_dac(struct hda_codec *codec, hda_nid_t pin, |
| 2923 | bool is_digital) |
Takashi Iwai | 463419d | 2012-12-05 14:17:37 +0100 | [diff] [blame] | 2924 | { |
| 2925 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 2926 | bool cap_digital; |
Takashi Iwai | 463419d | 2012-12-05 14:17:37 +0100 | [diff] [blame] | 2927 | int i; |
| 2928 | |
| 2929 | for (i = 0; i < spec->num_all_dacs; i++) { |
| 2930 | hda_nid_t nid = spec->all_dacs[i]; |
| 2931 | if (!nid || alc_is_dac_already_used(codec, nid)) |
| 2932 | continue; |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 2933 | cap_digital = !!(get_wcaps(codec, nid) & AC_WCAP_DIGITAL); |
| 2934 | if (is_digital != cap_digital) |
| 2935 | continue; |
Takashi Iwai | 9c64076 | 2012-12-14 16:15:56 +0100 | [diff] [blame] | 2936 | if (is_reachable_path(codec, nid, pin)) |
Takashi Iwai | 463419d | 2012-12-05 14:17:37 +0100 | [diff] [blame] | 2937 | return nid; |
| 2938 | } |
| 2939 | return 0; |
| 2940 | } |
| 2941 | |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2942 | /* called recursively */ |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2943 | static bool __parse_nid_path(struct hda_codec *codec, |
| 2944 | hda_nid_t from_nid, hda_nid_t to_nid, |
| 2945 | int with_aa_mix, struct nid_path *path, int depth) |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2946 | { |
| 2947 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2948 | hda_nid_t conn[16]; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2949 | int i, nums; |
| 2950 | |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2951 | if (to_nid == spec->mixer_nid) { |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2952 | if (!with_aa_mix) |
| 2953 | return false; |
| 2954 | with_aa_mix = 2; /* mark aa-mix is included */ |
| 2955 | } |
| 2956 | |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2957 | nums = snd_hda_get_connections(codec, to_nid, conn, ARRAY_SIZE(conn)); |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2958 | for (i = 0; i < nums; i++) { |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2959 | if (conn[i] != from_nid) { |
| 2960 | /* special case: when from_nid is 0, |
| 2961 | * try to find an empty DAC |
| 2962 | */ |
| 2963 | if (from_nid || |
| 2964 | get_wcaps_type(get_wcaps(codec, conn[i])) != AC_WID_AUD_OUT || |
| 2965 | alc_is_dac_already_used(codec, conn[i])) |
| 2966 | continue; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2967 | } |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2968 | /* aa-mix is requested but not included? */ |
| 2969 | if (!(spec->mixer_nid && with_aa_mix == 1)) |
| 2970 | goto found; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2971 | } |
| 2972 | if (depth >= MAX_NID_PATH_DEPTH) |
| 2973 | return false; |
| 2974 | for (i = 0; i < nums; i++) { |
| 2975 | unsigned int type; |
| 2976 | type = get_wcaps_type(get_wcaps(codec, conn[i])); |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2977 | if (type == AC_WID_AUD_OUT || type == AC_WID_AUD_IN || |
| 2978 | type == AC_WID_PIN) |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2979 | continue; |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2980 | if (__parse_nid_path(codec, from_nid, conn[i], |
| 2981 | with_aa_mix, path, depth + 1)) |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2982 | goto found; |
| 2983 | } |
| 2984 | return false; |
| 2985 | |
| 2986 | found: |
| 2987 | path->path[path->depth] = conn[i]; |
Takashi Iwai | 95e960c | 2012-12-10 17:27:57 +0100 | [diff] [blame] | 2988 | path->idx[path->depth + 1] = i; |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2989 | if (nums > 1 && get_wcaps_type(get_wcaps(codec, to_nid)) != AC_WID_AUD_MIX) |
Takashi Iwai | 95e960c | 2012-12-10 17:27:57 +0100 | [diff] [blame] | 2990 | path->multi[path->depth + 1] = 1; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2991 | path->depth++; |
| 2992 | return true; |
| 2993 | } |
| 2994 | |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2995 | /* parse the widget path from the given nid to the target nid; |
| 2996 | * when @from_nid is 0, try to find an empty DAC; |
| 2997 | * when @with_aa_mix is 0, paths with spec->mixer_nid are excluded. |
| 2998 | * when @with_aa_mix is 1, paths without spec->mixer_nid are excluded. |
| 2999 | * when @with_aa_mix is 2, no special handling about spec->mixer_nid. |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 3000 | */ |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 3001 | static bool parse_nid_path(struct hda_codec *codec, hda_nid_t from_nid, |
| 3002 | hda_nid_t to_nid, int with_aa_mix, |
| 3003 | struct nid_path *path) |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 3004 | { |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 3005 | if (__parse_nid_path(codec, from_nid, to_nid, with_aa_mix, path, 1)) { |
| 3006 | path->path[path->depth] = to_nid; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 3007 | path->depth++; |
| 3008 | #if 0 |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 3009 | snd_printdd("path: depth=%d, %02x/%02x/%02x/%02x/%02x\n", |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 3010 | path->depth, path->path[0], path->path[1], |
| 3011 | path->path[2], path->path[3], path->path[4]); |
| 3012 | #endif |
| 3013 | return true; |
| 3014 | } |
| 3015 | return false; |
| 3016 | } |
| 3017 | |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3018 | static hda_nid_t get_dac_if_single(struct hda_codec *codec, hda_nid_t pin) |
| 3019 | { |
Takashi Iwai | 140547e | 2012-02-16 17:23:46 +0100 | [diff] [blame] | 3020 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 463419d | 2012-12-05 14:17:37 +0100 | [diff] [blame] | 3021 | int i; |
| 3022 | hda_nid_t nid_found = 0; |
| 3023 | |
| 3024 | for (i = 0; i < spec->num_all_dacs; i++) { |
| 3025 | hda_nid_t nid = spec->all_dacs[i]; |
| 3026 | if (!nid || alc_is_dac_already_used(codec, nid)) |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3027 | continue; |
Takashi Iwai | 9c64076 | 2012-12-14 16:15:56 +0100 | [diff] [blame] | 3028 | if (is_reachable_path(codec, nid, pin)) { |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3029 | if (nid_found) |
| 3030 | return 0; |
| 3031 | nid_found = nid; |
| 3032 | } |
| 3033 | } |
| 3034 | return nid_found; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3035 | } |
| 3036 | |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3037 | static bool is_ctl_used(struct hda_codec *codec, unsigned int val, int type) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3038 | { |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3039 | struct alc_spec *spec = codec->spec; |
| 3040 | int i; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3041 | |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 3042 | for (i = 0; i < spec->paths.used; i++) { |
| 3043 | struct nid_path *path = snd_array_elem(&spec->paths, i); |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3044 | if (path->ctls[type] == val) |
| 3045 | return true; |
| 3046 | } |
| 3047 | return false; |
| 3048 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3049 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3050 | /* badness definition */ |
| 3051 | enum { |
| 3052 | /* No primary DAC is found for the main output */ |
| 3053 | BAD_NO_PRIMARY_DAC = 0x10000, |
| 3054 | /* No DAC is found for the extra output */ |
| 3055 | BAD_NO_DAC = 0x4000, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3056 | /* No possible multi-ios */ |
| 3057 | BAD_MULTI_IO = 0x103, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3058 | /* No individual DAC for extra output */ |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3059 | BAD_NO_EXTRA_DAC = 0x102, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3060 | /* No individual DAC for extra surrounds */ |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3061 | BAD_NO_EXTRA_SURR_DAC = 0x101, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3062 | /* Primary DAC shared with main surrounds */ |
| 3063 | BAD_SHARED_SURROUND = 0x100, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3064 | /* Primary DAC shared with main CLFE */ |
| 3065 | BAD_SHARED_CLFE = 0x10, |
| 3066 | /* Primary DAC shared with extra surrounds */ |
| 3067 | BAD_SHARED_EXTRA_SURROUND = 0x10, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3068 | /* Volume widget is shared */ |
| 3069 | BAD_SHARED_VOL = 0x10, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3070 | }; |
| 3071 | |
| 3072 | static hda_nid_t alc_look_for_out_mute_nid(struct hda_codec *codec, |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3073 | struct nid_path *path); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3074 | static hda_nid_t alc_look_for_out_vol_nid(struct hda_codec *codec, |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3075 | struct nid_path *path); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3076 | |
Takashi Iwai | 965cceb | 2012-12-18 11:46:37 +0100 | [diff] [blame] | 3077 | static struct nid_path *add_new_nid_path(struct hda_codec *codec, |
| 3078 | hda_nid_t from_nid, hda_nid_t to_nid, |
| 3079 | int with_aa_mix) |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 3080 | { |
| 3081 | struct alc_spec *spec = codec->spec; |
| 3082 | struct nid_path *path; |
| 3083 | |
Takashi Iwai | 965cceb | 2012-12-18 11:46:37 +0100 | [diff] [blame] | 3084 | if (from_nid && to_nid && !is_reachable_path(codec, from_nid, to_nid)) |
| 3085 | return NULL; |
| 3086 | |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 3087 | path = snd_array_new(&spec->paths); |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 3088 | if (!path) |
Takashi Iwai | 965cceb | 2012-12-18 11:46:37 +0100 | [diff] [blame] | 3089 | return NULL; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 3090 | memset(path, 0, sizeof(*path)); |
Takashi Iwai | 965cceb | 2012-12-18 11:46:37 +0100 | [diff] [blame] | 3091 | if (parse_nid_path(codec, from_nid, to_nid, with_aa_mix, path)) |
| 3092 | return path; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 3093 | /* push back */ |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 3094 | spec->paths.used--; |
Takashi Iwai | 965cceb | 2012-12-18 11:46:37 +0100 | [diff] [blame] | 3095 | return NULL; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 3096 | } |
| 3097 | |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame] | 3098 | /* get the path between the given NIDs; |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3099 | * passing 0 to either @pin or @dac behaves as a wildcard |
| 3100 | */ |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame] | 3101 | static struct nid_path * |
| 3102 | get_nid_path(struct hda_codec *codec, hda_nid_t from_nid, hda_nid_t to_nid) |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3103 | { |
| 3104 | struct alc_spec *spec = codec->spec; |
| 3105 | int i; |
| 3106 | |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 3107 | for (i = 0; i < spec->paths.used; i++) { |
| 3108 | struct nid_path *path = snd_array_elem(&spec->paths, i); |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3109 | if (path->depth <= 0) |
| 3110 | continue; |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame] | 3111 | if ((!from_nid || path->path[0] == from_nid) && |
| 3112 | (!to_nid || path->path[path->depth - 1] == to_nid)) |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3113 | return path; |
| 3114 | } |
| 3115 | return NULL; |
| 3116 | } |
| 3117 | |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3118 | /* look for widgets in the path between the given NIDs appropriate for |
| 3119 | * volume and mute controls, and assign the values to ctls[]. |
| 3120 | * |
| 3121 | * When no appropriate widget is found in the path, the badness value |
| 3122 | * is incremented depending on the situation. The function returns the |
| 3123 | * total badness for both volume and mute controls. |
| 3124 | */ |
| 3125 | static int assign_out_path_ctls(struct hda_codec *codec, hda_nid_t pin, |
| 3126 | hda_nid_t dac) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3127 | { |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame] | 3128 | struct nid_path *path = get_nid_path(codec, dac, pin); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3129 | hda_nid_t nid; |
| 3130 | unsigned int val; |
| 3131 | int badness = 0; |
| 3132 | |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3133 | if (!path) |
| 3134 | return BAD_SHARED_VOL * 2; |
| 3135 | nid = alc_look_for_out_vol_nid(codec, path); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3136 | if (nid) { |
| 3137 | val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3138 | if (is_ctl_used(codec, val, NID_PATH_VOL_CTL)) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3139 | badness += BAD_SHARED_VOL; |
| 3140 | else |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3141 | path->ctls[NID_PATH_VOL_CTL] = val; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3142 | } else |
| 3143 | badness += BAD_SHARED_VOL; |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3144 | nid = alc_look_for_out_mute_nid(codec, path); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3145 | if (nid) { |
| 3146 | unsigned int wid_type = get_wcaps_type(get_wcaps(codec, nid)); |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3147 | if (wid_type == AC_WID_PIN || wid_type == AC_WID_AUD_OUT || |
| 3148 | nid_has_mute(codec, nid, HDA_OUTPUT)) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3149 | val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); |
| 3150 | else |
| 3151 | val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT); |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3152 | if (is_ctl_used(codec, val, NID_PATH_MUTE_CTL)) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3153 | badness += BAD_SHARED_VOL; |
| 3154 | else |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3155 | path->ctls[NID_PATH_MUTE_CTL] = val; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3156 | } else |
| 3157 | badness += BAD_SHARED_VOL; |
| 3158 | return badness; |
| 3159 | } |
| 3160 | |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3161 | struct badness_table { |
| 3162 | int no_primary_dac; /* no primary DAC */ |
| 3163 | int no_dac; /* no secondary DACs */ |
| 3164 | int shared_primary; /* primary DAC is shared with main output */ |
| 3165 | int shared_surr; /* secondary DAC shared with main or primary */ |
| 3166 | int shared_clfe; /* third DAC shared with main or primary */ |
| 3167 | int shared_surr_main; /* secondary DAC sahred with main/DAC0 */ |
| 3168 | }; |
| 3169 | |
| 3170 | static struct badness_table main_out_badness = { |
| 3171 | .no_primary_dac = BAD_NO_PRIMARY_DAC, |
| 3172 | .no_dac = BAD_NO_DAC, |
| 3173 | .shared_primary = BAD_NO_PRIMARY_DAC, |
| 3174 | .shared_surr = BAD_SHARED_SURROUND, |
| 3175 | .shared_clfe = BAD_SHARED_CLFE, |
| 3176 | .shared_surr_main = BAD_SHARED_SURROUND, |
| 3177 | }; |
| 3178 | |
| 3179 | static struct badness_table extra_out_badness = { |
| 3180 | .no_primary_dac = BAD_NO_DAC, |
| 3181 | .no_dac = BAD_NO_DAC, |
| 3182 | .shared_primary = BAD_NO_EXTRA_DAC, |
| 3183 | .shared_surr = BAD_SHARED_EXTRA_SURROUND, |
| 3184 | .shared_clfe = BAD_SHARED_EXTRA_SURROUND, |
| 3185 | .shared_surr_main = BAD_NO_EXTRA_SURR_DAC, |
| 3186 | }; |
| 3187 | |
| 3188 | /* try to assign DACs to pins and return the resultant badness */ |
| 3189 | static int alc_auto_fill_dacs(struct hda_codec *codec, int num_outs, |
| 3190 | const hda_nid_t *pins, hda_nid_t *dacs, |
| 3191 | const struct badness_table *bad) |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3192 | { |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3193 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3194 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 3195 | int i, j; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3196 | int badness = 0; |
| 3197 | hda_nid_t dac; |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3198 | |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3199 | if (!num_outs) |
| 3200 | return 0; |
| 3201 | |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3202 | for (i = 0; i < num_outs; i++) { |
| 3203 | hda_nid_t pin = pins[i]; |
| 3204 | if (!dacs[i]) |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 3205 | dacs[i] = alc_auto_look_for_dac(codec, pin, false); |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3206 | if (!dacs[i] && !i) { |
| 3207 | for (j = 1; j < num_outs; j++) { |
Takashi Iwai | 9c64076 | 2012-12-14 16:15:56 +0100 | [diff] [blame] | 3208 | if (is_reachable_path(codec, dacs[j], pin)) { |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3209 | dacs[0] = dacs[j]; |
| 3210 | dacs[j] = 0; |
| 3211 | break; |
| 3212 | } |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3213 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3214 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3215 | dac = dacs[i]; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3216 | if (!dac) { |
Takashi Iwai | 9c64076 | 2012-12-14 16:15:56 +0100 | [diff] [blame] | 3217 | if (is_reachable_path(codec, dacs[0], pin)) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3218 | dac = dacs[0]; |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3219 | else if (cfg->line_outs > i && |
Takashi Iwai | 9c64076 | 2012-12-14 16:15:56 +0100 | [diff] [blame] | 3220 | is_reachable_path(codec, spec->private_dac_nids[i], pin)) |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3221 | dac = spec->private_dac_nids[i]; |
| 3222 | if (dac) { |
| 3223 | if (!i) |
| 3224 | badness += bad->shared_primary; |
| 3225 | else if (i == 1) |
| 3226 | badness += bad->shared_surr; |
| 3227 | else |
| 3228 | badness += bad->shared_clfe; |
Takashi Iwai | 9c64076 | 2012-12-14 16:15:56 +0100 | [diff] [blame] | 3229 | } else if (is_reachable_path(codec, spec->private_dac_nids[0], pin)) { |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3230 | dac = spec->private_dac_nids[0]; |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3231 | badness += bad->shared_surr_main; |
| 3232 | } else if (!i) |
| 3233 | badness += bad->no_primary_dac; |
| 3234 | else |
| 3235 | badness += bad->no_dac; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3236 | } |
Takashi Iwai | 965cceb | 2012-12-18 11:46:37 +0100 | [diff] [blame] | 3237 | if (!add_new_nid_path(codec, dac, pin, 0)) |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 3238 | dac = dacs[i] = 0; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3239 | if (dac) |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3240 | badness += assign_out_path_ctls(codec, pin, dac); |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3241 | } |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3242 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3243 | return badness; |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3244 | } |
| 3245 | |
| 3246 | static int alc_auto_fill_multi_ios(struct hda_codec *codec, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3247 | hda_nid_t reference_pin, |
| 3248 | bool hardwired, int offset); |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3249 | |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3250 | static bool alc_map_singles(struct hda_codec *codec, int outs, |
| 3251 | const hda_nid_t *pins, hda_nid_t *dacs) |
| 3252 | { |
| 3253 | int i; |
| 3254 | bool found = false; |
| 3255 | for (i = 0; i < outs; i++) { |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 3256 | hda_nid_t dac; |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3257 | if (dacs[i]) |
| 3258 | continue; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 3259 | dac = get_dac_if_single(codec, pins[i]); |
| 3260 | if (!dac) |
| 3261 | continue; |
Takashi Iwai | 965cceb | 2012-12-18 11:46:37 +0100 | [diff] [blame] | 3262 | if (add_new_nid_path(codec, dac, pins[i], 0)) { |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 3263 | dacs[i] = dac; |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3264 | found = true; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 3265 | } |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3266 | } |
| 3267 | return found; |
| 3268 | } |
| 3269 | |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3270 | /* fill in the dac_nids table from the parsed pin configuration */ |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3271 | static int fill_and_eval_dacs(struct hda_codec *codec, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3272 | bool fill_hardwired, |
| 3273 | bool fill_mio_first) |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3274 | { |
| 3275 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3276 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3277 | int i, err, badness; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3278 | |
Takashi Iwai | 8f398ae | 2011-07-23 18:57:11 +0200 | [diff] [blame] | 3279 | /* set num_dacs once to full for alc_auto_look_for_dac() */ |
| 3280 | spec->multiout.num_dacs = cfg->line_outs; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3281 | spec->multiout.dac_nids = spec->private_dac_nids; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3282 | memset(spec->private_dac_nids, 0, sizeof(spec->private_dac_nids)); |
| 3283 | memset(spec->multiout.hp_out_nid, 0, sizeof(spec->multiout.hp_out_nid)); |
| 3284 | 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] | 3285 | spec->multi_ios = 0; |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 3286 | snd_array_free(&spec->paths); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3287 | badness = 0; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3288 | |
| 3289 | /* fill hard-wired DACs first */ |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3290 | if (fill_hardwired) { |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3291 | bool mapped; |
| 3292 | do { |
| 3293 | mapped = alc_map_singles(codec, cfg->line_outs, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3294 | cfg->line_out_pins, |
| 3295 | spec->private_dac_nids); |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3296 | mapped |= alc_map_singles(codec, cfg->hp_outs, |
| 3297 | cfg->hp_pins, |
| 3298 | spec->multiout.hp_out_nid); |
| 3299 | mapped |= alc_map_singles(codec, cfg->speaker_outs, |
| 3300 | cfg->speaker_pins, |
| 3301 | spec->multiout.extra_out_nid); |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3302 | if (fill_mio_first && cfg->line_outs == 1 && |
| 3303 | cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { |
| 3304 | err = alc_auto_fill_multi_ios(codec, cfg->line_out_pins[0], true, 0); |
| 3305 | if (!err) |
| 3306 | mapped = true; |
| 3307 | } |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3308 | } while (mapped); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3309 | } |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3310 | |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3311 | badness += alc_auto_fill_dacs(codec, cfg->line_outs, cfg->line_out_pins, |
| 3312 | spec->private_dac_nids, |
| 3313 | &main_out_badness); |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3314 | |
Takashi Iwai | 8f398ae | 2011-07-23 18:57:11 +0200 | [diff] [blame] | 3315 | /* re-count num_dacs and squash invalid entries */ |
| 3316 | spec->multiout.num_dacs = 0; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3317 | for (i = 0; i < cfg->line_outs; i++) { |
| 3318 | if (spec->private_dac_nids[i]) |
| 3319 | spec->multiout.num_dacs++; |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3320 | else { |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3321 | memmove(spec->private_dac_nids + i, |
| 3322 | spec->private_dac_nids + i + 1, |
| 3323 | sizeof(hda_nid_t) * (cfg->line_outs - i - 1)); |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3324 | spec->private_dac_nids[cfg->line_outs - 1] = 0; |
| 3325 | } |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3326 | } |
| 3327 | |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3328 | if (fill_mio_first && |
| 3329 | cfg->line_outs == 1 && cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3330 | /* try to fill multi-io first */ |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3331 | 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] | 3332 | if (err < 0) |
| 3333 | return err; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3334 | /* we don't count badness at this stage yet */ |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3335 | } |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3336 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3337 | if (cfg->line_out_type != AUTO_PIN_HP_OUT) { |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3338 | err = alc_auto_fill_dacs(codec, cfg->hp_outs, cfg->hp_pins, |
| 3339 | spec->multiout.hp_out_nid, |
| 3340 | &extra_out_badness); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3341 | if (err < 0) |
| 3342 | return err; |
| 3343 | badness += err; |
| 3344 | } |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3345 | if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3346 | err = alc_auto_fill_dacs(codec, cfg->speaker_outs, |
| 3347 | cfg->speaker_pins, |
| 3348 | spec->multiout.extra_out_nid, |
| 3349 | &extra_out_badness); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3350 | if (err < 0) |
| 3351 | return err; |
| 3352 | badness += err; |
| 3353 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3354 | if (cfg->line_outs == 1 && cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { |
| 3355 | 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] | 3356 | if (err < 0) |
| 3357 | return err; |
| 3358 | badness += err; |
| 3359 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3360 | if (cfg->hp_outs && cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) { |
| 3361 | /* try multi-ios with HP + inputs */ |
Takashi Iwai | f568291 | 2012-02-21 12:37:00 +0100 | [diff] [blame] | 3362 | int offset = 0; |
| 3363 | if (cfg->line_outs >= 3) |
| 3364 | offset = 1; |
| 3365 | err = alc_auto_fill_multi_ios(codec, cfg->hp_pins[0], false, |
| 3366 | offset); |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3367 | if (err < 0) |
| 3368 | return err; |
| 3369 | badness += err; |
| 3370 | } |
| 3371 | |
| 3372 | if (spec->multi_ios == 2) { |
| 3373 | for (i = 0; i < 2; i++) |
| 3374 | spec->private_dac_nids[spec->multiout.num_dacs++] = |
| 3375 | spec->multi_io[i].dac; |
| 3376 | spec->ext_channel_count = 2; |
| 3377 | } else if (spec->multi_ios) { |
| 3378 | spec->multi_ios = 0; |
| 3379 | badness += BAD_MULTI_IO; |
| 3380 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3381 | |
| 3382 | return badness; |
| 3383 | } |
| 3384 | |
| 3385 | #define DEBUG_BADNESS |
| 3386 | |
| 3387 | #ifdef DEBUG_BADNESS |
| 3388 | #define debug_badness snd_printdd |
| 3389 | #else |
| 3390 | #define debug_badness(...) |
| 3391 | #endif |
| 3392 | |
| 3393 | static void debug_show_configs(struct alc_spec *spec, struct auto_pin_cfg *cfg) |
| 3394 | { |
| 3395 | debug_badness("multi_outs = %x/%x/%x/%x : %x/%x/%x/%x\n", |
| 3396 | cfg->line_out_pins[0], cfg->line_out_pins[1], |
| 3397 | cfg->line_out_pins[2], cfg->line_out_pins[2], |
| 3398 | spec->multiout.dac_nids[0], |
| 3399 | spec->multiout.dac_nids[1], |
| 3400 | spec->multiout.dac_nids[2], |
| 3401 | spec->multiout.dac_nids[3]); |
Takashi Iwai | 6f45304 | 2012-02-17 14:09:20 +0100 | [diff] [blame] | 3402 | if (spec->multi_ios > 0) |
| 3403 | debug_badness("multi_ios(%d) = %x/%x : %x/%x\n", |
| 3404 | spec->multi_ios, |
| 3405 | spec->multi_io[0].pin, spec->multi_io[1].pin, |
| 3406 | spec->multi_io[0].dac, spec->multi_io[1].dac); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3407 | debug_badness("hp_outs = %x/%x/%x/%x : %x/%x/%x/%x\n", |
| 3408 | cfg->hp_pins[0], cfg->hp_pins[1], |
| 3409 | cfg->hp_pins[2], cfg->hp_pins[2], |
| 3410 | spec->multiout.hp_out_nid[0], |
| 3411 | spec->multiout.hp_out_nid[1], |
| 3412 | spec->multiout.hp_out_nid[2], |
| 3413 | spec->multiout.hp_out_nid[3]); |
| 3414 | debug_badness("spk_outs = %x/%x/%x/%x : %x/%x/%x/%x\n", |
| 3415 | cfg->speaker_pins[0], cfg->speaker_pins[1], |
| 3416 | cfg->speaker_pins[2], cfg->speaker_pins[3], |
| 3417 | spec->multiout.extra_out_nid[0], |
| 3418 | spec->multiout.extra_out_nid[1], |
| 3419 | spec->multiout.extra_out_nid[2], |
| 3420 | spec->multiout.extra_out_nid[3]); |
| 3421 | } |
| 3422 | |
Takashi Iwai | 463419d | 2012-12-05 14:17:37 +0100 | [diff] [blame] | 3423 | /* find all available DACs of the codec */ |
| 3424 | static void alc_fill_all_nids(struct hda_codec *codec) |
| 3425 | { |
| 3426 | struct alc_spec *spec = codec->spec; |
| 3427 | int i; |
| 3428 | hda_nid_t nid = codec->start_nid; |
| 3429 | |
| 3430 | spec->num_all_dacs = 0; |
| 3431 | memset(spec->all_dacs, 0, sizeof(spec->all_dacs)); |
| 3432 | for (i = 0; i < codec->num_nodes; i++, nid++) { |
| 3433 | if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_AUD_OUT) |
| 3434 | continue; |
| 3435 | if (spec->num_all_dacs >= ARRAY_SIZE(spec->all_dacs)) { |
| 3436 | snd_printk(KERN_ERR "hda: Too many DACs!\n"); |
| 3437 | break; |
| 3438 | } |
| 3439 | spec->all_dacs[spec->num_all_dacs++] = nid; |
| 3440 | } |
| 3441 | } |
| 3442 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3443 | static int alc_auto_fill_dac_nids(struct hda_codec *codec) |
| 3444 | { |
| 3445 | struct alc_spec *spec = codec->spec; |
| 3446 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 3447 | struct auto_pin_cfg *best_cfg; |
| 3448 | int best_badness = INT_MAX; |
| 3449 | int badness; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3450 | bool fill_hardwired = true, fill_mio_first = true; |
| 3451 | bool best_wired = true, best_mio = true; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3452 | bool hp_spk_swapped = false; |
| 3453 | |
Takashi Iwai | 463419d | 2012-12-05 14:17:37 +0100 | [diff] [blame] | 3454 | alc_fill_all_nids(codec); |
| 3455 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3456 | best_cfg = kmalloc(sizeof(*best_cfg), GFP_KERNEL); |
| 3457 | if (!best_cfg) |
| 3458 | return -ENOMEM; |
| 3459 | *best_cfg = *cfg; |
| 3460 | |
| 3461 | for (;;) { |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3462 | badness = fill_and_eval_dacs(codec, fill_hardwired, |
| 3463 | fill_mio_first); |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 3464 | if (badness < 0) { |
| 3465 | kfree(best_cfg); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3466 | return badness; |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 3467 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3468 | debug_badness("==> lo_type=%d, wired=%d, mio=%d, badness=0x%x\n", |
| 3469 | cfg->line_out_type, fill_hardwired, fill_mio_first, |
| 3470 | badness); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3471 | debug_show_configs(spec, cfg); |
| 3472 | if (badness < best_badness) { |
| 3473 | best_badness = badness; |
| 3474 | *best_cfg = *cfg; |
| 3475 | best_wired = fill_hardwired; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3476 | best_mio = fill_mio_first; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3477 | } |
| 3478 | if (!badness) |
| 3479 | break; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3480 | fill_mio_first = !fill_mio_first; |
| 3481 | if (!fill_mio_first) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3482 | continue; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3483 | fill_hardwired = !fill_hardwired; |
| 3484 | if (!fill_hardwired) |
| 3485 | continue; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3486 | if (hp_spk_swapped) |
| 3487 | break; |
| 3488 | hp_spk_swapped = true; |
| 3489 | if (cfg->speaker_outs > 0 && |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3490 | cfg->line_out_type == AUTO_PIN_HP_OUT) { |
| 3491 | cfg->hp_outs = cfg->line_outs; |
| 3492 | memcpy(cfg->hp_pins, cfg->line_out_pins, |
| 3493 | sizeof(cfg->hp_pins)); |
| 3494 | cfg->line_outs = cfg->speaker_outs; |
| 3495 | memcpy(cfg->line_out_pins, cfg->speaker_pins, |
| 3496 | sizeof(cfg->speaker_pins)); |
| 3497 | cfg->speaker_outs = 0; |
| 3498 | memset(cfg->speaker_pins, 0, sizeof(cfg->speaker_pins)); |
| 3499 | cfg->line_out_type = AUTO_PIN_SPEAKER_OUT; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3500 | fill_hardwired = true; |
| 3501 | continue; |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 3502 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3503 | if (cfg->hp_outs > 0 && |
| 3504 | cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) { |
| 3505 | cfg->speaker_outs = cfg->line_outs; |
| 3506 | memcpy(cfg->speaker_pins, cfg->line_out_pins, |
| 3507 | sizeof(cfg->speaker_pins)); |
| 3508 | cfg->line_outs = cfg->hp_outs; |
| 3509 | memcpy(cfg->line_out_pins, cfg->hp_pins, |
| 3510 | sizeof(cfg->hp_pins)); |
| 3511 | cfg->hp_outs = 0; |
| 3512 | memset(cfg->hp_pins, 0, sizeof(cfg->hp_pins)); |
| 3513 | cfg->line_out_type = AUTO_PIN_HP_OUT; |
| 3514 | fill_hardwired = true; |
| 3515 | continue; |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 3516 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3517 | break; |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3518 | } |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3519 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3520 | if (badness) { |
| 3521 | *cfg = *best_cfg; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3522 | fill_and_eval_dacs(codec, best_wired, best_mio); |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 3523 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3524 | debug_badness("==> Best config: lo_type=%d, wired=%d, mio=%d\n", |
| 3525 | cfg->line_out_type, best_wired, best_mio); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3526 | debug_show_configs(spec, cfg); |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 3527 | |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3528 | if (cfg->line_out_pins[0]) { |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame] | 3529 | struct nid_path *path = get_nid_path(codec, |
| 3530 | spec->multiout.dac_nids[0], |
| 3531 | cfg->line_out_pins[0]); |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3532 | if (path) |
| 3533 | spec->vmaster_nid = alc_look_for_out_vol_nid(codec, path); |
| 3534 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3535 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3536 | kfree(best_cfg); |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3537 | return 0; |
| 3538 | } |
| 3539 | |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3540 | /* replace the channels in the composed amp value with the given number */ |
| 3541 | static unsigned int amp_val_replace_channels(unsigned int val, unsigned int chs) |
| 3542 | { |
| 3543 | val &= ~(0x3U << 16); |
| 3544 | val |= chs << 16; |
| 3545 | return val; |
| 3546 | } |
| 3547 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3548 | static int alc_auto_add_vol_ctl(struct hda_codec *codec, |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3549 | const char *pfx, int cidx, |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3550 | unsigned int chs, |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3551 | struct nid_path *path) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3552 | { |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3553 | unsigned int val; |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3554 | if (!path) |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3555 | return 0; |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3556 | val = path->ctls[NID_PATH_VOL_CTL]; |
| 3557 | if (!val) |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3558 | return 0; |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3559 | val = amp_val_replace_channels(val, chs); |
| 3560 | return __add_pb_vol_ctrl(codec->spec, ALC_CTL_WIDGET_VOL, pfx, cidx, val); |
| 3561 | } |
| 3562 | |
| 3563 | /* return the channel bits suitable for the given path->ctls[] */ |
| 3564 | static int get_default_ch_nums(struct hda_codec *codec, struct nid_path *path, |
| 3565 | int type) |
| 3566 | { |
| 3567 | int chs = 1; /* mono (left only) */ |
| 3568 | if (path) { |
| 3569 | hda_nid_t nid = get_amp_nid_(path->ctls[type]); |
| 3570 | if (nid && (get_wcaps(codec, nid) & AC_WCAP_STEREO)) |
| 3571 | chs = 3; /* stereo */ |
| 3572 | } |
| 3573 | return chs; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3574 | } |
| 3575 | |
Takashi Iwai | e29d377 | 2011-11-14 17:13:23 +0100 | [diff] [blame] | 3576 | static int alc_auto_add_stereo_vol(struct hda_codec *codec, |
| 3577 | const char *pfx, int cidx, |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3578 | struct nid_path *path) |
Takashi Iwai | e29d377 | 2011-11-14 17:13:23 +0100 | [diff] [blame] | 3579 | { |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3580 | int chs = get_default_ch_nums(codec, path, NID_PATH_VOL_CTL); |
| 3581 | return alc_auto_add_vol_ctl(codec, pfx, cidx, chs, path); |
Takashi Iwai | e29d377 | 2011-11-14 17:13:23 +0100 | [diff] [blame] | 3582 | } |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3583 | |
| 3584 | /* create a mute-switch for the given mixer widget; |
| 3585 | * if it has multiple sources (e.g. DAC and loopback), create a bind-mute |
| 3586 | */ |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3587 | static int alc_auto_add_sw_ctl(struct hda_codec *codec, |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3588 | const char *pfx, int cidx, |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3589 | unsigned int chs, |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3590 | struct nid_path *path) |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3591 | { |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3592 | unsigned int val; |
| 3593 | int type = ALC_CTL_WIDGET_MUTE; |
| 3594 | |
| 3595 | if (!path) |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3596 | return 0; |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3597 | val = path->ctls[NID_PATH_MUTE_CTL]; |
| 3598 | if (!val) |
| 3599 | return 0; |
| 3600 | val = amp_val_replace_channels(val, chs); |
| 3601 | if (get_amp_direction_(val) == HDA_INPUT) { |
| 3602 | hda_nid_t nid = get_amp_nid_(val); |
Takashi Iwai | 9366ede | 2012-12-13 16:43:52 +0100 | [diff] [blame] | 3603 | int nums = snd_hda_get_num_conns(codec, nid); |
| 3604 | if (nums > 1) { |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3605 | type = ALC_CTL_BIND_MUTE; |
Takashi Iwai | 9366ede | 2012-12-13 16:43:52 +0100 | [diff] [blame] | 3606 | val |= nums << 19; |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3607 | } |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3608 | } |
| 3609 | return __add_pb_sw_ctrl(codec->spec, type, pfx, cidx, val); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3610 | } |
| 3611 | |
Takashi Iwai | e29d377 | 2011-11-14 17:13:23 +0100 | [diff] [blame] | 3612 | static int alc_auto_add_stereo_sw(struct hda_codec *codec, const char *pfx, |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3613 | int cidx, struct nid_path *path) |
Takashi Iwai | e29d377 | 2011-11-14 17:13:23 +0100 | [diff] [blame] | 3614 | { |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3615 | int chs = get_default_ch_nums(codec, path, NID_PATH_MUTE_CTL); |
| 3616 | return alc_auto_add_sw_ctl(codec, pfx, cidx, chs, path); |
Takashi Iwai | e29d377 | 2011-11-14 17:13:23 +0100 | [diff] [blame] | 3617 | } |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3618 | |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3619 | static hda_nid_t alc_look_for_out_mute_nid(struct hda_codec *codec, |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3620 | struct nid_path *path) |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3621 | { |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3622 | int i; |
| 3623 | |
| 3624 | for (i = path->depth - 1; i >= 0; i--) { |
| 3625 | if (nid_has_mute(codec, path->path[i], HDA_OUTPUT)) |
| 3626 | return path->path[i]; |
| 3627 | if (i != path->depth - 1 && i != 0 && |
| 3628 | nid_has_mute(codec, path->path[i], HDA_INPUT)) |
| 3629 | return path->path[i]; |
| 3630 | } |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3631 | return 0; |
| 3632 | } |
| 3633 | |
| 3634 | static hda_nid_t alc_look_for_out_vol_nid(struct hda_codec *codec, |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3635 | struct nid_path *path) |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3636 | { |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3637 | int i; |
| 3638 | |
| 3639 | for (i = path->depth - 1; i >= 0; i--) { |
| 3640 | if (nid_has_volume(codec, path->path[i], HDA_OUTPUT)) |
| 3641 | return path->path[i]; |
| 3642 | } |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3643 | return 0; |
| 3644 | } |
| 3645 | |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3646 | /* add playback controls from the parsed DAC table */ |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3647 | static int alc_auto_create_multi_out_ctls(struct hda_codec *codec, |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3648 | const struct auto_pin_cfg *cfg) |
| 3649 | { |
| 3650 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3651 | int i, err, noutputs; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3652 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3653 | noutputs = cfg->line_outs; |
Takashi Iwai | b90bf1d | 2012-01-19 11:42:55 +0100 | [diff] [blame] | 3654 | if (spec->multi_ios > 0 && cfg->line_outs < 3) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3655 | noutputs += spec->multi_ios; |
| 3656 | |
| 3657 | for (i = 0; i < noutputs; i++) { |
Takashi Iwai | 6843ca1 | 2011-06-24 11:03:58 +0200 | [diff] [blame] | 3658 | const char *name; |
| 3659 | int index; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3660 | hda_nid_t dac, pin; |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3661 | struct nid_path *path; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3662 | |
| 3663 | dac = spec->multiout.dac_nids[i]; |
| 3664 | if (!dac) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3665 | continue; |
Takashi Iwai | 689cabf | 2012-02-21 12:35:27 +0100 | [diff] [blame] | 3666 | if (i >= cfg->line_outs) { |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3667 | pin = spec->multi_io[i - 1].pin; |
Takashi Iwai | 689cabf | 2012-02-21 12:35:27 +0100 | [diff] [blame] | 3668 | index = 0; |
| 3669 | name = channel_name[i]; |
| 3670 | } else { |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3671 | pin = cfg->line_out_pins[i]; |
Takashi Iwai | 689cabf | 2012-02-21 12:35:27 +0100 | [diff] [blame] | 3672 | name = alc_get_line_out_pfx(spec, i, true, &index); |
| 3673 | } |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3674 | |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame] | 3675 | path = get_nid_path(codec, dac, pin); |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3676 | if (!path) |
| 3677 | continue; |
Takashi Iwai | 9c4e84d | 2011-08-24 17:27:52 +0200 | [diff] [blame] | 3678 | if (!name || !strcmp(name, "CLFE")) { |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3679 | /* Center/LFE */ |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3680 | err = alc_auto_add_vol_ctl(codec, "Center", 0, 1, path); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3681 | if (err < 0) |
| 3682 | return err; |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3683 | err = alc_auto_add_vol_ctl(codec, "LFE", 0, 2, path); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3684 | if (err < 0) |
| 3685 | return err; |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3686 | err = alc_auto_add_sw_ctl(codec, "Center", 0, 1, path); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3687 | if (err < 0) |
| 3688 | return err; |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3689 | err = alc_auto_add_sw_ctl(codec, "LFE", 0, 2, path); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3690 | if (err < 0) |
| 3691 | return err; |
| 3692 | } else { |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3693 | err = alc_auto_add_stereo_vol(codec, name, index, path); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3694 | if (err < 0) |
| 3695 | return err; |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3696 | err = alc_auto_add_stereo_sw(codec, name, index, path); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3697 | if (err < 0) |
| 3698 | return err; |
| 3699 | } |
| 3700 | } |
| 3701 | return 0; |
| 3702 | } |
| 3703 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3704 | 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] | 3705 | hda_nid_t dac, const char *pfx, |
| 3706 | int cidx) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3707 | { |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3708 | struct nid_path *path; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3709 | int err; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3710 | |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame] | 3711 | path = get_nid_path(codec, dac, pin); |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3712 | if (!path) |
| 3713 | return 0; |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3714 | /* bind volume control will be created in the case of dac = 0 */ |
| 3715 | if (dac) { |
| 3716 | err = alc_auto_add_stereo_vol(codec, pfx, cidx, path); |
| 3717 | if (err < 0) |
| 3718 | return err; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3719 | } |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3720 | err = alc_auto_add_stereo_sw(codec, pfx, cidx, path); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3721 | if (err < 0) |
| 3722 | return err; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3723 | return 0; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3724 | } |
| 3725 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3726 | static struct hda_bind_ctls *new_bind_ctl(struct hda_codec *codec, |
| 3727 | unsigned int nums, |
| 3728 | struct hda_ctl_ops *ops) |
| 3729 | { |
| 3730 | struct alc_spec *spec = codec->spec; |
| 3731 | struct hda_bind_ctls **ctlp, *ctl; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3732 | ctlp = snd_array_new(&spec->bind_ctls); |
| 3733 | if (!ctlp) |
| 3734 | return NULL; |
| 3735 | ctl = kzalloc(sizeof(*ctl) + sizeof(long) * (nums + 1), GFP_KERNEL); |
| 3736 | *ctlp = ctl; |
| 3737 | if (ctl) |
| 3738 | ctl->ops = ops; |
| 3739 | return ctl; |
| 3740 | } |
| 3741 | |
| 3742 | /* add playback controls for speaker and HP outputs */ |
| 3743 | static int alc_auto_create_extra_outs(struct hda_codec *codec, int num_pins, |
| 3744 | const hda_nid_t *pins, |
| 3745 | const hda_nid_t *dacs, |
| 3746 | const char *pfx) |
| 3747 | { |
| 3748 | struct alc_spec *spec = codec->spec; |
| 3749 | struct hda_bind_ctls *ctl; |
| 3750 | char name[32]; |
| 3751 | int i, n, err; |
| 3752 | |
| 3753 | if (!num_pins || !pins[0]) |
| 3754 | return 0; |
| 3755 | |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3756 | if (num_pins == 1) { |
| 3757 | hda_nid_t dac = *dacs; |
| 3758 | if (!dac) |
| 3759 | dac = spec->multiout.dac_nids[0]; |
Takashi Iwai | 766ddee | 2011-12-07 16:55:19 +0100 | [diff] [blame] | 3760 | return alc_auto_create_extra_out(codec, *pins, dac, pfx, 0); |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3761 | } |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3762 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3763 | for (i = 0; i < num_pins; i++) { |
Takashi Iwai | c96f0bf | 2012-02-21 12:12:57 +0100 | [diff] [blame] | 3764 | hda_nid_t dac; |
| 3765 | if (dacs[num_pins - 1]) |
| 3766 | dac = dacs[i]; /* with individual volumes */ |
| 3767 | else |
| 3768 | dac = 0; |
| 3769 | if (num_pins == 2 && i == 1 && !strcmp(pfx, "Speaker")) { |
| 3770 | err = alc_auto_create_extra_out(codec, pins[i], dac, |
| 3771 | "Bass Speaker", 0); |
| 3772 | } else if (num_pins >= 3) { |
| 3773 | snprintf(name, sizeof(name), "%s %s", |
| 3774 | pfx, channel_name[i]); |
| 3775 | err = alc_auto_create_extra_out(codec, pins[i], dac, |
| 3776 | name, 0); |
| 3777 | } else { |
| 3778 | err = alc_auto_create_extra_out(codec, pins[i], dac, |
| 3779 | pfx, i); |
| 3780 | } |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3781 | if (err < 0) |
| 3782 | return err; |
| 3783 | } |
Takashi Iwai | c96f0bf | 2012-02-21 12:12:57 +0100 | [diff] [blame] | 3784 | if (dacs[num_pins - 1]) |
| 3785 | return 0; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3786 | |
Takashi Iwai | c96f0bf | 2012-02-21 12:12:57 +0100 | [diff] [blame] | 3787 | /* Let's create a bind-controls for volumes */ |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3788 | ctl = new_bind_ctl(codec, num_pins, &snd_hda_bind_vol); |
| 3789 | if (!ctl) |
| 3790 | return -ENOMEM; |
| 3791 | n = 0; |
| 3792 | for (i = 0; i < num_pins; i++) { |
| 3793 | hda_nid_t vol; |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3794 | struct nid_path *path; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3795 | if (!pins[i] || !dacs[i]) |
| 3796 | continue; |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame] | 3797 | path = get_nid_path(codec, dacs[i], pins[i]); |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3798 | if (!path) |
| 3799 | continue; |
| 3800 | vol = alc_look_for_out_vol_nid(codec, path); |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3801 | if (vol) |
| 3802 | ctl->values[n++] = |
| 3803 | HDA_COMPOSE_AMP_VAL(vol, 3, 0, HDA_OUTPUT); |
| 3804 | } |
| 3805 | if (n) { |
| 3806 | snprintf(name, sizeof(name), "%s Playback Volume", pfx); |
| 3807 | err = add_control(spec, ALC_CTL_BIND_VOL, name, 0, (long)ctl); |
| 3808 | if (err < 0) |
| 3809 | return err; |
| 3810 | } |
| 3811 | return 0; |
| 3812 | } |
| 3813 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3814 | static int alc_auto_create_hp_out(struct hda_codec *codec) |
| 3815 | { |
| 3816 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | e23832a | 2011-08-23 18:16:56 +0200 | [diff] [blame] | 3817 | return alc_auto_create_extra_outs(codec, spec->autocfg.hp_outs, |
| 3818 | spec->autocfg.hp_pins, |
| 3819 | spec->multiout.hp_out_nid, |
| 3820 | "Headphone"); |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3821 | } |
| 3822 | |
| 3823 | static int alc_auto_create_speaker_out(struct hda_codec *codec) |
| 3824 | { |
| 3825 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3826 | return alc_auto_create_extra_outs(codec, spec->autocfg.speaker_outs, |
| 3827 | spec->autocfg.speaker_pins, |
| 3828 | spec->multiout.extra_out_nid, |
| 3829 | "Speaker"); |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3830 | } |
| 3831 | |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3832 | /* check whether a control with the given (nid, dir, idx) was assigned */ |
| 3833 | static bool is_ctl_associated(struct hda_codec *codec, hda_nid_t nid, |
| 3834 | int dir, int idx) |
Takashi Iwai | 78e635c | 2012-12-10 17:07:16 +0100 | [diff] [blame] | 3835 | { |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3836 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 3837 | int i, type; |
| 3838 | |
| 3839 | for (i = 0; i < spec->paths.used; i++) { |
| 3840 | struct nid_path *p = snd_array_elem(&spec->paths, i); |
| 3841 | if (p->depth <= 0) |
| 3842 | continue; |
Takashi Iwai | 8dd4867 | 2012-12-14 18:19:04 +0100 | [diff] [blame] | 3843 | for (type = 0; type < NID_PATH_NUM_CTLS; type++) { |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 3844 | unsigned int val = p->ctls[type]; |
| 3845 | if (get_amp_nid_(val) == nid && |
| 3846 | get_amp_direction_(val) == dir && |
| 3847 | get_amp_index_(val) == idx) |
| 3848 | return true; |
| 3849 | } |
| 3850 | } |
| 3851 | return false; |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3852 | } |
| 3853 | |
| 3854 | /* can have the amp-in capability? */ |
| 3855 | static bool has_amp_in(struct hda_codec *codec, struct nid_path *path, int idx) |
| 3856 | { |
| 3857 | hda_nid_t nid = path->path[idx]; |
| 3858 | unsigned int caps = get_wcaps(codec, nid); |
| 3859 | unsigned int type = get_wcaps_type(caps); |
| 3860 | |
| 3861 | if (!(caps & AC_WCAP_IN_AMP)) |
| 3862 | return false; |
| 3863 | if (type == AC_WID_PIN && idx > 0) /* only for input pins */ |
| 3864 | return false; |
| 3865 | return true; |
| 3866 | } |
| 3867 | |
| 3868 | /* can have the amp-out capability? */ |
| 3869 | static bool has_amp_out(struct hda_codec *codec, struct nid_path *path, int idx) |
| 3870 | { |
| 3871 | hda_nid_t nid = path->path[idx]; |
| 3872 | unsigned int caps = get_wcaps(codec, nid); |
| 3873 | unsigned int type = get_wcaps_type(caps); |
| 3874 | |
| 3875 | if (!(caps & AC_WCAP_OUT_AMP)) |
| 3876 | return false; |
| 3877 | if (type == AC_WID_PIN && !idx) /* only for output pins */ |
| 3878 | return false; |
| 3879 | return true; |
| 3880 | } |
| 3881 | |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 3882 | /* check whether the given (nid,dir,idx) is active */ |
| 3883 | static bool is_active_nid(struct hda_codec *codec, hda_nid_t nid, |
| 3884 | unsigned int idx, unsigned int dir) |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3885 | { |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 3886 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3887 | int i, n; |
| 3888 | |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 3889 | for (n = 0; n < spec->paths.used; n++) { |
| 3890 | struct nid_path *path = snd_array_elem(&spec->paths, n); |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3891 | if (!path->active) |
| 3892 | continue; |
| 3893 | for (i = 0; i < path->depth; i++) { |
| 3894 | if (path->path[i] == nid) { |
| 3895 | if (dir == HDA_OUTPUT || path->idx[i] == idx) |
| 3896 | return true; |
| 3897 | break; |
| 3898 | } |
| 3899 | } |
| 3900 | } |
| 3901 | return false; |
| 3902 | } |
| 3903 | |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3904 | /* get the default amp value for the target state */ |
| 3905 | static int get_amp_val_to_activate(struct hda_codec *codec, hda_nid_t nid, |
| 3906 | int dir, bool enable) |
| 3907 | { |
| 3908 | unsigned int caps; |
Takashi Iwai | 78e635c | 2012-12-10 17:07:16 +0100 | [diff] [blame] | 3909 | unsigned int val = 0; |
| 3910 | |
| 3911 | caps = query_amp_caps(codec, nid, dir); |
| 3912 | if (caps & AC_AMPCAP_NUM_STEPS) { |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3913 | /* set to 0dB */ |
| 3914 | if (enable) |
| 3915 | val = (caps & AC_AMPCAP_OFFSET) >> AC_AMPCAP_OFFSET_SHIFT; |
Takashi Iwai | 78e635c | 2012-12-10 17:07:16 +0100 | [diff] [blame] | 3916 | } |
| 3917 | if (caps & AC_AMPCAP_MUTE) { |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3918 | if (!enable) |
Takashi Iwai | 78e635c | 2012-12-10 17:07:16 +0100 | [diff] [blame] | 3919 | val |= HDA_AMP_MUTE; |
| 3920 | } |
| 3921 | return val; |
| 3922 | } |
| 3923 | |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3924 | /* initialize the amp value (only at the first time) */ |
| 3925 | static void init_amp(struct hda_codec *codec, hda_nid_t nid, int dir, int idx) |
| 3926 | { |
| 3927 | int val = get_amp_val_to_activate(codec, nid, dir, false); |
| 3928 | snd_hda_codec_amp_init_stereo(codec, nid, dir, idx, 0xff, val); |
| 3929 | } |
| 3930 | |
| 3931 | static void activate_amp(struct hda_codec *codec, hda_nid_t nid, int dir, |
| 3932 | int idx, bool enable) |
| 3933 | { |
| 3934 | int val; |
| 3935 | if (is_ctl_associated(codec, nid, dir, idx) || |
| 3936 | is_active_nid(codec, nid, dir, idx)) |
| 3937 | return; |
| 3938 | val = get_amp_val_to_activate(codec, nid, dir, enable); |
| 3939 | snd_hda_codec_amp_stereo(codec, nid, dir, idx, 0xff, val); |
| 3940 | } |
| 3941 | |
| 3942 | static void activate_amp_out(struct hda_codec *codec, struct nid_path *path, |
| 3943 | int i, bool enable) |
| 3944 | { |
| 3945 | hda_nid_t nid = path->path[i]; |
| 3946 | init_amp(codec, nid, HDA_OUTPUT, 0); |
| 3947 | activate_amp(codec, nid, HDA_OUTPUT, 0, enable); |
| 3948 | } |
| 3949 | |
| 3950 | static void activate_amp_in(struct hda_codec *codec, struct nid_path *path, |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 3951 | int i, bool enable, bool add_aamix) |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3952 | { |
| 3953 | struct alc_spec *spec = codec->spec; |
| 3954 | hda_nid_t conn[16]; |
Takashi Iwai | 0250f7c | 2012-12-14 17:53:29 +0100 | [diff] [blame] | 3955 | int n, nums, idx; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 3956 | int type; |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3957 | hda_nid_t nid = path->path[i]; |
| 3958 | |
| 3959 | nums = snd_hda_get_connections(codec, nid, conn, ARRAY_SIZE(conn)); |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 3960 | type = get_wcaps_type(get_wcaps(codec, nid)); |
| 3961 | if (type == AC_WID_PIN || |
| 3962 | (type == AC_WID_AUD_IN && codec->single_adc_amp)) { |
Takashi Iwai | 0250f7c | 2012-12-14 17:53:29 +0100 | [diff] [blame] | 3963 | nums = 1; |
| 3964 | idx = 0; |
| 3965 | } else |
| 3966 | idx = path->idx[i]; |
| 3967 | |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3968 | for (n = 0; n < nums; n++) |
| 3969 | init_amp(codec, nid, HDA_INPUT, n); |
| 3970 | |
Takashi Iwai | 0250f7c | 2012-12-14 17:53:29 +0100 | [diff] [blame] | 3971 | if (is_ctl_associated(codec, nid, HDA_INPUT, idx)) |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3972 | return; |
| 3973 | |
| 3974 | /* here is a little bit tricky in comparison with activate_amp_out(); |
| 3975 | * when aa-mixer is available, we need to enable the path as well |
| 3976 | */ |
| 3977 | for (n = 0; n < nums; n++) { |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 3978 | if (n != idx && (!add_aamix || conn[n] != spec->mixer_nid)) |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3979 | continue; |
| 3980 | activate_amp(codec, nid, HDA_INPUT, n, enable); |
| 3981 | } |
| 3982 | } |
| 3983 | |
| 3984 | static void activate_path(struct hda_codec *codec, struct nid_path *path, |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 3985 | bool enable, bool add_aamix) |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3986 | { |
| 3987 | int i; |
| 3988 | |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3989 | if (!enable) |
| 3990 | path->active = false; |
| 3991 | |
| 3992 | for (i = path->depth - 1; i >= 0; i--) { |
Takashi Iwai | 183a444 | 2012-12-17 18:00:02 +0100 | [diff] [blame] | 3993 | if (enable && path->multi[i]) |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3994 | snd_hda_codec_write_cache(codec, path->path[i], 0, |
| 3995 | AC_VERB_SET_CONNECT_SEL, |
| 3996 | path->idx[i]); |
| 3997 | if (has_amp_in(codec, path, i)) |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 3998 | activate_amp_in(codec, path, i, enable, add_aamix); |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3999 | if (has_amp_out(codec, path, i)) |
| 4000 | activate_amp_out(codec, path, i, enable); |
| 4001 | } |
| 4002 | |
| 4003 | if (enable) |
| 4004 | path->active = true; |
| 4005 | } |
| 4006 | |
Takashi Iwai | 78e635c | 2012-12-10 17:07:16 +0100 | [diff] [blame] | 4007 | /* configure the path from the given dac to the pin as the proper output */ |
| 4008 | static void alc_auto_set_output_and_unmute(struct hda_codec *codec, |
| 4009 | hda_nid_t pin, int pin_type, |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 4010 | hda_nid_t dac) |
Takashi Iwai | 78e635c | 2012-12-10 17:07:16 +0100 | [diff] [blame] | 4011 | { |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 4012 | struct nid_path *path; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 4013 | |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 4014 | snd_hda_set_pin_ctl_cache(codec, pin, pin_type); |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame] | 4015 | path = get_nid_path(codec, dac, pin); |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 4016 | if (!path) |
| 4017 | return; |
Takashi Iwai | 3ebf1e9 | 2012-12-14 18:04:37 +0100 | [diff] [blame] | 4018 | if (path->active) |
| 4019 | return; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 4020 | activate_path(codec, path, true, true); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 4021 | } |
| 4022 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 4023 | static void alc_auto_init_multi_out(struct hda_codec *codec) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 4024 | { |
| 4025 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 4026 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 4027 | int i; |
| 4028 | |
| 4029 | for (i = 0; i <= HDA_SIDE; i++) { |
| 4030 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
| 4031 | if (nid) |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 4032 | alc_auto_set_output_and_unmute(codec, nid, pin_type, |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 4033 | spec->multiout.dac_nids[i]); |
Takashi Iwai | 78e635c | 2012-12-10 17:07:16 +0100 | [diff] [blame] | 4034 | |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 4035 | } |
| 4036 | } |
| 4037 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 4038 | static void alc_auto_init_extra_out(struct hda_codec *codec) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 4039 | { |
| 4040 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 8cd0775 | 2011-08-23 15:16:22 +0200 | [diff] [blame] | 4041 | int i; |
Takashi Iwai | 675c1aa | 2011-08-23 12:36:28 +0200 | [diff] [blame] | 4042 | hda_nid_t pin, dac; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 4043 | |
David Henningsson | 636030e | 2011-10-12 19:26:03 +0200 | [diff] [blame] | 4044 | for (i = 0; i < spec->autocfg.hp_outs; i++) { |
Takashi Iwai | 716eef0 | 2011-10-21 15:07:42 +0200 | [diff] [blame] | 4045 | if (spec->autocfg.line_out_type == AUTO_PIN_HP_OUT) |
| 4046 | break; |
Takashi Iwai | e23832a | 2011-08-23 18:16:56 +0200 | [diff] [blame] | 4047 | pin = spec->autocfg.hp_pins[i]; |
| 4048 | if (!pin) |
| 4049 | break; |
| 4050 | dac = spec->multiout.hp_out_nid[i]; |
| 4051 | if (!dac) { |
| 4052 | if (i > 0 && spec->multiout.hp_out_nid[0]) |
| 4053 | dac = spec->multiout.hp_out_nid[0]; |
| 4054 | else |
| 4055 | dac = spec->multiout.dac_nids[0]; |
| 4056 | } |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 4057 | alc_auto_set_output_and_unmute(codec, pin, PIN_HP, dac); |
Takashi Iwai | 675c1aa | 2011-08-23 12:36:28 +0200 | [diff] [blame] | 4058 | } |
Takashi Iwai | 8cd0775 | 2011-08-23 15:16:22 +0200 | [diff] [blame] | 4059 | for (i = 0; i < spec->autocfg.speaker_outs; i++) { |
Takashi Iwai | 716eef0 | 2011-10-21 15:07:42 +0200 | [diff] [blame] | 4060 | if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT) |
| 4061 | break; |
Takashi Iwai | 8cd0775 | 2011-08-23 15:16:22 +0200 | [diff] [blame] | 4062 | pin = spec->autocfg.speaker_pins[i]; |
| 4063 | if (!pin) |
| 4064 | break; |
| 4065 | dac = spec->multiout.extra_out_nid[i]; |
| 4066 | if (!dac) { |
| 4067 | if (i > 0 && spec->multiout.extra_out_nid[0]) |
| 4068 | dac = spec->multiout.extra_out_nid[0]; |
| 4069 | else |
| 4070 | dac = spec->multiout.dac_nids[0]; |
| 4071 | } |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 4072 | alc_auto_set_output_and_unmute(codec, pin, PIN_OUT, dac); |
Takashi Iwai | 675c1aa | 2011-08-23 12:36:28 +0200 | [diff] [blame] | 4073 | } |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 4074 | } |
| 4075 | |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4076 | /* check whether the given pin can be a multi-io pin */ |
| 4077 | static bool can_be_multiio_pin(struct hda_codec *codec, |
| 4078 | unsigned int location, hda_nid_t nid) |
| 4079 | { |
| 4080 | unsigned int defcfg, caps; |
| 4081 | |
| 4082 | defcfg = snd_hda_codec_get_pincfg(codec, nid); |
| 4083 | if (get_defcfg_connect(defcfg) != AC_JACK_PORT_COMPLEX) |
| 4084 | return false; |
| 4085 | if (location && get_defcfg_location(defcfg) != location) |
| 4086 | return false; |
| 4087 | caps = snd_hda_query_pin_caps(codec, nid); |
| 4088 | if (!(caps & AC_PINCAP_OUT)) |
| 4089 | return false; |
| 4090 | return true; |
| 4091 | } |
| 4092 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4093 | /* |
| 4094 | * multi-io helper |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4095 | * |
| 4096 | * When hardwired is set, try to fill ony hardwired pins, and returns |
| 4097 | * zero if any pins are filled, non-zero if nothing found. |
| 4098 | * When hardwired is off, try to fill possible input pins, and returns |
| 4099 | * the badness value. |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4100 | */ |
| 4101 | static int alc_auto_fill_multi_ios(struct hda_codec *codec, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4102 | hda_nid_t reference_pin, |
| 4103 | bool hardwired, int offset) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4104 | { |
| 4105 | struct alc_spec *spec = codec->spec; |
| 4106 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4107 | int type, i, j, dacs, num_pins, old_pins; |
| 4108 | unsigned int defcfg = snd_hda_codec_get_pincfg(codec, reference_pin); |
| 4109 | unsigned int location = get_defcfg_location(defcfg); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 4110 | int badness = 0; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4111 | |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4112 | old_pins = spec->multi_ios; |
| 4113 | if (old_pins >= 2) |
| 4114 | goto end_fill; |
| 4115 | |
| 4116 | num_pins = 0; |
| 4117 | for (type = AUTO_PIN_LINE_IN; type >= AUTO_PIN_MIC; type--) { |
| 4118 | for (i = 0; i < cfg->num_inputs; i++) { |
| 4119 | if (cfg->inputs[i].type != type) |
| 4120 | continue; |
| 4121 | if (can_be_multiio_pin(codec, location, |
| 4122 | cfg->inputs[i].pin)) |
| 4123 | num_pins++; |
| 4124 | } |
| 4125 | } |
| 4126 | if (num_pins < 2) |
| 4127 | goto end_fill; |
| 4128 | |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 4129 | dacs = spec->multiout.num_dacs; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4130 | for (type = AUTO_PIN_LINE_IN; type >= AUTO_PIN_MIC; type--) { |
| 4131 | for (i = 0; i < cfg->num_inputs; i++) { |
| 4132 | hda_nid_t nid = cfg->inputs[i].pin; |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 4133 | hda_nid_t dac = 0; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4134 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4135 | if (cfg->inputs[i].type != type) |
| 4136 | continue; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4137 | if (!can_be_multiio_pin(codec, location, nid)) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4138 | continue; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4139 | for (j = 0; j < spec->multi_ios; j++) { |
| 4140 | if (nid == spec->multi_io[j].pin) |
| 4141 | break; |
| 4142 | } |
| 4143 | if (j < spec->multi_ios) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4144 | continue; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4145 | |
| 4146 | if (offset && offset + spec->multi_ios < dacs) { |
| 4147 | dac = spec->private_dac_nids[offset + spec->multi_ios]; |
Takashi Iwai | 9c64076 | 2012-12-14 16:15:56 +0100 | [diff] [blame] | 4148 | if (!is_reachable_path(codec, dac, nid)) |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 4149 | dac = 0; |
| 4150 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4151 | if (hardwired) |
| 4152 | dac = get_dac_if_single(codec, nid); |
| 4153 | else if (!dac) |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 4154 | dac = alc_auto_look_for_dac(codec, nid, false); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 4155 | if (!dac) { |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4156 | badness++; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4157 | continue; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 4158 | } |
Takashi Iwai | 965cceb | 2012-12-18 11:46:37 +0100 | [diff] [blame] | 4159 | if (!add_new_nid_path(codec, dac, nid, 0)) { |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 4160 | badness++; |
| 4161 | continue; |
| 4162 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4163 | spec->multi_io[spec->multi_ios].pin = nid; |
| 4164 | spec->multi_io[spec->multi_ios].dac = dac; |
| 4165 | spec->multi_ios++; |
| 4166 | if (spec->multi_ios >= 2) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 4167 | break; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4168 | } |
| 4169 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4170 | end_fill: |
| 4171 | if (badness) |
| 4172 | badness = BAD_MULTI_IO; |
| 4173 | if (old_pins == spec->multi_ios) { |
| 4174 | if (hardwired) |
| 4175 | return 1; /* nothing found */ |
| 4176 | else |
| 4177 | return badness; /* no badness if nothing found */ |
| 4178 | } |
| 4179 | if (!hardwired && spec->multi_ios < 2) { |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 4180 | /* cancel newly assigned paths */ |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 4181 | spec->paths.used -= spec->multi_ios - old_pins; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4182 | spec->multi_ios = old_pins; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 4183 | return badness; |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 4184 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 4185 | |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 4186 | /* assign volume and mute controls */ |
| 4187 | for (i = old_pins; i < spec->multi_ios; i++) |
| 4188 | badness += assign_out_path_ctls(codec, spec->multi_io[i].pin, |
| 4189 | spec->multi_io[i].dac); |
| 4190 | |
| 4191 | return badness; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4192 | } |
| 4193 | |
| 4194 | static int alc_auto_ch_mode_info(struct snd_kcontrol *kcontrol, |
| 4195 | struct snd_ctl_elem_info *uinfo) |
| 4196 | { |
| 4197 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 4198 | struct alc_spec *spec = codec->spec; |
| 4199 | |
| 4200 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
| 4201 | uinfo->count = 1; |
| 4202 | uinfo->value.enumerated.items = spec->multi_ios + 1; |
| 4203 | if (uinfo->value.enumerated.item > spec->multi_ios) |
| 4204 | uinfo->value.enumerated.item = spec->multi_ios; |
| 4205 | sprintf(uinfo->value.enumerated.name, "%dch", |
| 4206 | (uinfo->value.enumerated.item + 1) * 2); |
| 4207 | return 0; |
| 4208 | } |
| 4209 | |
| 4210 | static int alc_auto_ch_mode_get(struct snd_kcontrol *kcontrol, |
| 4211 | struct snd_ctl_elem_value *ucontrol) |
| 4212 | { |
| 4213 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 4214 | struct alc_spec *spec = codec->spec; |
| 4215 | ucontrol->value.enumerated.item[0] = (spec->ext_channel_count - 1) / 2; |
| 4216 | return 0; |
| 4217 | } |
| 4218 | |
| 4219 | static int alc_set_multi_io(struct hda_codec *codec, int idx, bool output) |
| 4220 | { |
| 4221 | struct alc_spec *spec = codec->spec; |
| 4222 | hda_nid_t nid = spec->multi_io[idx].pin; |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 4223 | struct nid_path *path; |
| 4224 | |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame] | 4225 | path = get_nid_path(codec, spec->multi_io[idx].dac, nid); |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 4226 | if (!path) |
| 4227 | return -EINVAL; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4228 | |
Takashi Iwai | 3ebf1e9 | 2012-12-14 18:04:37 +0100 | [diff] [blame] | 4229 | if (path->active == output) |
| 4230 | return 0; |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 4231 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4232 | if (output) { |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 4233 | snd_hda_set_pin_ctl_cache(codec, nid, PIN_OUT); |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 4234 | activate_path(codec, path, true, true); |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4235 | } else { |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 4236 | activate_path(codec, path, false, true); |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 4237 | snd_hda_set_pin_ctl_cache(codec, nid, |
| 4238 | spec->multi_io[idx].ctl_in); |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4239 | } |
| 4240 | return 0; |
| 4241 | } |
| 4242 | |
| 4243 | static int alc_auto_ch_mode_put(struct snd_kcontrol *kcontrol, |
| 4244 | struct snd_ctl_elem_value *ucontrol) |
| 4245 | { |
| 4246 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 4247 | struct alc_spec *spec = codec->spec; |
| 4248 | int i, ch; |
| 4249 | |
| 4250 | ch = ucontrol->value.enumerated.item[0]; |
| 4251 | if (ch < 0 || ch > spec->multi_ios) |
| 4252 | return -EINVAL; |
| 4253 | if (ch == (spec->ext_channel_count - 1) / 2) |
| 4254 | return 0; |
| 4255 | spec->ext_channel_count = (ch + 1) * 2; |
| 4256 | for (i = 0; i < spec->multi_ios; i++) |
| 4257 | alc_set_multi_io(codec, i, i < ch); |
Takashi Iwai | b6adb57 | 2012-12-03 10:30:58 +0100 | [diff] [blame] | 4258 | spec->multiout.max_channels = max(spec->ext_channel_count, |
| 4259 | spec->const_channel_count); |
| 4260 | if (spec->need_dac_fix) |
Takashi Iwai | 7b1655f | 2011-07-14 15:31:21 +0200 | [diff] [blame] | 4261 | spec->multiout.num_dacs = spec->multiout.max_channels / 2; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4262 | return 1; |
| 4263 | } |
| 4264 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 4265 | static const struct snd_kcontrol_new alc_auto_channel_mode_enum = { |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4266 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 4267 | .name = "Channel Mode", |
| 4268 | .info = alc_auto_ch_mode_info, |
| 4269 | .get = alc_auto_ch_mode_get, |
| 4270 | .put = alc_auto_ch_mode_put, |
| 4271 | }; |
| 4272 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4273 | static int alc_auto_add_multi_channel_mode(struct hda_codec *codec) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4274 | { |
| 4275 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4276 | |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 4277 | if (spec->multi_ios > 0) { |
Takashi Iwai | bc54976 | 2012-12-18 15:35:11 +0100 | [diff] [blame] | 4278 | if (!alc_kcontrol_new(spec, NULL, &alc_auto_channel_mode_enum)) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4279 | return -ENOMEM; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4280 | } |
| 4281 | return 0; |
| 4282 | } |
| 4283 | |
Takashi Iwai | 3ebf1e9 | 2012-12-14 18:04:37 +0100 | [diff] [blame] | 4284 | static void alc_auto_init_multi_io(struct hda_codec *codec) |
| 4285 | { |
| 4286 | struct alc_spec *spec = codec->spec; |
| 4287 | int i; |
| 4288 | |
| 4289 | for (i = 0; i < spec->multi_ios; i++) { |
| 4290 | hda_nid_t pin = spec->multi_io[i].pin; |
| 4291 | struct nid_path *path; |
| 4292 | path = get_nid_path(codec, spec->multi_io[i].dac, pin); |
| 4293 | if (!path) |
| 4294 | continue; |
| 4295 | if (!spec->multi_io[i].ctl_in) |
| 4296 | spec->multi_io[i].ctl_in = |
| 4297 | snd_hda_codec_update_cache(codec, pin, 0, |
| 4298 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 4299 | activate_path(codec, path, path->active, true); |
Takashi Iwai | 3ebf1e9 | 2012-12-14 18:04:37 +0100 | [diff] [blame] | 4300 | } |
| 4301 | } |
| 4302 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4303 | /* |
| 4304 | * initialize ADC paths |
| 4305 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4306 | static void alc_auto_init_input_src(struct hda_codec *codec) |
| 4307 | { |
| 4308 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 4309 | struct hda_input_mux *imux = &spec->input_mux; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 4310 | struct nid_path *path; |
| 4311 | int i, c, nums; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4312 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4313 | if (spec->dyn_adc_switch) |
| 4314 | nums = 1; |
| 4315 | else |
| 4316 | nums = spec->num_adc_nids; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 4317 | |
| 4318 | for (c = 0; c < nums; c++) { |
| 4319 | for (i = 0; i < imux->num_items; i++) { |
| 4320 | path = get_nid_path(codec, spec->imux_pins[i], |
| 4321 | get_adc_nid(codec, c, i)); |
| 4322 | if (path) { |
| 4323 | bool active = path->active; |
| 4324 | if (i == spec->cur_mux[c]) |
| 4325 | active = true; |
| 4326 | activate_path(codec, path, active, false); |
| 4327 | } |
| 4328 | } |
| 4329 | } |
| 4330 | |
| 4331 | alc_inv_dmic_sync(codec, true); |
| 4332 | if (spec->shared_mic_hp) |
| 4333 | update_shared_mic_hp(codec, spec->cur_mux[0]); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4334 | } |
| 4335 | |
| 4336 | /* add mic boosts if needed */ |
| 4337 | static int alc_auto_add_mic_boost(struct hda_codec *codec) |
| 4338 | { |
| 4339 | struct alc_spec *spec = codec->spec; |
| 4340 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 4341 | int i, err; |
| 4342 | int type_idx = 0; |
| 4343 | hda_nid_t nid; |
| 4344 | const char *prev_label = NULL; |
| 4345 | |
| 4346 | for (i = 0; i < cfg->num_inputs; i++) { |
| 4347 | if (cfg->inputs[i].type > AUTO_PIN_MIC) |
| 4348 | break; |
| 4349 | nid = cfg->inputs[i].pin; |
| 4350 | if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) { |
| 4351 | const char *label; |
| 4352 | char boost_label[32]; |
Takashi Iwai | 8dd4867 | 2012-12-14 18:19:04 +0100 | [diff] [blame] | 4353 | struct nid_path *path; |
| 4354 | unsigned int val; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4355 | |
| 4356 | label = hda_get_autocfg_input_label(codec, cfg, i); |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 4357 | if (spec->shared_mic_hp && !strcmp(label, "Misc")) |
| 4358 | label = "Headphone Mic"; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4359 | if (prev_label && !strcmp(label, prev_label)) |
| 4360 | type_idx++; |
| 4361 | else |
| 4362 | type_idx = 0; |
| 4363 | prev_label = label; |
| 4364 | |
| 4365 | snprintf(boost_label, sizeof(boost_label), |
| 4366 | "%s Boost Volume", label); |
Takashi Iwai | 8dd4867 | 2012-12-14 18:19:04 +0100 | [diff] [blame] | 4367 | val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4368 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
Takashi Iwai | 8dd4867 | 2012-12-14 18:19:04 +0100 | [diff] [blame] | 4369 | boost_label, type_idx, val); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4370 | if (err < 0) |
| 4371 | return err; |
Takashi Iwai | 8dd4867 | 2012-12-14 18:19:04 +0100 | [diff] [blame] | 4372 | |
| 4373 | path = get_nid_path(codec, nid, 0); |
| 4374 | if (path) |
| 4375 | path->ctls[NID_PATH_BOOST_CTL] = val; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4376 | } |
| 4377 | } |
| 4378 | return 0; |
| 4379 | } |
| 4380 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4381 | /* |
Takashi Iwai | e477062 | 2011-07-08 11:11:35 +0200 | [diff] [blame] | 4382 | * standard auto-parser initializations |
| 4383 | */ |
| 4384 | static void alc_auto_init_std(struct hda_codec *codec) |
| 4385 | { |
Takashi Iwai | e477062 | 2011-07-08 11:11:35 +0200 | [diff] [blame] | 4386 | alc_auto_init_multi_out(codec); |
| 4387 | alc_auto_init_extra_out(codec); |
Takashi Iwai | 3ebf1e9 | 2012-12-14 18:04:37 +0100 | [diff] [blame] | 4388 | alc_auto_init_multi_io(codec); |
Takashi Iwai | e477062 | 2011-07-08 11:11:35 +0200 | [diff] [blame] | 4389 | alc_auto_init_analog_input(codec); |
| 4390 | alc_auto_init_input_src(codec); |
| 4391 | alc_auto_init_digital(codec); |
Takashi Iwai | 2eab694 | 2012-12-18 15:30:41 +0100 | [diff] [blame] | 4392 | /* call init functions of standard auto-mute helpers */ |
| 4393 | alc_hp_automute(codec, NULL); |
| 4394 | alc_line_automute(codec, NULL); |
| 4395 | alc_mic_automute(codec, NULL); |
Takashi Iwai | e477062 | 2011-07-08 11:11:35 +0200 | [diff] [blame] | 4396 | } |
| 4397 | |
| 4398 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4399 | * Digital-beep handlers |
| 4400 | */ |
| 4401 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
| 4402 | #define set_beep_amp(spec, nid, idx, dir) \ |
| 4403 | ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir)) |
| 4404 | |
| 4405 | static const struct snd_pci_quirk beep_white_list[] = { |
Duncan Roe | 7110005 | 2012-10-10 14:19:50 +0200 | [diff] [blame] | 4406 | SND_PCI_QUIRK(0x1043, 0x103c, "ASUS", 1), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4407 | SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1), |
| 4408 | SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1), |
| 4409 | SND_PCI_QUIRK(0x1043, 0x831a, "EeePC", 1), |
| 4410 | SND_PCI_QUIRK(0x1043, 0x834a, "EeePC", 1), |
Takashi Iwai | 78f8baf | 2012-03-06 14:02:32 +0100 | [diff] [blame] | 4411 | SND_PCI_QUIRK(0x1458, 0xa002, "GA-MA790X", 1), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4412 | SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1), |
| 4413 | {} |
| 4414 | }; |
| 4415 | |
| 4416 | static inline int has_cdefine_beep(struct hda_codec *codec) |
| 4417 | { |
| 4418 | struct alc_spec *spec = codec->spec; |
| 4419 | const struct snd_pci_quirk *q; |
| 4420 | q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list); |
| 4421 | if (q) |
| 4422 | return q->value; |
| 4423 | return spec->cdefine.enable_pcbeep; |
| 4424 | } |
| 4425 | #else |
| 4426 | #define set_beep_amp(spec, nid, idx, dir) /* NOP */ |
| 4427 | #define has_cdefine_beep(codec) 0 |
| 4428 | #endif |
| 4429 | |
| 4430 | /* parse the BIOS configuration and set up the alc_spec */ |
| 4431 | /* return 1 if successful, 0 if the proper config is not found, |
| 4432 | * or a negative error code |
| 4433 | */ |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4434 | static int alc_parse_auto_config(struct hda_codec *codec, |
| 4435 | const hda_nid_t *ignore_nids, |
| 4436 | const hda_nid_t *ssid_nids) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4437 | { |
| 4438 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4439 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4440 | int err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4441 | |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 4442 | err = snd_hda_parse_pin_defcfg(codec, cfg, ignore_nids, |
| 4443 | spec->parse_flags); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4444 | if (err < 0) |
| 4445 | return err; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4446 | if (!cfg->line_outs) { |
| 4447 | if (cfg->dig_outs || cfg->dig_in_pin) { |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4448 | spec->multiout.max_channels = 2; |
| 4449 | spec->no_analog = 1; |
| 4450 | goto dig_only; |
| 4451 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4452 | return 0; /* can't find valid BIOS pin config */ |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4453 | } |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4454 | |
Takashi Iwai | e427c23 | 2012-07-29 10:04:08 +0200 | [diff] [blame] | 4455 | if (!spec->no_primary_hp && |
| 4456 | cfg->line_out_type == AUTO_PIN_SPEAKER_OUT && |
Takashi Iwai | 0650367 | 2011-10-06 08:27:19 +0200 | [diff] [blame] | 4457 | cfg->line_outs <= cfg->hp_outs) { |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4458 | /* use HP as primary out */ |
| 4459 | cfg->speaker_outs = cfg->line_outs; |
| 4460 | memcpy(cfg->speaker_pins, cfg->line_out_pins, |
| 4461 | sizeof(cfg->speaker_pins)); |
| 4462 | cfg->line_outs = cfg->hp_outs; |
| 4463 | memcpy(cfg->line_out_pins, cfg->hp_pins, sizeof(cfg->hp_pins)); |
| 4464 | cfg->hp_outs = 0; |
| 4465 | memset(cfg->hp_pins, 0, sizeof(cfg->hp_pins)); |
| 4466 | cfg->line_out_type = AUTO_PIN_HP_OUT; |
| 4467 | } |
| 4468 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4469 | err = alc_auto_fill_dac_nids(codec); |
| 4470 | if (err < 0) |
| 4471 | return err; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4472 | err = alc_auto_add_multi_channel_mode(codec); |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4473 | if (err < 0) |
| 4474 | return err; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4475 | err = alc_auto_create_multi_out_ctls(codec, cfg); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4476 | if (err < 0) |
| 4477 | return err; |
| 4478 | err = alc_auto_create_hp_out(codec); |
| 4479 | if (err < 0) |
| 4480 | return err; |
| 4481 | err = alc_auto_create_speaker_out(codec); |
| 4482 | if (err < 0) |
| 4483 | return err; |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 4484 | err = alc_auto_create_shared_input(codec); |
| 4485 | if (err < 0) |
| 4486 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4487 | err = alc_auto_create_input_ctls(codec); |
| 4488 | if (err < 0) |
| 4489 | return err; |
| 4490 | |
Takashi Iwai | b6adb57 | 2012-12-03 10:30:58 +0100 | [diff] [blame] | 4491 | /* check the multiple speaker pins */ |
| 4492 | if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) |
| 4493 | spec->const_channel_count = cfg->line_outs * 2; |
| 4494 | else |
| 4495 | spec->const_channel_count = cfg->speaker_outs * 2; |
| 4496 | |
| 4497 | if (spec->multi_ios > 0) |
| 4498 | spec->multiout.max_channels = max(spec->ext_channel_count, |
| 4499 | spec->const_channel_count); |
| 4500 | else |
| 4501 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4502 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4503 | dig_only: |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4504 | alc_auto_parse_digital(codec); |
| 4505 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4506 | if (ssid_nids) |
| 4507 | alc_ssid_check(codec, ssid_nids); |
| 4508 | |
| 4509 | if (!spec->no_analog) { |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 4510 | err = alc_init_automute(codec); |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 4511 | if (err < 0) |
| 4512 | return err; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 4513 | |
| 4514 | err = check_dyn_adc_switch(codec); |
| 4515 | if (err < 0) |
| 4516 | return err; |
| 4517 | |
| 4518 | if (!spec->shared_mic_hp) { |
| 4519 | err = alc_init_auto_mic(codec); |
| 4520 | if (err < 0) |
| 4521 | return err; |
| 4522 | } |
| 4523 | |
| 4524 | err = create_capture_mixers(codec); |
| 4525 | if (err < 0) |
| 4526 | return err; |
| 4527 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4528 | err = alc_auto_add_mic_boost(codec); |
| 4529 | if (err < 0) |
| 4530 | return err; |
| 4531 | } |
| 4532 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4533 | if (spec->kctls.list) |
| 4534 | add_mixer(spec, spec->kctls.list); |
| 4535 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4536 | return 1; |
| 4537 | } |
| 4538 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 4539 | /* common preparation job for alc_spec */ |
| 4540 | static int alc_alloc_spec(struct hda_codec *codec, hda_nid_t mixer_nid) |
| 4541 | { |
| 4542 | struct alc_spec *spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 4543 | int err; |
| 4544 | |
| 4545 | if (!spec) |
| 4546 | return -ENOMEM; |
| 4547 | codec->spec = spec; |
Takashi Iwai | 1098b7c | 2012-12-17 20:03:15 +0100 | [diff] [blame] | 4548 | codec->single_adc_amp = 1; |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 4549 | spec->mixer_nid = mixer_nid; |
Takashi Iwai | 361dab3 | 2012-05-09 14:35:27 +0200 | [diff] [blame] | 4550 | snd_array_init(&spec->kctls, sizeof(struct snd_kcontrol_new), 32); |
| 4551 | snd_array_init(&spec->bind_ctls, sizeof(struct hda_bind_ctls *), 8); |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 4552 | snd_array_init(&spec->paths, sizeof(struct nid_path), 8); |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 4553 | |
| 4554 | err = alc_codec_rename_from_preset(codec); |
| 4555 | if (err < 0) { |
| 4556 | kfree(spec); |
| 4557 | return err; |
| 4558 | } |
| 4559 | return 0; |
| 4560 | } |
| 4561 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4562 | static int alc880_parse_auto_config(struct hda_codec *codec) |
| 4563 | { |
| 4564 | static const hda_nid_t alc880_ignore[] = { 0x1d, 0 }; |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 4565 | static const hda_nid_t alc880_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4566 | return alc_parse_auto_config(codec, alc880_ignore, alc880_ssids); |
| 4567 | } |
| 4568 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4569 | /* |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4570 | * ALC880 fix-ups |
| 4571 | */ |
| 4572 | enum { |
Takashi Iwai | 411225a | 2012-02-20 17:48:19 +0100 | [diff] [blame] | 4573 | ALC880_FIXUP_GPIO1, |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4574 | ALC880_FIXUP_GPIO2, |
| 4575 | ALC880_FIXUP_MEDION_RIM, |
Takashi Iwai | dc6af52 | 2012-02-17 16:18:59 +0100 | [diff] [blame] | 4576 | ALC880_FIXUP_LG, |
Takashi Iwai | f02aab5 | 2012-02-17 16:33:56 +0100 | [diff] [blame] | 4577 | ALC880_FIXUP_W810, |
Takashi Iwai | 27e917f | 2012-02-17 17:49:54 +0100 | [diff] [blame] | 4578 | ALC880_FIXUP_EAPD_COEF, |
Takashi Iwai | b9368f5 | 2012-02-17 17:54:44 +0100 | [diff] [blame] | 4579 | ALC880_FIXUP_TCL_S700, |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 4580 | ALC880_FIXUP_VOL_KNOB, |
| 4581 | ALC880_FIXUP_FUJITSU, |
Takashi Iwai | ba53381 | 2012-02-20 16:36:52 +0100 | [diff] [blame] | 4582 | ALC880_FIXUP_F1734, |
Takashi Iwai | 817de92 | 2012-02-20 17:20:48 +0100 | [diff] [blame] | 4583 | ALC880_FIXUP_UNIWILL, |
Takashi Iwai | 967b88c | 2012-02-20 17:31:02 +0100 | [diff] [blame] | 4584 | ALC880_FIXUP_UNIWILL_DIG, |
Takashi Iwai | 96e225f | 2012-02-20 17:41:51 +0100 | [diff] [blame] | 4585 | ALC880_FIXUP_Z71V, |
Takashi Iwai | 67b6ec3 | 2012-02-20 18:20:42 +0100 | [diff] [blame] | 4586 | ALC880_FIXUP_3ST_BASE, |
| 4587 | ALC880_FIXUP_3ST, |
| 4588 | ALC880_FIXUP_3ST_DIG, |
| 4589 | ALC880_FIXUP_5ST_BASE, |
| 4590 | ALC880_FIXUP_5ST, |
| 4591 | ALC880_FIXUP_5ST_DIG, |
| 4592 | ALC880_FIXUP_6ST_BASE, |
| 4593 | ALC880_FIXUP_6ST, |
| 4594 | ALC880_FIXUP_6ST_DIG, |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4595 | }; |
| 4596 | |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 4597 | /* enable the volume-knob widget support on NID 0x21 */ |
| 4598 | static void alc880_fixup_vol_knob(struct hda_codec *codec, |
| 4599 | const struct alc_fixup *fix, int action) |
| 4600 | { |
| 4601 | if (action == ALC_FIXUP_ACT_PROBE) |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 4602 | snd_hda_jack_detect_enable_callback(codec, 0x21, ALC_DCVOL_EVENT, alc_update_knob_master); |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 4603 | } |
| 4604 | |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4605 | static const struct alc_fixup alc880_fixups[] = { |
Takashi Iwai | 411225a | 2012-02-20 17:48:19 +0100 | [diff] [blame] | 4606 | [ALC880_FIXUP_GPIO1] = { |
| 4607 | .type = ALC_FIXUP_VERBS, |
| 4608 | .v.verbs = alc_gpio1_init_verbs, |
| 4609 | }, |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4610 | [ALC880_FIXUP_GPIO2] = { |
| 4611 | .type = ALC_FIXUP_VERBS, |
| 4612 | .v.verbs = alc_gpio2_init_verbs, |
| 4613 | }, |
| 4614 | [ALC880_FIXUP_MEDION_RIM] = { |
| 4615 | .type = ALC_FIXUP_VERBS, |
| 4616 | .v.verbs = (const struct hda_verb[]) { |
| 4617 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 4618 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 }, |
| 4619 | { } |
| 4620 | }, |
| 4621 | .chained = true, |
| 4622 | .chain_id = ALC880_FIXUP_GPIO2, |
| 4623 | }, |
Takashi Iwai | dc6af52 | 2012-02-17 16:18:59 +0100 | [diff] [blame] | 4624 | [ALC880_FIXUP_LG] = { |
| 4625 | .type = ALC_FIXUP_PINS, |
| 4626 | .v.pins = (const struct alc_pincfg[]) { |
| 4627 | /* disable bogus unused pins */ |
| 4628 | { 0x16, 0x411111f0 }, |
| 4629 | { 0x18, 0x411111f0 }, |
| 4630 | { 0x1a, 0x411111f0 }, |
| 4631 | { } |
| 4632 | } |
| 4633 | }, |
Takashi Iwai | f02aab5 | 2012-02-17 16:33:56 +0100 | [diff] [blame] | 4634 | [ALC880_FIXUP_W810] = { |
| 4635 | .type = ALC_FIXUP_PINS, |
| 4636 | .v.pins = (const struct alc_pincfg[]) { |
| 4637 | /* disable bogus unused pins */ |
| 4638 | { 0x17, 0x411111f0 }, |
| 4639 | { } |
| 4640 | }, |
| 4641 | .chained = true, |
| 4642 | .chain_id = ALC880_FIXUP_GPIO2, |
| 4643 | }, |
Takashi Iwai | 27e917f | 2012-02-17 17:49:54 +0100 | [diff] [blame] | 4644 | [ALC880_FIXUP_EAPD_COEF] = { |
| 4645 | .type = ALC_FIXUP_VERBS, |
| 4646 | .v.verbs = (const struct hda_verb[]) { |
| 4647 | /* change to EAPD mode */ |
| 4648 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 4649 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 }, |
| 4650 | {} |
| 4651 | }, |
| 4652 | }, |
Takashi Iwai | b9368f5 | 2012-02-17 17:54:44 +0100 | [diff] [blame] | 4653 | [ALC880_FIXUP_TCL_S700] = { |
| 4654 | .type = ALC_FIXUP_VERBS, |
| 4655 | .v.verbs = (const struct hda_verb[]) { |
| 4656 | /* change to EAPD mode */ |
| 4657 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 4658 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 }, |
| 4659 | {} |
| 4660 | }, |
| 4661 | .chained = true, |
| 4662 | .chain_id = ALC880_FIXUP_GPIO2, |
| 4663 | }, |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 4664 | [ALC880_FIXUP_VOL_KNOB] = { |
| 4665 | .type = ALC_FIXUP_FUNC, |
| 4666 | .v.func = alc880_fixup_vol_knob, |
| 4667 | }, |
| 4668 | [ALC880_FIXUP_FUJITSU] = { |
| 4669 | /* override all pins as BIOS on old Amilo is broken */ |
| 4670 | .type = ALC_FIXUP_PINS, |
| 4671 | .v.pins = (const struct alc_pincfg[]) { |
| 4672 | { 0x14, 0x0121411f }, /* HP */ |
| 4673 | { 0x15, 0x99030120 }, /* speaker */ |
| 4674 | { 0x16, 0x99030130 }, /* bass speaker */ |
| 4675 | { 0x17, 0x411111f0 }, /* N/A */ |
| 4676 | { 0x18, 0x411111f0 }, /* N/A */ |
| 4677 | { 0x19, 0x01a19950 }, /* mic-in */ |
| 4678 | { 0x1a, 0x411111f0 }, /* N/A */ |
| 4679 | { 0x1b, 0x411111f0 }, /* N/A */ |
| 4680 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4681 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4682 | { 0x1e, 0x01454140 }, /* SPDIF out */ |
| 4683 | { } |
| 4684 | }, |
| 4685 | .chained = true, |
| 4686 | .chain_id = ALC880_FIXUP_VOL_KNOB, |
| 4687 | }, |
Takashi Iwai | ba53381 | 2012-02-20 16:36:52 +0100 | [diff] [blame] | 4688 | [ALC880_FIXUP_F1734] = { |
| 4689 | /* almost compatible with FUJITSU, but no bass and SPDIF */ |
| 4690 | .type = ALC_FIXUP_PINS, |
| 4691 | .v.pins = (const struct alc_pincfg[]) { |
| 4692 | { 0x14, 0x0121411f }, /* HP */ |
| 4693 | { 0x15, 0x99030120 }, /* speaker */ |
| 4694 | { 0x16, 0x411111f0 }, /* N/A */ |
| 4695 | { 0x17, 0x411111f0 }, /* N/A */ |
| 4696 | { 0x18, 0x411111f0 }, /* N/A */ |
| 4697 | { 0x19, 0x01a19950 }, /* mic-in */ |
| 4698 | { 0x1a, 0x411111f0 }, /* N/A */ |
| 4699 | { 0x1b, 0x411111f0 }, /* N/A */ |
| 4700 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4701 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4702 | { 0x1e, 0x411111f0 }, /* N/A */ |
| 4703 | { } |
| 4704 | }, |
| 4705 | .chained = true, |
| 4706 | .chain_id = ALC880_FIXUP_VOL_KNOB, |
| 4707 | }, |
Takashi Iwai | 817de92 | 2012-02-20 17:20:48 +0100 | [diff] [blame] | 4708 | [ALC880_FIXUP_UNIWILL] = { |
| 4709 | /* need to fix HP and speaker pins to be parsed correctly */ |
| 4710 | .type = ALC_FIXUP_PINS, |
| 4711 | .v.pins = (const struct alc_pincfg[]) { |
| 4712 | { 0x14, 0x0121411f }, /* HP */ |
| 4713 | { 0x15, 0x99030120 }, /* speaker */ |
| 4714 | { 0x16, 0x99030130 }, /* bass speaker */ |
| 4715 | { } |
| 4716 | }, |
| 4717 | }, |
Takashi Iwai | 967b88c | 2012-02-20 17:31:02 +0100 | [diff] [blame] | 4718 | [ALC880_FIXUP_UNIWILL_DIG] = { |
| 4719 | .type = ALC_FIXUP_PINS, |
| 4720 | .v.pins = (const struct alc_pincfg[]) { |
| 4721 | /* disable bogus unused pins */ |
| 4722 | { 0x17, 0x411111f0 }, |
| 4723 | { 0x19, 0x411111f0 }, |
| 4724 | { 0x1b, 0x411111f0 }, |
| 4725 | { 0x1f, 0x411111f0 }, |
| 4726 | { } |
| 4727 | } |
| 4728 | }, |
Takashi Iwai | 96e225f | 2012-02-20 17:41:51 +0100 | [diff] [blame] | 4729 | [ALC880_FIXUP_Z71V] = { |
| 4730 | .type = ALC_FIXUP_PINS, |
| 4731 | .v.pins = (const struct alc_pincfg[]) { |
| 4732 | /* set up the whole pins as BIOS is utterly broken */ |
| 4733 | { 0x14, 0x99030120 }, /* speaker */ |
| 4734 | { 0x15, 0x0121411f }, /* HP */ |
| 4735 | { 0x16, 0x411111f0 }, /* N/A */ |
| 4736 | { 0x17, 0x411111f0 }, /* N/A */ |
| 4737 | { 0x18, 0x01a19950 }, /* mic-in */ |
| 4738 | { 0x19, 0x411111f0 }, /* N/A */ |
| 4739 | { 0x1a, 0x01813031 }, /* line-in */ |
| 4740 | { 0x1b, 0x411111f0 }, /* N/A */ |
| 4741 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4742 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4743 | { 0x1e, 0x0144111e }, /* SPDIF */ |
| 4744 | { } |
| 4745 | } |
| 4746 | }, |
Takashi Iwai | 67b6ec3 | 2012-02-20 18:20:42 +0100 | [diff] [blame] | 4747 | [ALC880_FIXUP_3ST_BASE] = { |
| 4748 | .type = ALC_FIXUP_PINS, |
| 4749 | .v.pins = (const struct alc_pincfg[]) { |
| 4750 | { 0x14, 0x01014010 }, /* line-out */ |
| 4751 | { 0x15, 0x411111f0 }, /* N/A */ |
| 4752 | { 0x16, 0x411111f0 }, /* N/A */ |
| 4753 | { 0x17, 0x411111f0 }, /* N/A */ |
| 4754 | { 0x18, 0x01a19c30 }, /* mic-in */ |
| 4755 | { 0x19, 0x0121411f }, /* HP */ |
| 4756 | { 0x1a, 0x01813031 }, /* line-in */ |
| 4757 | { 0x1b, 0x02a19c40 }, /* front-mic */ |
| 4758 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4759 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4760 | /* 0x1e is filled in below */ |
| 4761 | { 0x1f, 0x411111f0 }, /* N/A */ |
| 4762 | { } |
| 4763 | } |
| 4764 | }, |
| 4765 | [ALC880_FIXUP_3ST] = { |
| 4766 | .type = ALC_FIXUP_PINS, |
| 4767 | .v.pins = (const struct alc_pincfg[]) { |
| 4768 | { 0x1e, 0x411111f0 }, /* N/A */ |
| 4769 | { } |
| 4770 | }, |
| 4771 | .chained = true, |
| 4772 | .chain_id = ALC880_FIXUP_3ST_BASE, |
| 4773 | }, |
| 4774 | [ALC880_FIXUP_3ST_DIG] = { |
| 4775 | .type = ALC_FIXUP_PINS, |
| 4776 | .v.pins = (const struct alc_pincfg[]) { |
| 4777 | { 0x1e, 0x0144111e }, /* SPDIF */ |
| 4778 | { } |
| 4779 | }, |
| 4780 | .chained = true, |
| 4781 | .chain_id = ALC880_FIXUP_3ST_BASE, |
| 4782 | }, |
| 4783 | [ALC880_FIXUP_5ST_BASE] = { |
| 4784 | .type = ALC_FIXUP_PINS, |
| 4785 | .v.pins = (const struct alc_pincfg[]) { |
| 4786 | { 0x14, 0x01014010 }, /* front */ |
| 4787 | { 0x15, 0x411111f0 }, /* N/A */ |
| 4788 | { 0x16, 0x01011411 }, /* CLFE */ |
| 4789 | { 0x17, 0x01016412 }, /* surr */ |
| 4790 | { 0x18, 0x01a19c30 }, /* mic-in */ |
| 4791 | { 0x19, 0x0121411f }, /* HP */ |
| 4792 | { 0x1a, 0x01813031 }, /* line-in */ |
| 4793 | { 0x1b, 0x02a19c40 }, /* front-mic */ |
| 4794 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4795 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4796 | /* 0x1e is filled in below */ |
| 4797 | { 0x1f, 0x411111f0 }, /* N/A */ |
| 4798 | { } |
| 4799 | } |
| 4800 | }, |
| 4801 | [ALC880_FIXUP_5ST] = { |
| 4802 | .type = ALC_FIXUP_PINS, |
| 4803 | .v.pins = (const struct alc_pincfg[]) { |
| 4804 | { 0x1e, 0x411111f0 }, /* N/A */ |
| 4805 | { } |
| 4806 | }, |
| 4807 | .chained = true, |
| 4808 | .chain_id = ALC880_FIXUP_5ST_BASE, |
| 4809 | }, |
| 4810 | [ALC880_FIXUP_5ST_DIG] = { |
| 4811 | .type = ALC_FIXUP_PINS, |
| 4812 | .v.pins = (const struct alc_pincfg[]) { |
| 4813 | { 0x1e, 0x0144111e }, /* SPDIF */ |
| 4814 | { } |
| 4815 | }, |
| 4816 | .chained = true, |
| 4817 | .chain_id = ALC880_FIXUP_5ST_BASE, |
| 4818 | }, |
| 4819 | [ALC880_FIXUP_6ST_BASE] = { |
| 4820 | .type = ALC_FIXUP_PINS, |
| 4821 | .v.pins = (const struct alc_pincfg[]) { |
| 4822 | { 0x14, 0x01014010 }, /* front */ |
| 4823 | { 0x15, 0x01016412 }, /* surr */ |
| 4824 | { 0x16, 0x01011411 }, /* CLFE */ |
| 4825 | { 0x17, 0x01012414 }, /* side */ |
| 4826 | { 0x18, 0x01a19c30 }, /* mic-in */ |
| 4827 | { 0x19, 0x02a19c40 }, /* front-mic */ |
| 4828 | { 0x1a, 0x01813031 }, /* line-in */ |
| 4829 | { 0x1b, 0x0121411f }, /* HP */ |
| 4830 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4831 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4832 | /* 0x1e is filled in below */ |
| 4833 | { 0x1f, 0x411111f0 }, /* N/A */ |
| 4834 | { } |
| 4835 | } |
| 4836 | }, |
| 4837 | [ALC880_FIXUP_6ST] = { |
| 4838 | .type = ALC_FIXUP_PINS, |
| 4839 | .v.pins = (const struct alc_pincfg[]) { |
| 4840 | { 0x1e, 0x411111f0 }, /* N/A */ |
| 4841 | { } |
| 4842 | }, |
| 4843 | .chained = true, |
| 4844 | .chain_id = ALC880_FIXUP_6ST_BASE, |
| 4845 | }, |
| 4846 | [ALC880_FIXUP_6ST_DIG] = { |
| 4847 | .type = ALC_FIXUP_PINS, |
| 4848 | .v.pins = (const struct alc_pincfg[]) { |
| 4849 | { 0x1e, 0x0144111e }, /* SPDIF */ |
| 4850 | { } |
| 4851 | }, |
| 4852 | .chained = true, |
| 4853 | .chain_id = ALC880_FIXUP_6ST_BASE, |
| 4854 | }, |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4855 | }; |
| 4856 | |
| 4857 | static const struct snd_pci_quirk alc880_fixup_tbl[] = { |
Takashi Iwai | f02aab5 | 2012-02-17 16:33:56 +0100 | [diff] [blame] | 4858 | SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_FIXUP_W810), |
Takashi Iwai | 96e225f | 2012-02-20 17:41:51 +0100 | [diff] [blame] | 4859 | SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_FIXUP_Z71V), |
Takashi Iwai | 29e3fdc | 2012-02-20 17:56:57 +0100 | [diff] [blame] | 4860 | SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_FIXUP_GPIO1), |
| 4861 | SND_PCI_QUIRK(0x1558, 0x5401, "Clevo GPIO2", ALC880_FIXUP_GPIO2), |
Takashi Iwai | 27e917f | 2012-02-17 17:49:54 +0100 | [diff] [blame] | 4862 | SND_PCI_QUIRK_VENDOR(0x1558, "Clevo", ALC880_FIXUP_EAPD_COEF), |
Takashi Iwai | 967b88c | 2012-02-20 17:31:02 +0100 | [diff] [blame] | 4863 | SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_FIXUP_UNIWILL_DIG), |
Takashi Iwai | ba53381 | 2012-02-20 16:36:52 +0100 | [diff] [blame] | 4864 | SND_PCI_QUIRK(0x1584, 0x9054, "Uniwill", ALC880_FIXUP_F1734), |
Takashi Iwai | 817de92 | 2012-02-20 17:20:48 +0100 | [diff] [blame] | 4865 | SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_FIXUP_UNIWILL), |
Takashi Iwai | 7833c7e | 2012-02-20 17:11:38 +0100 | [diff] [blame] | 4866 | SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_FIXUP_VOL_KNOB), |
Takashi Iwai | f02aab5 | 2012-02-17 16:33:56 +0100 | [diff] [blame] | 4867 | SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_FIXUP_W810), |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4868 | SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_FIXUP_MEDION_RIM), |
Takashi Iwai | ba53381 | 2012-02-20 16:36:52 +0100 | [diff] [blame] | 4869 | SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_FIXUP_F1734), |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 4870 | SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FIXUP_FUJITSU), |
Takashi Iwai | ba53381 | 2012-02-20 16:36:52 +0100 | [diff] [blame] | 4871 | SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_FIXUP_F1734), |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 4872 | SND_PCI_QUIRK(0x1734, 0x10b0, "FSC Amilo Pi1556", ALC880_FIXUP_FUJITSU), |
Takashi Iwai | dc6af52 | 2012-02-17 16:18:59 +0100 | [diff] [blame] | 4873 | SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_FIXUP_LG), |
| 4874 | SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_FIXUP_LG), |
| 4875 | SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_FIXUP_LG), |
Takashi Iwai | b9368f5 | 2012-02-17 17:54:44 +0100 | [diff] [blame] | 4876 | SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_FIXUP_TCL_S700), |
Takashi Iwai | 67b6ec3 | 2012-02-20 18:20:42 +0100 | [diff] [blame] | 4877 | |
| 4878 | /* Below is the copied entries from alc880_quirks.c. |
| 4879 | * It's not quite sure whether BIOS sets the correct pin-config table |
| 4880 | * on these machines, thus they are kept to be compatible with |
| 4881 | * the old static quirks. Once when it's confirmed to work without |
| 4882 | * these overrides, it'd be better to remove. |
| 4883 | */ |
| 4884 | SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_FIXUP_5ST_DIG), |
| 4885 | SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_FIXUP_6ST), |
| 4886 | SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_FIXUP_3ST_DIG), |
| 4887 | SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_FIXUP_6ST_DIG), |
| 4888 | SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_FIXUP_6ST_DIG), |
| 4889 | SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_FIXUP_6ST_DIG), |
| 4890 | SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_FIXUP_3ST_DIG), |
| 4891 | SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_FIXUP_3ST), |
| 4892 | SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_FIXUP_6ST_DIG), |
| 4893 | SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_FIXUP_3ST), |
| 4894 | SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_FIXUP_3ST), |
| 4895 | SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_FIXUP_5ST), |
| 4896 | SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_FIXUP_5ST), |
| 4897 | SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_FIXUP_5ST), |
| 4898 | SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_FIXUP_6ST_DIG), |
| 4899 | SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_FIXUP_6ST_DIG), |
| 4900 | SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_FIXUP_6ST_DIG), |
| 4901 | SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_FIXUP_6ST_DIG), |
| 4902 | SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_FIXUP_5ST_DIG), |
| 4903 | SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_FIXUP_5ST_DIG), |
| 4904 | SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_FIXUP_5ST_DIG), |
| 4905 | SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_FIXUP_6ST_DIG), /* broken BIOS */ |
| 4906 | SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_FIXUP_6ST_DIG), |
| 4907 | SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4908 | SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4909 | SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4910 | SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_FIXUP_3ST_DIG), |
| 4911 | SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4912 | SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_FIXUP_3ST_DIG), |
| 4913 | SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_FIXUP_3ST_DIG), |
| 4914 | SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4915 | SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4916 | SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4917 | /* default Intel */ |
| 4918 | SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_FIXUP_3ST), |
| 4919 | SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_FIXUP_5ST_DIG), |
| 4920 | SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_FIXUP_6ST_DIG), |
| 4921 | {} |
| 4922 | }; |
| 4923 | |
| 4924 | static const struct alc_model_fixup alc880_fixup_models[] = { |
| 4925 | {.id = ALC880_FIXUP_3ST, .name = "3stack"}, |
| 4926 | {.id = ALC880_FIXUP_3ST_DIG, .name = "3stack-digout"}, |
| 4927 | {.id = ALC880_FIXUP_5ST, .name = "5stack"}, |
| 4928 | {.id = ALC880_FIXUP_5ST_DIG, .name = "5stack-digout"}, |
| 4929 | {.id = ALC880_FIXUP_6ST, .name = "6stack"}, |
| 4930 | {.id = ALC880_FIXUP_6ST_DIG, .name = "6stack-digout"}, |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4931 | {} |
| 4932 | }; |
| 4933 | |
| 4934 | |
| 4935 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4936 | * OK, here we have finally the patch for ALC880 |
| 4937 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4938 | static int patch_alc880(struct hda_codec *codec) |
| 4939 | { |
| 4940 | struct alc_spec *spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4941 | int err; |
| 4942 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 4943 | err = alc_alloc_spec(codec, 0x0b); |
| 4944 | if (err < 0) |
| 4945 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4946 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 4947 | spec = codec->spec; |
Takashi Iwai | 7b1655f | 2011-07-14 15:31:21 +0200 | [diff] [blame] | 4948 | spec->need_dac_fix = 1; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4949 | |
Takashi Iwai | 67b6ec3 | 2012-02-20 18:20:42 +0100 | [diff] [blame] | 4950 | alc_pick_fixup(codec, alc880_fixup_models, alc880_fixup_tbl, |
| 4951 | alc880_fixups); |
| 4952 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4953 | |
Takashi Iwai | 67b6ec3 | 2012-02-20 18:20:42 +0100 | [diff] [blame] | 4954 | /* automatic parse from the BIOS config */ |
| 4955 | err = alc880_parse_auto_config(codec); |
| 4956 | if (err < 0) |
| 4957 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4958 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4959 | if (!spec->no_analog) { |
| 4960 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 4961 | if (err < 0) |
| 4962 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4963 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
| 4964 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4965 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4966 | codec->patch_ops = alc_patch_ops; |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 4967 | codec->patch_ops.unsol_event = alc880_unsol_event; |
| 4968 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4969 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 4970 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 4971 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4972 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 4973 | |
| 4974 | error: |
| 4975 | alc_free(codec); |
| 4976 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4977 | } |
| 4978 | |
| 4979 | |
| 4980 | /* |
| 4981 | * ALC260 support |
| 4982 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4983 | static int alc260_parse_auto_config(struct hda_codec *codec) |
| 4984 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4985 | static const hda_nid_t alc260_ignore[] = { 0x17, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4986 | static const hda_nid_t alc260_ssids[] = { 0x10, 0x15, 0x0f, 0 }; |
| 4987 | return alc_parse_auto_config(codec, alc260_ignore, alc260_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4988 | } |
| 4989 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4990 | /* |
| 4991 | * Pin config fixes |
| 4992 | */ |
| 4993 | enum { |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 4994 | ALC260_FIXUP_HP_DC5750, |
| 4995 | ALC260_FIXUP_HP_PIN_0F, |
| 4996 | ALC260_FIXUP_COEF, |
Takashi Iwai | 15317ab | 2012-02-16 12:02:53 +0100 | [diff] [blame] | 4997 | ALC260_FIXUP_GPIO1, |
Takashi Iwai | 20f7d92 | 2012-02-16 12:35:16 +0100 | [diff] [blame] | 4998 | ALC260_FIXUP_GPIO1_TOGGLE, |
| 4999 | ALC260_FIXUP_REPLACER, |
Takashi Iwai | 0a1c4fa | 2012-02-16 12:42:30 +0100 | [diff] [blame] | 5000 | ALC260_FIXUP_HP_B1900, |
Takashi Iwai | 118cb4a | 2012-04-19 07:33:27 +0200 | [diff] [blame] | 5001 | ALC260_FIXUP_KN1, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5002 | }; |
| 5003 | |
Takashi Iwai | 20f7d92 | 2012-02-16 12:35:16 +0100 | [diff] [blame] | 5004 | static void alc260_gpio1_automute(struct hda_codec *codec) |
| 5005 | { |
| 5006 | struct alc_spec *spec = codec->spec; |
| 5007 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, |
| 5008 | spec->hp_jack_present); |
| 5009 | } |
| 5010 | |
| 5011 | static void alc260_fixup_gpio1_toggle(struct hda_codec *codec, |
| 5012 | const struct alc_fixup *fix, int action) |
| 5013 | { |
| 5014 | struct alc_spec *spec = codec->spec; |
| 5015 | if (action == ALC_FIXUP_ACT_PROBE) { |
| 5016 | /* although the machine has only one output pin, we need to |
| 5017 | * toggle GPIO1 according to the jack state |
| 5018 | */ |
| 5019 | spec->automute_hook = alc260_gpio1_automute; |
| 5020 | spec->detect_hp = 1; |
| 5021 | spec->automute_speaker = 1; |
| 5022 | spec->autocfg.hp_pins[0] = 0x0f; /* copy it for automute */ |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 5023 | snd_hda_jack_detect_enable_callback(codec, 0x0f, ALC_HP_EVENT, |
| 5024 | alc_hp_automute); |
Takashi Iwai | c9ce6b2 | 2012-12-18 18:12:44 +0100 | [diff] [blame] | 5025 | snd_hda_add_verbs(codec, alc_gpio1_init_verbs); |
Takashi Iwai | 20f7d92 | 2012-02-16 12:35:16 +0100 | [diff] [blame] | 5026 | } |
| 5027 | } |
| 5028 | |
Takashi Iwai | 118cb4a | 2012-04-19 07:33:27 +0200 | [diff] [blame] | 5029 | static void alc260_fixup_kn1(struct hda_codec *codec, |
| 5030 | const struct alc_fixup *fix, int action) |
| 5031 | { |
| 5032 | struct alc_spec *spec = codec->spec; |
| 5033 | static const struct alc_pincfg pincfgs[] = { |
| 5034 | { 0x0f, 0x02214000 }, /* HP/speaker */ |
| 5035 | { 0x12, 0x90a60160 }, /* int mic */ |
| 5036 | { 0x13, 0x02a19000 }, /* ext mic */ |
| 5037 | { 0x18, 0x01446000 }, /* SPDIF out */ |
| 5038 | /* disable bogus I/O pins */ |
| 5039 | { 0x10, 0x411111f0 }, |
| 5040 | { 0x11, 0x411111f0 }, |
| 5041 | { 0x14, 0x411111f0 }, |
| 5042 | { 0x15, 0x411111f0 }, |
| 5043 | { 0x16, 0x411111f0 }, |
| 5044 | { 0x17, 0x411111f0 }, |
| 5045 | { 0x19, 0x411111f0 }, |
| 5046 | { } |
| 5047 | }; |
| 5048 | |
| 5049 | switch (action) { |
| 5050 | case ALC_FIXUP_ACT_PRE_PROBE: |
| 5051 | alc_apply_pincfgs(codec, pincfgs); |
| 5052 | break; |
| 5053 | case ALC_FIXUP_ACT_PROBE: |
| 5054 | spec->init_amp = ALC_INIT_NONE; |
| 5055 | break; |
| 5056 | } |
| 5057 | } |
| 5058 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5059 | static const struct alc_fixup alc260_fixups[] = { |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 5060 | [ALC260_FIXUP_HP_DC5750] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5061 | .type = ALC_FIXUP_PINS, |
| 5062 | .v.pins = (const struct alc_pincfg[]) { |
| 5063 | { 0x11, 0x90130110 }, /* speaker */ |
| 5064 | { } |
| 5065 | } |
| 5066 | }, |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 5067 | [ALC260_FIXUP_HP_PIN_0F] = { |
| 5068 | .type = ALC_FIXUP_PINS, |
| 5069 | .v.pins = (const struct alc_pincfg[]) { |
| 5070 | { 0x0f, 0x01214000 }, /* HP */ |
| 5071 | { } |
| 5072 | } |
| 5073 | }, |
| 5074 | [ALC260_FIXUP_COEF] = { |
| 5075 | .type = ALC_FIXUP_VERBS, |
| 5076 | .v.verbs = (const struct hda_verb[]) { |
| 5077 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5078 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3040 }, |
| 5079 | { } |
| 5080 | }, |
| 5081 | .chained = true, |
| 5082 | .chain_id = ALC260_FIXUP_HP_PIN_0F, |
| 5083 | }, |
Takashi Iwai | 15317ab | 2012-02-16 12:02:53 +0100 | [diff] [blame] | 5084 | [ALC260_FIXUP_GPIO1] = { |
| 5085 | .type = ALC_FIXUP_VERBS, |
| 5086 | .v.verbs = alc_gpio1_init_verbs, |
| 5087 | }, |
Takashi Iwai | 20f7d92 | 2012-02-16 12:35:16 +0100 | [diff] [blame] | 5088 | [ALC260_FIXUP_GPIO1_TOGGLE] = { |
| 5089 | .type = ALC_FIXUP_FUNC, |
| 5090 | .v.func = alc260_fixup_gpio1_toggle, |
| 5091 | .chained = true, |
| 5092 | .chain_id = ALC260_FIXUP_HP_PIN_0F, |
| 5093 | }, |
| 5094 | [ALC260_FIXUP_REPLACER] = { |
| 5095 | .type = ALC_FIXUP_VERBS, |
| 5096 | .v.verbs = (const struct hda_verb[]) { |
| 5097 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5098 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 }, |
| 5099 | { } |
| 5100 | }, |
| 5101 | .chained = true, |
| 5102 | .chain_id = ALC260_FIXUP_GPIO1_TOGGLE, |
| 5103 | }, |
Takashi Iwai | 0a1c4fa | 2012-02-16 12:42:30 +0100 | [diff] [blame] | 5104 | [ALC260_FIXUP_HP_B1900] = { |
| 5105 | .type = ALC_FIXUP_FUNC, |
| 5106 | .v.func = alc260_fixup_gpio1_toggle, |
| 5107 | .chained = true, |
| 5108 | .chain_id = ALC260_FIXUP_COEF, |
Takashi Iwai | 118cb4a | 2012-04-19 07:33:27 +0200 | [diff] [blame] | 5109 | }, |
| 5110 | [ALC260_FIXUP_KN1] = { |
| 5111 | .type = ALC_FIXUP_FUNC, |
| 5112 | .v.func = alc260_fixup_kn1, |
| 5113 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5114 | }; |
| 5115 | |
| 5116 | static const struct snd_pci_quirk alc260_fixup_tbl[] = { |
Takashi Iwai | 15317ab | 2012-02-16 12:02:53 +0100 | [diff] [blame] | 5117 | SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_FIXUP_GPIO1), |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 5118 | SND_PCI_QUIRK(0x1025, 0x007f, "Acer Aspire 9500", ALC260_FIXUP_COEF), |
Takashi Iwai | 15317ab | 2012-02-16 12:02:53 +0100 | [diff] [blame] | 5119 | SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_FIXUP_GPIO1), |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 5120 | SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", ALC260_FIXUP_HP_DC5750), |
Takashi Iwai | 0a1c4fa | 2012-02-16 12:42:30 +0100 | [diff] [blame] | 5121 | SND_PCI_QUIRK(0x103c, 0x30ba, "HP Presario B1900", ALC260_FIXUP_HP_B1900), |
Takashi Iwai | b1f5808 | 2012-02-16 12:45:03 +0100 | [diff] [blame] | 5122 | SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FIXUP_GPIO1), |
Takashi Iwai | 118cb4a | 2012-04-19 07:33:27 +0200 | [diff] [blame] | 5123 | SND_PCI_QUIRK(0x152d, 0x0729, "Quanta KN1", ALC260_FIXUP_KN1), |
Takashi Iwai | 20f7d92 | 2012-02-16 12:35:16 +0100 | [diff] [blame] | 5124 | SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_FIXUP_REPLACER), |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 5125 | SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_FIXUP_COEF), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5126 | {} |
| 5127 | }; |
| 5128 | |
| 5129 | /* |
| 5130 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5131 | static int patch_alc260(struct hda_codec *codec) |
| 5132 | { |
| 5133 | struct alc_spec *spec; |
Takashi Iwai | c3c2c9e | 2012-02-16 12:59:55 +0100 | [diff] [blame] | 5134 | int err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5135 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 5136 | err = alc_alloc_spec(codec, 0x07); |
| 5137 | if (err < 0) |
| 5138 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5139 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 5140 | spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5141 | |
Takashi Iwai | c3c2c9e | 2012-02-16 12:59:55 +0100 | [diff] [blame] | 5142 | alc_pick_fixup(codec, NULL, alc260_fixup_tbl, alc260_fixups); |
| 5143 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5144 | |
Takashi Iwai | c3c2c9e | 2012-02-16 12:59:55 +0100 | [diff] [blame] | 5145 | /* automatic parse from the BIOS config */ |
| 5146 | err = alc260_parse_auto_config(codec); |
| 5147 | if (err < 0) |
| 5148 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5149 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5150 | if (!spec->no_analog) { |
| 5151 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5152 | if (err < 0) |
| 5153 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5154 | set_beep_amp(spec, 0x07, 0x05, HDA_INPUT); |
| 5155 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5156 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5157 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5158 | spec->shutup = alc_eapd_shutup; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5159 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 5160 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 5161 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5162 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5163 | |
| 5164 | error: |
| 5165 | alc_free(codec); |
| 5166 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5167 | } |
| 5168 | |
| 5169 | |
| 5170 | /* |
| 5171 | * ALC882/883/885/888/889 support |
| 5172 | * |
| 5173 | * ALC882 is almost identical with ALC880 but has cleaner and more flexible |
| 5174 | * configuration. Each pin widget can choose any input DACs and a mixer. |
| 5175 | * Each ADC is connected from a mixer of all inputs. This makes possible |
| 5176 | * 6-channel independent captures. |
| 5177 | * |
| 5178 | * In addition, an independent DAC for the multi-playback (not used in this |
| 5179 | * driver yet). |
| 5180 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5181 | |
| 5182 | /* |
| 5183 | * Pin config fixes |
| 5184 | */ |
| 5185 | enum { |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5186 | ALC882_FIXUP_ABIT_AW9D_MAX, |
| 5187 | ALC882_FIXUP_LENOVO_Y530, |
| 5188 | ALC882_FIXUP_PB_M5210, |
| 5189 | ALC882_FIXUP_ACER_ASPIRE_7736, |
| 5190 | ALC882_FIXUP_ASUS_W90V, |
Marton Balint | 8f23921 | 2012-03-05 21:33:23 +0100 | [diff] [blame] | 5191 | ALC889_FIXUP_CD, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5192 | ALC889_FIXUP_VAIO_TT, |
Takashi Iwai | 0e7cc2e | 2011-11-09 12:42:48 +0100 | [diff] [blame] | 5193 | ALC888_FIXUP_EEE1601, |
Takashi Iwai | 177943a | 2011-11-09 12:55:18 +0100 | [diff] [blame] | 5194 | ALC882_FIXUP_EAPD, |
Takashi Iwai | 7a6069b | 2011-11-09 15:22:01 +0100 | [diff] [blame] | 5195 | ALC883_FIXUP_EAPD, |
Takashi Iwai | 8812c4f | 2011-11-09 17:39:15 +0100 | [diff] [blame] | 5196 | ALC883_FIXUP_ACER_EAPD, |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5197 | ALC882_FIXUP_GPIO1, |
| 5198 | ALC882_FIXUP_GPIO2, |
Takashi Iwai | eb844d5 | 2011-11-09 18:03:07 +0100 | [diff] [blame] | 5199 | ALC882_FIXUP_GPIO3, |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 5200 | ALC889_FIXUP_COEF, |
| 5201 | ALC882_FIXUP_ASUS_W2JC, |
Takashi Iwai | c3e837b | 2011-11-10 16:01:47 +0100 | [diff] [blame] | 5202 | ALC882_FIXUP_ACER_ASPIRE_4930G, |
| 5203 | ALC882_FIXUP_ACER_ASPIRE_8930G, |
| 5204 | ALC882_FIXUP_ASPIRE_8930G_VERBS, |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5205 | ALC885_FIXUP_MACPRO_GPIO, |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5206 | ALC889_FIXUP_DAC_ROUTE, |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5207 | ALC889_FIXUP_MBP_VREF, |
| 5208 | ALC889_FIXUP_IMAC91_VREF, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5209 | ALC882_FIXUP_INV_DMIC, |
Takashi Iwai | e427c23 | 2012-07-29 10:04:08 +0200 | [diff] [blame] | 5210 | ALC882_FIXUP_NO_PRIMARY_HP, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5211 | }; |
| 5212 | |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 5213 | static void alc889_fixup_coef(struct hda_codec *codec, |
| 5214 | const struct alc_fixup *fix, int action) |
| 5215 | { |
| 5216 | if (action != ALC_FIXUP_ACT_INIT) |
| 5217 | return; |
| 5218 | alc889_coef_init(codec); |
| 5219 | } |
| 5220 | |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5221 | /* toggle speaker-output according to the hp-jack state */ |
| 5222 | static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted) |
| 5223 | { |
| 5224 | unsigned int gpiostate, gpiomask, gpiodir; |
| 5225 | |
| 5226 | gpiostate = snd_hda_codec_read(codec, codec->afg, 0, |
| 5227 | AC_VERB_GET_GPIO_DATA, 0); |
| 5228 | |
| 5229 | if (!muted) |
| 5230 | gpiostate |= (1 << pin); |
| 5231 | else |
| 5232 | gpiostate &= ~(1 << pin); |
| 5233 | |
| 5234 | gpiomask = snd_hda_codec_read(codec, codec->afg, 0, |
| 5235 | AC_VERB_GET_GPIO_MASK, 0); |
| 5236 | gpiomask |= (1 << pin); |
| 5237 | |
| 5238 | gpiodir = snd_hda_codec_read(codec, codec->afg, 0, |
| 5239 | AC_VERB_GET_GPIO_DIRECTION, 0); |
| 5240 | gpiodir |= (1 << pin); |
| 5241 | |
| 5242 | |
| 5243 | snd_hda_codec_write(codec, codec->afg, 0, |
| 5244 | AC_VERB_SET_GPIO_MASK, gpiomask); |
| 5245 | snd_hda_codec_write(codec, codec->afg, 0, |
| 5246 | AC_VERB_SET_GPIO_DIRECTION, gpiodir); |
| 5247 | |
| 5248 | msleep(1); |
| 5249 | |
| 5250 | snd_hda_codec_write(codec, codec->afg, 0, |
| 5251 | AC_VERB_SET_GPIO_DATA, gpiostate); |
| 5252 | } |
| 5253 | |
| 5254 | /* set up GPIO at initialization */ |
| 5255 | static void alc885_fixup_macpro_gpio(struct hda_codec *codec, |
| 5256 | const struct alc_fixup *fix, int action) |
| 5257 | { |
| 5258 | if (action != ALC_FIXUP_ACT_INIT) |
| 5259 | return; |
| 5260 | alc882_gpio_mute(codec, 0, 0); |
| 5261 | alc882_gpio_mute(codec, 1, 0); |
| 5262 | } |
| 5263 | |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5264 | /* Fix the connection of some pins for ALC889: |
| 5265 | * At least, Acer Aspire 5935 shows the connections to DAC3/4 don't |
| 5266 | * work correctly (bko#42740) |
| 5267 | */ |
| 5268 | static void alc889_fixup_dac_route(struct hda_codec *codec, |
| 5269 | const struct alc_fixup *fix, int action) |
| 5270 | { |
| 5271 | if (action == ALC_FIXUP_ACT_PRE_PROBE) { |
Takashi Iwai | ef8d60f | 2012-02-17 10:12:38 +0100 | [diff] [blame] | 5272 | /* fake the connections during parsing the tree */ |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5273 | hda_nid_t conn1[2] = { 0x0c, 0x0d }; |
| 5274 | hda_nid_t conn2[2] = { 0x0e, 0x0f }; |
| 5275 | snd_hda_override_conn_list(codec, 0x14, 2, conn1); |
| 5276 | snd_hda_override_conn_list(codec, 0x15, 2, conn1); |
| 5277 | snd_hda_override_conn_list(codec, 0x18, 2, conn2); |
| 5278 | snd_hda_override_conn_list(codec, 0x1a, 2, conn2); |
Takashi Iwai | ef8d60f | 2012-02-17 10:12:38 +0100 | [diff] [blame] | 5279 | } else if (action == ALC_FIXUP_ACT_PROBE) { |
| 5280 | /* restore the connections */ |
| 5281 | hda_nid_t conn[5] = { 0x0c, 0x0d, 0x0e, 0x0f, 0x26 }; |
| 5282 | snd_hda_override_conn_list(codec, 0x14, 5, conn); |
| 5283 | snd_hda_override_conn_list(codec, 0x15, 5, conn); |
| 5284 | snd_hda_override_conn_list(codec, 0x18, 5, conn); |
| 5285 | snd_hda_override_conn_list(codec, 0x1a, 5, conn); |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5286 | } |
| 5287 | } |
| 5288 | |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5289 | /* Set VREF on HP pin */ |
| 5290 | static void alc889_fixup_mbp_vref(struct hda_codec *codec, |
| 5291 | const struct alc_fixup *fix, int action) |
| 5292 | { |
| 5293 | struct alc_spec *spec = codec->spec; |
| 5294 | static hda_nid_t nids[2] = { 0x14, 0x15 }; |
| 5295 | int i; |
| 5296 | |
| 5297 | if (action != ALC_FIXUP_ACT_INIT) |
| 5298 | return; |
| 5299 | for (i = 0; i < ARRAY_SIZE(nids); i++) { |
| 5300 | unsigned int val = snd_hda_codec_get_pincfg(codec, nids[i]); |
| 5301 | if (get_defcfg_device(val) != AC_JACK_HP_OUT) |
| 5302 | continue; |
| 5303 | val = snd_hda_codec_read(codec, nids[i], 0, |
| 5304 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 5305 | val |= AC_PINCTL_VREF_80; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 5306 | snd_hda_set_pin_ctl(codec, nids[i], val); |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5307 | spec->keep_vref_in_automute = 1; |
| 5308 | break; |
| 5309 | } |
| 5310 | } |
| 5311 | |
| 5312 | /* Set VREF on speaker pins on imac91 */ |
| 5313 | static void alc889_fixup_imac91_vref(struct hda_codec *codec, |
| 5314 | const struct alc_fixup *fix, int action) |
| 5315 | { |
| 5316 | struct alc_spec *spec = codec->spec; |
| 5317 | static hda_nid_t nids[2] = { 0x18, 0x1a }; |
| 5318 | int i; |
| 5319 | |
| 5320 | if (action != ALC_FIXUP_ACT_INIT) |
| 5321 | return; |
| 5322 | for (i = 0; i < ARRAY_SIZE(nids); i++) { |
| 5323 | unsigned int val; |
| 5324 | val = snd_hda_codec_read(codec, nids[i], 0, |
| 5325 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 5326 | val |= AC_PINCTL_VREF_50; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 5327 | snd_hda_set_pin_ctl(codec, nids[i], val); |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5328 | } |
| 5329 | spec->keep_vref_in_automute = 1; |
| 5330 | } |
| 5331 | |
Takashi Iwai | e427c23 | 2012-07-29 10:04:08 +0200 | [diff] [blame] | 5332 | /* Don't take HP output as primary |
| 5333 | * strangely, the speaker output doesn't work on VAIO Z through DAC 0x05 |
| 5334 | */ |
| 5335 | static void alc882_fixup_no_primary_hp(struct hda_codec *codec, |
| 5336 | const struct alc_fixup *fix, int action) |
| 5337 | { |
| 5338 | struct alc_spec *spec = codec->spec; |
| 5339 | if (action == ALC_FIXUP_ACT_PRE_PROBE) |
| 5340 | spec->no_primary_hp = 1; |
| 5341 | } |
| 5342 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5343 | static const struct alc_fixup alc882_fixups[] = { |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5344 | [ALC882_FIXUP_ABIT_AW9D_MAX] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5345 | .type = ALC_FIXUP_PINS, |
| 5346 | .v.pins = (const struct alc_pincfg[]) { |
| 5347 | { 0x15, 0x01080104 }, /* side */ |
| 5348 | { 0x16, 0x01011012 }, /* rear */ |
| 5349 | { 0x17, 0x01016011 }, /* clfe */ |
| 5350 | { } |
| 5351 | } |
| 5352 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5353 | [ALC882_FIXUP_LENOVO_Y530] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5354 | .type = ALC_FIXUP_PINS, |
| 5355 | .v.pins = (const struct alc_pincfg[]) { |
| 5356 | { 0x15, 0x99130112 }, /* rear int speakers */ |
| 5357 | { 0x16, 0x99130111 }, /* subwoofer */ |
| 5358 | { } |
| 5359 | } |
| 5360 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5361 | [ALC882_FIXUP_PB_M5210] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5362 | .type = ALC_FIXUP_VERBS, |
| 5363 | .v.verbs = (const struct hda_verb[]) { |
| 5364 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 }, |
| 5365 | {} |
| 5366 | } |
| 5367 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5368 | [ALC882_FIXUP_ACER_ASPIRE_7736] = { |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 5369 | .type = ALC_FIXUP_FUNC, |
| 5370 | .v.func = alc_fixup_sku_ignore, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5371 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5372 | [ALC882_FIXUP_ASUS_W90V] = { |
Takashi Iwai | 5cdf745 | 2011-10-26 23:04:08 +0200 | [diff] [blame] | 5373 | .type = ALC_FIXUP_PINS, |
| 5374 | .v.pins = (const struct alc_pincfg[]) { |
| 5375 | { 0x16, 0x99130110 }, /* fix sequence for CLFE */ |
| 5376 | { } |
| 5377 | } |
| 5378 | }, |
Marton Balint | 8f23921 | 2012-03-05 21:33:23 +0100 | [diff] [blame] | 5379 | [ALC889_FIXUP_CD] = { |
| 5380 | .type = ALC_FIXUP_PINS, |
| 5381 | .v.pins = (const struct alc_pincfg[]) { |
| 5382 | { 0x1c, 0x993301f0 }, /* CD */ |
| 5383 | { } |
| 5384 | } |
| 5385 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5386 | [ALC889_FIXUP_VAIO_TT] = { |
| 5387 | .type = ALC_FIXUP_PINS, |
| 5388 | .v.pins = (const struct alc_pincfg[]) { |
| 5389 | { 0x17, 0x90170111 }, /* hidden surround speaker */ |
| 5390 | { } |
| 5391 | } |
| 5392 | }, |
Takashi Iwai | 0e7cc2e | 2011-11-09 12:42:48 +0100 | [diff] [blame] | 5393 | [ALC888_FIXUP_EEE1601] = { |
| 5394 | .type = ALC_FIXUP_VERBS, |
| 5395 | .v.verbs = (const struct hda_verb[]) { |
| 5396 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b }, |
| 5397 | { 0x20, AC_VERB_SET_PROC_COEF, 0x0838 }, |
| 5398 | { } |
| 5399 | } |
Takashi Iwai | 177943a | 2011-11-09 12:55:18 +0100 | [diff] [blame] | 5400 | }, |
| 5401 | [ALC882_FIXUP_EAPD] = { |
| 5402 | .type = ALC_FIXUP_VERBS, |
| 5403 | .v.verbs = (const struct hda_verb[]) { |
| 5404 | /* change to EAPD mode */ |
| 5405 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5406 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 }, |
| 5407 | { } |
| 5408 | } |
| 5409 | }, |
Takashi Iwai | 7a6069b | 2011-11-09 15:22:01 +0100 | [diff] [blame] | 5410 | [ALC883_FIXUP_EAPD] = { |
| 5411 | .type = ALC_FIXUP_VERBS, |
| 5412 | .v.verbs = (const struct hda_verb[]) { |
| 5413 | /* change to EAPD mode */ |
| 5414 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5415 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 }, |
| 5416 | { } |
| 5417 | } |
| 5418 | }, |
Takashi Iwai | 8812c4f | 2011-11-09 17:39:15 +0100 | [diff] [blame] | 5419 | [ALC883_FIXUP_ACER_EAPD] = { |
| 5420 | .type = ALC_FIXUP_VERBS, |
| 5421 | .v.verbs = (const struct hda_verb[]) { |
| 5422 | /* eanable EAPD on Acer laptops */ |
| 5423 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5424 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 }, |
| 5425 | { } |
| 5426 | } |
| 5427 | }, |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5428 | [ALC882_FIXUP_GPIO1] = { |
| 5429 | .type = ALC_FIXUP_VERBS, |
| 5430 | .v.verbs = alc_gpio1_init_verbs, |
| 5431 | }, |
| 5432 | [ALC882_FIXUP_GPIO2] = { |
| 5433 | .type = ALC_FIXUP_VERBS, |
| 5434 | .v.verbs = alc_gpio2_init_verbs, |
| 5435 | }, |
Takashi Iwai | eb844d5 | 2011-11-09 18:03:07 +0100 | [diff] [blame] | 5436 | [ALC882_FIXUP_GPIO3] = { |
| 5437 | .type = ALC_FIXUP_VERBS, |
| 5438 | .v.verbs = alc_gpio3_init_verbs, |
| 5439 | }, |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 5440 | [ALC882_FIXUP_ASUS_W2JC] = { |
| 5441 | .type = ALC_FIXUP_VERBS, |
| 5442 | .v.verbs = alc_gpio1_init_verbs, |
| 5443 | .chained = true, |
| 5444 | .chain_id = ALC882_FIXUP_EAPD, |
| 5445 | }, |
| 5446 | [ALC889_FIXUP_COEF] = { |
| 5447 | .type = ALC_FIXUP_FUNC, |
| 5448 | .v.func = alc889_fixup_coef, |
| 5449 | }, |
Takashi Iwai | c3e837b | 2011-11-10 16:01:47 +0100 | [diff] [blame] | 5450 | [ALC882_FIXUP_ACER_ASPIRE_4930G] = { |
| 5451 | .type = ALC_FIXUP_PINS, |
| 5452 | .v.pins = (const struct alc_pincfg[]) { |
| 5453 | { 0x16, 0x99130111 }, /* CLFE speaker */ |
| 5454 | { 0x17, 0x99130112 }, /* surround speaker */ |
| 5455 | { } |
Takashi Iwai | 038d4fe | 2012-04-11 17:18:12 +0200 | [diff] [blame] | 5456 | }, |
| 5457 | .chained = true, |
| 5458 | .chain_id = ALC882_FIXUP_GPIO1, |
Takashi Iwai | c3e837b | 2011-11-10 16:01:47 +0100 | [diff] [blame] | 5459 | }, |
| 5460 | [ALC882_FIXUP_ACER_ASPIRE_8930G] = { |
| 5461 | .type = ALC_FIXUP_PINS, |
| 5462 | .v.pins = (const struct alc_pincfg[]) { |
| 5463 | { 0x16, 0x99130111 }, /* CLFE speaker */ |
| 5464 | { 0x1b, 0x99130112 }, /* surround speaker */ |
| 5465 | { } |
| 5466 | }, |
| 5467 | .chained = true, |
| 5468 | .chain_id = ALC882_FIXUP_ASPIRE_8930G_VERBS, |
| 5469 | }, |
| 5470 | [ALC882_FIXUP_ASPIRE_8930G_VERBS] = { |
| 5471 | /* additional init verbs for Acer Aspire 8930G */ |
| 5472 | .type = ALC_FIXUP_VERBS, |
| 5473 | .v.verbs = (const struct hda_verb[]) { |
| 5474 | /* Enable all DACs */ |
| 5475 | /* DAC DISABLE/MUTE 1? */ |
| 5476 | /* setting bits 1-5 disables DAC nids 0x02-0x06 |
| 5477 | * apparently. Init=0x38 */ |
| 5478 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x03 }, |
| 5479 | { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 }, |
| 5480 | /* DAC DISABLE/MUTE 2? */ |
| 5481 | /* some bit here disables the other DACs. |
| 5482 | * Init=0x4900 */ |
| 5483 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x08 }, |
| 5484 | { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 }, |
| 5485 | /* DMIC fix |
| 5486 | * This laptop has a stereo digital microphone. |
| 5487 | * The mics are only 1cm apart which makes the stereo |
| 5488 | * useless. However, either the mic or the ALC889 |
| 5489 | * makes the signal become a difference/sum signal |
| 5490 | * instead of standard stereo, which is annoying. |
| 5491 | * So instead we flip this bit which makes the |
| 5492 | * codec replicate the sum signal to both channels, |
| 5493 | * turning it into a normal mono mic. |
| 5494 | */ |
| 5495 | /* DMIC_CONTROL? Init value = 0x0001 */ |
| 5496 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b }, |
| 5497 | { 0x20, AC_VERB_SET_PROC_COEF, 0x0003 }, |
| 5498 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5499 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 }, |
| 5500 | { } |
Takashi Iwai | 038d4fe | 2012-04-11 17:18:12 +0200 | [diff] [blame] | 5501 | }, |
| 5502 | .chained = true, |
| 5503 | .chain_id = ALC882_FIXUP_GPIO1, |
Takashi Iwai | c3e837b | 2011-11-10 16:01:47 +0100 | [diff] [blame] | 5504 | }, |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5505 | [ALC885_FIXUP_MACPRO_GPIO] = { |
| 5506 | .type = ALC_FIXUP_FUNC, |
| 5507 | .v.func = alc885_fixup_macpro_gpio, |
| 5508 | }, |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5509 | [ALC889_FIXUP_DAC_ROUTE] = { |
| 5510 | .type = ALC_FIXUP_FUNC, |
| 5511 | .v.func = alc889_fixup_dac_route, |
| 5512 | }, |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5513 | [ALC889_FIXUP_MBP_VREF] = { |
| 5514 | .type = ALC_FIXUP_FUNC, |
| 5515 | .v.func = alc889_fixup_mbp_vref, |
| 5516 | .chained = true, |
| 5517 | .chain_id = ALC882_FIXUP_GPIO1, |
| 5518 | }, |
| 5519 | [ALC889_FIXUP_IMAC91_VREF] = { |
| 5520 | .type = ALC_FIXUP_FUNC, |
| 5521 | .v.func = alc889_fixup_imac91_vref, |
| 5522 | .chained = true, |
| 5523 | .chain_id = ALC882_FIXUP_GPIO1, |
| 5524 | }, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5525 | [ALC882_FIXUP_INV_DMIC] = { |
| 5526 | .type = ALC_FIXUP_FUNC, |
| 5527 | .v.func = alc_fixup_inv_dmic_0x12, |
| 5528 | }, |
Takashi Iwai | e427c23 | 2012-07-29 10:04:08 +0200 | [diff] [blame] | 5529 | [ALC882_FIXUP_NO_PRIMARY_HP] = { |
| 5530 | .type = ALC_FIXUP_FUNC, |
| 5531 | .v.func = alc882_fixup_no_primary_hp, |
| 5532 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5533 | }; |
| 5534 | |
| 5535 | static const struct snd_pci_quirk alc882_fixup_tbl[] = { |
Takashi Iwai | 8812c4f | 2011-11-09 17:39:15 +0100 | [diff] [blame] | 5536 | SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_FIXUP_ACER_EAPD), |
| 5537 | SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_FIXUP_ACER_EAPD), |
| 5538 | SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_FIXUP_ACER_EAPD), |
| 5539 | SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_FIXUP_ACER_EAPD), |
| 5540 | SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_FIXUP_ACER_EAPD), |
| 5541 | SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_FIXUP_ACER_EAPD), |
Takashi Iwai | c3e837b | 2011-11-10 16:01:47 +0100 | [diff] [blame] | 5542 | SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G", |
| 5543 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
| 5544 | SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G", |
| 5545 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
| 5546 | SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G", |
| 5547 | ALC882_FIXUP_ACER_ASPIRE_8930G), |
| 5548 | SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G", |
| 5549 | ALC882_FIXUP_ACER_ASPIRE_8930G), |
| 5550 | SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G", |
| 5551 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
| 5552 | SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G", |
| 5553 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
| 5554 | SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G", |
| 5555 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5556 | SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", ALC882_FIXUP_PB_M5210), |
Takashi Iwai | f5c53d8 | 2012-05-07 10:07:33 +0200 | [diff] [blame] | 5557 | SND_PCI_QUIRK(0x1025, 0x021e, "Acer Aspire 5739G", |
| 5558 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5559 | SND_PCI_QUIRK(0x1025, 0x0259, "Acer Aspire 5935", ALC889_FIXUP_DAC_ROUTE), |
Takashi Iwai | fe97da1 | 2012-04-12 08:00:19 +0200 | [diff] [blame] | 5560 | 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] | 5561 | 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] | 5562 | SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_FIXUP_EAPD), |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5563 | SND_PCI_QUIRK(0x1043, 0x1873, "ASUS W90V", ALC882_FIXUP_ASUS_W90V), |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 5564 | SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_FIXUP_ASUS_W2JC), |
Takashi Iwai | 0e7cc2e | 2011-11-09 12:42:48 +0100 | [diff] [blame] | 5565 | SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601), |
Takashi Iwai | ac9b1cd | 2011-11-09 17:45:55 +0100 | [diff] [blame] | 5566 | SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT), |
Takashi Iwai | e427c23 | 2012-07-29 10:04:08 +0200 | [diff] [blame] | 5567 | SND_PCI_QUIRK(0x104d, 0x905a, "Sony Vaio Z", ALC882_FIXUP_NO_PRIMARY_HP), |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5568 | |
| 5569 | /* All Apple entries are in codec SSIDs */ |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5570 | SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC889_FIXUP_MBP_VREF), |
| 5571 | SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC889_FIXUP_MBP_VREF), |
| 5572 | SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF), |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5573 | SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_FIXUP_MACPRO_GPIO), |
| 5574 | SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_FIXUP_MACPRO_GPIO), |
| 5575 | SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_FIXUP_MACPRO_GPIO), |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5576 | SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC889_FIXUP_MBP_VREF), |
| 5577 | SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889_FIXUP_MBP_VREF), |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5578 | SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_FIXUP_EAPD), |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5579 | SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC889_FIXUP_MBP_VREF), |
| 5580 | SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC889_FIXUP_MBP_VREF), |
| 5581 | SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889_FIXUP_MBP_VREF), |
| 5582 | SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF), |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5583 | SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_FIXUP_MACPRO_GPIO), |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5584 | SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC889_FIXUP_IMAC91_VREF), |
| 5585 | SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC889_FIXUP_IMAC91_VREF), |
| 5586 | SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC889_FIXUP_IMAC91_VREF), |
Josh Boyer | 29ebe40 | 2012-04-12 13:55:36 -0400 | [diff] [blame] | 5587 | SND_PCI_QUIRK(0x106b, 0x4200, "Mac Pro 5,1", ALC885_FIXUP_MACPRO_GPIO), |
Takashi Iwai | 0519363 | 2012-11-12 10:07:36 +0100 | [diff] [blame] | 5588 | SND_PCI_QUIRK(0x106b, 0x4300, "iMac 9,1", ALC889_FIXUP_IMAC91_VREF), |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5589 | SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC889_FIXUP_IMAC91_VREF), |
| 5590 | SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC889_FIXUP_IMAC91_VREF), |
| 5591 | SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC889_FIXUP_IMAC91_VREF), |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5592 | |
Takashi Iwai | 7a6069b | 2011-11-09 15:22:01 +0100 | [diff] [blame] | 5593 | SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC882_FIXUP_EAPD), |
Takashi Iwai | bca4013 | 2012-05-07 11:13:14 +0200 | [diff] [blame] | 5594 | SND_PCI_QUIRK(0x1462, 0x7350, "MSI-7350", ALC889_FIXUP_CD), |
Takashi Iwai | eb844d5 | 2011-11-09 18:03:07 +0100 | [diff] [blame] | 5595 | SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3), |
Marton Balint | 8f23921 | 2012-03-05 21:33:23 +0100 | [diff] [blame] | 5596 | SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte EP45-DS3", ALC889_FIXUP_CD), |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5597 | 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] | 5598 | SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC882_FIXUP_EAPD), |
| 5599 | SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_FIXUP_EAPD), |
Takashi Iwai | ac9b1cd | 2011-11-09 17:45:55 +0100 | [diff] [blame] | 5600 | SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", ALC882_FIXUP_LENOVO_Y530), |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 5601 | SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_FIXUP_COEF), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5602 | {} |
| 5603 | }; |
| 5604 | |
Takashi Iwai | 912093b | 2012-04-11 14:03:41 +0200 | [diff] [blame] | 5605 | static const struct alc_model_fixup alc882_fixup_models[] = { |
| 5606 | {.id = ALC882_FIXUP_ACER_ASPIRE_4930G, .name = "acer-aspire-4930g"}, |
| 5607 | {.id = ALC882_FIXUP_ACER_ASPIRE_8930G, .name = "acer-aspire-8930g"}, |
| 5608 | {.id = ALC883_FIXUP_ACER_EAPD, .name = "acer-aspire"}, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5609 | {.id = ALC882_FIXUP_INV_DMIC, .name = "inv-dmic"}, |
Takashi Iwai | e427c23 | 2012-07-29 10:04:08 +0200 | [diff] [blame] | 5610 | {.id = ALC882_FIXUP_NO_PRIMARY_HP, .name = "no-primary-hp"}, |
Takashi Iwai | 912093b | 2012-04-11 14:03:41 +0200 | [diff] [blame] | 5611 | {} |
| 5612 | }; |
| 5613 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5614 | /* |
| 5615 | * BIOS auto configuration |
| 5616 | */ |
| 5617 | /* almost identical with ALC880 parser... */ |
| 5618 | static int alc882_parse_auto_config(struct hda_codec *codec) |
| 5619 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5620 | static const hda_nid_t alc882_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5621 | static const hda_nid_t alc882_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 5622 | return alc_parse_auto_config(codec, alc882_ignore, alc882_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5623 | } |
| 5624 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5625 | /* |
| 5626 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5627 | static int patch_alc882(struct hda_codec *codec) |
| 5628 | { |
| 5629 | struct alc_spec *spec; |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5630 | int err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5631 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 5632 | err = alc_alloc_spec(codec, 0x0b); |
| 5633 | if (err < 0) |
| 5634 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5635 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 5636 | spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5637 | |
| 5638 | switch (codec->vendor_id) { |
| 5639 | case 0x10ec0882: |
| 5640 | case 0x10ec0885: |
| 5641 | break; |
| 5642 | default: |
| 5643 | /* ALC883 and variants */ |
| 5644 | alc_fix_pll_init(codec, 0x20, 0x0a, 10); |
| 5645 | break; |
| 5646 | } |
| 5647 | |
Takashi Iwai | 912093b | 2012-04-11 14:03:41 +0200 | [diff] [blame] | 5648 | alc_pick_fixup(codec, alc882_fixup_models, alc882_fixup_tbl, |
| 5649 | alc882_fixups); |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5650 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5651 | |
| 5652 | alc_auto_parse_customize_define(codec); |
| 5653 | |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5654 | /* automatic parse from the BIOS config */ |
| 5655 | err = alc882_parse_auto_config(codec); |
| 5656 | if (err < 0) |
| 5657 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5658 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5659 | if (!spec->no_analog && has_cdefine_beep(codec)) { |
| 5660 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5661 | if (err < 0) |
| 5662 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5663 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5664 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5665 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5666 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5667 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 5668 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 5669 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5670 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5671 | |
| 5672 | error: |
| 5673 | alc_free(codec); |
| 5674 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5675 | } |
| 5676 | |
| 5677 | |
| 5678 | /* |
| 5679 | * ALC262 support |
| 5680 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5681 | static int alc262_parse_auto_config(struct hda_codec *codec) |
| 5682 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5683 | static const hda_nid_t alc262_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5684 | static const hda_nid_t alc262_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 5685 | return alc_parse_auto_config(codec, alc262_ignore, alc262_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5686 | } |
| 5687 | |
| 5688 | /* |
| 5689 | * Pin config fixes |
| 5690 | */ |
| 5691 | enum { |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5692 | ALC262_FIXUP_FSC_H270, |
| 5693 | ALC262_FIXUP_HP_Z200, |
| 5694 | ALC262_FIXUP_TYAN, |
Takashi Iwai | c470150 | 2011-11-07 14:20:07 +0100 | [diff] [blame] | 5695 | ALC262_FIXUP_LENOVO_3000, |
Takashi Iwai | b42590b | 2011-11-07 14:41:01 +0100 | [diff] [blame] | 5696 | ALC262_FIXUP_BENQ, |
| 5697 | ALC262_FIXUP_BENQ_T31, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5698 | ALC262_FIXUP_INV_DMIC, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5699 | }; |
| 5700 | |
| 5701 | static const struct alc_fixup alc262_fixups[] = { |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5702 | [ALC262_FIXUP_FSC_H270] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5703 | .type = ALC_FIXUP_PINS, |
| 5704 | .v.pins = (const struct alc_pincfg[]) { |
| 5705 | { 0x14, 0x99130110 }, /* speaker */ |
| 5706 | { 0x15, 0x0221142f }, /* front HP */ |
| 5707 | { 0x1b, 0x0121141f }, /* rear HP */ |
| 5708 | { } |
| 5709 | } |
| 5710 | }, |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5711 | [ALC262_FIXUP_HP_Z200] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5712 | .type = ALC_FIXUP_PINS, |
| 5713 | .v.pins = (const struct alc_pincfg[]) { |
| 5714 | { 0x16, 0x99130120 }, /* internal speaker */ |
| 5715 | { } |
| 5716 | } |
| 5717 | }, |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5718 | [ALC262_FIXUP_TYAN] = { |
| 5719 | .type = ALC_FIXUP_PINS, |
| 5720 | .v.pins = (const struct alc_pincfg[]) { |
| 5721 | { 0x14, 0x1993e1f0 }, /* int AUX */ |
| 5722 | { } |
| 5723 | } |
| 5724 | }, |
Takashi Iwai | c470150 | 2011-11-07 14:20:07 +0100 | [diff] [blame] | 5725 | [ALC262_FIXUP_LENOVO_3000] = { |
| 5726 | .type = ALC_FIXUP_VERBS, |
| 5727 | .v.verbs = (const struct hda_verb[]) { |
| 5728 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 }, |
Takashi Iwai | b42590b | 2011-11-07 14:41:01 +0100 | [diff] [blame] | 5729 | {} |
| 5730 | }, |
| 5731 | .chained = true, |
| 5732 | .chain_id = ALC262_FIXUP_BENQ, |
| 5733 | }, |
| 5734 | [ALC262_FIXUP_BENQ] = { |
| 5735 | .type = ALC_FIXUP_VERBS, |
| 5736 | .v.verbs = (const struct hda_verb[]) { |
Takashi Iwai | c470150 | 2011-11-07 14:20:07 +0100 | [diff] [blame] | 5737 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5738 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 }, |
| 5739 | {} |
| 5740 | } |
| 5741 | }, |
Takashi Iwai | b42590b | 2011-11-07 14:41:01 +0100 | [diff] [blame] | 5742 | [ALC262_FIXUP_BENQ_T31] = { |
| 5743 | .type = ALC_FIXUP_VERBS, |
| 5744 | .v.verbs = (const struct hda_verb[]) { |
| 5745 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5746 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 }, |
| 5747 | {} |
| 5748 | } |
| 5749 | }, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5750 | [ALC262_FIXUP_INV_DMIC] = { |
| 5751 | .type = ALC_FIXUP_FUNC, |
| 5752 | .v.func = alc_fixup_inv_dmic_0x12, |
| 5753 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5754 | }; |
| 5755 | |
| 5756 | static const struct snd_pci_quirk alc262_fixup_tbl[] = { |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5757 | SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200", ALC262_FIXUP_HP_Z200), |
Takashi Iwai | 3dcd3be | 2011-11-07 14:59:40 +0100 | [diff] [blame] | 5758 | SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FIXUP_BENQ), |
| 5759 | SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FIXUP_BENQ), |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5760 | SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_FIXUP_TYAN), |
| 5761 | SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", ALC262_FIXUP_FSC_H270), |
Takashi Iwai | c470150 | 2011-11-07 14:20:07 +0100 | [diff] [blame] | 5762 | SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000", ALC262_FIXUP_LENOVO_3000), |
Takashi Iwai | b42590b | 2011-11-07 14:41:01 +0100 | [diff] [blame] | 5763 | SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_FIXUP_BENQ), |
| 5764 | SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_FIXUP_BENQ_T31), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5765 | {} |
| 5766 | }; |
| 5767 | |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5768 | static const struct alc_model_fixup alc262_fixup_models[] = { |
| 5769 | {.id = ALC262_FIXUP_INV_DMIC, .name = "inv-dmic"}, |
| 5770 | {} |
| 5771 | }; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5772 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5773 | /* |
| 5774 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5775 | static int patch_alc262(struct hda_codec *codec) |
| 5776 | { |
| 5777 | struct alc_spec *spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5778 | int err; |
| 5779 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 5780 | err = alc_alloc_spec(codec, 0x0b); |
| 5781 | if (err < 0) |
| 5782 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5783 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 5784 | spec = codec->spec; |
Takashi Iwai | 37c0420 | 2012-12-18 14:22:45 +0100 | [diff] [blame] | 5785 | spec->shared_mic_vref_pin = 0x18; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5786 | |
| 5787 | #if 0 |
| 5788 | /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is |
| 5789 | * under-run |
| 5790 | */ |
| 5791 | { |
| 5792 | int tmp; |
| 5793 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); |
| 5794 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); |
| 5795 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); |
| 5796 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80); |
| 5797 | } |
| 5798 | #endif |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5799 | alc_fix_pll_init(codec, 0x20, 0x0a, 10); |
| 5800 | |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5801 | alc_pick_fixup(codec, alc262_fixup_models, alc262_fixup_tbl, |
| 5802 | alc262_fixups); |
Takashi Iwai | 42399f7 | 2011-11-07 17:18:44 +0100 | [diff] [blame] | 5803 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5804 | |
Takashi Iwai | af741c1 | 2012-05-07 18:09:48 +0200 | [diff] [blame] | 5805 | alc_auto_parse_customize_define(codec); |
| 5806 | |
Takashi Iwai | 42399f7 | 2011-11-07 17:18:44 +0100 | [diff] [blame] | 5807 | /* automatic parse from the BIOS config */ |
| 5808 | err = alc262_parse_auto_config(codec); |
| 5809 | if (err < 0) |
| 5810 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5811 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5812 | if (!spec->no_analog && has_cdefine_beep(codec)) { |
| 5813 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5814 | if (err < 0) |
| 5815 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5816 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5817 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5818 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5819 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5820 | spec->shutup = alc_eapd_shutup; |
| 5821 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 5822 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 5823 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5824 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5825 | |
| 5826 | error: |
| 5827 | alc_free(codec); |
| 5828 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5829 | } |
| 5830 | |
| 5831 | /* |
| 5832 | * ALC268 |
| 5833 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5834 | /* bind Beep switches of both NID 0x0f and 0x10 */ |
| 5835 | static const struct hda_bind_ctls alc268_bind_beep_sw = { |
| 5836 | .ops = &snd_hda_bind_sw, |
| 5837 | .values = { |
| 5838 | HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT), |
| 5839 | HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT), |
| 5840 | 0 |
| 5841 | }, |
| 5842 | }; |
| 5843 | |
| 5844 | static const struct snd_kcontrol_new alc268_beep_mixer[] = { |
| 5845 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT), |
| 5846 | HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw), |
| 5847 | { } |
| 5848 | }; |
| 5849 | |
| 5850 | /* set PCBEEP vol = 0, mute connections */ |
| 5851 | static const struct hda_verb alc268_beep_init_verbs[] = { |
| 5852 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5853 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 5854 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 5855 | { } |
| 5856 | }; |
| 5857 | |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5858 | enum { |
| 5859 | ALC268_FIXUP_INV_DMIC, |
Takashi Iwai | cb76640 | 2012-10-20 10:55:21 +0200 | [diff] [blame] | 5860 | ALC268_FIXUP_HP_EAPD, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5861 | }; |
| 5862 | |
| 5863 | static const struct alc_fixup alc268_fixups[] = { |
| 5864 | [ALC268_FIXUP_INV_DMIC] = { |
| 5865 | .type = ALC_FIXUP_FUNC, |
| 5866 | .v.func = alc_fixup_inv_dmic_0x12, |
| 5867 | }, |
Takashi Iwai | cb76640 | 2012-10-20 10:55:21 +0200 | [diff] [blame] | 5868 | [ALC268_FIXUP_HP_EAPD] = { |
| 5869 | .type = ALC_FIXUP_VERBS, |
| 5870 | .v.verbs = (const struct hda_verb[]) { |
| 5871 | {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0}, |
| 5872 | {} |
| 5873 | } |
| 5874 | }, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5875 | }; |
| 5876 | |
| 5877 | static const struct alc_model_fixup alc268_fixup_models[] = { |
| 5878 | {.id = ALC268_FIXUP_INV_DMIC, .name = "inv-dmic"}, |
Takashi Iwai | cb76640 | 2012-10-20 10:55:21 +0200 | [diff] [blame] | 5879 | {.id = ALC268_FIXUP_HP_EAPD, .name = "hp-eapd"}, |
| 5880 | {} |
| 5881 | }; |
| 5882 | |
| 5883 | static const struct snd_pci_quirk alc268_fixup_tbl[] = { |
| 5884 | /* below is codec SSID since multiple Toshiba laptops have the |
| 5885 | * same PCI SSID 1179:ff00 |
| 5886 | */ |
| 5887 | SND_PCI_QUIRK(0x1179, 0xff06, "Toshiba P200", ALC268_FIXUP_HP_EAPD), |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5888 | {} |
| 5889 | }; |
| 5890 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5891 | /* |
| 5892 | * BIOS auto configuration |
| 5893 | */ |
| 5894 | static int alc268_parse_auto_config(struct hda_codec *codec) |
| 5895 | { |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5896 | static const hda_nid_t alc268_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5897 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5898 | int err = alc_parse_auto_config(codec, NULL, alc268_ssids); |
| 5899 | if (err > 0) { |
| 5900 | if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d) { |
| 5901 | add_mixer(spec, alc268_beep_mixer); |
Takashi Iwai | c9ce6b2 | 2012-12-18 18:12:44 +0100 | [diff] [blame] | 5902 | snd_hda_add_verbs(codec, alc268_beep_init_verbs); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5903 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5904 | } |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5905 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5906 | } |
| 5907 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5908 | /* |
| 5909 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5910 | static int patch_alc268(struct hda_codec *codec) |
| 5911 | { |
| 5912 | struct alc_spec *spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5913 | int i, has_beep, err; |
| 5914 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5915 | /* ALC268 has no aa-loopback mixer */ |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 5916 | err = alc_alloc_spec(codec, 0); |
| 5917 | if (err < 0) |
| 5918 | return err; |
| 5919 | |
| 5920 | spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5921 | |
Takashi Iwai | cb76640 | 2012-10-20 10:55:21 +0200 | [diff] [blame] | 5922 | alc_pick_fixup(codec, alc268_fixup_models, alc268_fixup_tbl, alc268_fixups); |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5923 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
| 5924 | |
Takashi Iwai | 6ebb805 | 2011-08-16 15:15:40 +0200 | [diff] [blame] | 5925 | /* automatic parse from the BIOS config */ |
| 5926 | err = alc268_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5927 | if (err < 0) |
| 5928 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5929 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5930 | has_beep = 0; |
| 5931 | for (i = 0; i < spec->num_mixers; i++) { |
| 5932 | if (spec->mixers[i] == alc268_beep_mixer) { |
| 5933 | has_beep = 1; |
| 5934 | break; |
| 5935 | } |
| 5936 | } |
| 5937 | |
| 5938 | if (has_beep) { |
| 5939 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5940 | if (err < 0) |
| 5941 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5942 | if (!query_amp_caps(codec, 0x1d, HDA_INPUT)) |
| 5943 | /* override the amp caps for beep generator */ |
| 5944 | snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT, |
| 5945 | (0x0c << AC_AMPCAP_OFFSET_SHIFT) | |
| 5946 | (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) | |
| 5947 | (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) | |
| 5948 | (0 << AC_AMPCAP_MUTE_SHIFT)); |
| 5949 | } |
| 5950 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5951 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5952 | spec->shutup = alc_eapd_shutup; |
| 5953 | |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5954 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 5955 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5956 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5957 | |
| 5958 | error: |
| 5959 | alc_free(codec); |
| 5960 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5961 | } |
| 5962 | |
| 5963 | /* |
| 5964 | * ALC269 |
| 5965 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5966 | static const struct hda_pcm_stream alc269_44k_pcm_analog_playback = { |
| 5967 | .substreams = 1, |
| 5968 | .channels_min = 2, |
| 5969 | .channels_max = 8, |
| 5970 | .rates = SNDRV_PCM_RATE_44100, /* fixed rate */ |
| 5971 | /* NID is set in alc_build_pcms */ |
| 5972 | .ops = { |
| 5973 | .open = alc_playback_pcm_open, |
| 5974 | .prepare = alc_playback_pcm_prepare, |
| 5975 | .cleanup = alc_playback_pcm_cleanup |
| 5976 | }, |
| 5977 | }; |
| 5978 | |
| 5979 | static const struct hda_pcm_stream alc269_44k_pcm_analog_capture = { |
| 5980 | .substreams = 1, |
| 5981 | .channels_min = 2, |
| 5982 | .channels_max = 2, |
| 5983 | .rates = SNDRV_PCM_RATE_44100, /* fixed rate */ |
| 5984 | /* NID is set in alc_build_pcms */ |
| 5985 | }; |
| 5986 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5987 | /* different alc269-variants */ |
| 5988 | enum { |
| 5989 | ALC269_TYPE_ALC269VA, |
| 5990 | ALC269_TYPE_ALC269VB, |
| 5991 | ALC269_TYPE_ALC269VC, |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 5992 | ALC269_TYPE_ALC269VD, |
Kailang Yang | 065380f | 2013-01-10 10:25:48 +0100 | [diff] [blame] | 5993 | ALC269_TYPE_ALC280, |
| 5994 | ALC269_TYPE_ALC282, |
| 5995 | ALC269_TYPE_ALC284, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5996 | }; |
| 5997 | |
| 5998 | /* |
| 5999 | * BIOS auto configuration |
| 6000 | */ |
| 6001 | static int alc269_parse_auto_config(struct hda_codec *codec) |
| 6002 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6003 | static const hda_nid_t alc269_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6004 | static const hda_nid_t alc269_ssids[] = { 0, 0x1b, 0x14, 0x21 }; |
| 6005 | static const hda_nid_t alc269va_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 6006 | struct alc_spec *spec = codec->spec; |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 6007 | const hda_nid_t *ssids; |
| 6008 | |
| 6009 | switch (spec->codec_variant) { |
| 6010 | case ALC269_TYPE_ALC269VA: |
| 6011 | case ALC269_TYPE_ALC269VC: |
Kailang Yang | 065380f | 2013-01-10 10:25:48 +0100 | [diff] [blame] | 6012 | case ALC269_TYPE_ALC280: |
| 6013 | case ALC269_TYPE_ALC284: |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 6014 | ssids = alc269va_ssids; |
| 6015 | break; |
| 6016 | case ALC269_TYPE_ALC269VB: |
| 6017 | case ALC269_TYPE_ALC269VD: |
Kailang Yang | 065380f | 2013-01-10 10:25:48 +0100 | [diff] [blame] | 6018 | case ALC269_TYPE_ALC282: |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 6019 | ssids = alc269_ssids; |
| 6020 | break; |
| 6021 | default: |
| 6022 | ssids = alc269_ssids; |
| 6023 | break; |
| 6024 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6025 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6026 | return alc_parse_auto_config(codec, alc269_ignore, ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6027 | } |
| 6028 | |
Kailang Yang | 1387e2d | 2012-11-08 10:23:18 +0100 | [diff] [blame] | 6029 | static void alc269vb_toggle_power_output(struct hda_codec *codec, int power_up) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6030 | { |
| 6031 | int val = alc_read_coef_idx(codec, 0x04); |
| 6032 | if (power_up) |
| 6033 | val |= 1 << 11; |
| 6034 | else |
| 6035 | val &= ~(1 << 11); |
| 6036 | alc_write_coef_idx(codec, 0x04, val); |
| 6037 | } |
| 6038 | |
| 6039 | static void alc269_shutup(struct hda_codec *codec) |
| 6040 | { |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 6041 | struct alc_spec *spec = codec->spec; |
| 6042 | |
| 6043 | if (spec->codec_variant != ALC269_TYPE_ALC269VB) |
| 6044 | return; |
| 6045 | |
Kailang Yang | 1387e2d | 2012-11-08 10:23:18 +0100 | [diff] [blame] | 6046 | if (spec->codec_variant == ALC269_TYPE_ALC269VB) |
| 6047 | alc269vb_toggle_power_output(codec, 0); |
| 6048 | if (spec->codec_variant == ALC269_TYPE_ALC269VB && |
| 6049 | (alc_get_coef0(codec) & 0x00ff) == 0x018) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6050 | msleep(150); |
| 6051 | } |
| 6052 | } |
| 6053 | |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 6054 | #ifdef CONFIG_PM |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6055 | static int alc269_resume(struct hda_codec *codec) |
| 6056 | { |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 6057 | struct alc_spec *spec = codec->spec; |
| 6058 | |
Kailang Yang | 1387e2d | 2012-11-08 10:23:18 +0100 | [diff] [blame] | 6059 | if (spec->codec_variant == ALC269_TYPE_ALC269VB) |
| 6060 | alc269vb_toggle_power_output(codec, 0); |
| 6061 | if (spec->codec_variant == ALC269_TYPE_ALC269VB && |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 6062 | (alc_get_coef0(codec) & 0x00ff) == 0x018) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6063 | msleep(150); |
| 6064 | } |
| 6065 | |
| 6066 | codec->patch_ops.init(codec); |
| 6067 | |
Kailang Yang | 1387e2d | 2012-11-08 10:23:18 +0100 | [diff] [blame] | 6068 | if (spec->codec_variant == ALC269_TYPE_ALC269VB) |
| 6069 | alc269vb_toggle_power_output(codec, 1); |
| 6070 | if (spec->codec_variant == ALC269_TYPE_ALC269VB && |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 6071 | (alc_get_coef0(codec) & 0x00ff) == 0x017) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6072 | msleep(200); |
| 6073 | } |
| 6074 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6075 | snd_hda_codec_resume_amp(codec); |
| 6076 | snd_hda_codec_resume_cache(codec); |
| 6077 | hda_call_check_power_status(codec, 0x01); |
| 6078 | return 0; |
| 6079 | } |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 6080 | #endif /* CONFIG_PM */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6081 | |
David Henningsson | 108cc10 | 2012-07-20 10:37:25 +0200 | [diff] [blame] | 6082 | static void alc269_fixup_pincfg_no_hp_to_lineout(struct hda_codec *codec, |
| 6083 | const struct alc_fixup *fix, int action) |
| 6084 | { |
| 6085 | struct alc_spec *spec = codec->spec; |
| 6086 | |
| 6087 | if (action == ALC_FIXUP_ACT_PRE_PROBE) |
| 6088 | spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP; |
| 6089 | } |
| 6090 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6091 | static void alc269_fixup_hweq(struct hda_codec *codec, |
| 6092 | const struct alc_fixup *fix, int action) |
| 6093 | { |
| 6094 | int coef; |
| 6095 | |
| 6096 | if (action != ALC_FIXUP_ACT_INIT) |
| 6097 | return; |
| 6098 | coef = alc_read_coef_idx(codec, 0x1e); |
| 6099 | alc_write_coef_idx(codec, 0x1e, coef | 0x80); |
| 6100 | } |
| 6101 | |
| 6102 | static void alc271_fixup_dmic(struct hda_codec *codec, |
| 6103 | const struct alc_fixup *fix, int action) |
| 6104 | { |
| 6105 | static const struct hda_verb verbs[] = { |
| 6106 | {0x20, AC_VERB_SET_COEF_INDEX, 0x0d}, |
| 6107 | {0x20, AC_VERB_SET_PROC_COEF, 0x4000}, |
| 6108 | {} |
| 6109 | }; |
| 6110 | unsigned int cfg; |
| 6111 | |
| 6112 | if (strcmp(codec->chip_name, "ALC271X")) |
| 6113 | return; |
| 6114 | cfg = snd_hda_codec_get_pincfg(codec, 0x12); |
| 6115 | if (get_defcfg_connect(cfg) == AC_JACK_PORT_FIXED) |
| 6116 | snd_hda_sequence_write(codec, verbs); |
| 6117 | } |
| 6118 | |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 6119 | static void alc269_fixup_pcm_44k(struct hda_codec *codec, |
| 6120 | const struct alc_fixup *fix, int action) |
| 6121 | { |
| 6122 | struct alc_spec *spec = codec->spec; |
| 6123 | |
| 6124 | if (action != ALC_FIXUP_ACT_PROBE) |
| 6125 | return; |
| 6126 | |
| 6127 | /* Due to a hardware problem on Lenovo Ideadpad, we need to |
| 6128 | * fix the sample rate of analog I/O to 44.1kHz |
| 6129 | */ |
| 6130 | spec->stream_analog_playback = &alc269_44k_pcm_analog_playback; |
| 6131 | spec->stream_analog_capture = &alc269_44k_pcm_analog_capture; |
| 6132 | } |
| 6133 | |
Takashi Iwai | adabb3e | 2011-08-03 07:48:37 +0200 | [diff] [blame] | 6134 | static void alc269_fixup_stereo_dmic(struct hda_codec *codec, |
| 6135 | const struct alc_fixup *fix, int action) |
| 6136 | { |
| 6137 | int coef; |
| 6138 | |
| 6139 | if (action != ALC_FIXUP_ACT_INIT) |
| 6140 | return; |
| 6141 | /* The digital-mic unit sends PDM (differential signal) instead of |
| 6142 | * the standard PCM, thus you can't record a valid mono stream as is. |
| 6143 | * Below is a workaround specific to ALC269 to control the dmic |
| 6144 | * signal source as mono. |
| 6145 | */ |
| 6146 | coef = alc_read_coef_idx(codec, 0x07); |
| 6147 | alc_write_coef_idx(codec, 0x07, coef | 0x80); |
| 6148 | } |
| 6149 | |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 6150 | static void alc269_quanta_automute(struct hda_codec *codec) |
| 6151 | { |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 6152 | update_outputs(codec); |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 6153 | |
| 6154 | snd_hda_codec_write(codec, 0x20, 0, |
| 6155 | AC_VERB_SET_COEF_INDEX, 0x0c); |
| 6156 | snd_hda_codec_write(codec, 0x20, 0, |
| 6157 | AC_VERB_SET_PROC_COEF, 0x680); |
| 6158 | |
| 6159 | snd_hda_codec_write(codec, 0x20, 0, |
| 6160 | AC_VERB_SET_COEF_INDEX, 0x0c); |
| 6161 | snd_hda_codec_write(codec, 0x20, 0, |
| 6162 | AC_VERB_SET_PROC_COEF, 0x480); |
| 6163 | } |
| 6164 | |
| 6165 | static void alc269_fixup_quanta_mute(struct hda_codec *codec, |
| 6166 | const struct alc_fixup *fix, int action) |
| 6167 | { |
| 6168 | struct alc_spec *spec = codec->spec; |
| 6169 | if (action != ALC_FIXUP_ACT_PROBE) |
| 6170 | return; |
| 6171 | spec->automute_hook = alc269_quanta_automute; |
| 6172 | } |
| 6173 | |
David Henningsson | 6d3cd5d | 2013-01-07 12:03:47 +0100 | [diff] [blame] | 6174 | /* update mute-LED according to the speaker mute state via mic1 VREF pin */ |
| 6175 | static void alc269_fixup_mic1_mute_hook(void *private_data, int enabled) |
| 6176 | { |
| 6177 | struct hda_codec *codec = private_data; |
| 6178 | unsigned int pinval = AC_PINCTL_IN_EN + (enabled ? |
| 6179 | AC_PINCTL_VREF_HIZ : AC_PINCTL_VREF_80); |
| 6180 | snd_hda_set_pin_ctl_cache(codec, 0x18, pinval); |
| 6181 | } |
| 6182 | |
| 6183 | static void alc269_fixup_mic1_mute(struct hda_codec *codec, |
| 6184 | const struct alc_fixup *fix, int action) |
| 6185 | { |
| 6186 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 3bd7b64 | 2012-12-18 14:57:09 +0100 | [diff] [blame] | 6187 | if (action == ALC_FIXUP_ACT_PROBE) |
David Henningsson | 6d3cd5d | 2013-01-07 12:03:47 +0100 | [diff] [blame] | 6188 | spec->vmaster_mute.hook = alc269_fixup_mic1_mute_hook; |
David Henningsson | 6d3cd5d | 2013-01-07 12:03:47 +0100 | [diff] [blame] | 6189 | } |
| 6190 | |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 6191 | /* update mute-LED according to the speaker mute state via mic2 VREF pin */ |
| 6192 | static void alc269_fixup_mic2_mute_hook(void *private_data, int enabled) |
| 6193 | { |
| 6194 | struct hda_codec *codec = private_data; |
| 6195 | unsigned int pinval = enabled ? 0x20 : 0x24; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 6196 | snd_hda_set_pin_ctl_cache(codec, 0x19, pinval); |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 6197 | } |
| 6198 | |
| 6199 | static void alc269_fixup_mic2_mute(struct hda_codec *codec, |
| 6200 | const struct alc_fixup *fix, int action) |
| 6201 | { |
| 6202 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 3bd7b64 | 2012-12-18 14:57:09 +0100 | [diff] [blame] | 6203 | if (action == ALC_FIXUP_ACT_PROBE) |
Takashi Iwai | d2f344b | 2012-03-12 16:59:58 +0100 | [diff] [blame] | 6204 | spec->vmaster_mute.hook = alc269_fixup_mic2_mute_hook; |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 6205 | } |
| 6206 | |
Dylan Reid | 08a978d | 2012-11-18 22:56:40 -0800 | [diff] [blame] | 6207 | static void alc271_hp_gate_mic_jack(struct hda_codec *codec, |
| 6208 | const struct alc_fixup *fix, |
| 6209 | int action) |
| 6210 | { |
| 6211 | struct alc_spec *spec = codec->spec; |
| 6212 | |
Takashi Iwai | ab16c6d | 2012-11-29 09:56:50 +0100 | [diff] [blame^] | 6213 | if (snd_BUG_ON(!spec->am_entry[1].pin || !spec->autocfg.hp_pins[0])) |
| 6214 | return; |
Dylan Reid | 08a978d | 2012-11-18 22:56:40 -0800 | [diff] [blame] | 6215 | if (action == ALC_FIXUP_ACT_PROBE) |
Takashi Iwai | ab16c6d | 2012-11-29 09:56:50 +0100 | [diff] [blame^] | 6216 | snd_hda_jack_set_gating_jack(codec, spec->am_entry[1].pin, |
Dylan Reid | 08a978d | 2012-11-18 22:56:40 -0800 | [diff] [blame] | 6217 | spec->autocfg.hp_pins[0]); |
| 6218 | } |
David Henningsson | 693b613 | 2012-06-22 19:12:10 +0200 | [diff] [blame] | 6219 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6220 | enum { |
| 6221 | ALC269_FIXUP_SONY_VAIO, |
| 6222 | ALC275_FIXUP_SONY_VAIO_GPIO2, |
| 6223 | ALC269_FIXUP_DELL_M101Z, |
| 6224 | ALC269_FIXUP_SKU_IGNORE, |
| 6225 | ALC269_FIXUP_ASUS_G73JW, |
| 6226 | ALC269_FIXUP_LENOVO_EAPD, |
| 6227 | ALC275_FIXUP_SONY_HWEQ, |
| 6228 | ALC271_FIXUP_DMIC, |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 6229 | ALC269_FIXUP_PCM_44K, |
Takashi Iwai | adabb3e | 2011-08-03 07:48:37 +0200 | [diff] [blame] | 6230 | ALC269_FIXUP_STEREO_DMIC, |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 6231 | ALC269_FIXUP_QUANTA_MUTE, |
| 6232 | ALC269_FIXUP_LIFEBOOK, |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6233 | ALC269_FIXUP_AMIC, |
| 6234 | ALC269_FIXUP_DMIC, |
| 6235 | ALC269VB_FIXUP_AMIC, |
| 6236 | ALC269VB_FIXUP_DMIC, |
David Henningsson | 6d3cd5d | 2013-01-07 12:03:47 +0100 | [diff] [blame] | 6237 | ALC269_FIXUP_MIC1_MUTE_LED, |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 6238 | ALC269_FIXUP_MIC2_MUTE_LED, |
David Henningsson | 693b613 | 2012-06-22 19:12:10 +0200 | [diff] [blame] | 6239 | ALC269_FIXUP_INV_DMIC, |
David Henningsson | 108cc10 | 2012-07-20 10:37:25 +0200 | [diff] [blame] | 6240 | ALC269_FIXUP_LENOVO_DOCK, |
| 6241 | ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT, |
Dylan Reid | 08a978d | 2012-11-18 22:56:40 -0800 | [diff] [blame] | 6242 | ALC271_FIXUP_AMIC_MIC2, |
| 6243 | ALC271_FIXUP_HP_GATE_MIC_JACK, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6244 | }; |
| 6245 | |
| 6246 | static const struct alc_fixup alc269_fixups[] = { |
| 6247 | [ALC269_FIXUP_SONY_VAIO] = { |
| 6248 | .type = ALC_FIXUP_VERBS, |
| 6249 | .v.verbs = (const struct hda_verb[]) { |
| 6250 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREFGRD}, |
| 6251 | {} |
| 6252 | } |
| 6253 | }, |
| 6254 | [ALC275_FIXUP_SONY_VAIO_GPIO2] = { |
| 6255 | .type = ALC_FIXUP_VERBS, |
| 6256 | .v.verbs = (const struct hda_verb[]) { |
| 6257 | {0x01, AC_VERB_SET_GPIO_MASK, 0x04}, |
| 6258 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04}, |
| 6259 | {0x01, AC_VERB_SET_GPIO_DATA, 0x00}, |
| 6260 | { } |
| 6261 | }, |
| 6262 | .chained = true, |
| 6263 | .chain_id = ALC269_FIXUP_SONY_VAIO |
| 6264 | }, |
| 6265 | [ALC269_FIXUP_DELL_M101Z] = { |
| 6266 | .type = ALC_FIXUP_VERBS, |
| 6267 | .v.verbs = (const struct hda_verb[]) { |
| 6268 | /* Enables internal speaker */ |
| 6269 | {0x20, AC_VERB_SET_COEF_INDEX, 13}, |
| 6270 | {0x20, AC_VERB_SET_PROC_COEF, 0x4040}, |
| 6271 | {} |
| 6272 | } |
| 6273 | }, |
| 6274 | [ALC269_FIXUP_SKU_IGNORE] = { |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 6275 | .type = ALC_FIXUP_FUNC, |
| 6276 | .v.func = alc_fixup_sku_ignore, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6277 | }, |
| 6278 | [ALC269_FIXUP_ASUS_G73JW] = { |
| 6279 | .type = ALC_FIXUP_PINS, |
| 6280 | .v.pins = (const struct alc_pincfg[]) { |
| 6281 | { 0x17, 0x99130111 }, /* subwoofer */ |
| 6282 | { } |
| 6283 | } |
| 6284 | }, |
| 6285 | [ALC269_FIXUP_LENOVO_EAPD] = { |
| 6286 | .type = ALC_FIXUP_VERBS, |
| 6287 | .v.verbs = (const struct hda_verb[]) { |
| 6288 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0}, |
| 6289 | {} |
| 6290 | } |
| 6291 | }, |
| 6292 | [ALC275_FIXUP_SONY_HWEQ] = { |
| 6293 | .type = ALC_FIXUP_FUNC, |
| 6294 | .v.func = alc269_fixup_hweq, |
| 6295 | .chained = true, |
| 6296 | .chain_id = ALC275_FIXUP_SONY_VAIO_GPIO2 |
| 6297 | }, |
| 6298 | [ALC271_FIXUP_DMIC] = { |
| 6299 | .type = ALC_FIXUP_FUNC, |
| 6300 | .v.func = alc271_fixup_dmic, |
| 6301 | }, |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 6302 | [ALC269_FIXUP_PCM_44K] = { |
| 6303 | .type = ALC_FIXUP_FUNC, |
| 6304 | .v.func = alc269_fixup_pcm_44k, |
David Henningsson | 012e7eb | 2012-08-08 08:43:37 +0200 | [diff] [blame] | 6305 | .chained = true, |
| 6306 | .chain_id = ALC269_FIXUP_QUANTA_MUTE |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 6307 | }, |
Takashi Iwai | adabb3e | 2011-08-03 07:48:37 +0200 | [diff] [blame] | 6308 | [ALC269_FIXUP_STEREO_DMIC] = { |
| 6309 | .type = ALC_FIXUP_FUNC, |
| 6310 | .v.func = alc269_fixup_stereo_dmic, |
| 6311 | }, |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 6312 | [ALC269_FIXUP_QUANTA_MUTE] = { |
| 6313 | .type = ALC_FIXUP_FUNC, |
| 6314 | .v.func = alc269_fixup_quanta_mute, |
| 6315 | }, |
| 6316 | [ALC269_FIXUP_LIFEBOOK] = { |
| 6317 | .type = ALC_FIXUP_PINS, |
| 6318 | .v.pins = (const struct alc_pincfg[]) { |
| 6319 | { 0x1a, 0x2101103f }, /* dock line-out */ |
| 6320 | { 0x1b, 0x23a11040 }, /* dock mic-in */ |
| 6321 | { } |
| 6322 | }, |
| 6323 | .chained = true, |
| 6324 | .chain_id = ALC269_FIXUP_QUANTA_MUTE |
| 6325 | }, |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6326 | [ALC269_FIXUP_AMIC] = { |
| 6327 | .type = ALC_FIXUP_PINS, |
| 6328 | .v.pins = (const struct alc_pincfg[]) { |
| 6329 | { 0x14, 0x99130110 }, /* speaker */ |
| 6330 | { 0x15, 0x0121401f }, /* HP out */ |
| 6331 | { 0x18, 0x01a19c20 }, /* mic */ |
| 6332 | { 0x19, 0x99a3092f }, /* int-mic */ |
| 6333 | { } |
| 6334 | }, |
| 6335 | }, |
| 6336 | [ALC269_FIXUP_DMIC] = { |
| 6337 | .type = ALC_FIXUP_PINS, |
| 6338 | .v.pins = (const struct alc_pincfg[]) { |
| 6339 | { 0x12, 0x99a3092f }, /* int-mic */ |
| 6340 | { 0x14, 0x99130110 }, /* speaker */ |
| 6341 | { 0x15, 0x0121401f }, /* HP out */ |
| 6342 | { 0x18, 0x01a19c20 }, /* mic */ |
| 6343 | { } |
| 6344 | }, |
| 6345 | }, |
| 6346 | [ALC269VB_FIXUP_AMIC] = { |
| 6347 | .type = ALC_FIXUP_PINS, |
| 6348 | .v.pins = (const struct alc_pincfg[]) { |
| 6349 | { 0x14, 0x99130110 }, /* speaker */ |
| 6350 | { 0x18, 0x01a19c20 }, /* mic */ |
| 6351 | { 0x19, 0x99a3092f }, /* int-mic */ |
| 6352 | { 0x21, 0x0121401f }, /* HP out */ |
| 6353 | { } |
| 6354 | }, |
| 6355 | }, |
David Henningsson | 2267ea9 | 2012-01-03 08:45:56 +0100 | [diff] [blame] | 6356 | [ALC269VB_FIXUP_DMIC] = { |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6357 | .type = ALC_FIXUP_PINS, |
| 6358 | .v.pins = (const struct alc_pincfg[]) { |
| 6359 | { 0x12, 0x99a3092f }, /* int-mic */ |
| 6360 | { 0x14, 0x99130110 }, /* speaker */ |
| 6361 | { 0x18, 0x01a19c20 }, /* mic */ |
| 6362 | { 0x21, 0x0121401f }, /* HP out */ |
| 6363 | { } |
| 6364 | }, |
| 6365 | }, |
David Henningsson | 6d3cd5d | 2013-01-07 12:03:47 +0100 | [diff] [blame] | 6366 | [ALC269_FIXUP_MIC1_MUTE_LED] = { |
| 6367 | .type = ALC_FIXUP_FUNC, |
| 6368 | .v.func = alc269_fixup_mic1_mute, |
| 6369 | }, |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 6370 | [ALC269_FIXUP_MIC2_MUTE_LED] = { |
| 6371 | .type = ALC_FIXUP_FUNC, |
| 6372 | .v.func = alc269_fixup_mic2_mute, |
| 6373 | }, |
David Henningsson | 693b613 | 2012-06-22 19:12:10 +0200 | [diff] [blame] | 6374 | [ALC269_FIXUP_INV_DMIC] = { |
| 6375 | .type = ALC_FIXUP_FUNC, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 6376 | .v.func = alc_fixup_inv_dmic_0x12, |
David Henningsson | 693b613 | 2012-06-22 19:12:10 +0200 | [diff] [blame] | 6377 | }, |
David Henningsson | 108cc10 | 2012-07-20 10:37:25 +0200 | [diff] [blame] | 6378 | [ALC269_FIXUP_LENOVO_DOCK] = { |
| 6379 | .type = ALC_FIXUP_PINS, |
| 6380 | .v.pins = (const struct alc_pincfg[]) { |
| 6381 | { 0x19, 0x23a11040 }, /* dock mic */ |
| 6382 | { 0x1b, 0x2121103f }, /* dock headphone */ |
| 6383 | { } |
| 6384 | }, |
| 6385 | .chained = true, |
| 6386 | .chain_id = ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT |
| 6387 | }, |
| 6388 | [ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT] = { |
| 6389 | .type = ALC_FIXUP_FUNC, |
| 6390 | .v.func = alc269_fixup_pincfg_no_hp_to_lineout, |
| 6391 | }, |
Dylan Reid | 08a978d | 2012-11-18 22:56:40 -0800 | [diff] [blame] | 6392 | [ALC271_FIXUP_AMIC_MIC2] = { |
| 6393 | .type = ALC_FIXUP_PINS, |
| 6394 | .v.pins = (const struct alc_pincfg[]) { |
| 6395 | { 0x14, 0x99130110 }, /* speaker */ |
| 6396 | { 0x19, 0x01a19c20 }, /* mic */ |
| 6397 | { 0x1b, 0x99a7012f }, /* int-mic */ |
| 6398 | { 0x21, 0x0121401f }, /* HP out */ |
| 6399 | { } |
| 6400 | }, |
| 6401 | }, |
| 6402 | [ALC271_FIXUP_HP_GATE_MIC_JACK] = { |
| 6403 | .type = ALC_FIXUP_FUNC, |
| 6404 | .v.func = alc271_hp_gate_mic_jack, |
| 6405 | .chained = true, |
| 6406 | .chain_id = ALC271_FIXUP_AMIC_MIC2, |
| 6407 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6408 | }; |
| 6409 | |
| 6410 | static const struct snd_pci_quirk alc269_fixup_tbl[] = { |
David Henningsson | 693b613 | 2012-06-22 19:12:10 +0200 | [diff] [blame] | 6411 | SND_PCI_QUIRK(0x1025, 0x029b, "Acer 1810TZ", ALC269_FIXUP_INV_DMIC), |
| 6412 | SND_PCI_QUIRK(0x1025, 0x0349, "Acer AOD260", ALC269_FIXUP_INV_DMIC), |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 6413 | SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_MIC2_MUTE_LED), |
David Henningsson | 6d3cd5d | 2013-01-07 12:03:47 +0100 | [diff] [blame] | 6414 | SND_PCI_QUIRK(0x103c, 0x1972, "HP Pavilion 17", ALC269_FIXUP_MIC1_MUTE_LED), |
David Henningsson | 5ac5755 | 2012-04-20 10:01:46 +0200 | [diff] [blame] | 6415 | SND_PCI_QUIRK(0x1043, 0x1427, "Asus Zenbook UX31E", ALC269VB_FIXUP_DMIC), |
Oleksij Rempel | 148728f | 2012-09-21 17:44:58 +0200 | [diff] [blame] | 6416 | SND_PCI_QUIRK(0x1043, 0x1517, "Asus Zenbook UX31A", ALC269VB_FIXUP_DMIC), |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 6417 | SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW), |
David Henningsson | 693b613 | 2012-06-22 19:12:10 +0200 | [diff] [blame] | 6418 | SND_PCI_QUIRK(0x1043, 0x1b13, "Asus U41SV", ALC269_FIXUP_INV_DMIC), |
Takashi Iwai | adabb3e | 2011-08-03 07:48:37 +0200 | [diff] [blame] | 6419 | SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC), |
| 6420 | SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC), |
| 6421 | SND_PCI_QUIRK(0x1043, 0x834a, "ASUS S101", ALC269_FIXUP_STEREO_DMIC), |
| 6422 | SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC), |
| 6423 | SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6424 | SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2), |
| 6425 | SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ), |
| 6426 | SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ), |
| 6427 | SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO), |
| 6428 | SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z), |
Dylan Reid | 08a978d | 2012-11-18 22:56:40 -0800 | [diff] [blame] | 6429 | SND_PCI_QUIRK(0x1025, 0x0742, "Acer AO756", ALC271_FIXUP_HP_GATE_MIC_JACK), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6430 | SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC), |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 6431 | SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook", ALC269_FIXUP_LIFEBOOK), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6432 | SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE), |
| 6433 | SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE), |
| 6434 | SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE), |
| 6435 | SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE), |
| 6436 | SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE), |
Takashi Iwai | 707fba3 | 2012-08-02 09:04:39 +0200 | [diff] [blame] | 6437 | SND_PCI_QUIRK(0x17aa, 0x21f6, "Thinkpad T530", ALC269_FIXUP_LENOVO_DOCK), |
Felix Kaechele | c8415a4 | 2012-08-06 23:02:01 +0200 | [diff] [blame] | 6438 | SND_PCI_QUIRK(0x17aa, 0x21fa, "Thinkpad X230", ALC269_FIXUP_LENOVO_DOCK), |
Stefán Freyr | 84f98fd | 2012-10-19 22:46:00 +0200 | [diff] [blame] | 6439 | SND_PCI_QUIRK(0x17aa, 0x21f3, "Thinkpad T430", ALC269_FIXUP_LENOVO_DOCK), |
Philipp A. Mohrenweiser | 4407be6 | 2012-08-06 13:14:18 +0200 | [diff] [blame] | 6440 | SND_PCI_QUIRK(0x17aa, 0x21fb, "Thinkpad T430s", ALC269_FIXUP_LENOVO_DOCK), |
David Henningsson | 108cc10 | 2012-07-20 10:37:25 +0200 | [diff] [blame] | 6441 | SND_PCI_QUIRK(0x17aa, 0x2203, "Thinkpad X230 Tablet", ALC269_FIXUP_LENOVO_DOCK), |
David Henningsson | 012e7eb | 2012-08-08 08:43:37 +0200 | [diff] [blame] | 6442 | SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_PCM_44K), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6443 | SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD), |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6444 | |
Takashi Iwai | a7f3eed | 2012-02-16 13:03:18 +0100 | [diff] [blame] | 6445 | #if 0 |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6446 | /* Below is a quirk table taken from the old code. |
| 6447 | * Basically the device should work as is without the fixup table. |
| 6448 | * If BIOS doesn't give a proper info, enable the corresponding |
| 6449 | * fixup entry. |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 6450 | */ |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6451 | SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A", |
| 6452 | ALC269_FIXUP_AMIC), |
| 6453 | SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269_FIXUP_AMIC), |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6454 | SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269_FIXUP_AMIC), |
| 6455 | SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_FIXUP_AMIC), |
| 6456 | SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269_FIXUP_AMIC), |
| 6457 | SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269_FIXUP_AMIC), |
| 6458 | SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269_FIXUP_AMIC), |
| 6459 | SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269_FIXUP_AMIC), |
| 6460 | SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_FIXUP_AMIC), |
| 6461 | SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269_FIXUP_AMIC), |
| 6462 | SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_FIXUP_AMIC), |
| 6463 | SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_FIXUP_AMIC), |
| 6464 | SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_FIXUP_AMIC), |
| 6465 | SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_FIXUP_AMIC), |
| 6466 | SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_FIXUP_AMIC), |
| 6467 | SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_FIXUP_AMIC), |
| 6468 | SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_FIXUP_AMIC), |
| 6469 | SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_FIXUP_AMIC), |
| 6470 | SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_FIXUP_AMIC), |
| 6471 | SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_FIXUP_AMIC), |
| 6472 | SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_FIXUP_AMIC), |
| 6473 | SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_FIXUP_AMIC), |
| 6474 | SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_FIXUP_AMIC), |
| 6475 | SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_FIXUP_AMIC), |
| 6476 | SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_FIXUP_AMIC), |
| 6477 | SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_FIXUP_AMIC), |
| 6478 | SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_FIXUP_AMIC), |
| 6479 | SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_FIXUP_AMIC), |
| 6480 | SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_FIXUP_AMIC), |
| 6481 | SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_FIXUP_AMIC), |
| 6482 | SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_FIXUP_AMIC), |
| 6483 | SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_FIXUP_AMIC), |
| 6484 | SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_FIXUP_AMIC), |
| 6485 | SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_FIXUP_AMIC), |
| 6486 | SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_FIXUP_AMIC), |
| 6487 | SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_FIXUP_DMIC), |
| 6488 | SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_FIXUP_AMIC), |
| 6489 | SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_AMIC), |
| 6490 | SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_FIXUP_DMIC), |
| 6491 | SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_FIXUP_DMIC), |
| 6492 | #endif |
| 6493 | {} |
| 6494 | }; |
| 6495 | |
| 6496 | static const struct alc_model_fixup alc269_fixup_models[] = { |
| 6497 | {.id = ALC269_FIXUP_AMIC, .name = "laptop-amic"}, |
| 6498 | {.id = ALC269_FIXUP_DMIC, .name = "laptop-dmic"}, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 6499 | {.id = ALC269_FIXUP_STEREO_DMIC, .name = "alc269-dmic"}, |
| 6500 | {.id = ALC271_FIXUP_DMIC, .name = "alc271-dmic"}, |
| 6501 | {.id = ALC269_FIXUP_INV_DMIC, .name = "inv-dmic"}, |
David Henningsson | 108cc10 | 2012-07-20 10:37:25 +0200 | [diff] [blame] | 6502 | {.id = ALC269_FIXUP_LENOVO_DOCK, .name = "lenovo-dock"}, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6503 | {} |
| 6504 | }; |
| 6505 | |
| 6506 | |
Takashi Iwai | 546bb67 | 2012-03-07 08:37:19 +0100 | [diff] [blame] | 6507 | static void alc269_fill_coef(struct hda_codec *codec) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6508 | { |
Kailang Yang | 526af6e | 2012-03-07 08:25:20 +0100 | [diff] [blame] | 6509 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6510 | int val; |
| 6511 | |
Kailang Yang | 526af6e | 2012-03-07 08:25:20 +0100 | [diff] [blame] | 6512 | if (spec->codec_variant != ALC269_TYPE_ALC269VB) |
Takashi Iwai | 546bb67 | 2012-03-07 08:37:19 +0100 | [diff] [blame] | 6513 | return; |
Kailang Yang | 526af6e | 2012-03-07 08:25:20 +0100 | [diff] [blame] | 6514 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6515 | if ((alc_get_coef0(codec) & 0x00ff) < 0x015) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6516 | alc_write_coef_idx(codec, 0xf, 0x960b); |
| 6517 | alc_write_coef_idx(codec, 0xe, 0x8817); |
| 6518 | } |
| 6519 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6520 | if ((alc_get_coef0(codec) & 0x00ff) == 0x016) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6521 | alc_write_coef_idx(codec, 0xf, 0x960b); |
| 6522 | alc_write_coef_idx(codec, 0xe, 0x8814); |
| 6523 | } |
| 6524 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6525 | if ((alc_get_coef0(codec) & 0x00ff) == 0x017) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6526 | val = alc_read_coef_idx(codec, 0x04); |
| 6527 | /* Power up output pin */ |
| 6528 | alc_write_coef_idx(codec, 0x04, val | (1<<11)); |
| 6529 | } |
| 6530 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6531 | if ((alc_get_coef0(codec) & 0x00ff) == 0x018) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6532 | val = alc_read_coef_idx(codec, 0xd); |
| 6533 | if ((val & 0x0c00) >> 10 != 0x1) { |
| 6534 | /* Capless ramp up clock control */ |
| 6535 | alc_write_coef_idx(codec, 0xd, val | (1<<10)); |
| 6536 | } |
| 6537 | val = alc_read_coef_idx(codec, 0x17); |
| 6538 | if ((val & 0x01c0) >> 6 != 0x4) { |
| 6539 | /* Class D power on reset */ |
| 6540 | alc_write_coef_idx(codec, 0x17, val | (1<<7)); |
| 6541 | } |
| 6542 | } |
| 6543 | |
| 6544 | val = alc_read_coef_idx(codec, 0xd); /* Class D */ |
| 6545 | alc_write_coef_idx(codec, 0xd, val | (1<<14)); |
| 6546 | |
| 6547 | val = alc_read_coef_idx(codec, 0x4); /* HP */ |
| 6548 | alc_write_coef_idx(codec, 0x4, val | (1<<11)); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6549 | } |
| 6550 | |
| 6551 | /* |
| 6552 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6553 | static int patch_alc269(struct hda_codec *codec) |
| 6554 | { |
| 6555 | struct alc_spec *spec; |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6556 | int err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6557 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6558 | err = alc_alloc_spec(codec, 0x0b); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6559 | if (err < 0) |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6560 | return err; |
| 6561 | |
| 6562 | spec = codec->spec; |
Takashi Iwai | 37c0420 | 2012-12-18 14:22:45 +0100 | [diff] [blame] | 6563 | spec->shared_mic_vref_pin = 0x18; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6564 | |
Herton Ronaldo Krzesinski | 9f720bb | 2012-09-27 10:38:14 -0300 | [diff] [blame] | 6565 | alc_pick_fixup(codec, alc269_fixup_models, |
| 6566 | alc269_fixup_tbl, alc269_fixups); |
| 6567 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
| 6568 | |
| 6569 | alc_auto_parse_customize_define(codec); |
| 6570 | |
Kailang Yang | 065380f | 2013-01-10 10:25:48 +0100 | [diff] [blame] | 6571 | switch (codec->vendor_id) { |
| 6572 | case 0x10ec0269: |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6573 | spec->codec_variant = ALC269_TYPE_ALC269VA; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6574 | switch (alc_get_coef0(codec) & 0x00f0) { |
| 6575 | case 0x0010: |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6576 | if (codec->bus->pci->subsystem_vendor == 0x1025 && |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6577 | spec->cdefine.platform_type == 1) |
Takashi Iwai | 20ca0c3 | 2011-10-17 16:00:35 +0200 | [diff] [blame] | 6578 | err = alc_codec_rename(codec, "ALC271X"); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6579 | spec->codec_variant = ALC269_TYPE_ALC269VB; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6580 | break; |
| 6581 | case 0x0020: |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6582 | if (codec->bus->pci->subsystem_vendor == 0x17aa && |
| 6583 | codec->bus->pci->subsystem_device == 0x21f3) |
Takashi Iwai | 20ca0c3 | 2011-10-17 16:00:35 +0200 | [diff] [blame] | 6584 | err = alc_codec_rename(codec, "ALC3202"); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6585 | spec->codec_variant = ALC269_TYPE_ALC269VC; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6586 | break; |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 6587 | case 0x0030: |
| 6588 | spec->codec_variant = ALC269_TYPE_ALC269VD; |
| 6589 | break; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6590 | default: |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6591 | alc_fix_pll_init(codec, 0x20, 0x04, 15); |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6592 | } |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6593 | if (err < 0) |
| 6594 | goto error; |
Takashi Iwai | 546bb67 | 2012-03-07 08:37:19 +0100 | [diff] [blame] | 6595 | spec->init_hook = alc269_fill_coef; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6596 | alc269_fill_coef(codec); |
Kailang Yang | 065380f | 2013-01-10 10:25:48 +0100 | [diff] [blame] | 6597 | break; |
| 6598 | |
| 6599 | case 0x10ec0280: |
| 6600 | case 0x10ec0290: |
| 6601 | spec->codec_variant = ALC269_TYPE_ALC280; |
| 6602 | break; |
| 6603 | case 0x10ec0282: |
| 6604 | case 0x10ec0283: |
| 6605 | spec->codec_variant = ALC269_TYPE_ALC282; |
| 6606 | break; |
| 6607 | case 0x10ec0284: |
| 6608 | case 0x10ec0292: |
| 6609 | spec->codec_variant = ALC269_TYPE_ALC284; |
| 6610 | break; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6611 | } |
| 6612 | |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6613 | /* automatic parse from the BIOS config */ |
| 6614 | err = alc269_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6615 | if (err < 0) |
| 6616 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6617 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6618 | if (!spec->no_analog && has_cdefine_beep(codec)) { |
| 6619 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6620 | if (err < 0) |
| 6621 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6622 | set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6623 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6624 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6625 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 6626 | #ifdef CONFIG_PM |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6627 | codec->patch_ops.resume = alc269_resume; |
| 6628 | #endif |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6629 | spec->shutup = alc269_shutup; |
| 6630 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 6631 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 6632 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6633 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6634 | |
| 6635 | error: |
| 6636 | alc_free(codec); |
| 6637 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6638 | } |
| 6639 | |
| 6640 | /* |
| 6641 | * ALC861 |
| 6642 | */ |
| 6643 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6644 | static int alc861_parse_auto_config(struct hda_codec *codec) |
| 6645 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6646 | static const hda_nid_t alc861_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6647 | static const hda_nid_t alc861_ssids[] = { 0x0e, 0x0f, 0x0b, 0 }; |
| 6648 | return alc_parse_auto_config(codec, alc861_ignore, alc861_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6649 | } |
| 6650 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6651 | /* Pin config fixes */ |
| 6652 | enum { |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6653 | ALC861_FIXUP_FSC_AMILO_PI1505, |
| 6654 | ALC861_FIXUP_AMP_VREF_0F, |
| 6655 | ALC861_FIXUP_NO_JACK_DETECT, |
| 6656 | ALC861_FIXUP_ASUS_A6RP, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6657 | }; |
| 6658 | |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 6659 | /* On some laptops, VREF of pin 0x0f is abused for controlling the main amp */ |
| 6660 | static void alc861_fixup_asus_amp_vref_0f(struct hda_codec *codec, |
| 6661 | const struct alc_fixup *fix, int action) |
| 6662 | { |
| 6663 | struct alc_spec *spec = codec->spec; |
| 6664 | unsigned int val; |
| 6665 | |
| 6666 | if (action != ALC_FIXUP_ACT_INIT) |
| 6667 | return; |
| 6668 | val = snd_hda_codec_read(codec, 0x0f, 0, |
| 6669 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 6670 | if (!(val & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))) |
| 6671 | val |= AC_PINCTL_IN_EN; |
| 6672 | val |= AC_PINCTL_VREF_50; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 6673 | snd_hda_set_pin_ctl(codec, 0x0f, val); |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 6674 | spec->keep_vref_in_automute = 1; |
| 6675 | } |
| 6676 | |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6677 | /* suppress the jack-detection */ |
| 6678 | static void alc_fixup_no_jack_detect(struct hda_codec *codec, |
| 6679 | const struct alc_fixup *fix, int action) |
| 6680 | { |
| 6681 | if (action == ALC_FIXUP_ACT_PRE_PROBE) |
| 6682 | codec->no_jack_detect = 1; |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 6683 | } |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6684 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6685 | static const struct alc_fixup alc861_fixups[] = { |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6686 | [ALC861_FIXUP_FSC_AMILO_PI1505] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6687 | .type = ALC_FIXUP_PINS, |
| 6688 | .v.pins = (const struct alc_pincfg[]) { |
| 6689 | { 0x0b, 0x0221101f }, /* HP */ |
| 6690 | { 0x0f, 0x90170310 }, /* speaker */ |
| 6691 | { } |
| 6692 | } |
| 6693 | }, |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6694 | [ALC861_FIXUP_AMP_VREF_0F] = { |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 6695 | .type = ALC_FIXUP_FUNC, |
| 6696 | .v.func = alc861_fixup_asus_amp_vref_0f, |
Takashi Iwai | 3b25eb6 | 2012-01-25 09:55:46 +0100 | [diff] [blame] | 6697 | }, |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6698 | [ALC861_FIXUP_NO_JACK_DETECT] = { |
| 6699 | .type = ALC_FIXUP_FUNC, |
| 6700 | .v.func = alc_fixup_no_jack_detect, |
| 6701 | }, |
| 6702 | [ALC861_FIXUP_ASUS_A6RP] = { |
| 6703 | .type = ALC_FIXUP_FUNC, |
| 6704 | .v.func = alc861_fixup_asus_amp_vref_0f, |
| 6705 | .chained = true, |
| 6706 | .chain_id = ALC861_FIXUP_NO_JACK_DETECT, |
| 6707 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6708 | }; |
| 6709 | |
| 6710 | static const struct snd_pci_quirk alc861_fixup_tbl[] = { |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6711 | SND_PCI_QUIRK(0x1043, 0x1393, "ASUS A6Rp", ALC861_FIXUP_ASUS_A6RP), |
| 6712 | SND_PCI_QUIRK_VENDOR(0x1043, "ASUS laptop", ALC861_FIXUP_AMP_VREF_0F), |
| 6713 | SND_PCI_QUIRK(0x1462, 0x7254, "HP DX2200", ALC861_FIXUP_NO_JACK_DETECT), |
| 6714 | SND_PCI_QUIRK(0x1584, 0x2b01, "Haier W18", ALC861_FIXUP_AMP_VREF_0F), |
| 6715 | SND_PCI_QUIRK(0x1584, 0x0000, "Uniwill ECS M31EI", ALC861_FIXUP_AMP_VREF_0F), |
| 6716 | 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] | 6717 | {} |
| 6718 | }; |
| 6719 | |
| 6720 | /* |
| 6721 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6722 | static int patch_alc861(struct hda_codec *codec) |
| 6723 | { |
| 6724 | struct alc_spec *spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6725 | int err; |
| 6726 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6727 | err = alc_alloc_spec(codec, 0x15); |
| 6728 | if (err < 0) |
| 6729 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6730 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6731 | spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6732 | |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6733 | alc_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups); |
| 6734 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6735 | |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6736 | /* automatic parse from the BIOS config */ |
| 6737 | err = alc861_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6738 | if (err < 0) |
| 6739 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6740 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6741 | if (!spec->no_analog) { |
| 6742 | err = snd_hda_attach_beep_device(codec, 0x23); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6743 | if (err < 0) |
| 6744 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6745 | set_beep_amp(spec, 0x23, 0, HDA_OUTPUT); |
| 6746 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6747 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6748 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 83012a7 | 2012-08-24 18:38:08 +0200 | [diff] [blame] | 6749 | #ifdef CONFIG_PM |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6750 | spec->power_hook = alc_power_eapd; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6751 | #endif |
| 6752 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 6753 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 6754 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6755 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6756 | |
| 6757 | error: |
| 6758 | alc_free(codec); |
| 6759 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6760 | } |
| 6761 | |
| 6762 | /* |
| 6763 | * ALC861-VD support |
| 6764 | * |
| 6765 | * Based on ALC882 |
| 6766 | * |
| 6767 | * In addition, an independent DAC |
| 6768 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6769 | static int alc861vd_parse_auto_config(struct hda_codec *codec) |
| 6770 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6771 | static const hda_nid_t alc861vd_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6772 | static const hda_nid_t alc861vd_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 6773 | return alc_parse_auto_config(codec, alc861vd_ignore, alc861vd_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6774 | } |
| 6775 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6776 | enum { |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6777 | ALC660VD_FIX_ASUS_GPIO1, |
| 6778 | ALC861VD_FIX_DALLAS, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6779 | }; |
| 6780 | |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6781 | /* exclude VREF80 */ |
| 6782 | static void alc861vd_fixup_dallas(struct hda_codec *codec, |
| 6783 | const struct alc_fixup *fix, int action) |
| 6784 | { |
| 6785 | if (action == ALC_FIXUP_ACT_PRE_PROBE) { |
Takashi Iwai | b78562b | 2012-12-17 20:06:49 +0100 | [diff] [blame] | 6786 | snd_hda_override_pin_caps(codec, 0x18, 0x00000734); |
| 6787 | snd_hda_override_pin_caps(codec, 0x19, 0x0000073c); |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6788 | } |
| 6789 | } |
| 6790 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6791 | static const struct alc_fixup alc861vd_fixups[] = { |
| 6792 | [ALC660VD_FIX_ASUS_GPIO1] = { |
| 6793 | .type = ALC_FIXUP_VERBS, |
| 6794 | .v.verbs = (const struct hda_verb[]) { |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6795 | /* reset GPIO1 */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6796 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, |
| 6797 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, |
| 6798 | {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, |
| 6799 | { } |
| 6800 | } |
| 6801 | }, |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6802 | [ALC861VD_FIX_DALLAS] = { |
| 6803 | .type = ALC_FIXUP_FUNC, |
| 6804 | .v.func = alc861vd_fixup_dallas, |
| 6805 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6806 | }; |
| 6807 | |
| 6808 | static const struct snd_pci_quirk alc861vd_fixup_tbl[] = { |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6809 | SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_FIX_DALLAS), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6810 | SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1), |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6811 | SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_FIX_DALLAS), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6812 | {} |
| 6813 | }; |
| 6814 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6815 | /* |
| 6816 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6817 | static int patch_alc861vd(struct hda_codec *codec) |
| 6818 | { |
| 6819 | struct alc_spec *spec; |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6820 | int err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6821 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6822 | err = alc_alloc_spec(codec, 0x0b); |
| 6823 | if (err < 0) |
| 6824 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6825 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6826 | spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6827 | |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6828 | alc_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups); |
| 6829 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6830 | |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6831 | /* automatic parse from the BIOS config */ |
| 6832 | err = alc861vd_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6833 | if (err < 0) |
| 6834 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6835 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6836 | if (!spec->no_analog) { |
| 6837 | err = snd_hda_attach_beep_device(codec, 0x23); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6838 | if (err < 0) |
| 6839 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6840 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
| 6841 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6842 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6843 | codec->patch_ops = alc_patch_ops; |
| 6844 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6845 | spec->shutup = alc_eapd_shutup; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6846 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 6847 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 6848 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6849 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6850 | |
| 6851 | error: |
| 6852 | alc_free(codec); |
| 6853 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6854 | } |
| 6855 | |
| 6856 | /* |
| 6857 | * ALC662 support |
| 6858 | * |
| 6859 | * ALC662 is almost identical with ALC880 but has cleaner and more flexible |
| 6860 | * configuration. Each pin widget can choose any input DACs and a mixer. |
| 6861 | * Each ADC is connected from a mixer of all inputs. This makes possible |
| 6862 | * 6-channel independent captures. |
| 6863 | * |
| 6864 | * In addition, an independent DAC for the multi-playback (not used in this |
| 6865 | * driver yet). |
| 6866 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6867 | |
| 6868 | /* |
| 6869 | * BIOS auto configuration |
| 6870 | */ |
| 6871 | |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6872 | static int alc662_parse_auto_config(struct hda_codec *codec) |
| 6873 | { |
Takashi Iwai | 4c6d72d | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 6874 | static const hda_nid_t alc662_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6875 | static const hda_nid_t alc663_ssids[] = { 0x15, 0x1b, 0x14, 0x21 }; |
| 6876 | static const hda_nid_t alc662_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 6877 | const hda_nid_t *ssids; |
Takashi Iwai | ee979a14 | 2008-09-02 15:42:20 +0200 | [diff] [blame] | 6878 | |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 6879 | if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 || |
| 6880 | codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670) |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6881 | ssids = alc663_ssids; |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 6882 | else |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6883 | ssids = alc662_ssids; |
| 6884 | return alc_parse_auto_config(codec, alc662_ignore, ssids); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6885 | } |
| 6886 | |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 6887 | static void alc272_fixup_mario(struct hda_codec *codec, |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 6888 | const struct alc_fixup *fix, int action) |
Takashi Iwai | 6fc398c | 2011-01-13 14:36:37 +0100 | [diff] [blame] | 6889 | { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 6890 | if (action != ALC_FIXUP_ACT_PROBE) |
Takashi Iwai | 6fc398c | 2011-01-13 14:36:37 +0100 | [diff] [blame] | 6891 | return; |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 6892 | if (snd_hda_override_amp_caps(codec, 0x2, HDA_OUTPUT, |
| 6893 | (0x3b << AC_AMPCAP_OFFSET_SHIFT) | |
| 6894 | (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT) | |
| 6895 | (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT) | |
| 6896 | (0 << AC_AMPCAP_MUTE_SHIFT))) |
| 6897 | printk(KERN_WARNING |
| 6898 | "hda_codec: failed to override amp caps for NID 0x2\n"); |
| 6899 | } |
| 6900 | |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6901 | enum { |
Daniel T Chen | 2df0351 | 2010-10-10 22:39:28 -0400 | [diff] [blame] | 6902 | ALC662_FIXUP_ASPIRE, |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6903 | ALC662_FIXUP_IDEAPAD, |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 6904 | ALC272_FIXUP_MARIO, |
Anisse Astier | d2ebd47 | 2011-01-20 12:36:21 +0100 | [diff] [blame] | 6905 | ALC662_FIXUP_CZC_P10T, |
David Henningsson | 94024cd | 2011-04-29 14:10:55 +0200 | [diff] [blame] | 6906 | ALC662_FIXUP_SKU_IGNORE, |
Takashi Iwai | e59ea3e | 2011-06-29 17:21:00 +0200 | [diff] [blame] | 6907 | ALC662_FIXUP_HP_RP5800, |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6908 | ALC662_FIXUP_ASUS_MODE1, |
| 6909 | ALC662_FIXUP_ASUS_MODE2, |
| 6910 | ALC662_FIXUP_ASUS_MODE3, |
| 6911 | ALC662_FIXUP_ASUS_MODE4, |
| 6912 | ALC662_FIXUP_ASUS_MODE5, |
| 6913 | ALC662_FIXUP_ASUS_MODE6, |
| 6914 | ALC662_FIXUP_ASUS_MODE7, |
| 6915 | ALC662_FIXUP_ASUS_MODE8, |
Takashi Iwai | 1565cc3 | 2012-02-13 12:03:25 +0100 | [diff] [blame] | 6916 | ALC662_FIXUP_NO_JACK_DETECT, |
David Henningsson | edfe3bf | 2012-06-12 13:15:12 +0200 | [diff] [blame] | 6917 | ALC662_FIXUP_ZOTAC_Z68, |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 6918 | ALC662_FIXUP_INV_DMIC, |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6919 | }; |
| 6920 | |
| 6921 | static const struct alc_fixup alc662_fixups[] = { |
Daniel T Chen | 2df0351 | 2010-10-10 22:39:28 -0400 | [diff] [blame] | 6922 | [ALC662_FIXUP_ASPIRE] = { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 6923 | .type = ALC_FIXUP_PINS, |
| 6924 | .v.pins = (const struct alc_pincfg[]) { |
Daniel T Chen | 2df0351 | 2010-10-10 22:39:28 -0400 | [diff] [blame] | 6925 | { 0x15, 0x99130112 }, /* subwoofer */ |
| 6926 | { } |
| 6927 | } |
| 6928 | }, |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6929 | [ALC662_FIXUP_IDEAPAD] = { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 6930 | .type = ALC_FIXUP_PINS, |
| 6931 | .v.pins = (const struct alc_pincfg[]) { |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6932 | { 0x17, 0x99130112 }, /* subwoofer */ |
| 6933 | { } |
| 6934 | } |
| 6935 | }, |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 6936 | [ALC272_FIXUP_MARIO] = { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 6937 | .type = ALC_FIXUP_FUNC, |
| 6938 | .v.func = alc272_fixup_mario, |
Anisse Astier | d2ebd47 | 2011-01-20 12:36:21 +0100 | [diff] [blame] | 6939 | }, |
| 6940 | [ALC662_FIXUP_CZC_P10T] = { |
| 6941 | .type = ALC_FIXUP_VERBS, |
| 6942 | .v.verbs = (const struct hda_verb[]) { |
| 6943 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0}, |
| 6944 | {} |
| 6945 | } |
| 6946 | }, |
David Henningsson | 94024cd | 2011-04-29 14:10:55 +0200 | [diff] [blame] | 6947 | [ALC662_FIXUP_SKU_IGNORE] = { |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 6948 | .type = ALC_FIXUP_FUNC, |
| 6949 | .v.func = alc_fixup_sku_ignore, |
Takashi Iwai | c6b3587 | 2011-03-28 12:05:31 +0200 | [diff] [blame] | 6950 | }, |
Takashi Iwai | e59ea3e | 2011-06-29 17:21:00 +0200 | [diff] [blame] | 6951 | [ALC662_FIXUP_HP_RP5800] = { |
| 6952 | .type = ALC_FIXUP_PINS, |
| 6953 | .v.pins = (const struct alc_pincfg[]) { |
| 6954 | { 0x14, 0x0221201f }, /* HP out */ |
| 6955 | { } |
| 6956 | }, |
| 6957 | .chained = true, |
| 6958 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6959 | }, |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6960 | [ALC662_FIXUP_ASUS_MODE1] = { |
| 6961 | .type = ALC_FIXUP_PINS, |
| 6962 | .v.pins = (const struct alc_pincfg[]) { |
| 6963 | { 0x14, 0x99130110 }, /* speaker */ |
| 6964 | { 0x18, 0x01a19c20 }, /* mic */ |
| 6965 | { 0x19, 0x99a3092f }, /* int-mic */ |
| 6966 | { 0x21, 0x0121401f }, /* HP out */ |
| 6967 | { } |
| 6968 | }, |
| 6969 | .chained = true, |
| 6970 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6971 | }, |
| 6972 | [ALC662_FIXUP_ASUS_MODE2] = { |
Takashi Iwai | 2996bdb | 2011-08-18 16:02:24 +0200 | [diff] [blame] | 6973 | .type = ALC_FIXUP_PINS, |
| 6974 | .v.pins = (const struct alc_pincfg[]) { |
| 6975 | { 0x14, 0x99130110 }, /* speaker */ |
| 6976 | { 0x18, 0x01a19820 }, /* mic */ |
| 6977 | { 0x19, 0x99a3092f }, /* int-mic */ |
| 6978 | { 0x1b, 0x0121401f }, /* HP out */ |
| 6979 | { } |
| 6980 | }, |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6981 | .chained = true, |
| 6982 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6983 | }, |
| 6984 | [ALC662_FIXUP_ASUS_MODE3] = { |
| 6985 | .type = ALC_FIXUP_PINS, |
| 6986 | .v.pins = (const struct alc_pincfg[]) { |
| 6987 | { 0x14, 0x99130110 }, /* speaker */ |
| 6988 | { 0x15, 0x0121441f }, /* HP */ |
| 6989 | { 0x18, 0x01a19840 }, /* mic */ |
| 6990 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 6991 | { 0x21, 0x01211420 }, /* HP2 */ |
| 6992 | { } |
| 6993 | }, |
| 6994 | .chained = true, |
| 6995 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6996 | }, |
| 6997 | [ALC662_FIXUP_ASUS_MODE4] = { |
| 6998 | .type = ALC_FIXUP_PINS, |
| 6999 | .v.pins = (const struct alc_pincfg[]) { |
| 7000 | { 0x14, 0x99130110 }, /* speaker */ |
| 7001 | { 0x16, 0x99130111 }, /* speaker */ |
| 7002 | { 0x18, 0x01a19840 }, /* mic */ |
| 7003 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 7004 | { 0x21, 0x0121441f }, /* HP */ |
| 7005 | { } |
| 7006 | }, |
| 7007 | .chained = true, |
| 7008 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 7009 | }, |
| 7010 | [ALC662_FIXUP_ASUS_MODE5] = { |
| 7011 | .type = ALC_FIXUP_PINS, |
| 7012 | .v.pins = (const struct alc_pincfg[]) { |
| 7013 | { 0x14, 0x99130110 }, /* speaker */ |
| 7014 | { 0x15, 0x0121441f }, /* HP */ |
| 7015 | { 0x16, 0x99130111 }, /* speaker */ |
| 7016 | { 0x18, 0x01a19840 }, /* mic */ |
| 7017 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 7018 | { } |
| 7019 | }, |
| 7020 | .chained = true, |
| 7021 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 7022 | }, |
| 7023 | [ALC662_FIXUP_ASUS_MODE6] = { |
| 7024 | .type = ALC_FIXUP_PINS, |
| 7025 | .v.pins = (const struct alc_pincfg[]) { |
| 7026 | { 0x14, 0x99130110 }, /* speaker */ |
| 7027 | { 0x15, 0x01211420 }, /* HP2 */ |
| 7028 | { 0x18, 0x01a19840 }, /* mic */ |
| 7029 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 7030 | { 0x1b, 0x0121441f }, /* HP */ |
| 7031 | { } |
| 7032 | }, |
| 7033 | .chained = true, |
| 7034 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 7035 | }, |
| 7036 | [ALC662_FIXUP_ASUS_MODE7] = { |
| 7037 | .type = ALC_FIXUP_PINS, |
| 7038 | .v.pins = (const struct alc_pincfg[]) { |
| 7039 | { 0x14, 0x99130110 }, /* speaker */ |
| 7040 | { 0x17, 0x99130111 }, /* speaker */ |
| 7041 | { 0x18, 0x01a19840 }, /* mic */ |
| 7042 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 7043 | { 0x1b, 0x01214020 }, /* HP */ |
| 7044 | { 0x21, 0x0121401f }, /* HP */ |
| 7045 | { } |
| 7046 | }, |
| 7047 | .chained = true, |
| 7048 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 7049 | }, |
| 7050 | [ALC662_FIXUP_ASUS_MODE8] = { |
| 7051 | .type = ALC_FIXUP_PINS, |
| 7052 | .v.pins = (const struct alc_pincfg[]) { |
| 7053 | { 0x14, 0x99130110 }, /* speaker */ |
| 7054 | { 0x12, 0x99a30970 }, /* int-mic */ |
| 7055 | { 0x15, 0x01214020 }, /* HP */ |
| 7056 | { 0x17, 0x99130111 }, /* speaker */ |
| 7057 | { 0x18, 0x01a19840 }, /* mic */ |
| 7058 | { 0x21, 0x0121401f }, /* HP */ |
| 7059 | { } |
| 7060 | }, |
| 7061 | .chained = true, |
| 7062 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
Takashi Iwai | 2996bdb | 2011-08-18 16:02:24 +0200 | [diff] [blame] | 7063 | }, |
Takashi Iwai | 1565cc3 | 2012-02-13 12:03:25 +0100 | [diff] [blame] | 7064 | [ALC662_FIXUP_NO_JACK_DETECT] = { |
| 7065 | .type = ALC_FIXUP_FUNC, |
| 7066 | .v.func = alc_fixup_no_jack_detect, |
| 7067 | }, |
David Henningsson | edfe3bf | 2012-06-12 13:15:12 +0200 | [diff] [blame] | 7068 | [ALC662_FIXUP_ZOTAC_Z68] = { |
| 7069 | .type = ALC_FIXUP_PINS, |
| 7070 | .v.pins = (const struct alc_pincfg[]) { |
| 7071 | { 0x1b, 0x02214020 }, /* Front HP */ |
| 7072 | { } |
| 7073 | } |
| 7074 | }, |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 7075 | [ALC662_FIXUP_INV_DMIC] = { |
| 7076 | .type = ALC_FIXUP_FUNC, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 7077 | .v.func = alc_fixup_inv_dmic_0x12, |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 7078 | }, |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 7079 | }; |
| 7080 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 7081 | static const struct snd_pci_quirk alc662_fixup_tbl[] = { |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 7082 | SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_FIXUP_ASUS_MODE2), |
David Henningsson | a6c47a8 | 2011-02-10 15:39:19 +0100 | [diff] [blame] | 7083 | SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE), |
David Henningsson | 94024cd | 2011-04-29 14:10:55 +0200 | [diff] [blame] | 7084 | SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE), |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 7085 | SND_PCI_QUIRK(0x1025, 0x0349, "eMachines eM250", ALC662_FIXUP_INV_DMIC), |
Daniel T Chen | 2df0351 | 2010-10-10 22:39:28 -0400 | [diff] [blame] | 7086 | SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE), |
Takashi Iwai | e59ea3e | 2011-06-29 17:21:00 +0200 | [diff] [blame] | 7087 | SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800), |
Takashi Iwai | 1565cc3 | 2012-02-13 12:03:25 +0100 | [diff] [blame] | 7088 | SND_PCI_QUIRK(0x1043, 0x8469, "ASUS mobo", ALC662_FIXUP_NO_JACK_DETECT), |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 7089 | SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2), |
Daniel T Chen | a0e90ac | 2010-11-20 10:20:35 -0500 | [diff] [blame] | 7090 | SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD), |
Valentine Sinitsyn | d411858 | 2010-10-01 22:24:08 +0600 | [diff] [blame] | 7091 | SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD), |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 7092 | SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD), |
David Henningsson | edfe3bf | 2012-06-12 13:15:12 +0200 | [diff] [blame] | 7093 | SND_PCI_QUIRK(0x19da, 0xa130, "Zotac Z68", ALC662_FIXUP_ZOTAC_Z68), |
Anisse Astier | d2ebd47 | 2011-01-20 12:36:21 +0100 | [diff] [blame] | 7094 | SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T), |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 7095 | |
| 7096 | #if 0 |
| 7097 | /* Below is a quirk table taken from the old code. |
| 7098 | * Basically the device should work as is without the fixup table. |
| 7099 | * If BIOS doesn't give a proper info, enable the corresponding |
| 7100 | * fixup entry. |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 7101 | */ |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 7102 | SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC662_FIXUP_ASUS_MODE1), |
| 7103 | SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC662_FIXUP_ASUS_MODE3), |
| 7104 | SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC662_FIXUP_ASUS_MODE1), |
| 7105 | SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC662_FIXUP_ASUS_MODE3), |
| 7106 | SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), |
| 7107 | SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 7108 | SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), |
| 7109 | SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC662_FIXUP_ASUS_MODE1), |
| 7110 | SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC662_FIXUP_ASUS_MODE1), |
| 7111 | SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 7112 | SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC662_FIXUP_ASUS_MODE7), |
| 7113 | SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC662_FIXUP_ASUS_MODE7), |
| 7114 | SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC662_FIXUP_ASUS_MODE8), |
| 7115 | SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC662_FIXUP_ASUS_MODE3), |
| 7116 | SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC662_FIXUP_ASUS_MODE1), |
| 7117 | SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 7118 | SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_FIXUP_ASUS_MODE2), |
| 7119 | SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC662_FIXUP_ASUS_MODE1), |
| 7120 | SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 7121 | SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC662_FIXUP_ASUS_MODE6), |
| 7122 | SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC662_FIXUP_ASUS_MODE6), |
| 7123 | SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 7124 | SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC662_FIXUP_ASUS_MODE1), |
| 7125 | SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC662_FIXUP_ASUS_MODE3), |
| 7126 | SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_FIXUP_ASUS_MODE2), |
| 7127 | SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 7128 | SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC662_FIXUP_ASUS_MODE5), |
| 7129 | SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC662_FIXUP_ASUS_MODE6), |
| 7130 | SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 7131 | SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC662_FIXUP_ASUS_MODE1), |
| 7132 | SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 7133 | SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 7134 | SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC662_FIXUP_ASUS_MODE3), |
| 7135 | SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC662_FIXUP_ASUS_MODE3), |
| 7136 | SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC662_FIXUP_ASUS_MODE1), |
| 7137 | SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC662_FIXUP_ASUS_MODE1), |
| 7138 | SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC662_FIXUP_ASUS_MODE1), |
| 7139 | SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC662_FIXUP_ASUS_MODE1), |
| 7140 | SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC662_FIXUP_ASUS_MODE1), |
| 7141 | SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 7142 | SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_FIXUP_ASUS_MODE2), |
| 7143 | SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC662_FIXUP_ASUS_MODE1), |
| 7144 | SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), |
| 7145 | SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC662_FIXUP_ASUS_MODE3), |
| 7146 | SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC662_FIXUP_ASUS_MODE1), |
| 7147 | SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC662_FIXUP_ASUS_MODE1), |
| 7148 | SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC662_FIXUP_ASUS_MODE1), |
| 7149 | SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_FIXUP_ASUS_MODE2), |
| 7150 | SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), |
| 7151 | SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE4), |
| 7152 | #endif |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 7153 | {} |
| 7154 | }; |
| 7155 | |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 7156 | static const struct alc_model_fixup alc662_fixup_models[] = { |
| 7157 | {.id = ALC272_FIXUP_MARIO, .name = "mario"}, |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 7158 | {.id = ALC662_FIXUP_ASUS_MODE1, .name = "asus-mode1"}, |
| 7159 | {.id = ALC662_FIXUP_ASUS_MODE2, .name = "asus-mode2"}, |
| 7160 | {.id = ALC662_FIXUP_ASUS_MODE3, .name = "asus-mode3"}, |
| 7161 | {.id = ALC662_FIXUP_ASUS_MODE4, .name = "asus-mode4"}, |
| 7162 | {.id = ALC662_FIXUP_ASUS_MODE5, .name = "asus-mode5"}, |
| 7163 | {.id = ALC662_FIXUP_ASUS_MODE6, .name = "asus-mode6"}, |
| 7164 | {.id = ALC662_FIXUP_ASUS_MODE7, .name = "asus-mode7"}, |
| 7165 | {.id = ALC662_FIXUP_ASUS_MODE8, .name = "asus-mode8"}, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 7166 | {.id = ALC662_FIXUP_INV_DMIC, .name = "inv-dmic"}, |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 7167 | {} |
| 7168 | }; |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 7169 | |
Kailang Yang | 8663ff7 | 2012-06-29 09:35:52 +0200 | [diff] [blame] | 7170 | static void alc662_fill_coef(struct hda_codec *codec) |
| 7171 | { |
| 7172 | int val, coef; |
| 7173 | |
| 7174 | coef = alc_get_coef0(codec); |
| 7175 | |
| 7176 | switch (codec->vendor_id) { |
| 7177 | case 0x10ec0662: |
| 7178 | if ((coef & 0x00f0) == 0x0030) { |
| 7179 | val = alc_read_coef_idx(codec, 0x4); /* EAPD Ctrl */ |
| 7180 | alc_write_coef_idx(codec, 0x4, val & ~(1<<10)); |
| 7181 | } |
| 7182 | break; |
| 7183 | case 0x10ec0272: |
| 7184 | case 0x10ec0273: |
| 7185 | case 0x10ec0663: |
| 7186 | case 0x10ec0665: |
| 7187 | case 0x10ec0670: |
| 7188 | case 0x10ec0671: |
| 7189 | case 0x10ec0672: |
| 7190 | val = alc_read_coef_idx(codec, 0xd); /* EAPD Ctrl */ |
| 7191 | alc_write_coef_idx(codec, 0xd, val | (1<<14)); |
| 7192 | break; |
| 7193 | } |
| 7194 | } |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 7195 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 7196 | /* |
| 7197 | */ |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7198 | static int patch_alc662(struct hda_codec *codec) |
| 7199 | { |
| 7200 | struct alc_spec *spec; |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 7201 | int err; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7202 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 7203 | err = alc_alloc_spec(codec, 0x0b); |
| 7204 | if (err < 0) |
| 7205 | return err; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7206 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 7207 | spec = codec->spec; |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 7208 | |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 7209 | /* handle multiple HPs as is */ |
| 7210 | spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP; |
| 7211 | |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 7212 | alc_fix_pll_init(codec, 0x20, 0x04, 15); |
| 7213 | |
Kailang Yang | 8663ff7 | 2012-06-29 09:35:52 +0200 | [diff] [blame] | 7214 | spec->init_hook = alc662_fill_coef; |
| 7215 | alc662_fill_coef(codec); |
| 7216 | |
Takashi Iwai | 8e5a050 | 2012-06-21 15:49:33 +0200 | [diff] [blame] | 7217 | alc_pick_fixup(codec, alc662_fixup_models, |
| 7218 | alc662_fixup_tbl, alc662_fixups); |
| 7219 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
| 7220 | |
| 7221 | alc_auto_parse_customize_define(codec); |
| 7222 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 7223 | if ((alc_get_coef0(codec) & (1 << 14)) && |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 7224 | codec->bus->pci->subsystem_vendor == 0x1025 && |
| 7225 | spec->cdefine.platform_type == 1) { |
| 7226 | if (alc_codec_rename(codec, "ALC272X") < 0) |
| 7227 | goto error; |
Takashi Iwai | 20ca0c3 | 2011-10-17 16:00:35 +0200 | [diff] [blame] | 7228 | } |
Kailang Yang | 274693f | 2009-12-03 10:07:50 +0100 | [diff] [blame] | 7229 | |
Takashi Iwai | b9c5106 | 2011-08-24 18:08:07 +0200 | [diff] [blame] | 7230 | /* automatic parse from the BIOS config */ |
| 7231 | err = alc662_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 7232 | if (err < 0) |
| 7233 | goto error; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7234 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 7235 | if (!spec->no_analog && has_cdefine_beep(codec)) { |
| 7236 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 7237 | if (err < 0) |
| 7238 | goto error; |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 7239 | switch (codec->vendor_id) { |
| 7240 | case 0x10ec0662: |
| 7241 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
| 7242 | break; |
| 7243 | case 0x10ec0272: |
| 7244 | case 0x10ec0663: |
| 7245 | case 0x10ec0665: |
| 7246 | set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); |
| 7247 | break; |
| 7248 | case 0x10ec0273: |
| 7249 | set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT); |
| 7250 | break; |
| 7251 | } |
Kailang Yang | cec27c8 | 2010-02-04 14:18:18 +0100 | [diff] [blame] | 7252 | } |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 7253 | |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7254 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1c71615 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 7255 | spec->shutup = alc_eapd_shutup; |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 7256 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 7257 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 7258 | |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7259 | return 0; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7260 | |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 7261 | error: |
| 7262 | alc_free(codec); |
| 7263 | return err; |
Kailang Yang | b478b99 | 2011-05-18 11:51:15 +0200 | [diff] [blame] | 7264 | } |
| 7265 | |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7266 | /* |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7267 | * ALC680 support |
| 7268 | */ |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7269 | |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7270 | static int alc680_parse_auto_config(struct hda_codec *codec) |
| 7271 | { |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 7272 | return alc_parse_auto_config(codec, NULL, NULL); |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7273 | } |
| 7274 | |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7275 | /* |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7276 | */ |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7277 | static int patch_alc680(struct hda_codec *codec) |
| 7278 | { |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7279 | int err; |
| 7280 | |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 7281 | /* ALC680 has no aa-loopback mixer */ |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 7282 | err = alc_alloc_spec(codec, 0); |
| 7283 | if (err < 0) |
| 7284 | return err; |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 7285 | |
Takashi Iwai | 1ebec5f | 2011-08-15 13:21:48 +0200 | [diff] [blame] | 7286 | /* automatic parse from the BIOS config */ |
| 7287 | err = alc680_parse_auto_config(codec); |
| 7288 | if (err < 0) { |
| 7289 | alc_free(codec); |
| 7290 | return err; |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7291 | } |
| 7292 | |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7293 | codec->patch_ops = alc_patch_ops; |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7294 | |
| 7295 | return 0; |
| 7296 | } |
| 7297 | |
| 7298 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7299 | * patch entries |
| 7300 | */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 7301 | static const struct hda_codec_preset snd_hda_preset_realtek[] = { |
Kailang Yang | 296f033 | 2011-05-18 11:52:36 +0200 | [diff] [blame] | 7302 | { .id = 0x10ec0221, .name = "ALC221", .patch = patch_alc269 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7303 | { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 7304 | { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 }, |
Kailang Yang | f6a9224 | 2007-12-13 16:52:54 +0100 | [diff] [blame] | 7305 | { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 }, |
Kailang Yang | a361d84 | 2007-06-05 12:30:55 +0200 | [diff] [blame] | 7306 | { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 }, |
Kailang Yang | f6a9224 | 2007-12-13 16:52:54 +0100 | [diff] [blame] | 7307 | { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 }, |
Kailang Yang | ebb83ee | 2009-12-17 12:23:00 +0100 | [diff] [blame] | 7308 | { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 }, |
Kailang Yang | 01afd41 | 2008-10-15 11:22:09 +0200 | [diff] [blame] | 7309 | { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 }, |
Kailang Yang | ebb83ee | 2009-12-17 12:23:00 +0100 | [diff] [blame] | 7310 | { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 }, |
Kailang Yang | 296f033 | 2011-05-18 11:52:36 +0200 | [diff] [blame] | 7311 | { .id = 0x10ec0276, .name = "ALC276", .patch = patch_alc269 }, |
David Henningsson | befae82 | 2012-06-25 19:49:28 +0200 | [diff] [blame] | 7312 | { .id = 0x10ec0280, .name = "ALC280", .patch = patch_alc269 }, |
David Henningsson | 4e01ec6 | 2012-07-18 07:38:46 +0200 | [diff] [blame] | 7313 | { .id = 0x10ec0282, .name = "ALC282", .patch = patch_alc269 }, |
Kailang Yang | 7ff34ad | 2012-10-06 17:02:30 +0200 | [diff] [blame] | 7314 | { .id = 0x10ec0283, .name = "ALC283", .patch = patch_alc269 }, |
Kailang Yang | 065380f | 2013-01-10 10:25:48 +0100 | [diff] [blame] | 7315 | { .id = 0x10ec0284, .name = "ALC284", .patch = patch_alc269 }, |
Kailang Yang | 7ff34ad | 2012-10-06 17:02:30 +0200 | [diff] [blame] | 7316 | { .id = 0x10ec0290, .name = "ALC290", .patch = patch_alc269 }, |
David Henningsson | af02dde | 2012-11-21 08:57:58 +0100 | [diff] [blame] | 7317 | { .id = 0x10ec0292, .name = "ALC292", .patch = patch_alc269 }, |
Jakub Schmidtke | f32610e | 2007-02-02 18:17:27 +0100 | [diff] [blame] | 7318 | { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660", |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7319 | .patch = patch_alc861 }, |
Jakub Schmidtke | f32610e | 2007-02-02 18:17:27 +0100 | [diff] [blame] | 7320 | { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd }, |
| 7321 | { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 }, |
| 7322 | { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd }, |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7323 | { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2", |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 7324 | .patch = patch_alc882 }, |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7325 | { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1", |
| 7326 | .patch = patch_alc662 }, |
David Henningsson | cc667a7 | 2011-10-18 14:07:51 +0200 | [diff] [blame] | 7327 | { .id = 0x10ec0662, .rev = 0x100300, .name = "ALC662 rev3", |
| 7328 | .patch = patch_alc662 }, |
Kailang Yang | 6dda9f4 | 2008-05-27 12:05:31 +0200 | [diff] [blame] | 7329 | { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 }, |
Kailang Yang | cec27c8 | 2010-02-04 14:18:18 +0100 | [diff] [blame] | 7330 | { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 }, |
Kailang Yang | 19a6282 | 2012-11-08 10:25:37 +0100 | [diff] [blame] | 7331 | { .id = 0x10ec0668, .name = "ALC668", .patch = patch_alc662 }, |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 7332 | { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 }, |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7333 | { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 }, |
Jakub Schmidtke | f32610e | 2007-02-02 18:17:27 +0100 | [diff] [blame] | 7334 | { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7335 | { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 }, |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 7336 | { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 }, |
Clive Messer | 669faba | 2008-09-30 15:49:13 +0200 | [diff] [blame] | 7337 | { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A", |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 7338 | .patch = patch_alc882 }, |
Takashi Iwai | cb308f9 | 2008-04-16 14:13:29 +0200 | [diff] [blame] | 7339 | { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A", |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 7340 | .patch = patch_alc882 }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 7341 | { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 }, |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 7342 | { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 }, |
Kailang Yang | 4442608 | 2008-10-15 11:18:05 +0200 | [diff] [blame] | 7343 | { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200", |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 7344 | .patch = patch_alc882 }, |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 7345 | { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc882 }, |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 7346 | { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 }, |
Kailang Yang | 274693f | 2009-12-03 10:07:50 +0100 | [diff] [blame] | 7347 | { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 }, |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 7348 | { .id = 0x10ec0899, .name = "ALC898", .patch = patch_alc882 }, |
Kailang Yang | 19a6282 | 2012-11-08 10:25:37 +0100 | [diff] [blame] | 7349 | { .id = 0x10ec0900, .name = "ALC1150", .patch = patch_alc882 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7350 | {} /* terminator */ |
| 7351 | }; |
Takashi Iwai | 1289e9e | 2008-11-27 15:47:11 +0100 | [diff] [blame] | 7352 | |
| 7353 | MODULE_ALIAS("snd-hda-codec-id:10ec*"); |
| 7354 | |
| 7355 | MODULE_LICENSE("GPL"); |
| 7356 | MODULE_DESCRIPTION("Realtek HD-audio codec"); |
| 7357 | |
| 7358 | static struct hda_codec_preset_list realtek_list = { |
| 7359 | .preset = snd_hda_preset_realtek, |
| 7360 | .owner = THIS_MODULE, |
| 7361 | }; |
| 7362 | |
| 7363 | static int __init patch_realtek_init(void) |
| 7364 | { |
| 7365 | return snd_hda_add_codec_preset(&realtek_list); |
| 7366 | } |
| 7367 | |
| 7368 | static void __exit patch_realtek_exit(void) |
| 7369 | { |
| 7370 | snd_hda_delete_codec_preset(&realtek_list); |
| 7371 | } |
| 7372 | |
| 7373 | module_init(patch_realtek_init) |
| 7374 | module_exit(patch_realtek_exit) |