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> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | #include <sound/core.h> |
Kailang Yang | 9ad0e49 | 2010-09-14 23:22:00 +0200 | [diff] [blame] | 32 | #include <sound/jack.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | #include "hda_codec.h" |
| 34 | #include "hda_local.h" |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 35 | #include "hda_auto_parser.h" |
Kusanagi Kouichi | 680cd53 | 2009-02-05 00:00:58 +0900 | [diff] [blame] | 36 | #include "hda_beep.h" |
Takashi Iwai | 1835a0f | 2011-10-27 22:12:46 +0200 | [diff] [blame] | 37 | #include "hda_jack.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 39 | /* unsol event tags */ |
| 40 | #define ALC_FRONT_EVENT 0x01 |
| 41 | #define ALC_DCVOL_EVENT 0x02 |
| 42 | #define ALC_HP_EVENT 0x04 |
| 43 | #define ALC_MIC_EVENT 0x08 |
Takashi Iwai | d4a86d8 | 2010-06-23 17:51:26 +0200 | [diff] [blame] | 44 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 45 | /* for GPIO Poll */ |
| 46 | #define GPIO_MASK 0x03 |
| 47 | |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 48 | /* extra amp-initialization sequence types */ |
| 49 | enum { |
| 50 | ALC_INIT_NONE, |
| 51 | ALC_INIT_DEFAULT, |
| 52 | ALC_INIT_GPIO1, |
| 53 | ALC_INIT_GPIO2, |
| 54 | ALC_INIT_GPIO3, |
| 55 | }; |
| 56 | |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 57 | struct alc_customize_define { |
| 58 | unsigned int sku_cfg; |
| 59 | unsigned char port_connectivity; |
| 60 | unsigned char check_sum; |
| 61 | unsigned char customization; |
| 62 | unsigned char external_amp; |
| 63 | unsigned int enable_pcbeep:1; |
| 64 | unsigned int platform_type:1; |
| 65 | unsigned int swap:1; |
| 66 | unsigned int override:1; |
David Henningsson | 9062291 | 2010-10-14 14:50:18 +0200 | [diff] [blame] | 67 | unsigned int fixup:1; /* Means that this sku is set by driver, not read from hw */ |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 68 | }; |
| 69 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 70 | struct alc_multi_io { |
| 71 | hda_nid_t pin; /* multi-io widget pin NID */ |
| 72 | hda_nid_t dac; /* DAC to be connected */ |
| 73 | unsigned int ctl_in; /* cached input-pin control value */ |
| 74 | }; |
| 75 | |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 76 | /* make compatible with old code */ |
| 77 | #define alc_apply_pincfgs snd_hda_apply_pincfgs |
| 78 | #define alc_apply_fixup snd_hda_apply_fixup |
| 79 | #define alc_pick_fixup snd_hda_pick_fixup |
| 80 | #define alc_fixup hda_fixup |
| 81 | #define alc_pincfg hda_pintbl |
| 82 | #define alc_model_fixup hda_model_fixup |
| 83 | |
| 84 | #define ALC_FIXUP_PINS HDA_FIXUP_PINS |
| 85 | #define ALC_FIXUP_VERBS HDA_FIXUP_VERBS |
| 86 | #define ALC_FIXUP_FUNC HDA_FIXUP_FUNC |
| 87 | |
| 88 | #define ALC_FIXUP_ACT_PRE_PROBE HDA_FIXUP_ACT_PRE_PROBE |
| 89 | #define ALC_FIXUP_ACT_PROBE HDA_FIXUP_ACT_PROBE |
| 90 | #define ALC_FIXUP_ACT_INIT HDA_FIXUP_ACT_INIT |
| 91 | #define ALC_FIXUP_ACT_BUILD HDA_FIXUP_ACT_BUILD |
| 92 | |
| 93 | |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 94 | #define MAX_NID_PATH_DEPTH 5 |
| 95 | |
Takashi Iwai | 8dd4867 | 2012-12-14 18:19:04 +0100 | [diff] [blame] | 96 | enum { |
| 97 | NID_PATH_VOL_CTL, |
| 98 | NID_PATH_MUTE_CTL, |
| 99 | NID_PATH_BOOST_CTL, |
| 100 | NID_PATH_NUM_CTLS |
| 101 | }; |
| 102 | |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 103 | /* Widget connection path |
| 104 | * |
| 105 | * For output, stored in the order of DAC -> ... -> pin, |
| 106 | * for input, pin -> ... -> ADC. |
| 107 | * |
Takashi Iwai | 95e960c | 2012-12-10 17:27:57 +0100 | [diff] [blame] | 108 | * idx[i] contains the source index number to select on of the widget path[i]; |
| 109 | * 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] | 110 | * multi[] indicates whether it's a selector widget with multi-connectors |
| 111 | * (i.e. the connection selection is mandatory) |
| 112 | * vol_ctl and mute_ctl contains the NIDs for the assigned mixers |
| 113 | */ |
| 114 | struct nid_path { |
| 115 | int depth; |
| 116 | hda_nid_t path[MAX_NID_PATH_DEPTH]; |
| 117 | unsigned char idx[MAX_NID_PATH_DEPTH]; |
| 118 | unsigned char multi[MAX_NID_PATH_DEPTH]; |
Takashi Iwai | 8dd4867 | 2012-12-14 18:19:04 +0100 | [diff] [blame] | 119 | unsigned int ctls[NID_PATH_NUM_CTLS]; /* NID_PATH_XXX_CTL */ |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 120 | bool active; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 121 | }; |
| 122 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | struct alc_spec { |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 124 | struct hda_gen_spec gen; |
| 125 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | /* codec parameterization */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 127 | const struct snd_kcontrol_new *mixers[5]; /* mixer arrays */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | unsigned int num_mixers; |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 129 | unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 130 | |
Takashi Iwai | aa563af | 2009-07-31 10:05:11 +0200 | [diff] [blame] | 131 | char stream_name_analog[32]; /* analog PCM stream */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 132 | const struct hda_pcm_stream *stream_analog_playback; |
| 133 | const struct hda_pcm_stream *stream_analog_capture; |
| 134 | const struct hda_pcm_stream *stream_analog_alt_playback; |
| 135 | const struct hda_pcm_stream *stream_analog_alt_capture; |
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_digital[32]; /* digital PCM stream */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 138 | const struct hda_pcm_stream *stream_digital_playback; |
| 139 | const struct hda_pcm_stream *stream_digital_capture; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | |
| 141 | /* playback */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 142 | struct hda_multi_out multiout; /* playback set-up |
| 143 | * max_channels, dacs must be set |
| 144 | * dig_out_nid and hp_nid are optional |
| 145 | */ |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 146 | hda_nid_t alt_dac_nid; |
Takashi Iwai | 6a05ac4 | 2009-02-13 11:19:09 +0100 | [diff] [blame] | 147 | hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */ |
Takashi Iwai | 8c44198 | 2009-01-20 18:30:20 +0100 | [diff] [blame] | 148 | int dig_out_type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 149 | |
| 150 | /* capture */ |
| 151 | unsigned int num_adc_nids; |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 152 | hda_nid_t adc_nids[AUTO_CFG_MAX_OUTS]; |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 153 | hda_nid_t dig_in_nid; /* digital-in NID; optional */ |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 154 | hda_nid_t mixer_nid; /* analog-mixer NID */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 155 | |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 156 | /* capture setup for dynamic dual-adc switch */ |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 157 | hda_nid_t cur_adc; |
| 158 | unsigned int cur_adc_stream_tag; |
| 159 | unsigned int cur_adc_format; |
| 160 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | /* capture source */ |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 162 | struct hda_input_mux input_mux; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 163 | unsigned int cur_mux[3]; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 164 | hda_nid_t ext_mic_pin; |
| 165 | hda_nid_t dock_mic_pin; |
| 166 | hda_nid_t int_mic_pin; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | |
| 168 | /* channel model */ |
Takashi Iwai | d2a6d7d | 2005-11-17 11:06:29 +0100 | [diff] [blame] | 169 | const struct hda_channel_mode *channel_mode; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 170 | int num_channel_mode; |
Takashi Iwai | b6adb57 | 2012-12-03 10:30:58 +0100 | [diff] [blame] | 171 | int const_channel_count; /* min. channel count (for speakers) */ |
| 172 | int ext_channel_count; /* current channel count for multi-io */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 173 | |
| 174 | /* PCM information */ |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 175 | struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */ |
Takashi Iwai | 41e41f1 | 2005-06-08 14:48:49 +0200 | [diff] [blame] | 176 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 177 | /* dynamic controls, init_verbs and input_mux */ |
| 178 | struct auto_pin_cfg autocfg; |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 179 | struct alc_customize_define cdefine; |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 180 | struct snd_array kctls; |
Takashi Iwai | 41923e4 | 2007-10-22 17:20:10 +0200 | [diff] [blame] | 181 | hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 182 | hda_nid_t imux_pins[HDA_MAX_NUM_INPUTS]; |
| 183 | unsigned int dyn_adc_idx[HDA_MAX_NUM_INPUTS]; |
| 184 | int int_mic_idx, ext_mic_idx, dock_mic_idx; /* for auto-mic */ |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 185 | hda_nid_t inv_dmic_pin; |
Takashi Iwai | 37c0420 | 2012-12-18 14:22:45 +0100 | [diff] [blame] | 186 | hda_nid_t shared_mic_vref_pin; |
Takashi Iwai | 81fede8 | 2012-12-18 17:24:25 +0100 | [diff] [blame^] | 187 | int inv_dmic_split_idx; /* used internally for inv_dmic_split */ |
Takashi Iwai | 834be88 | 2006-03-01 14:16:17 +0100 | [diff] [blame] | 188 | |
Takashi Iwai | 463419d | 2012-12-05 14:17:37 +0100 | [diff] [blame] | 189 | /* DAC list */ |
| 190 | int num_all_dacs; |
| 191 | hda_nid_t all_dacs[16]; |
| 192 | |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 193 | /* path list */ |
| 194 | struct snd_array paths; |
Takashi Iwai | c2fd19c | 2012-12-12 18:02:41 +0100 | [diff] [blame] | 195 | |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 196 | /* hooks */ |
| 197 | void (*init_hook)(struct hda_codec *codec); |
Takashi Iwai | 83012a7 | 2012-08-24 18:38:08 +0200 | [diff] [blame] | 198 | #ifdef CONFIG_PM |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 199 | void (*power_hook)(struct hda_codec *codec); |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 200 | #endif |
Takashi Iwai | 1c71615 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 201 | void (*shutup)(struct hda_codec *codec); |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 202 | void (*automute_hook)(struct hda_codec *codec); |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 203 | |
Takashi Iwai | 834be88 | 2006-03-01 14:16:17 +0100 | [diff] [blame] | 204 | /* for pin sensing */ |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 205 | unsigned int hp_jack_present:1; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 206 | unsigned int line_jack_present:1; |
Takashi Iwai | e942796 | 2011-04-28 15:46:07 +0200 | [diff] [blame] | 207 | unsigned int master_mute:1; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 208 | unsigned int auto_mic:1; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 209 | unsigned int automute_speaker:1; /* automute speaker outputs */ |
| 210 | unsigned int automute_lo:1; /* automute LO outputs */ |
| 211 | unsigned int detect_hp:1; /* Headphone detection enabled */ |
| 212 | unsigned int detect_lo:1; /* Line-out detection enabled */ |
| 213 | unsigned int automute_speaker_possible:1; /* there are speakers and either LO or HP */ |
| 214 | unsigned int automute_lo_possible:1; /* there are line outs and HP */ |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 215 | unsigned int keep_vref_in_automute:1; /* Don't clear VREF in automute */ |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 216 | |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 217 | /* other flags */ |
Takashi Iwai | 20c18f5 | 2012-12-18 14:33:21 +0100 | [diff] [blame] | 218 | 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] | 219 | unsigned int no_analog :1; /* digital I/O only */ |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 220 | unsigned int dyn_adc_switch:1; /* switch ADCs (for ALC275) */ |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 221 | unsigned int shared_mic_hp:1; /* HP/Mic-in sharing */ |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 222 | unsigned int inv_dmic_fixup:1; /* has inverted digital-mic workaround */ |
| 223 | 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] | 224 | 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] | 225 | unsigned int multi_cap_vol:1; /* allow multiple capture xxx volumes */ |
Takashi Iwai | 81fede8 | 2012-12-18 17:24:25 +0100 | [diff] [blame^] | 226 | unsigned int inv_dmic_split:1; /* inverted dmic w/a for conexant */ |
Takashi Iwai | d922b51 | 2011-04-28 12:18:53 +0200 | [diff] [blame] | 227 | |
Takashi Iwai | 20c18f5 | 2012-12-18 14:33:21 +0100 | [diff] [blame] | 228 | unsigned int parse_flags; /* passed to snd_hda_parse_pin_defcfg() */ |
Takashi Iwai | d922b51 | 2011-04-28 12:18:53 +0200 | [diff] [blame] | 229 | |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 230 | int init_amp; |
Takashi Iwai | d433a67 | 2010-09-20 15:11:54 +0200 | [diff] [blame] | 231 | int codec_variant; /* flag for other variants */ |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 232 | |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 233 | /* for virtual master */ |
| 234 | hda_nid_t vmaster_nid; |
Takashi Iwai | d2f344b | 2012-03-12 16:59:58 +0100 | [diff] [blame] | 235 | struct hda_vmaster_mute_hook vmaster_mute; |
Takashi Iwai | 83012a7 | 2012-08-24 18:38:08 +0200 | [diff] [blame] | 236 | #ifdef CONFIG_PM |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 237 | struct hda_loopback_check loopback; |
Takashi Iwai | 164f73e | 2012-02-21 11:27:09 +0100 | [diff] [blame] | 238 | int num_loopbacks; |
| 239 | struct hda_amp_list loopback_list[8]; |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 240 | #endif |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 241 | |
| 242 | /* for PLL fix */ |
| 243 | hda_nid_t pll_nid; |
| 244 | unsigned int pll_coef_idx, pll_coef_bit; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 245 | unsigned int coef0; |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 246 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 247 | /* multi-io */ |
| 248 | int multi_ios; |
| 249 | struct alc_multi_io multi_io[4]; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 250 | |
| 251 | /* bind volumes */ |
| 252 | struct snd_array bind_ctls; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 253 | }; |
| 254 | |
Takashi Iwai | 44c0240 | 2011-07-08 15:14:19 +0200 | [diff] [blame] | 255 | static bool check_amp_caps(struct hda_codec *codec, hda_nid_t nid, |
| 256 | int dir, unsigned int bits) |
| 257 | { |
| 258 | if (!nid) |
| 259 | return false; |
| 260 | if (get_wcaps(codec, nid) & (1 << (dir + 1))) |
| 261 | if (query_amp_caps(codec, nid, dir) & bits) |
| 262 | return true; |
| 263 | return false; |
| 264 | } |
| 265 | |
| 266 | #define nid_has_mute(codec, nid, dir) \ |
| 267 | check_amp_caps(codec, nid, dir, AC_AMPCAP_MUTE) |
| 268 | #define nid_has_volume(codec, nid, dir) \ |
| 269 | check_amp_caps(codec, nid, dir, AC_AMPCAP_NUM_STEPS) |
| 270 | |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 271 | static struct nid_path * |
| 272 | get_nid_path(struct hda_codec *codec, hda_nid_t from_nid, hda_nid_t to_nid); |
| 273 | static void activate_path(struct hda_codec *codec, struct nid_path *path, |
| 274 | bool enable, bool add_aamix); |
| 275 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 276 | /* |
| 277 | * input MUX handling |
| 278 | */ |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 279 | static int alc_mux_enum_info(struct snd_kcontrol *kcontrol, |
| 280 | struct snd_ctl_elem_info *uinfo) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 281 | { |
| 282 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 283 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 284 | return snd_hda_input_mux_info(&spec->input_mux, uinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 285 | } |
| 286 | |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 287 | static int alc_mux_enum_get(struct snd_kcontrol *kcontrol, |
| 288 | struct snd_ctl_elem_value *ucontrol) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 289 | { |
| 290 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 291 | struct alc_spec *spec = codec->spec; |
| 292 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 293 | |
| 294 | ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; |
| 295 | return 0; |
| 296 | } |
| 297 | |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 298 | static hda_nid_t get_adc_nid(struct hda_codec *codec, int adc_idx, int imux_idx) |
| 299 | { |
| 300 | struct alc_spec *spec = codec->spec; |
| 301 | if (spec->dyn_adc_switch) |
| 302 | adc_idx = spec->dyn_adc_idx[imux_idx]; |
| 303 | return spec->adc_nids[adc_idx]; |
| 304 | } |
| 305 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 306 | 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] | 307 | { |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 308 | struct alc_spec *spec = codec->spec; |
| 309 | hda_nid_t new_adc = spec->adc_nids[spec->dyn_adc_idx[cur]]; |
| 310 | |
| 311 | if (spec->cur_adc && spec->cur_adc != new_adc) { |
| 312 | /* stream is running, let's swap the current ADC */ |
| 313 | __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1); |
| 314 | spec->cur_adc = new_adc; |
| 315 | snd_hda_codec_setup_stream(codec, new_adc, |
| 316 | spec->cur_adc_stream_tag, 0, |
| 317 | spec->cur_adc_format); |
| 318 | return true; |
| 319 | } |
| 320 | return false; |
| 321 | } |
| 322 | |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 323 | static void call_update_outputs(struct hda_codec *codec); |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 324 | static void alc_inv_dmic_sync(struct hda_codec *codec, bool force); |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 325 | 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] | 326 | |
David Henningsson | 00227f1 | 2012-06-27 18:45:44 +0200 | [diff] [blame] | 327 | /* for shared I/O, change the pin-control accordingly */ |
| 328 | static void update_shared_mic_hp(struct hda_codec *codec, bool set_as_mic) |
| 329 | { |
| 330 | struct alc_spec *spec = codec->spec; |
| 331 | unsigned int val; |
| 332 | hda_nid_t pin = spec->autocfg.inputs[1].pin; |
| 333 | /* NOTE: this assumes that there are only two inputs, the |
| 334 | * first is the real internal mic and the second is HP/mic jack. |
| 335 | */ |
| 336 | |
| 337 | val = snd_hda_get_default_vref(codec, pin); |
| 338 | |
| 339 | /* This pin does not have vref caps - let's enable vref on pin 0x18 |
| 340 | instead, as suggested by Realtek */ |
Takashi Iwai | 37c0420 | 2012-12-18 14:22:45 +0100 | [diff] [blame] | 341 | if (val == AC_PINCTL_VREF_HIZ && spec->shared_mic_vref_pin) { |
| 342 | const hda_nid_t vref_pin = spec->shared_mic_vref_pin; |
| 343 | unsigned int vref_val = snd_hda_get_default_vref(codec, vref_pin); |
| 344 | if (vref_val != AC_PINCTL_VREF_HIZ) |
| 345 | 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] | 346 | } |
| 347 | |
| 348 | val = set_as_mic ? val | PIN_IN : PIN_HP; |
| 349 | snd_hda_set_pin_ctl(codec, pin, val); |
| 350 | |
| 351 | spec->automute_speaker = !set_as_mic; |
| 352 | call_update_outputs(codec); |
| 353 | } |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 354 | |
| 355 | /* select the given imux item; either unmute exclusively or select the route */ |
| 356 | static int alc_mux_select(struct hda_codec *codec, unsigned int adc_idx, |
| 357 | unsigned int idx, bool force) |
| 358 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 359 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | cd896c3 | 2008-11-18 12:36:33 +0100 | [diff] [blame] | 360 | const struct hda_input_mux *imux; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 361 | struct nid_path *path; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 362 | |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 363 | imux = &spec->input_mux; |
| 364 | if (!imux->num_items) |
Takashi Iwai | cce4aa3 | 2011-12-02 15:29:12 +0100 | [diff] [blame] | 365 | return 0; |
Takashi Iwai | cd896c3 | 2008-11-18 12:36:33 +0100 | [diff] [blame] | 366 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 367 | if (idx >= imux->num_items) |
| 368 | idx = imux->num_items - 1; |
| 369 | if (spec->cur_mux[adc_idx] == idx && !force) |
| 370 | return 0; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 371 | |
| 372 | path = get_nid_path(codec, spec->imux_pins[spec->cur_mux[adc_idx]], |
| 373 | spec->adc_nids[adc_idx]); |
| 374 | if (!path) |
| 375 | return 0; |
| 376 | if (path->active) |
| 377 | activate_path(codec, path, false, false); |
| 378 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 379 | spec->cur_mux[adc_idx] = idx; |
| 380 | |
David Henningsson | 00227f1 | 2012-06-27 18:45:44 +0200 | [diff] [blame] | 381 | if (spec->shared_mic_hp) |
| 382 | update_shared_mic_hp(codec, spec->cur_mux[adc_idx]); |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 383 | |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 384 | if (spec->dyn_adc_switch) |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 385 | alc_dyn_adc_pcm_resetup(codec, idx); |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 386 | |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 387 | path = get_nid_path(codec, spec->imux_pins[idx], |
| 388 | get_adc_nid(codec, adc_idx, idx)); |
| 389 | if (!path) |
| 390 | return 0; |
| 391 | if (path->active) |
| 392 | return 0; |
| 393 | activate_path(codec, path, true, false); |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 394 | alc_inv_dmic_sync(codec, true); |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 395 | return 1; |
| 396 | } |
| 397 | |
| 398 | static int alc_mux_enum_put(struct snd_kcontrol *kcontrol, |
| 399 | struct snd_ctl_elem_value *ucontrol) |
| 400 | { |
| 401 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 402 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 403 | return alc_mux_select(codec, adc_idx, |
| 404 | ucontrol->value.enumerated.item[0], false); |
Takashi Iwai | 54cbc9a | 2008-10-31 15:24:04 +0100 | [diff] [blame] | 405 | } |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 406 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 407 | /* |
Takashi Iwai | 23f0c04 | 2009-02-26 13:03:58 +0100 | [diff] [blame] | 408 | * set up the input pin config (depending on the given auto-pin type) |
| 409 | */ |
| 410 | static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid, |
| 411 | int auto_pin_type) |
| 412 | { |
| 413 | unsigned int val = PIN_IN; |
Takashi Iwai | 4740860 | 2012-04-20 13:06:53 +0200 | [diff] [blame] | 414 | if (auto_pin_type == AUTO_PIN_MIC) |
| 415 | val |= snd_hda_get_default_vref(codec, nid); |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 416 | snd_hda_set_pin_ctl(codec, nid, val); |
Takashi Iwai | 23f0c04 | 2009-02-26 13:03:58 +0100 | [diff] [blame] | 417 | } |
| 418 | |
| 419 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 420 | * Append the given mixer and verb elements for the later use |
| 421 | * The mixer array is referred in build_controls(), and init_verbs are |
| 422 | * called in init(). |
Takashi Iwai | d88897e | 2008-10-31 15:01:37 +0100 | [diff] [blame] | 423 | */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 424 | 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] | 425 | { |
| 426 | if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers))) |
| 427 | return; |
| 428 | spec->mixers[spec->num_mixers++] = mix; |
| 429 | } |
| 430 | |
Takashi Iwai | d88897e | 2008-10-31 15:01:37 +0100 | [diff] [blame] | 431 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 432 | * GPIO setup tables, used in initialization |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 433 | */ |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 434 | /* Enable GPIO mask and set output */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 435 | static const struct hda_verb alc_gpio1_init_verbs[] = { |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 436 | {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, |
| 437 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, |
| 438 | {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, |
| 439 | { } |
| 440 | }; |
| 441 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 442 | static const struct hda_verb alc_gpio2_init_verbs[] = { |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 443 | {0x01, AC_VERB_SET_GPIO_MASK, 0x02}, |
| 444 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02}, |
| 445 | {0x01, AC_VERB_SET_GPIO_DATA, 0x02}, |
| 446 | { } |
| 447 | }; |
| 448 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 449 | static const struct hda_verb alc_gpio3_init_verbs[] = { |
Kailang Yang | bdd148a | 2007-05-08 15:19:08 +0200 | [diff] [blame] | 450 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, |
| 451 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, |
| 452 | {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, |
| 453 | { } |
| 454 | }; |
| 455 | |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 456 | /* |
| 457 | * Fix hardware PLL issue |
| 458 | * On some codecs, the analog PLL gating control must be off while |
| 459 | * the default value is 1. |
| 460 | */ |
| 461 | static void alc_fix_pll(struct hda_codec *codec) |
| 462 | { |
| 463 | struct alc_spec *spec = codec->spec; |
| 464 | unsigned int val; |
| 465 | |
| 466 | if (!spec->pll_nid) |
| 467 | return; |
| 468 | snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX, |
| 469 | spec->pll_coef_idx); |
| 470 | val = snd_hda_codec_read(codec, spec->pll_nid, 0, |
| 471 | AC_VERB_GET_PROC_COEF, 0); |
| 472 | snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX, |
| 473 | spec->pll_coef_idx); |
| 474 | snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF, |
| 475 | val & ~(1 << spec->pll_coef_bit)); |
| 476 | } |
| 477 | |
| 478 | static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid, |
| 479 | unsigned int coef_idx, unsigned int coef_bit) |
| 480 | { |
| 481 | struct alc_spec *spec = codec->spec; |
| 482 | spec->pll_nid = nid; |
| 483 | spec->pll_coef_idx = coef_idx; |
| 484 | spec->pll_coef_bit = coef_bit; |
| 485 | alc_fix_pll(codec); |
| 486 | } |
| 487 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 488 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 489 | * Jack detections for HP auto-mute and mic-switch |
| 490 | */ |
| 491 | |
| 492 | /* check each pin in the given array; returns true if any of them is plugged */ |
| 493 | 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] | 494 | { |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 495 | int i, present = 0; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 496 | |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 497 | for (i = 0; i < num_pins; i++) { |
| 498 | hda_nid_t nid = pins[i]; |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 499 | if (!nid) |
| 500 | break; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 501 | present |= snd_hda_jack_detect(codec, nid); |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 502 | } |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 503 | return present; |
| 504 | } |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 505 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 506 | /* standard HP/line-out auto-mute helper */ |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 507 | 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] | 508 | bool mute, bool hp_out) |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 509 | { |
| 510 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | e942796 | 2011-04-28 15:46:07 +0200 | [diff] [blame] | 511 | unsigned int pin_bits = mute ? 0 : (hp_out ? PIN_HP : PIN_OUT); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 512 | int i; |
| 513 | |
| 514 | for (i = 0; i < num_pins; i++) { |
| 515 | hda_nid_t nid = pins[i]; |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 516 | unsigned int val; |
Takashi Iwai | a9fd4f3 | 2009-05-08 15:57:59 +0200 | [diff] [blame] | 517 | if (!nid) |
| 518 | break; |
Takashi Iwai | b8a47c7 | 2012-12-14 14:20:34 +0100 | [diff] [blame] | 519 | /* don't reset VREF value in case it's controlling |
| 520 | * the amp (see alc861_fixup_asus_amp_vref_0f()) |
| 521 | */ |
| 522 | if (spec->keep_vref_in_automute) { |
| 523 | val = snd_hda_codec_read(codec, nid, 0, |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 524 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
Takashi Iwai | b8a47c7 | 2012-12-14 14:20:34 +0100 | [diff] [blame] | 525 | val &= ~PIN_HP; |
| 526 | } else |
| 527 | val = 0; |
| 528 | val |= pin_bits; |
| 529 | snd_hda_set_pin_ctl(codec, nid, val); |
Takashi Iwai | a9fd4f3 | 2009-05-08 15:57:59 +0200 | [diff] [blame] | 530 | } |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 531 | } |
| 532 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 533 | /* Toggle outputs muting */ |
| 534 | static void update_outputs(struct hda_codec *codec) |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 535 | { |
| 536 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 537 | int on; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 538 | |
Takashi Iwai | c0a2026 | 2011-06-10 15:28:15 +0200 | [diff] [blame] | 539 | /* Control HP pins/amps depending on master_mute state; |
| 540 | * in general, HP pins/amps control should be enabled in all cases, |
| 541 | * but currently set only for master_mute, just to be safe |
| 542 | */ |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 543 | if (!spec->shared_mic_hp) /* don't change HP-pin when shared with mic */ |
| 544 | do_automute(codec, ARRAY_SIZE(spec->autocfg.hp_pins), |
Takashi Iwai | c0a2026 | 2011-06-10 15:28:15 +0200 | [diff] [blame] | 545 | spec->autocfg.hp_pins, spec->master_mute, true); |
| 546 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 547 | if (!spec->automute_speaker) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 548 | on = 0; |
| 549 | else |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 550 | on = spec->hp_jack_present | spec->line_jack_present; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 551 | on |= spec->master_mute; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 552 | do_automute(codec, ARRAY_SIZE(spec->autocfg.speaker_pins), |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 553 | spec->autocfg.speaker_pins, on, false); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 554 | |
| 555 | /* toggle line-out mutes if needed, too */ |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 556 | /* if LO is a copy of either HP or Speaker, don't need to handle it */ |
| 557 | if (spec->autocfg.line_out_pins[0] == spec->autocfg.hp_pins[0] || |
| 558 | spec->autocfg.line_out_pins[0] == spec->autocfg.speaker_pins[0]) |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 559 | return; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 560 | if (!spec->automute_lo) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 561 | on = 0; |
| 562 | else |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 563 | on = spec->hp_jack_present; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 564 | on |= spec->master_mute; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 565 | do_automute(codec, ARRAY_SIZE(spec->autocfg.line_out_pins), |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 566 | spec->autocfg.line_out_pins, on, false); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 567 | } |
| 568 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 569 | static void call_update_outputs(struct hda_codec *codec) |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 570 | { |
| 571 | struct alc_spec *spec = codec->spec; |
| 572 | if (spec->automute_hook) |
| 573 | spec->automute_hook(codec); |
| 574 | else |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 575 | update_outputs(codec); |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 576 | } |
| 577 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 578 | /* standard HP-automute helper */ |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 579 | 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] | 580 | { |
| 581 | struct alc_spec *spec = codec->spec; |
| 582 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 583 | spec->hp_jack_present = |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 584 | detect_jacks(codec, ARRAY_SIZE(spec->autocfg.hp_pins), |
| 585 | spec->autocfg.hp_pins); |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 586 | if (!spec->detect_hp || (!spec->automute_speaker && !spec->automute_lo)) |
Takashi Iwai | 3c715a9 | 2011-08-23 12:41:09 +0200 | [diff] [blame] | 587 | return; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 588 | call_update_outputs(codec); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 589 | } |
| 590 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 591 | /* standard line-out-automute helper */ |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 592 | 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] | 593 | { |
| 594 | struct alc_spec *spec = codec->spec; |
| 595 | |
David Henningsson | f7f4b23 | 2012-10-10 16:32:09 +0200 | [diff] [blame] | 596 | if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT) |
| 597 | return; |
Takashi Iwai | e0d32e3 | 2011-09-26 15:19:55 +0200 | [diff] [blame] | 598 | /* check LO jack only when it's different from HP */ |
| 599 | if (spec->autocfg.line_out_pins[0] == spec->autocfg.hp_pins[0]) |
| 600 | return; |
| 601 | |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 602 | spec->line_jack_present = |
| 603 | detect_jacks(codec, ARRAY_SIZE(spec->autocfg.line_out_pins), |
| 604 | spec->autocfg.line_out_pins); |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 605 | if (!spec->automute_speaker || !spec->detect_lo) |
Takashi Iwai | 3c715a9 | 2011-08-23 12:41:09 +0200 | [diff] [blame] | 606 | return; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 607 | call_update_outputs(codec); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 608 | } |
| 609 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 610 | /* standard mic auto-switch helper */ |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 611 | 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] | 612 | { |
| 613 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 614 | hda_nid_t *pins = spec->imux_pins; |
Kailang Yang | 7fb0d78 | 2008-10-15 11:12:35 +0200 | [diff] [blame] | 615 | |
Takashi Iwai | 480967d | 2012-12-18 14:29:52 +0100 | [diff] [blame] | 616 | if (!spec->auto_mic) |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 617 | return; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 618 | if (snd_BUG_ON(spec->int_mic_idx < 0 || spec->ext_mic_idx < 0)) |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 619 | return; |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 620 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 621 | if (snd_hda_jack_detect(codec, pins[spec->ext_mic_idx])) |
| 622 | alc_mux_select(codec, 0, spec->ext_mic_idx, false); |
| 623 | else if (spec->dock_mic_idx >= 0 && |
| 624 | snd_hda_jack_detect(codec, pins[spec->dock_mic_idx])) |
| 625 | alc_mux_select(codec, 0, spec->dock_mic_idx, false); |
| 626 | else |
| 627 | alc_mux_select(codec, 0, spec->int_mic_idx, false); |
Kailang Yang | 7fb0d78 | 2008-10-15 11:12:35 +0200 | [diff] [blame] | 628 | } |
| 629 | |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 630 | /* update the master volume per volume-knob's unsol event */ |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 631 | 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] | 632 | { |
| 633 | unsigned int val; |
| 634 | struct snd_kcontrol *kctl; |
| 635 | struct snd_ctl_elem_value *uctl; |
| 636 | |
| 637 | kctl = snd_hda_find_mixer_ctl(codec, "Master Playback Volume"); |
| 638 | if (!kctl) |
| 639 | return; |
| 640 | uctl = kzalloc(sizeof(*uctl), GFP_KERNEL); |
| 641 | if (!uctl) |
| 642 | return; |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 643 | val = snd_hda_codec_read(codec, jack->nid, 0, |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 644 | AC_VERB_GET_VOLUME_KNOB_CONTROL, 0); |
| 645 | val &= HDA_AMP_VOLMASK; |
| 646 | uctl->value.integer.value[0] = val; |
| 647 | uctl->value.integer.value[1] = val; |
| 648 | kctl->put(kctl, uctl); |
| 649 | kfree(uctl); |
| 650 | } |
| 651 | |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 652 | static void alc880_unsol_event(struct hda_codec *codec, unsigned int res) |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 653 | { |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 654 | /* For some reason, the res given from ALC880 is broken. |
| 655 | Here we adjust it properly. */ |
| 656 | snd_hda_jack_unsol_event(codec, res >> 2); |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 657 | } |
| 658 | |
Kailang Yang | f9423e7 | 2008-05-27 12:32:25 +0200 | [diff] [blame] | 659 | /* additional initialization for ALC888 variants */ |
| 660 | static void alc888_coef_init(struct hda_codec *codec) |
| 661 | { |
| 662 | unsigned int tmp; |
| 663 | |
| 664 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0); |
| 665 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); |
| 666 | 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] | 667 | if ((tmp & 0xf0) == 0x20) |
Kailang Yang | f9423e7 | 2008-05-27 12:32:25 +0200 | [diff] [blame] | 668 | /* alc888S-VC */ |
| 669 | snd_hda_codec_read(codec, 0x20, 0, |
| 670 | AC_VERB_SET_PROC_COEF, 0x830); |
| 671 | else |
| 672 | /* alc888-VB */ |
| 673 | snd_hda_codec_read(codec, 0x20, 0, |
| 674 | AC_VERB_SET_PROC_COEF, 0x3030); |
| 675 | } |
| 676 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 677 | /* additional initialization for ALC889 variants */ |
Jaroslav Kysela | 87a8c37 | 2009-07-23 10:58:29 +0200 | [diff] [blame] | 678 | static void alc889_coef_init(struct hda_codec *codec) |
| 679 | { |
| 680 | unsigned int tmp; |
| 681 | |
| 682 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7); |
| 683 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); |
| 684 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7); |
| 685 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010); |
| 686 | } |
| 687 | |
Takashi Iwai | 3fb4a50 | 2010-01-19 15:46:37 +0100 | [diff] [blame] | 688 | /* turn on/off EAPD control (only if available) */ |
| 689 | static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on) |
| 690 | { |
| 691 | if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN) |
| 692 | return; |
| 693 | if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD) |
| 694 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE, |
| 695 | on ? 2 : 0); |
| 696 | } |
| 697 | |
Takashi Iwai | 691f1fc | 2011-04-07 10:31:43 +0200 | [diff] [blame] | 698 | /* turn on/off EAPD controls of the codec */ |
| 699 | static void alc_auto_setup_eapd(struct hda_codec *codec, bool on) |
| 700 | { |
| 701 | /* We currently only handle front, HP */ |
Takashi Iwai | 39fa84e | 2011-06-27 15:28:57 +0200 | [diff] [blame] | 702 | static hda_nid_t pins[] = { |
| 703 | 0x0f, 0x10, 0x14, 0x15, 0 |
| 704 | }; |
| 705 | hda_nid_t *p; |
| 706 | for (p = pins; *p; p++) |
| 707 | set_eapd(codec, *p, on); |
Takashi Iwai | 691f1fc | 2011-04-07 10:31:43 +0200 | [diff] [blame] | 708 | } |
| 709 | |
Takashi Iwai | 1c71615 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 710 | /* generic shutup callback; |
| 711 | * just turning off EPAD and a little pause for avoiding pop-noise |
| 712 | */ |
| 713 | static void alc_eapd_shutup(struct hda_codec *codec) |
| 714 | { |
| 715 | alc_auto_setup_eapd(codec, false); |
| 716 | msleep(200); |
| 717 | } |
| 718 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 719 | /* generic EAPD initialization */ |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 720 | static void alc_auto_init_amp(struct hda_codec *codec, int type) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 721 | { |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 722 | unsigned int tmp; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 723 | |
Takashi Iwai | 39fa84e | 2011-06-27 15:28:57 +0200 | [diff] [blame] | 724 | alc_auto_setup_eapd(codec, true); |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 725 | switch (type) { |
| 726 | case ALC_INIT_GPIO1: |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 727 | snd_hda_sequence_write(codec, alc_gpio1_init_verbs); |
| 728 | break; |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 729 | case ALC_INIT_GPIO2: |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 730 | snd_hda_sequence_write(codec, alc_gpio2_init_verbs); |
| 731 | break; |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 732 | case ALC_INIT_GPIO3: |
Kailang Yang | bdd148a | 2007-05-08 15:19:08 +0200 | [diff] [blame] | 733 | snd_hda_sequence_write(codec, alc_gpio3_init_verbs); |
| 734 | break; |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 735 | case ALC_INIT_DEFAULT: |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 736 | switch (codec->vendor_id) { |
| 737 | case 0x10ec0260: |
| 738 | snd_hda_codec_write(codec, 0x1a, 0, |
| 739 | AC_VERB_SET_COEF_INDEX, 7); |
| 740 | tmp = snd_hda_codec_read(codec, 0x1a, 0, |
| 741 | AC_VERB_GET_PROC_COEF, 0); |
| 742 | snd_hda_codec_write(codec, 0x1a, 0, |
| 743 | AC_VERB_SET_COEF_INDEX, 7); |
| 744 | snd_hda_codec_write(codec, 0x1a, 0, |
| 745 | AC_VERB_SET_PROC_COEF, |
| 746 | tmp | 0x2010); |
| 747 | break; |
| 748 | case 0x10ec0262: |
| 749 | case 0x10ec0880: |
| 750 | case 0x10ec0882: |
| 751 | case 0x10ec0883: |
| 752 | case 0x10ec0885: |
Takashi Iwai | 4a5a4c5 | 2009-02-06 12:46:59 +0100 | [diff] [blame] | 753 | case 0x10ec0887: |
Takashi Iwai | 20b67dd | 2011-03-23 22:54:32 +0100 | [diff] [blame] | 754 | /*case 0x10ec0889:*/ /* this causes an SPDIF problem */ |
Jaroslav Kysela | 87a8c37 | 2009-07-23 10:58:29 +0200 | [diff] [blame] | 755 | alc889_coef_init(codec); |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 756 | break; |
Kailang Yang | f9423e7 | 2008-05-27 12:32:25 +0200 | [diff] [blame] | 757 | case 0x10ec0888: |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 758 | alc888_coef_init(codec); |
Kailang Yang | f9423e7 | 2008-05-27 12:32:25 +0200 | [diff] [blame] | 759 | break; |
Takashi Iwai | 0aea778 | 2010-01-25 15:44:11 +0100 | [diff] [blame] | 760 | #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] | 761 | case 0x10ec0267: |
| 762 | case 0x10ec0268: |
| 763 | snd_hda_codec_write(codec, 0x20, 0, |
| 764 | AC_VERB_SET_COEF_INDEX, 7); |
| 765 | tmp = snd_hda_codec_read(codec, 0x20, 0, |
| 766 | AC_VERB_GET_PROC_COEF, 0); |
| 767 | snd_hda_codec_write(codec, 0x20, 0, |
Kailang Yang | ea1fb29 | 2008-08-26 12:58:38 +0200 | [diff] [blame] | 768 | AC_VERB_SET_COEF_INDEX, 7); |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 769 | snd_hda_codec_write(codec, 0x20, 0, |
| 770 | AC_VERB_SET_PROC_COEF, |
| 771 | tmp | 0x3000); |
| 772 | break; |
Takashi Iwai | 0aea778 | 2010-01-25 15:44:11 +0100 | [diff] [blame] | 773 | #endif /* XXX */ |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 774 | } |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 775 | break; |
| 776 | } |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 777 | } |
Kailang Yang | ea1fb29 | 2008-08-26 12:58:38 +0200 | [diff] [blame] | 778 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 779 | /* |
| 780 | * Auto-Mute mode mixer enum support |
| 781 | */ |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 782 | static int alc_automute_mode_info(struct snd_kcontrol *kcontrol, |
| 783 | struct snd_ctl_elem_info *uinfo) |
| 784 | { |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 785 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 786 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 787 | static const char * const texts3[] = { |
Takashi Iwai | e49a343 | 2012-03-01 18:14:41 +0100 | [diff] [blame] | 788 | "Disabled", "Speaker Only", "Line Out+Speaker" |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 789 | }; |
| 790 | |
Takashi Iwai | dda415d | 2012-11-30 18:34:38 +0100 | [diff] [blame] | 791 | if (spec->automute_speaker_possible && spec->automute_lo_possible) |
| 792 | return snd_hda_enum_helper_info(kcontrol, uinfo, 3, texts3); |
| 793 | return snd_hda_enum_bool_helper_info(kcontrol, uinfo); |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 794 | } |
| 795 | |
| 796 | static int alc_automute_mode_get(struct snd_kcontrol *kcontrol, |
| 797 | struct snd_ctl_elem_value *ucontrol) |
| 798 | { |
| 799 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 800 | struct alc_spec *spec = codec->spec; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 801 | unsigned int val = 0; |
| 802 | if (spec->automute_speaker) |
| 803 | val++; |
| 804 | if (spec->automute_lo) |
| 805 | val++; |
| 806 | |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 807 | ucontrol->value.enumerated.item[0] = val; |
| 808 | return 0; |
| 809 | } |
| 810 | |
| 811 | static int alc_automute_mode_put(struct snd_kcontrol *kcontrol, |
| 812 | struct snd_ctl_elem_value *ucontrol) |
| 813 | { |
| 814 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 815 | struct alc_spec *spec = codec->spec; |
| 816 | |
| 817 | switch (ucontrol->value.enumerated.item[0]) { |
| 818 | case 0: |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 819 | if (!spec->automute_speaker && !spec->automute_lo) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 820 | return 0; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 821 | spec->automute_speaker = 0; |
| 822 | spec->automute_lo = 0; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 823 | break; |
| 824 | case 1: |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 825 | if (spec->automute_speaker_possible) { |
| 826 | if (!spec->automute_lo && spec->automute_speaker) |
| 827 | return 0; |
| 828 | spec->automute_speaker = 1; |
| 829 | spec->automute_lo = 0; |
| 830 | } else if (spec->automute_lo_possible) { |
| 831 | if (spec->automute_lo) |
| 832 | return 0; |
| 833 | spec->automute_lo = 1; |
| 834 | } else |
| 835 | return -EINVAL; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 836 | break; |
| 837 | case 2: |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 838 | if (!spec->automute_lo_possible || !spec->automute_speaker_possible) |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 839 | return -EINVAL; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 840 | if (spec->automute_speaker && spec->automute_lo) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 841 | return 0; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 842 | spec->automute_speaker = 1; |
| 843 | spec->automute_lo = 1; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 844 | break; |
| 845 | default: |
| 846 | return -EINVAL; |
| 847 | } |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 848 | call_update_outputs(codec); |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 849 | return 1; |
| 850 | } |
| 851 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 852 | static const struct snd_kcontrol_new alc_automute_mode_enum = { |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 853 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 854 | .name = "Auto-Mute Mode", |
| 855 | .info = alc_automute_mode_info, |
| 856 | .get = alc_automute_mode_get, |
| 857 | .put = alc_automute_mode_put, |
| 858 | }; |
| 859 | |
Takashi Iwai | 668d1e9 | 2012-11-29 14:10:17 +0100 | [diff] [blame] | 860 | static struct snd_kcontrol_new * |
| 861 | alc_kcontrol_new(struct alc_spec *spec, const char *name, |
| 862 | const struct snd_kcontrol_new *temp) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 863 | { |
Takashi Iwai | 668d1e9 | 2012-11-29 14:10:17 +0100 | [diff] [blame] | 864 | struct snd_kcontrol_new *knew = snd_array_new(&spec->kctls); |
| 865 | if (!knew) |
| 866 | return NULL; |
| 867 | *knew = *temp; |
Takashi Iwai | bc54976 | 2012-12-18 15:35:11 +0100 | [diff] [blame] | 868 | if (name) |
| 869 | knew->name = kstrdup(name, GFP_KERNEL); |
| 870 | else if (knew->name) |
| 871 | knew->name = kstrdup(knew->name, GFP_KERNEL); |
Takashi Iwai | 668d1e9 | 2012-11-29 14:10:17 +0100 | [diff] [blame] | 872 | if (!knew->name) |
| 873 | return NULL; |
| 874 | return knew; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 875 | } |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 876 | |
| 877 | static int alc_add_automute_mode_enum(struct hda_codec *codec) |
| 878 | { |
| 879 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 880 | |
Takashi Iwai | bc54976 | 2012-12-18 15:35:11 +0100 | [diff] [blame] | 881 | if (!alc_kcontrol_new(spec, NULL, &alc_automute_mode_enum)) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 882 | return -ENOMEM; |
| 883 | return 0; |
| 884 | } |
| 885 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 886 | /* |
| 887 | * Check the availability of HP/line-out auto-mute; |
| 888 | * Set up appropriately if really supported |
| 889 | */ |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 890 | static int alc_init_automute(struct hda_codec *codec) |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 891 | { |
| 892 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 893 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | 1daf5f4 | 2011-04-28 17:57:46 +0200 | [diff] [blame] | 894 | int present = 0; |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 895 | int i, err; |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 896 | |
Takashi Iwai | 1daf5f4 | 2011-04-28 17:57:46 +0200 | [diff] [blame] | 897 | if (cfg->hp_pins[0]) |
| 898 | present++; |
| 899 | if (cfg->line_out_pins[0]) |
| 900 | present++; |
| 901 | if (cfg->speaker_pins[0]) |
| 902 | present++; |
| 903 | if (present < 2) /* need two different output types */ |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 904 | return 0; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 905 | |
Takashi Iwai | c48a8fb | 2011-07-27 16:41:57 +0200 | [diff] [blame] | 906 | if (!cfg->speaker_pins[0] && |
| 907 | cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) { |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 908 | memcpy(cfg->speaker_pins, cfg->line_out_pins, |
| 909 | sizeof(cfg->speaker_pins)); |
| 910 | cfg->speaker_outs = cfg->line_outs; |
| 911 | } |
| 912 | |
Takashi Iwai | c48a8fb | 2011-07-27 16:41:57 +0200 | [diff] [blame] | 913 | if (!cfg->hp_pins[0] && |
| 914 | cfg->line_out_type == AUTO_PIN_HP_OUT) { |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 915 | memcpy(cfg->hp_pins, cfg->line_out_pins, |
| 916 | sizeof(cfg->hp_pins)); |
| 917 | cfg->hp_outs = cfg->line_outs; |
| 918 | } |
| 919 | |
| 920 | for (i = 0; i < cfg->hp_outs; i++) { |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 921 | hda_nid_t nid = cfg->hp_pins[i]; |
Takashi Iwai | 06dec22 | 2011-05-17 10:00:16 +0200 | [diff] [blame] | 922 | if (!is_jack_detectable(codec, nid)) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 923 | continue; |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 924 | snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n", |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 925 | nid); |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 926 | snd_hda_jack_detect_enable_callback(codec, nid, ALC_HP_EVENT, |
| 927 | alc_hp_automute); |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 928 | spec->detect_hp = 1; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 929 | } |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 930 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 931 | if (cfg->line_out_type == AUTO_PIN_LINE_OUT && cfg->line_outs) { |
| 932 | if (cfg->speaker_outs) |
| 933 | for (i = 0; i < cfg->line_outs; i++) { |
| 934 | hda_nid_t nid = cfg->line_out_pins[i]; |
| 935 | if (!is_jack_detectable(codec, nid)) |
| 936 | continue; |
| 937 | snd_printdd("realtek: Enable Line-Out " |
| 938 | "auto-muting on NID 0x%x\n", nid); |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 939 | snd_hda_jack_detect_enable_callback(codec, nid, ALC_FRONT_EVENT, |
| 940 | alc_line_automute); |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 941 | spec->detect_lo = 1; |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 942 | } |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 943 | spec->automute_lo_possible = spec->detect_hp; |
| 944 | } |
| 945 | |
| 946 | spec->automute_speaker_possible = cfg->speaker_outs && |
| 947 | (spec->detect_hp || spec->detect_lo); |
| 948 | |
| 949 | spec->automute_lo = spec->automute_lo_possible; |
| 950 | spec->automute_speaker = spec->automute_speaker_possible; |
| 951 | |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 952 | if (spec->automute_speaker_possible || spec->automute_lo_possible) { |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 953 | /* create a control for automute mode */ |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 954 | err = alc_add_automute_mode_enum(codec); |
| 955 | if (err < 0) |
| 956 | return err; |
| 957 | } |
| 958 | return 0; |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 959 | } |
| 960 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 961 | /* 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] | 962 | static int find_idx_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums) |
| 963 | { |
| 964 | int i; |
| 965 | for (i = 0; i < nums; i++) |
| 966 | if (list[i] == nid) |
| 967 | return i; |
| 968 | return -1; |
| 969 | } |
| 970 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 971 | /* check whether all auto-mic pins are valid; setup indices if OK */ |
| 972 | static bool alc_auto_mic_check_imux(struct hda_codec *codec) |
| 973 | { |
| 974 | struct alc_spec *spec = codec->spec; |
| 975 | const struct hda_input_mux *imux; |
| 976 | |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 977 | imux = &spec->input_mux; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 978 | spec->ext_mic_idx = find_idx_in_nid_list(spec->ext_mic_pin, |
| 979 | spec->imux_pins, imux->num_items); |
| 980 | spec->int_mic_idx = find_idx_in_nid_list(spec->int_mic_pin, |
| 981 | spec->imux_pins, imux->num_items); |
| 982 | spec->dock_mic_idx = find_idx_in_nid_list(spec->dock_mic_pin, |
| 983 | spec->imux_pins, imux->num_items); |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 984 | if (spec->ext_mic_idx < 0 || spec->int_mic_idx < 0) |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 985 | return false; /* no corresponding imux */ |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 986 | |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 987 | snd_hda_jack_detect_enable_callback(codec, spec->ext_mic_pin, |
| 988 | ALC_MIC_EVENT, alc_mic_automute); |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 989 | if (spec->dock_mic_pin) |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 990 | snd_hda_jack_detect_enable_callback(codec, spec->dock_mic_pin, |
| 991 | ALC_MIC_EVENT, |
| 992 | alc_mic_automute); |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 993 | return true; |
| 994 | } |
| 995 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 996 | /* |
| 997 | * Check the availability of auto-mic switch; |
| 998 | * Set up if really supported |
| 999 | */ |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1000 | static int alc_init_auto_mic(struct hda_codec *codec) |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1001 | { |
| 1002 | struct alc_spec *spec = codec->spec; |
| 1003 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1004 | hda_nid_t fixed, ext, dock; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1005 | int i; |
| 1006 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1007 | spec->ext_mic_idx = spec->int_mic_idx = spec->dock_mic_idx = -1; |
| 1008 | |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1009 | fixed = ext = dock = 0; |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 1010 | for (i = 0; i < cfg->num_inputs; i++) { |
| 1011 | hda_nid_t nid = cfg->inputs[i].pin; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1012 | unsigned int defcfg; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1013 | defcfg = snd_hda_codec_get_pincfg(codec, nid); |
Takashi Iwai | 99ae28b | 2010-09-17 14:42:34 +0200 | [diff] [blame] | 1014 | switch (snd_hda_get_input_pin_attr(defcfg)) { |
| 1015 | case INPUT_PIN_ATTR_INT: |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1016 | if (fixed) |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1017 | return 0; /* already occupied */ |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1018 | if (cfg->inputs[i].type != AUTO_PIN_MIC) |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1019 | return 0; /* invalid type */ |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1020 | fixed = nid; |
| 1021 | break; |
Takashi Iwai | 99ae28b | 2010-09-17 14:42:34 +0200 | [diff] [blame] | 1022 | case INPUT_PIN_ATTR_UNUSED: |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1023 | return 0; /* invalid entry */ |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1024 | case INPUT_PIN_ATTR_DOCK: |
| 1025 | if (dock) |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1026 | return 0; /* already occupied */ |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1027 | if (cfg->inputs[i].type > AUTO_PIN_LINE_IN) |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1028 | return 0; /* invalid type */ |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1029 | dock = nid; |
| 1030 | break; |
Takashi Iwai | 99ae28b | 2010-09-17 14:42:34 +0200 | [diff] [blame] | 1031 | default: |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1032 | if (ext) |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1033 | return 0; /* already occupied */ |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1034 | if (cfg->inputs[i].type != AUTO_PIN_MIC) |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1035 | return 0; /* invalid type */ |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1036 | ext = nid; |
| 1037 | break; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1038 | } |
| 1039 | } |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1040 | if (!ext && dock) { |
| 1041 | ext = dock; |
| 1042 | dock = 0; |
| 1043 | } |
Takashi Iwai | eaa9b3a | 2010-01-17 13:09:33 +0100 | [diff] [blame] | 1044 | if (!ext || !fixed) |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1045 | return 0; |
Takashi Iwai | e35d9d6 | 2011-05-17 11:28:16 +0200 | [diff] [blame] | 1046 | if (!is_jack_detectable(codec, ext)) |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1047 | return 0; /* no unsol support */ |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1048 | if (dock && !is_jack_detectable(codec, dock)) |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1049 | return 0; /* no unsol support */ |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1050 | |
| 1051 | /* check imux indices */ |
| 1052 | spec->ext_mic_pin = ext; |
| 1053 | spec->int_mic_pin = fixed; |
| 1054 | spec->dock_mic_pin = dock; |
| 1055 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1056 | if (!alc_auto_mic_check_imux(codec)) |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1057 | return 0; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1058 | |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1059 | spec->auto_mic = 1; |
| 1060 | spec->num_adc_nids = 1; |
| 1061 | spec->cur_mux[0] = spec->int_mic_idx; |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1062 | snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x/0x%x\n", |
| 1063 | ext, fixed, dock); |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1064 | |
| 1065 | return 0; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1066 | } |
| 1067 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1068 | /* |
| 1069 | * Realtek SSID verification |
| 1070 | */ |
| 1071 | |
David Henningsson | 9062291 | 2010-10-14 14:50:18 +0200 | [diff] [blame] | 1072 | /* Could be any non-zero and even value. When used as fixup, tells |
| 1073 | * the driver to ignore any present sku defines. |
| 1074 | */ |
| 1075 | #define ALC_FIXUP_SKU_IGNORE (2) |
| 1076 | |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 1077 | static void alc_fixup_sku_ignore(struct hda_codec *codec, |
| 1078 | const struct hda_fixup *fix, int action) |
| 1079 | { |
| 1080 | struct alc_spec *spec = codec->spec; |
| 1081 | if (action == HDA_FIXUP_ACT_PRE_PROBE) { |
| 1082 | spec->cdefine.fixup = 1; |
| 1083 | spec->cdefine.sku_cfg = ALC_FIXUP_SKU_IGNORE; |
| 1084 | } |
| 1085 | } |
| 1086 | |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 1087 | static int alc_auto_parse_customize_define(struct hda_codec *codec) |
| 1088 | { |
| 1089 | unsigned int ass, tmp, i; |
Takashi Iwai | 7fb5622 | 2010-03-22 17:09:47 +0100 | [diff] [blame] | 1090 | unsigned nid = 0; |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 1091 | struct alc_spec *spec = codec->spec; |
| 1092 | |
Takashi Iwai | b6cbe51 | 2010-07-28 17:43:36 +0200 | [diff] [blame] | 1093 | spec->cdefine.enable_pcbeep = 1; /* assume always enabled */ |
| 1094 | |
David Henningsson | 9062291 | 2010-10-14 14:50:18 +0200 | [diff] [blame] | 1095 | if (spec->cdefine.fixup) { |
| 1096 | ass = spec->cdefine.sku_cfg; |
| 1097 | if (ass == ALC_FIXUP_SKU_IGNORE) |
| 1098 | return -1; |
| 1099 | goto do_sku; |
| 1100 | } |
| 1101 | |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 1102 | ass = codec->subsystem_id & 0xffff; |
Takashi Iwai | b6cbe51 | 2010-07-28 17:43:36 +0200 | [diff] [blame] | 1103 | if (ass != codec->bus->pci->subsystem_device && (ass & 1)) |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 1104 | goto do_sku; |
| 1105 | |
| 1106 | nid = 0x1d; |
| 1107 | if (codec->vendor_id == 0x10ec0260) |
| 1108 | nid = 0x17; |
| 1109 | ass = snd_hda_codec_get_pincfg(codec, nid); |
| 1110 | |
| 1111 | if (!(ass & 1)) { |
| 1112 | printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n", |
| 1113 | codec->chip_name, ass); |
| 1114 | return -1; |
| 1115 | } |
| 1116 | |
| 1117 | /* check sum */ |
| 1118 | tmp = 0; |
| 1119 | for (i = 1; i < 16; i++) { |
| 1120 | if ((ass >> i) & 1) |
| 1121 | tmp++; |
| 1122 | } |
| 1123 | if (((ass >> 16) & 0xf) != tmp) |
| 1124 | return -1; |
| 1125 | |
| 1126 | spec->cdefine.port_connectivity = ass >> 30; |
| 1127 | spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20; |
| 1128 | spec->cdefine.check_sum = (ass >> 16) & 0xf; |
| 1129 | spec->cdefine.customization = ass >> 8; |
| 1130 | do_sku: |
| 1131 | spec->cdefine.sku_cfg = ass; |
| 1132 | spec->cdefine.external_amp = (ass & 0x38) >> 3; |
| 1133 | spec->cdefine.platform_type = (ass & 0x4) >> 2; |
| 1134 | spec->cdefine.swap = (ass & 0x2) >> 1; |
| 1135 | spec->cdefine.override = ass & 0x1; |
| 1136 | |
| 1137 | snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n", |
| 1138 | nid, spec->cdefine.sku_cfg); |
| 1139 | snd_printd("SKU: port_connectivity=0x%x\n", |
| 1140 | spec->cdefine.port_connectivity); |
| 1141 | snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep); |
| 1142 | snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum); |
| 1143 | snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization); |
| 1144 | snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp); |
| 1145 | snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type); |
| 1146 | snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap); |
| 1147 | snd_printd("SKU: override=0x%x\n", spec->cdefine.override); |
| 1148 | |
| 1149 | return 0; |
| 1150 | } |
| 1151 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1152 | /* return true if the given NID is found in the list */ |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 1153 | static bool found_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums) |
| 1154 | { |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1155 | return find_idx_in_nid_list(nid, list, nums) >= 0; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 1156 | } |
| 1157 | |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1158 | /* check subsystem ID and set up device-specific initialization; |
| 1159 | * return 1 if initialized, 0 if invalid SSID |
| 1160 | */ |
| 1161 | /* 32-bit subsystem ID for BIOS loading in HD Audio codec. |
| 1162 | * 31 ~ 16 : Manufacture ID |
| 1163 | * 15 ~ 8 : SKU ID |
| 1164 | * 7 ~ 0 : Assembly ID |
| 1165 | * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36 |
| 1166 | */ |
| 1167 | static int alc_subsystem_id(struct hda_codec *codec, |
| 1168 | hda_nid_t porta, hda_nid_t porte, |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 1169 | hda_nid_t portd, hda_nid_t porti) |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1170 | { |
| 1171 | unsigned int ass, tmp, i; |
| 1172 | unsigned nid; |
| 1173 | struct alc_spec *spec = codec->spec; |
| 1174 | |
David Henningsson | 9062291 | 2010-10-14 14:50:18 +0200 | [diff] [blame] | 1175 | if (spec->cdefine.fixup) { |
| 1176 | ass = spec->cdefine.sku_cfg; |
| 1177 | if (ass == ALC_FIXUP_SKU_IGNORE) |
| 1178 | return 0; |
| 1179 | goto do_sku; |
| 1180 | } |
| 1181 | |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1182 | ass = codec->subsystem_id & 0xffff; |
| 1183 | if ((ass != codec->bus->pci->subsystem_device) && (ass & 1)) |
| 1184 | goto do_sku; |
| 1185 | |
| 1186 | /* invalid SSID, check the special NID pin defcfg instead */ |
| 1187 | /* |
Sasha Alexandr | def319f | 2009-06-16 16:00:15 -0400 | [diff] [blame] | 1188 | * 31~30 : port connectivity |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1189 | * 29~21 : reserve |
| 1190 | * 20 : PCBEEP input |
| 1191 | * 19~16 : Check sum (15:1) |
| 1192 | * 15~1 : Custom |
| 1193 | * 0 : override |
| 1194 | */ |
| 1195 | nid = 0x1d; |
| 1196 | if (codec->vendor_id == 0x10ec0260) |
| 1197 | nid = 0x17; |
| 1198 | ass = snd_hda_codec_get_pincfg(codec, nid); |
| 1199 | snd_printd("realtek: No valid SSID, " |
| 1200 | "checking pincfg 0x%08x for NID 0x%x\n", |
Takashi Iwai | cb6605c | 2009-04-28 13:03:19 +0200 | [diff] [blame] | 1201 | ass, nid); |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 1202 | if (!(ass & 1)) |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1203 | return 0; |
| 1204 | if ((ass >> 30) != 1) /* no physical connection */ |
| 1205 | return 0; |
| 1206 | |
| 1207 | /* check sum */ |
| 1208 | tmp = 0; |
| 1209 | for (i = 1; i < 16; i++) { |
| 1210 | if ((ass >> i) & 1) |
| 1211 | tmp++; |
| 1212 | } |
| 1213 | if (((ass >> 16) & 0xf) != tmp) |
| 1214 | return 0; |
| 1215 | do_sku: |
| 1216 | snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n", |
| 1217 | ass & 0xffff, codec->vendor_id); |
| 1218 | /* |
| 1219 | * 0 : override |
| 1220 | * 1 : Swap Jack |
| 1221 | * 2 : 0 --> Desktop, 1 --> Laptop |
| 1222 | * 3~5 : External Amplifier control |
| 1223 | * 7~6 : Reserved |
| 1224 | */ |
| 1225 | tmp = (ass & 0x38) >> 3; /* external Amp control */ |
| 1226 | switch (tmp) { |
| 1227 | case 1: |
| 1228 | spec->init_amp = ALC_INIT_GPIO1; |
| 1229 | break; |
| 1230 | case 3: |
| 1231 | spec->init_amp = ALC_INIT_GPIO2; |
| 1232 | break; |
| 1233 | case 7: |
| 1234 | spec->init_amp = ALC_INIT_GPIO3; |
| 1235 | break; |
| 1236 | case 5: |
Takashi Iwai | 5a8cfb4 | 2010-11-26 17:11:18 +0100 | [diff] [blame] | 1237 | default: |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1238 | spec->init_amp = ALC_INIT_DEFAULT; |
| 1239 | break; |
| 1240 | } |
| 1241 | |
| 1242 | /* is laptop or Desktop and enable the function "Mute internal speaker |
| 1243 | * when the external headphone out jack is plugged" |
| 1244 | */ |
| 1245 | if (!(ass & 0x8000)) |
| 1246 | return 1; |
| 1247 | /* |
| 1248 | * 10~8 : Jack location |
| 1249 | * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered |
| 1250 | * 14~13: Resvered |
| 1251 | * 15 : 1 --> enable the function "Mute internal speaker |
| 1252 | * when the external headphone out jack is plugged" |
| 1253 | */ |
Takashi Iwai | 5fe6e01 | 2011-09-26 10:41:21 +0200 | [diff] [blame] | 1254 | if (!spec->autocfg.hp_pins[0] && |
| 1255 | !(spec->autocfg.line_out_pins[0] && |
| 1256 | spec->autocfg.line_out_type == AUTO_PIN_HP_OUT)) { |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1257 | hda_nid_t nid; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1258 | tmp = (ass >> 11) & 0x3; /* HP to chassis */ |
| 1259 | if (tmp == 0) |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1260 | nid = porta; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1261 | else if (tmp == 1) |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1262 | nid = porte; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1263 | else if (tmp == 2) |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1264 | nid = portd; |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 1265 | else if (tmp == 3) |
| 1266 | nid = porti; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1267 | else |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1268 | return 1; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 1269 | if (found_in_nid_list(nid, spec->autocfg.line_out_pins, |
| 1270 | spec->autocfg.line_outs)) |
| 1271 | return 1; |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1272 | spec->autocfg.hp_pins[0] = nid; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1273 | } |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1274 | return 1; |
| 1275 | } |
Kailang Yang | ea1fb29 | 2008-08-26 12:58:38 +0200 | [diff] [blame] | 1276 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 1277 | /* Check the validity of ALC subsystem-id |
| 1278 | * ports contains an array of 4 pin NIDs for port-A, E, D and I */ |
| 1279 | 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] | 1280 | { |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 1281 | 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] | 1282 | struct alc_spec *spec = codec->spec; |
| 1283 | snd_printd("realtek: " |
| 1284 | "Enable default setup for auto mode as fallback\n"); |
| 1285 | spec->init_amp = ALC_INIT_DEFAULT; |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1286 | } |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1287 | } |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 1288 | |
Takashi Iwai | 41e41f1 | 2005-06-08 14:48:49 +0200 | [diff] [blame] | 1289 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1290 | * COEF access helper functions |
| 1291 | */ |
Kailang Yang | 274693f | 2009-12-03 10:07:50 +0100 | [diff] [blame] | 1292 | static int alc_read_coef_idx(struct hda_codec *codec, |
| 1293 | unsigned int coef_idx) |
| 1294 | { |
| 1295 | unsigned int val; |
| 1296 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, |
| 1297 | coef_idx); |
| 1298 | val = snd_hda_codec_read(codec, 0x20, 0, |
| 1299 | AC_VERB_GET_PROC_COEF, 0); |
| 1300 | return val; |
| 1301 | } |
| 1302 | |
Kailang Yang | 977ddd6 | 2010-09-15 10:02:29 +0200 | [diff] [blame] | 1303 | static void alc_write_coef_idx(struct hda_codec *codec, unsigned int coef_idx, |
| 1304 | unsigned int coef_val) |
| 1305 | { |
| 1306 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, |
| 1307 | coef_idx); |
| 1308 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, |
| 1309 | coef_val); |
| 1310 | } |
| 1311 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 1312 | /* a special bypass for COEF 0; read the cached value at the second time */ |
| 1313 | static unsigned int alc_get_coef0(struct hda_codec *codec) |
| 1314 | { |
| 1315 | struct alc_spec *spec = codec->spec; |
| 1316 | if (!spec->coef0) |
| 1317 | spec->coef0 = alc_read_coef_idx(codec, 0); |
| 1318 | return spec->coef0; |
| 1319 | } |
| 1320 | |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 1321 | static void alc_auto_set_output_and_unmute(struct hda_codec *codec, |
| 1322 | hda_nid_t pin, int pin_type, |
| 1323 | hda_nid_t dac); |
| 1324 | static hda_nid_t alc_auto_look_for_dac(struct hda_codec *codec, hda_nid_t pin, |
| 1325 | bool is_digital); |
Takashi Iwai | 965cceb | 2012-12-18 11:46:37 +0100 | [diff] [blame] | 1326 | static bool parse_nid_path(struct hda_codec *codec, hda_nid_t from_nid, |
| 1327 | hda_nid_t to_nid, int with_aa_mix, |
| 1328 | struct nid_path *path); |
| 1329 | static struct nid_path *add_new_nid_path(struct hda_codec *codec, |
| 1330 | hda_nid_t from_nid, hda_nid_t to_nid, |
| 1331 | int with_aa_mix); |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 1332 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1333 | /* |
| 1334 | * Digital I/O handling |
| 1335 | */ |
| 1336 | |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1337 | /* set right pin controls for digital I/O */ |
| 1338 | static void alc_auto_init_digital(struct hda_codec *codec) |
| 1339 | { |
| 1340 | struct alc_spec *spec = codec->spec; |
| 1341 | int i; |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 1342 | hda_nid_t pin; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1343 | |
| 1344 | for (i = 0; i < spec->autocfg.dig_outs; i++) { |
| 1345 | pin = spec->autocfg.dig_out_pins[i]; |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 1346 | if (!pin) |
| 1347 | continue; |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 1348 | alc_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1349 | } |
| 1350 | pin = spec->autocfg.dig_in_pin; |
| 1351 | if (pin) |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 1352 | snd_hda_set_pin_ctl(codec, pin, PIN_IN); |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1353 | } |
| 1354 | |
| 1355 | /* parse digital I/Os and set up NIDs in BIOS auto-parse mode */ |
| 1356 | static void alc_auto_parse_digital(struct hda_codec *codec) |
| 1357 | { |
| 1358 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 965cceb | 2012-12-18 11:46:37 +0100 | [diff] [blame] | 1359 | int i, nums; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1360 | hda_nid_t dig_nid; |
| 1361 | |
| 1362 | /* support multiple SPDIFs; the secondary is set up as a slave */ |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1363 | nums = 0; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1364 | for (i = 0; i < spec->autocfg.dig_outs; i++) { |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 1365 | hda_nid_t pin = spec->autocfg.dig_out_pins[i]; |
| 1366 | dig_nid = alc_auto_look_for_dac(codec, pin, true); |
| 1367 | if (!dig_nid) |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1368 | continue; |
Takashi Iwai | 965cceb | 2012-12-18 11:46:37 +0100 | [diff] [blame] | 1369 | if (!add_new_nid_path(codec, dig_nid, pin, 2)) |
| 1370 | continue; |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1371 | if (!nums) { |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1372 | spec->multiout.dig_out_nid = dig_nid; |
| 1373 | spec->dig_out_type = spec->autocfg.dig_out_type[0]; |
| 1374 | } else { |
| 1375 | spec->multiout.slave_dig_outs = spec->slave_dig_outs; |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1376 | if (nums >= ARRAY_SIZE(spec->slave_dig_outs) - 1) |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1377 | break; |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1378 | spec->slave_dig_outs[nums - 1] = dig_nid; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1379 | } |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1380 | nums++; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1381 | } |
| 1382 | |
| 1383 | if (spec->autocfg.dig_in_pin) { |
Takashi Iwai | 01fdf18 | 2010-09-24 09:09:42 +0200 | [diff] [blame] | 1384 | dig_nid = codec->start_nid; |
| 1385 | for (i = 0; i < codec->num_nodes; i++, dig_nid++) { |
Takashi Iwai | df1d1fb | 2012-12-18 11:55:53 +0100 | [diff] [blame] | 1386 | struct nid_path *path; |
Takashi Iwai | 01fdf18 | 2010-09-24 09:09:42 +0200 | [diff] [blame] | 1387 | unsigned int wcaps = get_wcaps(codec, dig_nid); |
| 1388 | if (get_wcaps_type(wcaps) != AC_WID_AUD_IN) |
| 1389 | continue; |
| 1390 | if (!(wcaps & AC_WCAP_DIGITAL)) |
| 1391 | continue; |
Takashi Iwai | df1d1fb | 2012-12-18 11:55:53 +0100 | [diff] [blame] | 1392 | path = add_new_nid_path(codec, spec->autocfg.dig_in_pin, |
| 1393 | dig_nid, 2); |
| 1394 | if (path) { |
| 1395 | path->active = true; |
Takashi Iwai | 01fdf18 | 2010-09-24 09:09:42 +0200 | [diff] [blame] | 1396 | spec->dig_in_nid = dig_nid; |
| 1397 | break; |
| 1398 | } |
| 1399 | } |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1400 | } |
| 1401 | } |
| 1402 | |
Takashi Iwai | f95474e | 2007-07-10 00:47:43 +0200 | [diff] [blame] | 1403 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1404 | * capture mixer elements |
Vincent Petry | ef8ef5f | 2008-11-23 11:31:41 +0800 | [diff] [blame] | 1405 | */ |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1406 | #define alc_cap_vol_info snd_hda_mixer_amp_volume_info |
| 1407 | #define alc_cap_vol_get snd_hda_mixer_amp_volume_get |
| 1408 | #define alc_cap_vol_tlv snd_hda_mixer_amp_tlv |
| 1409 | |
| 1410 | typedef int (*put_call_t)(struct snd_kcontrol *kcontrol, |
| 1411 | struct snd_ctl_elem_value *ucontrol); |
| 1412 | |
| 1413 | static int alc_cap_put_caller(struct snd_kcontrol *kcontrol, |
| 1414 | struct snd_ctl_elem_value *ucontrol, |
| 1415 | put_call_t func, int type) |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1416 | { |
| 1417 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1418 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1419 | const struct hda_input_mux *imux; |
| 1420 | struct nid_path *path; |
| 1421 | int i, adc_idx, err = 0; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1422 | |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 1423 | imux = &spec->input_mux; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1424 | adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1425 | mutex_lock(&codec->control_mutex); |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1426 | codec->cached_write = 1; |
| 1427 | for (i = 0; i < imux->num_items; i++) { |
| 1428 | path = get_nid_path(codec, spec->imux_pins[i], |
| 1429 | get_adc_nid(codec, adc_idx, i)); |
| 1430 | if (!path->ctls[type]) |
| 1431 | continue; |
| 1432 | kcontrol->private_value = path->ctls[type]; |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1433 | err = func(kcontrol, ucontrol); |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1434 | if (err < 0) |
| 1435 | goto error; |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1436 | } |
| 1437 | error: |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1438 | codec->cached_write = 0; |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1439 | mutex_unlock(&codec->control_mutex); |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1440 | snd_hda_codec_resume_amp(codec); |
| 1441 | if (err >= 0 && type == NID_PATH_MUTE_CTL && |
| 1442 | spec->inv_dmic_fixup && spec->inv_dmic_muted) |
| 1443 | alc_inv_dmic_sync_adc(codec, adc_idx); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1444 | return err; |
| 1445 | } |
| 1446 | |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1447 | static int alc_cap_vol_put(struct snd_kcontrol *kcontrol, |
| 1448 | struct snd_ctl_elem_value *ucontrol) |
| 1449 | { |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1450 | return alc_cap_put_caller(kcontrol, ucontrol, |
| 1451 | snd_hda_mixer_amp_volume_put, |
| 1452 | NID_PATH_VOL_CTL); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1453 | } |
| 1454 | |
| 1455 | /* capture mixer elements */ |
| 1456 | #define alc_cap_sw_info snd_ctl_boolean_stereo_info |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1457 | #define alc_cap_sw_get snd_hda_mixer_amp_switch_get |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1458 | |
| 1459 | static int alc_cap_sw_put(struct snd_kcontrol *kcontrol, |
| 1460 | struct snd_ctl_elem_value *ucontrol) |
| 1461 | { |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1462 | return alc_cap_put_caller(kcontrol, ucontrol, |
| 1463 | snd_hda_mixer_amp_switch_put, |
| 1464 | NID_PATH_MUTE_CTL); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1465 | } |
| 1466 | |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1467 | static void alc_inv_dmic_sync_adc(struct hda_codec *codec, int adc_idx) |
| 1468 | { |
| 1469 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 1470 | struct hda_input_mux *imux = &spec->input_mux; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1471 | struct nid_path *path; |
| 1472 | hda_nid_t nid; |
| 1473 | int i, dir, parm; |
| 1474 | unsigned int val; |
| 1475 | |
| 1476 | for (i = 0; i < imux->num_items; i++) { |
| 1477 | if (spec->imux_pins[i] == spec->inv_dmic_pin) |
| 1478 | break; |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1479 | } |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1480 | if (i >= imux->num_items) |
| 1481 | return; |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1482 | |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1483 | path = get_nid_path(codec, spec->inv_dmic_pin, |
| 1484 | get_adc_nid(codec, adc_idx, i)); |
| 1485 | val = path->ctls[NID_PATH_MUTE_CTL]; |
| 1486 | if (!val) |
| 1487 | return; |
| 1488 | nid = get_amp_nid_(val); |
| 1489 | dir = get_amp_direction_(val); |
| 1490 | parm = AC_AMP_SET_RIGHT | |
| 1491 | (dir == HDA_OUTPUT ? AC_AMP_SET_OUTPUT : AC_AMP_SET_INPUT); |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1492 | |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1493 | /* we care only right channel */ |
| 1494 | val = snd_hda_codec_amp_read(codec, nid, 1, dir, 0); |
| 1495 | if (val & 0x80) /* if already muted, we don't need to touch */ |
| 1496 | return; |
| 1497 | val |= 0x80; |
| 1498 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
| 1499 | parm | val); |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1500 | } |
| 1501 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1502 | /* |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 1503 | * Inverted digital-mic handling |
| 1504 | * |
| 1505 | * First off, it's a bit tricky. The "Inverted Internal Mic Capture Switch" |
| 1506 | * gives the additional mute only to the right channel of the digital mic |
| 1507 | * capture stream. This is a workaround for avoiding the almost silence |
| 1508 | * by summing the stereo stream from some (known to be ForteMedia) |
| 1509 | * digital mic unit. |
| 1510 | * |
| 1511 | * The logic is to call alc_inv_dmic_sync() after each action (possibly) |
| 1512 | * modifying ADC amp. When the mute flag is set, it mutes the R-channel |
| 1513 | * without caching so that the cache can still keep the original value. |
| 1514 | * The cached value is then restored when the flag is set off or any other |
| 1515 | * than d-mic is used as the current input source. |
| 1516 | */ |
| 1517 | static void alc_inv_dmic_sync(struct hda_codec *codec, bool force) |
| 1518 | { |
| 1519 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1520 | int src, nums; |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 1521 | |
| 1522 | if (!spec->inv_dmic_fixup) |
| 1523 | return; |
| 1524 | if (!spec->inv_dmic_muted && !force) |
| 1525 | return; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1526 | nums = spec->dyn_adc_switch ? 1 : spec->num_adc_nids; |
| 1527 | for (src = 0; src < nums; src++) { |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 1528 | bool dmic_fixup = false; |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 1529 | |
| 1530 | if (spec->inv_dmic_muted && |
| 1531 | spec->imux_pins[spec->cur_mux[src]] == spec->inv_dmic_pin) |
| 1532 | dmic_fixup = true; |
| 1533 | if (!dmic_fixup && !force) |
| 1534 | continue; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1535 | alc_inv_dmic_sync_adc(codec, src); |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 1536 | } |
| 1537 | } |
| 1538 | |
| 1539 | static int alc_inv_dmic_sw_get(struct snd_kcontrol *kcontrol, |
| 1540 | struct snd_ctl_elem_value *ucontrol) |
| 1541 | { |
| 1542 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1543 | struct alc_spec *spec = codec->spec; |
| 1544 | |
| 1545 | ucontrol->value.integer.value[0] = !spec->inv_dmic_muted; |
| 1546 | return 0; |
| 1547 | } |
| 1548 | |
| 1549 | static int alc_inv_dmic_sw_put(struct snd_kcontrol *kcontrol, |
| 1550 | struct snd_ctl_elem_value *ucontrol) |
| 1551 | { |
| 1552 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1553 | struct alc_spec *spec = codec->spec; |
| 1554 | unsigned int val = !ucontrol->value.integer.value[0]; |
| 1555 | |
| 1556 | if (val == spec->inv_dmic_muted) |
| 1557 | return 0; |
| 1558 | spec->inv_dmic_muted = val; |
| 1559 | alc_inv_dmic_sync(codec, true); |
| 1560 | return 0; |
| 1561 | } |
| 1562 | |
| 1563 | static const struct snd_kcontrol_new alc_inv_dmic_sw = { |
| 1564 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
Takashi Iwai | bc54976 | 2012-12-18 15:35:11 +0100 | [diff] [blame] | 1565 | .name = "Inverted Internal Mic Capture Switch", |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 1566 | .info = snd_ctl_boolean_mono_info, |
| 1567 | .get = alc_inv_dmic_sw_get, |
| 1568 | .put = alc_inv_dmic_sw_put, |
| 1569 | }; |
| 1570 | |
| 1571 | static int alc_add_inv_dmic_mixer(struct hda_codec *codec, hda_nid_t nid) |
| 1572 | { |
| 1573 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 668d1e9 | 2012-11-29 14:10:17 +0100 | [diff] [blame] | 1574 | |
Takashi Iwai | bc54976 | 2012-12-18 15:35:11 +0100 | [diff] [blame] | 1575 | if (!alc_kcontrol_new(spec, NULL, &alc_inv_dmic_sw)) |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 1576 | return -ENOMEM; |
| 1577 | spec->inv_dmic_fixup = 1; |
| 1578 | spec->inv_dmic_muted = 0; |
| 1579 | spec->inv_dmic_pin = nid; |
| 1580 | return 0; |
| 1581 | } |
| 1582 | |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 1583 | /* typically the digital mic is put at node 0x12 */ |
| 1584 | static void alc_fixup_inv_dmic_0x12(struct hda_codec *codec, |
| 1585 | const struct alc_fixup *fix, int action) |
| 1586 | { |
| 1587 | if (action == ALC_FIXUP_ACT_PROBE) |
| 1588 | alc_add_inv_dmic_mixer(codec, 0x12); |
| 1589 | } |
| 1590 | |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 1591 | /* |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1592 | * virtual master controls |
| 1593 | */ |
| 1594 | |
| 1595 | /* |
| 1596 | * slave controls for virtual master |
| 1597 | */ |
Takashi Iwai | 9322ca5 | 2012-02-03 14:28:01 +0100 | [diff] [blame] | 1598 | static const char * const alc_slave_pfxs[] = { |
| 1599 | "Front", "Surround", "Center", "LFE", "Side", |
Takashi Iwai | 7c58975 | 2012-03-02 09:00:33 +0100 | [diff] [blame] | 1600 | "Headphone", "Speaker", "Mono", "Line Out", |
Takashi Iwai | 9322ca5 | 2012-02-03 14:28:01 +0100 | [diff] [blame] | 1601 | "CLFE", "Bass Speaker", "PCM", |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1602 | NULL, |
| 1603 | }; |
| 1604 | |
| 1605 | /* |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1606 | * build control elements |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1607 | */ |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 1608 | |
| 1609 | static void alc_free_kctls(struct hda_codec *codec); |
| 1610 | |
Takashi Iwai | 67d634c | 2009-11-16 15:35:59 +0100 | [diff] [blame] | 1611 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1612 | /* additional beep mixers; the actual parameters are overwritten at build */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 1613 | static const struct snd_kcontrol_new alc_beep_mixer[] = { |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1614 | HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT), |
Jaroslav Kysela | 123c07a | 2009-10-21 14:48:23 +0200 | [diff] [blame] | 1615 | HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT), |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1616 | { } /* end */ |
| 1617 | }; |
Takashi Iwai | 67d634c | 2009-11-16 15:35:59 +0100 | [diff] [blame] | 1618 | #endif |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1619 | |
Takashi Iwai | 2eab694 | 2012-12-18 15:30:41 +0100 | [diff] [blame] | 1620 | static int alc_build_controls(struct hda_codec *codec) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1621 | { |
| 1622 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1623 | int i, err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1624 | |
| 1625 | for (i = 0; i < spec->num_mixers; i++) { |
| 1626 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); |
| 1627 | if (err < 0) |
| 1628 | return err; |
| 1629 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1630 | if (spec->multiout.dig_out_nid) { |
Takashi Iwai | dcda580 | 2012-10-12 17:24:51 +0200 | [diff] [blame] | 1631 | err = snd_hda_create_dig_out_ctls(codec, |
| 1632 | spec->multiout.dig_out_nid, |
| 1633 | spec->multiout.dig_out_nid, |
| 1634 | spec->pcm_rec[1].pcm_type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1635 | if (err < 0) |
| 1636 | return err; |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 1637 | if (!spec->no_analog) { |
| 1638 | err = snd_hda_create_spdif_share_sw(codec, |
| 1639 | &spec->multiout); |
| 1640 | if (err < 0) |
| 1641 | return err; |
| 1642 | spec->multiout.share_spdif = 1; |
| 1643 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1644 | } |
| 1645 | if (spec->dig_in_nid) { |
| 1646 | err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); |
| 1647 | if (err < 0) |
| 1648 | return err; |
| 1649 | } |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1650 | |
Takashi Iwai | 67d634c | 2009-11-16 15:35:59 +0100 | [diff] [blame] | 1651 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1652 | /* create beep controls if needed */ |
| 1653 | if (spec->beep_amp) { |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 1654 | const struct snd_kcontrol_new *knew; |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1655 | for (knew = alc_beep_mixer; knew->name; knew++) { |
| 1656 | struct snd_kcontrol *kctl; |
| 1657 | kctl = snd_ctl_new1(knew, codec); |
| 1658 | if (!kctl) |
| 1659 | return -ENOMEM; |
| 1660 | kctl->private_value = spec->beep_amp; |
Jaroslav Kysela | 5e26dfd | 2009-12-10 13:57:01 +0100 | [diff] [blame] | 1661 | err = snd_hda_ctl_add(codec, 0, kctl); |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1662 | if (err < 0) |
| 1663 | return err; |
| 1664 | } |
| 1665 | } |
Takashi Iwai | 67d634c | 2009-11-16 15:35:59 +0100 | [diff] [blame] | 1666 | #endif |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1667 | |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1668 | /* if we have no master control, let's create it */ |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 1669 | if (!spec->no_analog && |
| 1670 | !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1671 | unsigned int vmaster_tlv[4]; |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1672 | snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid, |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1673 | HDA_OUTPUT, vmaster_tlv); |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1674 | err = snd_hda_add_vmaster(codec, "Master Playback Volume", |
Takashi Iwai | 9322ca5 | 2012-02-03 14:28:01 +0100 | [diff] [blame] | 1675 | vmaster_tlv, alc_slave_pfxs, |
| 1676 | "Playback Volume"); |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1677 | if (err < 0) |
| 1678 | return err; |
| 1679 | } |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 1680 | if (!spec->no_analog && |
| 1681 | !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) { |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 1682 | err = __snd_hda_add_vmaster(codec, "Master Playback Switch", |
| 1683 | NULL, alc_slave_pfxs, |
| 1684 | "Playback Switch", |
Takashi Iwai | d2f344b | 2012-03-12 16:59:58 +0100 | [diff] [blame] | 1685 | true, &spec->vmaster_mute.sw_kctl); |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1686 | if (err < 0) |
| 1687 | return err; |
Takashi Iwai | 3bd7b64 | 2012-12-18 14:57:09 +0100 | [diff] [blame] | 1688 | if (spec->vmaster_mute.hook) |
| 1689 | snd_hda_add_vmaster_hook(codec, &spec->vmaster_mute, true); |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1690 | } |
| 1691 | |
Takashi Iwai | bae84e7 | 2010-03-22 08:30:20 +0100 | [diff] [blame] | 1692 | alc_free_kctls(codec); /* no longer needed */ |
| 1693 | |
David Henningsson | 5780b62 | 2012-06-27 18:45:45 +0200 | [diff] [blame] | 1694 | if (spec->shared_mic_hp) { |
| 1695 | int err; |
| 1696 | int nid = spec->autocfg.inputs[1].pin; |
| 1697 | err = snd_hda_jack_add_kctl(codec, nid, "Headphone Mic", 0); |
| 1698 | if (err < 0) |
| 1699 | return err; |
| 1700 | err = snd_hda_jack_detect_enable(codec, nid, 0); |
| 1701 | if (err < 0) |
| 1702 | return err; |
| 1703 | } |
| 1704 | |
Takashi Iwai | 2eab694 | 2012-12-18 15:30:41 +0100 | [diff] [blame] | 1705 | err = snd_hda_jack_add_kctls(codec, &spec->autocfg); |
Takashi Iwai | 01a61e1 | 2011-10-28 00:03:22 +0200 | [diff] [blame] | 1706 | if (err < 0) |
| 1707 | return err; |
David Henningsson | 5780b62 | 2012-06-27 18:45:45 +0200 | [diff] [blame] | 1708 | |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 1709 | alc_apply_fixup(codec, ALC_FIXUP_ACT_BUILD); |
| 1710 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1711 | } |
| 1712 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1713 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1714 | /* |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 1715 | * Common callbacks |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1716 | */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1717 | |
Takashi Iwai | 070cff4 | 2012-02-21 12:54:17 +0100 | [diff] [blame] | 1718 | static void alc_auto_init_std(struct hda_codec *codec); |
Takashi Iwai | 584c0c4 | 2011-03-10 12:51:11 +0100 | [diff] [blame] | 1719 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1720 | static int alc_init(struct hda_codec *codec) |
| 1721 | { |
| 1722 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1723 | |
Takashi Iwai | 546bb67 | 2012-03-07 08:37:19 +0100 | [diff] [blame] | 1724 | if (spec->init_hook) |
| 1725 | spec->init_hook(codec); |
Kailang Yang | 526af6e | 2012-03-07 08:25:20 +0100 | [diff] [blame] | 1726 | |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 1727 | alc_fix_pll(codec); |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1728 | alc_auto_init_amp(codec, spec->init_amp); |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 1729 | |
Takashi Iwai | 2e8b2b2 | 2012-06-13 16:47:32 +0200 | [diff] [blame] | 1730 | snd_hda_gen_apply_verbs(codec); |
Takashi Iwai | 070cff4 | 2012-02-21 12:54:17 +0100 | [diff] [blame] | 1731 | alc_auto_init_std(codec); |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 1732 | |
Takashi Iwai | 3bd7b64 | 2012-12-18 14:57:09 +0100 | [diff] [blame] | 1733 | if (spec->vmaster_mute.sw_kctl && spec->vmaster_mute.hook) |
| 1734 | snd_hda_sync_vmaster_hook(&spec->vmaster_mute); |
| 1735 | |
Takashi Iwai | 5870112 | 2011-01-13 15:41:45 +0100 | [diff] [blame] | 1736 | alc_apply_fixup(codec, ALC_FIXUP_ACT_INIT); |
| 1737 | |
Takashi Iwai | 9e5341b | 2010-09-21 09:57:06 +0200 | [diff] [blame] | 1738 | hda_call_check_power_status(codec, 0x01); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1739 | return 0; |
| 1740 | } |
| 1741 | |
Takashi Iwai | 83012a7 | 2012-08-24 18:38:08 +0200 | [diff] [blame] | 1742 | #ifdef CONFIG_PM |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 1743 | static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid) |
| 1744 | { |
| 1745 | struct alc_spec *spec = codec->spec; |
| 1746 | return snd_hda_check_amp_list_power(codec, &spec->loopback, nid); |
| 1747 | } |
| 1748 | #endif |
| 1749 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1750 | /* |
| 1751 | * Analog playback callbacks |
| 1752 | */ |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1753 | static int alc_playback_pcm_open(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1754 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1755 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1756 | { |
| 1757 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 9a08160 | 2008-02-12 18:37:26 +0100 | [diff] [blame] | 1758 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, |
| 1759 | hinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1760 | } |
| 1761 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1762 | static int alc_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1763 | struct hda_codec *codec, |
| 1764 | unsigned int stream_tag, |
| 1765 | unsigned int format, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1766 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1767 | { |
| 1768 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 1769 | return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, |
| 1770 | stream_tag, format, substream); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1771 | } |
| 1772 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1773 | static int alc_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1774 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1775 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1776 | { |
| 1777 | struct alc_spec *spec = codec->spec; |
| 1778 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); |
| 1779 | } |
| 1780 | |
| 1781 | /* |
| 1782 | * Digital out |
| 1783 | */ |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1784 | static int alc_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1785 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1786 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1787 | { |
| 1788 | struct alc_spec *spec = codec->spec; |
| 1789 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); |
| 1790 | } |
| 1791 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1792 | static int alc_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
Takashi Iwai | 6b97eb4 | 2007-04-05 14:51:48 +0200 | [diff] [blame] | 1793 | struct hda_codec *codec, |
| 1794 | unsigned int stream_tag, |
| 1795 | unsigned int format, |
| 1796 | struct snd_pcm_substream *substream) |
| 1797 | { |
| 1798 | struct alc_spec *spec = codec->spec; |
| 1799 | return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, |
| 1800 | stream_tag, format, substream); |
| 1801 | } |
| 1802 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1803 | static int alc_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
Takashi Iwai | 9b5f12e | 2009-02-13 11:47:37 +0100 | [diff] [blame] | 1804 | struct hda_codec *codec, |
| 1805 | struct snd_pcm_substream *substream) |
| 1806 | { |
| 1807 | struct alc_spec *spec = codec->spec; |
| 1808 | return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout); |
| 1809 | } |
| 1810 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1811 | static int alc_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1812 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1813 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1814 | { |
| 1815 | struct alc_spec *spec = codec->spec; |
| 1816 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); |
| 1817 | } |
| 1818 | |
| 1819 | /* |
| 1820 | * Analog capture |
| 1821 | */ |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1822 | static int alc_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1823 | struct hda_codec *codec, |
| 1824 | unsigned int stream_tag, |
| 1825 | unsigned int format, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1826 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1827 | { |
| 1828 | struct alc_spec *spec = codec->spec; |
| 1829 | |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 1830 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1], |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1831 | stream_tag, 0, format); |
| 1832 | return 0; |
| 1833 | } |
| 1834 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1835 | static int alc_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1836 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1837 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1838 | { |
| 1839 | struct alc_spec *spec = codec->spec; |
| 1840 | |
Takashi Iwai | 888afa1 | 2008-03-18 09:57:50 +0100 | [diff] [blame] | 1841 | snd_hda_codec_cleanup_stream(codec, |
| 1842 | spec->adc_nids[substream->number + 1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1843 | return 0; |
| 1844 | } |
| 1845 | |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 1846 | /* analog capture with dynamic dual-adc changes */ |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1847 | static int dyn_adc_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 1848 | struct hda_codec *codec, |
| 1849 | unsigned int stream_tag, |
| 1850 | unsigned int format, |
| 1851 | struct snd_pcm_substream *substream) |
| 1852 | { |
| 1853 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1854 | 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] | 1855 | spec->cur_adc_stream_tag = stream_tag; |
| 1856 | spec->cur_adc_format = format; |
| 1857 | snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format); |
| 1858 | return 0; |
| 1859 | } |
| 1860 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1861 | static int dyn_adc_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 1862 | struct hda_codec *codec, |
| 1863 | struct snd_pcm_substream *substream) |
| 1864 | { |
| 1865 | struct alc_spec *spec = codec->spec; |
| 1866 | snd_hda_codec_cleanup_stream(codec, spec->cur_adc); |
| 1867 | spec->cur_adc = 0; |
| 1868 | return 0; |
| 1869 | } |
| 1870 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1871 | static const struct hda_pcm_stream dyn_adc_pcm_analog_capture = { |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 1872 | .substreams = 1, |
| 1873 | .channels_min = 2, |
| 1874 | .channels_max = 2, |
| 1875 | .nid = 0, /* fill later */ |
| 1876 | .ops = { |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1877 | .prepare = dyn_adc_capture_pcm_prepare, |
| 1878 | .cleanup = dyn_adc_capture_pcm_cleanup |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 1879 | }, |
| 1880 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1881 | |
| 1882 | /* |
| 1883 | */ |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1884 | static const struct hda_pcm_stream alc_pcm_analog_playback = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1885 | .substreams = 1, |
| 1886 | .channels_min = 2, |
| 1887 | .channels_max = 8, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1888 | /* NID is set in alc_build_pcms */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1889 | .ops = { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1890 | .open = alc_playback_pcm_open, |
| 1891 | .prepare = alc_playback_pcm_prepare, |
| 1892 | .cleanup = alc_playback_pcm_cleanup |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1893 | }, |
| 1894 | }; |
| 1895 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1896 | static const struct hda_pcm_stream alc_pcm_analog_capture = { |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 1897 | .substreams = 1, |
| 1898 | .channels_min = 2, |
| 1899 | .channels_max = 2, |
| 1900 | /* NID is set in alc_build_pcms */ |
| 1901 | }; |
| 1902 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1903 | static const struct hda_pcm_stream alc_pcm_analog_alt_playback = { |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 1904 | .substreams = 1, |
| 1905 | .channels_min = 2, |
| 1906 | .channels_max = 2, |
| 1907 | /* NID is set in alc_build_pcms */ |
| 1908 | }; |
| 1909 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1910 | static const struct hda_pcm_stream alc_pcm_analog_alt_capture = { |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 1911 | .substreams = 2, /* can be overridden */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1912 | .channels_min = 2, |
| 1913 | .channels_max = 2, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1914 | /* NID is set in alc_build_pcms */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1915 | .ops = { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1916 | .prepare = alc_alt_capture_pcm_prepare, |
| 1917 | .cleanup = alc_alt_capture_pcm_cleanup |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1918 | }, |
| 1919 | }; |
| 1920 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1921 | static const struct hda_pcm_stream alc_pcm_digital_playback = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1922 | .substreams = 1, |
| 1923 | .channels_min = 2, |
| 1924 | .channels_max = 2, |
| 1925 | /* NID is set in alc_build_pcms */ |
| 1926 | .ops = { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1927 | .open = alc_dig_playback_pcm_open, |
| 1928 | .close = alc_dig_playback_pcm_close, |
| 1929 | .prepare = alc_dig_playback_pcm_prepare, |
| 1930 | .cleanup = alc_dig_playback_pcm_cleanup |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1931 | }, |
| 1932 | }; |
| 1933 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1934 | static const struct hda_pcm_stream alc_pcm_digital_capture = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1935 | .substreams = 1, |
| 1936 | .channels_min = 2, |
| 1937 | .channels_max = 2, |
| 1938 | /* NID is set in alc_build_pcms */ |
| 1939 | }; |
| 1940 | |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 1941 | /* 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] | 1942 | static const struct hda_pcm_stream alc_pcm_null_stream = { |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 1943 | .substreams = 0, |
| 1944 | .channels_min = 0, |
| 1945 | .channels_max = 0, |
| 1946 | }; |
| 1947 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1948 | static int alc_build_pcms(struct hda_codec *codec) |
| 1949 | { |
| 1950 | struct alc_spec *spec = codec->spec; |
| 1951 | struct hda_pcm *info = spec->pcm_rec; |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1952 | const struct hda_pcm_stream *p; |
Takashi Iwai | 1fa1757 | 2011-11-02 21:30:51 +0100 | [diff] [blame] | 1953 | bool have_multi_adcs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1954 | int i; |
| 1955 | |
| 1956 | codec->num_pcms = 1; |
| 1957 | codec->pcm_info = info; |
| 1958 | |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 1959 | if (spec->no_analog) |
| 1960 | goto skip_analog; |
| 1961 | |
Takashi Iwai | 812a2cc | 2009-05-16 10:00:49 +0200 | [diff] [blame] | 1962 | snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog), |
| 1963 | "%s Analog", codec->chip_name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1964 | info->name = spec->stream_name_analog; |
Kailang Yang | 274693f | 2009-12-03 10:07:50 +0100 | [diff] [blame] | 1965 | |
Takashi Iwai | eedec3d | 2012-02-06 10:24:04 +0100 | [diff] [blame] | 1966 | if (spec->multiout.num_dacs > 0) { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1967 | p = spec->stream_analog_playback; |
| 1968 | if (!p) |
| 1969 | p = &alc_pcm_analog_playback; |
| 1970 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *p; |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 1971 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0]; |
Takashi Iwai | 9c9a517 | 2012-07-31 11:35:35 +0200 | [diff] [blame] | 1972 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = |
| 1973 | spec->multiout.max_channels; |
Takashi Iwai | ee81abb | 2012-11-08 17:12:10 +0100 | [diff] [blame] | 1974 | if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT && |
| 1975 | spec->autocfg.line_outs == 2) |
| 1976 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].chmap = |
| 1977 | snd_pcm_2_1_chmaps; |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 1978 | } |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 1979 | if (spec->num_adc_nids) { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1980 | p = spec->stream_analog_capture; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1981 | if (!p) { |
| 1982 | if (spec->dyn_adc_switch) |
| 1983 | p = &dyn_adc_pcm_analog_capture; |
| 1984 | else |
| 1985 | p = &alc_pcm_analog_capture; |
| 1986 | } |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1987 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *p; |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 1988 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; |
| 1989 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1990 | |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 1991 | if (spec->channel_mode) { |
| 1992 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0; |
| 1993 | for (i = 0; i < spec->num_channel_mode; i++) { |
| 1994 | if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) { |
| 1995 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels; |
| 1996 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1997 | } |
| 1998 | } |
| 1999 | |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 2000 | skip_analog: |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2001 | /* SPDIF for stream index #1 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2002 | if (spec->multiout.dig_out_nid || spec->dig_in_nid) { |
Takashi Iwai | 812a2cc | 2009-05-16 10:00:49 +0200 | [diff] [blame] | 2003 | snprintf(spec->stream_name_digital, |
| 2004 | sizeof(spec->stream_name_digital), |
| 2005 | "%s Digital", codec->chip_name); |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2006 | codec->num_pcms = 2; |
Wu Fengguang | b25c9da | 2009-02-06 15:02:27 +0800 | [diff] [blame] | 2007 | codec->slave_dig_outs = spec->multiout.slave_dig_outs; |
Takashi Iwai | c06134d | 2006-10-11 18:49:13 +0200 | [diff] [blame] | 2008 | info = spec->pcm_rec + 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2009 | info->name = spec->stream_name_digital; |
Takashi Iwai | 8c44198 | 2009-01-20 18:30:20 +0100 | [diff] [blame] | 2010 | if (spec->dig_out_type) |
| 2011 | info->pcm_type = spec->dig_out_type; |
| 2012 | else |
| 2013 | info->pcm_type = HDA_PCM_TYPE_SPDIF; |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2014 | if (spec->multiout.dig_out_nid) { |
| 2015 | p = spec->stream_digital_playback; |
| 2016 | if (!p) |
| 2017 | p = &alc_pcm_digital_playback; |
| 2018 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2019 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; |
| 2020 | } |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2021 | if (spec->dig_in_nid) { |
| 2022 | p = spec->stream_digital_capture; |
| 2023 | if (!p) |
| 2024 | p = &alc_pcm_digital_capture; |
| 2025 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2026 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; |
| 2027 | } |
Takashi Iwai | 963f803 | 2008-08-11 10:04:40 +0200 | [diff] [blame] | 2028 | /* FIXME: do we need this for all Realtek codec models? */ |
| 2029 | codec->spdif_status_reset = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2030 | } |
| 2031 | |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 2032 | if (spec->no_analog) |
| 2033 | return 0; |
| 2034 | |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2035 | /* If the use of more than one ADC is requested for the current |
| 2036 | * model, configure a second analog capture-only PCM. |
| 2037 | */ |
Takashi Iwai | 1fa1757 | 2011-11-02 21:30:51 +0100 | [diff] [blame] | 2038 | have_multi_adcs = (spec->num_adc_nids > 1) && |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 2039 | !spec->dyn_adc_switch && !spec->auto_mic; |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2040 | /* Additional Analaog capture for index #2 */ |
Takashi Iwai | 1fa1757 | 2011-11-02 21:30:51 +0100 | [diff] [blame] | 2041 | if (spec->alt_dac_nid || have_multi_adcs) { |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2042 | codec->num_pcms = 3; |
Takashi Iwai | c06134d | 2006-10-11 18:49:13 +0200 | [diff] [blame] | 2043 | info = spec->pcm_rec + 2; |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2044 | info->name = spec->stream_name_analog; |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2045 | if (spec->alt_dac_nid) { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2046 | p = spec->stream_analog_alt_playback; |
| 2047 | if (!p) |
| 2048 | p = &alc_pcm_analog_alt_playback; |
| 2049 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *p; |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2050 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = |
| 2051 | spec->alt_dac_nid; |
| 2052 | } else { |
| 2053 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = |
| 2054 | alc_pcm_null_stream; |
| 2055 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0; |
| 2056 | } |
Takashi Iwai | 1fa1757 | 2011-11-02 21:30:51 +0100 | [diff] [blame] | 2057 | if (have_multi_adcs) { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2058 | p = spec->stream_analog_alt_capture; |
| 2059 | if (!p) |
| 2060 | p = &alc_pcm_analog_alt_capture; |
| 2061 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *p; |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2062 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = |
| 2063 | spec->adc_nids[1]; |
| 2064 | info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = |
| 2065 | spec->num_adc_nids - 1; |
| 2066 | } else { |
| 2067 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = |
| 2068 | alc_pcm_null_stream; |
| 2069 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0; |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2070 | } |
| 2071 | } |
| 2072 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2073 | return 0; |
| 2074 | } |
| 2075 | |
Takashi Iwai | a4e09aa | 2009-12-27 11:22:24 +0100 | [diff] [blame] | 2076 | static inline void alc_shutup(struct hda_codec *codec) |
| 2077 | { |
Takashi Iwai | 1c71615 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 2078 | struct alc_spec *spec = codec->spec; |
| 2079 | |
| 2080 | if (spec && spec->shutup) |
| 2081 | spec->shutup(codec); |
Takashi Iwai | a4e09aa | 2009-12-27 11:22:24 +0100 | [diff] [blame] | 2082 | snd_hda_shutup_pins(codec); |
| 2083 | } |
| 2084 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 2085 | static void alc_free_kctls(struct hda_codec *codec) |
| 2086 | { |
| 2087 | struct alc_spec *spec = codec->spec; |
| 2088 | |
| 2089 | if (spec->kctls.list) { |
| 2090 | struct snd_kcontrol_new *kctl = spec->kctls.list; |
| 2091 | int i; |
| 2092 | for (i = 0; i < spec->kctls.used; i++) |
| 2093 | kfree(kctl[i].name); |
| 2094 | } |
| 2095 | snd_array_free(&spec->kctls); |
| 2096 | } |
| 2097 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2098 | static void alc_free_bind_ctls(struct hda_codec *codec) |
| 2099 | { |
| 2100 | struct alc_spec *spec = codec->spec; |
| 2101 | if (spec->bind_ctls.list) { |
| 2102 | struct hda_bind_ctls **ctl = spec->bind_ctls.list; |
| 2103 | int i; |
| 2104 | for (i = 0; i < spec->bind_ctls.used; i++) |
| 2105 | kfree(ctl[i]); |
| 2106 | } |
| 2107 | snd_array_free(&spec->bind_ctls); |
| 2108 | } |
| 2109 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2110 | static void alc_free(struct hda_codec *codec) |
| 2111 | { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2112 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2113 | |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2114 | if (!spec) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2115 | return; |
| 2116 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 2117 | alc_free_kctls(codec); |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2118 | alc_free_bind_ctls(codec); |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 2119 | snd_array_free(&spec->paths); |
Takashi Iwai | ee48df5 | 2012-06-26 14:54:32 +0200 | [diff] [blame] | 2120 | snd_hda_gen_free(&spec->gen); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2121 | kfree(spec); |
Kusanagi Kouichi | 680cd53 | 2009-02-05 00:00:58 +0900 | [diff] [blame] | 2122 | snd_hda_detach_beep_device(codec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2123 | } |
| 2124 | |
Takashi Iwai | 83012a7 | 2012-08-24 18:38:08 +0200 | [diff] [blame] | 2125 | #ifdef CONFIG_PM |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 2126 | static void alc_power_eapd(struct hda_codec *codec) |
| 2127 | { |
Takashi Iwai | 691f1fc | 2011-04-07 10:31:43 +0200 | [diff] [blame] | 2128 | alc_auto_setup_eapd(codec, false); |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 2129 | } |
| 2130 | |
Takashi Iwai | 68cb2b5 | 2012-07-02 15:20:37 +0200 | [diff] [blame] | 2131 | static int alc_suspend(struct hda_codec *codec) |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 2132 | { |
| 2133 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | a4e09aa | 2009-12-27 11:22:24 +0100 | [diff] [blame] | 2134 | alc_shutup(codec); |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 2135 | if (spec && spec->power_hook) |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 2136 | spec->power_hook(codec); |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 2137 | return 0; |
| 2138 | } |
| 2139 | #endif |
| 2140 | |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 2141 | #ifdef CONFIG_PM |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2142 | static int alc_resume(struct hda_codec *codec) |
| 2143 | { |
Takashi Iwai | 1c71615 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 2144 | msleep(150); /* to avoid pop noise */ |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2145 | codec->patch_ops.init(codec); |
| 2146 | snd_hda_codec_resume_amp(codec); |
| 2147 | snd_hda_codec_resume_cache(codec); |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 2148 | alc_inv_dmic_sync(codec, true); |
Takashi Iwai | 9e5341b | 2010-09-21 09:57:06 +0200 | [diff] [blame] | 2149 | hda_call_check_power_status(codec, 0x01); |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2150 | return 0; |
| 2151 | } |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2152 | #endif |
| 2153 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2154 | /* |
| 2155 | */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 2156 | static const struct hda_codec_ops alc_patch_ops = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2157 | .build_controls = alc_build_controls, |
| 2158 | .build_pcms = alc_build_pcms, |
| 2159 | .init = alc_init, |
| 2160 | .free = alc_free, |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 2161 | .unsol_event = snd_hda_jack_unsol_event, |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 2162 | #ifdef CONFIG_PM |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2163 | .resume = alc_resume, |
| 2164 | #endif |
Takashi Iwai | 83012a7 | 2012-08-24 18:38:08 +0200 | [diff] [blame] | 2165 | #ifdef CONFIG_PM |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 2166 | .suspend = alc_suspend, |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 2167 | .check_power_status = alc_check_power_status, |
| 2168 | #endif |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 2169 | .reboot_notify = alc_shutup, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2170 | }; |
| 2171 | |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 2172 | |
Kailang Yang | c027ddc | 2010-03-19 11:33:06 +0100 | [diff] [blame] | 2173 | /* replace the codec chip_name with the given string */ |
| 2174 | static int alc_codec_rename(struct hda_codec *codec, const char *name) |
| 2175 | { |
| 2176 | kfree(codec->chip_name); |
| 2177 | codec->chip_name = kstrdup(name, GFP_KERNEL); |
| 2178 | if (!codec->chip_name) { |
| 2179 | alc_free(codec); |
| 2180 | return -ENOMEM; |
| 2181 | } |
| 2182 | return 0; |
| 2183 | } |
| 2184 | |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 2185 | /* |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 2186 | * Rename codecs appropriately from COEF value |
| 2187 | */ |
| 2188 | struct alc_codec_rename_table { |
| 2189 | unsigned int vendor_id; |
| 2190 | unsigned short coef_mask; |
| 2191 | unsigned short coef_bits; |
| 2192 | const char *name; |
| 2193 | }; |
| 2194 | |
| 2195 | static struct alc_codec_rename_table rename_tbl[] = { |
| 2196 | { 0x10ec0269, 0xfff0, 0x3010, "ALC277" }, |
| 2197 | { 0x10ec0269, 0xf0f0, 0x2010, "ALC259" }, |
| 2198 | { 0x10ec0269, 0xf0f0, 0x3010, "ALC258" }, |
| 2199 | { 0x10ec0269, 0x00f0, 0x0010, "ALC269VB" }, |
| 2200 | { 0x10ec0269, 0xffff, 0xa023, "ALC259" }, |
| 2201 | { 0x10ec0269, 0xffff, 0x6023, "ALC281X" }, |
| 2202 | { 0x10ec0269, 0x00f0, 0x0020, "ALC269VC" }, |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 2203 | { 0x10ec0269, 0x00f0, 0x0030, "ALC269VD" }, |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 2204 | { 0x10ec0887, 0x00f0, 0x0030, "ALC887-VD" }, |
| 2205 | { 0x10ec0888, 0x00f0, 0x0030, "ALC888-VD" }, |
| 2206 | { 0x10ec0888, 0xf0f0, 0x3020, "ALC886" }, |
| 2207 | { 0x10ec0899, 0x2000, 0x2000, "ALC899" }, |
| 2208 | { 0x10ec0892, 0xffff, 0x8020, "ALC661" }, |
| 2209 | { 0x10ec0892, 0xffff, 0x8011, "ALC661" }, |
| 2210 | { 0x10ec0892, 0xffff, 0x4011, "ALC656" }, |
| 2211 | { } /* terminator */ |
| 2212 | }; |
| 2213 | |
| 2214 | static int alc_codec_rename_from_preset(struct hda_codec *codec) |
| 2215 | { |
| 2216 | const struct alc_codec_rename_table *p; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 2217 | |
| 2218 | for (p = rename_tbl; p->vendor_id; p++) { |
| 2219 | if (p->vendor_id != codec->vendor_id) |
| 2220 | continue; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 2221 | if ((alc_get_coef0(codec) & p->coef_mask) == p->coef_bits) |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 2222 | return alc_codec_rename(codec, p->name); |
| 2223 | } |
| 2224 | return 0; |
| 2225 | } |
| 2226 | |
| 2227 | /* |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2228 | * Automatic parse of I/O pins from the BIOS configuration |
| 2229 | */ |
| 2230 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2231 | enum { |
| 2232 | ALC_CTL_WIDGET_VOL, |
| 2233 | ALC_CTL_WIDGET_MUTE, |
| 2234 | ALC_CTL_BIND_MUTE, |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2235 | ALC_CTL_BIND_VOL, |
| 2236 | ALC_CTL_BIND_SW, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2237 | }; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 2238 | static const struct snd_kcontrol_new alc_control_templates[] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2239 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), |
| 2240 | HDA_CODEC_MUTE(NULL, 0, 0, 0), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 2241 | HDA_BIND_MUTE(NULL, 0, 0, 0), |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2242 | HDA_BIND_VOL(NULL, 0), |
| 2243 | HDA_BIND_SW(NULL, 0), |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2244 | }; |
| 2245 | |
| 2246 | /* add dynamic controls */ |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2247 | 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] | 2248 | int cidx, unsigned long val) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2249 | { |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2250 | struct snd_kcontrol_new *knew; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2251 | |
Takashi Iwai | 668d1e9 | 2012-11-29 14:10:17 +0100 | [diff] [blame] | 2252 | knew = alc_kcontrol_new(spec, name, &alc_control_templates[type]); |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 2253 | if (!knew) |
| 2254 | return -ENOMEM; |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2255 | knew->index = cidx; |
Jaroslav Kysela | 4d02d1b | 2009-11-12 10:15:48 +0100 | [diff] [blame] | 2256 | if (get_amp_nid_(val)) |
Jaroslav Kysela | 5e26dfd | 2009-12-10 13:57:01 +0100 | [diff] [blame] | 2257 | knew->subdevice = HDA_SUBDEV_AMP_FLAG; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2258 | knew->private_value = val; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2259 | return 0; |
| 2260 | } |
| 2261 | |
Takashi Iwai | 0afe5f8 | 2009-10-02 09:20:00 +0200 | [diff] [blame] | 2262 | static int add_control_with_pfx(struct alc_spec *spec, int type, |
| 2263 | const char *pfx, const char *dir, |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2264 | const char *sfx, int cidx, unsigned long val) |
Takashi Iwai | 0afe5f8 | 2009-10-02 09:20:00 +0200 | [diff] [blame] | 2265 | { |
| 2266 | char name[32]; |
| 2267 | snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx); |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2268 | return add_control(spec, type, name, cidx, val); |
Takashi Iwai | 0afe5f8 | 2009-10-02 09:20:00 +0200 | [diff] [blame] | 2269 | } |
| 2270 | |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2271 | #define add_pb_vol_ctrl(spec, type, pfx, val) \ |
| 2272 | add_control_with_pfx(spec, type, pfx, "Playback", "Volume", 0, val) |
| 2273 | #define add_pb_sw_ctrl(spec, type, pfx, val) \ |
| 2274 | add_control_with_pfx(spec, type, pfx, "Playback", "Switch", 0, val) |
| 2275 | #define __add_pb_vol_ctrl(spec, type, pfx, cidx, val) \ |
| 2276 | add_control_with_pfx(spec, type, pfx, "Playback", "Volume", cidx, val) |
| 2277 | #define __add_pb_sw_ctrl(spec, type, pfx, cidx, val) \ |
| 2278 | add_control_with_pfx(spec, type, pfx, "Playback", "Switch", cidx, val) |
Takashi Iwai | 0afe5f8 | 2009-10-02 09:20:00 +0200 | [diff] [blame] | 2279 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2280 | static const char * const channel_name[4] = { |
| 2281 | "Front", "Surround", "CLFE", "Side" |
| 2282 | }; |
| 2283 | |
Takashi Iwai | 6843ca1 | 2011-06-24 11:03:58 +0200 | [diff] [blame] | 2284 | static const char *alc_get_line_out_pfx(struct alc_spec *spec, int ch, |
| 2285 | bool can_be_master, int *index) |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2286 | { |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 2287 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2288 | |
Takashi Iwai | 6843ca1 | 2011-06-24 11:03:58 +0200 | [diff] [blame] | 2289 | *index = 0; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 2290 | if (cfg->line_outs == 1 && !spec->multi_ios && |
| 2291 | !cfg->hp_outs && !cfg->speaker_outs && can_be_master) |
Takashi Iwai | 52a8efa | 2012-12-18 17:33:04 +0100 | [diff] [blame] | 2292 | return spec->vmaster_mute.hook ? "PCM" : "Master"; |
| 2293 | |
| 2294 | /* if there is really a single DAC used in the whole output paths, |
| 2295 | * use it master (or "PCM" if a vmaster hook is present) |
| 2296 | */ |
| 2297 | if (spec->multiout.num_dacs == 1 && !spec->mixer_nid && |
| 2298 | !spec->multiout.hp_out_nid[0] && !spec->multiout.extra_out_nid[0]) |
| 2299 | return spec->vmaster_mute.hook ? "PCM" : "Master"; |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2300 | |
| 2301 | switch (cfg->line_out_type) { |
| 2302 | case AUTO_PIN_SPEAKER_OUT: |
David Henningsson | ebbeb3d | 2011-03-04 14:08:30 +0100 | [diff] [blame] | 2303 | if (cfg->line_outs == 1) |
| 2304 | return "Speaker"; |
Takashi Iwai | fbabc24 | 2011-12-07 17:14:20 +0100 | [diff] [blame] | 2305 | if (cfg->line_outs == 2) |
| 2306 | return ch ? "Bass Speaker" : "Speaker"; |
David Henningsson | ebbeb3d | 2011-03-04 14:08:30 +0100 | [diff] [blame] | 2307 | break; |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2308 | case AUTO_PIN_HP_OUT: |
Takashi Iwai | 6843ca1 | 2011-06-24 11:03:58 +0200 | [diff] [blame] | 2309 | /* for multi-io case, only the primary out */ |
| 2310 | if (ch && spec->multi_ios) |
| 2311 | break; |
| 2312 | *index = ch; |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2313 | return "Headphone"; |
| 2314 | default: |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 2315 | if (cfg->line_outs == 1 && !spec->multi_ios) |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2316 | return "PCM"; |
| 2317 | break; |
| 2318 | } |
David Henningsson | 71aa5eb | 2012-10-17 12:43:44 +0200 | [diff] [blame] | 2319 | if (ch >= ARRAY_SIZE(channel_name)) { |
| 2320 | snd_BUG(); |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2321 | return "PCM"; |
David Henningsson | 71aa5eb | 2012-10-17 12:43:44 +0200 | [diff] [blame] | 2322 | } |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2323 | |
| 2324 | return channel_name[ch]; |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2325 | } |
| 2326 | |
Takashi Iwai | 83012a7 | 2012-08-24 18:38:08 +0200 | [diff] [blame] | 2327 | #ifdef CONFIG_PM |
Takashi Iwai | 164f73e | 2012-02-21 11:27:09 +0100 | [diff] [blame] | 2328 | /* add the powersave loopback-list entry */ |
| 2329 | static void add_loopback_list(struct alc_spec *spec, hda_nid_t mix, int idx) |
| 2330 | { |
| 2331 | struct hda_amp_list *list; |
| 2332 | |
| 2333 | if (spec->num_loopbacks >= ARRAY_SIZE(spec->loopback_list) - 1) |
| 2334 | return; |
| 2335 | list = spec->loopback_list + spec->num_loopbacks; |
| 2336 | list->nid = mix; |
| 2337 | list->dir = HDA_INPUT; |
| 2338 | list->idx = idx; |
| 2339 | spec->num_loopbacks++; |
| 2340 | spec->loopback.amplist = spec->loopback_list; |
| 2341 | } |
| 2342 | #else |
| 2343 | #define add_loopback_list(spec, mix, idx) /* NOP */ |
| 2344 | #endif |
| 2345 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2346 | /* create input playback/capture controls for the given pin */ |
Takashi Iwai | c2fd19c | 2012-12-12 18:02:41 +0100 | [diff] [blame] | 2347 | 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] | 2348 | const char *ctlname, int ctlidx, |
Takashi Iwai | c2fd19c | 2012-12-12 18:02:41 +0100 | [diff] [blame] | 2349 | hda_nid_t mix_nid) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2350 | { |
Takashi Iwai | c2fd19c | 2012-12-12 18:02:41 +0100 | [diff] [blame] | 2351 | struct alc_spec *spec = codec->spec; |
| 2352 | struct nid_path *path; |
Takashi Iwai | 829f69e | 2012-12-14 18:26:02 +0100 | [diff] [blame] | 2353 | unsigned int val; |
Takashi Iwai | c2fd19c | 2012-12-12 18:02:41 +0100 | [diff] [blame] | 2354 | int err, idx; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2355 | |
Takashi Iwai | bd32f78 | 2012-12-12 18:08:52 +0100 | [diff] [blame] | 2356 | if (!nid_has_volume(codec, mix_nid, HDA_INPUT) && |
| 2357 | !nid_has_mute(codec, mix_nid, HDA_INPUT)) |
| 2358 | return 0; /* no need for analog loopback */ |
| 2359 | |
Takashi Iwai | 965cceb | 2012-12-18 11:46:37 +0100 | [diff] [blame] | 2360 | path = add_new_nid_path(codec, pin, mix_nid, 2); |
Takashi Iwai | c2fd19c | 2012-12-12 18:02:41 +0100 | [diff] [blame] | 2361 | if (!path) |
Takashi Iwai | c2fd19c | 2012-12-12 18:02:41 +0100 | [diff] [blame] | 2362 | return -EINVAL; |
| 2363 | |
| 2364 | idx = path->idx[path->depth - 1]; |
Takashi Iwai | bd32f78 | 2012-12-12 18:08:52 +0100 | [diff] [blame] | 2365 | if (nid_has_volume(codec, mix_nid, HDA_INPUT)) { |
Takashi Iwai | 829f69e | 2012-12-14 18:26:02 +0100 | [diff] [blame] | 2366 | val = HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT); |
| 2367 | 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] | 2368 | if (err < 0) |
| 2369 | return err; |
Takashi Iwai | 829f69e | 2012-12-14 18:26:02 +0100 | [diff] [blame] | 2370 | path->ctls[NID_PATH_VOL_CTL] = val; |
Takashi Iwai | bd32f78 | 2012-12-12 18:08:52 +0100 | [diff] [blame] | 2371 | } |
| 2372 | |
| 2373 | if (nid_has_mute(codec, mix_nid, HDA_INPUT)) { |
Takashi Iwai | 829f69e | 2012-12-14 18:26:02 +0100 | [diff] [blame] | 2374 | val = HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT); |
| 2375 | 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] | 2376 | if (err < 0) |
| 2377 | return err; |
Takashi Iwai | 829f69e | 2012-12-14 18:26:02 +0100 | [diff] [blame] | 2378 | path->ctls[NID_PATH_MUTE_CTL] = val; |
Takashi Iwai | bd32f78 | 2012-12-12 18:08:52 +0100 | [diff] [blame] | 2379 | } |
| 2380 | |
Takashi Iwai | 829f69e | 2012-12-14 18:26:02 +0100 | [diff] [blame] | 2381 | path->active = true; |
Takashi Iwai | 164f73e | 2012-02-21 11:27:09 +0100 | [diff] [blame] | 2382 | add_loopback_list(spec, mix_nid, idx); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2383 | return 0; |
| 2384 | } |
| 2385 | |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2386 | 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] | 2387 | { |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2388 | unsigned int pincap = snd_hda_query_pin_caps(codec, nid); |
| 2389 | return (pincap & AC_PINCAP_IN) != 0; |
| 2390 | } |
| 2391 | |
Takashi Iwai | c2fd19c | 2012-12-12 18:02:41 +0100 | [diff] [blame] | 2392 | /* check whether the given two widgets can be connected */ |
| 2393 | static bool is_reachable_path(struct hda_codec *codec, |
| 2394 | hda_nid_t from_nid, hda_nid_t to_nid) |
| 2395 | { |
| 2396 | if (!from_nid || !to_nid) |
| 2397 | return false; |
| 2398 | return snd_hda_get_conn_index(codec, to_nid, from_nid, true) >= 0; |
| 2399 | } |
| 2400 | |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2401 | /* Parse the codec tree and retrieve ADCs */ |
| 2402 | static int alc_auto_fill_adc_nids(struct hda_codec *codec) |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2403 | { |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2404 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2405 | hda_nid_t nid; |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 2406 | hda_nid_t *adc_nids = spec->adc_nids; |
| 2407 | int max_nums = ARRAY_SIZE(spec->adc_nids); |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2408 | int i, nums = 0; |
| 2409 | |
| 2410 | nid = codec->start_nid; |
| 2411 | for (i = 0; i < codec->num_nodes; i++, nid++) { |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2412 | unsigned int caps = get_wcaps(codec, nid); |
| 2413 | int type = get_wcaps_type(caps); |
| 2414 | |
| 2415 | if (type != AC_WID_AUD_IN || (caps & AC_WCAP_DIGITAL)) |
| 2416 | continue; |
| 2417 | adc_nids[nums] = nid; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2418 | if (++nums >= max_nums) |
| 2419 | break; |
| 2420 | } |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2421 | spec->num_adc_nids = nums; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2422 | return nums; |
| 2423 | } |
| 2424 | |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2425 | /* filter out invalid adc_nids that don't give all active input pins; |
| 2426 | * if needed, check whether dynamic ADC-switching is available |
| 2427 | */ |
| 2428 | static int check_dyn_adc_switch(struct hda_codec *codec) |
| 2429 | { |
| 2430 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 2431 | struct hda_input_mux *imux = &spec->input_mux; |
| 2432 | hda_nid_t adc_nids[ARRAY_SIZE(spec->adc_nids)]; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2433 | int i, n, nums; |
| 2434 | hda_nid_t pin, adc; |
| 2435 | |
| 2436 | again: |
| 2437 | nums = 0; |
| 2438 | for (n = 0; n < spec->num_adc_nids; n++) { |
| 2439 | adc = spec->adc_nids[n]; |
| 2440 | for (i = 0; i < imux->num_items; i++) { |
| 2441 | pin = spec->imux_pins[i]; |
| 2442 | if (!is_reachable_path(codec, pin, adc)) |
| 2443 | break; |
| 2444 | } |
| 2445 | if (i >= imux->num_items) |
| 2446 | adc_nids[nums++] = adc; |
| 2447 | } |
| 2448 | |
| 2449 | if (!nums) { |
| 2450 | if (spec->shared_mic_hp) { |
| 2451 | spec->shared_mic_hp = 0; |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 2452 | imux->num_items = 1; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2453 | goto again; |
| 2454 | } |
| 2455 | |
| 2456 | /* check whether ADC-switch is possible */ |
| 2457 | for (i = 0; i < imux->num_items; i++) { |
| 2458 | pin = spec->imux_pins[i]; |
| 2459 | for (n = 0; n < spec->num_adc_nids; n++) { |
| 2460 | adc = spec->adc_nids[n]; |
| 2461 | if (is_reachable_path(codec, pin, adc)) { |
| 2462 | spec->dyn_adc_idx[i] = n; |
| 2463 | break; |
| 2464 | } |
| 2465 | } |
| 2466 | } |
| 2467 | |
| 2468 | snd_printdd("realtek: enabling ADC switching\n"); |
| 2469 | spec->dyn_adc_switch = 1; |
| 2470 | } else if (nums != spec->num_adc_nids) { |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 2471 | memcpy(spec->adc_nids, adc_nids, nums * sizeof(hda_nid_t)); |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2472 | spec->num_adc_nids = nums; |
| 2473 | } |
| 2474 | |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 2475 | if (imux->num_items == 1 || spec->shared_mic_hp) { |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2476 | snd_printdd("realtek: reducing to a single ADC\n"); |
| 2477 | spec->num_adc_nids = 1; /* reduce to a single ADC */ |
| 2478 | } |
| 2479 | |
Takashi Iwai | 9bf387b | 2012-12-18 17:18:21 +0100 | [diff] [blame] | 2480 | /* single index for individual volumes ctls */ |
| 2481 | if (!spec->dyn_adc_switch && spec->multi_cap_vol) |
| 2482 | spec->num_adc_nids = 1; |
| 2483 | |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2484 | return 0; |
| 2485 | } |
| 2486 | |
| 2487 | /* templates for capture controls */ |
| 2488 | static const struct snd_kcontrol_new cap_src_temp = { |
| 2489 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 2490 | .name = "Input Source", |
| 2491 | .info = alc_mux_enum_info, |
| 2492 | .get = alc_mux_enum_get, |
| 2493 | .put = alc_mux_enum_put, |
| 2494 | }; |
| 2495 | |
| 2496 | static const struct snd_kcontrol_new cap_vol_temp = { |
| 2497 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 2498 | .name = "Capture Volume", |
| 2499 | .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | |
| 2500 | SNDRV_CTL_ELEM_ACCESS_TLV_READ | |
| 2501 | SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), |
| 2502 | .info = alc_cap_vol_info, |
| 2503 | .get = alc_cap_vol_get, |
| 2504 | .put = alc_cap_vol_put, |
| 2505 | .tlv = { .c = alc_cap_vol_tlv }, |
| 2506 | }; |
| 2507 | |
| 2508 | static const struct snd_kcontrol_new cap_sw_temp = { |
| 2509 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 2510 | .name = "Capture Switch", |
| 2511 | .info = alc_cap_sw_info, |
| 2512 | .get = alc_cap_sw_get, |
| 2513 | .put = alc_cap_sw_put, |
| 2514 | }; |
| 2515 | |
| 2516 | static int parse_capvol_in_path(struct hda_codec *codec, struct nid_path *path) |
| 2517 | { |
| 2518 | hda_nid_t nid; |
| 2519 | int i, depth; |
| 2520 | |
| 2521 | path->ctls[NID_PATH_VOL_CTL] = path->ctls[NID_PATH_MUTE_CTL] = 0; |
| 2522 | for (depth = 0; depth < 3; depth++) { |
| 2523 | if (depth >= path->depth) |
| 2524 | return -EINVAL; |
| 2525 | i = path->depth - depth - 1; |
| 2526 | nid = path->path[i]; |
| 2527 | if (!path->ctls[NID_PATH_VOL_CTL]) { |
| 2528 | if (nid_has_volume(codec, nid, HDA_OUTPUT)) |
| 2529 | path->ctls[NID_PATH_VOL_CTL] = |
| 2530 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); |
| 2531 | else if (nid_has_volume(codec, nid, HDA_INPUT)) { |
| 2532 | int idx = path->idx[i]; |
| 2533 | if (!depth && codec->single_adc_amp) |
| 2534 | idx = 0; |
| 2535 | path->ctls[NID_PATH_VOL_CTL] = |
| 2536 | HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_INPUT); |
| 2537 | } |
| 2538 | } |
| 2539 | if (!path->ctls[NID_PATH_MUTE_CTL]) { |
| 2540 | if (nid_has_mute(codec, nid, HDA_OUTPUT)) |
| 2541 | path->ctls[NID_PATH_MUTE_CTL] = |
| 2542 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); |
| 2543 | else if (nid_has_mute(codec, nid, HDA_INPUT)) { |
| 2544 | int idx = path->idx[i]; |
| 2545 | if (!depth && codec->single_adc_amp) |
| 2546 | idx = 0; |
| 2547 | path->ctls[NID_PATH_MUTE_CTL] = |
| 2548 | HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_INPUT); |
| 2549 | } |
| 2550 | } |
| 2551 | } |
| 2552 | return 0; |
| 2553 | } |
| 2554 | |
Takashi Iwai | 81fede8 | 2012-12-18 17:24:25 +0100 | [diff] [blame^] | 2555 | static unsigned int amp_val_replace_channels(unsigned int val, unsigned int chs); |
| 2556 | |
Takashi Iwai | 9bf387b | 2012-12-18 17:18:21 +0100 | [diff] [blame] | 2557 | static int add_single_cap_ctl(struct hda_codec *codec, const char *label, |
| 2558 | int idx, bool is_switch, unsigned int ctl) |
| 2559 | { |
| 2560 | struct alc_spec *spec = codec->spec; |
| 2561 | char tmpname[44]; |
| 2562 | int type = is_switch ? ALC_CTL_WIDGET_MUTE : ALC_CTL_WIDGET_VOL; |
| 2563 | const char *sfx = is_switch ? "Switch" : "Volume"; |
Takashi Iwai | 81fede8 | 2012-12-18 17:24:25 +0100 | [diff] [blame^] | 2564 | unsigned int chs; |
| 2565 | int err; |
Takashi Iwai | 9bf387b | 2012-12-18 17:18:21 +0100 | [diff] [blame] | 2566 | |
| 2567 | if (!ctl) |
| 2568 | return 0; |
| 2569 | |
Takashi Iwai | 81fede8 | 2012-12-18 17:24:25 +0100 | [diff] [blame^] | 2570 | if (idx == spec->inv_dmic_split_idx) |
| 2571 | chs = 1; |
| 2572 | else |
| 2573 | chs = 3; |
| 2574 | |
Takashi Iwai | 9bf387b | 2012-12-18 17:18:21 +0100 | [diff] [blame] | 2575 | if (label) |
| 2576 | snprintf(tmpname, sizeof(tmpname), |
| 2577 | "%s Capture %s", label, sfx); |
| 2578 | else |
| 2579 | snprintf(tmpname, sizeof(tmpname), |
| 2580 | "Capture %s", sfx); |
Takashi Iwai | 81fede8 | 2012-12-18 17:24:25 +0100 | [diff] [blame^] | 2581 | err = add_control(spec, type, tmpname, idx, |
| 2582 | amp_val_replace_channels(ctl, chs)); |
| 2583 | if (err < 0 || chs == 3) |
| 2584 | return err; |
| 2585 | |
| 2586 | /* Make independent right kcontrol */ |
| 2587 | if (label) |
| 2588 | snprintf(tmpname, sizeof(tmpname), |
| 2589 | "Inverted %s Capture %s", label, sfx); |
| 2590 | else |
| 2591 | snprintf(tmpname, sizeof(tmpname), |
| 2592 | "Inverted Capture %s", sfx); |
| 2593 | return add_control(spec, type, tmpname, idx, |
| 2594 | amp_val_replace_channels(ctl, 2)); |
Takashi Iwai | 9bf387b | 2012-12-18 17:18:21 +0100 | [diff] [blame] | 2595 | } |
| 2596 | |
| 2597 | /* create single (and simple) capture volume and switch controls */ |
| 2598 | static int create_single_cap_vol_ctl(struct hda_codec *codec, int idx, |
| 2599 | unsigned int vol_ctl, unsigned int sw_ctl) |
| 2600 | { |
| 2601 | int err; |
| 2602 | err = add_single_cap_ctl(codec, NULL, idx, false, vol_ctl); |
| 2603 | if (err < 0) |
| 2604 | return err; |
| 2605 | err = add_single_cap_ctl(codec, NULL, idx, true, sw_ctl); |
| 2606 | if (err < 0) |
| 2607 | return err; |
| 2608 | return 0; |
| 2609 | } |
| 2610 | |
| 2611 | /* create bound capture volume and switch controls */ |
| 2612 | static int create_bind_cap_vol_ctl(struct hda_codec *codec, int idx, |
| 2613 | unsigned int vol_ctl, unsigned int sw_ctl) |
| 2614 | { |
| 2615 | struct alc_spec *spec = codec->spec; |
| 2616 | struct snd_kcontrol_new *knew; |
| 2617 | |
| 2618 | if (vol_ctl) { |
| 2619 | knew = alc_kcontrol_new(spec, NULL, &cap_vol_temp); |
| 2620 | if (!knew) |
| 2621 | return -ENOMEM; |
| 2622 | knew->index = idx; |
| 2623 | knew->private_value = vol_ctl; |
| 2624 | knew->subdevice = HDA_SUBDEV_AMP_FLAG; |
| 2625 | } |
| 2626 | if (sw_ctl) { |
| 2627 | knew = alc_kcontrol_new(spec, NULL, &cap_sw_temp); |
| 2628 | if (!knew) |
| 2629 | return -ENOMEM; |
| 2630 | knew->index = idx; |
| 2631 | knew->private_value = sw_ctl; |
| 2632 | knew->subdevice = HDA_SUBDEV_AMP_FLAG; |
| 2633 | } |
| 2634 | return 0; |
| 2635 | } |
| 2636 | |
| 2637 | /* return the vol ctl when used first in the imux list */ |
| 2638 | static unsigned int get_first_cap_ctl(struct hda_codec *codec, int idx, int type) |
| 2639 | { |
| 2640 | struct alc_spec *spec = codec->spec; |
| 2641 | struct nid_path *path; |
| 2642 | unsigned int ctl; |
| 2643 | int i; |
| 2644 | |
| 2645 | path = get_nid_path(codec, spec->imux_pins[idx], |
| 2646 | get_adc_nid(codec, 0, idx)); |
| 2647 | if (!path) |
| 2648 | return 0; |
| 2649 | ctl = path->ctls[type]; |
| 2650 | if (!ctl) |
| 2651 | return 0; |
| 2652 | for (i = 0; i < idx - 1; i++) { |
| 2653 | path = get_nid_path(codec, spec->imux_pins[i], |
| 2654 | get_adc_nid(codec, 0, i)); |
| 2655 | if (path && path->ctls[type] == ctl) |
| 2656 | return 0; |
| 2657 | } |
| 2658 | return ctl; |
| 2659 | } |
| 2660 | |
| 2661 | /* create individual capture volume and switch controls per input */ |
| 2662 | static int create_multi_cap_vol_ctl(struct hda_codec *codec) |
| 2663 | { |
| 2664 | struct alc_spec *spec = codec->spec; |
| 2665 | struct hda_input_mux *imux = &spec->input_mux; |
| 2666 | int i, err, type, type_idx = 0; |
| 2667 | const char *prev_label = NULL; |
| 2668 | |
| 2669 | for (i = 0; i < imux->num_items; i++) { |
| 2670 | const char *label; |
| 2671 | label = hda_get_autocfg_input_label(codec, &spec->autocfg, i); |
| 2672 | if (prev_label && !strcmp(label, prev_label)) |
| 2673 | type_idx++; |
| 2674 | else |
| 2675 | type_idx = 0; |
| 2676 | prev_label = label; |
| 2677 | |
| 2678 | for (type = 0; type < 2; type++) { |
| 2679 | err = add_single_cap_ctl(codec, label, type_idx, type, |
| 2680 | get_first_cap_ctl(codec, i, type)); |
| 2681 | if (err < 0) |
| 2682 | return err; |
| 2683 | } |
| 2684 | } |
| 2685 | return 0; |
| 2686 | } |
| 2687 | |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2688 | static int create_capture_mixers(struct hda_codec *codec) |
| 2689 | { |
| 2690 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 2691 | struct hda_input_mux *imux = &spec->input_mux; |
Takashi Iwai | 9bf387b | 2012-12-18 17:18:21 +0100 | [diff] [blame] | 2692 | int i, n, nums, err; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2693 | |
| 2694 | if (spec->dyn_adc_switch) |
| 2695 | nums = 1; |
| 2696 | else |
| 2697 | nums = spec->num_adc_nids; |
| 2698 | |
| 2699 | if (!spec->auto_mic && imux->num_items > 1) { |
Takashi Iwai | 9bf387b | 2012-12-18 17:18:21 +0100 | [diff] [blame] | 2700 | struct snd_kcontrol_new *knew; |
Takashi Iwai | bc54976 | 2012-12-18 15:35:11 +0100 | [diff] [blame] | 2701 | knew = alc_kcontrol_new(spec, NULL, &cap_src_temp); |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2702 | if (!knew) |
| 2703 | return -ENOMEM; |
| 2704 | knew->count = nums; |
| 2705 | } |
| 2706 | |
| 2707 | for (n = 0; n < nums; n++) { |
Takashi Iwai | 9bf387b | 2012-12-18 17:18:21 +0100 | [diff] [blame] | 2708 | bool multi = false; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2709 | int vol, sw; |
| 2710 | |
| 2711 | vol = sw = 0; |
| 2712 | for (i = 0; i < imux->num_items; i++) { |
| 2713 | struct nid_path *path; |
| 2714 | path = get_nid_path(codec, spec->imux_pins[i], |
| 2715 | get_adc_nid(codec, n, i)); |
| 2716 | if (!path) |
| 2717 | continue; |
| 2718 | parse_capvol_in_path(codec, path); |
| 2719 | if (!vol) |
| 2720 | vol = path->ctls[NID_PATH_VOL_CTL]; |
Takashi Iwai | 9bf387b | 2012-12-18 17:18:21 +0100 | [diff] [blame] | 2721 | else if (vol != path->ctls[NID_PATH_VOL_CTL]) |
| 2722 | multi = true; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2723 | if (!sw) |
| 2724 | sw = path->ctls[NID_PATH_MUTE_CTL]; |
Takashi Iwai | 9bf387b | 2012-12-18 17:18:21 +0100 | [diff] [blame] | 2725 | else if (sw != path->ctls[NID_PATH_MUTE_CTL]) |
| 2726 | multi = true; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2727 | } |
| 2728 | |
Takashi Iwai | 9bf387b | 2012-12-18 17:18:21 +0100 | [diff] [blame] | 2729 | if (!multi) |
| 2730 | err = create_single_cap_vol_ctl(codec, n, vol, sw); |
| 2731 | else if (!spec->multi_cap_vol) |
| 2732 | err = create_bind_cap_vol_ctl(codec, n, vol, sw); |
| 2733 | else |
| 2734 | err = create_multi_cap_vol_ctl(codec); |
| 2735 | if (err < 0) |
| 2736 | return err; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2737 | } |
| 2738 | |
| 2739 | return 0; |
| 2740 | } |
| 2741 | |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2742 | /* create playback/capture controls for input pins */ |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2743 | static int alc_auto_create_input_ctls(struct hda_codec *codec) |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2744 | { |
| 2745 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2746 | const struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2747 | hda_nid_t mixer = spec->mixer_nid; |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 2748 | struct hda_input_mux *imux = &spec->input_mux; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2749 | int num_adcs; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2750 | int i, c, err, type_idx = 0; |
David Henningsson | 5322bf2 | 2011-01-05 11:03:56 +0100 | [diff] [blame] | 2751 | const char *prev_label = NULL; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2752 | |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2753 | num_adcs = alc_auto_fill_adc_nids(codec); |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2754 | if (num_adcs < 0) |
| 2755 | return 0; |
| 2756 | |
Takashi Iwai | 81fede8 | 2012-12-18 17:24:25 +0100 | [diff] [blame^] | 2757 | spec->inv_dmic_split_idx = -1; |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2758 | for (i = 0; i < cfg->num_inputs; i++) { |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2759 | hda_nid_t pin; |
Takashi Iwai | 10a20af | 2010-09-09 16:28:02 +0200 | [diff] [blame] | 2760 | const char *label; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2761 | bool imux_added; |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2762 | |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2763 | pin = cfg->inputs[i].pin; |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2764 | if (!alc_is_input_pin(codec, pin)) |
| 2765 | continue; |
| 2766 | |
David Henningsson | 5322bf2 | 2011-01-05 11:03:56 +0100 | [diff] [blame] | 2767 | label = hda_get_autocfg_input_label(codec, cfg, i); |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 2768 | if (spec->shared_mic_hp && !strcmp(label, "Misc")) |
| 2769 | label = "Headphone Mic"; |
David Henningsson | 5322bf2 | 2011-01-05 11:03:56 +0100 | [diff] [blame] | 2770 | if (prev_label && !strcmp(label, prev_label)) |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2771 | type_idx++; |
| 2772 | else |
| 2773 | type_idx = 0; |
David Henningsson | 5322bf2 | 2011-01-05 11:03:56 +0100 | [diff] [blame] | 2774 | prev_label = label; |
| 2775 | |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2776 | if (mixer) { |
Takashi Iwai | c2fd19c | 2012-12-12 18:02:41 +0100 | [diff] [blame] | 2777 | if (is_reachable_path(codec, pin, mixer)) { |
| 2778 | err = new_analog_input(codec, pin, |
| 2779 | label, type_idx, mixer); |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2780 | if (err < 0) |
| 2781 | return err; |
| 2782 | } |
| 2783 | } |
| 2784 | |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2785 | imux_added = false; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2786 | for (c = 0; c < num_adcs; c++) { |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2787 | struct nid_path *path; |
| 2788 | hda_nid_t adc = spec->adc_nids[c]; |
| 2789 | |
| 2790 | if (!is_reachable_path(codec, pin, adc)) |
| 2791 | continue; |
| 2792 | path = snd_array_new(&spec->paths); |
| 2793 | if (!path) |
| 2794 | return -ENOMEM; |
| 2795 | memset(path, 0, sizeof(*path)); |
| 2796 | if (!parse_nid_path(codec, pin, adc, 2, path)) { |
| 2797 | snd_printd(KERN_ERR |
| 2798 | "invalid input path 0x%x -> 0x%x\n", |
| 2799 | pin, adc); |
| 2800 | spec->paths.used--; |
| 2801 | continue; |
| 2802 | } |
| 2803 | |
| 2804 | if (!imux_added) { |
| 2805 | spec->imux_pins[imux->num_items] = pin; |
| 2806 | snd_hda_add_imux_item(imux, label, |
| 2807 | imux->num_items, NULL); |
| 2808 | imux_added = true; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2809 | } |
| 2810 | } |
Takashi Iwai | 81fede8 | 2012-12-18 17:24:25 +0100 | [diff] [blame^] | 2811 | |
| 2812 | if (spec->inv_dmic_split) { |
| 2813 | if (cfg->inputs[i].type == AUTO_PIN_MIC) { |
| 2814 | unsigned int def_conf = snd_hda_codec_get_pincfg(codec, pin); |
| 2815 | if (snd_hda_get_input_pin_attr(def_conf) == INPUT_PIN_ATTR_INT) |
| 2816 | spec->inv_dmic_split_idx = i; |
| 2817 | } |
| 2818 | } |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2819 | } |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2820 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2821 | return 0; |
| 2822 | } |
| 2823 | |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 2824 | /* create a shared input with the headphone out */ |
| 2825 | static int alc_auto_create_shared_input(struct hda_codec *codec) |
| 2826 | { |
| 2827 | struct alc_spec *spec = codec->spec; |
| 2828 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2829 | unsigned int defcfg; |
| 2830 | hda_nid_t nid; |
| 2831 | |
| 2832 | /* only one internal input pin? */ |
| 2833 | if (cfg->num_inputs != 1) |
| 2834 | return 0; |
| 2835 | defcfg = snd_hda_codec_get_pincfg(codec, cfg->inputs[0].pin); |
| 2836 | if (snd_hda_get_input_pin_attr(defcfg) != INPUT_PIN_ATTR_INT) |
| 2837 | return 0; |
| 2838 | |
| 2839 | if (cfg->hp_outs == 1 && cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) |
| 2840 | nid = cfg->hp_pins[0]; /* OK, we have a single HP-out */ |
| 2841 | else if (cfg->line_outs == 1 && cfg->line_out_type == AUTO_PIN_HP_OUT) |
| 2842 | nid = cfg->line_out_pins[0]; /* OK, we have a single line-out */ |
| 2843 | else |
| 2844 | return 0; /* both not available */ |
| 2845 | |
| 2846 | if (!(snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_IN)) |
| 2847 | return 0; /* no input */ |
| 2848 | |
| 2849 | cfg->inputs[1].pin = nid; |
| 2850 | cfg->inputs[1].type = AUTO_PIN_MIC; |
| 2851 | cfg->num_inputs = 2; |
| 2852 | spec->shared_mic_hp = 1; |
| 2853 | snd_printdd("realtek: Enable shared I/O jack on NID 0x%x\n", nid); |
| 2854 | return 0; |
| 2855 | } |
| 2856 | |
Takashi Iwai | baba8ee | 2007-04-23 17:17:48 +0200 | [diff] [blame] | 2857 | static int get_pin_type(int line_out_type) |
| 2858 | { |
| 2859 | if (line_out_type == AUTO_PIN_HP_OUT) |
| 2860 | return PIN_HP; |
| 2861 | else |
| 2862 | return PIN_OUT; |
| 2863 | } |
| 2864 | |
Takashi Iwai | 0a7f532 | 2011-07-06 15:15:12 +0200 | [diff] [blame] | 2865 | static void alc_auto_init_analog_input(struct hda_codec *codec) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2866 | { |
| 2867 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2868 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2869 | int i; |
| 2870 | |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2871 | for (i = 0; i < cfg->num_inputs; i++) { |
| 2872 | hda_nid_t nid = cfg->inputs[i].pin; |
Takashi Iwai | 6234399 | 2012-12-18 09:06:01 +0100 | [diff] [blame] | 2873 | if (alc_is_input_pin(codec, nid)) |
Takashi Iwai | 30ea098 | 2010-09-16 18:47:56 +0200 | [diff] [blame] | 2874 | alc_set_input_pin(codec, nid, cfg->inputs[i].type); |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 2875 | |
Takashi Iwai | 829f69e | 2012-12-14 18:26:02 +0100 | [diff] [blame] | 2876 | /* mute loopback inputs */ |
| 2877 | if (spec->mixer_nid) { |
| 2878 | struct nid_path *path; |
| 2879 | path = get_nid_path(codec, nid, spec->mixer_nid); |
| 2880 | if (path) |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2881 | activate_path(codec, path, path->active, false); |
Takashi Iwai | 829f69e | 2012-12-14 18:26:02 +0100 | [diff] [blame] | 2882 | } |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 2883 | } |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2884 | } |
| 2885 | |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 2886 | static bool alc_is_dac_already_used(struct hda_codec *codec, hda_nid_t nid) |
| 2887 | { |
| 2888 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 2889 | int i; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2890 | |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 2891 | for (i = 0; i < spec->paths.used; i++) { |
| 2892 | struct nid_path *path = snd_array_elem(&spec->paths, i); |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2893 | if (path->path[0] == nid) |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 2894 | return true; |
| 2895 | } |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 2896 | return false; |
| 2897 | } |
| 2898 | |
Takashi Iwai | 463419d | 2012-12-05 14:17:37 +0100 | [diff] [blame] | 2899 | /* look for an empty DAC slot */ |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 2900 | static hda_nid_t alc_auto_look_for_dac(struct hda_codec *codec, hda_nid_t pin, |
| 2901 | bool is_digital) |
Takashi Iwai | 463419d | 2012-12-05 14:17:37 +0100 | [diff] [blame] | 2902 | { |
| 2903 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 2904 | bool cap_digital; |
Takashi Iwai | 463419d | 2012-12-05 14:17:37 +0100 | [diff] [blame] | 2905 | int i; |
| 2906 | |
| 2907 | for (i = 0; i < spec->num_all_dacs; i++) { |
| 2908 | hda_nid_t nid = spec->all_dacs[i]; |
| 2909 | if (!nid || alc_is_dac_already_used(codec, nid)) |
| 2910 | continue; |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 2911 | cap_digital = !!(get_wcaps(codec, nid) & AC_WCAP_DIGITAL); |
| 2912 | if (is_digital != cap_digital) |
| 2913 | continue; |
Takashi Iwai | 9c64076 | 2012-12-14 16:15:56 +0100 | [diff] [blame] | 2914 | if (is_reachable_path(codec, nid, pin)) |
Takashi Iwai | 463419d | 2012-12-05 14:17:37 +0100 | [diff] [blame] | 2915 | return nid; |
| 2916 | } |
| 2917 | return 0; |
| 2918 | } |
| 2919 | |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2920 | /* called recursively */ |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2921 | static bool __parse_nid_path(struct hda_codec *codec, |
| 2922 | hda_nid_t from_nid, hda_nid_t to_nid, |
| 2923 | int with_aa_mix, struct nid_path *path, int depth) |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2924 | { |
| 2925 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2926 | hda_nid_t conn[16]; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2927 | int i, nums; |
| 2928 | |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2929 | if (to_nid == spec->mixer_nid) { |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2930 | if (!with_aa_mix) |
| 2931 | return false; |
| 2932 | with_aa_mix = 2; /* mark aa-mix is included */ |
| 2933 | } |
| 2934 | |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2935 | nums = snd_hda_get_connections(codec, to_nid, conn, ARRAY_SIZE(conn)); |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2936 | for (i = 0; i < nums; i++) { |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2937 | if (conn[i] != from_nid) { |
| 2938 | /* special case: when from_nid is 0, |
| 2939 | * try to find an empty DAC |
| 2940 | */ |
| 2941 | if (from_nid || |
| 2942 | get_wcaps_type(get_wcaps(codec, conn[i])) != AC_WID_AUD_OUT || |
| 2943 | alc_is_dac_already_used(codec, conn[i])) |
| 2944 | continue; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2945 | } |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2946 | /* aa-mix is requested but not included? */ |
| 2947 | if (!(spec->mixer_nid && with_aa_mix == 1)) |
| 2948 | goto found; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2949 | } |
| 2950 | if (depth >= MAX_NID_PATH_DEPTH) |
| 2951 | return false; |
| 2952 | for (i = 0; i < nums; i++) { |
| 2953 | unsigned int type; |
| 2954 | type = get_wcaps_type(get_wcaps(codec, conn[i])); |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2955 | if (type == AC_WID_AUD_OUT || type == AC_WID_AUD_IN || |
| 2956 | type == AC_WID_PIN) |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2957 | continue; |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2958 | if (__parse_nid_path(codec, from_nid, conn[i], |
| 2959 | with_aa_mix, path, depth + 1)) |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2960 | goto found; |
| 2961 | } |
| 2962 | return false; |
| 2963 | |
| 2964 | found: |
| 2965 | path->path[path->depth] = conn[i]; |
Takashi Iwai | 95e960c | 2012-12-10 17:27:57 +0100 | [diff] [blame] | 2966 | path->idx[path->depth + 1] = i; |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2967 | 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] | 2968 | path->multi[path->depth + 1] = 1; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2969 | path->depth++; |
| 2970 | return true; |
| 2971 | } |
| 2972 | |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2973 | /* parse the widget path from the given nid to the target nid; |
| 2974 | * when @from_nid is 0, try to find an empty DAC; |
| 2975 | * when @with_aa_mix is 0, paths with spec->mixer_nid are excluded. |
| 2976 | * when @with_aa_mix is 1, paths without spec->mixer_nid are excluded. |
| 2977 | * 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] | 2978 | */ |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2979 | static bool parse_nid_path(struct hda_codec *codec, hda_nid_t from_nid, |
| 2980 | hda_nid_t to_nid, int with_aa_mix, |
| 2981 | struct nid_path *path) |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2982 | { |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2983 | if (__parse_nid_path(codec, from_nid, to_nid, with_aa_mix, path, 1)) { |
| 2984 | path->path[path->depth] = to_nid; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2985 | path->depth++; |
| 2986 | #if 0 |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2987 | snd_printdd("path: depth=%d, %02x/%02x/%02x/%02x/%02x\n", |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2988 | path->depth, path->path[0], path->path[1], |
| 2989 | path->path[2], path->path[3], path->path[4]); |
| 2990 | #endif |
| 2991 | return true; |
| 2992 | } |
| 2993 | return false; |
| 2994 | } |
| 2995 | |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 2996 | static hda_nid_t get_dac_if_single(struct hda_codec *codec, hda_nid_t pin) |
| 2997 | { |
Takashi Iwai | 140547e | 2012-02-16 17:23:46 +0100 | [diff] [blame] | 2998 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 463419d | 2012-12-05 14:17:37 +0100 | [diff] [blame] | 2999 | int i; |
| 3000 | hda_nid_t nid_found = 0; |
| 3001 | |
| 3002 | for (i = 0; i < spec->num_all_dacs; i++) { |
| 3003 | hda_nid_t nid = spec->all_dacs[i]; |
| 3004 | if (!nid || alc_is_dac_already_used(codec, nid)) |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3005 | continue; |
Takashi Iwai | 9c64076 | 2012-12-14 16:15:56 +0100 | [diff] [blame] | 3006 | if (is_reachable_path(codec, nid, pin)) { |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3007 | if (nid_found) |
| 3008 | return 0; |
| 3009 | nid_found = nid; |
| 3010 | } |
| 3011 | } |
| 3012 | return nid_found; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3013 | } |
| 3014 | |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3015 | 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] | 3016 | { |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3017 | struct alc_spec *spec = codec->spec; |
| 3018 | int i; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3019 | |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 3020 | for (i = 0; i < spec->paths.used; i++) { |
| 3021 | struct nid_path *path = snd_array_elem(&spec->paths, i); |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3022 | if (path->ctls[type] == val) |
| 3023 | return true; |
| 3024 | } |
| 3025 | return false; |
| 3026 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3027 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3028 | /* badness definition */ |
| 3029 | enum { |
| 3030 | /* No primary DAC is found for the main output */ |
| 3031 | BAD_NO_PRIMARY_DAC = 0x10000, |
| 3032 | /* No DAC is found for the extra output */ |
| 3033 | BAD_NO_DAC = 0x4000, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3034 | /* No possible multi-ios */ |
| 3035 | BAD_MULTI_IO = 0x103, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3036 | /* No individual DAC for extra output */ |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3037 | BAD_NO_EXTRA_DAC = 0x102, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3038 | /* No individual DAC for extra surrounds */ |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3039 | BAD_NO_EXTRA_SURR_DAC = 0x101, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3040 | /* Primary DAC shared with main surrounds */ |
| 3041 | BAD_SHARED_SURROUND = 0x100, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3042 | /* Primary DAC shared with main CLFE */ |
| 3043 | BAD_SHARED_CLFE = 0x10, |
| 3044 | /* Primary DAC shared with extra surrounds */ |
| 3045 | BAD_SHARED_EXTRA_SURROUND = 0x10, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3046 | /* Volume widget is shared */ |
| 3047 | BAD_SHARED_VOL = 0x10, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3048 | }; |
| 3049 | |
| 3050 | 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] | 3051 | struct nid_path *path); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3052 | 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] | 3053 | struct nid_path *path); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3054 | |
Takashi Iwai | 965cceb | 2012-12-18 11:46:37 +0100 | [diff] [blame] | 3055 | static struct nid_path *add_new_nid_path(struct hda_codec *codec, |
| 3056 | hda_nid_t from_nid, hda_nid_t to_nid, |
| 3057 | int with_aa_mix) |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 3058 | { |
| 3059 | struct alc_spec *spec = codec->spec; |
| 3060 | struct nid_path *path; |
| 3061 | |
Takashi Iwai | 965cceb | 2012-12-18 11:46:37 +0100 | [diff] [blame] | 3062 | if (from_nid && to_nid && !is_reachable_path(codec, from_nid, to_nid)) |
| 3063 | return NULL; |
| 3064 | |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 3065 | path = snd_array_new(&spec->paths); |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 3066 | if (!path) |
Takashi Iwai | 965cceb | 2012-12-18 11:46:37 +0100 | [diff] [blame] | 3067 | return NULL; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 3068 | memset(path, 0, sizeof(*path)); |
Takashi Iwai | 965cceb | 2012-12-18 11:46:37 +0100 | [diff] [blame] | 3069 | if (parse_nid_path(codec, from_nid, to_nid, with_aa_mix, path)) |
| 3070 | return path; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 3071 | /* push back */ |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 3072 | spec->paths.used--; |
Takashi Iwai | 965cceb | 2012-12-18 11:46:37 +0100 | [diff] [blame] | 3073 | return NULL; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 3074 | } |
| 3075 | |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame] | 3076 | /* get the path between the given NIDs; |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3077 | * passing 0 to either @pin or @dac behaves as a wildcard |
| 3078 | */ |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame] | 3079 | static struct nid_path * |
| 3080 | 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] | 3081 | { |
| 3082 | struct alc_spec *spec = codec->spec; |
| 3083 | int i; |
| 3084 | |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 3085 | for (i = 0; i < spec->paths.used; i++) { |
| 3086 | struct nid_path *path = snd_array_elem(&spec->paths, i); |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3087 | if (path->depth <= 0) |
| 3088 | continue; |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame] | 3089 | if ((!from_nid || path->path[0] == from_nid) && |
| 3090 | (!to_nid || path->path[path->depth - 1] == to_nid)) |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3091 | return path; |
| 3092 | } |
| 3093 | return NULL; |
| 3094 | } |
| 3095 | |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3096 | /* look for widgets in the path between the given NIDs appropriate for |
| 3097 | * volume and mute controls, and assign the values to ctls[]. |
| 3098 | * |
| 3099 | * When no appropriate widget is found in the path, the badness value |
| 3100 | * is incremented depending on the situation. The function returns the |
| 3101 | * total badness for both volume and mute controls. |
| 3102 | */ |
| 3103 | static int assign_out_path_ctls(struct hda_codec *codec, hda_nid_t pin, |
| 3104 | hda_nid_t dac) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3105 | { |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame] | 3106 | struct nid_path *path = get_nid_path(codec, dac, pin); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3107 | hda_nid_t nid; |
| 3108 | unsigned int val; |
| 3109 | int badness = 0; |
| 3110 | |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3111 | if (!path) |
| 3112 | return BAD_SHARED_VOL * 2; |
| 3113 | nid = alc_look_for_out_vol_nid(codec, path); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3114 | if (nid) { |
| 3115 | val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3116 | if (is_ctl_used(codec, val, NID_PATH_VOL_CTL)) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3117 | badness += BAD_SHARED_VOL; |
| 3118 | else |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3119 | path->ctls[NID_PATH_VOL_CTL] = val; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3120 | } else |
| 3121 | badness += BAD_SHARED_VOL; |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3122 | nid = alc_look_for_out_mute_nid(codec, path); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3123 | if (nid) { |
| 3124 | unsigned int wid_type = get_wcaps_type(get_wcaps(codec, nid)); |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3125 | if (wid_type == AC_WID_PIN || wid_type == AC_WID_AUD_OUT || |
| 3126 | nid_has_mute(codec, nid, HDA_OUTPUT)) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3127 | val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); |
| 3128 | else |
| 3129 | val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT); |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3130 | if (is_ctl_used(codec, val, NID_PATH_MUTE_CTL)) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3131 | badness += BAD_SHARED_VOL; |
| 3132 | else |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3133 | path->ctls[NID_PATH_MUTE_CTL] = val; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3134 | } else |
| 3135 | badness += BAD_SHARED_VOL; |
| 3136 | return badness; |
| 3137 | } |
| 3138 | |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3139 | struct badness_table { |
| 3140 | int no_primary_dac; /* no primary DAC */ |
| 3141 | int no_dac; /* no secondary DACs */ |
| 3142 | int shared_primary; /* primary DAC is shared with main output */ |
| 3143 | int shared_surr; /* secondary DAC shared with main or primary */ |
| 3144 | int shared_clfe; /* third DAC shared with main or primary */ |
| 3145 | int shared_surr_main; /* secondary DAC sahred with main/DAC0 */ |
| 3146 | }; |
| 3147 | |
| 3148 | static struct badness_table main_out_badness = { |
| 3149 | .no_primary_dac = BAD_NO_PRIMARY_DAC, |
| 3150 | .no_dac = BAD_NO_DAC, |
| 3151 | .shared_primary = BAD_NO_PRIMARY_DAC, |
| 3152 | .shared_surr = BAD_SHARED_SURROUND, |
| 3153 | .shared_clfe = BAD_SHARED_CLFE, |
| 3154 | .shared_surr_main = BAD_SHARED_SURROUND, |
| 3155 | }; |
| 3156 | |
| 3157 | static struct badness_table extra_out_badness = { |
| 3158 | .no_primary_dac = BAD_NO_DAC, |
| 3159 | .no_dac = BAD_NO_DAC, |
| 3160 | .shared_primary = BAD_NO_EXTRA_DAC, |
| 3161 | .shared_surr = BAD_SHARED_EXTRA_SURROUND, |
| 3162 | .shared_clfe = BAD_SHARED_EXTRA_SURROUND, |
| 3163 | .shared_surr_main = BAD_NO_EXTRA_SURR_DAC, |
| 3164 | }; |
| 3165 | |
| 3166 | /* try to assign DACs to pins and return the resultant badness */ |
| 3167 | static int alc_auto_fill_dacs(struct hda_codec *codec, int num_outs, |
| 3168 | const hda_nid_t *pins, hda_nid_t *dacs, |
| 3169 | const struct badness_table *bad) |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3170 | { |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3171 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3172 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 3173 | int i, j; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3174 | int badness = 0; |
| 3175 | hda_nid_t dac; |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3176 | |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3177 | if (!num_outs) |
| 3178 | return 0; |
| 3179 | |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3180 | for (i = 0; i < num_outs; i++) { |
| 3181 | hda_nid_t pin = pins[i]; |
| 3182 | if (!dacs[i]) |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 3183 | dacs[i] = alc_auto_look_for_dac(codec, pin, false); |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3184 | if (!dacs[i] && !i) { |
| 3185 | for (j = 1; j < num_outs; j++) { |
Takashi Iwai | 9c64076 | 2012-12-14 16:15:56 +0100 | [diff] [blame] | 3186 | if (is_reachable_path(codec, dacs[j], pin)) { |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3187 | dacs[0] = dacs[j]; |
| 3188 | dacs[j] = 0; |
| 3189 | break; |
| 3190 | } |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3191 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3192 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3193 | dac = dacs[i]; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3194 | if (!dac) { |
Takashi Iwai | 9c64076 | 2012-12-14 16:15:56 +0100 | [diff] [blame] | 3195 | if (is_reachable_path(codec, dacs[0], pin)) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3196 | dac = dacs[0]; |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3197 | else if (cfg->line_outs > i && |
Takashi Iwai | 9c64076 | 2012-12-14 16:15:56 +0100 | [diff] [blame] | 3198 | is_reachable_path(codec, spec->private_dac_nids[i], pin)) |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3199 | dac = spec->private_dac_nids[i]; |
| 3200 | if (dac) { |
| 3201 | if (!i) |
| 3202 | badness += bad->shared_primary; |
| 3203 | else if (i == 1) |
| 3204 | badness += bad->shared_surr; |
| 3205 | else |
| 3206 | badness += bad->shared_clfe; |
Takashi Iwai | 9c64076 | 2012-12-14 16:15:56 +0100 | [diff] [blame] | 3207 | } else if (is_reachable_path(codec, spec->private_dac_nids[0], pin)) { |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3208 | dac = spec->private_dac_nids[0]; |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3209 | badness += bad->shared_surr_main; |
| 3210 | } else if (!i) |
| 3211 | badness += bad->no_primary_dac; |
| 3212 | else |
| 3213 | badness += bad->no_dac; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3214 | } |
Takashi Iwai | 965cceb | 2012-12-18 11:46:37 +0100 | [diff] [blame] | 3215 | if (!add_new_nid_path(codec, dac, pin, 0)) |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 3216 | dac = dacs[i] = 0; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3217 | if (dac) |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3218 | badness += assign_out_path_ctls(codec, pin, dac); |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3219 | } |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3220 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3221 | return badness; |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3222 | } |
| 3223 | |
| 3224 | static int alc_auto_fill_multi_ios(struct hda_codec *codec, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3225 | hda_nid_t reference_pin, |
| 3226 | bool hardwired, int offset); |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3227 | |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3228 | static bool alc_map_singles(struct hda_codec *codec, int outs, |
| 3229 | const hda_nid_t *pins, hda_nid_t *dacs) |
| 3230 | { |
| 3231 | int i; |
| 3232 | bool found = false; |
| 3233 | for (i = 0; i < outs; i++) { |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 3234 | hda_nid_t dac; |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3235 | if (dacs[i]) |
| 3236 | continue; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 3237 | dac = get_dac_if_single(codec, pins[i]); |
| 3238 | if (!dac) |
| 3239 | continue; |
Takashi Iwai | 965cceb | 2012-12-18 11:46:37 +0100 | [diff] [blame] | 3240 | if (add_new_nid_path(codec, dac, pins[i], 0)) { |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 3241 | dacs[i] = dac; |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3242 | found = true; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 3243 | } |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3244 | } |
| 3245 | return found; |
| 3246 | } |
| 3247 | |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3248 | /* fill in the dac_nids table from the parsed pin configuration */ |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3249 | static int fill_and_eval_dacs(struct hda_codec *codec, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3250 | bool fill_hardwired, |
| 3251 | bool fill_mio_first) |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3252 | { |
| 3253 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3254 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3255 | int i, err, badness; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3256 | |
Takashi Iwai | 8f398ae | 2011-07-23 18:57:11 +0200 | [diff] [blame] | 3257 | /* set num_dacs once to full for alc_auto_look_for_dac() */ |
| 3258 | spec->multiout.num_dacs = cfg->line_outs; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3259 | spec->multiout.dac_nids = spec->private_dac_nids; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3260 | memset(spec->private_dac_nids, 0, sizeof(spec->private_dac_nids)); |
| 3261 | memset(spec->multiout.hp_out_nid, 0, sizeof(spec->multiout.hp_out_nid)); |
| 3262 | 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] | 3263 | spec->multi_ios = 0; |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 3264 | snd_array_free(&spec->paths); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3265 | badness = 0; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3266 | |
| 3267 | /* fill hard-wired DACs first */ |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3268 | if (fill_hardwired) { |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3269 | bool mapped; |
| 3270 | do { |
| 3271 | mapped = alc_map_singles(codec, cfg->line_outs, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3272 | cfg->line_out_pins, |
| 3273 | spec->private_dac_nids); |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3274 | mapped |= alc_map_singles(codec, cfg->hp_outs, |
| 3275 | cfg->hp_pins, |
| 3276 | spec->multiout.hp_out_nid); |
| 3277 | mapped |= alc_map_singles(codec, cfg->speaker_outs, |
| 3278 | cfg->speaker_pins, |
| 3279 | spec->multiout.extra_out_nid); |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3280 | if (fill_mio_first && cfg->line_outs == 1 && |
| 3281 | cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { |
| 3282 | err = alc_auto_fill_multi_ios(codec, cfg->line_out_pins[0], true, 0); |
| 3283 | if (!err) |
| 3284 | mapped = true; |
| 3285 | } |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3286 | } while (mapped); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3287 | } |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3288 | |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3289 | badness += alc_auto_fill_dacs(codec, cfg->line_outs, cfg->line_out_pins, |
| 3290 | spec->private_dac_nids, |
| 3291 | &main_out_badness); |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3292 | |
Takashi Iwai | 8f398ae | 2011-07-23 18:57:11 +0200 | [diff] [blame] | 3293 | /* re-count num_dacs and squash invalid entries */ |
| 3294 | spec->multiout.num_dacs = 0; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3295 | for (i = 0; i < cfg->line_outs; i++) { |
| 3296 | if (spec->private_dac_nids[i]) |
| 3297 | spec->multiout.num_dacs++; |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3298 | else { |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3299 | memmove(spec->private_dac_nids + i, |
| 3300 | spec->private_dac_nids + i + 1, |
| 3301 | sizeof(hda_nid_t) * (cfg->line_outs - i - 1)); |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3302 | spec->private_dac_nids[cfg->line_outs - 1] = 0; |
| 3303 | } |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3304 | } |
| 3305 | |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3306 | if (fill_mio_first && |
| 3307 | cfg->line_outs == 1 && cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3308 | /* try to fill multi-io first */ |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3309 | 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] | 3310 | if (err < 0) |
| 3311 | return err; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3312 | /* we don't count badness at this stage yet */ |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3313 | } |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3314 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3315 | if (cfg->line_out_type != AUTO_PIN_HP_OUT) { |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3316 | err = alc_auto_fill_dacs(codec, cfg->hp_outs, cfg->hp_pins, |
| 3317 | spec->multiout.hp_out_nid, |
| 3318 | &extra_out_badness); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3319 | if (err < 0) |
| 3320 | return err; |
| 3321 | badness += err; |
| 3322 | } |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3323 | if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3324 | err = alc_auto_fill_dacs(codec, cfg->speaker_outs, |
| 3325 | cfg->speaker_pins, |
| 3326 | spec->multiout.extra_out_nid, |
| 3327 | &extra_out_badness); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3328 | if (err < 0) |
| 3329 | return err; |
| 3330 | badness += err; |
| 3331 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3332 | if (cfg->line_outs == 1 && cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { |
| 3333 | 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] | 3334 | if (err < 0) |
| 3335 | return err; |
| 3336 | badness += err; |
| 3337 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3338 | if (cfg->hp_outs && cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) { |
| 3339 | /* try multi-ios with HP + inputs */ |
Takashi Iwai | f568291 | 2012-02-21 12:37:00 +0100 | [diff] [blame] | 3340 | int offset = 0; |
| 3341 | if (cfg->line_outs >= 3) |
| 3342 | offset = 1; |
| 3343 | err = alc_auto_fill_multi_ios(codec, cfg->hp_pins[0], false, |
| 3344 | offset); |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3345 | if (err < 0) |
| 3346 | return err; |
| 3347 | badness += err; |
| 3348 | } |
| 3349 | |
| 3350 | if (spec->multi_ios == 2) { |
| 3351 | for (i = 0; i < 2; i++) |
| 3352 | spec->private_dac_nids[spec->multiout.num_dacs++] = |
| 3353 | spec->multi_io[i].dac; |
| 3354 | spec->ext_channel_count = 2; |
| 3355 | } else if (spec->multi_ios) { |
| 3356 | spec->multi_ios = 0; |
| 3357 | badness += BAD_MULTI_IO; |
| 3358 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3359 | |
| 3360 | return badness; |
| 3361 | } |
| 3362 | |
| 3363 | #define DEBUG_BADNESS |
| 3364 | |
| 3365 | #ifdef DEBUG_BADNESS |
| 3366 | #define debug_badness snd_printdd |
| 3367 | #else |
| 3368 | #define debug_badness(...) |
| 3369 | #endif |
| 3370 | |
| 3371 | static void debug_show_configs(struct alc_spec *spec, struct auto_pin_cfg *cfg) |
| 3372 | { |
| 3373 | debug_badness("multi_outs = %x/%x/%x/%x : %x/%x/%x/%x\n", |
| 3374 | cfg->line_out_pins[0], cfg->line_out_pins[1], |
| 3375 | cfg->line_out_pins[2], cfg->line_out_pins[2], |
| 3376 | spec->multiout.dac_nids[0], |
| 3377 | spec->multiout.dac_nids[1], |
| 3378 | spec->multiout.dac_nids[2], |
| 3379 | spec->multiout.dac_nids[3]); |
Takashi Iwai | 6f45304 | 2012-02-17 14:09:20 +0100 | [diff] [blame] | 3380 | if (spec->multi_ios > 0) |
| 3381 | debug_badness("multi_ios(%d) = %x/%x : %x/%x\n", |
| 3382 | spec->multi_ios, |
| 3383 | spec->multi_io[0].pin, spec->multi_io[1].pin, |
| 3384 | spec->multi_io[0].dac, spec->multi_io[1].dac); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3385 | debug_badness("hp_outs = %x/%x/%x/%x : %x/%x/%x/%x\n", |
| 3386 | cfg->hp_pins[0], cfg->hp_pins[1], |
| 3387 | cfg->hp_pins[2], cfg->hp_pins[2], |
| 3388 | spec->multiout.hp_out_nid[0], |
| 3389 | spec->multiout.hp_out_nid[1], |
| 3390 | spec->multiout.hp_out_nid[2], |
| 3391 | spec->multiout.hp_out_nid[3]); |
| 3392 | debug_badness("spk_outs = %x/%x/%x/%x : %x/%x/%x/%x\n", |
| 3393 | cfg->speaker_pins[0], cfg->speaker_pins[1], |
| 3394 | cfg->speaker_pins[2], cfg->speaker_pins[3], |
| 3395 | spec->multiout.extra_out_nid[0], |
| 3396 | spec->multiout.extra_out_nid[1], |
| 3397 | spec->multiout.extra_out_nid[2], |
| 3398 | spec->multiout.extra_out_nid[3]); |
| 3399 | } |
| 3400 | |
Takashi Iwai | 463419d | 2012-12-05 14:17:37 +0100 | [diff] [blame] | 3401 | /* find all available DACs of the codec */ |
| 3402 | static void alc_fill_all_nids(struct hda_codec *codec) |
| 3403 | { |
| 3404 | struct alc_spec *spec = codec->spec; |
| 3405 | int i; |
| 3406 | hda_nid_t nid = codec->start_nid; |
| 3407 | |
| 3408 | spec->num_all_dacs = 0; |
| 3409 | memset(spec->all_dacs, 0, sizeof(spec->all_dacs)); |
| 3410 | for (i = 0; i < codec->num_nodes; i++, nid++) { |
| 3411 | if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_AUD_OUT) |
| 3412 | continue; |
| 3413 | if (spec->num_all_dacs >= ARRAY_SIZE(spec->all_dacs)) { |
| 3414 | snd_printk(KERN_ERR "hda: Too many DACs!\n"); |
| 3415 | break; |
| 3416 | } |
| 3417 | spec->all_dacs[spec->num_all_dacs++] = nid; |
| 3418 | } |
| 3419 | } |
| 3420 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3421 | static int alc_auto_fill_dac_nids(struct hda_codec *codec) |
| 3422 | { |
| 3423 | struct alc_spec *spec = codec->spec; |
| 3424 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 3425 | struct auto_pin_cfg *best_cfg; |
| 3426 | int best_badness = INT_MAX; |
| 3427 | int badness; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3428 | bool fill_hardwired = true, fill_mio_first = true; |
| 3429 | bool best_wired = true, best_mio = true; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3430 | bool hp_spk_swapped = false; |
| 3431 | |
Takashi Iwai | 463419d | 2012-12-05 14:17:37 +0100 | [diff] [blame] | 3432 | alc_fill_all_nids(codec); |
| 3433 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3434 | best_cfg = kmalloc(sizeof(*best_cfg), GFP_KERNEL); |
| 3435 | if (!best_cfg) |
| 3436 | return -ENOMEM; |
| 3437 | *best_cfg = *cfg; |
| 3438 | |
| 3439 | for (;;) { |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3440 | badness = fill_and_eval_dacs(codec, fill_hardwired, |
| 3441 | fill_mio_first); |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 3442 | if (badness < 0) { |
| 3443 | kfree(best_cfg); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3444 | return badness; |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 3445 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3446 | debug_badness("==> lo_type=%d, wired=%d, mio=%d, badness=0x%x\n", |
| 3447 | cfg->line_out_type, fill_hardwired, fill_mio_first, |
| 3448 | badness); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3449 | debug_show_configs(spec, cfg); |
| 3450 | if (badness < best_badness) { |
| 3451 | best_badness = badness; |
| 3452 | *best_cfg = *cfg; |
| 3453 | best_wired = fill_hardwired; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3454 | best_mio = fill_mio_first; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3455 | } |
| 3456 | if (!badness) |
| 3457 | break; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3458 | fill_mio_first = !fill_mio_first; |
| 3459 | if (!fill_mio_first) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3460 | continue; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3461 | fill_hardwired = !fill_hardwired; |
| 3462 | if (!fill_hardwired) |
| 3463 | continue; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3464 | if (hp_spk_swapped) |
| 3465 | break; |
| 3466 | hp_spk_swapped = true; |
| 3467 | if (cfg->speaker_outs > 0 && |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3468 | cfg->line_out_type == AUTO_PIN_HP_OUT) { |
| 3469 | cfg->hp_outs = cfg->line_outs; |
| 3470 | memcpy(cfg->hp_pins, cfg->line_out_pins, |
| 3471 | sizeof(cfg->hp_pins)); |
| 3472 | cfg->line_outs = cfg->speaker_outs; |
| 3473 | memcpy(cfg->line_out_pins, cfg->speaker_pins, |
| 3474 | sizeof(cfg->speaker_pins)); |
| 3475 | cfg->speaker_outs = 0; |
| 3476 | memset(cfg->speaker_pins, 0, sizeof(cfg->speaker_pins)); |
| 3477 | cfg->line_out_type = AUTO_PIN_SPEAKER_OUT; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3478 | fill_hardwired = true; |
| 3479 | continue; |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 3480 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3481 | if (cfg->hp_outs > 0 && |
| 3482 | cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) { |
| 3483 | cfg->speaker_outs = cfg->line_outs; |
| 3484 | memcpy(cfg->speaker_pins, cfg->line_out_pins, |
| 3485 | sizeof(cfg->speaker_pins)); |
| 3486 | cfg->line_outs = cfg->hp_outs; |
| 3487 | memcpy(cfg->line_out_pins, cfg->hp_pins, |
| 3488 | sizeof(cfg->hp_pins)); |
| 3489 | cfg->hp_outs = 0; |
| 3490 | memset(cfg->hp_pins, 0, sizeof(cfg->hp_pins)); |
| 3491 | cfg->line_out_type = AUTO_PIN_HP_OUT; |
| 3492 | fill_hardwired = true; |
| 3493 | continue; |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 3494 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3495 | break; |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3496 | } |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3497 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3498 | if (badness) { |
| 3499 | *cfg = *best_cfg; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3500 | fill_and_eval_dacs(codec, best_wired, best_mio); |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 3501 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3502 | debug_badness("==> Best config: lo_type=%d, wired=%d, mio=%d\n", |
| 3503 | cfg->line_out_type, best_wired, best_mio); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3504 | debug_show_configs(spec, cfg); |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 3505 | |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3506 | if (cfg->line_out_pins[0]) { |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame] | 3507 | struct nid_path *path = get_nid_path(codec, |
| 3508 | spec->multiout.dac_nids[0], |
| 3509 | cfg->line_out_pins[0]); |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3510 | if (path) |
| 3511 | spec->vmaster_nid = alc_look_for_out_vol_nid(codec, path); |
| 3512 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3513 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3514 | kfree(best_cfg); |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3515 | return 0; |
| 3516 | } |
| 3517 | |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3518 | /* replace the channels in the composed amp value with the given number */ |
| 3519 | static unsigned int amp_val_replace_channels(unsigned int val, unsigned int chs) |
| 3520 | { |
| 3521 | val &= ~(0x3U << 16); |
| 3522 | val |= chs << 16; |
| 3523 | return val; |
| 3524 | } |
| 3525 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3526 | static int alc_auto_add_vol_ctl(struct hda_codec *codec, |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3527 | const char *pfx, int cidx, |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3528 | unsigned int chs, |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3529 | struct nid_path *path) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3530 | { |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3531 | unsigned int val; |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3532 | if (!path) |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3533 | return 0; |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3534 | val = path->ctls[NID_PATH_VOL_CTL]; |
| 3535 | if (!val) |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3536 | return 0; |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3537 | val = amp_val_replace_channels(val, chs); |
| 3538 | return __add_pb_vol_ctrl(codec->spec, ALC_CTL_WIDGET_VOL, pfx, cidx, val); |
| 3539 | } |
| 3540 | |
| 3541 | /* return the channel bits suitable for the given path->ctls[] */ |
| 3542 | static int get_default_ch_nums(struct hda_codec *codec, struct nid_path *path, |
| 3543 | int type) |
| 3544 | { |
| 3545 | int chs = 1; /* mono (left only) */ |
| 3546 | if (path) { |
| 3547 | hda_nid_t nid = get_amp_nid_(path->ctls[type]); |
| 3548 | if (nid && (get_wcaps(codec, nid) & AC_WCAP_STEREO)) |
| 3549 | chs = 3; /* stereo */ |
| 3550 | } |
| 3551 | return chs; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3552 | } |
| 3553 | |
Takashi Iwai | e29d377 | 2011-11-14 17:13:23 +0100 | [diff] [blame] | 3554 | static int alc_auto_add_stereo_vol(struct hda_codec *codec, |
| 3555 | const char *pfx, int cidx, |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3556 | struct nid_path *path) |
Takashi Iwai | e29d377 | 2011-11-14 17:13:23 +0100 | [diff] [blame] | 3557 | { |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3558 | int chs = get_default_ch_nums(codec, path, NID_PATH_VOL_CTL); |
| 3559 | return alc_auto_add_vol_ctl(codec, pfx, cidx, chs, path); |
Takashi Iwai | e29d377 | 2011-11-14 17:13:23 +0100 | [diff] [blame] | 3560 | } |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3561 | |
| 3562 | /* create a mute-switch for the given mixer widget; |
| 3563 | * if it has multiple sources (e.g. DAC and loopback), create a bind-mute |
| 3564 | */ |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3565 | static int alc_auto_add_sw_ctl(struct hda_codec *codec, |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3566 | const char *pfx, int cidx, |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3567 | unsigned int chs, |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3568 | struct nid_path *path) |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3569 | { |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3570 | unsigned int val; |
| 3571 | int type = ALC_CTL_WIDGET_MUTE; |
| 3572 | |
| 3573 | if (!path) |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3574 | return 0; |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3575 | val = path->ctls[NID_PATH_MUTE_CTL]; |
| 3576 | if (!val) |
| 3577 | return 0; |
| 3578 | val = amp_val_replace_channels(val, chs); |
| 3579 | if (get_amp_direction_(val) == HDA_INPUT) { |
| 3580 | hda_nid_t nid = get_amp_nid_(val); |
Takashi Iwai | 9366ede | 2012-12-13 16:43:52 +0100 | [diff] [blame] | 3581 | int nums = snd_hda_get_num_conns(codec, nid); |
| 3582 | if (nums > 1) { |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3583 | type = ALC_CTL_BIND_MUTE; |
Takashi Iwai | 9366ede | 2012-12-13 16:43:52 +0100 | [diff] [blame] | 3584 | val |= nums << 19; |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3585 | } |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3586 | } |
| 3587 | return __add_pb_sw_ctrl(codec->spec, type, pfx, cidx, val); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3588 | } |
| 3589 | |
Takashi Iwai | e29d377 | 2011-11-14 17:13:23 +0100 | [diff] [blame] | 3590 | 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] | 3591 | int cidx, struct nid_path *path) |
Takashi Iwai | e29d377 | 2011-11-14 17:13:23 +0100 | [diff] [blame] | 3592 | { |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3593 | int chs = get_default_ch_nums(codec, path, NID_PATH_MUTE_CTL); |
| 3594 | return alc_auto_add_sw_ctl(codec, pfx, cidx, chs, path); |
Takashi Iwai | e29d377 | 2011-11-14 17:13:23 +0100 | [diff] [blame] | 3595 | } |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3596 | |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3597 | 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] | 3598 | struct nid_path *path) |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3599 | { |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3600 | int i; |
| 3601 | |
| 3602 | for (i = path->depth - 1; i >= 0; i--) { |
| 3603 | if (nid_has_mute(codec, path->path[i], HDA_OUTPUT)) |
| 3604 | return path->path[i]; |
| 3605 | if (i != path->depth - 1 && i != 0 && |
| 3606 | nid_has_mute(codec, path->path[i], HDA_INPUT)) |
| 3607 | return path->path[i]; |
| 3608 | } |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3609 | return 0; |
| 3610 | } |
| 3611 | |
| 3612 | 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] | 3613 | struct nid_path *path) |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3614 | { |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3615 | int i; |
| 3616 | |
| 3617 | for (i = path->depth - 1; i >= 0; i--) { |
| 3618 | if (nid_has_volume(codec, path->path[i], HDA_OUTPUT)) |
| 3619 | return path->path[i]; |
| 3620 | } |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3621 | return 0; |
| 3622 | } |
| 3623 | |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3624 | /* add playback controls from the parsed DAC table */ |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3625 | static int alc_auto_create_multi_out_ctls(struct hda_codec *codec, |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3626 | const struct auto_pin_cfg *cfg) |
| 3627 | { |
| 3628 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3629 | int i, err, noutputs; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3630 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3631 | noutputs = cfg->line_outs; |
Takashi Iwai | b90bf1d | 2012-01-19 11:42:55 +0100 | [diff] [blame] | 3632 | if (spec->multi_ios > 0 && cfg->line_outs < 3) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3633 | noutputs += spec->multi_ios; |
| 3634 | |
| 3635 | for (i = 0; i < noutputs; i++) { |
Takashi Iwai | 6843ca1 | 2011-06-24 11:03:58 +0200 | [diff] [blame] | 3636 | const char *name; |
| 3637 | int index; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3638 | hda_nid_t dac, pin; |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3639 | struct nid_path *path; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3640 | |
| 3641 | dac = spec->multiout.dac_nids[i]; |
| 3642 | if (!dac) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3643 | continue; |
Takashi Iwai | 689cabf | 2012-02-21 12:35:27 +0100 | [diff] [blame] | 3644 | if (i >= cfg->line_outs) { |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3645 | pin = spec->multi_io[i - 1].pin; |
Takashi Iwai | 689cabf | 2012-02-21 12:35:27 +0100 | [diff] [blame] | 3646 | index = 0; |
| 3647 | name = channel_name[i]; |
| 3648 | } else { |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3649 | pin = cfg->line_out_pins[i]; |
Takashi Iwai | 689cabf | 2012-02-21 12:35:27 +0100 | [diff] [blame] | 3650 | name = alc_get_line_out_pfx(spec, i, true, &index); |
| 3651 | } |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3652 | |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame] | 3653 | path = get_nid_path(codec, dac, pin); |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3654 | if (!path) |
| 3655 | continue; |
Takashi Iwai | 9c4e84d | 2011-08-24 17:27:52 +0200 | [diff] [blame] | 3656 | if (!name || !strcmp(name, "CLFE")) { |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3657 | /* Center/LFE */ |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3658 | err = alc_auto_add_vol_ctl(codec, "Center", 0, 1, path); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3659 | if (err < 0) |
| 3660 | return err; |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3661 | err = alc_auto_add_vol_ctl(codec, "LFE", 0, 2, path); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3662 | if (err < 0) |
| 3663 | return err; |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3664 | err = alc_auto_add_sw_ctl(codec, "Center", 0, 1, path); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3665 | if (err < 0) |
| 3666 | return err; |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3667 | err = alc_auto_add_sw_ctl(codec, "LFE", 0, 2, path); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3668 | if (err < 0) |
| 3669 | return err; |
| 3670 | } else { |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3671 | err = alc_auto_add_stereo_vol(codec, name, index, path); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3672 | if (err < 0) |
| 3673 | return err; |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3674 | err = alc_auto_add_stereo_sw(codec, name, index, path); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3675 | if (err < 0) |
| 3676 | return err; |
| 3677 | } |
| 3678 | } |
| 3679 | return 0; |
| 3680 | } |
| 3681 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3682 | 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] | 3683 | hda_nid_t dac, const char *pfx, |
| 3684 | int cidx) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3685 | { |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3686 | struct nid_path *path; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3687 | int err; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3688 | |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame] | 3689 | path = get_nid_path(codec, dac, pin); |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3690 | if (!path) |
| 3691 | return 0; |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3692 | /* bind volume control will be created in the case of dac = 0 */ |
| 3693 | if (dac) { |
| 3694 | err = alc_auto_add_stereo_vol(codec, pfx, cidx, path); |
| 3695 | if (err < 0) |
| 3696 | return err; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3697 | } |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3698 | err = alc_auto_add_stereo_sw(codec, pfx, cidx, path); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3699 | if (err < 0) |
| 3700 | return err; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3701 | return 0; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3702 | } |
| 3703 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3704 | static struct hda_bind_ctls *new_bind_ctl(struct hda_codec *codec, |
| 3705 | unsigned int nums, |
| 3706 | struct hda_ctl_ops *ops) |
| 3707 | { |
| 3708 | struct alc_spec *spec = codec->spec; |
| 3709 | struct hda_bind_ctls **ctlp, *ctl; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3710 | ctlp = snd_array_new(&spec->bind_ctls); |
| 3711 | if (!ctlp) |
| 3712 | return NULL; |
| 3713 | ctl = kzalloc(sizeof(*ctl) + sizeof(long) * (nums + 1), GFP_KERNEL); |
| 3714 | *ctlp = ctl; |
| 3715 | if (ctl) |
| 3716 | ctl->ops = ops; |
| 3717 | return ctl; |
| 3718 | } |
| 3719 | |
| 3720 | /* add playback controls for speaker and HP outputs */ |
| 3721 | static int alc_auto_create_extra_outs(struct hda_codec *codec, int num_pins, |
| 3722 | const hda_nid_t *pins, |
| 3723 | const hda_nid_t *dacs, |
| 3724 | const char *pfx) |
| 3725 | { |
| 3726 | struct alc_spec *spec = codec->spec; |
| 3727 | struct hda_bind_ctls *ctl; |
| 3728 | char name[32]; |
| 3729 | int i, n, err; |
| 3730 | |
| 3731 | if (!num_pins || !pins[0]) |
| 3732 | return 0; |
| 3733 | |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3734 | if (num_pins == 1) { |
| 3735 | hda_nid_t dac = *dacs; |
| 3736 | if (!dac) |
| 3737 | dac = spec->multiout.dac_nids[0]; |
Takashi Iwai | 766ddee | 2011-12-07 16:55:19 +0100 | [diff] [blame] | 3738 | return alc_auto_create_extra_out(codec, *pins, dac, pfx, 0); |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3739 | } |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3740 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3741 | for (i = 0; i < num_pins; i++) { |
Takashi Iwai | c96f0bf | 2012-02-21 12:12:57 +0100 | [diff] [blame] | 3742 | hda_nid_t dac; |
| 3743 | if (dacs[num_pins - 1]) |
| 3744 | dac = dacs[i]; /* with individual volumes */ |
| 3745 | else |
| 3746 | dac = 0; |
| 3747 | if (num_pins == 2 && i == 1 && !strcmp(pfx, "Speaker")) { |
| 3748 | err = alc_auto_create_extra_out(codec, pins[i], dac, |
| 3749 | "Bass Speaker", 0); |
| 3750 | } else if (num_pins >= 3) { |
| 3751 | snprintf(name, sizeof(name), "%s %s", |
| 3752 | pfx, channel_name[i]); |
| 3753 | err = alc_auto_create_extra_out(codec, pins[i], dac, |
| 3754 | name, 0); |
| 3755 | } else { |
| 3756 | err = alc_auto_create_extra_out(codec, pins[i], dac, |
| 3757 | pfx, i); |
| 3758 | } |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3759 | if (err < 0) |
| 3760 | return err; |
| 3761 | } |
Takashi Iwai | c96f0bf | 2012-02-21 12:12:57 +0100 | [diff] [blame] | 3762 | if (dacs[num_pins - 1]) |
| 3763 | return 0; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3764 | |
Takashi Iwai | c96f0bf | 2012-02-21 12:12:57 +0100 | [diff] [blame] | 3765 | /* Let's create a bind-controls for volumes */ |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3766 | ctl = new_bind_ctl(codec, num_pins, &snd_hda_bind_vol); |
| 3767 | if (!ctl) |
| 3768 | return -ENOMEM; |
| 3769 | n = 0; |
| 3770 | for (i = 0; i < num_pins; i++) { |
| 3771 | hda_nid_t vol; |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3772 | struct nid_path *path; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3773 | if (!pins[i] || !dacs[i]) |
| 3774 | continue; |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame] | 3775 | path = get_nid_path(codec, dacs[i], pins[i]); |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3776 | if (!path) |
| 3777 | continue; |
| 3778 | vol = alc_look_for_out_vol_nid(codec, path); |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3779 | if (vol) |
| 3780 | ctl->values[n++] = |
| 3781 | HDA_COMPOSE_AMP_VAL(vol, 3, 0, HDA_OUTPUT); |
| 3782 | } |
| 3783 | if (n) { |
| 3784 | snprintf(name, sizeof(name), "%s Playback Volume", pfx); |
| 3785 | err = add_control(spec, ALC_CTL_BIND_VOL, name, 0, (long)ctl); |
| 3786 | if (err < 0) |
| 3787 | return err; |
| 3788 | } |
| 3789 | return 0; |
| 3790 | } |
| 3791 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3792 | static int alc_auto_create_hp_out(struct hda_codec *codec) |
| 3793 | { |
| 3794 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | e23832a | 2011-08-23 18:16:56 +0200 | [diff] [blame] | 3795 | return alc_auto_create_extra_outs(codec, spec->autocfg.hp_outs, |
| 3796 | spec->autocfg.hp_pins, |
| 3797 | spec->multiout.hp_out_nid, |
| 3798 | "Headphone"); |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3799 | } |
| 3800 | |
| 3801 | static int alc_auto_create_speaker_out(struct hda_codec *codec) |
| 3802 | { |
| 3803 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3804 | return alc_auto_create_extra_outs(codec, spec->autocfg.speaker_outs, |
| 3805 | spec->autocfg.speaker_pins, |
| 3806 | spec->multiout.extra_out_nid, |
| 3807 | "Speaker"); |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3808 | } |
| 3809 | |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3810 | /* check whether a control with the given (nid, dir, idx) was assigned */ |
| 3811 | static bool is_ctl_associated(struct hda_codec *codec, hda_nid_t nid, |
| 3812 | int dir, int idx) |
Takashi Iwai | 78e635c | 2012-12-10 17:07:16 +0100 | [diff] [blame] | 3813 | { |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3814 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 3815 | int i, type; |
| 3816 | |
| 3817 | for (i = 0; i < spec->paths.used; i++) { |
| 3818 | struct nid_path *p = snd_array_elem(&spec->paths, i); |
| 3819 | if (p->depth <= 0) |
| 3820 | continue; |
Takashi Iwai | 8dd4867 | 2012-12-14 18:19:04 +0100 | [diff] [blame] | 3821 | for (type = 0; type < NID_PATH_NUM_CTLS; type++) { |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 3822 | unsigned int val = p->ctls[type]; |
| 3823 | if (get_amp_nid_(val) == nid && |
| 3824 | get_amp_direction_(val) == dir && |
| 3825 | get_amp_index_(val) == idx) |
| 3826 | return true; |
| 3827 | } |
| 3828 | } |
| 3829 | return false; |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3830 | } |
| 3831 | |
| 3832 | /* can have the amp-in capability? */ |
| 3833 | static bool has_amp_in(struct hda_codec *codec, struct nid_path *path, int idx) |
| 3834 | { |
| 3835 | hda_nid_t nid = path->path[idx]; |
| 3836 | unsigned int caps = get_wcaps(codec, nid); |
| 3837 | unsigned int type = get_wcaps_type(caps); |
| 3838 | |
| 3839 | if (!(caps & AC_WCAP_IN_AMP)) |
| 3840 | return false; |
| 3841 | if (type == AC_WID_PIN && idx > 0) /* only for input pins */ |
| 3842 | return false; |
| 3843 | return true; |
| 3844 | } |
| 3845 | |
| 3846 | /* can have the amp-out capability? */ |
| 3847 | static bool has_amp_out(struct hda_codec *codec, struct nid_path *path, int idx) |
| 3848 | { |
| 3849 | hda_nid_t nid = path->path[idx]; |
| 3850 | unsigned int caps = get_wcaps(codec, nid); |
| 3851 | unsigned int type = get_wcaps_type(caps); |
| 3852 | |
| 3853 | if (!(caps & AC_WCAP_OUT_AMP)) |
| 3854 | return false; |
| 3855 | if (type == AC_WID_PIN && !idx) /* only for output pins */ |
| 3856 | return false; |
| 3857 | return true; |
| 3858 | } |
| 3859 | |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 3860 | /* check whether the given (nid,dir,idx) is active */ |
| 3861 | static bool is_active_nid(struct hda_codec *codec, hda_nid_t nid, |
| 3862 | unsigned int idx, unsigned int dir) |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3863 | { |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 3864 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3865 | int i, n; |
| 3866 | |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 3867 | for (n = 0; n < spec->paths.used; n++) { |
| 3868 | struct nid_path *path = snd_array_elem(&spec->paths, n); |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3869 | if (!path->active) |
| 3870 | continue; |
| 3871 | for (i = 0; i < path->depth; i++) { |
| 3872 | if (path->path[i] == nid) { |
| 3873 | if (dir == HDA_OUTPUT || path->idx[i] == idx) |
| 3874 | return true; |
| 3875 | break; |
| 3876 | } |
| 3877 | } |
| 3878 | } |
| 3879 | return false; |
| 3880 | } |
| 3881 | |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3882 | /* get the default amp value for the target state */ |
| 3883 | static int get_amp_val_to_activate(struct hda_codec *codec, hda_nid_t nid, |
| 3884 | int dir, bool enable) |
| 3885 | { |
| 3886 | unsigned int caps; |
Takashi Iwai | 78e635c | 2012-12-10 17:07:16 +0100 | [diff] [blame] | 3887 | unsigned int val = 0; |
| 3888 | |
| 3889 | caps = query_amp_caps(codec, nid, dir); |
| 3890 | if (caps & AC_AMPCAP_NUM_STEPS) { |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3891 | /* set to 0dB */ |
| 3892 | if (enable) |
| 3893 | val = (caps & AC_AMPCAP_OFFSET) >> AC_AMPCAP_OFFSET_SHIFT; |
Takashi Iwai | 78e635c | 2012-12-10 17:07:16 +0100 | [diff] [blame] | 3894 | } |
| 3895 | if (caps & AC_AMPCAP_MUTE) { |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3896 | if (!enable) |
Takashi Iwai | 78e635c | 2012-12-10 17:07:16 +0100 | [diff] [blame] | 3897 | val |= HDA_AMP_MUTE; |
| 3898 | } |
| 3899 | return val; |
| 3900 | } |
| 3901 | |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3902 | /* initialize the amp value (only at the first time) */ |
| 3903 | static void init_amp(struct hda_codec *codec, hda_nid_t nid, int dir, int idx) |
| 3904 | { |
| 3905 | int val = get_amp_val_to_activate(codec, nid, dir, false); |
| 3906 | snd_hda_codec_amp_init_stereo(codec, nid, dir, idx, 0xff, val); |
| 3907 | } |
| 3908 | |
| 3909 | static void activate_amp(struct hda_codec *codec, hda_nid_t nid, int dir, |
| 3910 | int idx, bool enable) |
| 3911 | { |
| 3912 | int val; |
| 3913 | if (is_ctl_associated(codec, nid, dir, idx) || |
| 3914 | is_active_nid(codec, nid, dir, idx)) |
| 3915 | return; |
| 3916 | val = get_amp_val_to_activate(codec, nid, dir, enable); |
| 3917 | snd_hda_codec_amp_stereo(codec, nid, dir, idx, 0xff, val); |
| 3918 | } |
| 3919 | |
| 3920 | static void activate_amp_out(struct hda_codec *codec, struct nid_path *path, |
| 3921 | int i, bool enable) |
| 3922 | { |
| 3923 | hda_nid_t nid = path->path[i]; |
| 3924 | init_amp(codec, nid, HDA_OUTPUT, 0); |
| 3925 | activate_amp(codec, nid, HDA_OUTPUT, 0, enable); |
| 3926 | } |
| 3927 | |
| 3928 | 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] | 3929 | int i, bool enable, bool add_aamix) |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3930 | { |
| 3931 | struct alc_spec *spec = codec->spec; |
| 3932 | hda_nid_t conn[16]; |
Takashi Iwai | 0250f7c | 2012-12-14 17:53:29 +0100 | [diff] [blame] | 3933 | int n, nums, idx; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 3934 | int type; |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3935 | hda_nid_t nid = path->path[i]; |
| 3936 | |
| 3937 | nums = snd_hda_get_connections(codec, nid, conn, ARRAY_SIZE(conn)); |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 3938 | type = get_wcaps_type(get_wcaps(codec, nid)); |
| 3939 | if (type == AC_WID_PIN || |
| 3940 | (type == AC_WID_AUD_IN && codec->single_adc_amp)) { |
Takashi Iwai | 0250f7c | 2012-12-14 17:53:29 +0100 | [diff] [blame] | 3941 | nums = 1; |
| 3942 | idx = 0; |
| 3943 | } else |
| 3944 | idx = path->idx[i]; |
| 3945 | |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3946 | for (n = 0; n < nums; n++) |
| 3947 | init_amp(codec, nid, HDA_INPUT, n); |
| 3948 | |
Takashi Iwai | 0250f7c | 2012-12-14 17:53:29 +0100 | [diff] [blame] | 3949 | if (is_ctl_associated(codec, nid, HDA_INPUT, idx)) |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3950 | return; |
| 3951 | |
| 3952 | /* here is a little bit tricky in comparison with activate_amp_out(); |
| 3953 | * when aa-mixer is available, we need to enable the path as well |
| 3954 | */ |
| 3955 | for (n = 0; n < nums; n++) { |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 3956 | if (n != idx && (!add_aamix || conn[n] != spec->mixer_nid)) |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3957 | continue; |
| 3958 | activate_amp(codec, nid, HDA_INPUT, n, enable); |
| 3959 | } |
| 3960 | } |
| 3961 | |
| 3962 | static void activate_path(struct hda_codec *codec, struct nid_path *path, |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 3963 | bool enable, bool add_aamix) |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3964 | { |
| 3965 | int i; |
| 3966 | |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3967 | if (!enable) |
| 3968 | path->active = false; |
| 3969 | |
| 3970 | for (i = path->depth - 1; i >= 0; i--) { |
Takashi Iwai | 183a444 | 2012-12-17 18:00:02 +0100 | [diff] [blame] | 3971 | if (enable && path->multi[i]) |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3972 | snd_hda_codec_write_cache(codec, path->path[i], 0, |
| 3973 | AC_VERB_SET_CONNECT_SEL, |
| 3974 | path->idx[i]); |
| 3975 | if (has_amp_in(codec, path, i)) |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 3976 | activate_amp_in(codec, path, i, enable, add_aamix); |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3977 | if (has_amp_out(codec, path, i)) |
| 3978 | activate_amp_out(codec, path, i, enable); |
| 3979 | } |
| 3980 | |
| 3981 | if (enable) |
| 3982 | path->active = true; |
| 3983 | } |
| 3984 | |
Takashi Iwai | 78e635c | 2012-12-10 17:07:16 +0100 | [diff] [blame] | 3985 | /* configure the path from the given dac to the pin as the proper output */ |
| 3986 | static void alc_auto_set_output_and_unmute(struct hda_codec *codec, |
| 3987 | hda_nid_t pin, int pin_type, |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3988 | hda_nid_t dac) |
Takashi Iwai | 78e635c | 2012-12-10 17:07:16 +0100 | [diff] [blame] | 3989 | { |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3990 | struct nid_path *path; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3991 | |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3992 | snd_hda_set_pin_ctl_cache(codec, pin, pin_type); |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame] | 3993 | path = get_nid_path(codec, dac, pin); |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3994 | if (!path) |
| 3995 | return; |
Takashi Iwai | 3ebf1e9 | 2012-12-14 18:04:37 +0100 | [diff] [blame] | 3996 | if (path->active) |
| 3997 | return; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 3998 | activate_path(codec, path, true, true); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3999 | } |
| 4000 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 4001 | static void alc_auto_init_multi_out(struct hda_codec *codec) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 4002 | { |
| 4003 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 4004 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 4005 | int i; |
| 4006 | |
| 4007 | for (i = 0; i <= HDA_SIDE; i++) { |
| 4008 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
| 4009 | if (nid) |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 4010 | alc_auto_set_output_and_unmute(codec, nid, pin_type, |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 4011 | spec->multiout.dac_nids[i]); |
Takashi Iwai | 78e635c | 2012-12-10 17:07:16 +0100 | [diff] [blame] | 4012 | |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 4013 | } |
| 4014 | } |
| 4015 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 4016 | static void alc_auto_init_extra_out(struct hda_codec *codec) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 4017 | { |
| 4018 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 8cd0775 | 2011-08-23 15:16:22 +0200 | [diff] [blame] | 4019 | int i; |
Takashi Iwai | 675c1aa | 2011-08-23 12:36:28 +0200 | [diff] [blame] | 4020 | hda_nid_t pin, dac; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 4021 | |
David Henningsson | 636030e | 2011-10-12 19:26:03 +0200 | [diff] [blame] | 4022 | for (i = 0; i < spec->autocfg.hp_outs; i++) { |
Takashi Iwai | 716eef0 | 2011-10-21 15:07:42 +0200 | [diff] [blame] | 4023 | if (spec->autocfg.line_out_type == AUTO_PIN_HP_OUT) |
| 4024 | break; |
Takashi Iwai | e23832a | 2011-08-23 18:16:56 +0200 | [diff] [blame] | 4025 | pin = spec->autocfg.hp_pins[i]; |
| 4026 | if (!pin) |
| 4027 | break; |
| 4028 | dac = spec->multiout.hp_out_nid[i]; |
| 4029 | if (!dac) { |
| 4030 | if (i > 0 && spec->multiout.hp_out_nid[0]) |
| 4031 | dac = spec->multiout.hp_out_nid[0]; |
| 4032 | else |
| 4033 | dac = spec->multiout.dac_nids[0]; |
| 4034 | } |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 4035 | alc_auto_set_output_and_unmute(codec, pin, PIN_HP, dac); |
Takashi Iwai | 675c1aa | 2011-08-23 12:36:28 +0200 | [diff] [blame] | 4036 | } |
Takashi Iwai | 8cd0775 | 2011-08-23 15:16:22 +0200 | [diff] [blame] | 4037 | for (i = 0; i < spec->autocfg.speaker_outs; i++) { |
Takashi Iwai | 716eef0 | 2011-10-21 15:07:42 +0200 | [diff] [blame] | 4038 | if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT) |
| 4039 | break; |
Takashi Iwai | 8cd0775 | 2011-08-23 15:16:22 +0200 | [diff] [blame] | 4040 | pin = spec->autocfg.speaker_pins[i]; |
| 4041 | if (!pin) |
| 4042 | break; |
| 4043 | dac = spec->multiout.extra_out_nid[i]; |
| 4044 | if (!dac) { |
| 4045 | if (i > 0 && spec->multiout.extra_out_nid[0]) |
| 4046 | dac = spec->multiout.extra_out_nid[0]; |
| 4047 | else |
| 4048 | dac = spec->multiout.dac_nids[0]; |
| 4049 | } |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 4050 | alc_auto_set_output_and_unmute(codec, pin, PIN_OUT, dac); |
Takashi Iwai | 675c1aa | 2011-08-23 12:36:28 +0200 | [diff] [blame] | 4051 | } |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 4052 | } |
| 4053 | |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4054 | /* check whether the given pin can be a multi-io pin */ |
| 4055 | static bool can_be_multiio_pin(struct hda_codec *codec, |
| 4056 | unsigned int location, hda_nid_t nid) |
| 4057 | { |
| 4058 | unsigned int defcfg, caps; |
| 4059 | |
| 4060 | defcfg = snd_hda_codec_get_pincfg(codec, nid); |
| 4061 | if (get_defcfg_connect(defcfg) != AC_JACK_PORT_COMPLEX) |
| 4062 | return false; |
| 4063 | if (location && get_defcfg_location(defcfg) != location) |
| 4064 | return false; |
| 4065 | caps = snd_hda_query_pin_caps(codec, nid); |
| 4066 | if (!(caps & AC_PINCAP_OUT)) |
| 4067 | return false; |
| 4068 | return true; |
| 4069 | } |
| 4070 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4071 | /* |
| 4072 | * multi-io helper |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4073 | * |
| 4074 | * When hardwired is set, try to fill ony hardwired pins, and returns |
| 4075 | * zero if any pins are filled, non-zero if nothing found. |
| 4076 | * When hardwired is off, try to fill possible input pins, and returns |
| 4077 | * the badness value. |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4078 | */ |
| 4079 | static int alc_auto_fill_multi_ios(struct hda_codec *codec, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4080 | hda_nid_t reference_pin, |
| 4081 | bool hardwired, int offset) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4082 | { |
| 4083 | struct alc_spec *spec = codec->spec; |
| 4084 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4085 | int type, i, j, dacs, num_pins, old_pins; |
| 4086 | unsigned int defcfg = snd_hda_codec_get_pincfg(codec, reference_pin); |
| 4087 | unsigned int location = get_defcfg_location(defcfg); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 4088 | int badness = 0; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4089 | |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4090 | old_pins = spec->multi_ios; |
| 4091 | if (old_pins >= 2) |
| 4092 | goto end_fill; |
| 4093 | |
| 4094 | num_pins = 0; |
| 4095 | for (type = AUTO_PIN_LINE_IN; type >= AUTO_PIN_MIC; type--) { |
| 4096 | for (i = 0; i < cfg->num_inputs; i++) { |
| 4097 | if (cfg->inputs[i].type != type) |
| 4098 | continue; |
| 4099 | if (can_be_multiio_pin(codec, location, |
| 4100 | cfg->inputs[i].pin)) |
| 4101 | num_pins++; |
| 4102 | } |
| 4103 | } |
| 4104 | if (num_pins < 2) |
| 4105 | goto end_fill; |
| 4106 | |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 4107 | dacs = spec->multiout.num_dacs; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4108 | for (type = AUTO_PIN_LINE_IN; type >= AUTO_PIN_MIC; type--) { |
| 4109 | for (i = 0; i < cfg->num_inputs; i++) { |
| 4110 | hda_nid_t nid = cfg->inputs[i].pin; |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 4111 | hda_nid_t dac = 0; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4112 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4113 | if (cfg->inputs[i].type != type) |
| 4114 | continue; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4115 | if (!can_be_multiio_pin(codec, location, nid)) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4116 | continue; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4117 | for (j = 0; j < spec->multi_ios; j++) { |
| 4118 | if (nid == spec->multi_io[j].pin) |
| 4119 | break; |
| 4120 | } |
| 4121 | if (j < spec->multi_ios) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4122 | continue; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4123 | |
| 4124 | if (offset && offset + spec->multi_ios < dacs) { |
| 4125 | dac = spec->private_dac_nids[offset + spec->multi_ios]; |
Takashi Iwai | 9c64076 | 2012-12-14 16:15:56 +0100 | [diff] [blame] | 4126 | if (!is_reachable_path(codec, dac, nid)) |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 4127 | dac = 0; |
| 4128 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4129 | if (hardwired) |
| 4130 | dac = get_dac_if_single(codec, nid); |
| 4131 | else if (!dac) |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 4132 | dac = alc_auto_look_for_dac(codec, nid, false); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 4133 | if (!dac) { |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4134 | badness++; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4135 | continue; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 4136 | } |
Takashi Iwai | 965cceb | 2012-12-18 11:46:37 +0100 | [diff] [blame] | 4137 | if (!add_new_nid_path(codec, dac, nid, 0)) { |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 4138 | badness++; |
| 4139 | continue; |
| 4140 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4141 | spec->multi_io[spec->multi_ios].pin = nid; |
| 4142 | spec->multi_io[spec->multi_ios].dac = dac; |
| 4143 | spec->multi_ios++; |
| 4144 | if (spec->multi_ios >= 2) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 4145 | break; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4146 | } |
| 4147 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4148 | end_fill: |
| 4149 | if (badness) |
| 4150 | badness = BAD_MULTI_IO; |
| 4151 | if (old_pins == spec->multi_ios) { |
| 4152 | if (hardwired) |
| 4153 | return 1; /* nothing found */ |
| 4154 | else |
| 4155 | return badness; /* no badness if nothing found */ |
| 4156 | } |
| 4157 | if (!hardwired && spec->multi_ios < 2) { |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 4158 | /* cancel newly assigned paths */ |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 4159 | spec->paths.used -= spec->multi_ios - old_pins; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4160 | spec->multi_ios = old_pins; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 4161 | return badness; |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 4162 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 4163 | |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 4164 | /* assign volume and mute controls */ |
| 4165 | for (i = old_pins; i < spec->multi_ios; i++) |
| 4166 | badness += assign_out_path_ctls(codec, spec->multi_io[i].pin, |
| 4167 | spec->multi_io[i].dac); |
| 4168 | |
| 4169 | return badness; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4170 | } |
| 4171 | |
| 4172 | static int alc_auto_ch_mode_info(struct snd_kcontrol *kcontrol, |
| 4173 | struct snd_ctl_elem_info *uinfo) |
| 4174 | { |
| 4175 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 4176 | struct alc_spec *spec = codec->spec; |
| 4177 | |
| 4178 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
| 4179 | uinfo->count = 1; |
| 4180 | uinfo->value.enumerated.items = spec->multi_ios + 1; |
| 4181 | if (uinfo->value.enumerated.item > spec->multi_ios) |
| 4182 | uinfo->value.enumerated.item = spec->multi_ios; |
| 4183 | sprintf(uinfo->value.enumerated.name, "%dch", |
| 4184 | (uinfo->value.enumerated.item + 1) * 2); |
| 4185 | return 0; |
| 4186 | } |
| 4187 | |
| 4188 | static int alc_auto_ch_mode_get(struct snd_kcontrol *kcontrol, |
| 4189 | struct snd_ctl_elem_value *ucontrol) |
| 4190 | { |
| 4191 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 4192 | struct alc_spec *spec = codec->spec; |
| 4193 | ucontrol->value.enumerated.item[0] = (spec->ext_channel_count - 1) / 2; |
| 4194 | return 0; |
| 4195 | } |
| 4196 | |
| 4197 | static int alc_set_multi_io(struct hda_codec *codec, int idx, bool output) |
| 4198 | { |
| 4199 | struct alc_spec *spec = codec->spec; |
| 4200 | hda_nid_t nid = spec->multi_io[idx].pin; |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 4201 | struct nid_path *path; |
| 4202 | |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame] | 4203 | path = get_nid_path(codec, spec->multi_io[idx].dac, nid); |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 4204 | if (!path) |
| 4205 | return -EINVAL; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4206 | |
Takashi Iwai | 3ebf1e9 | 2012-12-14 18:04:37 +0100 | [diff] [blame] | 4207 | if (path->active == output) |
| 4208 | return 0; |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 4209 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4210 | if (output) { |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 4211 | snd_hda_set_pin_ctl_cache(codec, nid, PIN_OUT); |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 4212 | activate_path(codec, path, true, true); |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4213 | } else { |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 4214 | activate_path(codec, path, false, true); |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 4215 | snd_hda_set_pin_ctl_cache(codec, nid, |
| 4216 | spec->multi_io[idx].ctl_in); |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4217 | } |
| 4218 | return 0; |
| 4219 | } |
| 4220 | |
| 4221 | static int alc_auto_ch_mode_put(struct snd_kcontrol *kcontrol, |
| 4222 | struct snd_ctl_elem_value *ucontrol) |
| 4223 | { |
| 4224 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 4225 | struct alc_spec *spec = codec->spec; |
| 4226 | int i, ch; |
| 4227 | |
| 4228 | ch = ucontrol->value.enumerated.item[0]; |
| 4229 | if (ch < 0 || ch > spec->multi_ios) |
| 4230 | return -EINVAL; |
| 4231 | if (ch == (spec->ext_channel_count - 1) / 2) |
| 4232 | return 0; |
| 4233 | spec->ext_channel_count = (ch + 1) * 2; |
| 4234 | for (i = 0; i < spec->multi_ios; i++) |
| 4235 | alc_set_multi_io(codec, i, i < ch); |
Takashi Iwai | b6adb57 | 2012-12-03 10:30:58 +0100 | [diff] [blame] | 4236 | spec->multiout.max_channels = max(spec->ext_channel_count, |
| 4237 | spec->const_channel_count); |
| 4238 | if (spec->need_dac_fix) |
Takashi Iwai | 7b1655f | 2011-07-14 15:31:21 +0200 | [diff] [blame] | 4239 | spec->multiout.num_dacs = spec->multiout.max_channels / 2; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4240 | return 1; |
| 4241 | } |
| 4242 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 4243 | static const struct snd_kcontrol_new alc_auto_channel_mode_enum = { |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4244 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 4245 | .name = "Channel Mode", |
| 4246 | .info = alc_auto_ch_mode_info, |
| 4247 | .get = alc_auto_ch_mode_get, |
| 4248 | .put = alc_auto_ch_mode_put, |
| 4249 | }; |
| 4250 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4251 | static int alc_auto_add_multi_channel_mode(struct hda_codec *codec) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4252 | { |
| 4253 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4254 | |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 4255 | if (spec->multi_ios > 0) { |
Takashi Iwai | bc54976 | 2012-12-18 15:35:11 +0100 | [diff] [blame] | 4256 | if (!alc_kcontrol_new(spec, NULL, &alc_auto_channel_mode_enum)) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4257 | return -ENOMEM; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4258 | } |
| 4259 | return 0; |
| 4260 | } |
| 4261 | |
Takashi Iwai | 3ebf1e9 | 2012-12-14 18:04:37 +0100 | [diff] [blame] | 4262 | static void alc_auto_init_multi_io(struct hda_codec *codec) |
| 4263 | { |
| 4264 | struct alc_spec *spec = codec->spec; |
| 4265 | int i; |
| 4266 | |
| 4267 | for (i = 0; i < spec->multi_ios; i++) { |
| 4268 | hda_nid_t pin = spec->multi_io[i].pin; |
| 4269 | struct nid_path *path; |
| 4270 | path = get_nid_path(codec, spec->multi_io[i].dac, pin); |
| 4271 | if (!path) |
| 4272 | continue; |
| 4273 | if (!spec->multi_io[i].ctl_in) |
| 4274 | spec->multi_io[i].ctl_in = |
| 4275 | snd_hda_codec_update_cache(codec, pin, 0, |
| 4276 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 4277 | activate_path(codec, path, path->active, true); |
Takashi Iwai | 3ebf1e9 | 2012-12-14 18:04:37 +0100 | [diff] [blame] | 4278 | } |
| 4279 | } |
| 4280 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4281 | /* |
| 4282 | * initialize ADC paths |
| 4283 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4284 | static void alc_auto_init_input_src(struct hda_codec *codec) |
| 4285 | { |
| 4286 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 4287 | struct hda_input_mux *imux = &spec->input_mux; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 4288 | struct nid_path *path; |
| 4289 | int i, c, nums; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4290 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4291 | if (spec->dyn_adc_switch) |
| 4292 | nums = 1; |
| 4293 | else |
| 4294 | nums = spec->num_adc_nids; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 4295 | |
| 4296 | for (c = 0; c < nums; c++) { |
| 4297 | for (i = 0; i < imux->num_items; i++) { |
| 4298 | path = get_nid_path(codec, spec->imux_pins[i], |
| 4299 | get_adc_nid(codec, c, i)); |
| 4300 | if (path) { |
| 4301 | bool active = path->active; |
| 4302 | if (i == spec->cur_mux[c]) |
| 4303 | active = true; |
| 4304 | activate_path(codec, path, active, false); |
| 4305 | } |
| 4306 | } |
| 4307 | } |
| 4308 | |
| 4309 | alc_inv_dmic_sync(codec, true); |
| 4310 | if (spec->shared_mic_hp) |
| 4311 | update_shared_mic_hp(codec, spec->cur_mux[0]); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4312 | } |
| 4313 | |
| 4314 | /* add mic boosts if needed */ |
| 4315 | static int alc_auto_add_mic_boost(struct hda_codec *codec) |
| 4316 | { |
| 4317 | struct alc_spec *spec = codec->spec; |
| 4318 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 4319 | int i, err; |
| 4320 | int type_idx = 0; |
| 4321 | hda_nid_t nid; |
| 4322 | const char *prev_label = NULL; |
| 4323 | |
| 4324 | for (i = 0; i < cfg->num_inputs; i++) { |
| 4325 | if (cfg->inputs[i].type > AUTO_PIN_MIC) |
| 4326 | break; |
| 4327 | nid = cfg->inputs[i].pin; |
| 4328 | if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) { |
| 4329 | const char *label; |
| 4330 | char boost_label[32]; |
Takashi Iwai | 8dd4867 | 2012-12-14 18:19:04 +0100 | [diff] [blame] | 4331 | struct nid_path *path; |
| 4332 | unsigned int val; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4333 | |
| 4334 | label = hda_get_autocfg_input_label(codec, cfg, i); |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 4335 | if (spec->shared_mic_hp && !strcmp(label, "Misc")) |
| 4336 | label = "Headphone Mic"; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4337 | if (prev_label && !strcmp(label, prev_label)) |
| 4338 | type_idx++; |
| 4339 | else |
| 4340 | type_idx = 0; |
| 4341 | prev_label = label; |
| 4342 | |
| 4343 | snprintf(boost_label, sizeof(boost_label), |
| 4344 | "%s Boost Volume", label); |
Takashi Iwai | 8dd4867 | 2012-12-14 18:19:04 +0100 | [diff] [blame] | 4345 | val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4346 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
Takashi Iwai | 8dd4867 | 2012-12-14 18:19:04 +0100 | [diff] [blame] | 4347 | boost_label, type_idx, val); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4348 | if (err < 0) |
| 4349 | return err; |
Takashi Iwai | 8dd4867 | 2012-12-14 18:19:04 +0100 | [diff] [blame] | 4350 | |
| 4351 | path = get_nid_path(codec, nid, 0); |
| 4352 | if (path) |
| 4353 | path->ctls[NID_PATH_BOOST_CTL] = val; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4354 | } |
| 4355 | } |
| 4356 | return 0; |
| 4357 | } |
| 4358 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4359 | /* |
Takashi Iwai | e477062 | 2011-07-08 11:11:35 +0200 | [diff] [blame] | 4360 | * standard auto-parser initializations |
| 4361 | */ |
| 4362 | static void alc_auto_init_std(struct hda_codec *codec) |
| 4363 | { |
Takashi Iwai | e477062 | 2011-07-08 11:11:35 +0200 | [diff] [blame] | 4364 | alc_auto_init_multi_out(codec); |
| 4365 | alc_auto_init_extra_out(codec); |
Takashi Iwai | 3ebf1e9 | 2012-12-14 18:04:37 +0100 | [diff] [blame] | 4366 | alc_auto_init_multi_io(codec); |
Takashi Iwai | e477062 | 2011-07-08 11:11:35 +0200 | [diff] [blame] | 4367 | alc_auto_init_analog_input(codec); |
| 4368 | alc_auto_init_input_src(codec); |
| 4369 | alc_auto_init_digital(codec); |
Takashi Iwai | 2eab694 | 2012-12-18 15:30:41 +0100 | [diff] [blame] | 4370 | /* call init functions of standard auto-mute helpers */ |
| 4371 | alc_hp_automute(codec, NULL); |
| 4372 | alc_line_automute(codec, NULL); |
| 4373 | alc_mic_automute(codec, NULL); |
Takashi Iwai | e477062 | 2011-07-08 11:11:35 +0200 | [diff] [blame] | 4374 | } |
| 4375 | |
| 4376 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4377 | * Digital-beep handlers |
| 4378 | */ |
| 4379 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
| 4380 | #define set_beep_amp(spec, nid, idx, dir) \ |
| 4381 | ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir)) |
| 4382 | |
| 4383 | static const struct snd_pci_quirk beep_white_list[] = { |
Duncan Roe | 7110005 | 2012-10-10 14:19:50 +0200 | [diff] [blame] | 4384 | SND_PCI_QUIRK(0x1043, 0x103c, "ASUS", 1), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4385 | SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1), |
| 4386 | SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1), |
| 4387 | SND_PCI_QUIRK(0x1043, 0x831a, "EeePC", 1), |
| 4388 | SND_PCI_QUIRK(0x1043, 0x834a, "EeePC", 1), |
Takashi Iwai | 78f8baf | 2012-03-06 14:02:32 +0100 | [diff] [blame] | 4389 | SND_PCI_QUIRK(0x1458, 0xa002, "GA-MA790X", 1), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4390 | SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1), |
| 4391 | {} |
| 4392 | }; |
| 4393 | |
| 4394 | static inline int has_cdefine_beep(struct hda_codec *codec) |
| 4395 | { |
| 4396 | struct alc_spec *spec = codec->spec; |
| 4397 | const struct snd_pci_quirk *q; |
| 4398 | q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list); |
| 4399 | if (q) |
| 4400 | return q->value; |
| 4401 | return spec->cdefine.enable_pcbeep; |
| 4402 | } |
| 4403 | #else |
| 4404 | #define set_beep_amp(spec, nid, idx, dir) /* NOP */ |
| 4405 | #define has_cdefine_beep(codec) 0 |
| 4406 | #endif |
| 4407 | |
| 4408 | /* parse the BIOS configuration and set up the alc_spec */ |
| 4409 | /* return 1 if successful, 0 if the proper config is not found, |
| 4410 | * or a negative error code |
| 4411 | */ |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4412 | static int alc_parse_auto_config(struct hda_codec *codec, |
| 4413 | const hda_nid_t *ignore_nids, |
| 4414 | const hda_nid_t *ssid_nids) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4415 | { |
| 4416 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4417 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4418 | int err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4419 | |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 4420 | err = snd_hda_parse_pin_defcfg(codec, cfg, ignore_nids, |
| 4421 | spec->parse_flags); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4422 | if (err < 0) |
| 4423 | return err; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4424 | if (!cfg->line_outs) { |
| 4425 | if (cfg->dig_outs || cfg->dig_in_pin) { |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4426 | spec->multiout.max_channels = 2; |
| 4427 | spec->no_analog = 1; |
| 4428 | goto dig_only; |
| 4429 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4430 | return 0; /* can't find valid BIOS pin config */ |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4431 | } |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4432 | |
Takashi Iwai | e427c23 | 2012-07-29 10:04:08 +0200 | [diff] [blame] | 4433 | if (!spec->no_primary_hp && |
| 4434 | cfg->line_out_type == AUTO_PIN_SPEAKER_OUT && |
Takashi Iwai | 0650367 | 2011-10-06 08:27:19 +0200 | [diff] [blame] | 4435 | cfg->line_outs <= cfg->hp_outs) { |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4436 | /* use HP as primary out */ |
| 4437 | cfg->speaker_outs = cfg->line_outs; |
| 4438 | memcpy(cfg->speaker_pins, cfg->line_out_pins, |
| 4439 | sizeof(cfg->speaker_pins)); |
| 4440 | cfg->line_outs = cfg->hp_outs; |
| 4441 | memcpy(cfg->line_out_pins, cfg->hp_pins, sizeof(cfg->hp_pins)); |
| 4442 | cfg->hp_outs = 0; |
| 4443 | memset(cfg->hp_pins, 0, sizeof(cfg->hp_pins)); |
| 4444 | cfg->line_out_type = AUTO_PIN_HP_OUT; |
| 4445 | } |
| 4446 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4447 | err = alc_auto_fill_dac_nids(codec); |
| 4448 | if (err < 0) |
| 4449 | return err; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4450 | err = alc_auto_add_multi_channel_mode(codec); |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4451 | if (err < 0) |
| 4452 | return err; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4453 | err = alc_auto_create_multi_out_ctls(codec, cfg); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4454 | if (err < 0) |
| 4455 | return err; |
| 4456 | err = alc_auto_create_hp_out(codec); |
| 4457 | if (err < 0) |
| 4458 | return err; |
| 4459 | err = alc_auto_create_speaker_out(codec); |
| 4460 | if (err < 0) |
| 4461 | return err; |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 4462 | err = alc_auto_create_shared_input(codec); |
| 4463 | if (err < 0) |
| 4464 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4465 | err = alc_auto_create_input_ctls(codec); |
| 4466 | if (err < 0) |
| 4467 | return err; |
| 4468 | |
Takashi Iwai | b6adb57 | 2012-12-03 10:30:58 +0100 | [diff] [blame] | 4469 | /* check the multiple speaker pins */ |
| 4470 | if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) |
| 4471 | spec->const_channel_count = cfg->line_outs * 2; |
| 4472 | else |
| 4473 | spec->const_channel_count = cfg->speaker_outs * 2; |
| 4474 | |
| 4475 | if (spec->multi_ios > 0) |
| 4476 | spec->multiout.max_channels = max(spec->ext_channel_count, |
| 4477 | spec->const_channel_count); |
| 4478 | else |
| 4479 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4480 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4481 | dig_only: |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4482 | alc_auto_parse_digital(codec); |
| 4483 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4484 | if (ssid_nids) |
| 4485 | alc_ssid_check(codec, ssid_nids); |
| 4486 | |
| 4487 | if (!spec->no_analog) { |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 4488 | err = alc_init_automute(codec); |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 4489 | if (err < 0) |
| 4490 | return err; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 4491 | |
| 4492 | err = check_dyn_adc_switch(codec); |
| 4493 | if (err < 0) |
| 4494 | return err; |
| 4495 | |
| 4496 | if (!spec->shared_mic_hp) { |
| 4497 | err = alc_init_auto_mic(codec); |
| 4498 | if (err < 0) |
| 4499 | return err; |
| 4500 | } |
| 4501 | |
| 4502 | err = create_capture_mixers(codec); |
| 4503 | if (err < 0) |
| 4504 | return err; |
| 4505 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4506 | err = alc_auto_add_mic_boost(codec); |
| 4507 | if (err < 0) |
| 4508 | return err; |
| 4509 | } |
| 4510 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4511 | if (spec->kctls.list) |
| 4512 | add_mixer(spec, spec->kctls.list); |
| 4513 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4514 | return 1; |
| 4515 | } |
| 4516 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 4517 | /* common preparation job for alc_spec */ |
| 4518 | static int alc_alloc_spec(struct hda_codec *codec, hda_nid_t mixer_nid) |
| 4519 | { |
| 4520 | struct alc_spec *spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 4521 | int err; |
| 4522 | |
| 4523 | if (!spec) |
| 4524 | return -ENOMEM; |
| 4525 | codec->spec = spec; |
Takashi Iwai | 1098b7c | 2012-12-17 20:03:15 +0100 | [diff] [blame] | 4526 | codec->single_adc_amp = 1; |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 4527 | spec->mixer_nid = mixer_nid; |
Takashi Iwai | ee48df5 | 2012-06-26 14:54:32 +0200 | [diff] [blame] | 4528 | snd_hda_gen_init(&spec->gen); |
Takashi Iwai | 361dab3 | 2012-05-09 14:35:27 +0200 | [diff] [blame] | 4529 | snd_array_init(&spec->kctls, sizeof(struct snd_kcontrol_new), 32); |
| 4530 | snd_array_init(&spec->bind_ctls, sizeof(struct hda_bind_ctls *), 8); |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 4531 | snd_array_init(&spec->paths, sizeof(struct nid_path), 8); |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 4532 | |
| 4533 | err = alc_codec_rename_from_preset(codec); |
| 4534 | if (err < 0) { |
| 4535 | kfree(spec); |
| 4536 | return err; |
| 4537 | } |
| 4538 | return 0; |
| 4539 | } |
| 4540 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4541 | static int alc880_parse_auto_config(struct hda_codec *codec) |
| 4542 | { |
| 4543 | static const hda_nid_t alc880_ignore[] = { 0x1d, 0 }; |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 4544 | static const hda_nid_t alc880_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4545 | return alc_parse_auto_config(codec, alc880_ignore, alc880_ssids); |
| 4546 | } |
| 4547 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4548 | /* |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4549 | * ALC880 fix-ups |
| 4550 | */ |
| 4551 | enum { |
Takashi Iwai | 411225a | 2012-02-20 17:48:19 +0100 | [diff] [blame] | 4552 | ALC880_FIXUP_GPIO1, |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4553 | ALC880_FIXUP_GPIO2, |
| 4554 | ALC880_FIXUP_MEDION_RIM, |
Takashi Iwai | dc6af52 | 2012-02-17 16:18:59 +0100 | [diff] [blame] | 4555 | ALC880_FIXUP_LG, |
Takashi Iwai | f02aab5 | 2012-02-17 16:33:56 +0100 | [diff] [blame] | 4556 | ALC880_FIXUP_W810, |
Takashi Iwai | 27e917f | 2012-02-17 17:49:54 +0100 | [diff] [blame] | 4557 | ALC880_FIXUP_EAPD_COEF, |
Takashi Iwai | b9368f5 | 2012-02-17 17:54:44 +0100 | [diff] [blame] | 4558 | ALC880_FIXUP_TCL_S700, |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 4559 | ALC880_FIXUP_VOL_KNOB, |
| 4560 | ALC880_FIXUP_FUJITSU, |
Takashi Iwai | ba53381 | 2012-02-20 16:36:52 +0100 | [diff] [blame] | 4561 | ALC880_FIXUP_F1734, |
Takashi Iwai | 817de92 | 2012-02-20 17:20:48 +0100 | [diff] [blame] | 4562 | ALC880_FIXUP_UNIWILL, |
Takashi Iwai | 967b88c | 2012-02-20 17:31:02 +0100 | [diff] [blame] | 4563 | ALC880_FIXUP_UNIWILL_DIG, |
Takashi Iwai | 96e225f | 2012-02-20 17:41:51 +0100 | [diff] [blame] | 4564 | ALC880_FIXUP_Z71V, |
Takashi Iwai | 67b6ec3 | 2012-02-20 18:20:42 +0100 | [diff] [blame] | 4565 | ALC880_FIXUP_3ST_BASE, |
| 4566 | ALC880_FIXUP_3ST, |
| 4567 | ALC880_FIXUP_3ST_DIG, |
| 4568 | ALC880_FIXUP_5ST_BASE, |
| 4569 | ALC880_FIXUP_5ST, |
| 4570 | ALC880_FIXUP_5ST_DIG, |
| 4571 | ALC880_FIXUP_6ST_BASE, |
| 4572 | ALC880_FIXUP_6ST, |
| 4573 | ALC880_FIXUP_6ST_DIG, |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4574 | }; |
| 4575 | |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 4576 | /* enable the volume-knob widget support on NID 0x21 */ |
| 4577 | static void alc880_fixup_vol_knob(struct hda_codec *codec, |
| 4578 | const struct alc_fixup *fix, int action) |
| 4579 | { |
| 4580 | if (action == ALC_FIXUP_ACT_PROBE) |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 4581 | 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] | 4582 | } |
| 4583 | |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4584 | static const struct alc_fixup alc880_fixups[] = { |
Takashi Iwai | 411225a | 2012-02-20 17:48:19 +0100 | [diff] [blame] | 4585 | [ALC880_FIXUP_GPIO1] = { |
| 4586 | .type = ALC_FIXUP_VERBS, |
| 4587 | .v.verbs = alc_gpio1_init_verbs, |
| 4588 | }, |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4589 | [ALC880_FIXUP_GPIO2] = { |
| 4590 | .type = ALC_FIXUP_VERBS, |
| 4591 | .v.verbs = alc_gpio2_init_verbs, |
| 4592 | }, |
| 4593 | [ALC880_FIXUP_MEDION_RIM] = { |
| 4594 | .type = ALC_FIXUP_VERBS, |
| 4595 | .v.verbs = (const struct hda_verb[]) { |
| 4596 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 4597 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 }, |
| 4598 | { } |
| 4599 | }, |
| 4600 | .chained = true, |
| 4601 | .chain_id = ALC880_FIXUP_GPIO2, |
| 4602 | }, |
Takashi Iwai | dc6af52 | 2012-02-17 16:18:59 +0100 | [diff] [blame] | 4603 | [ALC880_FIXUP_LG] = { |
| 4604 | .type = ALC_FIXUP_PINS, |
| 4605 | .v.pins = (const struct alc_pincfg[]) { |
| 4606 | /* disable bogus unused pins */ |
| 4607 | { 0x16, 0x411111f0 }, |
| 4608 | { 0x18, 0x411111f0 }, |
| 4609 | { 0x1a, 0x411111f0 }, |
| 4610 | { } |
| 4611 | } |
| 4612 | }, |
Takashi Iwai | f02aab5 | 2012-02-17 16:33:56 +0100 | [diff] [blame] | 4613 | [ALC880_FIXUP_W810] = { |
| 4614 | .type = ALC_FIXUP_PINS, |
| 4615 | .v.pins = (const struct alc_pincfg[]) { |
| 4616 | /* disable bogus unused pins */ |
| 4617 | { 0x17, 0x411111f0 }, |
| 4618 | { } |
| 4619 | }, |
| 4620 | .chained = true, |
| 4621 | .chain_id = ALC880_FIXUP_GPIO2, |
| 4622 | }, |
Takashi Iwai | 27e917f | 2012-02-17 17:49:54 +0100 | [diff] [blame] | 4623 | [ALC880_FIXUP_EAPD_COEF] = { |
| 4624 | .type = ALC_FIXUP_VERBS, |
| 4625 | .v.verbs = (const struct hda_verb[]) { |
| 4626 | /* change to EAPD mode */ |
| 4627 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 4628 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 }, |
| 4629 | {} |
| 4630 | }, |
| 4631 | }, |
Takashi Iwai | b9368f5 | 2012-02-17 17:54:44 +0100 | [diff] [blame] | 4632 | [ALC880_FIXUP_TCL_S700] = { |
| 4633 | .type = ALC_FIXUP_VERBS, |
| 4634 | .v.verbs = (const struct hda_verb[]) { |
| 4635 | /* change to EAPD mode */ |
| 4636 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 4637 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 }, |
| 4638 | {} |
| 4639 | }, |
| 4640 | .chained = true, |
| 4641 | .chain_id = ALC880_FIXUP_GPIO2, |
| 4642 | }, |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 4643 | [ALC880_FIXUP_VOL_KNOB] = { |
| 4644 | .type = ALC_FIXUP_FUNC, |
| 4645 | .v.func = alc880_fixup_vol_knob, |
| 4646 | }, |
| 4647 | [ALC880_FIXUP_FUJITSU] = { |
| 4648 | /* override all pins as BIOS on old Amilo is broken */ |
| 4649 | .type = ALC_FIXUP_PINS, |
| 4650 | .v.pins = (const struct alc_pincfg[]) { |
| 4651 | { 0x14, 0x0121411f }, /* HP */ |
| 4652 | { 0x15, 0x99030120 }, /* speaker */ |
| 4653 | { 0x16, 0x99030130 }, /* bass speaker */ |
| 4654 | { 0x17, 0x411111f0 }, /* N/A */ |
| 4655 | { 0x18, 0x411111f0 }, /* N/A */ |
| 4656 | { 0x19, 0x01a19950 }, /* mic-in */ |
| 4657 | { 0x1a, 0x411111f0 }, /* N/A */ |
| 4658 | { 0x1b, 0x411111f0 }, /* N/A */ |
| 4659 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4660 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4661 | { 0x1e, 0x01454140 }, /* SPDIF out */ |
| 4662 | { } |
| 4663 | }, |
| 4664 | .chained = true, |
| 4665 | .chain_id = ALC880_FIXUP_VOL_KNOB, |
| 4666 | }, |
Takashi Iwai | ba53381 | 2012-02-20 16:36:52 +0100 | [diff] [blame] | 4667 | [ALC880_FIXUP_F1734] = { |
| 4668 | /* almost compatible with FUJITSU, but no bass and SPDIF */ |
| 4669 | .type = ALC_FIXUP_PINS, |
| 4670 | .v.pins = (const struct alc_pincfg[]) { |
| 4671 | { 0x14, 0x0121411f }, /* HP */ |
| 4672 | { 0x15, 0x99030120 }, /* speaker */ |
| 4673 | { 0x16, 0x411111f0 }, /* N/A */ |
| 4674 | { 0x17, 0x411111f0 }, /* N/A */ |
| 4675 | { 0x18, 0x411111f0 }, /* N/A */ |
| 4676 | { 0x19, 0x01a19950 }, /* mic-in */ |
| 4677 | { 0x1a, 0x411111f0 }, /* N/A */ |
| 4678 | { 0x1b, 0x411111f0 }, /* N/A */ |
| 4679 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4680 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4681 | { 0x1e, 0x411111f0 }, /* N/A */ |
| 4682 | { } |
| 4683 | }, |
| 4684 | .chained = true, |
| 4685 | .chain_id = ALC880_FIXUP_VOL_KNOB, |
| 4686 | }, |
Takashi Iwai | 817de92 | 2012-02-20 17:20:48 +0100 | [diff] [blame] | 4687 | [ALC880_FIXUP_UNIWILL] = { |
| 4688 | /* need to fix HP and speaker pins to be parsed correctly */ |
| 4689 | .type = ALC_FIXUP_PINS, |
| 4690 | .v.pins = (const struct alc_pincfg[]) { |
| 4691 | { 0x14, 0x0121411f }, /* HP */ |
| 4692 | { 0x15, 0x99030120 }, /* speaker */ |
| 4693 | { 0x16, 0x99030130 }, /* bass speaker */ |
| 4694 | { } |
| 4695 | }, |
| 4696 | }, |
Takashi Iwai | 967b88c | 2012-02-20 17:31:02 +0100 | [diff] [blame] | 4697 | [ALC880_FIXUP_UNIWILL_DIG] = { |
| 4698 | .type = ALC_FIXUP_PINS, |
| 4699 | .v.pins = (const struct alc_pincfg[]) { |
| 4700 | /* disable bogus unused pins */ |
| 4701 | { 0x17, 0x411111f0 }, |
| 4702 | { 0x19, 0x411111f0 }, |
| 4703 | { 0x1b, 0x411111f0 }, |
| 4704 | { 0x1f, 0x411111f0 }, |
| 4705 | { } |
| 4706 | } |
| 4707 | }, |
Takashi Iwai | 96e225f | 2012-02-20 17:41:51 +0100 | [diff] [blame] | 4708 | [ALC880_FIXUP_Z71V] = { |
| 4709 | .type = ALC_FIXUP_PINS, |
| 4710 | .v.pins = (const struct alc_pincfg[]) { |
| 4711 | /* set up the whole pins as BIOS is utterly broken */ |
| 4712 | { 0x14, 0x99030120 }, /* speaker */ |
| 4713 | { 0x15, 0x0121411f }, /* HP */ |
| 4714 | { 0x16, 0x411111f0 }, /* N/A */ |
| 4715 | { 0x17, 0x411111f0 }, /* N/A */ |
| 4716 | { 0x18, 0x01a19950 }, /* mic-in */ |
| 4717 | { 0x19, 0x411111f0 }, /* N/A */ |
| 4718 | { 0x1a, 0x01813031 }, /* line-in */ |
| 4719 | { 0x1b, 0x411111f0 }, /* N/A */ |
| 4720 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4721 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4722 | { 0x1e, 0x0144111e }, /* SPDIF */ |
| 4723 | { } |
| 4724 | } |
| 4725 | }, |
Takashi Iwai | 67b6ec3 | 2012-02-20 18:20:42 +0100 | [diff] [blame] | 4726 | [ALC880_FIXUP_3ST_BASE] = { |
| 4727 | .type = ALC_FIXUP_PINS, |
| 4728 | .v.pins = (const struct alc_pincfg[]) { |
| 4729 | { 0x14, 0x01014010 }, /* line-out */ |
| 4730 | { 0x15, 0x411111f0 }, /* N/A */ |
| 4731 | { 0x16, 0x411111f0 }, /* N/A */ |
| 4732 | { 0x17, 0x411111f0 }, /* N/A */ |
| 4733 | { 0x18, 0x01a19c30 }, /* mic-in */ |
| 4734 | { 0x19, 0x0121411f }, /* HP */ |
| 4735 | { 0x1a, 0x01813031 }, /* line-in */ |
| 4736 | { 0x1b, 0x02a19c40 }, /* front-mic */ |
| 4737 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4738 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4739 | /* 0x1e is filled in below */ |
| 4740 | { 0x1f, 0x411111f0 }, /* N/A */ |
| 4741 | { } |
| 4742 | } |
| 4743 | }, |
| 4744 | [ALC880_FIXUP_3ST] = { |
| 4745 | .type = ALC_FIXUP_PINS, |
| 4746 | .v.pins = (const struct alc_pincfg[]) { |
| 4747 | { 0x1e, 0x411111f0 }, /* N/A */ |
| 4748 | { } |
| 4749 | }, |
| 4750 | .chained = true, |
| 4751 | .chain_id = ALC880_FIXUP_3ST_BASE, |
| 4752 | }, |
| 4753 | [ALC880_FIXUP_3ST_DIG] = { |
| 4754 | .type = ALC_FIXUP_PINS, |
| 4755 | .v.pins = (const struct alc_pincfg[]) { |
| 4756 | { 0x1e, 0x0144111e }, /* SPDIF */ |
| 4757 | { } |
| 4758 | }, |
| 4759 | .chained = true, |
| 4760 | .chain_id = ALC880_FIXUP_3ST_BASE, |
| 4761 | }, |
| 4762 | [ALC880_FIXUP_5ST_BASE] = { |
| 4763 | .type = ALC_FIXUP_PINS, |
| 4764 | .v.pins = (const struct alc_pincfg[]) { |
| 4765 | { 0x14, 0x01014010 }, /* front */ |
| 4766 | { 0x15, 0x411111f0 }, /* N/A */ |
| 4767 | { 0x16, 0x01011411 }, /* CLFE */ |
| 4768 | { 0x17, 0x01016412 }, /* surr */ |
| 4769 | { 0x18, 0x01a19c30 }, /* mic-in */ |
| 4770 | { 0x19, 0x0121411f }, /* HP */ |
| 4771 | { 0x1a, 0x01813031 }, /* line-in */ |
| 4772 | { 0x1b, 0x02a19c40 }, /* front-mic */ |
| 4773 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4774 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4775 | /* 0x1e is filled in below */ |
| 4776 | { 0x1f, 0x411111f0 }, /* N/A */ |
| 4777 | { } |
| 4778 | } |
| 4779 | }, |
| 4780 | [ALC880_FIXUP_5ST] = { |
| 4781 | .type = ALC_FIXUP_PINS, |
| 4782 | .v.pins = (const struct alc_pincfg[]) { |
| 4783 | { 0x1e, 0x411111f0 }, /* N/A */ |
| 4784 | { } |
| 4785 | }, |
| 4786 | .chained = true, |
| 4787 | .chain_id = ALC880_FIXUP_5ST_BASE, |
| 4788 | }, |
| 4789 | [ALC880_FIXUP_5ST_DIG] = { |
| 4790 | .type = ALC_FIXUP_PINS, |
| 4791 | .v.pins = (const struct alc_pincfg[]) { |
| 4792 | { 0x1e, 0x0144111e }, /* SPDIF */ |
| 4793 | { } |
| 4794 | }, |
| 4795 | .chained = true, |
| 4796 | .chain_id = ALC880_FIXUP_5ST_BASE, |
| 4797 | }, |
| 4798 | [ALC880_FIXUP_6ST_BASE] = { |
| 4799 | .type = ALC_FIXUP_PINS, |
| 4800 | .v.pins = (const struct alc_pincfg[]) { |
| 4801 | { 0x14, 0x01014010 }, /* front */ |
| 4802 | { 0x15, 0x01016412 }, /* surr */ |
| 4803 | { 0x16, 0x01011411 }, /* CLFE */ |
| 4804 | { 0x17, 0x01012414 }, /* side */ |
| 4805 | { 0x18, 0x01a19c30 }, /* mic-in */ |
| 4806 | { 0x19, 0x02a19c40 }, /* front-mic */ |
| 4807 | { 0x1a, 0x01813031 }, /* line-in */ |
| 4808 | { 0x1b, 0x0121411f }, /* HP */ |
| 4809 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4810 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4811 | /* 0x1e is filled in below */ |
| 4812 | { 0x1f, 0x411111f0 }, /* N/A */ |
| 4813 | { } |
| 4814 | } |
| 4815 | }, |
| 4816 | [ALC880_FIXUP_6ST] = { |
| 4817 | .type = ALC_FIXUP_PINS, |
| 4818 | .v.pins = (const struct alc_pincfg[]) { |
| 4819 | { 0x1e, 0x411111f0 }, /* N/A */ |
| 4820 | { } |
| 4821 | }, |
| 4822 | .chained = true, |
| 4823 | .chain_id = ALC880_FIXUP_6ST_BASE, |
| 4824 | }, |
| 4825 | [ALC880_FIXUP_6ST_DIG] = { |
| 4826 | .type = ALC_FIXUP_PINS, |
| 4827 | .v.pins = (const struct alc_pincfg[]) { |
| 4828 | { 0x1e, 0x0144111e }, /* SPDIF */ |
| 4829 | { } |
| 4830 | }, |
| 4831 | .chained = true, |
| 4832 | .chain_id = ALC880_FIXUP_6ST_BASE, |
| 4833 | }, |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4834 | }; |
| 4835 | |
| 4836 | static const struct snd_pci_quirk alc880_fixup_tbl[] = { |
Takashi Iwai | f02aab5 | 2012-02-17 16:33:56 +0100 | [diff] [blame] | 4837 | SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_FIXUP_W810), |
Takashi Iwai | 96e225f | 2012-02-20 17:41:51 +0100 | [diff] [blame] | 4838 | SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_FIXUP_Z71V), |
Takashi Iwai | 29e3fdc | 2012-02-20 17:56:57 +0100 | [diff] [blame] | 4839 | SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_FIXUP_GPIO1), |
| 4840 | SND_PCI_QUIRK(0x1558, 0x5401, "Clevo GPIO2", ALC880_FIXUP_GPIO2), |
Takashi Iwai | 27e917f | 2012-02-17 17:49:54 +0100 | [diff] [blame] | 4841 | SND_PCI_QUIRK_VENDOR(0x1558, "Clevo", ALC880_FIXUP_EAPD_COEF), |
Takashi Iwai | 967b88c | 2012-02-20 17:31:02 +0100 | [diff] [blame] | 4842 | SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_FIXUP_UNIWILL_DIG), |
Takashi Iwai | ba53381 | 2012-02-20 16:36:52 +0100 | [diff] [blame] | 4843 | SND_PCI_QUIRK(0x1584, 0x9054, "Uniwill", ALC880_FIXUP_F1734), |
Takashi Iwai | 817de92 | 2012-02-20 17:20:48 +0100 | [diff] [blame] | 4844 | SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_FIXUP_UNIWILL), |
Takashi Iwai | 7833c7e | 2012-02-20 17:11:38 +0100 | [diff] [blame] | 4845 | SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_FIXUP_VOL_KNOB), |
Takashi Iwai | f02aab5 | 2012-02-17 16:33:56 +0100 | [diff] [blame] | 4846 | SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_FIXUP_W810), |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4847 | SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_FIXUP_MEDION_RIM), |
Takashi Iwai | ba53381 | 2012-02-20 16:36:52 +0100 | [diff] [blame] | 4848 | SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_FIXUP_F1734), |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 4849 | SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FIXUP_FUJITSU), |
Takashi Iwai | ba53381 | 2012-02-20 16:36:52 +0100 | [diff] [blame] | 4850 | SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_FIXUP_F1734), |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 4851 | SND_PCI_QUIRK(0x1734, 0x10b0, "FSC Amilo Pi1556", ALC880_FIXUP_FUJITSU), |
Takashi Iwai | dc6af52 | 2012-02-17 16:18:59 +0100 | [diff] [blame] | 4852 | SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_FIXUP_LG), |
| 4853 | SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_FIXUP_LG), |
| 4854 | SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_FIXUP_LG), |
Takashi Iwai | b9368f5 | 2012-02-17 17:54:44 +0100 | [diff] [blame] | 4855 | SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_FIXUP_TCL_S700), |
Takashi Iwai | 67b6ec3 | 2012-02-20 18:20:42 +0100 | [diff] [blame] | 4856 | |
| 4857 | /* Below is the copied entries from alc880_quirks.c. |
| 4858 | * It's not quite sure whether BIOS sets the correct pin-config table |
| 4859 | * on these machines, thus they are kept to be compatible with |
| 4860 | * the old static quirks. Once when it's confirmed to work without |
| 4861 | * these overrides, it'd be better to remove. |
| 4862 | */ |
| 4863 | SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_FIXUP_5ST_DIG), |
| 4864 | SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_FIXUP_6ST), |
| 4865 | SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_FIXUP_3ST_DIG), |
| 4866 | SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_FIXUP_6ST_DIG), |
| 4867 | SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_FIXUP_6ST_DIG), |
| 4868 | SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_FIXUP_6ST_DIG), |
| 4869 | SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_FIXUP_3ST_DIG), |
| 4870 | SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_FIXUP_3ST), |
| 4871 | SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_FIXUP_6ST_DIG), |
| 4872 | SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_FIXUP_3ST), |
| 4873 | SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_FIXUP_3ST), |
| 4874 | SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_FIXUP_5ST), |
| 4875 | SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_FIXUP_5ST), |
| 4876 | SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_FIXUP_5ST), |
| 4877 | SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_FIXUP_6ST_DIG), |
| 4878 | SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_FIXUP_6ST_DIG), |
| 4879 | SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_FIXUP_6ST_DIG), |
| 4880 | SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_FIXUP_6ST_DIG), |
| 4881 | SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_FIXUP_5ST_DIG), |
| 4882 | SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_FIXUP_5ST_DIG), |
| 4883 | SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_FIXUP_5ST_DIG), |
| 4884 | SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_FIXUP_6ST_DIG), /* broken BIOS */ |
| 4885 | SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_FIXUP_6ST_DIG), |
| 4886 | SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4887 | SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4888 | SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4889 | SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_FIXUP_3ST_DIG), |
| 4890 | SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4891 | SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_FIXUP_3ST_DIG), |
| 4892 | SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_FIXUP_3ST_DIG), |
| 4893 | SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4894 | SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4895 | SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4896 | /* default Intel */ |
| 4897 | SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_FIXUP_3ST), |
| 4898 | SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_FIXUP_5ST_DIG), |
| 4899 | SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_FIXUP_6ST_DIG), |
| 4900 | {} |
| 4901 | }; |
| 4902 | |
| 4903 | static const struct alc_model_fixup alc880_fixup_models[] = { |
| 4904 | {.id = ALC880_FIXUP_3ST, .name = "3stack"}, |
| 4905 | {.id = ALC880_FIXUP_3ST_DIG, .name = "3stack-digout"}, |
| 4906 | {.id = ALC880_FIXUP_5ST, .name = "5stack"}, |
| 4907 | {.id = ALC880_FIXUP_5ST_DIG, .name = "5stack-digout"}, |
| 4908 | {.id = ALC880_FIXUP_6ST, .name = "6stack"}, |
| 4909 | {.id = ALC880_FIXUP_6ST_DIG, .name = "6stack-digout"}, |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4910 | {} |
| 4911 | }; |
| 4912 | |
| 4913 | |
| 4914 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4915 | * OK, here we have finally the patch for ALC880 |
| 4916 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4917 | static int patch_alc880(struct hda_codec *codec) |
| 4918 | { |
| 4919 | struct alc_spec *spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4920 | int err; |
| 4921 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 4922 | err = alc_alloc_spec(codec, 0x0b); |
| 4923 | if (err < 0) |
| 4924 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4925 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 4926 | spec = codec->spec; |
Takashi Iwai | 7b1655f | 2011-07-14 15:31:21 +0200 | [diff] [blame] | 4927 | spec->need_dac_fix = 1; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4928 | |
Takashi Iwai | 67b6ec3 | 2012-02-20 18:20:42 +0100 | [diff] [blame] | 4929 | alc_pick_fixup(codec, alc880_fixup_models, alc880_fixup_tbl, |
| 4930 | alc880_fixups); |
| 4931 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4932 | |
Takashi Iwai | 67b6ec3 | 2012-02-20 18:20:42 +0100 | [diff] [blame] | 4933 | /* automatic parse from the BIOS config */ |
| 4934 | err = alc880_parse_auto_config(codec); |
| 4935 | if (err < 0) |
| 4936 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4937 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4938 | if (!spec->no_analog) { |
| 4939 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 4940 | if (err < 0) |
| 4941 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4942 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
| 4943 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4944 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4945 | codec->patch_ops = alc_patch_ops; |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 4946 | codec->patch_ops.unsol_event = alc880_unsol_event; |
| 4947 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4948 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 4949 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 4950 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4951 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 4952 | |
| 4953 | error: |
| 4954 | alc_free(codec); |
| 4955 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4956 | } |
| 4957 | |
| 4958 | |
| 4959 | /* |
| 4960 | * ALC260 support |
| 4961 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4962 | static int alc260_parse_auto_config(struct hda_codec *codec) |
| 4963 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4964 | static const hda_nid_t alc260_ignore[] = { 0x17, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4965 | static const hda_nid_t alc260_ssids[] = { 0x10, 0x15, 0x0f, 0 }; |
| 4966 | return alc_parse_auto_config(codec, alc260_ignore, alc260_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4967 | } |
| 4968 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4969 | /* |
| 4970 | * Pin config fixes |
| 4971 | */ |
| 4972 | enum { |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 4973 | ALC260_FIXUP_HP_DC5750, |
| 4974 | ALC260_FIXUP_HP_PIN_0F, |
| 4975 | ALC260_FIXUP_COEF, |
Takashi Iwai | 15317ab | 2012-02-16 12:02:53 +0100 | [diff] [blame] | 4976 | ALC260_FIXUP_GPIO1, |
Takashi Iwai | 20f7d92 | 2012-02-16 12:35:16 +0100 | [diff] [blame] | 4977 | ALC260_FIXUP_GPIO1_TOGGLE, |
| 4978 | ALC260_FIXUP_REPLACER, |
Takashi Iwai | 0a1c4fa | 2012-02-16 12:42:30 +0100 | [diff] [blame] | 4979 | ALC260_FIXUP_HP_B1900, |
Takashi Iwai | 118cb4a | 2012-04-19 07:33:27 +0200 | [diff] [blame] | 4980 | ALC260_FIXUP_KN1, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4981 | }; |
| 4982 | |
Takashi Iwai | 20f7d92 | 2012-02-16 12:35:16 +0100 | [diff] [blame] | 4983 | static void alc260_gpio1_automute(struct hda_codec *codec) |
| 4984 | { |
| 4985 | struct alc_spec *spec = codec->spec; |
| 4986 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, |
| 4987 | spec->hp_jack_present); |
| 4988 | } |
| 4989 | |
| 4990 | static void alc260_fixup_gpio1_toggle(struct hda_codec *codec, |
| 4991 | const struct alc_fixup *fix, int action) |
| 4992 | { |
| 4993 | struct alc_spec *spec = codec->spec; |
| 4994 | if (action == ALC_FIXUP_ACT_PROBE) { |
| 4995 | /* although the machine has only one output pin, we need to |
| 4996 | * toggle GPIO1 according to the jack state |
| 4997 | */ |
| 4998 | spec->automute_hook = alc260_gpio1_automute; |
| 4999 | spec->detect_hp = 1; |
| 5000 | spec->automute_speaker = 1; |
| 5001 | spec->autocfg.hp_pins[0] = 0x0f; /* copy it for automute */ |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 5002 | snd_hda_jack_detect_enable_callback(codec, 0x0f, ALC_HP_EVENT, |
| 5003 | alc_hp_automute); |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 5004 | snd_hda_gen_add_verbs(&spec->gen, alc_gpio1_init_verbs); |
Takashi Iwai | 20f7d92 | 2012-02-16 12:35:16 +0100 | [diff] [blame] | 5005 | } |
| 5006 | } |
| 5007 | |
Takashi Iwai | 118cb4a | 2012-04-19 07:33:27 +0200 | [diff] [blame] | 5008 | static void alc260_fixup_kn1(struct hda_codec *codec, |
| 5009 | const struct alc_fixup *fix, int action) |
| 5010 | { |
| 5011 | struct alc_spec *spec = codec->spec; |
| 5012 | static const struct alc_pincfg pincfgs[] = { |
| 5013 | { 0x0f, 0x02214000 }, /* HP/speaker */ |
| 5014 | { 0x12, 0x90a60160 }, /* int mic */ |
| 5015 | { 0x13, 0x02a19000 }, /* ext mic */ |
| 5016 | { 0x18, 0x01446000 }, /* SPDIF out */ |
| 5017 | /* disable bogus I/O pins */ |
| 5018 | { 0x10, 0x411111f0 }, |
| 5019 | { 0x11, 0x411111f0 }, |
| 5020 | { 0x14, 0x411111f0 }, |
| 5021 | { 0x15, 0x411111f0 }, |
| 5022 | { 0x16, 0x411111f0 }, |
| 5023 | { 0x17, 0x411111f0 }, |
| 5024 | { 0x19, 0x411111f0 }, |
| 5025 | { } |
| 5026 | }; |
| 5027 | |
| 5028 | switch (action) { |
| 5029 | case ALC_FIXUP_ACT_PRE_PROBE: |
| 5030 | alc_apply_pincfgs(codec, pincfgs); |
| 5031 | break; |
| 5032 | case ALC_FIXUP_ACT_PROBE: |
| 5033 | spec->init_amp = ALC_INIT_NONE; |
| 5034 | break; |
| 5035 | } |
| 5036 | } |
| 5037 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5038 | static const struct alc_fixup alc260_fixups[] = { |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 5039 | [ALC260_FIXUP_HP_DC5750] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5040 | .type = ALC_FIXUP_PINS, |
| 5041 | .v.pins = (const struct alc_pincfg[]) { |
| 5042 | { 0x11, 0x90130110 }, /* speaker */ |
| 5043 | { } |
| 5044 | } |
| 5045 | }, |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 5046 | [ALC260_FIXUP_HP_PIN_0F] = { |
| 5047 | .type = ALC_FIXUP_PINS, |
| 5048 | .v.pins = (const struct alc_pincfg[]) { |
| 5049 | { 0x0f, 0x01214000 }, /* HP */ |
| 5050 | { } |
| 5051 | } |
| 5052 | }, |
| 5053 | [ALC260_FIXUP_COEF] = { |
| 5054 | .type = ALC_FIXUP_VERBS, |
| 5055 | .v.verbs = (const struct hda_verb[]) { |
| 5056 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5057 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3040 }, |
| 5058 | { } |
| 5059 | }, |
| 5060 | .chained = true, |
| 5061 | .chain_id = ALC260_FIXUP_HP_PIN_0F, |
| 5062 | }, |
Takashi Iwai | 15317ab | 2012-02-16 12:02:53 +0100 | [diff] [blame] | 5063 | [ALC260_FIXUP_GPIO1] = { |
| 5064 | .type = ALC_FIXUP_VERBS, |
| 5065 | .v.verbs = alc_gpio1_init_verbs, |
| 5066 | }, |
Takashi Iwai | 20f7d92 | 2012-02-16 12:35:16 +0100 | [diff] [blame] | 5067 | [ALC260_FIXUP_GPIO1_TOGGLE] = { |
| 5068 | .type = ALC_FIXUP_FUNC, |
| 5069 | .v.func = alc260_fixup_gpio1_toggle, |
| 5070 | .chained = true, |
| 5071 | .chain_id = ALC260_FIXUP_HP_PIN_0F, |
| 5072 | }, |
| 5073 | [ALC260_FIXUP_REPLACER] = { |
| 5074 | .type = ALC_FIXUP_VERBS, |
| 5075 | .v.verbs = (const struct hda_verb[]) { |
| 5076 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5077 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 }, |
| 5078 | { } |
| 5079 | }, |
| 5080 | .chained = true, |
| 5081 | .chain_id = ALC260_FIXUP_GPIO1_TOGGLE, |
| 5082 | }, |
Takashi Iwai | 0a1c4fa | 2012-02-16 12:42:30 +0100 | [diff] [blame] | 5083 | [ALC260_FIXUP_HP_B1900] = { |
| 5084 | .type = ALC_FIXUP_FUNC, |
| 5085 | .v.func = alc260_fixup_gpio1_toggle, |
| 5086 | .chained = true, |
| 5087 | .chain_id = ALC260_FIXUP_COEF, |
Takashi Iwai | 118cb4a | 2012-04-19 07:33:27 +0200 | [diff] [blame] | 5088 | }, |
| 5089 | [ALC260_FIXUP_KN1] = { |
| 5090 | .type = ALC_FIXUP_FUNC, |
| 5091 | .v.func = alc260_fixup_kn1, |
| 5092 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5093 | }; |
| 5094 | |
| 5095 | static const struct snd_pci_quirk alc260_fixup_tbl[] = { |
Takashi Iwai | 15317ab | 2012-02-16 12:02:53 +0100 | [diff] [blame] | 5096 | SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_FIXUP_GPIO1), |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 5097 | SND_PCI_QUIRK(0x1025, 0x007f, "Acer Aspire 9500", ALC260_FIXUP_COEF), |
Takashi Iwai | 15317ab | 2012-02-16 12:02:53 +0100 | [diff] [blame] | 5098 | SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_FIXUP_GPIO1), |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 5099 | SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", ALC260_FIXUP_HP_DC5750), |
Takashi Iwai | 0a1c4fa | 2012-02-16 12:42:30 +0100 | [diff] [blame] | 5100 | SND_PCI_QUIRK(0x103c, 0x30ba, "HP Presario B1900", ALC260_FIXUP_HP_B1900), |
Takashi Iwai | b1f5808 | 2012-02-16 12:45:03 +0100 | [diff] [blame] | 5101 | SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FIXUP_GPIO1), |
Takashi Iwai | 118cb4a | 2012-04-19 07:33:27 +0200 | [diff] [blame] | 5102 | SND_PCI_QUIRK(0x152d, 0x0729, "Quanta KN1", ALC260_FIXUP_KN1), |
Takashi Iwai | 20f7d92 | 2012-02-16 12:35:16 +0100 | [diff] [blame] | 5103 | SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_FIXUP_REPLACER), |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 5104 | SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_FIXUP_COEF), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5105 | {} |
| 5106 | }; |
| 5107 | |
| 5108 | /* |
| 5109 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5110 | static int patch_alc260(struct hda_codec *codec) |
| 5111 | { |
| 5112 | struct alc_spec *spec; |
Takashi Iwai | c3c2c9e | 2012-02-16 12:59:55 +0100 | [diff] [blame] | 5113 | int err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5114 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 5115 | err = alc_alloc_spec(codec, 0x07); |
| 5116 | if (err < 0) |
| 5117 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5118 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 5119 | spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5120 | |
Takashi Iwai | c3c2c9e | 2012-02-16 12:59:55 +0100 | [diff] [blame] | 5121 | alc_pick_fixup(codec, NULL, alc260_fixup_tbl, alc260_fixups); |
| 5122 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5123 | |
Takashi Iwai | c3c2c9e | 2012-02-16 12:59:55 +0100 | [diff] [blame] | 5124 | /* automatic parse from the BIOS config */ |
| 5125 | err = alc260_parse_auto_config(codec); |
| 5126 | if (err < 0) |
| 5127 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5128 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5129 | if (!spec->no_analog) { |
| 5130 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5131 | if (err < 0) |
| 5132 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5133 | set_beep_amp(spec, 0x07, 0x05, HDA_INPUT); |
| 5134 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5135 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5136 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5137 | spec->shutup = alc_eapd_shutup; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5138 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 5139 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 5140 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5141 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5142 | |
| 5143 | error: |
| 5144 | alc_free(codec); |
| 5145 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5146 | } |
| 5147 | |
| 5148 | |
| 5149 | /* |
| 5150 | * ALC882/883/885/888/889 support |
| 5151 | * |
| 5152 | * ALC882 is almost identical with ALC880 but has cleaner and more flexible |
| 5153 | * configuration. Each pin widget can choose any input DACs and a mixer. |
| 5154 | * Each ADC is connected from a mixer of all inputs. This makes possible |
| 5155 | * 6-channel independent captures. |
| 5156 | * |
| 5157 | * In addition, an independent DAC for the multi-playback (not used in this |
| 5158 | * driver yet). |
| 5159 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5160 | |
| 5161 | /* |
| 5162 | * Pin config fixes |
| 5163 | */ |
| 5164 | enum { |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5165 | ALC882_FIXUP_ABIT_AW9D_MAX, |
| 5166 | ALC882_FIXUP_LENOVO_Y530, |
| 5167 | ALC882_FIXUP_PB_M5210, |
| 5168 | ALC882_FIXUP_ACER_ASPIRE_7736, |
| 5169 | ALC882_FIXUP_ASUS_W90V, |
Marton Balint | 8f23921 | 2012-03-05 21:33:23 +0100 | [diff] [blame] | 5170 | ALC889_FIXUP_CD, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5171 | ALC889_FIXUP_VAIO_TT, |
Takashi Iwai | 0e7cc2e | 2011-11-09 12:42:48 +0100 | [diff] [blame] | 5172 | ALC888_FIXUP_EEE1601, |
Takashi Iwai | 177943a | 2011-11-09 12:55:18 +0100 | [diff] [blame] | 5173 | ALC882_FIXUP_EAPD, |
Takashi Iwai | 7a6069b | 2011-11-09 15:22:01 +0100 | [diff] [blame] | 5174 | ALC883_FIXUP_EAPD, |
Takashi Iwai | 8812c4f | 2011-11-09 17:39:15 +0100 | [diff] [blame] | 5175 | ALC883_FIXUP_ACER_EAPD, |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5176 | ALC882_FIXUP_GPIO1, |
| 5177 | ALC882_FIXUP_GPIO2, |
Takashi Iwai | eb844d5 | 2011-11-09 18:03:07 +0100 | [diff] [blame] | 5178 | ALC882_FIXUP_GPIO3, |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 5179 | ALC889_FIXUP_COEF, |
| 5180 | ALC882_FIXUP_ASUS_W2JC, |
Takashi Iwai | c3e837b | 2011-11-10 16:01:47 +0100 | [diff] [blame] | 5181 | ALC882_FIXUP_ACER_ASPIRE_4930G, |
| 5182 | ALC882_FIXUP_ACER_ASPIRE_8930G, |
| 5183 | ALC882_FIXUP_ASPIRE_8930G_VERBS, |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5184 | ALC885_FIXUP_MACPRO_GPIO, |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5185 | ALC889_FIXUP_DAC_ROUTE, |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5186 | ALC889_FIXUP_MBP_VREF, |
| 5187 | ALC889_FIXUP_IMAC91_VREF, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5188 | ALC882_FIXUP_INV_DMIC, |
Takashi Iwai | e427c23 | 2012-07-29 10:04:08 +0200 | [diff] [blame] | 5189 | ALC882_FIXUP_NO_PRIMARY_HP, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5190 | }; |
| 5191 | |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 5192 | static void alc889_fixup_coef(struct hda_codec *codec, |
| 5193 | const struct alc_fixup *fix, int action) |
| 5194 | { |
| 5195 | if (action != ALC_FIXUP_ACT_INIT) |
| 5196 | return; |
| 5197 | alc889_coef_init(codec); |
| 5198 | } |
| 5199 | |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5200 | /* toggle speaker-output according to the hp-jack state */ |
| 5201 | static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted) |
| 5202 | { |
| 5203 | unsigned int gpiostate, gpiomask, gpiodir; |
| 5204 | |
| 5205 | gpiostate = snd_hda_codec_read(codec, codec->afg, 0, |
| 5206 | AC_VERB_GET_GPIO_DATA, 0); |
| 5207 | |
| 5208 | if (!muted) |
| 5209 | gpiostate |= (1 << pin); |
| 5210 | else |
| 5211 | gpiostate &= ~(1 << pin); |
| 5212 | |
| 5213 | gpiomask = snd_hda_codec_read(codec, codec->afg, 0, |
| 5214 | AC_VERB_GET_GPIO_MASK, 0); |
| 5215 | gpiomask |= (1 << pin); |
| 5216 | |
| 5217 | gpiodir = snd_hda_codec_read(codec, codec->afg, 0, |
| 5218 | AC_VERB_GET_GPIO_DIRECTION, 0); |
| 5219 | gpiodir |= (1 << pin); |
| 5220 | |
| 5221 | |
| 5222 | snd_hda_codec_write(codec, codec->afg, 0, |
| 5223 | AC_VERB_SET_GPIO_MASK, gpiomask); |
| 5224 | snd_hda_codec_write(codec, codec->afg, 0, |
| 5225 | AC_VERB_SET_GPIO_DIRECTION, gpiodir); |
| 5226 | |
| 5227 | msleep(1); |
| 5228 | |
| 5229 | snd_hda_codec_write(codec, codec->afg, 0, |
| 5230 | AC_VERB_SET_GPIO_DATA, gpiostate); |
| 5231 | } |
| 5232 | |
| 5233 | /* set up GPIO at initialization */ |
| 5234 | static void alc885_fixup_macpro_gpio(struct hda_codec *codec, |
| 5235 | const struct alc_fixup *fix, int action) |
| 5236 | { |
| 5237 | if (action != ALC_FIXUP_ACT_INIT) |
| 5238 | return; |
| 5239 | alc882_gpio_mute(codec, 0, 0); |
| 5240 | alc882_gpio_mute(codec, 1, 0); |
| 5241 | } |
| 5242 | |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5243 | /* Fix the connection of some pins for ALC889: |
| 5244 | * At least, Acer Aspire 5935 shows the connections to DAC3/4 don't |
| 5245 | * work correctly (bko#42740) |
| 5246 | */ |
| 5247 | static void alc889_fixup_dac_route(struct hda_codec *codec, |
| 5248 | const struct alc_fixup *fix, int action) |
| 5249 | { |
| 5250 | if (action == ALC_FIXUP_ACT_PRE_PROBE) { |
Takashi Iwai | ef8d60f | 2012-02-17 10:12:38 +0100 | [diff] [blame] | 5251 | /* fake the connections during parsing the tree */ |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5252 | hda_nid_t conn1[2] = { 0x0c, 0x0d }; |
| 5253 | hda_nid_t conn2[2] = { 0x0e, 0x0f }; |
| 5254 | snd_hda_override_conn_list(codec, 0x14, 2, conn1); |
| 5255 | snd_hda_override_conn_list(codec, 0x15, 2, conn1); |
| 5256 | snd_hda_override_conn_list(codec, 0x18, 2, conn2); |
| 5257 | snd_hda_override_conn_list(codec, 0x1a, 2, conn2); |
Takashi Iwai | ef8d60f | 2012-02-17 10:12:38 +0100 | [diff] [blame] | 5258 | } else if (action == ALC_FIXUP_ACT_PROBE) { |
| 5259 | /* restore the connections */ |
| 5260 | hda_nid_t conn[5] = { 0x0c, 0x0d, 0x0e, 0x0f, 0x26 }; |
| 5261 | snd_hda_override_conn_list(codec, 0x14, 5, conn); |
| 5262 | snd_hda_override_conn_list(codec, 0x15, 5, conn); |
| 5263 | snd_hda_override_conn_list(codec, 0x18, 5, conn); |
| 5264 | snd_hda_override_conn_list(codec, 0x1a, 5, conn); |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5265 | } |
| 5266 | } |
| 5267 | |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5268 | /* Set VREF on HP pin */ |
| 5269 | static void alc889_fixup_mbp_vref(struct hda_codec *codec, |
| 5270 | const struct alc_fixup *fix, int action) |
| 5271 | { |
| 5272 | struct alc_spec *spec = codec->spec; |
| 5273 | static hda_nid_t nids[2] = { 0x14, 0x15 }; |
| 5274 | int i; |
| 5275 | |
| 5276 | if (action != ALC_FIXUP_ACT_INIT) |
| 5277 | return; |
| 5278 | for (i = 0; i < ARRAY_SIZE(nids); i++) { |
| 5279 | unsigned int val = snd_hda_codec_get_pincfg(codec, nids[i]); |
| 5280 | if (get_defcfg_device(val) != AC_JACK_HP_OUT) |
| 5281 | continue; |
| 5282 | val = snd_hda_codec_read(codec, nids[i], 0, |
| 5283 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 5284 | val |= AC_PINCTL_VREF_80; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 5285 | snd_hda_set_pin_ctl(codec, nids[i], val); |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5286 | spec->keep_vref_in_automute = 1; |
| 5287 | break; |
| 5288 | } |
| 5289 | } |
| 5290 | |
| 5291 | /* Set VREF on speaker pins on imac91 */ |
| 5292 | static void alc889_fixup_imac91_vref(struct hda_codec *codec, |
| 5293 | const struct alc_fixup *fix, int action) |
| 5294 | { |
| 5295 | struct alc_spec *spec = codec->spec; |
| 5296 | static hda_nid_t nids[2] = { 0x18, 0x1a }; |
| 5297 | int i; |
| 5298 | |
| 5299 | if (action != ALC_FIXUP_ACT_INIT) |
| 5300 | return; |
| 5301 | for (i = 0; i < ARRAY_SIZE(nids); i++) { |
| 5302 | unsigned int val; |
| 5303 | val = snd_hda_codec_read(codec, nids[i], 0, |
| 5304 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 5305 | val |= AC_PINCTL_VREF_50; |
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 | } |
| 5308 | spec->keep_vref_in_automute = 1; |
| 5309 | } |
| 5310 | |
Takashi Iwai | e427c23 | 2012-07-29 10:04:08 +0200 | [diff] [blame] | 5311 | /* Don't take HP output as primary |
| 5312 | * strangely, the speaker output doesn't work on VAIO Z through DAC 0x05 |
| 5313 | */ |
| 5314 | static void alc882_fixup_no_primary_hp(struct hda_codec *codec, |
| 5315 | const struct alc_fixup *fix, int action) |
| 5316 | { |
| 5317 | struct alc_spec *spec = codec->spec; |
| 5318 | if (action == ALC_FIXUP_ACT_PRE_PROBE) |
| 5319 | spec->no_primary_hp = 1; |
| 5320 | } |
| 5321 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5322 | static const struct alc_fixup alc882_fixups[] = { |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5323 | [ALC882_FIXUP_ABIT_AW9D_MAX] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5324 | .type = ALC_FIXUP_PINS, |
| 5325 | .v.pins = (const struct alc_pincfg[]) { |
| 5326 | { 0x15, 0x01080104 }, /* side */ |
| 5327 | { 0x16, 0x01011012 }, /* rear */ |
| 5328 | { 0x17, 0x01016011 }, /* clfe */ |
| 5329 | { } |
| 5330 | } |
| 5331 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5332 | [ALC882_FIXUP_LENOVO_Y530] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5333 | .type = ALC_FIXUP_PINS, |
| 5334 | .v.pins = (const struct alc_pincfg[]) { |
| 5335 | { 0x15, 0x99130112 }, /* rear int speakers */ |
| 5336 | { 0x16, 0x99130111 }, /* subwoofer */ |
| 5337 | { } |
| 5338 | } |
| 5339 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5340 | [ALC882_FIXUP_PB_M5210] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5341 | .type = ALC_FIXUP_VERBS, |
| 5342 | .v.verbs = (const struct hda_verb[]) { |
| 5343 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 }, |
| 5344 | {} |
| 5345 | } |
| 5346 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5347 | [ALC882_FIXUP_ACER_ASPIRE_7736] = { |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 5348 | .type = ALC_FIXUP_FUNC, |
| 5349 | .v.func = alc_fixup_sku_ignore, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5350 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5351 | [ALC882_FIXUP_ASUS_W90V] = { |
Takashi Iwai | 5cdf745 | 2011-10-26 23:04:08 +0200 | [diff] [blame] | 5352 | .type = ALC_FIXUP_PINS, |
| 5353 | .v.pins = (const struct alc_pincfg[]) { |
| 5354 | { 0x16, 0x99130110 }, /* fix sequence for CLFE */ |
| 5355 | { } |
| 5356 | } |
| 5357 | }, |
Marton Balint | 8f23921 | 2012-03-05 21:33:23 +0100 | [diff] [blame] | 5358 | [ALC889_FIXUP_CD] = { |
| 5359 | .type = ALC_FIXUP_PINS, |
| 5360 | .v.pins = (const struct alc_pincfg[]) { |
| 5361 | { 0x1c, 0x993301f0 }, /* CD */ |
| 5362 | { } |
| 5363 | } |
| 5364 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5365 | [ALC889_FIXUP_VAIO_TT] = { |
| 5366 | .type = ALC_FIXUP_PINS, |
| 5367 | .v.pins = (const struct alc_pincfg[]) { |
| 5368 | { 0x17, 0x90170111 }, /* hidden surround speaker */ |
| 5369 | { } |
| 5370 | } |
| 5371 | }, |
Takashi Iwai | 0e7cc2e | 2011-11-09 12:42:48 +0100 | [diff] [blame] | 5372 | [ALC888_FIXUP_EEE1601] = { |
| 5373 | .type = ALC_FIXUP_VERBS, |
| 5374 | .v.verbs = (const struct hda_verb[]) { |
| 5375 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b }, |
| 5376 | { 0x20, AC_VERB_SET_PROC_COEF, 0x0838 }, |
| 5377 | { } |
| 5378 | } |
Takashi Iwai | 177943a | 2011-11-09 12:55:18 +0100 | [diff] [blame] | 5379 | }, |
| 5380 | [ALC882_FIXUP_EAPD] = { |
| 5381 | .type = ALC_FIXUP_VERBS, |
| 5382 | .v.verbs = (const struct hda_verb[]) { |
| 5383 | /* change to EAPD mode */ |
| 5384 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5385 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 }, |
| 5386 | { } |
| 5387 | } |
| 5388 | }, |
Takashi Iwai | 7a6069b | 2011-11-09 15:22:01 +0100 | [diff] [blame] | 5389 | [ALC883_FIXUP_EAPD] = { |
| 5390 | .type = ALC_FIXUP_VERBS, |
| 5391 | .v.verbs = (const struct hda_verb[]) { |
| 5392 | /* change to EAPD mode */ |
| 5393 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5394 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 }, |
| 5395 | { } |
| 5396 | } |
| 5397 | }, |
Takashi Iwai | 8812c4f | 2011-11-09 17:39:15 +0100 | [diff] [blame] | 5398 | [ALC883_FIXUP_ACER_EAPD] = { |
| 5399 | .type = ALC_FIXUP_VERBS, |
| 5400 | .v.verbs = (const struct hda_verb[]) { |
| 5401 | /* eanable EAPD on Acer laptops */ |
| 5402 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5403 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 }, |
| 5404 | { } |
| 5405 | } |
| 5406 | }, |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5407 | [ALC882_FIXUP_GPIO1] = { |
| 5408 | .type = ALC_FIXUP_VERBS, |
| 5409 | .v.verbs = alc_gpio1_init_verbs, |
| 5410 | }, |
| 5411 | [ALC882_FIXUP_GPIO2] = { |
| 5412 | .type = ALC_FIXUP_VERBS, |
| 5413 | .v.verbs = alc_gpio2_init_verbs, |
| 5414 | }, |
Takashi Iwai | eb844d5 | 2011-11-09 18:03:07 +0100 | [diff] [blame] | 5415 | [ALC882_FIXUP_GPIO3] = { |
| 5416 | .type = ALC_FIXUP_VERBS, |
| 5417 | .v.verbs = alc_gpio3_init_verbs, |
| 5418 | }, |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 5419 | [ALC882_FIXUP_ASUS_W2JC] = { |
| 5420 | .type = ALC_FIXUP_VERBS, |
| 5421 | .v.verbs = alc_gpio1_init_verbs, |
| 5422 | .chained = true, |
| 5423 | .chain_id = ALC882_FIXUP_EAPD, |
| 5424 | }, |
| 5425 | [ALC889_FIXUP_COEF] = { |
| 5426 | .type = ALC_FIXUP_FUNC, |
| 5427 | .v.func = alc889_fixup_coef, |
| 5428 | }, |
Takashi Iwai | c3e837b | 2011-11-10 16:01:47 +0100 | [diff] [blame] | 5429 | [ALC882_FIXUP_ACER_ASPIRE_4930G] = { |
| 5430 | .type = ALC_FIXUP_PINS, |
| 5431 | .v.pins = (const struct alc_pincfg[]) { |
| 5432 | { 0x16, 0x99130111 }, /* CLFE speaker */ |
| 5433 | { 0x17, 0x99130112 }, /* surround speaker */ |
| 5434 | { } |
Takashi Iwai | 038d4fe | 2012-04-11 17:18:12 +0200 | [diff] [blame] | 5435 | }, |
| 5436 | .chained = true, |
| 5437 | .chain_id = ALC882_FIXUP_GPIO1, |
Takashi Iwai | c3e837b | 2011-11-10 16:01:47 +0100 | [diff] [blame] | 5438 | }, |
| 5439 | [ALC882_FIXUP_ACER_ASPIRE_8930G] = { |
| 5440 | .type = ALC_FIXUP_PINS, |
| 5441 | .v.pins = (const struct alc_pincfg[]) { |
| 5442 | { 0x16, 0x99130111 }, /* CLFE speaker */ |
| 5443 | { 0x1b, 0x99130112 }, /* surround speaker */ |
| 5444 | { } |
| 5445 | }, |
| 5446 | .chained = true, |
| 5447 | .chain_id = ALC882_FIXUP_ASPIRE_8930G_VERBS, |
| 5448 | }, |
| 5449 | [ALC882_FIXUP_ASPIRE_8930G_VERBS] = { |
| 5450 | /* additional init verbs for Acer Aspire 8930G */ |
| 5451 | .type = ALC_FIXUP_VERBS, |
| 5452 | .v.verbs = (const struct hda_verb[]) { |
| 5453 | /* Enable all DACs */ |
| 5454 | /* DAC DISABLE/MUTE 1? */ |
| 5455 | /* setting bits 1-5 disables DAC nids 0x02-0x06 |
| 5456 | * apparently. Init=0x38 */ |
| 5457 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x03 }, |
| 5458 | { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 }, |
| 5459 | /* DAC DISABLE/MUTE 2? */ |
| 5460 | /* some bit here disables the other DACs. |
| 5461 | * Init=0x4900 */ |
| 5462 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x08 }, |
| 5463 | { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 }, |
| 5464 | /* DMIC fix |
| 5465 | * This laptop has a stereo digital microphone. |
| 5466 | * The mics are only 1cm apart which makes the stereo |
| 5467 | * useless. However, either the mic or the ALC889 |
| 5468 | * makes the signal become a difference/sum signal |
| 5469 | * instead of standard stereo, which is annoying. |
| 5470 | * So instead we flip this bit which makes the |
| 5471 | * codec replicate the sum signal to both channels, |
| 5472 | * turning it into a normal mono mic. |
| 5473 | */ |
| 5474 | /* DMIC_CONTROL? Init value = 0x0001 */ |
| 5475 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b }, |
| 5476 | { 0x20, AC_VERB_SET_PROC_COEF, 0x0003 }, |
| 5477 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5478 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 }, |
| 5479 | { } |
Takashi Iwai | 038d4fe | 2012-04-11 17:18:12 +0200 | [diff] [blame] | 5480 | }, |
| 5481 | .chained = true, |
| 5482 | .chain_id = ALC882_FIXUP_GPIO1, |
Takashi Iwai | c3e837b | 2011-11-10 16:01:47 +0100 | [diff] [blame] | 5483 | }, |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5484 | [ALC885_FIXUP_MACPRO_GPIO] = { |
| 5485 | .type = ALC_FIXUP_FUNC, |
| 5486 | .v.func = alc885_fixup_macpro_gpio, |
| 5487 | }, |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5488 | [ALC889_FIXUP_DAC_ROUTE] = { |
| 5489 | .type = ALC_FIXUP_FUNC, |
| 5490 | .v.func = alc889_fixup_dac_route, |
| 5491 | }, |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5492 | [ALC889_FIXUP_MBP_VREF] = { |
| 5493 | .type = ALC_FIXUP_FUNC, |
| 5494 | .v.func = alc889_fixup_mbp_vref, |
| 5495 | .chained = true, |
| 5496 | .chain_id = ALC882_FIXUP_GPIO1, |
| 5497 | }, |
| 5498 | [ALC889_FIXUP_IMAC91_VREF] = { |
| 5499 | .type = ALC_FIXUP_FUNC, |
| 5500 | .v.func = alc889_fixup_imac91_vref, |
| 5501 | .chained = true, |
| 5502 | .chain_id = ALC882_FIXUP_GPIO1, |
| 5503 | }, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5504 | [ALC882_FIXUP_INV_DMIC] = { |
| 5505 | .type = ALC_FIXUP_FUNC, |
| 5506 | .v.func = alc_fixup_inv_dmic_0x12, |
| 5507 | }, |
Takashi Iwai | e427c23 | 2012-07-29 10:04:08 +0200 | [diff] [blame] | 5508 | [ALC882_FIXUP_NO_PRIMARY_HP] = { |
| 5509 | .type = ALC_FIXUP_FUNC, |
| 5510 | .v.func = alc882_fixup_no_primary_hp, |
| 5511 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5512 | }; |
| 5513 | |
| 5514 | static const struct snd_pci_quirk alc882_fixup_tbl[] = { |
Takashi Iwai | 8812c4f | 2011-11-09 17:39:15 +0100 | [diff] [blame] | 5515 | SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_FIXUP_ACER_EAPD), |
| 5516 | SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_FIXUP_ACER_EAPD), |
| 5517 | SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_FIXUP_ACER_EAPD), |
| 5518 | SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_FIXUP_ACER_EAPD), |
| 5519 | SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_FIXUP_ACER_EAPD), |
| 5520 | SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_FIXUP_ACER_EAPD), |
Takashi Iwai | c3e837b | 2011-11-10 16:01:47 +0100 | [diff] [blame] | 5521 | SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G", |
| 5522 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
| 5523 | SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G", |
| 5524 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
| 5525 | SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G", |
| 5526 | ALC882_FIXUP_ACER_ASPIRE_8930G), |
| 5527 | SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G", |
| 5528 | ALC882_FIXUP_ACER_ASPIRE_8930G), |
| 5529 | SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G", |
| 5530 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
| 5531 | SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G", |
| 5532 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
| 5533 | SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G", |
| 5534 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5535 | SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", ALC882_FIXUP_PB_M5210), |
Takashi Iwai | f5c53d8 | 2012-05-07 10:07:33 +0200 | [diff] [blame] | 5536 | SND_PCI_QUIRK(0x1025, 0x021e, "Acer Aspire 5739G", |
| 5537 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5538 | SND_PCI_QUIRK(0x1025, 0x0259, "Acer Aspire 5935", ALC889_FIXUP_DAC_ROUTE), |
Takashi Iwai | fe97da1 | 2012-04-12 08:00:19 +0200 | [diff] [blame] | 5539 | 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] | 5540 | 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] | 5541 | SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_FIXUP_EAPD), |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5542 | SND_PCI_QUIRK(0x1043, 0x1873, "ASUS W90V", ALC882_FIXUP_ASUS_W90V), |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 5543 | SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_FIXUP_ASUS_W2JC), |
Takashi Iwai | 0e7cc2e | 2011-11-09 12:42:48 +0100 | [diff] [blame] | 5544 | SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601), |
Takashi Iwai | ac9b1cd | 2011-11-09 17:45:55 +0100 | [diff] [blame] | 5545 | SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT), |
Takashi Iwai | e427c23 | 2012-07-29 10:04:08 +0200 | [diff] [blame] | 5546 | 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] | 5547 | |
| 5548 | /* All Apple entries are in codec SSIDs */ |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5549 | SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC889_FIXUP_MBP_VREF), |
| 5550 | SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC889_FIXUP_MBP_VREF), |
| 5551 | SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF), |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5552 | SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_FIXUP_MACPRO_GPIO), |
| 5553 | SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_FIXUP_MACPRO_GPIO), |
| 5554 | SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_FIXUP_MACPRO_GPIO), |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5555 | SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC889_FIXUP_MBP_VREF), |
| 5556 | SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889_FIXUP_MBP_VREF), |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5557 | SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_FIXUP_EAPD), |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5558 | SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC889_FIXUP_MBP_VREF), |
| 5559 | SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC889_FIXUP_MBP_VREF), |
| 5560 | SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889_FIXUP_MBP_VREF), |
| 5561 | SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF), |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5562 | SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_FIXUP_MACPRO_GPIO), |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5563 | SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC889_FIXUP_IMAC91_VREF), |
| 5564 | SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC889_FIXUP_IMAC91_VREF), |
| 5565 | SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC889_FIXUP_IMAC91_VREF), |
Josh Boyer | 29ebe40 | 2012-04-12 13:55:36 -0400 | [diff] [blame] | 5566 | 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] | 5567 | SND_PCI_QUIRK(0x106b, 0x4300, "iMac 9,1", ALC889_FIXUP_IMAC91_VREF), |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5568 | SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC889_FIXUP_IMAC91_VREF), |
| 5569 | SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC889_FIXUP_IMAC91_VREF), |
| 5570 | SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC889_FIXUP_IMAC91_VREF), |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5571 | |
Takashi Iwai | 7a6069b | 2011-11-09 15:22:01 +0100 | [diff] [blame] | 5572 | SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC882_FIXUP_EAPD), |
Takashi Iwai | bca4013 | 2012-05-07 11:13:14 +0200 | [diff] [blame] | 5573 | SND_PCI_QUIRK(0x1462, 0x7350, "MSI-7350", ALC889_FIXUP_CD), |
Takashi Iwai | eb844d5 | 2011-11-09 18:03:07 +0100 | [diff] [blame] | 5574 | SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3), |
Marton Balint | 8f23921 | 2012-03-05 21:33:23 +0100 | [diff] [blame] | 5575 | SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte EP45-DS3", ALC889_FIXUP_CD), |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5576 | 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] | 5577 | SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC882_FIXUP_EAPD), |
| 5578 | SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_FIXUP_EAPD), |
Takashi Iwai | ac9b1cd | 2011-11-09 17:45:55 +0100 | [diff] [blame] | 5579 | SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", ALC882_FIXUP_LENOVO_Y530), |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 5580 | SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_FIXUP_COEF), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5581 | {} |
| 5582 | }; |
| 5583 | |
Takashi Iwai | 912093b | 2012-04-11 14:03:41 +0200 | [diff] [blame] | 5584 | static const struct alc_model_fixup alc882_fixup_models[] = { |
| 5585 | {.id = ALC882_FIXUP_ACER_ASPIRE_4930G, .name = "acer-aspire-4930g"}, |
| 5586 | {.id = ALC882_FIXUP_ACER_ASPIRE_8930G, .name = "acer-aspire-8930g"}, |
| 5587 | {.id = ALC883_FIXUP_ACER_EAPD, .name = "acer-aspire"}, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5588 | {.id = ALC882_FIXUP_INV_DMIC, .name = "inv-dmic"}, |
Takashi Iwai | e427c23 | 2012-07-29 10:04:08 +0200 | [diff] [blame] | 5589 | {.id = ALC882_FIXUP_NO_PRIMARY_HP, .name = "no-primary-hp"}, |
Takashi Iwai | 912093b | 2012-04-11 14:03:41 +0200 | [diff] [blame] | 5590 | {} |
| 5591 | }; |
| 5592 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5593 | /* |
| 5594 | * BIOS auto configuration |
| 5595 | */ |
| 5596 | /* almost identical with ALC880 parser... */ |
| 5597 | static int alc882_parse_auto_config(struct hda_codec *codec) |
| 5598 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5599 | static const hda_nid_t alc882_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5600 | static const hda_nid_t alc882_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 5601 | return alc_parse_auto_config(codec, alc882_ignore, alc882_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5602 | } |
| 5603 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5604 | /* |
| 5605 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5606 | static int patch_alc882(struct hda_codec *codec) |
| 5607 | { |
| 5608 | struct alc_spec *spec; |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5609 | int err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5610 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 5611 | err = alc_alloc_spec(codec, 0x0b); |
| 5612 | if (err < 0) |
| 5613 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5614 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 5615 | spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5616 | |
| 5617 | switch (codec->vendor_id) { |
| 5618 | case 0x10ec0882: |
| 5619 | case 0x10ec0885: |
| 5620 | break; |
| 5621 | default: |
| 5622 | /* ALC883 and variants */ |
| 5623 | alc_fix_pll_init(codec, 0x20, 0x0a, 10); |
| 5624 | break; |
| 5625 | } |
| 5626 | |
Takashi Iwai | 912093b | 2012-04-11 14:03:41 +0200 | [diff] [blame] | 5627 | alc_pick_fixup(codec, alc882_fixup_models, alc882_fixup_tbl, |
| 5628 | alc882_fixups); |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5629 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5630 | |
| 5631 | alc_auto_parse_customize_define(codec); |
| 5632 | |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5633 | /* automatic parse from the BIOS config */ |
| 5634 | err = alc882_parse_auto_config(codec); |
| 5635 | if (err < 0) |
| 5636 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5637 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5638 | if (!spec->no_analog && has_cdefine_beep(codec)) { |
| 5639 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5640 | if (err < 0) |
| 5641 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5642 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5643 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5644 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5645 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5646 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 5647 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 5648 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5649 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5650 | |
| 5651 | error: |
| 5652 | alc_free(codec); |
| 5653 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5654 | } |
| 5655 | |
| 5656 | |
| 5657 | /* |
| 5658 | * ALC262 support |
| 5659 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5660 | static int alc262_parse_auto_config(struct hda_codec *codec) |
| 5661 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5662 | static const hda_nid_t alc262_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5663 | static const hda_nid_t alc262_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 5664 | return alc_parse_auto_config(codec, alc262_ignore, alc262_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5665 | } |
| 5666 | |
| 5667 | /* |
| 5668 | * Pin config fixes |
| 5669 | */ |
| 5670 | enum { |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5671 | ALC262_FIXUP_FSC_H270, |
| 5672 | ALC262_FIXUP_HP_Z200, |
| 5673 | ALC262_FIXUP_TYAN, |
Takashi Iwai | c470150 | 2011-11-07 14:20:07 +0100 | [diff] [blame] | 5674 | ALC262_FIXUP_LENOVO_3000, |
Takashi Iwai | b42590b | 2011-11-07 14:41:01 +0100 | [diff] [blame] | 5675 | ALC262_FIXUP_BENQ, |
| 5676 | ALC262_FIXUP_BENQ_T31, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5677 | ALC262_FIXUP_INV_DMIC, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5678 | }; |
| 5679 | |
| 5680 | static const struct alc_fixup alc262_fixups[] = { |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5681 | [ALC262_FIXUP_FSC_H270] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5682 | .type = ALC_FIXUP_PINS, |
| 5683 | .v.pins = (const struct alc_pincfg[]) { |
| 5684 | { 0x14, 0x99130110 }, /* speaker */ |
| 5685 | { 0x15, 0x0221142f }, /* front HP */ |
| 5686 | { 0x1b, 0x0121141f }, /* rear HP */ |
| 5687 | { } |
| 5688 | } |
| 5689 | }, |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5690 | [ALC262_FIXUP_HP_Z200] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5691 | .type = ALC_FIXUP_PINS, |
| 5692 | .v.pins = (const struct alc_pincfg[]) { |
| 5693 | { 0x16, 0x99130120 }, /* internal speaker */ |
| 5694 | { } |
| 5695 | } |
| 5696 | }, |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5697 | [ALC262_FIXUP_TYAN] = { |
| 5698 | .type = ALC_FIXUP_PINS, |
| 5699 | .v.pins = (const struct alc_pincfg[]) { |
| 5700 | { 0x14, 0x1993e1f0 }, /* int AUX */ |
| 5701 | { } |
| 5702 | } |
| 5703 | }, |
Takashi Iwai | c470150 | 2011-11-07 14:20:07 +0100 | [diff] [blame] | 5704 | [ALC262_FIXUP_LENOVO_3000] = { |
| 5705 | .type = ALC_FIXUP_VERBS, |
| 5706 | .v.verbs = (const struct hda_verb[]) { |
| 5707 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 }, |
Takashi Iwai | b42590b | 2011-11-07 14:41:01 +0100 | [diff] [blame] | 5708 | {} |
| 5709 | }, |
| 5710 | .chained = true, |
| 5711 | .chain_id = ALC262_FIXUP_BENQ, |
| 5712 | }, |
| 5713 | [ALC262_FIXUP_BENQ] = { |
| 5714 | .type = ALC_FIXUP_VERBS, |
| 5715 | .v.verbs = (const struct hda_verb[]) { |
Takashi Iwai | c470150 | 2011-11-07 14:20:07 +0100 | [diff] [blame] | 5716 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5717 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 }, |
| 5718 | {} |
| 5719 | } |
| 5720 | }, |
Takashi Iwai | b42590b | 2011-11-07 14:41:01 +0100 | [diff] [blame] | 5721 | [ALC262_FIXUP_BENQ_T31] = { |
| 5722 | .type = ALC_FIXUP_VERBS, |
| 5723 | .v.verbs = (const struct hda_verb[]) { |
| 5724 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5725 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 }, |
| 5726 | {} |
| 5727 | } |
| 5728 | }, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5729 | [ALC262_FIXUP_INV_DMIC] = { |
| 5730 | .type = ALC_FIXUP_FUNC, |
| 5731 | .v.func = alc_fixup_inv_dmic_0x12, |
| 5732 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5733 | }; |
| 5734 | |
| 5735 | static const struct snd_pci_quirk alc262_fixup_tbl[] = { |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5736 | SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200", ALC262_FIXUP_HP_Z200), |
Takashi Iwai | 3dcd3be | 2011-11-07 14:59:40 +0100 | [diff] [blame] | 5737 | SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FIXUP_BENQ), |
| 5738 | SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FIXUP_BENQ), |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5739 | SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_FIXUP_TYAN), |
| 5740 | SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", ALC262_FIXUP_FSC_H270), |
Takashi Iwai | c470150 | 2011-11-07 14:20:07 +0100 | [diff] [blame] | 5741 | SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000", ALC262_FIXUP_LENOVO_3000), |
Takashi Iwai | b42590b | 2011-11-07 14:41:01 +0100 | [diff] [blame] | 5742 | SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_FIXUP_BENQ), |
| 5743 | SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_FIXUP_BENQ_T31), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5744 | {} |
| 5745 | }; |
| 5746 | |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5747 | static const struct alc_model_fixup alc262_fixup_models[] = { |
| 5748 | {.id = ALC262_FIXUP_INV_DMIC, .name = "inv-dmic"}, |
| 5749 | {} |
| 5750 | }; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5751 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5752 | /* |
| 5753 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5754 | static int patch_alc262(struct hda_codec *codec) |
| 5755 | { |
| 5756 | struct alc_spec *spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5757 | int err; |
| 5758 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 5759 | err = alc_alloc_spec(codec, 0x0b); |
| 5760 | if (err < 0) |
| 5761 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5762 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 5763 | spec = codec->spec; |
Takashi Iwai | 37c0420 | 2012-12-18 14:22:45 +0100 | [diff] [blame] | 5764 | spec->shared_mic_vref_pin = 0x18; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5765 | |
| 5766 | #if 0 |
| 5767 | /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is |
| 5768 | * under-run |
| 5769 | */ |
| 5770 | { |
| 5771 | int tmp; |
| 5772 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); |
| 5773 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); |
| 5774 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); |
| 5775 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80); |
| 5776 | } |
| 5777 | #endif |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5778 | alc_fix_pll_init(codec, 0x20, 0x0a, 10); |
| 5779 | |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5780 | alc_pick_fixup(codec, alc262_fixup_models, alc262_fixup_tbl, |
| 5781 | alc262_fixups); |
Takashi Iwai | 42399f7 | 2011-11-07 17:18:44 +0100 | [diff] [blame] | 5782 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5783 | |
Takashi Iwai | af741c1 | 2012-05-07 18:09:48 +0200 | [diff] [blame] | 5784 | alc_auto_parse_customize_define(codec); |
| 5785 | |
Takashi Iwai | 42399f7 | 2011-11-07 17:18:44 +0100 | [diff] [blame] | 5786 | /* automatic parse from the BIOS config */ |
| 5787 | err = alc262_parse_auto_config(codec); |
| 5788 | if (err < 0) |
| 5789 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5790 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5791 | if (!spec->no_analog && has_cdefine_beep(codec)) { |
| 5792 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5793 | if (err < 0) |
| 5794 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5795 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5796 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5797 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5798 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5799 | spec->shutup = alc_eapd_shutup; |
| 5800 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 5801 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 5802 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5803 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5804 | |
| 5805 | error: |
| 5806 | alc_free(codec); |
| 5807 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5808 | } |
| 5809 | |
| 5810 | /* |
| 5811 | * ALC268 |
| 5812 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5813 | /* bind Beep switches of both NID 0x0f and 0x10 */ |
| 5814 | static const struct hda_bind_ctls alc268_bind_beep_sw = { |
| 5815 | .ops = &snd_hda_bind_sw, |
| 5816 | .values = { |
| 5817 | HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT), |
| 5818 | HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT), |
| 5819 | 0 |
| 5820 | }, |
| 5821 | }; |
| 5822 | |
| 5823 | static const struct snd_kcontrol_new alc268_beep_mixer[] = { |
| 5824 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT), |
| 5825 | HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw), |
| 5826 | { } |
| 5827 | }; |
| 5828 | |
| 5829 | /* set PCBEEP vol = 0, mute connections */ |
| 5830 | static const struct hda_verb alc268_beep_init_verbs[] = { |
| 5831 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5832 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 5833 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 5834 | { } |
| 5835 | }; |
| 5836 | |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5837 | enum { |
| 5838 | ALC268_FIXUP_INV_DMIC, |
Takashi Iwai | cb76640 | 2012-10-20 10:55:21 +0200 | [diff] [blame] | 5839 | ALC268_FIXUP_HP_EAPD, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5840 | }; |
| 5841 | |
| 5842 | static const struct alc_fixup alc268_fixups[] = { |
| 5843 | [ALC268_FIXUP_INV_DMIC] = { |
| 5844 | .type = ALC_FIXUP_FUNC, |
| 5845 | .v.func = alc_fixup_inv_dmic_0x12, |
| 5846 | }, |
Takashi Iwai | cb76640 | 2012-10-20 10:55:21 +0200 | [diff] [blame] | 5847 | [ALC268_FIXUP_HP_EAPD] = { |
| 5848 | .type = ALC_FIXUP_VERBS, |
| 5849 | .v.verbs = (const struct hda_verb[]) { |
| 5850 | {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0}, |
| 5851 | {} |
| 5852 | } |
| 5853 | }, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5854 | }; |
| 5855 | |
| 5856 | static const struct alc_model_fixup alc268_fixup_models[] = { |
| 5857 | {.id = ALC268_FIXUP_INV_DMIC, .name = "inv-dmic"}, |
Takashi Iwai | cb76640 | 2012-10-20 10:55:21 +0200 | [diff] [blame] | 5858 | {.id = ALC268_FIXUP_HP_EAPD, .name = "hp-eapd"}, |
| 5859 | {} |
| 5860 | }; |
| 5861 | |
| 5862 | static const struct snd_pci_quirk alc268_fixup_tbl[] = { |
| 5863 | /* below is codec SSID since multiple Toshiba laptops have the |
| 5864 | * same PCI SSID 1179:ff00 |
| 5865 | */ |
| 5866 | SND_PCI_QUIRK(0x1179, 0xff06, "Toshiba P200", ALC268_FIXUP_HP_EAPD), |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5867 | {} |
| 5868 | }; |
| 5869 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5870 | /* |
| 5871 | * BIOS auto configuration |
| 5872 | */ |
| 5873 | static int alc268_parse_auto_config(struct hda_codec *codec) |
| 5874 | { |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5875 | static const hda_nid_t alc268_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5876 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5877 | int err = alc_parse_auto_config(codec, NULL, alc268_ssids); |
| 5878 | if (err > 0) { |
| 5879 | if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d) { |
| 5880 | add_mixer(spec, alc268_beep_mixer); |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 5881 | snd_hda_gen_add_verbs(&spec->gen, alc268_beep_init_verbs); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5882 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5883 | } |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5884 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5885 | } |
| 5886 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5887 | /* |
| 5888 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5889 | static int patch_alc268(struct hda_codec *codec) |
| 5890 | { |
| 5891 | struct alc_spec *spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5892 | int i, has_beep, err; |
| 5893 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5894 | /* ALC268 has no aa-loopback mixer */ |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 5895 | err = alc_alloc_spec(codec, 0); |
| 5896 | if (err < 0) |
| 5897 | return err; |
| 5898 | |
| 5899 | spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5900 | |
Takashi Iwai | cb76640 | 2012-10-20 10:55:21 +0200 | [diff] [blame] | 5901 | alc_pick_fixup(codec, alc268_fixup_models, alc268_fixup_tbl, alc268_fixups); |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5902 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
| 5903 | |
Takashi Iwai | 6ebb805 | 2011-08-16 15:15:40 +0200 | [diff] [blame] | 5904 | /* automatic parse from the BIOS config */ |
| 5905 | err = alc268_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5906 | if (err < 0) |
| 5907 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5908 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5909 | has_beep = 0; |
| 5910 | for (i = 0; i < spec->num_mixers; i++) { |
| 5911 | if (spec->mixers[i] == alc268_beep_mixer) { |
| 5912 | has_beep = 1; |
| 5913 | break; |
| 5914 | } |
| 5915 | } |
| 5916 | |
| 5917 | if (has_beep) { |
| 5918 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5919 | if (err < 0) |
| 5920 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5921 | if (!query_amp_caps(codec, 0x1d, HDA_INPUT)) |
| 5922 | /* override the amp caps for beep generator */ |
| 5923 | snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT, |
| 5924 | (0x0c << AC_AMPCAP_OFFSET_SHIFT) | |
| 5925 | (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) | |
| 5926 | (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) | |
| 5927 | (0 << AC_AMPCAP_MUTE_SHIFT)); |
| 5928 | } |
| 5929 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5930 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5931 | spec->shutup = alc_eapd_shutup; |
| 5932 | |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5933 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 5934 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5935 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5936 | |
| 5937 | error: |
| 5938 | alc_free(codec); |
| 5939 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5940 | } |
| 5941 | |
| 5942 | /* |
| 5943 | * ALC269 |
| 5944 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5945 | static const struct hda_pcm_stream alc269_44k_pcm_analog_playback = { |
| 5946 | .substreams = 1, |
| 5947 | .channels_min = 2, |
| 5948 | .channels_max = 8, |
| 5949 | .rates = SNDRV_PCM_RATE_44100, /* fixed rate */ |
| 5950 | /* NID is set in alc_build_pcms */ |
| 5951 | .ops = { |
| 5952 | .open = alc_playback_pcm_open, |
| 5953 | .prepare = alc_playback_pcm_prepare, |
| 5954 | .cleanup = alc_playback_pcm_cleanup |
| 5955 | }, |
| 5956 | }; |
| 5957 | |
| 5958 | static const struct hda_pcm_stream alc269_44k_pcm_analog_capture = { |
| 5959 | .substreams = 1, |
| 5960 | .channels_min = 2, |
| 5961 | .channels_max = 2, |
| 5962 | .rates = SNDRV_PCM_RATE_44100, /* fixed rate */ |
| 5963 | /* NID is set in alc_build_pcms */ |
| 5964 | }; |
| 5965 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5966 | /* different alc269-variants */ |
| 5967 | enum { |
| 5968 | ALC269_TYPE_ALC269VA, |
| 5969 | ALC269_TYPE_ALC269VB, |
| 5970 | ALC269_TYPE_ALC269VC, |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 5971 | ALC269_TYPE_ALC269VD, |
Kailang Yang | 065380f | 2013-01-10 10:25:48 +0100 | [diff] [blame] | 5972 | ALC269_TYPE_ALC280, |
| 5973 | ALC269_TYPE_ALC282, |
| 5974 | ALC269_TYPE_ALC284, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5975 | }; |
| 5976 | |
| 5977 | /* |
| 5978 | * BIOS auto configuration |
| 5979 | */ |
| 5980 | static int alc269_parse_auto_config(struct hda_codec *codec) |
| 5981 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5982 | static const hda_nid_t alc269_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5983 | static const hda_nid_t alc269_ssids[] = { 0, 0x1b, 0x14, 0x21 }; |
| 5984 | static const hda_nid_t alc269va_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 5985 | struct alc_spec *spec = codec->spec; |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 5986 | const hda_nid_t *ssids; |
| 5987 | |
| 5988 | switch (spec->codec_variant) { |
| 5989 | case ALC269_TYPE_ALC269VA: |
| 5990 | case ALC269_TYPE_ALC269VC: |
Kailang Yang | 065380f | 2013-01-10 10:25:48 +0100 | [diff] [blame] | 5991 | case ALC269_TYPE_ALC280: |
| 5992 | case ALC269_TYPE_ALC284: |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 5993 | ssids = alc269va_ssids; |
| 5994 | break; |
| 5995 | case ALC269_TYPE_ALC269VB: |
| 5996 | case ALC269_TYPE_ALC269VD: |
Kailang Yang | 065380f | 2013-01-10 10:25:48 +0100 | [diff] [blame] | 5997 | case ALC269_TYPE_ALC282: |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 5998 | ssids = alc269_ssids; |
| 5999 | break; |
| 6000 | default: |
| 6001 | ssids = alc269_ssids; |
| 6002 | break; |
| 6003 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6004 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6005 | return alc_parse_auto_config(codec, alc269_ignore, ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6006 | } |
| 6007 | |
Kailang Yang | 1387e2d | 2012-11-08 10:23:18 +0100 | [diff] [blame] | 6008 | 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] | 6009 | { |
| 6010 | int val = alc_read_coef_idx(codec, 0x04); |
| 6011 | if (power_up) |
| 6012 | val |= 1 << 11; |
| 6013 | else |
| 6014 | val &= ~(1 << 11); |
| 6015 | alc_write_coef_idx(codec, 0x04, val); |
| 6016 | } |
| 6017 | |
| 6018 | static void alc269_shutup(struct hda_codec *codec) |
| 6019 | { |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 6020 | struct alc_spec *spec = codec->spec; |
| 6021 | |
| 6022 | if (spec->codec_variant != ALC269_TYPE_ALC269VB) |
| 6023 | return; |
| 6024 | |
Kailang Yang | 1387e2d | 2012-11-08 10:23:18 +0100 | [diff] [blame] | 6025 | if (spec->codec_variant == ALC269_TYPE_ALC269VB) |
| 6026 | alc269vb_toggle_power_output(codec, 0); |
| 6027 | if (spec->codec_variant == ALC269_TYPE_ALC269VB && |
| 6028 | (alc_get_coef0(codec) & 0x00ff) == 0x018) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6029 | msleep(150); |
| 6030 | } |
| 6031 | } |
| 6032 | |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 6033 | #ifdef CONFIG_PM |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6034 | static int alc269_resume(struct hda_codec *codec) |
| 6035 | { |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 6036 | struct alc_spec *spec = codec->spec; |
| 6037 | |
Kailang Yang | 1387e2d | 2012-11-08 10:23:18 +0100 | [diff] [blame] | 6038 | if (spec->codec_variant == ALC269_TYPE_ALC269VB) |
| 6039 | alc269vb_toggle_power_output(codec, 0); |
| 6040 | if (spec->codec_variant == ALC269_TYPE_ALC269VB && |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 6041 | (alc_get_coef0(codec) & 0x00ff) == 0x018) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6042 | msleep(150); |
| 6043 | } |
| 6044 | |
| 6045 | codec->patch_ops.init(codec); |
| 6046 | |
Kailang Yang | 1387e2d | 2012-11-08 10:23:18 +0100 | [diff] [blame] | 6047 | if (spec->codec_variant == ALC269_TYPE_ALC269VB) |
| 6048 | alc269vb_toggle_power_output(codec, 1); |
| 6049 | if (spec->codec_variant == ALC269_TYPE_ALC269VB && |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 6050 | (alc_get_coef0(codec) & 0x00ff) == 0x017) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6051 | msleep(200); |
| 6052 | } |
| 6053 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6054 | snd_hda_codec_resume_amp(codec); |
| 6055 | snd_hda_codec_resume_cache(codec); |
| 6056 | hda_call_check_power_status(codec, 0x01); |
| 6057 | return 0; |
| 6058 | } |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 6059 | #endif /* CONFIG_PM */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6060 | |
David Henningsson | 108cc10 | 2012-07-20 10:37:25 +0200 | [diff] [blame] | 6061 | static void alc269_fixup_pincfg_no_hp_to_lineout(struct hda_codec *codec, |
| 6062 | const struct alc_fixup *fix, int action) |
| 6063 | { |
| 6064 | struct alc_spec *spec = codec->spec; |
| 6065 | |
| 6066 | if (action == ALC_FIXUP_ACT_PRE_PROBE) |
| 6067 | spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP; |
| 6068 | } |
| 6069 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6070 | static void alc269_fixup_hweq(struct hda_codec *codec, |
| 6071 | const struct alc_fixup *fix, int action) |
| 6072 | { |
| 6073 | int coef; |
| 6074 | |
| 6075 | if (action != ALC_FIXUP_ACT_INIT) |
| 6076 | return; |
| 6077 | coef = alc_read_coef_idx(codec, 0x1e); |
| 6078 | alc_write_coef_idx(codec, 0x1e, coef | 0x80); |
| 6079 | } |
| 6080 | |
| 6081 | static void alc271_fixup_dmic(struct hda_codec *codec, |
| 6082 | const struct alc_fixup *fix, int action) |
| 6083 | { |
| 6084 | static const struct hda_verb verbs[] = { |
| 6085 | {0x20, AC_VERB_SET_COEF_INDEX, 0x0d}, |
| 6086 | {0x20, AC_VERB_SET_PROC_COEF, 0x4000}, |
| 6087 | {} |
| 6088 | }; |
| 6089 | unsigned int cfg; |
| 6090 | |
| 6091 | if (strcmp(codec->chip_name, "ALC271X")) |
| 6092 | return; |
| 6093 | cfg = snd_hda_codec_get_pincfg(codec, 0x12); |
| 6094 | if (get_defcfg_connect(cfg) == AC_JACK_PORT_FIXED) |
| 6095 | snd_hda_sequence_write(codec, verbs); |
| 6096 | } |
| 6097 | |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 6098 | static void alc269_fixup_pcm_44k(struct hda_codec *codec, |
| 6099 | const struct alc_fixup *fix, int action) |
| 6100 | { |
| 6101 | struct alc_spec *spec = codec->spec; |
| 6102 | |
| 6103 | if (action != ALC_FIXUP_ACT_PROBE) |
| 6104 | return; |
| 6105 | |
| 6106 | /* Due to a hardware problem on Lenovo Ideadpad, we need to |
| 6107 | * fix the sample rate of analog I/O to 44.1kHz |
| 6108 | */ |
| 6109 | spec->stream_analog_playback = &alc269_44k_pcm_analog_playback; |
| 6110 | spec->stream_analog_capture = &alc269_44k_pcm_analog_capture; |
| 6111 | } |
| 6112 | |
Takashi Iwai | adabb3e | 2011-08-03 07:48:37 +0200 | [diff] [blame] | 6113 | static void alc269_fixup_stereo_dmic(struct hda_codec *codec, |
| 6114 | const struct alc_fixup *fix, int action) |
| 6115 | { |
| 6116 | int coef; |
| 6117 | |
| 6118 | if (action != ALC_FIXUP_ACT_INIT) |
| 6119 | return; |
| 6120 | /* The digital-mic unit sends PDM (differential signal) instead of |
| 6121 | * the standard PCM, thus you can't record a valid mono stream as is. |
| 6122 | * Below is a workaround specific to ALC269 to control the dmic |
| 6123 | * signal source as mono. |
| 6124 | */ |
| 6125 | coef = alc_read_coef_idx(codec, 0x07); |
| 6126 | alc_write_coef_idx(codec, 0x07, coef | 0x80); |
| 6127 | } |
| 6128 | |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 6129 | static void alc269_quanta_automute(struct hda_codec *codec) |
| 6130 | { |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 6131 | update_outputs(codec); |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 6132 | |
| 6133 | snd_hda_codec_write(codec, 0x20, 0, |
| 6134 | AC_VERB_SET_COEF_INDEX, 0x0c); |
| 6135 | snd_hda_codec_write(codec, 0x20, 0, |
| 6136 | AC_VERB_SET_PROC_COEF, 0x680); |
| 6137 | |
| 6138 | snd_hda_codec_write(codec, 0x20, 0, |
| 6139 | AC_VERB_SET_COEF_INDEX, 0x0c); |
| 6140 | snd_hda_codec_write(codec, 0x20, 0, |
| 6141 | AC_VERB_SET_PROC_COEF, 0x480); |
| 6142 | } |
| 6143 | |
| 6144 | static void alc269_fixup_quanta_mute(struct hda_codec *codec, |
| 6145 | const struct alc_fixup *fix, int action) |
| 6146 | { |
| 6147 | struct alc_spec *spec = codec->spec; |
| 6148 | if (action != ALC_FIXUP_ACT_PROBE) |
| 6149 | return; |
| 6150 | spec->automute_hook = alc269_quanta_automute; |
| 6151 | } |
| 6152 | |
David Henningsson | 6d3cd5d | 2013-01-07 12:03:47 +0100 | [diff] [blame] | 6153 | /* update mute-LED according to the speaker mute state via mic1 VREF pin */ |
| 6154 | static void alc269_fixup_mic1_mute_hook(void *private_data, int enabled) |
| 6155 | { |
| 6156 | struct hda_codec *codec = private_data; |
| 6157 | unsigned int pinval = AC_PINCTL_IN_EN + (enabled ? |
| 6158 | AC_PINCTL_VREF_HIZ : AC_PINCTL_VREF_80); |
| 6159 | snd_hda_set_pin_ctl_cache(codec, 0x18, pinval); |
| 6160 | } |
| 6161 | |
| 6162 | static void alc269_fixup_mic1_mute(struct hda_codec *codec, |
| 6163 | const struct alc_fixup *fix, int action) |
| 6164 | { |
| 6165 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 3bd7b64 | 2012-12-18 14:57:09 +0100 | [diff] [blame] | 6166 | if (action == ALC_FIXUP_ACT_PROBE) |
David Henningsson | 6d3cd5d | 2013-01-07 12:03:47 +0100 | [diff] [blame] | 6167 | spec->vmaster_mute.hook = alc269_fixup_mic1_mute_hook; |
David Henningsson | 6d3cd5d | 2013-01-07 12:03:47 +0100 | [diff] [blame] | 6168 | } |
| 6169 | |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 6170 | /* update mute-LED according to the speaker mute state via mic2 VREF pin */ |
| 6171 | static void alc269_fixup_mic2_mute_hook(void *private_data, int enabled) |
| 6172 | { |
| 6173 | struct hda_codec *codec = private_data; |
| 6174 | unsigned int pinval = enabled ? 0x20 : 0x24; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 6175 | snd_hda_set_pin_ctl_cache(codec, 0x19, pinval); |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 6176 | } |
| 6177 | |
| 6178 | static void alc269_fixup_mic2_mute(struct hda_codec *codec, |
| 6179 | const struct alc_fixup *fix, int action) |
| 6180 | { |
| 6181 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 3bd7b64 | 2012-12-18 14:57:09 +0100 | [diff] [blame] | 6182 | if (action == ALC_FIXUP_ACT_PROBE) |
Takashi Iwai | d2f344b | 2012-03-12 16:59:58 +0100 | [diff] [blame] | 6183 | spec->vmaster_mute.hook = alc269_fixup_mic2_mute_hook; |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 6184 | } |
| 6185 | |
Dylan Reid | 08a978d | 2012-11-18 22:56:40 -0800 | [diff] [blame] | 6186 | static void alc271_hp_gate_mic_jack(struct hda_codec *codec, |
| 6187 | const struct alc_fixup *fix, |
| 6188 | int action) |
| 6189 | { |
| 6190 | struct alc_spec *spec = codec->spec; |
| 6191 | |
| 6192 | if (action == ALC_FIXUP_ACT_PROBE) |
| 6193 | snd_hda_jack_set_gating_jack(codec, spec->ext_mic_pin, |
| 6194 | spec->autocfg.hp_pins[0]); |
| 6195 | } |
David Henningsson | 693b613 | 2012-06-22 19:12:10 +0200 | [diff] [blame] | 6196 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6197 | enum { |
| 6198 | ALC269_FIXUP_SONY_VAIO, |
| 6199 | ALC275_FIXUP_SONY_VAIO_GPIO2, |
| 6200 | ALC269_FIXUP_DELL_M101Z, |
| 6201 | ALC269_FIXUP_SKU_IGNORE, |
| 6202 | ALC269_FIXUP_ASUS_G73JW, |
| 6203 | ALC269_FIXUP_LENOVO_EAPD, |
| 6204 | ALC275_FIXUP_SONY_HWEQ, |
| 6205 | ALC271_FIXUP_DMIC, |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 6206 | ALC269_FIXUP_PCM_44K, |
Takashi Iwai | adabb3e | 2011-08-03 07:48:37 +0200 | [diff] [blame] | 6207 | ALC269_FIXUP_STEREO_DMIC, |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 6208 | ALC269_FIXUP_QUANTA_MUTE, |
| 6209 | ALC269_FIXUP_LIFEBOOK, |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6210 | ALC269_FIXUP_AMIC, |
| 6211 | ALC269_FIXUP_DMIC, |
| 6212 | ALC269VB_FIXUP_AMIC, |
| 6213 | ALC269VB_FIXUP_DMIC, |
David Henningsson | 6d3cd5d | 2013-01-07 12:03:47 +0100 | [diff] [blame] | 6214 | ALC269_FIXUP_MIC1_MUTE_LED, |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 6215 | ALC269_FIXUP_MIC2_MUTE_LED, |
David Henningsson | 693b613 | 2012-06-22 19:12:10 +0200 | [diff] [blame] | 6216 | ALC269_FIXUP_INV_DMIC, |
David Henningsson | 108cc10 | 2012-07-20 10:37:25 +0200 | [diff] [blame] | 6217 | ALC269_FIXUP_LENOVO_DOCK, |
| 6218 | ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT, |
Dylan Reid | 08a978d | 2012-11-18 22:56:40 -0800 | [diff] [blame] | 6219 | ALC271_FIXUP_AMIC_MIC2, |
| 6220 | ALC271_FIXUP_HP_GATE_MIC_JACK, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6221 | }; |
| 6222 | |
| 6223 | static const struct alc_fixup alc269_fixups[] = { |
| 6224 | [ALC269_FIXUP_SONY_VAIO] = { |
| 6225 | .type = ALC_FIXUP_VERBS, |
| 6226 | .v.verbs = (const struct hda_verb[]) { |
| 6227 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREFGRD}, |
| 6228 | {} |
| 6229 | } |
| 6230 | }, |
| 6231 | [ALC275_FIXUP_SONY_VAIO_GPIO2] = { |
| 6232 | .type = ALC_FIXUP_VERBS, |
| 6233 | .v.verbs = (const struct hda_verb[]) { |
| 6234 | {0x01, AC_VERB_SET_GPIO_MASK, 0x04}, |
| 6235 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04}, |
| 6236 | {0x01, AC_VERB_SET_GPIO_DATA, 0x00}, |
| 6237 | { } |
| 6238 | }, |
| 6239 | .chained = true, |
| 6240 | .chain_id = ALC269_FIXUP_SONY_VAIO |
| 6241 | }, |
| 6242 | [ALC269_FIXUP_DELL_M101Z] = { |
| 6243 | .type = ALC_FIXUP_VERBS, |
| 6244 | .v.verbs = (const struct hda_verb[]) { |
| 6245 | /* Enables internal speaker */ |
| 6246 | {0x20, AC_VERB_SET_COEF_INDEX, 13}, |
| 6247 | {0x20, AC_VERB_SET_PROC_COEF, 0x4040}, |
| 6248 | {} |
| 6249 | } |
| 6250 | }, |
| 6251 | [ALC269_FIXUP_SKU_IGNORE] = { |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 6252 | .type = ALC_FIXUP_FUNC, |
| 6253 | .v.func = alc_fixup_sku_ignore, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6254 | }, |
| 6255 | [ALC269_FIXUP_ASUS_G73JW] = { |
| 6256 | .type = ALC_FIXUP_PINS, |
| 6257 | .v.pins = (const struct alc_pincfg[]) { |
| 6258 | { 0x17, 0x99130111 }, /* subwoofer */ |
| 6259 | { } |
| 6260 | } |
| 6261 | }, |
| 6262 | [ALC269_FIXUP_LENOVO_EAPD] = { |
| 6263 | .type = ALC_FIXUP_VERBS, |
| 6264 | .v.verbs = (const struct hda_verb[]) { |
| 6265 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0}, |
| 6266 | {} |
| 6267 | } |
| 6268 | }, |
| 6269 | [ALC275_FIXUP_SONY_HWEQ] = { |
| 6270 | .type = ALC_FIXUP_FUNC, |
| 6271 | .v.func = alc269_fixup_hweq, |
| 6272 | .chained = true, |
| 6273 | .chain_id = ALC275_FIXUP_SONY_VAIO_GPIO2 |
| 6274 | }, |
| 6275 | [ALC271_FIXUP_DMIC] = { |
| 6276 | .type = ALC_FIXUP_FUNC, |
| 6277 | .v.func = alc271_fixup_dmic, |
| 6278 | }, |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 6279 | [ALC269_FIXUP_PCM_44K] = { |
| 6280 | .type = ALC_FIXUP_FUNC, |
| 6281 | .v.func = alc269_fixup_pcm_44k, |
David Henningsson | 012e7eb | 2012-08-08 08:43:37 +0200 | [diff] [blame] | 6282 | .chained = true, |
| 6283 | .chain_id = ALC269_FIXUP_QUANTA_MUTE |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 6284 | }, |
Takashi Iwai | adabb3e | 2011-08-03 07:48:37 +0200 | [diff] [blame] | 6285 | [ALC269_FIXUP_STEREO_DMIC] = { |
| 6286 | .type = ALC_FIXUP_FUNC, |
| 6287 | .v.func = alc269_fixup_stereo_dmic, |
| 6288 | }, |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 6289 | [ALC269_FIXUP_QUANTA_MUTE] = { |
| 6290 | .type = ALC_FIXUP_FUNC, |
| 6291 | .v.func = alc269_fixup_quanta_mute, |
| 6292 | }, |
| 6293 | [ALC269_FIXUP_LIFEBOOK] = { |
| 6294 | .type = ALC_FIXUP_PINS, |
| 6295 | .v.pins = (const struct alc_pincfg[]) { |
| 6296 | { 0x1a, 0x2101103f }, /* dock line-out */ |
| 6297 | { 0x1b, 0x23a11040 }, /* dock mic-in */ |
| 6298 | { } |
| 6299 | }, |
| 6300 | .chained = true, |
| 6301 | .chain_id = ALC269_FIXUP_QUANTA_MUTE |
| 6302 | }, |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6303 | [ALC269_FIXUP_AMIC] = { |
| 6304 | .type = ALC_FIXUP_PINS, |
| 6305 | .v.pins = (const struct alc_pincfg[]) { |
| 6306 | { 0x14, 0x99130110 }, /* speaker */ |
| 6307 | { 0x15, 0x0121401f }, /* HP out */ |
| 6308 | { 0x18, 0x01a19c20 }, /* mic */ |
| 6309 | { 0x19, 0x99a3092f }, /* int-mic */ |
| 6310 | { } |
| 6311 | }, |
| 6312 | }, |
| 6313 | [ALC269_FIXUP_DMIC] = { |
| 6314 | .type = ALC_FIXUP_PINS, |
| 6315 | .v.pins = (const struct alc_pincfg[]) { |
| 6316 | { 0x12, 0x99a3092f }, /* int-mic */ |
| 6317 | { 0x14, 0x99130110 }, /* speaker */ |
| 6318 | { 0x15, 0x0121401f }, /* HP out */ |
| 6319 | { 0x18, 0x01a19c20 }, /* mic */ |
| 6320 | { } |
| 6321 | }, |
| 6322 | }, |
| 6323 | [ALC269VB_FIXUP_AMIC] = { |
| 6324 | .type = ALC_FIXUP_PINS, |
| 6325 | .v.pins = (const struct alc_pincfg[]) { |
| 6326 | { 0x14, 0x99130110 }, /* speaker */ |
| 6327 | { 0x18, 0x01a19c20 }, /* mic */ |
| 6328 | { 0x19, 0x99a3092f }, /* int-mic */ |
| 6329 | { 0x21, 0x0121401f }, /* HP out */ |
| 6330 | { } |
| 6331 | }, |
| 6332 | }, |
David Henningsson | 2267ea9 | 2012-01-03 08:45:56 +0100 | [diff] [blame] | 6333 | [ALC269VB_FIXUP_DMIC] = { |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6334 | .type = ALC_FIXUP_PINS, |
| 6335 | .v.pins = (const struct alc_pincfg[]) { |
| 6336 | { 0x12, 0x99a3092f }, /* int-mic */ |
| 6337 | { 0x14, 0x99130110 }, /* speaker */ |
| 6338 | { 0x18, 0x01a19c20 }, /* mic */ |
| 6339 | { 0x21, 0x0121401f }, /* HP out */ |
| 6340 | { } |
| 6341 | }, |
| 6342 | }, |
David Henningsson | 6d3cd5d | 2013-01-07 12:03:47 +0100 | [diff] [blame] | 6343 | [ALC269_FIXUP_MIC1_MUTE_LED] = { |
| 6344 | .type = ALC_FIXUP_FUNC, |
| 6345 | .v.func = alc269_fixup_mic1_mute, |
| 6346 | }, |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 6347 | [ALC269_FIXUP_MIC2_MUTE_LED] = { |
| 6348 | .type = ALC_FIXUP_FUNC, |
| 6349 | .v.func = alc269_fixup_mic2_mute, |
| 6350 | }, |
David Henningsson | 693b613 | 2012-06-22 19:12:10 +0200 | [diff] [blame] | 6351 | [ALC269_FIXUP_INV_DMIC] = { |
| 6352 | .type = ALC_FIXUP_FUNC, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 6353 | .v.func = alc_fixup_inv_dmic_0x12, |
David Henningsson | 693b613 | 2012-06-22 19:12:10 +0200 | [diff] [blame] | 6354 | }, |
David Henningsson | 108cc10 | 2012-07-20 10:37:25 +0200 | [diff] [blame] | 6355 | [ALC269_FIXUP_LENOVO_DOCK] = { |
| 6356 | .type = ALC_FIXUP_PINS, |
| 6357 | .v.pins = (const struct alc_pincfg[]) { |
| 6358 | { 0x19, 0x23a11040 }, /* dock mic */ |
| 6359 | { 0x1b, 0x2121103f }, /* dock headphone */ |
| 6360 | { } |
| 6361 | }, |
| 6362 | .chained = true, |
| 6363 | .chain_id = ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT |
| 6364 | }, |
| 6365 | [ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT] = { |
| 6366 | .type = ALC_FIXUP_FUNC, |
| 6367 | .v.func = alc269_fixup_pincfg_no_hp_to_lineout, |
| 6368 | }, |
Dylan Reid | 08a978d | 2012-11-18 22:56:40 -0800 | [diff] [blame] | 6369 | [ALC271_FIXUP_AMIC_MIC2] = { |
| 6370 | .type = ALC_FIXUP_PINS, |
| 6371 | .v.pins = (const struct alc_pincfg[]) { |
| 6372 | { 0x14, 0x99130110 }, /* speaker */ |
| 6373 | { 0x19, 0x01a19c20 }, /* mic */ |
| 6374 | { 0x1b, 0x99a7012f }, /* int-mic */ |
| 6375 | { 0x21, 0x0121401f }, /* HP out */ |
| 6376 | { } |
| 6377 | }, |
| 6378 | }, |
| 6379 | [ALC271_FIXUP_HP_GATE_MIC_JACK] = { |
| 6380 | .type = ALC_FIXUP_FUNC, |
| 6381 | .v.func = alc271_hp_gate_mic_jack, |
| 6382 | .chained = true, |
| 6383 | .chain_id = ALC271_FIXUP_AMIC_MIC2, |
| 6384 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6385 | }; |
| 6386 | |
| 6387 | static const struct snd_pci_quirk alc269_fixup_tbl[] = { |
David Henningsson | 693b613 | 2012-06-22 19:12:10 +0200 | [diff] [blame] | 6388 | SND_PCI_QUIRK(0x1025, 0x029b, "Acer 1810TZ", ALC269_FIXUP_INV_DMIC), |
| 6389 | SND_PCI_QUIRK(0x1025, 0x0349, "Acer AOD260", ALC269_FIXUP_INV_DMIC), |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 6390 | SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_MIC2_MUTE_LED), |
David Henningsson | 6d3cd5d | 2013-01-07 12:03:47 +0100 | [diff] [blame] | 6391 | 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] | 6392 | SND_PCI_QUIRK(0x1043, 0x1427, "Asus Zenbook UX31E", ALC269VB_FIXUP_DMIC), |
Oleksij Rempel | 148728f | 2012-09-21 17:44:58 +0200 | [diff] [blame] | 6393 | SND_PCI_QUIRK(0x1043, 0x1517, "Asus Zenbook UX31A", ALC269VB_FIXUP_DMIC), |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 6394 | SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW), |
David Henningsson | 693b613 | 2012-06-22 19:12:10 +0200 | [diff] [blame] | 6395 | SND_PCI_QUIRK(0x1043, 0x1b13, "Asus U41SV", ALC269_FIXUP_INV_DMIC), |
Takashi Iwai | adabb3e | 2011-08-03 07:48:37 +0200 | [diff] [blame] | 6396 | SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC), |
| 6397 | SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC), |
| 6398 | SND_PCI_QUIRK(0x1043, 0x834a, "ASUS S101", ALC269_FIXUP_STEREO_DMIC), |
| 6399 | SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC), |
| 6400 | SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6401 | SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2), |
| 6402 | SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ), |
| 6403 | SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ), |
| 6404 | SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO), |
| 6405 | SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z), |
Dylan Reid | 08a978d | 2012-11-18 22:56:40 -0800 | [diff] [blame] | 6406 | 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] | 6407 | SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC), |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 6408 | SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook", ALC269_FIXUP_LIFEBOOK), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6409 | SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE), |
| 6410 | SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE), |
| 6411 | SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE), |
| 6412 | SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE), |
| 6413 | SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE), |
Takashi Iwai | 707fba3 | 2012-08-02 09:04:39 +0200 | [diff] [blame] | 6414 | SND_PCI_QUIRK(0x17aa, 0x21f6, "Thinkpad T530", ALC269_FIXUP_LENOVO_DOCK), |
Felix Kaechele | c8415a4 | 2012-08-06 23:02:01 +0200 | [diff] [blame] | 6415 | SND_PCI_QUIRK(0x17aa, 0x21fa, "Thinkpad X230", ALC269_FIXUP_LENOVO_DOCK), |
Stefán Freyr | 84f98fd | 2012-10-19 22:46:00 +0200 | [diff] [blame] | 6416 | SND_PCI_QUIRK(0x17aa, 0x21f3, "Thinkpad T430", ALC269_FIXUP_LENOVO_DOCK), |
Philipp A. Mohrenweiser | 4407be6 | 2012-08-06 13:14:18 +0200 | [diff] [blame] | 6417 | SND_PCI_QUIRK(0x17aa, 0x21fb, "Thinkpad T430s", ALC269_FIXUP_LENOVO_DOCK), |
David Henningsson | 108cc10 | 2012-07-20 10:37:25 +0200 | [diff] [blame] | 6418 | SND_PCI_QUIRK(0x17aa, 0x2203, "Thinkpad X230 Tablet", ALC269_FIXUP_LENOVO_DOCK), |
David Henningsson | 012e7eb | 2012-08-08 08:43:37 +0200 | [diff] [blame] | 6419 | SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_PCM_44K), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6420 | SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD), |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6421 | |
Takashi Iwai | a7f3eed | 2012-02-16 13:03:18 +0100 | [diff] [blame] | 6422 | #if 0 |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6423 | /* Below is a quirk table taken from the old code. |
| 6424 | * Basically the device should work as is without the fixup table. |
| 6425 | * If BIOS doesn't give a proper info, enable the corresponding |
| 6426 | * fixup entry. |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 6427 | */ |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6428 | SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A", |
| 6429 | ALC269_FIXUP_AMIC), |
| 6430 | SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269_FIXUP_AMIC), |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6431 | SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269_FIXUP_AMIC), |
| 6432 | SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_FIXUP_AMIC), |
| 6433 | SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269_FIXUP_AMIC), |
| 6434 | SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269_FIXUP_AMIC), |
| 6435 | SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269_FIXUP_AMIC), |
| 6436 | SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269_FIXUP_AMIC), |
| 6437 | SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_FIXUP_AMIC), |
| 6438 | SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269_FIXUP_AMIC), |
| 6439 | SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_FIXUP_AMIC), |
| 6440 | SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_FIXUP_AMIC), |
| 6441 | SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_FIXUP_AMIC), |
| 6442 | SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_FIXUP_AMIC), |
| 6443 | SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_FIXUP_AMIC), |
| 6444 | SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_FIXUP_AMIC), |
| 6445 | SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_FIXUP_AMIC), |
| 6446 | SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_FIXUP_AMIC), |
| 6447 | SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_FIXUP_AMIC), |
| 6448 | SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_FIXUP_AMIC), |
| 6449 | SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_FIXUP_AMIC), |
| 6450 | SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_FIXUP_AMIC), |
| 6451 | SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_FIXUP_AMIC), |
| 6452 | SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_FIXUP_AMIC), |
| 6453 | SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_FIXUP_AMIC), |
| 6454 | SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_FIXUP_AMIC), |
| 6455 | SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_FIXUP_AMIC), |
| 6456 | SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_FIXUP_AMIC), |
| 6457 | SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_FIXUP_AMIC), |
| 6458 | SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_FIXUP_AMIC), |
| 6459 | SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_FIXUP_AMIC), |
| 6460 | SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_FIXUP_AMIC), |
| 6461 | SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_FIXUP_AMIC), |
| 6462 | SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_FIXUP_AMIC), |
| 6463 | SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_FIXUP_AMIC), |
| 6464 | SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_FIXUP_DMIC), |
| 6465 | SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_FIXUP_AMIC), |
| 6466 | SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_AMIC), |
| 6467 | SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_FIXUP_DMIC), |
| 6468 | SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_FIXUP_DMIC), |
| 6469 | #endif |
| 6470 | {} |
| 6471 | }; |
| 6472 | |
| 6473 | static const struct alc_model_fixup alc269_fixup_models[] = { |
| 6474 | {.id = ALC269_FIXUP_AMIC, .name = "laptop-amic"}, |
| 6475 | {.id = ALC269_FIXUP_DMIC, .name = "laptop-dmic"}, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 6476 | {.id = ALC269_FIXUP_STEREO_DMIC, .name = "alc269-dmic"}, |
| 6477 | {.id = ALC271_FIXUP_DMIC, .name = "alc271-dmic"}, |
| 6478 | {.id = ALC269_FIXUP_INV_DMIC, .name = "inv-dmic"}, |
David Henningsson | 108cc10 | 2012-07-20 10:37:25 +0200 | [diff] [blame] | 6479 | {.id = ALC269_FIXUP_LENOVO_DOCK, .name = "lenovo-dock"}, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6480 | {} |
| 6481 | }; |
| 6482 | |
| 6483 | |
Takashi Iwai | 546bb67 | 2012-03-07 08:37:19 +0100 | [diff] [blame] | 6484 | static void alc269_fill_coef(struct hda_codec *codec) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6485 | { |
Kailang Yang | 526af6e | 2012-03-07 08:25:20 +0100 | [diff] [blame] | 6486 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6487 | int val; |
| 6488 | |
Kailang Yang | 526af6e | 2012-03-07 08:25:20 +0100 | [diff] [blame] | 6489 | if (spec->codec_variant != ALC269_TYPE_ALC269VB) |
Takashi Iwai | 546bb67 | 2012-03-07 08:37:19 +0100 | [diff] [blame] | 6490 | return; |
Kailang Yang | 526af6e | 2012-03-07 08:25:20 +0100 | [diff] [blame] | 6491 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6492 | if ((alc_get_coef0(codec) & 0x00ff) < 0x015) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6493 | alc_write_coef_idx(codec, 0xf, 0x960b); |
| 6494 | alc_write_coef_idx(codec, 0xe, 0x8817); |
| 6495 | } |
| 6496 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6497 | if ((alc_get_coef0(codec) & 0x00ff) == 0x016) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6498 | alc_write_coef_idx(codec, 0xf, 0x960b); |
| 6499 | alc_write_coef_idx(codec, 0xe, 0x8814); |
| 6500 | } |
| 6501 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6502 | if ((alc_get_coef0(codec) & 0x00ff) == 0x017) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6503 | val = alc_read_coef_idx(codec, 0x04); |
| 6504 | /* Power up output pin */ |
| 6505 | alc_write_coef_idx(codec, 0x04, val | (1<<11)); |
| 6506 | } |
| 6507 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6508 | if ((alc_get_coef0(codec) & 0x00ff) == 0x018) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6509 | val = alc_read_coef_idx(codec, 0xd); |
| 6510 | if ((val & 0x0c00) >> 10 != 0x1) { |
| 6511 | /* Capless ramp up clock control */ |
| 6512 | alc_write_coef_idx(codec, 0xd, val | (1<<10)); |
| 6513 | } |
| 6514 | val = alc_read_coef_idx(codec, 0x17); |
| 6515 | if ((val & 0x01c0) >> 6 != 0x4) { |
| 6516 | /* Class D power on reset */ |
| 6517 | alc_write_coef_idx(codec, 0x17, val | (1<<7)); |
| 6518 | } |
| 6519 | } |
| 6520 | |
| 6521 | val = alc_read_coef_idx(codec, 0xd); /* Class D */ |
| 6522 | alc_write_coef_idx(codec, 0xd, val | (1<<14)); |
| 6523 | |
| 6524 | val = alc_read_coef_idx(codec, 0x4); /* HP */ |
| 6525 | alc_write_coef_idx(codec, 0x4, val | (1<<11)); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6526 | } |
| 6527 | |
| 6528 | /* |
| 6529 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6530 | static int patch_alc269(struct hda_codec *codec) |
| 6531 | { |
| 6532 | struct alc_spec *spec; |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6533 | int err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6534 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6535 | err = alc_alloc_spec(codec, 0x0b); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6536 | if (err < 0) |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6537 | return err; |
| 6538 | |
| 6539 | spec = codec->spec; |
Takashi Iwai | 37c0420 | 2012-12-18 14:22:45 +0100 | [diff] [blame] | 6540 | spec->shared_mic_vref_pin = 0x18; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6541 | |
Herton Ronaldo Krzesinski | 9f720bb | 2012-09-27 10:38:14 -0300 | [diff] [blame] | 6542 | alc_pick_fixup(codec, alc269_fixup_models, |
| 6543 | alc269_fixup_tbl, alc269_fixups); |
| 6544 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
| 6545 | |
| 6546 | alc_auto_parse_customize_define(codec); |
| 6547 | |
Kailang Yang | 065380f | 2013-01-10 10:25:48 +0100 | [diff] [blame] | 6548 | switch (codec->vendor_id) { |
| 6549 | case 0x10ec0269: |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6550 | spec->codec_variant = ALC269_TYPE_ALC269VA; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6551 | switch (alc_get_coef0(codec) & 0x00f0) { |
| 6552 | case 0x0010: |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6553 | if (codec->bus->pci->subsystem_vendor == 0x1025 && |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6554 | spec->cdefine.platform_type == 1) |
Takashi Iwai | 20ca0c3 | 2011-10-17 16:00:35 +0200 | [diff] [blame] | 6555 | err = alc_codec_rename(codec, "ALC271X"); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6556 | spec->codec_variant = ALC269_TYPE_ALC269VB; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6557 | break; |
| 6558 | case 0x0020: |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6559 | if (codec->bus->pci->subsystem_vendor == 0x17aa && |
| 6560 | codec->bus->pci->subsystem_device == 0x21f3) |
Takashi Iwai | 20ca0c3 | 2011-10-17 16:00:35 +0200 | [diff] [blame] | 6561 | err = alc_codec_rename(codec, "ALC3202"); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6562 | spec->codec_variant = ALC269_TYPE_ALC269VC; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6563 | break; |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 6564 | case 0x0030: |
| 6565 | spec->codec_variant = ALC269_TYPE_ALC269VD; |
| 6566 | break; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6567 | default: |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6568 | alc_fix_pll_init(codec, 0x20, 0x04, 15); |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6569 | } |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6570 | if (err < 0) |
| 6571 | goto error; |
Takashi Iwai | 546bb67 | 2012-03-07 08:37:19 +0100 | [diff] [blame] | 6572 | spec->init_hook = alc269_fill_coef; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6573 | alc269_fill_coef(codec); |
Kailang Yang | 065380f | 2013-01-10 10:25:48 +0100 | [diff] [blame] | 6574 | break; |
| 6575 | |
| 6576 | case 0x10ec0280: |
| 6577 | case 0x10ec0290: |
| 6578 | spec->codec_variant = ALC269_TYPE_ALC280; |
| 6579 | break; |
| 6580 | case 0x10ec0282: |
| 6581 | case 0x10ec0283: |
| 6582 | spec->codec_variant = ALC269_TYPE_ALC282; |
| 6583 | break; |
| 6584 | case 0x10ec0284: |
| 6585 | case 0x10ec0292: |
| 6586 | spec->codec_variant = ALC269_TYPE_ALC284; |
| 6587 | break; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6588 | } |
| 6589 | |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6590 | /* automatic parse from the BIOS config */ |
| 6591 | err = alc269_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6592 | if (err < 0) |
| 6593 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6594 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6595 | if (!spec->no_analog && has_cdefine_beep(codec)) { |
| 6596 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6597 | if (err < 0) |
| 6598 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6599 | set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6600 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6601 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6602 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 6603 | #ifdef CONFIG_PM |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6604 | codec->patch_ops.resume = alc269_resume; |
| 6605 | #endif |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6606 | spec->shutup = alc269_shutup; |
| 6607 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 6608 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 6609 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6610 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6611 | |
| 6612 | error: |
| 6613 | alc_free(codec); |
| 6614 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6615 | } |
| 6616 | |
| 6617 | /* |
| 6618 | * ALC861 |
| 6619 | */ |
| 6620 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6621 | static int alc861_parse_auto_config(struct hda_codec *codec) |
| 6622 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6623 | static const hda_nid_t alc861_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6624 | static const hda_nid_t alc861_ssids[] = { 0x0e, 0x0f, 0x0b, 0 }; |
| 6625 | return alc_parse_auto_config(codec, alc861_ignore, alc861_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6626 | } |
| 6627 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6628 | /* Pin config fixes */ |
| 6629 | enum { |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6630 | ALC861_FIXUP_FSC_AMILO_PI1505, |
| 6631 | ALC861_FIXUP_AMP_VREF_0F, |
| 6632 | ALC861_FIXUP_NO_JACK_DETECT, |
| 6633 | ALC861_FIXUP_ASUS_A6RP, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6634 | }; |
| 6635 | |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 6636 | /* On some laptops, VREF of pin 0x0f is abused for controlling the main amp */ |
| 6637 | static void alc861_fixup_asus_amp_vref_0f(struct hda_codec *codec, |
| 6638 | const struct alc_fixup *fix, int action) |
| 6639 | { |
| 6640 | struct alc_spec *spec = codec->spec; |
| 6641 | unsigned int val; |
| 6642 | |
| 6643 | if (action != ALC_FIXUP_ACT_INIT) |
| 6644 | return; |
| 6645 | val = snd_hda_codec_read(codec, 0x0f, 0, |
| 6646 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 6647 | if (!(val & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))) |
| 6648 | val |= AC_PINCTL_IN_EN; |
| 6649 | val |= AC_PINCTL_VREF_50; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 6650 | snd_hda_set_pin_ctl(codec, 0x0f, val); |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 6651 | spec->keep_vref_in_automute = 1; |
| 6652 | } |
| 6653 | |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6654 | /* suppress the jack-detection */ |
| 6655 | static void alc_fixup_no_jack_detect(struct hda_codec *codec, |
| 6656 | const struct alc_fixup *fix, int action) |
| 6657 | { |
| 6658 | if (action == ALC_FIXUP_ACT_PRE_PROBE) |
| 6659 | codec->no_jack_detect = 1; |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 6660 | } |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6661 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6662 | static const struct alc_fixup alc861_fixups[] = { |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6663 | [ALC861_FIXUP_FSC_AMILO_PI1505] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6664 | .type = ALC_FIXUP_PINS, |
| 6665 | .v.pins = (const struct alc_pincfg[]) { |
| 6666 | { 0x0b, 0x0221101f }, /* HP */ |
| 6667 | { 0x0f, 0x90170310 }, /* speaker */ |
| 6668 | { } |
| 6669 | } |
| 6670 | }, |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6671 | [ALC861_FIXUP_AMP_VREF_0F] = { |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 6672 | .type = ALC_FIXUP_FUNC, |
| 6673 | .v.func = alc861_fixup_asus_amp_vref_0f, |
Takashi Iwai | 3b25eb6 | 2012-01-25 09:55:46 +0100 | [diff] [blame] | 6674 | }, |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6675 | [ALC861_FIXUP_NO_JACK_DETECT] = { |
| 6676 | .type = ALC_FIXUP_FUNC, |
| 6677 | .v.func = alc_fixup_no_jack_detect, |
| 6678 | }, |
| 6679 | [ALC861_FIXUP_ASUS_A6RP] = { |
| 6680 | .type = ALC_FIXUP_FUNC, |
| 6681 | .v.func = alc861_fixup_asus_amp_vref_0f, |
| 6682 | .chained = true, |
| 6683 | .chain_id = ALC861_FIXUP_NO_JACK_DETECT, |
| 6684 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6685 | }; |
| 6686 | |
| 6687 | static const struct snd_pci_quirk alc861_fixup_tbl[] = { |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6688 | SND_PCI_QUIRK(0x1043, 0x1393, "ASUS A6Rp", ALC861_FIXUP_ASUS_A6RP), |
| 6689 | SND_PCI_QUIRK_VENDOR(0x1043, "ASUS laptop", ALC861_FIXUP_AMP_VREF_0F), |
| 6690 | SND_PCI_QUIRK(0x1462, 0x7254, "HP DX2200", ALC861_FIXUP_NO_JACK_DETECT), |
| 6691 | SND_PCI_QUIRK(0x1584, 0x2b01, "Haier W18", ALC861_FIXUP_AMP_VREF_0F), |
| 6692 | SND_PCI_QUIRK(0x1584, 0x0000, "Uniwill ECS M31EI", ALC861_FIXUP_AMP_VREF_0F), |
| 6693 | 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] | 6694 | {} |
| 6695 | }; |
| 6696 | |
| 6697 | /* |
| 6698 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6699 | static int patch_alc861(struct hda_codec *codec) |
| 6700 | { |
| 6701 | struct alc_spec *spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6702 | int err; |
| 6703 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6704 | err = alc_alloc_spec(codec, 0x15); |
| 6705 | if (err < 0) |
| 6706 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6707 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6708 | spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6709 | |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6710 | alc_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups); |
| 6711 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6712 | |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6713 | /* automatic parse from the BIOS config */ |
| 6714 | err = alc861_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6715 | if (err < 0) |
| 6716 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6717 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6718 | if (!spec->no_analog) { |
| 6719 | err = snd_hda_attach_beep_device(codec, 0x23); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6720 | if (err < 0) |
| 6721 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6722 | set_beep_amp(spec, 0x23, 0, HDA_OUTPUT); |
| 6723 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6724 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6725 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 83012a7 | 2012-08-24 18:38:08 +0200 | [diff] [blame] | 6726 | #ifdef CONFIG_PM |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6727 | spec->power_hook = alc_power_eapd; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6728 | #endif |
| 6729 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 6730 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 6731 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6732 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6733 | |
| 6734 | error: |
| 6735 | alc_free(codec); |
| 6736 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6737 | } |
| 6738 | |
| 6739 | /* |
| 6740 | * ALC861-VD support |
| 6741 | * |
| 6742 | * Based on ALC882 |
| 6743 | * |
| 6744 | * In addition, an independent DAC |
| 6745 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6746 | static int alc861vd_parse_auto_config(struct hda_codec *codec) |
| 6747 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6748 | static const hda_nid_t alc861vd_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6749 | static const hda_nid_t alc861vd_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 6750 | return alc_parse_auto_config(codec, alc861vd_ignore, alc861vd_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6751 | } |
| 6752 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6753 | enum { |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6754 | ALC660VD_FIX_ASUS_GPIO1, |
| 6755 | ALC861VD_FIX_DALLAS, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6756 | }; |
| 6757 | |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6758 | /* exclude VREF80 */ |
| 6759 | static void alc861vd_fixup_dallas(struct hda_codec *codec, |
| 6760 | const struct alc_fixup *fix, int action) |
| 6761 | { |
| 6762 | if (action == ALC_FIXUP_ACT_PRE_PROBE) { |
Takashi Iwai | b78562b | 2012-12-17 20:06:49 +0100 | [diff] [blame] | 6763 | snd_hda_override_pin_caps(codec, 0x18, 0x00000734); |
| 6764 | snd_hda_override_pin_caps(codec, 0x19, 0x0000073c); |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6765 | } |
| 6766 | } |
| 6767 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6768 | static const struct alc_fixup alc861vd_fixups[] = { |
| 6769 | [ALC660VD_FIX_ASUS_GPIO1] = { |
| 6770 | .type = ALC_FIXUP_VERBS, |
| 6771 | .v.verbs = (const struct hda_verb[]) { |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6772 | /* reset GPIO1 */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6773 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, |
| 6774 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, |
| 6775 | {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, |
| 6776 | { } |
| 6777 | } |
| 6778 | }, |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6779 | [ALC861VD_FIX_DALLAS] = { |
| 6780 | .type = ALC_FIXUP_FUNC, |
| 6781 | .v.func = alc861vd_fixup_dallas, |
| 6782 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6783 | }; |
| 6784 | |
| 6785 | static const struct snd_pci_quirk alc861vd_fixup_tbl[] = { |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6786 | SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_FIX_DALLAS), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6787 | SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1), |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6788 | SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_FIX_DALLAS), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6789 | {} |
| 6790 | }; |
| 6791 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6792 | /* |
| 6793 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6794 | static int patch_alc861vd(struct hda_codec *codec) |
| 6795 | { |
| 6796 | struct alc_spec *spec; |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6797 | int err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6798 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6799 | err = alc_alloc_spec(codec, 0x0b); |
| 6800 | if (err < 0) |
| 6801 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6802 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6803 | spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6804 | |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6805 | alc_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups); |
| 6806 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6807 | |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6808 | /* automatic parse from the BIOS config */ |
| 6809 | err = alc861vd_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6810 | if (err < 0) |
| 6811 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6812 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6813 | if (!spec->no_analog) { |
| 6814 | err = snd_hda_attach_beep_device(codec, 0x23); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6815 | if (err < 0) |
| 6816 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6817 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
| 6818 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6819 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6820 | codec->patch_ops = alc_patch_ops; |
| 6821 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6822 | spec->shutup = alc_eapd_shutup; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6823 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 6824 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 6825 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6826 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6827 | |
| 6828 | error: |
| 6829 | alc_free(codec); |
| 6830 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6831 | } |
| 6832 | |
| 6833 | /* |
| 6834 | * ALC662 support |
| 6835 | * |
| 6836 | * ALC662 is almost identical with ALC880 but has cleaner and more flexible |
| 6837 | * configuration. Each pin widget can choose any input DACs and a mixer. |
| 6838 | * Each ADC is connected from a mixer of all inputs. This makes possible |
| 6839 | * 6-channel independent captures. |
| 6840 | * |
| 6841 | * In addition, an independent DAC for the multi-playback (not used in this |
| 6842 | * driver yet). |
| 6843 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6844 | |
| 6845 | /* |
| 6846 | * BIOS auto configuration |
| 6847 | */ |
| 6848 | |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6849 | static int alc662_parse_auto_config(struct hda_codec *codec) |
| 6850 | { |
Takashi Iwai | 4c6d72d | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 6851 | static const hda_nid_t alc662_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6852 | static const hda_nid_t alc663_ssids[] = { 0x15, 0x1b, 0x14, 0x21 }; |
| 6853 | static const hda_nid_t alc662_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 6854 | const hda_nid_t *ssids; |
Takashi Iwai | ee979a14 | 2008-09-02 15:42:20 +0200 | [diff] [blame] | 6855 | |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 6856 | if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 || |
| 6857 | codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670) |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6858 | ssids = alc663_ssids; |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 6859 | else |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6860 | ssids = alc662_ssids; |
| 6861 | return alc_parse_auto_config(codec, alc662_ignore, ssids); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6862 | } |
| 6863 | |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 6864 | static void alc272_fixup_mario(struct hda_codec *codec, |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 6865 | const struct alc_fixup *fix, int action) |
Takashi Iwai | 6fc398c | 2011-01-13 14:36:37 +0100 | [diff] [blame] | 6866 | { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 6867 | if (action != ALC_FIXUP_ACT_PROBE) |
Takashi Iwai | 6fc398c | 2011-01-13 14:36:37 +0100 | [diff] [blame] | 6868 | return; |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 6869 | if (snd_hda_override_amp_caps(codec, 0x2, HDA_OUTPUT, |
| 6870 | (0x3b << AC_AMPCAP_OFFSET_SHIFT) | |
| 6871 | (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT) | |
| 6872 | (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT) | |
| 6873 | (0 << AC_AMPCAP_MUTE_SHIFT))) |
| 6874 | printk(KERN_WARNING |
| 6875 | "hda_codec: failed to override amp caps for NID 0x2\n"); |
| 6876 | } |
| 6877 | |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6878 | enum { |
Daniel T Chen | 2df0351 | 2010-10-10 22:39:28 -0400 | [diff] [blame] | 6879 | ALC662_FIXUP_ASPIRE, |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6880 | ALC662_FIXUP_IDEAPAD, |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 6881 | ALC272_FIXUP_MARIO, |
Anisse Astier | d2ebd47 | 2011-01-20 12:36:21 +0100 | [diff] [blame] | 6882 | ALC662_FIXUP_CZC_P10T, |
David Henningsson | 94024cd | 2011-04-29 14:10:55 +0200 | [diff] [blame] | 6883 | ALC662_FIXUP_SKU_IGNORE, |
Takashi Iwai | e59ea3e | 2011-06-29 17:21:00 +0200 | [diff] [blame] | 6884 | ALC662_FIXUP_HP_RP5800, |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6885 | ALC662_FIXUP_ASUS_MODE1, |
| 6886 | ALC662_FIXUP_ASUS_MODE2, |
| 6887 | ALC662_FIXUP_ASUS_MODE3, |
| 6888 | ALC662_FIXUP_ASUS_MODE4, |
| 6889 | ALC662_FIXUP_ASUS_MODE5, |
| 6890 | ALC662_FIXUP_ASUS_MODE6, |
| 6891 | ALC662_FIXUP_ASUS_MODE7, |
| 6892 | ALC662_FIXUP_ASUS_MODE8, |
Takashi Iwai | 1565cc3 | 2012-02-13 12:03:25 +0100 | [diff] [blame] | 6893 | ALC662_FIXUP_NO_JACK_DETECT, |
David Henningsson | edfe3bf | 2012-06-12 13:15:12 +0200 | [diff] [blame] | 6894 | ALC662_FIXUP_ZOTAC_Z68, |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 6895 | ALC662_FIXUP_INV_DMIC, |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6896 | }; |
| 6897 | |
| 6898 | static const struct alc_fixup alc662_fixups[] = { |
Daniel T Chen | 2df0351 | 2010-10-10 22:39:28 -0400 | [diff] [blame] | 6899 | [ALC662_FIXUP_ASPIRE] = { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 6900 | .type = ALC_FIXUP_PINS, |
| 6901 | .v.pins = (const struct alc_pincfg[]) { |
Daniel T Chen | 2df0351 | 2010-10-10 22:39:28 -0400 | [diff] [blame] | 6902 | { 0x15, 0x99130112 }, /* subwoofer */ |
| 6903 | { } |
| 6904 | } |
| 6905 | }, |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6906 | [ALC662_FIXUP_IDEAPAD] = { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 6907 | .type = ALC_FIXUP_PINS, |
| 6908 | .v.pins = (const struct alc_pincfg[]) { |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6909 | { 0x17, 0x99130112 }, /* subwoofer */ |
| 6910 | { } |
| 6911 | } |
| 6912 | }, |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 6913 | [ALC272_FIXUP_MARIO] = { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 6914 | .type = ALC_FIXUP_FUNC, |
| 6915 | .v.func = alc272_fixup_mario, |
Anisse Astier | d2ebd47 | 2011-01-20 12:36:21 +0100 | [diff] [blame] | 6916 | }, |
| 6917 | [ALC662_FIXUP_CZC_P10T] = { |
| 6918 | .type = ALC_FIXUP_VERBS, |
| 6919 | .v.verbs = (const struct hda_verb[]) { |
| 6920 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0}, |
| 6921 | {} |
| 6922 | } |
| 6923 | }, |
David Henningsson | 94024cd | 2011-04-29 14:10:55 +0200 | [diff] [blame] | 6924 | [ALC662_FIXUP_SKU_IGNORE] = { |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 6925 | .type = ALC_FIXUP_FUNC, |
| 6926 | .v.func = alc_fixup_sku_ignore, |
Takashi Iwai | c6b3587 | 2011-03-28 12:05:31 +0200 | [diff] [blame] | 6927 | }, |
Takashi Iwai | e59ea3e | 2011-06-29 17:21:00 +0200 | [diff] [blame] | 6928 | [ALC662_FIXUP_HP_RP5800] = { |
| 6929 | .type = ALC_FIXUP_PINS, |
| 6930 | .v.pins = (const struct alc_pincfg[]) { |
| 6931 | { 0x14, 0x0221201f }, /* HP out */ |
| 6932 | { } |
| 6933 | }, |
| 6934 | .chained = true, |
| 6935 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6936 | }, |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6937 | [ALC662_FIXUP_ASUS_MODE1] = { |
| 6938 | .type = ALC_FIXUP_PINS, |
| 6939 | .v.pins = (const struct alc_pincfg[]) { |
| 6940 | { 0x14, 0x99130110 }, /* speaker */ |
| 6941 | { 0x18, 0x01a19c20 }, /* mic */ |
| 6942 | { 0x19, 0x99a3092f }, /* int-mic */ |
| 6943 | { 0x21, 0x0121401f }, /* HP out */ |
| 6944 | { } |
| 6945 | }, |
| 6946 | .chained = true, |
| 6947 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6948 | }, |
| 6949 | [ALC662_FIXUP_ASUS_MODE2] = { |
Takashi Iwai | 2996bdb | 2011-08-18 16:02:24 +0200 | [diff] [blame] | 6950 | .type = ALC_FIXUP_PINS, |
| 6951 | .v.pins = (const struct alc_pincfg[]) { |
| 6952 | { 0x14, 0x99130110 }, /* speaker */ |
| 6953 | { 0x18, 0x01a19820 }, /* mic */ |
| 6954 | { 0x19, 0x99a3092f }, /* int-mic */ |
| 6955 | { 0x1b, 0x0121401f }, /* HP out */ |
| 6956 | { } |
| 6957 | }, |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6958 | .chained = true, |
| 6959 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6960 | }, |
| 6961 | [ALC662_FIXUP_ASUS_MODE3] = { |
| 6962 | .type = ALC_FIXUP_PINS, |
| 6963 | .v.pins = (const struct alc_pincfg[]) { |
| 6964 | { 0x14, 0x99130110 }, /* speaker */ |
| 6965 | { 0x15, 0x0121441f }, /* HP */ |
| 6966 | { 0x18, 0x01a19840 }, /* mic */ |
| 6967 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 6968 | { 0x21, 0x01211420 }, /* HP2 */ |
| 6969 | { } |
| 6970 | }, |
| 6971 | .chained = true, |
| 6972 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6973 | }, |
| 6974 | [ALC662_FIXUP_ASUS_MODE4] = { |
| 6975 | .type = ALC_FIXUP_PINS, |
| 6976 | .v.pins = (const struct alc_pincfg[]) { |
| 6977 | { 0x14, 0x99130110 }, /* speaker */ |
| 6978 | { 0x16, 0x99130111 }, /* speaker */ |
| 6979 | { 0x18, 0x01a19840 }, /* mic */ |
| 6980 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 6981 | { 0x21, 0x0121441f }, /* HP */ |
| 6982 | { } |
| 6983 | }, |
| 6984 | .chained = true, |
| 6985 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6986 | }, |
| 6987 | [ALC662_FIXUP_ASUS_MODE5] = { |
| 6988 | .type = ALC_FIXUP_PINS, |
| 6989 | .v.pins = (const struct alc_pincfg[]) { |
| 6990 | { 0x14, 0x99130110 }, /* speaker */ |
| 6991 | { 0x15, 0x0121441f }, /* HP */ |
| 6992 | { 0x16, 0x99130111 }, /* speaker */ |
| 6993 | { 0x18, 0x01a19840 }, /* mic */ |
| 6994 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 6995 | { } |
| 6996 | }, |
| 6997 | .chained = true, |
| 6998 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6999 | }, |
| 7000 | [ALC662_FIXUP_ASUS_MODE6] = { |
| 7001 | .type = ALC_FIXUP_PINS, |
| 7002 | .v.pins = (const struct alc_pincfg[]) { |
| 7003 | { 0x14, 0x99130110 }, /* speaker */ |
| 7004 | { 0x15, 0x01211420 }, /* HP2 */ |
| 7005 | { 0x18, 0x01a19840 }, /* mic */ |
| 7006 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 7007 | { 0x1b, 0x0121441f }, /* HP */ |
| 7008 | { } |
| 7009 | }, |
| 7010 | .chained = true, |
| 7011 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 7012 | }, |
| 7013 | [ALC662_FIXUP_ASUS_MODE7] = { |
| 7014 | .type = ALC_FIXUP_PINS, |
| 7015 | .v.pins = (const struct alc_pincfg[]) { |
| 7016 | { 0x14, 0x99130110 }, /* speaker */ |
| 7017 | { 0x17, 0x99130111 }, /* speaker */ |
| 7018 | { 0x18, 0x01a19840 }, /* mic */ |
| 7019 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 7020 | { 0x1b, 0x01214020 }, /* HP */ |
| 7021 | { 0x21, 0x0121401f }, /* HP */ |
| 7022 | { } |
| 7023 | }, |
| 7024 | .chained = true, |
| 7025 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 7026 | }, |
| 7027 | [ALC662_FIXUP_ASUS_MODE8] = { |
| 7028 | .type = ALC_FIXUP_PINS, |
| 7029 | .v.pins = (const struct alc_pincfg[]) { |
| 7030 | { 0x14, 0x99130110 }, /* speaker */ |
| 7031 | { 0x12, 0x99a30970 }, /* int-mic */ |
| 7032 | { 0x15, 0x01214020 }, /* HP */ |
| 7033 | { 0x17, 0x99130111 }, /* speaker */ |
| 7034 | { 0x18, 0x01a19840 }, /* mic */ |
| 7035 | { 0x21, 0x0121401f }, /* HP */ |
| 7036 | { } |
| 7037 | }, |
| 7038 | .chained = true, |
| 7039 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
Takashi Iwai | 2996bdb | 2011-08-18 16:02:24 +0200 | [diff] [blame] | 7040 | }, |
Takashi Iwai | 1565cc3 | 2012-02-13 12:03:25 +0100 | [diff] [blame] | 7041 | [ALC662_FIXUP_NO_JACK_DETECT] = { |
| 7042 | .type = ALC_FIXUP_FUNC, |
| 7043 | .v.func = alc_fixup_no_jack_detect, |
| 7044 | }, |
David Henningsson | edfe3bf | 2012-06-12 13:15:12 +0200 | [diff] [blame] | 7045 | [ALC662_FIXUP_ZOTAC_Z68] = { |
| 7046 | .type = ALC_FIXUP_PINS, |
| 7047 | .v.pins = (const struct alc_pincfg[]) { |
| 7048 | { 0x1b, 0x02214020 }, /* Front HP */ |
| 7049 | { } |
| 7050 | } |
| 7051 | }, |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 7052 | [ALC662_FIXUP_INV_DMIC] = { |
| 7053 | .type = ALC_FIXUP_FUNC, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 7054 | .v.func = alc_fixup_inv_dmic_0x12, |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 7055 | }, |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 7056 | }; |
| 7057 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 7058 | static const struct snd_pci_quirk alc662_fixup_tbl[] = { |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 7059 | SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_FIXUP_ASUS_MODE2), |
David Henningsson | a6c47a8 | 2011-02-10 15:39:19 +0100 | [diff] [blame] | 7060 | SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE), |
David Henningsson | 94024cd | 2011-04-29 14:10:55 +0200 | [diff] [blame] | 7061 | SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE), |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 7062 | SND_PCI_QUIRK(0x1025, 0x0349, "eMachines eM250", ALC662_FIXUP_INV_DMIC), |
Daniel T Chen | 2df0351 | 2010-10-10 22:39:28 -0400 | [diff] [blame] | 7063 | SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE), |
Takashi Iwai | e59ea3e | 2011-06-29 17:21:00 +0200 | [diff] [blame] | 7064 | SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800), |
Takashi Iwai | 1565cc3 | 2012-02-13 12:03:25 +0100 | [diff] [blame] | 7065 | SND_PCI_QUIRK(0x1043, 0x8469, "ASUS mobo", ALC662_FIXUP_NO_JACK_DETECT), |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 7066 | SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2), |
Daniel T Chen | a0e90ac | 2010-11-20 10:20:35 -0500 | [diff] [blame] | 7067 | SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD), |
Valentine Sinitsyn | d411858 | 2010-10-01 22:24:08 +0600 | [diff] [blame] | 7068 | SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD), |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 7069 | SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD), |
David Henningsson | edfe3bf | 2012-06-12 13:15:12 +0200 | [diff] [blame] | 7070 | SND_PCI_QUIRK(0x19da, 0xa130, "Zotac Z68", ALC662_FIXUP_ZOTAC_Z68), |
Anisse Astier | d2ebd47 | 2011-01-20 12:36:21 +0100 | [diff] [blame] | 7071 | SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T), |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 7072 | |
| 7073 | #if 0 |
| 7074 | /* Below is a quirk table taken from the old code. |
| 7075 | * Basically the device should work as is without the fixup table. |
| 7076 | * If BIOS doesn't give a proper info, enable the corresponding |
| 7077 | * fixup entry. |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 7078 | */ |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 7079 | SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC662_FIXUP_ASUS_MODE1), |
| 7080 | SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC662_FIXUP_ASUS_MODE3), |
| 7081 | SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC662_FIXUP_ASUS_MODE1), |
| 7082 | SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC662_FIXUP_ASUS_MODE3), |
| 7083 | SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), |
| 7084 | SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 7085 | SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), |
| 7086 | SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC662_FIXUP_ASUS_MODE1), |
| 7087 | SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC662_FIXUP_ASUS_MODE1), |
| 7088 | SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 7089 | SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC662_FIXUP_ASUS_MODE7), |
| 7090 | SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC662_FIXUP_ASUS_MODE7), |
| 7091 | SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC662_FIXUP_ASUS_MODE8), |
| 7092 | SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC662_FIXUP_ASUS_MODE3), |
| 7093 | SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC662_FIXUP_ASUS_MODE1), |
| 7094 | SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 7095 | SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_FIXUP_ASUS_MODE2), |
| 7096 | SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC662_FIXUP_ASUS_MODE1), |
| 7097 | SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 7098 | SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC662_FIXUP_ASUS_MODE6), |
| 7099 | SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC662_FIXUP_ASUS_MODE6), |
| 7100 | SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 7101 | SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC662_FIXUP_ASUS_MODE1), |
| 7102 | SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC662_FIXUP_ASUS_MODE3), |
| 7103 | SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_FIXUP_ASUS_MODE2), |
| 7104 | SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 7105 | SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC662_FIXUP_ASUS_MODE5), |
| 7106 | SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC662_FIXUP_ASUS_MODE6), |
| 7107 | SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 7108 | SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC662_FIXUP_ASUS_MODE1), |
| 7109 | SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 7110 | SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 7111 | SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC662_FIXUP_ASUS_MODE3), |
| 7112 | SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC662_FIXUP_ASUS_MODE3), |
| 7113 | SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC662_FIXUP_ASUS_MODE1), |
| 7114 | SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC662_FIXUP_ASUS_MODE1), |
| 7115 | SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC662_FIXUP_ASUS_MODE1), |
| 7116 | SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC662_FIXUP_ASUS_MODE1), |
| 7117 | SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC662_FIXUP_ASUS_MODE1), |
| 7118 | SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 7119 | SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_FIXUP_ASUS_MODE2), |
| 7120 | SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC662_FIXUP_ASUS_MODE1), |
| 7121 | SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), |
| 7122 | SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC662_FIXUP_ASUS_MODE3), |
| 7123 | SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC662_FIXUP_ASUS_MODE1), |
| 7124 | SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC662_FIXUP_ASUS_MODE1), |
| 7125 | SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC662_FIXUP_ASUS_MODE1), |
| 7126 | SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_FIXUP_ASUS_MODE2), |
| 7127 | SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), |
| 7128 | SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE4), |
| 7129 | #endif |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 7130 | {} |
| 7131 | }; |
| 7132 | |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 7133 | static const struct alc_model_fixup alc662_fixup_models[] = { |
| 7134 | {.id = ALC272_FIXUP_MARIO, .name = "mario"}, |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 7135 | {.id = ALC662_FIXUP_ASUS_MODE1, .name = "asus-mode1"}, |
| 7136 | {.id = ALC662_FIXUP_ASUS_MODE2, .name = "asus-mode2"}, |
| 7137 | {.id = ALC662_FIXUP_ASUS_MODE3, .name = "asus-mode3"}, |
| 7138 | {.id = ALC662_FIXUP_ASUS_MODE4, .name = "asus-mode4"}, |
| 7139 | {.id = ALC662_FIXUP_ASUS_MODE5, .name = "asus-mode5"}, |
| 7140 | {.id = ALC662_FIXUP_ASUS_MODE6, .name = "asus-mode6"}, |
| 7141 | {.id = ALC662_FIXUP_ASUS_MODE7, .name = "asus-mode7"}, |
| 7142 | {.id = ALC662_FIXUP_ASUS_MODE8, .name = "asus-mode8"}, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 7143 | {.id = ALC662_FIXUP_INV_DMIC, .name = "inv-dmic"}, |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 7144 | {} |
| 7145 | }; |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 7146 | |
Kailang Yang | 8663ff7 | 2012-06-29 09:35:52 +0200 | [diff] [blame] | 7147 | static void alc662_fill_coef(struct hda_codec *codec) |
| 7148 | { |
| 7149 | int val, coef; |
| 7150 | |
| 7151 | coef = alc_get_coef0(codec); |
| 7152 | |
| 7153 | switch (codec->vendor_id) { |
| 7154 | case 0x10ec0662: |
| 7155 | if ((coef & 0x00f0) == 0x0030) { |
| 7156 | val = alc_read_coef_idx(codec, 0x4); /* EAPD Ctrl */ |
| 7157 | alc_write_coef_idx(codec, 0x4, val & ~(1<<10)); |
| 7158 | } |
| 7159 | break; |
| 7160 | case 0x10ec0272: |
| 7161 | case 0x10ec0273: |
| 7162 | case 0x10ec0663: |
| 7163 | case 0x10ec0665: |
| 7164 | case 0x10ec0670: |
| 7165 | case 0x10ec0671: |
| 7166 | case 0x10ec0672: |
| 7167 | val = alc_read_coef_idx(codec, 0xd); /* EAPD Ctrl */ |
| 7168 | alc_write_coef_idx(codec, 0xd, val | (1<<14)); |
| 7169 | break; |
| 7170 | } |
| 7171 | } |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 7172 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 7173 | /* |
| 7174 | */ |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7175 | static int patch_alc662(struct hda_codec *codec) |
| 7176 | { |
| 7177 | struct alc_spec *spec; |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 7178 | int err; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7179 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 7180 | err = alc_alloc_spec(codec, 0x0b); |
| 7181 | if (err < 0) |
| 7182 | return err; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7183 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 7184 | spec = codec->spec; |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 7185 | |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 7186 | /* handle multiple HPs as is */ |
| 7187 | spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP; |
| 7188 | |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 7189 | alc_fix_pll_init(codec, 0x20, 0x04, 15); |
| 7190 | |
Kailang Yang | 8663ff7 | 2012-06-29 09:35:52 +0200 | [diff] [blame] | 7191 | spec->init_hook = alc662_fill_coef; |
| 7192 | alc662_fill_coef(codec); |
| 7193 | |
Takashi Iwai | 8e5a050 | 2012-06-21 15:49:33 +0200 | [diff] [blame] | 7194 | alc_pick_fixup(codec, alc662_fixup_models, |
| 7195 | alc662_fixup_tbl, alc662_fixups); |
| 7196 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
| 7197 | |
| 7198 | alc_auto_parse_customize_define(codec); |
| 7199 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 7200 | if ((alc_get_coef0(codec) & (1 << 14)) && |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 7201 | codec->bus->pci->subsystem_vendor == 0x1025 && |
| 7202 | spec->cdefine.platform_type == 1) { |
| 7203 | if (alc_codec_rename(codec, "ALC272X") < 0) |
| 7204 | goto error; |
Takashi Iwai | 20ca0c3 | 2011-10-17 16:00:35 +0200 | [diff] [blame] | 7205 | } |
Kailang Yang | 274693f | 2009-12-03 10:07:50 +0100 | [diff] [blame] | 7206 | |
Takashi Iwai | b9c5106 | 2011-08-24 18:08:07 +0200 | [diff] [blame] | 7207 | /* automatic parse from the BIOS config */ |
| 7208 | err = alc662_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 7209 | if (err < 0) |
| 7210 | goto error; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7211 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 7212 | if (!spec->no_analog && has_cdefine_beep(codec)) { |
| 7213 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 7214 | if (err < 0) |
| 7215 | goto error; |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 7216 | switch (codec->vendor_id) { |
| 7217 | case 0x10ec0662: |
| 7218 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
| 7219 | break; |
| 7220 | case 0x10ec0272: |
| 7221 | case 0x10ec0663: |
| 7222 | case 0x10ec0665: |
| 7223 | set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); |
| 7224 | break; |
| 7225 | case 0x10ec0273: |
| 7226 | set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT); |
| 7227 | break; |
| 7228 | } |
Kailang Yang | cec27c8 | 2010-02-04 14:18:18 +0100 | [diff] [blame] | 7229 | } |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 7230 | |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7231 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1c71615 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 7232 | spec->shutup = alc_eapd_shutup; |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 7233 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 7234 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 7235 | |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7236 | return 0; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7237 | |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 7238 | error: |
| 7239 | alc_free(codec); |
| 7240 | return err; |
Kailang Yang | b478b99 | 2011-05-18 11:51:15 +0200 | [diff] [blame] | 7241 | } |
| 7242 | |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7243 | /* |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7244 | * ALC680 support |
| 7245 | */ |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7246 | |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7247 | static int alc680_parse_auto_config(struct hda_codec *codec) |
| 7248 | { |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 7249 | return alc_parse_auto_config(codec, NULL, NULL); |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7250 | } |
| 7251 | |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7252 | /* |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7253 | */ |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7254 | static int patch_alc680(struct hda_codec *codec) |
| 7255 | { |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7256 | int err; |
| 7257 | |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 7258 | /* ALC680 has no aa-loopback mixer */ |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 7259 | err = alc_alloc_spec(codec, 0); |
| 7260 | if (err < 0) |
| 7261 | return err; |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 7262 | |
Takashi Iwai | 1ebec5f | 2011-08-15 13:21:48 +0200 | [diff] [blame] | 7263 | /* automatic parse from the BIOS config */ |
| 7264 | err = alc680_parse_auto_config(codec); |
| 7265 | if (err < 0) { |
| 7266 | alc_free(codec); |
| 7267 | return err; |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7268 | } |
| 7269 | |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7270 | codec->patch_ops = alc_patch_ops; |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7271 | |
| 7272 | return 0; |
| 7273 | } |
| 7274 | |
| 7275 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7276 | * patch entries |
| 7277 | */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 7278 | static const struct hda_codec_preset snd_hda_preset_realtek[] = { |
Kailang Yang | 296f033 | 2011-05-18 11:52:36 +0200 | [diff] [blame] | 7279 | { .id = 0x10ec0221, .name = "ALC221", .patch = patch_alc269 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7280 | { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 7281 | { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 }, |
Kailang Yang | f6a9224 | 2007-12-13 16:52:54 +0100 | [diff] [blame] | 7282 | { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 }, |
Kailang Yang | a361d84 | 2007-06-05 12:30:55 +0200 | [diff] [blame] | 7283 | { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 }, |
Kailang Yang | f6a9224 | 2007-12-13 16:52:54 +0100 | [diff] [blame] | 7284 | { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 }, |
Kailang Yang | ebb83ee | 2009-12-17 12:23:00 +0100 | [diff] [blame] | 7285 | { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 }, |
Kailang Yang | 01afd41 | 2008-10-15 11:22:09 +0200 | [diff] [blame] | 7286 | { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 }, |
Kailang Yang | ebb83ee | 2009-12-17 12:23:00 +0100 | [diff] [blame] | 7287 | { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 }, |
Kailang Yang | 296f033 | 2011-05-18 11:52:36 +0200 | [diff] [blame] | 7288 | { .id = 0x10ec0276, .name = "ALC276", .patch = patch_alc269 }, |
David Henningsson | befae82 | 2012-06-25 19:49:28 +0200 | [diff] [blame] | 7289 | { .id = 0x10ec0280, .name = "ALC280", .patch = patch_alc269 }, |
David Henningsson | 4e01ec6 | 2012-07-18 07:38:46 +0200 | [diff] [blame] | 7290 | { .id = 0x10ec0282, .name = "ALC282", .patch = patch_alc269 }, |
Kailang Yang | 7ff34ad | 2012-10-06 17:02:30 +0200 | [diff] [blame] | 7291 | { .id = 0x10ec0283, .name = "ALC283", .patch = patch_alc269 }, |
Kailang Yang | 065380f | 2013-01-10 10:25:48 +0100 | [diff] [blame] | 7292 | { .id = 0x10ec0284, .name = "ALC284", .patch = patch_alc269 }, |
Kailang Yang | 7ff34ad | 2012-10-06 17:02:30 +0200 | [diff] [blame] | 7293 | { .id = 0x10ec0290, .name = "ALC290", .patch = patch_alc269 }, |
David Henningsson | af02dde | 2012-11-21 08:57:58 +0100 | [diff] [blame] | 7294 | { .id = 0x10ec0292, .name = "ALC292", .patch = patch_alc269 }, |
Jakub Schmidtke | f32610e | 2007-02-02 18:17:27 +0100 | [diff] [blame] | 7295 | { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660", |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7296 | .patch = patch_alc861 }, |
Jakub Schmidtke | f32610e | 2007-02-02 18:17:27 +0100 | [diff] [blame] | 7297 | { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd }, |
| 7298 | { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 }, |
| 7299 | { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd }, |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7300 | { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2", |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 7301 | .patch = patch_alc882 }, |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7302 | { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1", |
| 7303 | .patch = patch_alc662 }, |
David Henningsson | cc667a7 | 2011-10-18 14:07:51 +0200 | [diff] [blame] | 7304 | { .id = 0x10ec0662, .rev = 0x100300, .name = "ALC662 rev3", |
| 7305 | .patch = patch_alc662 }, |
Kailang Yang | 6dda9f4 | 2008-05-27 12:05:31 +0200 | [diff] [blame] | 7306 | { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 }, |
Kailang Yang | cec27c8 | 2010-02-04 14:18:18 +0100 | [diff] [blame] | 7307 | { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 }, |
Kailang Yang | 19a6282 | 2012-11-08 10:25:37 +0100 | [diff] [blame] | 7308 | { .id = 0x10ec0668, .name = "ALC668", .patch = patch_alc662 }, |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 7309 | { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 }, |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7310 | { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 }, |
Jakub Schmidtke | f32610e | 2007-02-02 18:17:27 +0100 | [diff] [blame] | 7311 | { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7312 | { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 }, |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 7313 | { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 }, |
Clive Messer | 669faba | 2008-09-30 15:49:13 +0200 | [diff] [blame] | 7314 | { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A", |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 7315 | .patch = patch_alc882 }, |
Takashi Iwai | cb308f9 | 2008-04-16 14:13:29 +0200 | [diff] [blame] | 7316 | { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A", |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 7317 | .patch = patch_alc882 }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 7318 | { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 }, |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 7319 | { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 }, |
Kailang Yang | 4442608 | 2008-10-15 11:18:05 +0200 | [diff] [blame] | 7320 | { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200", |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 7321 | .patch = patch_alc882 }, |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 7322 | { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc882 }, |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 7323 | { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 }, |
Kailang Yang | 274693f | 2009-12-03 10:07:50 +0100 | [diff] [blame] | 7324 | { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 }, |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 7325 | { .id = 0x10ec0899, .name = "ALC898", .patch = patch_alc882 }, |
Kailang Yang | 19a6282 | 2012-11-08 10:25:37 +0100 | [diff] [blame] | 7326 | { .id = 0x10ec0900, .name = "ALC1150", .patch = patch_alc882 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7327 | {} /* terminator */ |
| 7328 | }; |
Takashi Iwai | 1289e9e | 2008-11-27 15:47:11 +0100 | [diff] [blame] | 7329 | |
| 7330 | MODULE_ALIAS("snd-hda-codec-id:10ec*"); |
| 7331 | |
| 7332 | MODULE_LICENSE("GPL"); |
| 7333 | MODULE_DESCRIPTION("Realtek HD-audio codec"); |
| 7334 | |
| 7335 | static struct hda_codec_preset_list realtek_list = { |
| 7336 | .preset = snd_hda_preset_realtek, |
| 7337 | .owner = THIS_MODULE, |
| 7338 | }; |
| 7339 | |
| 7340 | static int __init patch_realtek_init(void) |
| 7341 | { |
| 7342 | return snd_hda_add_codec_preset(&realtek_list); |
| 7343 | } |
| 7344 | |
| 7345 | static void __exit patch_realtek_exit(void) |
| 7346 | { |
| 7347 | snd_hda_delete_codec_preset(&realtek_list); |
| 7348 | } |
| 7349 | |
| 7350 | module_init(patch_realtek_init) |
| 7351 | module_exit(patch_realtek_exit) |