Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Universal Interface for Intel High Definition Audio Codec |
| 3 | * |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4 | * HD audio interface patch for Realtek ALC codecs |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | * |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 6 | * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw> |
| 7 | * PeiSen Hou <pshou@realtek.com.tw> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | * Takashi Iwai <tiwai@suse.de> |
Jonathan Woithe | 7cf51e48 | 2006-02-09 12:01:26 +0100 | [diff] [blame] | 9 | * Jonathan Woithe <jwoithe@physics.adelaide.edu.au> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | * |
| 11 | * This driver is free software; you can redistribute it and/or modify |
| 12 | * it under the terms of the GNU General Public License as published by |
| 13 | * the Free Software Foundation; either version 2 of the License, or |
| 14 | * (at your option) any later version. |
| 15 | * |
| 16 | * This driver is distributed in the hope that it will be useful, |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 | * GNU General Public License for more details. |
| 20 | * |
| 21 | * You should have received a copy of the GNU General Public License |
| 22 | * along with this program; if not, write to the Free Software |
| 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 24 | */ |
| 25 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | #include <linux/init.h> |
| 27 | #include <linux/delay.h> |
| 28 | #include <linux/slab.h> |
| 29 | #include <linux/pci.h> |
| 30 | #include <sound/core.h> |
Kailang Yang | 9ad0e49 | 2010-09-14 23:22:00 +0200 | [diff] [blame] | 31 | #include <sound/jack.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | #include "hda_codec.h" |
| 33 | #include "hda_local.h" |
Kusanagi Kouichi | 680cd53 | 2009-02-05 00:00:58 +0900 | [diff] [blame] | 34 | #include "hda_beep.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 36 | /* unsol event tags */ |
| 37 | #define ALC_FRONT_EVENT 0x01 |
| 38 | #define ALC_DCVOL_EVENT 0x02 |
| 39 | #define ALC_HP_EVENT 0x04 |
| 40 | #define ALC_MIC_EVENT 0x08 |
Takashi Iwai | d4a86d8 | 2010-06-23 17:51:26 +0200 | [diff] [blame] | 41 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 42 | /* for GPIO Poll */ |
| 43 | #define GPIO_MASK 0x03 |
| 44 | |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 45 | /* extra amp-initialization sequence types */ |
| 46 | enum { |
| 47 | ALC_INIT_NONE, |
| 48 | ALC_INIT_DEFAULT, |
| 49 | ALC_INIT_GPIO1, |
| 50 | ALC_INIT_GPIO2, |
| 51 | ALC_INIT_GPIO3, |
| 52 | }; |
| 53 | |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 54 | struct alc_customize_define { |
| 55 | unsigned int sku_cfg; |
| 56 | unsigned char port_connectivity; |
| 57 | unsigned char check_sum; |
| 58 | unsigned char customization; |
| 59 | unsigned char external_amp; |
| 60 | unsigned int enable_pcbeep:1; |
| 61 | unsigned int platform_type:1; |
| 62 | unsigned int swap:1; |
| 63 | unsigned int override:1; |
David Henningsson | 9062291 | 2010-10-14 14:50:18 +0200 | [diff] [blame] | 64 | 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] | 65 | }; |
| 66 | |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 67 | struct alc_fixup; |
| 68 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 69 | struct alc_multi_io { |
| 70 | hda_nid_t pin; /* multi-io widget pin NID */ |
| 71 | hda_nid_t dac; /* DAC to be connected */ |
| 72 | unsigned int ctl_in; /* cached input-pin control value */ |
| 73 | }; |
| 74 | |
Takashi Iwai | d922b51 | 2011-04-28 12:18:53 +0200 | [diff] [blame] | 75 | enum { |
Takashi Iwai | 3b8510c | 2011-04-28 14:03:24 +0200 | [diff] [blame] | 76 | ALC_AUTOMUTE_PIN, /* change the pin control */ |
| 77 | ALC_AUTOMUTE_AMP, /* mute/unmute the pin AMP */ |
| 78 | ALC_AUTOMUTE_MIXER, /* mute/unmute mixer widget AMP */ |
Takashi Iwai | d922b51 | 2011-04-28 12:18:53 +0200 | [diff] [blame] | 79 | }; |
| 80 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | struct alc_spec { |
| 82 | /* codec parameterization */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 83 | const struct snd_kcontrol_new *mixers[5]; /* mixer arrays */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | unsigned int num_mixers; |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 85 | const struct snd_kcontrol_new *cap_mixer; /* capture mixer */ |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 86 | unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | |
Takashi Iwai | 2d9c648 | 2009-10-13 08:06:55 +0200 | [diff] [blame] | 88 | const struct hda_verb *init_verbs[10]; /* initialization verbs |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 89 | * don't forget NULL |
| 90 | * termination! |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 91 | */ |
| 92 | unsigned int num_init_verbs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | |
Takashi Iwai | aa563af | 2009-07-31 10:05:11 +0200 | [diff] [blame] | 94 | char stream_name_analog[32]; /* analog PCM stream */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 95 | const struct hda_pcm_stream *stream_analog_playback; |
| 96 | const struct hda_pcm_stream *stream_analog_capture; |
| 97 | const struct hda_pcm_stream *stream_analog_alt_playback; |
| 98 | const struct hda_pcm_stream *stream_analog_alt_capture; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | |
Takashi Iwai | aa563af | 2009-07-31 10:05:11 +0200 | [diff] [blame] | 100 | char stream_name_digital[32]; /* digital PCM stream */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 101 | const struct hda_pcm_stream *stream_digital_playback; |
| 102 | const struct hda_pcm_stream *stream_digital_capture; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | |
| 104 | /* playback */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 105 | struct hda_multi_out multiout; /* playback set-up |
| 106 | * max_channels, dacs must be set |
| 107 | * dig_out_nid and hp_nid are optional |
| 108 | */ |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 109 | hda_nid_t alt_dac_nid; |
Takashi Iwai | 6a05ac4 | 2009-02-13 11:19:09 +0100 | [diff] [blame] | 110 | hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */ |
Takashi Iwai | 8c44198 | 2009-01-20 18:30:20 +0100 | [diff] [blame] | 111 | int dig_out_type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | |
| 113 | /* capture */ |
| 114 | unsigned int num_adc_nids; |
Takashi Iwai | 4c6d72d | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 115 | const hda_nid_t *adc_nids; |
| 116 | const hda_nid_t *capsrc_nids; |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 117 | hda_nid_t dig_in_nid; /* digital-in NID; optional */ |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 118 | hda_nid_t mixer_nid; /* analog-mixer NID */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 120 | /* capture setup for dynamic dual-adc switch */ |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 121 | hda_nid_t cur_adc; |
| 122 | unsigned int cur_adc_stream_tag; |
| 123 | unsigned int cur_adc_format; |
| 124 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | /* capture source */ |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 126 | unsigned int num_mux_defs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | const struct hda_input_mux *input_mux; |
| 128 | unsigned int cur_mux[3]; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 129 | hda_nid_t ext_mic_pin; |
| 130 | hda_nid_t dock_mic_pin; |
| 131 | hda_nid_t int_mic_pin; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | |
| 133 | /* channel model */ |
Takashi Iwai | d2a6d7d | 2005-11-17 11:06:29 +0100 | [diff] [blame] | 134 | const struct hda_channel_mode *channel_mode; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | int num_channel_mode; |
Takashi Iwai | 4e195a7 | 2006-07-28 14:47:34 +0200 | [diff] [blame] | 136 | int need_dac_fix; |
Hector Martin | 3b315d7 | 2009-06-02 10:54:19 +0200 | [diff] [blame] | 137 | int const_channel_count; |
| 138 | int ext_channel_count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | |
| 140 | /* PCM information */ |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 141 | struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */ |
Takashi Iwai | 41e41f1 | 2005-06-08 14:48:49 +0200 | [diff] [blame] | 142 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 143 | /* dynamic controls, init_verbs and input_mux */ |
| 144 | struct auto_pin_cfg autocfg; |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 145 | struct alc_customize_define cdefine; |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 146 | struct snd_array kctls; |
Herton Ronaldo Krzesinski | 61b9b9b | 2009-01-28 09:16:33 -0200 | [diff] [blame] | 147 | struct hda_input_mux private_imux[3]; |
Takashi Iwai | 41923e4 | 2007-10-22 17:20:10 +0200 | [diff] [blame] | 148 | hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 149 | hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS]; |
| 150 | hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS]; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 151 | hda_nid_t imux_pins[HDA_MAX_NUM_INPUTS]; |
| 152 | unsigned int dyn_adc_idx[HDA_MAX_NUM_INPUTS]; |
| 153 | int int_mic_idx, ext_mic_idx, dock_mic_idx; /* for auto-mic */ |
Takashi Iwai | 834be88 | 2006-03-01 14:16:17 +0100 | [diff] [blame] | 154 | |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 155 | /* hooks */ |
| 156 | void (*init_hook)(struct hda_codec *codec); |
| 157 | void (*unsol_event)(struct hda_codec *codec, unsigned int res); |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 158 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 159 | void (*power_hook)(struct hda_codec *codec); |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 160 | #endif |
Takashi Iwai | 1c716153 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 161 | void (*shutup)(struct hda_codec *codec); |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 162 | void (*automute_hook)(struct hda_codec *codec); |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 163 | |
Takashi Iwai | 834be88 | 2006-03-01 14:16:17 +0100 | [diff] [blame] | 164 | /* for pin sensing */ |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 165 | unsigned int hp_jack_present:1; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 166 | unsigned int line_jack_present:1; |
Takashi Iwai | e942796 | 2011-04-28 15:46:07 +0200 | [diff] [blame] | 167 | unsigned int master_mute:1; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 168 | unsigned int auto_mic:1; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 169 | unsigned int auto_mic_valid_imux:1; /* valid imux for auto-mic */ |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 170 | unsigned int automute_speaker:1; /* automute speaker outputs */ |
| 171 | unsigned int automute_lo:1; /* automute LO outputs */ |
| 172 | unsigned int detect_hp:1; /* Headphone detection enabled */ |
| 173 | unsigned int detect_lo:1; /* Line-out detection enabled */ |
| 174 | unsigned int automute_speaker_possible:1; /* there are speakers and either LO or HP */ |
| 175 | unsigned int automute_lo_possible:1; /* there are line outs and HP */ |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 176 | |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 177 | /* other flags */ |
| 178 | unsigned int no_analog :1; /* digital I/O only */ |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 179 | unsigned int dyn_adc_switch:1; /* switch ADCs (for ALC275) */ |
Takashi Iwai | 584c0c4 | 2011-03-10 12:51:11 +0100 | [diff] [blame] | 180 | unsigned int single_input_src:1; |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 181 | unsigned int vol_in_capsrc:1; /* use capsrc volume (ADC has no vol) */ |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 182 | unsigned int parse_flags; /* passed to snd_hda_parse_pin_defcfg() */ |
Takashi Iwai | d922b51 | 2011-04-28 12:18:53 +0200 | [diff] [blame] | 183 | |
| 184 | /* auto-mute control */ |
| 185 | int automute_mode; |
Takashi Iwai | 3b8510c | 2011-04-28 14:03:24 +0200 | [diff] [blame] | 186 | hda_nid_t automute_mixer_nid[AUTO_CFG_MAX_OUTS]; |
Takashi Iwai | d922b51 | 2011-04-28 12:18:53 +0200 | [diff] [blame] | 187 | |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 188 | int init_amp; |
Takashi Iwai | d433a67 | 2010-09-20 15:11:54 +0200 | [diff] [blame] | 189 | int codec_variant; /* flag for other variants */ |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 190 | |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 191 | /* for virtual master */ |
| 192 | hda_nid_t vmaster_nid; |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 193 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 194 | struct hda_loopback_check loopback; |
| 195 | #endif |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 196 | |
| 197 | /* for PLL fix */ |
| 198 | hda_nid_t pll_nid; |
| 199 | unsigned int pll_coef_idx, pll_coef_bit; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 200 | unsigned int coef0; |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 201 | |
| 202 | /* fix-up list */ |
| 203 | int fixup_id; |
| 204 | const struct alc_fixup *fixup_list; |
| 205 | const char *fixup_name; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 206 | |
| 207 | /* multi-io */ |
| 208 | int multi_ios; |
| 209 | struct alc_multi_io multi_io[4]; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 210 | |
| 211 | /* bind volumes */ |
| 212 | struct snd_array bind_ctls; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 213 | }; |
| 214 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 215 | #define ALC_MODEL_AUTO 0 /* common for all chips */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 216 | |
Takashi Iwai | 44c0240 | 2011-07-08 15:14:19 +0200 | [diff] [blame] | 217 | static bool check_amp_caps(struct hda_codec *codec, hda_nid_t nid, |
| 218 | int dir, unsigned int bits) |
| 219 | { |
| 220 | if (!nid) |
| 221 | return false; |
| 222 | if (get_wcaps(codec, nid) & (1 << (dir + 1))) |
| 223 | if (query_amp_caps(codec, nid, dir) & bits) |
| 224 | return true; |
| 225 | return false; |
| 226 | } |
| 227 | |
| 228 | #define nid_has_mute(codec, nid, dir) \ |
| 229 | check_amp_caps(codec, nid, dir, AC_AMPCAP_MUTE) |
| 230 | #define nid_has_volume(codec, nid, dir) \ |
| 231 | check_amp_caps(codec, nid, dir, AC_AMPCAP_NUM_STEPS) |
| 232 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 233 | /* |
| 234 | * input MUX handling |
| 235 | */ |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 236 | static int alc_mux_enum_info(struct snd_kcontrol *kcontrol, |
| 237 | struct snd_ctl_elem_info *uinfo) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 238 | { |
| 239 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 240 | struct alc_spec *spec = codec->spec; |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 241 | unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id); |
| 242 | if (mux_idx >= spec->num_mux_defs) |
| 243 | mux_idx = 0; |
Takashi Iwai | 5311114 | 2010-03-08 12:13:07 +0100 | [diff] [blame] | 244 | if (!spec->input_mux[mux_idx].num_items && mux_idx > 0) |
| 245 | mux_idx = 0; |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 246 | return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 247 | } |
| 248 | |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 249 | static int alc_mux_enum_get(struct snd_kcontrol *kcontrol, |
| 250 | struct snd_ctl_elem_value *ucontrol) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 251 | { |
| 252 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 253 | struct alc_spec *spec = codec->spec; |
| 254 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 255 | |
| 256 | ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; |
| 257 | return 0; |
| 258 | } |
| 259 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 260 | 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] | 261 | { |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 262 | struct alc_spec *spec = codec->spec; |
| 263 | hda_nid_t new_adc = spec->adc_nids[spec->dyn_adc_idx[cur]]; |
| 264 | |
| 265 | if (spec->cur_adc && spec->cur_adc != new_adc) { |
| 266 | /* stream is running, let's swap the current ADC */ |
| 267 | __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1); |
| 268 | spec->cur_adc = new_adc; |
| 269 | snd_hda_codec_setup_stream(codec, new_adc, |
| 270 | spec->cur_adc_stream_tag, 0, |
| 271 | spec->cur_adc_format); |
| 272 | return true; |
| 273 | } |
| 274 | return false; |
| 275 | } |
| 276 | |
| 277 | /* select the given imux item; either unmute exclusively or select the route */ |
| 278 | static int alc_mux_select(struct hda_codec *codec, unsigned int adc_idx, |
| 279 | unsigned int idx, bool force) |
| 280 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 281 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | cd896c3 | 2008-11-18 12:36:33 +0100 | [diff] [blame] | 282 | const struct hda_input_mux *imux; |
Takashi Iwai | cd896c3 | 2008-11-18 12:36:33 +0100 | [diff] [blame] | 283 | unsigned int mux_idx; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 284 | int i, type; |
| 285 | hda_nid_t nid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 286 | |
Takashi Iwai | cd896c3 | 2008-11-18 12:36:33 +0100 | [diff] [blame] | 287 | mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx; |
| 288 | imux = &spec->input_mux[mux_idx]; |
Takashi Iwai | 5311114 | 2010-03-08 12:13:07 +0100 | [diff] [blame] | 289 | if (!imux->num_items && mux_idx > 0) |
| 290 | imux = &spec->input_mux[0]; |
Takashi Iwai | cd896c3 | 2008-11-18 12:36:33 +0100 | [diff] [blame] | 291 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 292 | if (idx >= imux->num_items) |
| 293 | idx = imux->num_items - 1; |
| 294 | if (spec->cur_mux[adc_idx] == idx && !force) |
| 295 | return 0; |
| 296 | spec->cur_mux[adc_idx] = idx; |
| 297 | |
| 298 | if (spec->dyn_adc_switch) { |
| 299 | alc_dyn_adc_pcm_resetup(codec, idx); |
| 300 | adc_idx = spec->dyn_adc_idx[idx]; |
| 301 | } |
| 302 | |
| 303 | nid = spec->capsrc_nids ? |
| 304 | spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx]; |
| 305 | |
| 306 | /* no selection? */ |
| 307 | if (snd_hda_get_conn_list(codec, nid, NULL) <= 1) |
| 308 | return 1; |
| 309 | |
Takashi Iwai | a22d543 | 2009-07-27 12:54:26 +0200 | [diff] [blame] | 310 | type = get_wcaps_type(get_wcaps(codec, nid)); |
Takashi Iwai | 0169b6b | 2009-06-22 10:50:19 +0200 | [diff] [blame] | 311 | if (type == AC_WID_AUD_MIX) { |
Takashi Iwai | 54cbc9a | 2008-10-31 15:24:04 +0100 | [diff] [blame] | 312 | /* Matrix-mixer style (e.g. ALC882) */ |
Takashi Iwai | 54cbc9a | 2008-10-31 15:24:04 +0100 | [diff] [blame] | 313 | for (i = 0; i < imux->num_items; i++) { |
| 314 | unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE; |
| 315 | snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, |
| 316 | imux->items[i].index, |
| 317 | HDA_AMP_MUTE, v); |
| 318 | } |
Takashi Iwai | 54cbc9a | 2008-10-31 15:24:04 +0100 | [diff] [blame] | 319 | } else { |
| 320 | /* MUX style (e.g. ALC880) */ |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 321 | snd_hda_codec_write_cache(codec, nid, 0, |
| 322 | AC_VERB_SET_CONNECT_SEL, |
| 323 | imux->items[idx].index); |
Takashi Iwai | 54cbc9a | 2008-10-31 15:24:04 +0100 | [diff] [blame] | 324 | } |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 325 | return 1; |
| 326 | } |
| 327 | |
| 328 | static int alc_mux_enum_put(struct snd_kcontrol *kcontrol, |
| 329 | struct snd_ctl_elem_value *ucontrol) |
| 330 | { |
| 331 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 332 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 333 | return alc_mux_select(codec, adc_idx, |
| 334 | ucontrol->value.enumerated.item[0], false); |
Takashi Iwai | 54cbc9a | 2008-10-31 15:24:04 +0100 | [diff] [blame] | 335 | } |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 336 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 337 | /* |
Takashi Iwai | 23f0c04 | 2009-02-26 13:03:58 +0100 | [diff] [blame] | 338 | * set up the input pin config (depending on the given auto-pin type) |
| 339 | */ |
| 340 | static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid, |
| 341 | int auto_pin_type) |
| 342 | { |
| 343 | unsigned int val = PIN_IN; |
| 344 | |
Takashi Iwai | 86e2959 | 2010-09-09 14:50:17 +0200 | [diff] [blame] | 345 | if (auto_pin_type == AUTO_PIN_MIC) { |
Takashi Iwai | 23f0c04 | 2009-02-26 13:03:58 +0100 | [diff] [blame] | 346 | unsigned int pincap; |
Takashi Iwai | 954a29c | 2010-07-30 10:55:44 +0200 | [diff] [blame] | 347 | unsigned int oldval; |
| 348 | oldval = snd_hda_codec_read(codec, nid, 0, |
| 349 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
Takashi Iwai | 1327a32 | 2009-03-23 13:07:47 +0100 | [diff] [blame] | 350 | pincap = snd_hda_query_pin_caps(codec, nid); |
Takashi Iwai | 23f0c04 | 2009-02-26 13:03:58 +0100 | [diff] [blame] | 351 | pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT; |
Takashi Iwai | 954a29c | 2010-07-30 10:55:44 +0200 | [diff] [blame] | 352 | /* if the default pin setup is vref50, we give it priority */ |
| 353 | if ((pincap & AC_PINCAP_VREF_80) && oldval != PIN_VREF50) |
Takashi Iwai | 23f0c04 | 2009-02-26 13:03:58 +0100 | [diff] [blame] | 354 | val = PIN_VREF80; |
Takashi Iwai | 461c6c3 | 2009-05-25 08:06:02 +0200 | [diff] [blame] | 355 | else if (pincap & AC_PINCAP_VREF_50) |
| 356 | val = PIN_VREF50; |
| 357 | else if (pincap & AC_PINCAP_VREF_100) |
| 358 | val = PIN_VREF100; |
| 359 | else if (pincap & AC_PINCAP_VREF_GRD) |
| 360 | val = PIN_VREFGRD; |
Takashi Iwai | 23f0c04 | 2009-02-26 13:03:58 +0100 | [diff] [blame] | 361 | } |
| 362 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val); |
| 363 | } |
| 364 | |
| 365 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 366 | * Append the given mixer and verb elements for the later use |
| 367 | * The mixer array is referred in build_controls(), and init_verbs are |
| 368 | * called in init(). |
Takashi Iwai | d88897e | 2008-10-31 15:01:37 +0100 | [diff] [blame] | 369 | */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 370 | 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] | 371 | { |
| 372 | if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers))) |
| 373 | return; |
| 374 | spec->mixers[spec->num_mixers++] = mix; |
| 375 | } |
| 376 | |
| 377 | static void add_verb(struct alc_spec *spec, const struct hda_verb *verb) |
| 378 | { |
| 379 | if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs))) |
| 380 | return; |
| 381 | spec->init_verbs[spec->num_init_verbs++] = verb; |
| 382 | } |
| 383 | |
| 384 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 385 | * GPIO setup tables, used in initialization |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 386 | */ |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 387 | /* Enable GPIO mask and set output */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 388 | static const struct hda_verb alc_gpio1_init_verbs[] = { |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 389 | {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, |
| 390 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, |
| 391 | {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, |
| 392 | { } |
| 393 | }; |
| 394 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 395 | static const struct hda_verb alc_gpio2_init_verbs[] = { |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 396 | {0x01, AC_VERB_SET_GPIO_MASK, 0x02}, |
| 397 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02}, |
| 398 | {0x01, AC_VERB_SET_GPIO_DATA, 0x02}, |
| 399 | { } |
| 400 | }; |
| 401 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 402 | static const struct hda_verb alc_gpio3_init_verbs[] = { |
Kailang Yang | bdd148a | 2007-05-08 15:19:08 +0200 | [diff] [blame] | 403 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, |
| 404 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, |
| 405 | {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, |
| 406 | { } |
| 407 | }; |
| 408 | |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 409 | /* |
| 410 | * Fix hardware PLL issue |
| 411 | * On some codecs, the analog PLL gating control must be off while |
| 412 | * the default value is 1. |
| 413 | */ |
| 414 | static void alc_fix_pll(struct hda_codec *codec) |
| 415 | { |
| 416 | struct alc_spec *spec = codec->spec; |
| 417 | unsigned int val; |
| 418 | |
| 419 | if (!spec->pll_nid) |
| 420 | return; |
| 421 | snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX, |
| 422 | spec->pll_coef_idx); |
| 423 | val = snd_hda_codec_read(codec, spec->pll_nid, 0, |
| 424 | AC_VERB_GET_PROC_COEF, 0); |
| 425 | snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX, |
| 426 | spec->pll_coef_idx); |
| 427 | snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF, |
| 428 | val & ~(1 << spec->pll_coef_bit)); |
| 429 | } |
| 430 | |
| 431 | static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid, |
| 432 | unsigned int coef_idx, unsigned int coef_bit) |
| 433 | { |
| 434 | struct alc_spec *spec = codec->spec; |
| 435 | spec->pll_nid = nid; |
| 436 | spec->pll_coef_idx = coef_idx; |
| 437 | spec->pll_coef_bit = coef_bit; |
| 438 | alc_fix_pll(codec); |
| 439 | } |
| 440 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 441 | /* |
| 442 | * Jack-reporting via input-jack layer |
| 443 | */ |
| 444 | |
| 445 | /* initialization of jacks; currently checks only a few known pins */ |
Kailang Yang | 9ad0e49 | 2010-09-14 23:22:00 +0200 | [diff] [blame] | 446 | static int alc_init_jacks(struct hda_codec *codec) |
| 447 | { |
Takashi Iwai | cd372fb | 2011-03-03 14:40:14 +0100 | [diff] [blame] | 448 | #ifdef CONFIG_SND_HDA_INPUT_JACK |
Kailang Yang | 9ad0e49 | 2010-09-14 23:22:00 +0200 | [diff] [blame] | 449 | struct alc_spec *spec = codec->spec; |
| 450 | int err; |
| 451 | unsigned int hp_nid = spec->autocfg.hp_pins[0]; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 452 | unsigned int mic_nid = spec->ext_mic_pin; |
| 453 | unsigned int dock_nid = spec->dock_mic_pin; |
Kailang Yang | 9ad0e49 | 2010-09-14 23:22:00 +0200 | [diff] [blame] | 454 | |
Takashi Iwai | 265a024 | 2010-09-21 11:26:21 +0200 | [diff] [blame] | 455 | if (hp_nid) { |
Takashi Iwai | cd372fb | 2011-03-03 14:40:14 +0100 | [diff] [blame] | 456 | err = snd_hda_input_jack_add(codec, hp_nid, |
| 457 | SND_JACK_HEADPHONE, NULL); |
Takashi Iwai | 265a024 | 2010-09-21 11:26:21 +0200 | [diff] [blame] | 458 | if (err < 0) |
| 459 | return err; |
Takashi Iwai | cd372fb | 2011-03-03 14:40:14 +0100 | [diff] [blame] | 460 | snd_hda_input_jack_report(codec, hp_nid); |
Takashi Iwai | 265a024 | 2010-09-21 11:26:21 +0200 | [diff] [blame] | 461 | } |
Kailang Yang | 9ad0e49 | 2010-09-14 23:22:00 +0200 | [diff] [blame] | 462 | |
Takashi Iwai | 265a024 | 2010-09-21 11:26:21 +0200 | [diff] [blame] | 463 | if (mic_nid) { |
Takashi Iwai | cd372fb | 2011-03-03 14:40:14 +0100 | [diff] [blame] | 464 | err = snd_hda_input_jack_add(codec, mic_nid, |
| 465 | SND_JACK_MICROPHONE, NULL); |
Takashi Iwai | 265a024 | 2010-09-21 11:26:21 +0200 | [diff] [blame] | 466 | if (err < 0) |
| 467 | return err; |
Takashi Iwai | cd372fb | 2011-03-03 14:40:14 +0100 | [diff] [blame] | 468 | snd_hda_input_jack_report(codec, mic_nid); |
Takashi Iwai | 265a024 | 2010-09-21 11:26:21 +0200 | [diff] [blame] | 469 | } |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 470 | if (dock_nid) { |
| 471 | err = snd_hda_input_jack_add(codec, dock_nid, |
| 472 | SND_JACK_MICROPHONE, NULL); |
| 473 | if (err < 0) |
| 474 | return err; |
| 475 | snd_hda_input_jack_report(codec, dock_nid); |
| 476 | } |
Takashi Iwai | cd372fb | 2011-03-03 14:40:14 +0100 | [diff] [blame] | 477 | #endif /* CONFIG_SND_HDA_INPUT_JACK */ |
Kailang Yang | 9ad0e49 | 2010-09-14 23:22:00 +0200 | [diff] [blame] | 478 | return 0; |
| 479 | } |
Kailang Yang | 9ad0e49 | 2010-09-14 23:22:00 +0200 | [diff] [blame] | 480 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 481 | /* |
| 482 | * Jack detections for HP auto-mute and mic-switch |
| 483 | */ |
| 484 | |
| 485 | /* check each pin in the given array; returns true if any of them is plugged */ |
| 486 | 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] | 487 | { |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 488 | int i, present = 0; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 489 | |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 490 | for (i = 0; i < num_pins; i++) { |
| 491 | hda_nid_t nid = pins[i]; |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 492 | if (!nid) |
| 493 | break; |
Takashi Iwai | cd372fb | 2011-03-03 14:40:14 +0100 | [diff] [blame] | 494 | snd_hda_input_jack_report(codec, nid); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 495 | present |= snd_hda_jack_detect(codec, nid); |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 496 | } |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 497 | return present; |
| 498 | } |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 499 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 500 | /* standard HP/line-out auto-mute helper */ |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 501 | 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] | 502 | bool mute, bool hp_out) |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 503 | { |
| 504 | struct alc_spec *spec = codec->spec; |
| 505 | unsigned int mute_bits = mute ? HDA_AMP_MUTE : 0; |
Takashi Iwai | e942796 | 2011-04-28 15:46:07 +0200 | [diff] [blame] | 506 | unsigned int pin_bits = mute ? 0 : (hp_out ? PIN_HP : PIN_OUT); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 507 | int i; |
| 508 | |
| 509 | for (i = 0; i < num_pins; i++) { |
| 510 | hda_nid_t nid = pins[i]; |
Takashi Iwai | a9fd4f3 | 2009-05-08 15:57:59 +0200 | [diff] [blame] | 511 | if (!nid) |
| 512 | break; |
Takashi Iwai | 3b8510c | 2011-04-28 14:03:24 +0200 | [diff] [blame] | 513 | switch (spec->automute_mode) { |
| 514 | case ALC_AUTOMUTE_PIN: |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 515 | snd_hda_codec_write(codec, nid, 0, |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 516 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 517 | pin_bits); |
Takashi Iwai | 3b8510c | 2011-04-28 14:03:24 +0200 | [diff] [blame] | 518 | break; |
| 519 | case ALC_AUTOMUTE_AMP: |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 520 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 521 | HDA_AMP_MUTE, mute_bits); |
Takashi Iwai | 3b8510c | 2011-04-28 14:03:24 +0200 | [diff] [blame] | 522 | break; |
| 523 | case ALC_AUTOMUTE_MIXER: |
| 524 | nid = spec->automute_mixer_nid[i]; |
| 525 | if (!nid) |
| 526 | break; |
| 527 | snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0, |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 528 | HDA_AMP_MUTE, mute_bits); |
Takashi Iwai | 3b8510c | 2011-04-28 14:03:24 +0200 | [diff] [blame] | 529 | snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 1, |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 530 | HDA_AMP_MUTE, mute_bits); |
Takashi Iwai | 3b8510c | 2011-04-28 14:03:24 +0200 | [diff] [blame] | 531 | break; |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 532 | } |
Takashi Iwai | a9fd4f3 | 2009-05-08 15:57:59 +0200 | [diff] [blame] | 533 | } |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 534 | } |
| 535 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 536 | /* Toggle outputs muting */ |
| 537 | static void update_outputs(struct hda_codec *codec) |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 538 | { |
| 539 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 540 | int on; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 541 | |
Takashi Iwai | c0a2026 | 2011-06-10 15:28:15 +0200 | [diff] [blame] | 542 | /* Control HP pins/amps depending on master_mute state; |
| 543 | * in general, HP pins/amps control should be enabled in all cases, |
| 544 | * but currently set only for master_mute, just to be safe |
| 545 | */ |
| 546 | do_automute(codec, ARRAY_SIZE(spec->autocfg.hp_pins), |
| 547 | spec->autocfg.hp_pins, spec->master_mute, true); |
| 548 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 549 | if (!spec->automute_speaker) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 550 | on = 0; |
| 551 | else |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 552 | on = spec->hp_jack_present | spec->line_jack_present; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 553 | on |= spec->master_mute; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 554 | do_automute(codec, ARRAY_SIZE(spec->autocfg.speaker_pins), |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 555 | spec->autocfg.speaker_pins, on, false); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 556 | |
| 557 | /* toggle line-out mutes if needed, too */ |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 558 | /* if LO is a copy of either HP or Speaker, don't need to handle it */ |
| 559 | if (spec->autocfg.line_out_pins[0] == spec->autocfg.hp_pins[0] || |
| 560 | spec->autocfg.line_out_pins[0] == spec->autocfg.speaker_pins[0]) |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 561 | return; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 562 | if (!spec->automute_lo) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 563 | on = 0; |
| 564 | else |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 565 | on = spec->hp_jack_present; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 566 | on |= spec->master_mute; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 567 | do_automute(codec, ARRAY_SIZE(spec->autocfg.line_out_pins), |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 568 | spec->autocfg.line_out_pins, on, false); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 569 | } |
| 570 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 571 | static void call_update_outputs(struct hda_codec *codec) |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 572 | { |
| 573 | struct alc_spec *spec = codec->spec; |
| 574 | if (spec->automute_hook) |
| 575 | spec->automute_hook(codec); |
| 576 | else |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 577 | update_outputs(codec); |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 578 | } |
| 579 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 580 | /* standard HP-automute helper */ |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 581 | static void alc_hp_automute(struct hda_codec *codec) |
| 582 | { |
| 583 | struct alc_spec *spec = codec->spec; |
| 584 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 585 | spec->hp_jack_present = |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 586 | detect_jacks(codec, ARRAY_SIZE(spec->autocfg.hp_pins), |
| 587 | spec->autocfg.hp_pins); |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 588 | if (!spec->detect_hp || (!spec->automute_speaker && !spec->automute_lo)) |
Takashi Iwai | 3c715a9 | 2011-08-23 12:41:09 +0200 | [diff] [blame] | 589 | return; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 590 | call_update_outputs(codec); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 591 | } |
| 592 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 593 | /* standard line-out-automute helper */ |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 594 | static void alc_line_automute(struct hda_codec *codec) |
| 595 | { |
| 596 | struct alc_spec *spec = codec->spec; |
| 597 | |
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 | 8d087c7 | 2011-06-28 12:45:47 +0200 | [diff] [blame] | 610 | #define get_connection_index(codec, mux, nid) \ |
| 611 | snd_hda_get_conn_index(codec, mux, nid, 0) |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 612 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 613 | /* standard mic auto-switch helper */ |
Kailang Yang | 7fb0d78 | 2008-10-15 11:12:35 +0200 | [diff] [blame] | 614 | static void alc_mic_automute(struct hda_codec *codec) |
| 615 | { |
| 616 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 617 | hda_nid_t *pins = spec->imux_pins; |
Kailang Yang | 7fb0d78 | 2008-10-15 11:12:35 +0200 | [diff] [blame] | 618 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 619 | if (!spec->auto_mic || !spec->auto_mic_valid_imux) |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 620 | return; |
| 621 | if (snd_BUG_ON(!spec->adc_nids)) |
| 622 | return; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 623 | 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] | 624 | return; |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 625 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 626 | if (snd_hda_jack_detect(codec, pins[spec->ext_mic_idx])) |
| 627 | alc_mux_select(codec, 0, spec->ext_mic_idx, false); |
| 628 | else if (spec->dock_mic_idx >= 0 && |
| 629 | snd_hda_jack_detect(codec, pins[spec->dock_mic_idx])) |
| 630 | alc_mux_select(codec, 0, spec->dock_mic_idx, false); |
| 631 | else |
| 632 | alc_mux_select(codec, 0, spec->int_mic_idx, false); |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 633 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 634 | snd_hda_input_jack_report(codec, pins[spec->ext_mic_idx]); |
| 635 | if (spec->dock_mic_idx >= 0) |
| 636 | snd_hda_input_jack_report(codec, pins[spec->dock_mic_idx]); |
Kailang Yang | 7fb0d78 | 2008-10-15 11:12:35 +0200 | [diff] [blame] | 637 | } |
| 638 | |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 639 | /* unsolicited event for HP jack sensing */ |
| 640 | static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res) |
| 641 | { |
| 642 | if (codec->vendor_id == 0x10ec0880) |
| 643 | res >>= 28; |
| 644 | else |
| 645 | res >>= 26; |
Takashi Iwai | a9fd4f3 | 2009-05-08 15:57:59 +0200 | [diff] [blame] | 646 | switch (res) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 647 | case ALC_HP_EVENT: |
Takashi Iwai | d922b51 | 2011-04-28 12:18:53 +0200 | [diff] [blame] | 648 | alc_hp_automute(codec); |
Takashi Iwai | a9fd4f3 | 2009-05-08 15:57:59 +0200 | [diff] [blame] | 649 | break; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 650 | case ALC_FRONT_EVENT: |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 651 | alc_line_automute(codec); |
| 652 | break; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 653 | case ALC_MIC_EVENT: |
Kailang Yang | 7fb0d78 | 2008-10-15 11:12:35 +0200 | [diff] [blame] | 654 | alc_mic_automute(codec); |
Takashi Iwai | a9fd4f3 | 2009-05-08 15:57:59 +0200 | [diff] [blame] | 655 | break; |
| 656 | } |
Kailang Yang | 7fb0d78 | 2008-10-15 11:12:35 +0200 | [diff] [blame] | 657 | } |
| 658 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 659 | /* call init functions of standard auto-mute helpers */ |
Kailang Yang | 7fb0d78 | 2008-10-15 11:12:35 +0200 | [diff] [blame] | 660 | static void alc_inithook(struct hda_codec *codec) |
| 661 | { |
Takashi Iwai | d922b51 | 2011-04-28 12:18:53 +0200 | [diff] [blame] | 662 | alc_hp_automute(codec); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 663 | alc_line_automute(codec); |
Kailang Yang | 7fb0d78 | 2008-10-15 11:12:35 +0200 | [diff] [blame] | 664 | alc_mic_automute(codec); |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 665 | } |
| 666 | |
Kailang Yang | f9423e7 | 2008-05-27 12:32:25 +0200 | [diff] [blame] | 667 | /* additional initialization for ALC888 variants */ |
| 668 | static void alc888_coef_init(struct hda_codec *codec) |
| 669 | { |
| 670 | unsigned int tmp; |
| 671 | |
| 672 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0); |
| 673 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); |
| 674 | 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] | 675 | if ((tmp & 0xf0) == 0x20) |
Kailang Yang | f9423e7 | 2008-05-27 12:32:25 +0200 | [diff] [blame] | 676 | /* alc888S-VC */ |
| 677 | snd_hda_codec_read(codec, 0x20, 0, |
| 678 | AC_VERB_SET_PROC_COEF, 0x830); |
| 679 | else |
| 680 | /* alc888-VB */ |
| 681 | snd_hda_codec_read(codec, 0x20, 0, |
| 682 | AC_VERB_SET_PROC_COEF, 0x3030); |
| 683 | } |
| 684 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 685 | /* additional initialization for ALC889 variants */ |
Jaroslav Kysela | 87a8c37 | 2009-07-23 10:58:29 +0200 | [diff] [blame] | 686 | static void alc889_coef_init(struct hda_codec *codec) |
| 687 | { |
| 688 | unsigned int tmp; |
| 689 | |
| 690 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7); |
| 691 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); |
| 692 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7); |
| 693 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010); |
| 694 | } |
| 695 | |
Takashi Iwai | 3fb4a50 | 2010-01-19 15:46:37 +0100 | [diff] [blame] | 696 | /* turn on/off EAPD control (only if available) */ |
| 697 | static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on) |
| 698 | { |
| 699 | if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN) |
| 700 | return; |
| 701 | if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD) |
| 702 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE, |
| 703 | on ? 2 : 0); |
| 704 | } |
| 705 | |
Takashi Iwai | 691f1fc | 2011-04-07 10:31:43 +0200 | [diff] [blame] | 706 | /* turn on/off EAPD controls of the codec */ |
| 707 | static void alc_auto_setup_eapd(struct hda_codec *codec, bool on) |
| 708 | { |
| 709 | /* We currently only handle front, HP */ |
Takashi Iwai | 39fa84e | 2011-06-27 15:28:57 +0200 | [diff] [blame] | 710 | static hda_nid_t pins[] = { |
| 711 | 0x0f, 0x10, 0x14, 0x15, 0 |
| 712 | }; |
| 713 | hda_nid_t *p; |
| 714 | for (p = pins; *p; p++) |
| 715 | set_eapd(codec, *p, on); |
Takashi Iwai | 691f1fc | 2011-04-07 10:31:43 +0200 | [diff] [blame] | 716 | } |
| 717 | |
Takashi Iwai | 1c716153 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 718 | /* generic shutup callback; |
| 719 | * just turning off EPAD and a little pause for avoiding pop-noise |
| 720 | */ |
| 721 | static void alc_eapd_shutup(struct hda_codec *codec) |
| 722 | { |
| 723 | alc_auto_setup_eapd(codec, false); |
| 724 | msleep(200); |
| 725 | } |
| 726 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 727 | /* generic EAPD initialization */ |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 728 | static void alc_auto_init_amp(struct hda_codec *codec, int type) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 729 | { |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 730 | unsigned int tmp; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 731 | |
Takashi Iwai | 39fa84e | 2011-06-27 15:28:57 +0200 | [diff] [blame] | 732 | alc_auto_setup_eapd(codec, true); |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 733 | switch (type) { |
| 734 | case ALC_INIT_GPIO1: |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 735 | snd_hda_sequence_write(codec, alc_gpio1_init_verbs); |
| 736 | break; |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 737 | case ALC_INIT_GPIO2: |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 738 | snd_hda_sequence_write(codec, alc_gpio2_init_verbs); |
| 739 | break; |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 740 | case ALC_INIT_GPIO3: |
Kailang Yang | bdd148a | 2007-05-08 15:19:08 +0200 | [diff] [blame] | 741 | snd_hda_sequence_write(codec, alc_gpio3_init_verbs); |
| 742 | break; |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 743 | case ALC_INIT_DEFAULT: |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 744 | switch (codec->vendor_id) { |
| 745 | case 0x10ec0260: |
| 746 | snd_hda_codec_write(codec, 0x1a, 0, |
| 747 | AC_VERB_SET_COEF_INDEX, 7); |
| 748 | tmp = snd_hda_codec_read(codec, 0x1a, 0, |
| 749 | AC_VERB_GET_PROC_COEF, 0); |
| 750 | snd_hda_codec_write(codec, 0x1a, 0, |
| 751 | AC_VERB_SET_COEF_INDEX, 7); |
| 752 | snd_hda_codec_write(codec, 0x1a, 0, |
| 753 | AC_VERB_SET_PROC_COEF, |
| 754 | tmp | 0x2010); |
| 755 | break; |
| 756 | case 0x10ec0262: |
| 757 | case 0x10ec0880: |
| 758 | case 0x10ec0882: |
| 759 | case 0x10ec0883: |
| 760 | case 0x10ec0885: |
Takashi Iwai | 4a5a4c5 | 2009-02-06 12:46:59 +0100 | [diff] [blame] | 761 | case 0x10ec0887: |
Takashi Iwai | 20b67dd | 2011-03-23 22:54:32 +0100 | [diff] [blame] | 762 | /*case 0x10ec0889:*/ /* this causes an SPDIF problem */ |
Jaroslav Kysela | 87a8c37 | 2009-07-23 10:58:29 +0200 | [diff] [blame] | 763 | alc889_coef_init(codec); |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 764 | break; |
Kailang Yang | f9423e7 | 2008-05-27 12:32:25 +0200 | [diff] [blame] | 765 | case 0x10ec0888: |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 766 | alc888_coef_init(codec); |
Kailang Yang | f9423e7 | 2008-05-27 12:32:25 +0200 | [diff] [blame] | 767 | break; |
Takashi Iwai | 0aea778 | 2010-01-25 15:44:11 +0100 | [diff] [blame] | 768 | #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] | 769 | case 0x10ec0267: |
| 770 | case 0x10ec0268: |
| 771 | snd_hda_codec_write(codec, 0x20, 0, |
| 772 | AC_VERB_SET_COEF_INDEX, 7); |
| 773 | tmp = snd_hda_codec_read(codec, 0x20, 0, |
| 774 | AC_VERB_GET_PROC_COEF, 0); |
| 775 | snd_hda_codec_write(codec, 0x20, 0, |
Kailang Yang | ea1fb29 | 2008-08-26 12:58:38 +0200 | [diff] [blame] | 776 | AC_VERB_SET_COEF_INDEX, 7); |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 777 | snd_hda_codec_write(codec, 0x20, 0, |
| 778 | AC_VERB_SET_PROC_COEF, |
| 779 | tmp | 0x3000); |
| 780 | break; |
Takashi Iwai | 0aea778 | 2010-01-25 15:44:11 +0100 | [diff] [blame] | 781 | #endif /* XXX */ |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 782 | } |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 783 | break; |
| 784 | } |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 785 | } |
Kailang Yang | ea1fb29 | 2008-08-26 12:58:38 +0200 | [diff] [blame] | 786 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 787 | /* |
| 788 | * Auto-Mute mode mixer enum support |
| 789 | */ |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 790 | static int alc_automute_mode_info(struct snd_kcontrol *kcontrol, |
| 791 | struct snd_ctl_elem_info *uinfo) |
| 792 | { |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 793 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 794 | struct alc_spec *spec = codec->spec; |
| 795 | static const char * const texts2[] = { |
| 796 | "Disabled", "Enabled" |
| 797 | }; |
| 798 | static const char * const texts3[] = { |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 799 | "Disabled", "Speaker Only", "Line-Out+Speaker" |
| 800 | }; |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 801 | const char * const *texts; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 802 | |
| 803 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
| 804 | uinfo->count = 1; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 805 | if (spec->automute_speaker_possible && spec->automute_lo_possible) { |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 806 | uinfo->value.enumerated.items = 3; |
| 807 | texts = texts3; |
| 808 | } else { |
| 809 | uinfo->value.enumerated.items = 2; |
| 810 | texts = texts2; |
| 811 | } |
| 812 | if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) |
| 813 | uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 814 | strcpy(uinfo->value.enumerated.name, |
| 815 | texts[uinfo->value.enumerated.item]); |
| 816 | return 0; |
| 817 | } |
| 818 | |
| 819 | static int alc_automute_mode_get(struct snd_kcontrol *kcontrol, |
| 820 | struct snd_ctl_elem_value *ucontrol) |
| 821 | { |
| 822 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 823 | struct alc_spec *spec = codec->spec; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 824 | unsigned int val = 0; |
| 825 | if (spec->automute_speaker) |
| 826 | val++; |
| 827 | if (spec->automute_lo) |
| 828 | val++; |
| 829 | |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 830 | ucontrol->value.enumerated.item[0] = val; |
| 831 | return 0; |
| 832 | } |
| 833 | |
| 834 | static int alc_automute_mode_put(struct snd_kcontrol *kcontrol, |
| 835 | struct snd_ctl_elem_value *ucontrol) |
| 836 | { |
| 837 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 838 | struct alc_spec *spec = codec->spec; |
| 839 | |
| 840 | switch (ucontrol->value.enumerated.item[0]) { |
| 841 | case 0: |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 842 | if (!spec->automute_speaker && !spec->automute_lo) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 843 | return 0; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 844 | spec->automute_speaker = 0; |
| 845 | spec->automute_lo = 0; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 846 | break; |
| 847 | case 1: |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 848 | if (spec->automute_speaker_possible) { |
| 849 | if (!spec->automute_lo && spec->automute_speaker) |
| 850 | return 0; |
| 851 | spec->automute_speaker = 1; |
| 852 | spec->automute_lo = 0; |
| 853 | } else if (spec->automute_lo_possible) { |
| 854 | if (spec->automute_lo) |
| 855 | return 0; |
| 856 | spec->automute_lo = 1; |
| 857 | } else |
| 858 | return -EINVAL; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 859 | break; |
| 860 | case 2: |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 861 | if (!spec->automute_lo_possible || !spec->automute_speaker_possible) |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 862 | return -EINVAL; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 863 | if (spec->automute_speaker && spec->automute_lo) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 864 | return 0; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 865 | spec->automute_speaker = 1; |
| 866 | spec->automute_lo = 1; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 867 | break; |
| 868 | default: |
| 869 | return -EINVAL; |
| 870 | } |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 871 | call_update_outputs(codec); |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 872 | return 1; |
| 873 | } |
| 874 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 875 | static const struct snd_kcontrol_new alc_automute_mode_enum = { |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 876 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 877 | .name = "Auto-Mute Mode", |
| 878 | .info = alc_automute_mode_info, |
| 879 | .get = alc_automute_mode_get, |
| 880 | .put = alc_automute_mode_put, |
| 881 | }; |
| 882 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 883 | static struct snd_kcontrol_new *alc_kcontrol_new(struct alc_spec *spec) |
| 884 | { |
| 885 | snd_array_init(&spec->kctls, sizeof(struct snd_kcontrol_new), 32); |
| 886 | return snd_array_new(&spec->kctls); |
| 887 | } |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 888 | |
| 889 | static int alc_add_automute_mode_enum(struct hda_codec *codec) |
| 890 | { |
| 891 | struct alc_spec *spec = codec->spec; |
| 892 | struct snd_kcontrol_new *knew; |
| 893 | |
| 894 | knew = alc_kcontrol_new(spec); |
| 895 | if (!knew) |
| 896 | return -ENOMEM; |
| 897 | *knew = alc_automute_mode_enum; |
| 898 | knew->name = kstrdup("Auto-Mute Mode", GFP_KERNEL); |
| 899 | if (!knew->name) |
| 900 | return -ENOMEM; |
| 901 | return 0; |
| 902 | } |
| 903 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 904 | /* |
| 905 | * Check the availability of HP/line-out auto-mute; |
| 906 | * Set up appropriately if really supported |
| 907 | */ |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 908 | static void alc_init_automute(struct hda_codec *codec) |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 909 | { |
| 910 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 911 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | 1daf5f4 | 2011-04-28 17:57:46 +0200 | [diff] [blame] | 912 | int present = 0; |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 913 | int i; |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 914 | |
Takashi Iwai | 1daf5f4 | 2011-04-28 17:57:46 +0200 | [diff] [blame] | 915 | if (cfg->hp_pins[0]) |
| 916 | present++; |
| 917 | if (cfg->line_out_pins[0]) |
| 918 | present++; |
| 919 | if (cfg->speaker_pins[0]) |
| 920 | present++; |
| 921 | if (present < 2) /* need two different output types */ |
| 922 | return; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 923 | |
Takashi Iwai | c48a8fb | 2011-07-27 16:41:57 +0200 | [diff] [blame] | 924 | if (!cfg->speaker_pins[0] && |
| 925 | cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) { |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 926 | memcpy(cfg->speaker_pins, cfg->line_out_pins, |
| 927 | sizeof(cfg->speaker_pins)); |
| 928 | cfg->speaker_outs = cfg->line_outs; |
| 929 | } |
| 930 | |
Takashi Iwai | c48a8fb | 2011-07-27 16:41:57 +0200 | [diff] [blame] | 931 | if (!cfg->hp_pins[0] && |
| 932 | cfg->line_out_type == AUTO_PIN_HP_OUT) { |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 933 | memcpy(cfg->hp_pins, cfg->line_out_pins, |
| 934 | sizeof(cfg->hp_pins)); |
| 935 | cfg->hp_outs = cfg->line_outs; |
| 936 | } |
| 937 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 938 | spec->automute_mode = ALC_AUTOMUTE_PIN; |
| 939 | |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 940 | for (i = 0; i < cfg->hp_outs; i++) { |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 941 | hda_nid_t nid = cfg->hp_pins[i]; |
Takashi Iwai | 06dec22 | 2011-05-17 10:00:16 +0200 | [diff] [blame] | 942 | if (!is_jack_detectable(codec, nid)) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 943 | continue; |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 944 | snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n", |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 945 | nid); |
| 946 | snd_hda_codec_write_cache(codec, nid, 0, |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 947 | AC_VERB_SET_UNSOLICITED_ENABLE, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 948 | AC_USRSP_EN | ALC_HP_EVENT); |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 949 | spec->detect_hp = 1; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 950 | } |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 951 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 952 | if (cfg->line_out_type == AUTO_PIN_LINE_OUT && cfg->line_outs) { |
| 953 | if (cfg->speaker_outs) |
| 954 | for (i = 0; i < cfg->line_outs; i++) { |
| 955 | hda_nid_t nid = cfg->line_out_pins[i]; |
| 956 | if (!is_jack_detectable(codec, nid)) |
| 957 | continue; |
| 958 | snd_printdd("realtek: Enable Line-Out " |
| 959 | "auto-muting on NID 0x%x\n", nid); |
| 960 | snd_hda_codec_write_cache(codec, nid, 0, |
| 961 | AC_VERB_SET_UNSOLICITED_ENABLE, |
| 962 | AC_USRSP_EN | ALC_FRONT_EVENT); |
| 963 | spec->detect_lo = 1; |
| 964 | } |
| 965 | spec->automute_lo_possible = spec->detect_hp; |
| 966 | } |
| 967 | |
| 968 | spec->automute_speaker_possible = cfg->speaker_outs && |
| 969 | (spec->detect_hp || spec->detect_lo); |
| 970 | |
| 971 | spec->automute_lo = spec->automute_lo_possible; |
| 972 | spec->automute_speaker = spec->automute_speaker_possible; |
| 973 | |
| 974 | if (spec->automute_speaker_possible || spec->automute_lo_possible) { |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 975 | /* create a control for automute mode */ |
| 976 | alc_add_automute_mode_enum(codec); |
| 977 | spec->unsol_event = alc_sku_unsol_event; |
| 978 | } |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 979 | } |
| 980 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 981 | /* 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] | 982 | static int find_idx_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums) |
| 983 | { |
| 984 | int i; |
| 985 | for (i = 0; i < nums; i++) |
| 986 | if (list[i] == nid) |
| 987 | return i; |
| 988 | return -1; |
| 989 | } |
| 990 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 991 | /* check whether dynamic ADC-switching is available */ |
| 992 | static bool alc_check_dyn_adc_switch(struct hda_codec *codec) |
| 993 | { |
| 994 | struct alc_spec *spec = codec->spec; |
| 995 | struct hda_input_mux *imux = &spec->private_imux[0]; |
| 996 | int i, n, idx; |
| 997 | hda_nid_t cap, pin; |
| 998 | |
| 999 | if (imux != spec->input_mux) /* no dynamic imux? */ |
| 1000 | return false; |
| 1001 | |
| 1002 | for (n = 0; n < spec->num_adc_nids; n++) { |
| 1003 | cap = spec->private_capsrc_nids[n]; |
| 1004 | for (i = 0; i < imux->num_items; i++) { |
| 1005 | pin = spec->imux_pins[i]; |
| 1006 | if (!pin) |
| 1007 | return false; |
| 1008 | if (get_connection_index(codec, cap, pin) < 0) |
| 1009 | break; |
| 1010 | } |
| 1011 | if (i >= imux->num_items) |
Takashi Iwai | 268ff6f | 2011-07-08 14:37:35 +0200 | [diff] [blame] | 1012 | return true; /* no ADC-switch is needed */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1013 | } |
| 1014 | |
| 1015 | for (i = 0; i < imux->num_items; i++) { |
| 1016 | pin = spec->imux_pins[i]; |
| 1017 | for (n = 0; n < spec->num_adc_nids; n++) { |
| 1018 | cap = spec->private_capsrc_nids[n]; |
| 1019 | idx = get_connection_index(codec, cap, pin); |
| 1020 | if (idx >= 0) { |
| 1021 | imux->items[i].index = idx; |
| 1022 | spec->dyn_adc_idx[i] = n; |
| 1023 | break; |
| 1024 | } |
| 1025 | } |
| 1026 | } |
| 1027 | |
| 1028 | snd_printdd("realtek: enabling ADC switching\n"); |
| 1029 | spec->dyn_adc_switch = 1; |
| 1030 | return true; |
| 1031 | } |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1032 | |
| 1033 | /* rebuild imux for matching with the given auto-mic pins (if not yet) */ |
| 1034 | static bool alc_rebuild_imux_for_auto_mic(struct hda_codec *codec) |
| 1035 | { |
| 1036 | struct alc_spec *spec = codec->spec; |
| 1037 | struct hda_input_mux *imux; |
| 1038 | static char * const texts[3] = { |
| 1039 | "Mic", "Internal Mic", "Dock Mic" |
| 1040 | }; |
| 1041 | int i; |
| 1042 | |
| 1043 | if (!spec->auto_mic) |
| 1044 | return false; |
| 1045 | imux = &spec->private_imux[0]; |
| 1046 | if (spec->input_mux == imux) |
| 1047 | return true; |
| 1048 | spec->imux_pins[0] = spec->ext_mic_pin; |
| 1049 | spec->imux_pins[1] = spec->int_mic_pin; |
| 1050 | spec->imux_pins[2] = spec->dock_mic_pin; |
| 1051 | for (i = 0; i < 3; i++) { |
| 1052 | strcpy(imux->items[i].label, texts[i]); |
| 1053 | if (spec->imux_pins[i]) |
| 1054 | imux->num_items = i + 1; |
| 1055 | } |
| 1056 | spec->num_mux_defs = 1; |
| 1057 | spec->input_mux = imux; |
| 1058 | return true; |
| 1059 | } |
| 1060 | |
| 1061 | /* check whether all auto-mic pins are valid; setup indices if OK */ |
| 1062 | static bool alc_auto_mic_check_imux(struct hda_codec *codec) |
| 1063 | { |
| 1064 | struct alc_spec *spec = codec->spec; |
| 1065 | const struct hda_input_mux *imux; |
| 1066 | |
| 1067 | if (!spec->auto_mic) |
| 1068 | return false; |
| 1069 | if (spec->auto_mic_valid_imux) |
| 1070 | return true; /* already checked */ |
| 1071 | |
| 1072 | /* fill up imux indices */ |
| 1073 | if (!alc_check_dyn_adc_switch(codec)) { |
| 1074 | spec->auto_mic = 0; |
| 1075 | return false; |
| 1076 | } |
| 1077 | |
| 1078 | imux = spec->input_mux; |
| 1079 | spec->ext_mic_idx = find_idx_in_nid_list(spec->ext_mic_pin, |
| 1080 | spec->imux_pins, imux->num_items); |
| 1081 | spec->int_mic_idx = find_idx_in_nid_list(spec->int_mic_pin, |
| 1082 | spec->imux_pins, imux->num_items); |
| 1083 | spec->dock_mic_idx = find_idx_in_nid_list(spec->dock_mic_pin, |
| 1084 | spec->imux_pins, imux->num_items); |
| 1085 | if (spec->ext_mic_idx < 0 || spec->int_mic_idx < 0) { |
| 1086 | spec->auto_mic = 0; |
| 1087 | return false; /* no corresponding imux */ |
| 1088 | } |
| 1089 | |
| 1090 | snd_hda_codec_write_cache(codec, spec->ext_mic_pin, 0, |
| 1091 | AC_VERB_SET_UNSOLICITED_ENABLE, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1092 | AC_USRSP_EN | ALC_MIC_EVENT); |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1093 | if (spec->dock_mic_pin) |
| 1094 | snd_hda_codec_write_cache(codec, spec->dock_mic_pin, 0, |
| 1095 | AC_VERB_SET_UNSOLICITED_ENABLE, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1096 | AC_USRSP_EN | ALC_MIC_EVENT); |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1097 | |
| 1098 | spec->auto_mic_valid_imux = 1; |
| 1099 | spec->auto_mic = 1; |
| 1100 | return true; |
| 1101 | } |
| 1102 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1103 | /* |
| 1104 | * Check the availability of auto-mic switch; |
| 1105 | * Set up if really supported |
| 1106 | */ |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1107 | static void alc_init_auto_mic(struct hda_codec *codec) |
| 1108 | { |
| 1109 | struct alc_spec *spec = codec->spec; |
| 1110 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1111 | hda_nid_t fixed, ext, dock; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1112 | int i; |
| 1113 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1114 | spec->ext_mic_idx = spec->int_mic_idx = spec->dock_mic_idx = -1; |
| 1115 | |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1116 | fixed = ext = dock = 0; |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 1117 | for (i = 0; i < cfg->num_inputs; i++) { |
| 1118 | hda_nid_t nid = cfg->inputs[i].pin; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1119 | unsigned int defcfg; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1120 | defcfg = snd_hda_codec_get_pincfg(codec, nid); |
Takashi Iwai | 99ae28b | 2010-09-17 14:42:34 +0200 | [diff] [blame] | 1121 | switch (snd_hda_get_input_pin_attr(defcfg)) { |
| 1122 | case INPUT_PIN_ATTR_INT: |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1123 | if (fixed) |
| 1124 | return; /* already occupied */ |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1125 | if (cfg->inputs[i].type != AUTO_PIN_MIC) |
| 1126 | return; /* invalid type */ |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1127 | fixed = nid; |
| 1128 | break; |
Takashi Iwai | 99ae28b | 2010-09-17 14:42:34 +0200 | [diff] [blame] | 1129 | case INPUT_PIN_ATTR_UNUSED: |
| 1130 | return; /* invalid entry */ |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1131 | case INPUT_PIN_ATTR_DOCK: |
| 1132 | if (dock) |
| 1133 | return; /* already occupied */ |
| 1134 | if (cfg->inputs[i].type > AUTO_PIN_LINE_IN) |
| 1135 | return; /* invalid type */ |
| 1136 | dock = nid; |
| 1137 | break; |
Takashi Iwai | 99ae28b | 2010-09-17 14:42:34 +0200 | [diff] [blame] | 1138 | default: |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1139 | if (ext) |
| 1140 | return; /* already occupied */ |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1141 | if (cfg->inputs[i].type != AUTO_PIN_MIC) |
| 1142 | return; /* invalid type */ |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1143 | ext = nid; |
| 1144 | break; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1145 | } |
| 1146 | } |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1147 | if (!ext && dock) { |
| 1148 | ext = dock; |
| 1149 | dock = 0; |
| 1150 | } |
Takashi Iwai | eaa9b3a | 2010-01-17 13:09:33 +0100 | [diff] [blame] | 1151 | if (!ext || !fixed) |
| 1152 | return; |
Takashi Iwai | e35d9d6 | 2011-05-17 11:28:16 +0200 | [diff] [blame] | 1153 | if (!is_jack_detectable(codec, ext)) |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1154 | return; /* no unsol support */ |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1155 | if (dock && !is_jack_detectable(codec, dock)) |
| 1156 | return; /* no unsol support */ |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1157 | |
| 1158 | /* check imux indices */ |
| 1159 | spec->ext_mic_pin = ext; |
| 1160 | spec->int_mic_pin = fixed; |
| 1161 | spec->dock_mic_pin = dock; |
| 1162 | |
| 1163 | spec->auto_mic = 1; |
| 1164 | if (!alc_auto_mic_check_imux(codec)) |
| 1165 | return; |
| 1166 | |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1167 | snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x/0x%x\n", |
| 1168 | ext, fixed, dock); |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1169 | spec->unsol_event = alc_sku_unsol_event; |
| 1170 | } |
| 1171 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1172 | /* check the availabilities of auto-mute and auto-mic switches */ |
| 1173 | static void alc_auto_check_switches(struct hda_codec *codec) |
| 1174 | { |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 1175 | alc_init_automute(codec); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1176 | alc_init_auto_mic(codec); |
| 1177 | } |
| 1178 | |
| 1179 | /* |
| 1180 | * Realtek SSID verification |
| 1181 | */ |
| 1182 | |
David Henningsson | 9062291 | 2010-10-14 14:50:18 +0200 | [diff] [blame] | 1183 | /* Could be any non-zero and even value. When used as fixup, tells |
| 1184 | * the driver to ignore any present sku defines. |
| 1185 | */ |
| 1186 | #define ALC_FIXUP_SKU_IGNORE (2) |
| 1187 | |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 1188 | static int alc_auto_parse_customize_define(struct hda_codec *codec) |
| 1189 | { |
| 1190 | unsigned int ass, tmp, i; |
Takashi Iwai | 7fb5622 | 2010-03-22 17:09:47 +0100 | [diff] [blame] | 1191 | unsigned nid = 0; |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 1192 | struct alc_spec *spec = codec->spec; |
| 1193 | |
Takashi Iwai | b6cbe51 | 2010-07-28 17:43:36 +0200 | [diff] [blame] | 1194 | spec->cdefine.enable_pcbeep = 1; /* assume always enabled */ |
| 1195 | |
David Henningsson | 9062291 | 2010-10-14 14:50:18 +0200 | [diff] [blame] | 1196 | if (spec->cdefine.fixup) { |
| 1197 | ass = spec->cdefine.sku_cfg; |
| 1198 | if (ass == ALC_FIXUP_SKU_IGNORE) |
| 1199 | return -1; |
| 1200 | goto do_sku; |
| 1201 | } |
| 1202 | |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 1203 | ass = codec->subsystem_id & 0xffff; |
Takashi Iwai | b6cbe51 | 2010-07-28 17:43:36 +0200 | [diff] [blame] | 1204 | if (ass != codec->bus->pci->subsystem_device && (ass & 1)) |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 1205 | goto do_sku; |
| 1206 | |
| 1207 | nid = 0x1d; |
| 1208 | if (codec->vendor_id == 0x10ec0260) |
| 1209 | nid = 0x17; |
| 1210 | ass = snd_hda_codec_get_pincfg(codec, nid); |
| 1211 | |
| 1212 | if (!(ass & 1)) { |
| 1213 | printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n", |
| 1214 | codec->chip_name, ass); |
| 1215 | return -1; |
| 1216 | } |
| 1217 | |
| 1218 | /* check sum */ |
| 1219 | tmp = 0; |
| 1220 | for (i = 1; i < 16; i++) { |
| 1221 | if ((ass >> i) & 1) |
| 1222 | tmp++; |
| 1223 | } |
| 1224 | if (((ass >> 16) & 0xf) != tmp) |
| 1225 | return -1; |
| 1226 | |
| 1227 | spec->cdefine.port_connectivity = ass >> 30; |
| 1228 | spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20; |
| 1229 | spec->cdefine.check_sum = (ass >> 16) & 0xf; |
| 1230 | spec->cdefine.customization = ass >> 8; |
| 1231 | do_sku: |
| 1232 | spec->cdefine.sku_cfg = ass; |
| 1233 | spec->cdefine.external_amp = (ass & 0x38) >> 3; |
| 1234 | spec->cdefine.platform_type = (ass & 0x4) >> 2; |
| 1235 | spec->cdefine.swap = (ass & 0x2) >> 1; |
| 1236 | spec->cdefine.override = ass & 0x1; |
| 1237 | |
| 1238 | snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n", |
| 1239 | nid, spec->cdefine.sku_cfg); |
| 1240 | snd_printd("SKU: port_connectivity=0x%x\n", |
| 1241 | spec->cdefine.port_connectivity); |
| 1242 | snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep); |
| 1243 | snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum); |
| 1244 | snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization); |
| 1245 | snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp); |
| 1246 | snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type); |
| 1247 | snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap); |
| 1248 | snd_printd("SKU: override=0x%x\n", spec->cdefine.override); |
| 1249 | |
| 1250 | return 0; |
| 1251 | } |
| 1252 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1253 | /* return true if the given NID is found in the list */ |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 1254 | static bool found_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums) |
| 1255 | { |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1256 | return find_idx_in_nid_list(nid, list, nums) >= 0; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 1257 | } |
| 1258 | |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1259 | /* check subsystem ID and set up device-specific initialization; |
| 1260 | * return 1 if initialized, 0 if invalid SSID |
| 1261 | */ |
| 1262 | /* 32-bit subsystem ID for BIOS loading in HD Audio codec. |
| 1263 | * 31 ~ 16 : Manufacture ID |
| 1264 | * 15 ~ 8 : SKU ID |
| 1265 | * 7 ~ 0 : Assembly ID |
| 1266 | * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36 |
| 1267 | */ |
| 1268 | static int alc_subsystem_id(struct hda_codec *codec, |
| 1269 | hda_nid_t porta, hda_nid_t porte, |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 1270 | hda_nid_t portd, hda_nid_t porti) |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1271 | { |
| 1272 | unsigned int ass, tmp, i; |
| 1273 | unsigned nid; |
| 1274 | struct alc_spec *spec = codec->spec; |
| 1275 | |
David Henningsson | 9062291 | 2010-10-14 14:50:18 +0200 | [diff] [blame] | 1276 | if (spec->cdefine.fixup) { |
| 1277 | ass = spec->cdefine.sku_cfg; |
| 1278 | if (ass == ALC_FIXUP_SKU_IGNORE) |
| 1279 | return 0; |
| 1280 | goto do_sku; |
| 1281 | } |
| 1282 | |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1283 | ass = codec->subsystem_id & 0xffff; |
| 1284 | if ((ass != codec->bus->pci->subsystem_device) && (ass & 1)) |
| 1285 | goto do_sku; |
| 1286 | |
| 1287 | /* invalid SSID, check the special NID pin defcfg instead */ |
| 1288 | /* |
Sasha Alexandr | def319f | 2009-06-16 16:00:15 -0400 | [diff] [blame] | 1289 | * 31~30 : port connectivity |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1290 | * 29~21 : reserve |
| 1291 | * 20 : PCBEEP input |
| 1292 | * 19~16 : Check sum (15:1) |
| 1293 | * 15~1 : Custom |
| 1294 | * 0 : override |
| 1295 | */ |
| 1296 | nid = 0x1d; |
| 1297 | if (codec->vendor_id == 0x10ec0260) |
| 1298 | nid = 0x17; |
| 1299 | ass = snd_hda_codec_get_pincfg(codec, nid); |
| 1300 | snd_printd("realtek: No valid SSID, " |
| 1301 | "checking pincfg 0x%08x for NID 0x%x\n", |
Takashi Iwai | cb6605c | 2009-04-28 13:03:19 +0200 | [diff] [blame] | 1302 | ass, nid); |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 1303 | if (!(ass & 1)) |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1304 | return 0; |
| 1305 | if ((ass >> 30) != 1) /* no physical connection */ |
| 1306 | return 0; |
| 1307 | |
| 1308 | /* check sum */ |
| 1309 | tmp = 0; |
| 1310 | for (i = 1; i < 16; i++) { |
| 1311 | if ((ass >> i) & 1) |
| 1312 | tmp++; |
| 1313 | } |
| 1314 | if (((ass >> 16) & 0xf) != tmp) |
| 1315 | return 0; |
| 1316 | do_sku: |
| 1317 | snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n", |
| 1318 | ass & 0xffff, codec->vendor_id); |
| 1319 | /* |
| 1320 | * 0 : override |
| 1321 | * 1 : Swap Jack |
| 1322 | * 2 : 0 --> Desktop, 1 --> Laptop |
| 1323 | * 3~5 : External Amplifier control |
| 1324 | * 7~6 : Reserved |
| 1325 | */ |
| 1326 | tmp = (ass & 0x38) >> 3; /* external Amp control */ |
| 1327 | switch (tmp) { |
| 1328 | case 1: |
| 1329 | spec->init_amp = ALC_INIT_GPIO1; |
| 1330 | break; |
| 1331 | case 3: |
| 1332 | spec->init_amp = ALC_INIT_GPIO2; |
| 1333 | break; |
| 1334 | case 7: |
| 1335 | spec->init_amp = ALC_INIT_GPIO3; |
| 1336 | break; |
| 1337 | case 5: |
Takashi Iwai | 5a8cfb4 | 2010-11-26 17:11:18 +0100 | [diff] [blame] | 1338 | default: |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1339 | spec->init_amp = ALC_INIT_DEFAULT; |
| 1340 | break; |
| 1341 | } |
| 1342 | |
| 1343 | /* is laptop or Desktop and enable the function "Mute internal speaker |
| 1344 | * when the external headphone out jack is plugged" |
| 1345 | */ |
| 1346 | if (!(ass & 0x8000)) |
| 1347 | return 1; |
| 1348 | /* |
| 1349 | * 10~8 : Jack location |
| 1350 | * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered |
| 1351 | * 14~13: Resvered |
| 1352 | * 15 : 1 --> enable the function "Mute internal speaker |
| 1353 | * when the external headphone out jack is plugged" |
| 1354 | */ |
Takashi Iwai | 5fe6e01 | 2011-09-26 10:41:21 +0200 | [diff] [blame] | 1355 | if (!spec->autocfg.hp_pins[0] && |
| 1356 | !(spec->autocfg.line_out_pins[0] && |
| 1357 | spec->autocfg.line_out_type == AUTO_PIN_HP_OUT)) { |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1358 | hda_nid_t nid; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1359 | tmp = (ass >> 11) & 0x3; /* HP to chassis */ |
| 1360 | if (tmp == 0) |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1361 | nid = porta; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1362 | else if (tmp == 1) |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1363 | nid = porte; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1364 | else if (tmp == 2) |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1365 | nid = portd; |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 1366 | else if (tmp == 3) |
| 1367 | nid = porti; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1368 | else |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1369 | return 1; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 1370 | if (found_in_nid_list(nid, spec->autocfg.line_out_pins, |
| 1371 | spec->autocfg.line_outs)) |
| 1372 | return 1; |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1373 | spec->autocfg.hp_pins[0] = nid; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1374 | } |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1375 | return 1; |
| 1376 | } |
Kailang Yang | ea1fb29 | 2008-08-26 12:58:38 +0200 | [diff] [blame] | 1377 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 1378 | /* Check the validity of ALC subsystem-id |
| 1379 | * ports contains an array of 4 pin NIDs for port-A, E, D and I */ |
| 1380 | 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] | 1381 | { |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 1382 | 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] | 1383 | struct alc_spec *spec = codec->spec; |
| 1384 | snd_printd("realtek: " |
| 1385 | "Enable default setup for auto mode as fallback\n"); |
| 1386 | spec->init_amp = ALC_INIT_DEFAULT; |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1387 | } |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1388 | } |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 1389 | |
Takashi Iwai | 41e41f1 | 2005-06-08 14:48:49 +0200 | [diff] [blame] | 1390 | /* |
Takashi Iwai | f8f25ba | 2009-10-06 08:31:29 +0200 | [diff] [blame] | 1391 | * Fix-up pin default configurations and add default verbs |
Takashi Iwai | f95474e | 2007-07-10 00:47:43 +0200 | [diff] [blame] | 1392 | */ |
| 1393 | |
| 1394 | struct alc_pincfg { |
| 1395 | hda_nid_t nid; |
| 1396 | u32 val; |
| 1397 | }; |
| 1398 | |
Todd Broch | e1eb5f1 | 2010-12-06 11:19:51 -0800 | [diff] [blame] | 1399 | struct alc_model_fixup { |
| 1400 | const int id; |
| 1401 | const char *name; |
| 1402 | }; |
| 1403 | |
Takashi Iwai | f8f25ba | 2009-10-06 08:31:29 +0200 | [diff] [blame] | 1404 | struct alc_fixup { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1405 | int type; |
Takashi Iwai | 361fe6e | 2011-01-14 09:55:32 +0100 | [diff] [blame] | 1406 | bool chained; |
| 1407 | int chain_id; |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1408 | union { |
| 1409 | unsigned int sku; |
| 1410 | const struct alc_pincfg *pins; |
| 1411 | const struct hda_verb *verbs; |
| 1412 | void (*func)(struct hda_codec *codec, |
| 1413 | const struct alc_fixup *fix, |
| 1414 | int action); |
| 1415 | } v; |
Takashi Iwai | f8f25ba | 2009-10-06 08:31:29 +0200 | [diff] [blame] | 1416 | }; |
| 1417 | |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1418 | enum { |
| 1419 | ALC_FIXUP_INVALID, |
| 1420 | ALC_FIXUP_SKU, |
| 1421 | ALC_FIXUP_PINS, |
| 1422 | ALC_FIXUP_VERBS, |
| 1423 | ALC_FIXUP_FUNC, |
| 1424 | }; |
Takashi Iwai | f95474e | 2007-07-10 00:47:43 +0200 | [diff] [blame] | 1425 | |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1426 | enum { |
| 1427 | ALC_FIXUP_ACT_PRE_PROBE, |
| 1428 | ALC_FIXUP_ACT_PROBE, |
Takashi Iwai | 5870112 | 2011-01-13 15:41:45 +0100 | [diff] [blame] | 1429 | ALC_FIXUP_ACT_INIT, |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1430 | }; |
| 1431 | |
| 1432 | static void alc_apply_fixup(struct hda_codec *codec, int action) |
| 1433 | { |
| 1434 | struct alc_spec *spec = codec->spec; |
| 1435 | int id = spec->fixup_id; |
Takashi Iwai | aa1d0c5 | 2011-01-19 17:27:58 +0100 | [diff] [blame] | 1436 | #ifdef CONFIG_SND_DEBUG_VERBOSE |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1437 | const char *modelname = spec->fixup_name; |
Takashi Iwai | aa1d0c5 | 2011-01-19 17:27:58 +0100 | [diff] [blame] | 1438 | #endif |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1439 | int depth = 0; |
| 1440 | |
| 1441 | if (!spec->fixup_list) |
| 1442 | return; |
| 1443 | |
| 1444 | while (id >= 0) { |
| 1445 | const struct alc_fixup *fix = spec->fixup_list + id; |
| 1446 | const struct alc_pincfg *cfg; |
| 1447 | |
| 1448 | switch (fix->type) { |
| 1449 | case ALC_FIXUP_SKU: |
| 1450 | if (action != ALC_FIXUP_ACT_PRE_PROBE || !fix->v.sku) |
| 1451 | break;; |
| 1452 | snd_printdd(KERN_INFO "hda_codec: %s: " |
| 1453 | "Apply sku override for %s\n", |
| 1454 | codec->chip_name, modelname); |
| 1455 | spec->cdefine.sku_cfg = fix->v.sku; |
| 1456 | spec->cdefine.fixup = 1; |
| 1457 | break; |
| 1458 | case ALC_FIXUP_PINS: |
| 1459 | cfg = fix->v.pins; |
| 1460 | if (action != ALC_FIXUP_ACT_PRE_PROBE || !cfg) |
| 1461 | break; |
| 1462 | snd_printdd(KERN_INFO "hda_codec: %s: " |
| 1463 | "Apply pincfg for %s\n", |
| 1464 | codec->chip_name, modelname); |
| 1465 | for (; cfg->nid; cfg++) |
| 1466 | snd_hda_codec_set_pincfg(codec, cfg->nid, |
| 1467 | cfg->val); |
| 1468 | break; |
| 1469 | case ALC_FIXUP_VERBS: |
| 1470 | if (action != ALC_FIXUP_ACT_PROBE || !fix->v.verbs) |
| 1471 | break; |
| 1472 | snd_printdd(KERN_INFO "hda_codec: %s: " |
| 1473 | "Apply fix-verbs for %s\n", |
| 1474 | codec->chip_name, modelname); |
| 1475 | add_verb(codec->spec, fix->v.verbs); |
| 1476 | break; |
| 1477 | case ALC_FIXUP_FUNC: |
| 1478 | if (!fix->v.func) |
| 1479 | break; |
| 1480 | snd_printdd(KERN_INFO "hda_codec: %s: " |
| 1481 | "Apply fix-func for %s\n", |
| 1482 | codec->chip_name, modelname); |
| 1483 | fix->v.func(codec, fix, action); |
| 1484 | break; |
| 1485 | default: |
| 1486 | snd_printk(KERN_ERR "hda_codec: %s: " |
| 1487 | "Invalid fixup type %d\n", |
| 1488 | codec->chip_name, fix->type); |
| 1489 | break; |
| 1490 | } |
Takashi Iwai | 24af2b1 | 2011-05-02 13:55:36 +0200 | [diff] [blame] | 1491 | if (!fix->chained) |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1492 | break; |
| 1493 | if (++depth > 10) |
| 1494 | break; |
Takashi Iwai | 24af2b1 | 2011-05-02 13:55:36 +0200 | [diff] [blame] | 1495 | id = fix->chain_id; |
Takashi Iwai | 9d57883 | 2010-11-22 13:29:19 +0100 | [diff] [blame] | 1496 | } |
Takashi Iwai | f95474e | 2007-07-10 00:47:43 +0200 | [diff] [blame] | 1497 | } |
| 1498 | |
Todd Broch | e1eb5f1 | 2010-12-06 11:19:51 -0800 | [diff] [blame] | 1499 | static void alc_pick_fixup(struct hda_codec *codec, |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1500 | const struct alc_model_fixup *models, |
| 1501 | const struct snd_pci_quirk *quirk, |
| 1502 | const struct alc_fixup *fixlist) |
Todd Broch | e1eb5f1 | 2010-12-06 11:19:51 -0800 | [diff] [blame] | 1503 | { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1504 | struct alc_spec *spec = codec->spec; |
| 1505 | int id = -1; |
| 1506 | const char *name = NULL; |
Todd Broch | e1eb5f1 | 2010-12-06 11:19:51 -0800 | [diff] [blame] | 1507 | |
Todd Broch | e1eb5f1 | 2010-12-06 11:19:51 -0800 | [diff] [blame] | 1508 | if (codec->modelname && models) { |
| 1509 | while (models->name) { |
| 1510 | if (!strcmp(codec->modelname, models->name)) { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1511 | id = models->id; |
| 1512 | name = models->name; |
Todd Broch | e1eb5f1 | 2010-12-06 11:19:51 -0800 | [diff] [blame] | 1513 | break; |
| 1514 | } |
| 1515 | models++; |
| 1516 | } |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1517 | } |
| 1518 | if (id < 0) { |
| 1519 | quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk); |
| 1520 | if (quirk) { |
| 1521 | id = quirk->value; |
| 1522 | #ifdef CONFIG_SND_DEBUG_VERBOSE |
| 1523 | name = quirk->name; |
| 1524 | #endif |
| 1525 | } |
| 1526 | } |
| 1527 | |
| 1528 | spec->fixup_id = id; |
| 1529 | if (id >= 0) { |
| 1530 | spec->fixup_list = fixlist; |
| 1531 | spec->fixup_name = name; |
Todd Broch | e1eb5f1 | 2010-12-06 11:19:51 -0800 | [diff] [blame] | 1532 | } |
Takashi Iwai | f95474e | 2007-07-10 00:47:43 +0200 | [diff] [blame] | 1533 | } |
| 1534 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1535 | /* |
| 1536 | * COEF access helper functions |
| 1537 | */ |
Kailang Yang | 274693f | 2009-12-03 10:07:50 +0100 | [diff] [blame] | 1538 | static int alc_read_coef_idx(struct hda_codec *codec, |
| 1539 | unsigned int coef_idx) |
| 1540 | { |
| 1541 | unsigned int val; |
| 1542 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, |
| 1543 | coef_idx); |
| 1544 | val = snd_hda_codec_read(codec, 0x20, 0, |
| 1545 | AC_VERB_GET_PROC_COEF, 0); |
| 1546 | return val; |
| 1547 | } |
| 1548 | |
Kailang Yang | 977ddd6 | 2010-09-15 10:02:29 +0200 | [diff] [blame] | 1549 | static void alc_write_coef_idx(struct hda_codec *codec, unsigned int coef_idx, |
| 1550 | unsigned int coef_val) |
| 1551 | { |
| 1552 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, |
| 1553 | coef_idx); |
| 1554 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, |
| 1555 | coef_val); |
| 1556 | } |
| 1557 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 1558 | /* a special bypass for COEF 0; read the cached value at the second time */ |
| 1559 | static unsigned int alc_get_coef0(struct hda_codec *codec) |
| 1560 | { |
| 1561 | struct alc_spec *spec = codec->spec; |
| 1562 | if (!spec->coef0) |
| 1563 | spec->coef0 = alc_read_coef_idx(codec, 0); |
| 1564 | return spec->coef0; |
| 1565 | } |
| 1566 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1567 | /* |
| 1568 | * Digital I/O handling |
| 1569 | */ |
| 1570 | |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1571 | /* set right pin controls for digital I/O */ |
| 1572 | static void alc_auto_init_digital(struct hda_codec *codec) |
| 1573 | { |
| 1574 | struct alc_spec *spec = codec->spec; |
| 1575 | int i; |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 1576 | hda_nid_t pin, dac; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1577 | |
| 1578 | for (i = 0; i < spec->autocfg.dig_outs; i++) { |
| 1579 | pin = spec->autocfg.dig_out_pins[i]; |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 1580 | if (!pin) |
| 1581 | continue; |
| 1582 | snd_hda_codec_write(codec, pin, 0, |
| 1583 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); |
| 1584 | if (!i) |
| 1585 | dac = spec->multiout.dig_out_nid; |
| 1586 | else |
| 1587 | dac = spec->slave_dig_outs[i - 1]; |
| 1588 | if (!dac || !(get_wcaps(codec, dac) & AC_WCAP_OUT_AMP)) |
| 1589 | continue; |
| 1590 | snd_hda_codec_write(codec, dac, 0, |
| 1591 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 1592 | AMP_OUT_UNMUTE); |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1593 | } |
| 1594 | pin = spec->autocfg.dig_in_pin; |
| 1595 | if (pin) |
| 1596 | snd_hda_codec_write(codec, pin, 0, |
| 1597 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 1598 | PIN_IN); |
| 1599 | } |
| 1600 | |
| 1601 | /* parse digital I/Os and set up NIDs in BIOS auto-parse mode */ |
| 1602 | static void alc_auto_parse_digital(struct hda_codec *codec) |
| 1603 | { |
| 1604 | struct alc_spec *spec = codec->spec; |
| 1605 | int i, err; |
| 1606 | hda_nid_t dig_nid; |
| 1607 | |
| 1608 | /* support multiple SPDIFs; the secondary is set up as a slave */ |
| 1609 | for (i = 0; i < spec->autocfg.dig_outs; i++) { |
Takashi Iwai | a926757 | 2011-07-07 15:12:55 +0200 | [diff] [blame] | 1610 | hda_nid_t conn[4]; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1611 | err = snd_hda_get_connections(codec, |
| 1612 | spec->autocfg.dig_out_pins[i], |
Takashi Iwai | a926757 | 2011-07-07 15:12:55 +0200 | [diff] [blame] | 1613 | conn, ARRAY_SIZE(conn)); |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1614 | if (err < 0) |
| 1615 | continue; |
Takashi Iwai | a926757 | 2011-07-07 15:12:55 +0200 | [diff] [blame] | 1616 | dig_nid = conn[0]; /* assume the first element is audio-out */ |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1617 | if (!i) { |
| 1618 | spec->multiout.dig_out_nid = dig_nid; |
| 1619 | spec->dig_out_type = spec->autocfg.dig_out_type[0]; |
| 1620 | } else { |
| 1621 | spec->multiout.slave_dig_outs = spec->slave_dig_outs; |
| 1622 | if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1) |
| 1623 | break; |
| 1624 | spec->slave_dig_outs[i - 1] = dig_nid; |
| 1625 | } |
| 1626 | } |
| 1627 | |
| 1628 | if (spec->autocfg.dig_in_pin) { |
Takashi Iwai | 01fdf18 | 2010-09-24 09:09:42 +0200 | [diff] [blame] | 1629 | dig_nid = codec->start_nid; |
| 1630 | for (i = 0; i < codec->num_nodes; i++, dig_nid++) { |
| 1631 | unsigned int wcaps = get_wcaps(codec, dig_nid); |
| 1632 | if (get_wcaps_type(wcaps) != AC_WID_AUD_IN) |
| 1633 | continue; |
| 1634 | if (!(wcaps & AC_WCAP_DIGITAL)) |
| 1635 | continue; |
| 1636 | if (!(wcaps & AC_WCAP_CONN_LIST)) |
| 1637 | continue; |
| 1638 | err = get_connection_index(codec, dig_nid, |
| 1639 | spec->autocfg.dig_in_pin); |
| 1640 | if (err >= 0) { |
| 1641 | spec->dig_in_nid = dig_nid; |
| 1642 | break; |
| 1643 | } |
| 1644 | } |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1645 | } |
| 1646 | } |
| 1647 | |
Takashi Iwai | f95474e | 2007-07-10 00:47:43 +0200 | [diff] [blame] | 1648 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1649 | * capture mixer elements |
Vincent Petry | ef8ef5f | 2008-11-23 11:31:41 +0800 | [diff] [blame] | 1650 | */ |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1651 | static int alc_cap_vol_info(struct snd_kcontrol *kcontrol, |
| 1652 | struct snd_ctl_elem_info *uinfo) |
| 1653 | { |
| 1654 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1655 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 1656 | unsigned long val; |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1657 | int err; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1658 | |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1659 | mutex_lock(&codec->control_mutex); |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 1660 | if (spec->vol_in_capsrc) |
| 1661 | val = HDA_COMPOSE_AMP_VAL(spec->capsrc_nids[0], 3, 0, HDA_OUTPUT); |
| 1662 | else |
| 1663 | val = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0, HDA_INPUT); |
| 1664 | kcontrol->private_value = val; |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1665 | err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo); |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1666 | mutex_unlock(&codec->control_mutex); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1667 | return err; |
| 1668 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1669 | |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1670 | static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag, |
| 1671 | unsigned int size, unsigned int __user *tlv) |
| 1672 | { |
| 1673 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1674 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 1675 | unsigned long val; |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1676 | int err; |
| 1677 | |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1678 | mutex_lock(&codec->control_mutex); |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 1679 | if (spec->vol_in_capsrc) |
| 1680 | val = HDA_COMPOSE_AMP_VAL(spec->capsrc_nids[0], 3, 0, HDA_OUTPUT); |
| 1681 | else |
| 1682 | val = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0, HDA_INPUT); |
| 1683 | kcontrol->private_value = val; |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1684 | err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv); |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1685 | mutex_unlock(&codec->control_mutex); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1686 | return err; |
| 1687 | } |
| 1688 | |
| 1689 | typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol, |
| 1690 | struct snd_ctl_elem_value *ucontrol); |
| 1691 | |
| 1692 | static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol, |
| 1693 | struct snd_ctl_elem_value *ucontrol, |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1694 | getput_call_t func, bool check_adc_switch) |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1695 | { |
| 1696 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1697 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1698 | int i, err = 0; |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1699 | |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1700 | mutex_lock(&codec->control_mutex); |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1701 | if (check_adc_switch && spec->dyn_adc_switch) { |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1702 | for (i = 0; i < spec->num_adc_nids; i++) { |
| 1703 | kcontrol->private_value = |
| 1704 | HDA_COMPOSE_AMP_VAL(spec->adc_nids[i], |
| 1705 | 3, 0, HDA_INPUT); |
| 1706 | err = func(kcontrol, ucontrol); |
| 1707 | if (err < 0) |
| 1708 | goto error; |
| 1709 | } |
| 1710 | } else { |
| 1711 | i = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 1712 | if (spec->vol_in_capsrc) |
| 1713 | kcontrol->private_value = |
| 1714 | HDA_COMPOSE_AMP_VAL(spec->capsrc_nids[i], |
| 1715 | 3, 0, HDA_OUTPUT); |
| 1716 | else |
| 1717 | kcontrol->private_value = |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1718 | HDA_COMPOSE_AMP_VAL(spec->adc_nids[i], |
| 1719 | 3, 0, HDA_INPUT); |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1720 | err = func(kcontrol, ucontrol); |
| 1721 | } |
| 1722 | error: |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1723 | mutex_unlock(&codec->control_mutex); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1724 | return err; |
| 1725 | } |
| 1726 | |
| 1727 | static int alc_cap_vol_get(struct snd_kcontrol *kcontrol, |
| 1728 | struct snd_ctl_elem_value *ucontrol) |
| 1729 | { |
| 1730 | return alc_cap_getput_caller(kcontrol, ucontrol, |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1731 | snd_hda_mixer_amp_volume_get, false); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1732 | } |
| 1733 | |
| 1734 | static int alc_cap_vol_put(struct snd_kcontrol *kcontrol, |
| 1735 | struct snd_ctl_elem_value *ucontrol) |
| 1736 | { |
| 1737 | return alc_cap_getput_caller(kcontrol, ucontrol, |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1738 | snd_hda_mixer_amp_volume_put, true); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1739 | } |
| 1740 | |
| 1741 | /* capture mixer elements */ |
| 1742 | #define alc_cap_sw_info snd_ctl_boolean_stereo_info |
| 1743 | |
| 1744 | static int alc_cap_sw_get(struct snd_kcontrol *kcontrol, |
| 1745 | struct snd_ctl_elem_value *ucontrol) |
| 1746 | { |
| 1747 | return alc_cap_getput_caller(kcontrol, ucontrol, |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1748 | snd_hda_mixer_amp_switch_get, false); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1749 | } |
| 1750 | |
| 1751 | static int alc_cap_sw_put(struct snd_kcontrol *kcontrol, |
| 1752 | struct snd_ctl_elem_value *ucontrol) |
| 1753 | { |
| 1754 | return alc_cap_getput_caller(kcontrol, ucontrol, |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1755 | snd_hda_mixer_amp_switch_put, true); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1756 | } |
| 1757 | |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1758 | #define _DEFINE_CAPMIX(num) \ |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1759 | { \ |
| 1760 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1761 | .name = "Capture Switch", \ |
| 1762 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \ |
| 1763 | .count = num, \ |
| 1764 | .info = alc_cap_sw_info, \ |
| 1765 | .get = alc_cap_sw_get, \ |
| 1766 | .put = alc_cap_sw_put, \ |
| 1767 | }, \ |
| 1768 | { \ |
| 1769 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1770 | .name = "Capture Volume", \ |
| 1771 | .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \ |
| 1772 | SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ |
| 1773 | SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \ |
| 1774 | .count = num, \ |
| 1775 | .info = alc_cap_vol_info, \ |
| 1776 | .get = alc_cap_vol_get, \ |
| 1777 | .put = alc_cap_vol_put, \ |
| 1778 | .tlv = { .c = alc_cap_vol_tlv }, \ |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1779 | } |
| 1780 | |
| 1781 | #define _DEFINE_CAPSRC(num) \ |
Takashi Iwai | 3c3e989 | 2008-10-31 17:48:56 +0100 | [diff] [blame] | 1782 | { \ |
| 1783 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1784 | /* .name = "Capture Source", */ \ |
| 1785 | .name = "Input Source", \ |
| 1786 | .count = num, \ |
| 1787 | .info = alc_mux_enum_info, \ |
| 1788 | .get = alc_mux_enum_get, \ |
| 1789 | .put = alc_mux_enum_put, \ |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1790 | } |
| 1791 | |
| 1792 | #define DEFINE_CAPMIX(num) \ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 1793 | static const struct snd_kcontrol_new alc_capture_mixer ## num[] = { \ |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1794 | _DEFINE_CAPMIX(num), \ |
| 1795 | _DEFINE_CAPSRC(num), \ |
| 1796 | { } /* end */ \ |
| 1797 | } |
| 1798 | |
| 1799 | #define DEFINE_CAPMIX_NOSRC(num) \ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 1800 | static const struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \ |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1801 | _DEFINE_CAPMIX(num), \ |
| 1802 | { } /* end */ \ |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1803 | } |
| 1804 | |
| 1805 | /* up to three ADCs */ |
| 1806 | DEFINE_CAPMIX(1); |
| 1807 | DEFINE_CAPMIX(2); |
| 1808 | DEFINE_CAPMIX(3); |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1809 | DEFINE_CAPMIX_NOSRC(1); |
| 1810 | DEFINE_CAPMIX_NOSRC(2); |
| 1811 | DEFINE_CAPMIX_NOSRC(3); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1812 | |
| 1813 | /* |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1814 | * virtual master controls |
| 1815 | */ |
| 1816 | |
| 1817 | /* |
| 1818 | * slave controls for virtual master |
| 1819 | */ |
Takashi Iwai | ea73496 | 2011-01-17 11:29:34 +0100 | [diff] [blame] | 1820 | static const char * const alc_slave_vols[] = { |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1821 | "Front Playback Volume", |
| 1822 | "Surround Playback Volume", |
| 1823 | "Center Playback Volume", |
| 1824 | "LFE Playback Volume", |
| 1825 | "Side Playback Volume", |
| 1826 | "Headphone Playback Volume", |
| 1827 | "Speaker Playback Volume", |
| 1828 | "Mono Playback Volume", |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1829 | "Line-Out Playback Volume", |
Takashi Iwai | 3fe45ae | 2011-08-18 15:13:17 +0200 | [diff] [blame] | 1830 | "PCM Playback Volume", |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1831 | NULL, |
| 1832 | }; |
| 1833 | |
Takashi Iwai | ea73496 | 2011-01-17 11:29:34 +0100 | [diff] [blame] | 1834 | static const char * const alc_slave_sws[] = { |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1835 | "Front Playback Switch", |
| 1836 | "Surround Playback Switch", |
| 1837 | "Center Playback Switch", |
| 1838 | "LFE Playback Switch", |
| 1839 | "Side Playback Switch", |
| 1840 | "Headphone Playback Switch", |
| 1841 | "Speaker Playback Switch", |
| 1842 | "Mono Playback Switch", |
Takashi Iwai | edb54a5 | 2008-01-29 12:47:02 +0100 | [diff] [blame] | 1843 | "IEC958 Playback Switch", |
Takashi Iwai | 23033b2 | 2009-12-08 12:36:52 +0100 | [diff] [blame] | 1844 | "Line-Out Playback Switch", |
Takashi Iwai | 3fe45ae | 2011-08-18 15:13:17 +0200 | [diff] [blame] | 1845 | "PCM Playback Switch", |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1846 | NULL, |
| 1847 | }; |
| 1848 | |
| 1849 | /* |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1850 | * build control elements |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1851 | */ |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 1852 | |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 1853 | #define NID_MAPPING (-1) |
| 1854 | |
| 1855 | #define SUBDEV_SPEAKER_ (0 << 6) |
| 1856 | #define SUBDEV_HP_ (1 << 6) |
| 1857 | #define SUBDEV_LINE_ (2 << 6) |
| 1858 | #define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f)) |
| 1859 | #define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f)) |
| 1860 | #define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f)) |
| 1861 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 1862 | static void alc_free_kctls(struct hda_codec *codec); |
| 1863 | |
Takashi Iwai | 67d634c | 2009-11-16 15:35:59 +0100 | [diff] [blame] | 1864 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1865 | /* additional beep mixers; the actual parameters are overwritten at build */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 1866 | static const struct snd_kcontrol_new alc_beep_mixer[] = { |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1867 | HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT), |
Jaroslav Kysela | 123c07a | 2009-10-21 14:48:23 +0200 | [diff] [blame] | 1868 | HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT), |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1869 | { } /* end */ |
| 1870 | }; |
Takashi Iwai | 67d634c | 2009-11-16 15:35:59 +0100 | [diff] [blame] | 1871 | #endif |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1872 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1873 | static int alc_build_controls(struct hda_codec *codec) |
| 1874 | { |
| 1875 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 2f44f84 | 2010-06-22 11:12:32 +0200 | [diff] [blame] | 1876 | struct snd_kcontrol *kctl = NULL; |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 1877 | const struct snd_kcontrol_new *knew; |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 1878 | int i, j, err; |
| 1879 | unsigned int u; |
| 1880 | hda_nid_t nid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1881 | |
| 1882 | for (i = 0; i < spec->num_mixers; i++) { |
| 1883 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); |
| 1884 | if (err < 0) |
| 1885 | return err; |
| 1886 | } |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1887 | if (spec->cap_mixer) { |
| 1888 | err = snd_hda_add_new_ctls(codec, spec->cap_mixer); |
| 1889 | if (err < 0) |
| 1890 | return err; |
| 1891 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1892 | if (spec->multiout.dig_out_nid) { |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 1893 | err = snd_hda_create_spdif_out_ctls(codec, |
Stephen Warren | 74b654c | 2011-06-01 11:14:18 -0600 | [diff] [blame] | 1894 | spec->multiout.dig_out_nid, |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 1895 | spec->multiout.dig_out_nid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1896 | if (err < 0) |
| 1897 | return err; |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 1898 | if (!spec->no_analog) { |
| 1899 | err = snd_hda_create_spdif_share_sw(codec, |
| 1900 | &spec->multiout); |
| 1901 | if (err < 0) |
| 1902 | return err; |
| 1903 | spec->multiout.share_spdif = 1; |
| 1904 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1905 | } |
| 1906 | if (spec->dig_in_nid) { |
| 1907 | err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); |
| 1908 | if (err < 0) |
| 1909 | return err; |
| 1910 | } |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1911 | |
Takashi Iwai | 67d634c | 2009-11-16 15:35:59 +0100 | [diff] [blame] | 1912 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1913 | /* create beep controls if needed */ |
| 1914 | if (spec->beep_amp) { |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 1915 | const struct snd_kcontrol_new *knew; |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1916 | for (knew = alc_beep_mixer; knew->name; knew++) { |
| 1917 | struct snd_kcontrol *kctl; |
| 1918 | kctl = snd_ctl_new1(knew, codec); |
| 1919 | if (!kctl) |
| 1920 | return -ENOMEM; |
| 1921 | kctl->private_value = spec->beep_amp; |
Jaroslav Kysela | 5e26dfd | 2009-12-10 13:57:01 +0100 | [diff] [blame] | 1922 | err = snd_hda_ctl_add(codec, 0, kctl); |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1923 | if (err < 0) |
| 1924 | return err; |
| 1925 | } |
| 1926 | } |
Takashi Iwai | 67d634c | 2009-11-16 15:35:59 +0100 | [diff] [blame] | 1927 | #endif |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1928 | |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1929 | /* if we have no master control, let's create it */ |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 1930 | if (!spec->no_analog && |
| 1931 | !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1932 | unsigned int vmaster_tlv[4]; |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1933 | snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid, |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1934 | HDA_OUTPUT, vmaster_tlv); |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1935 | err = snd_hda_add_vmaster(codec, "Master Playback Volume", |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1936 | vmaster_tlv, alc_slave_vols); |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1937 | if (err < 0) |
| 1938 | return err; |
| 1939 | } |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 1940 | if (!spec->no_analog && |
| 1941 | !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) { |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1942 | err = snd_hda_add_vmaster(codec, "Master Playback Switch", |
| 1943 | NULL, alc_slave_sws); |
| 1944 | if (err < 0) |
| 1945 | return err; |
| 1946 | } |
| 1947 | |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 1948 | /* assign Capture Source enums to NID */ |
Takashi Iwai | fbe618f | 2010-06-11 11:24:58 +0200 | [diff] [blame] | 1949 | if (spec->capsrc_nids || spec->adc_nids) { |
| 1950 | kctl = snd_hda_find_mixer_ctl(codec, "Capture Source"); |
| 1951 | if (!kctl) |
| 1952 | kctl = snd_hda_find_mixer_ctl(codec, "Input Source"); |
| 1953 | for (i = 0; kctl && i < kctl->count; i++) { |
Takashi Iwai | 4c6d72d | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 1954 | const hda_nid_t *nids = spec->capsrc_nids; |
Takashi Iwai | fbe618f | 2010-06-11 11:24:58 +0200 | [diff] [blame] | 1955 | if (!nids) |
| 1956 | nids = spec->adc_nids; |
| 1957 | err = snd_hda_add_nid(codec, kctl, i, nids[i]); |
| 1958 | if (err < 0) |
| 1959 | return err; |
| 1960 | } |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 1961 | } |
Takashi Iwai | 60a6a84 | 2011-07-27 14:01:24 +0200 | [diff] [blame] | 1962 | if (spec->cap_mixer && spec->adc_nids) { |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 1963 | const char *kname = kctl ? kctl->id.name : NULL; |
| 1964 | for (knew = spec->cap_mixer; knew->name; knew++) { |
| 1965 | if (kname && strcmp(knew->name, kname) == 0) |
| 1966 | continue; |
| 1967 | kctl = snd_hda_find_mixer_ctl(codec, knew->name); |
| 1968 | for (i = 0; kctl && i < kctl->count; i++) { |
| 1969 | err = snd_hda_add_nid(codec, kctl, i, |
| 1970 | spec->adc_nids[i]); |
| 1971 | if (err < 0) |
| 1972 | return err; |
| 1973 | } |
| 1974 | } |
| 1975 | } |
| 1976 | |
| 1977 | /* other nid->control mapping */ |
| 1978 | for (i = 0; i < spec->num_mixers; i++) { |
| 1979 | for (knew = spec->mixers[i]; knew->name; knew++) { |
| 1980 | if (knew->iface != NID_MAPPING) |
| 1981 | continue; |
| 1982 | kctl = snd_hda_find_mixer_ctl(codec, knew->name); |
| 1983 | if (kctl == NULL) |
| 1984 | continue; |
| 1985 | u = knew->subdevice; |
| 1986 | for (j = 0; j < 4; j++, u >>= 8) { |
| 1987 | nid = u & 0x3f; |
| 1988 | if (nid == 0) |
| 1989 | continue; |
| 1990 | switch (u & 0xc0) { |
| 1991 | case SUBDEV_SPEAKER_: |
| 1992 | nid = spec->autocfg.speaker_pins[nid]; |
| 1993 | break; |
| 1994 | case SUBDEV_LINE_: |
| 1995 | nid = spec->autocfg.line_out_pins[nid]; |
| 1996 | break; |
| 1997 | case SUBDEV_HP_: |
| 1998 | nid = spec->autocfg.hp_pins[nid]; |
| 1999 | break; |
| 2000 | default: |
| 2001 | continue; |
| 2002 | } |
| 2003 | err = snd_hda_add_nid(codec, kctl, 0, nid); |
| 2004 | if (err < 0) |
| 2005 | return err; |
| 2006 | } |
| 2007 | u = knew->private_value; |
| 2008 | for (j = 0; j < 4; j++, u >>= 8) { |
| 2009 | nid = u & 0xff; |
| 2010 | if (nid == 0) |
| 2011 | continue; |
| 2012 | err = snd_hda_add_nid(codec, kctl, 0, nid); |
| 2013 | if (err < 0) |
| 2014 | return err; |
| 2015 | } |
| 2016 | } |
| 2017 | } |
Takashi Iwai | bae84e7 | 2010-03-22 08:30:20 +0100 | [diff] [blame] | 2018 | |
| 2019 | alc_free_kctls(codec); /* no longer needed */ |
| 2020 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2021 | return 0; |
| 2022 | } |
| 2023 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2024 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2025 | /* |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 2026 | * Common callbacks |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2027 | */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2028 | |
Takashi Iwai | 584c0c4 | 2011-03-10 12:51:11 +0100 | [diff] [blame] | 2029 | static void alc_init_special_input_src(struct hda_codec *codec); |
| 2030 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2031 | static int alc_init(struct hda_codec *codec) |
| 2032 | { |
| 2033 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2034 | unsigned int i; |
| 2035 | |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 2036 | alc_fix_pll(codec); |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 2037 | alc_auto_init_amp(codec, spec->init_amp); |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 2038 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2039 | for (i = 0; i < spec->num_init_verbs; i++) |
| 2040 | snd_hda_sequence_write(codec, spec->init_verbs[i]); |
Takashi Iwai | 584c0c4 | 2011-03-10 12:51:11 +0100 | [diff] [blame] | 2041 | alc_init_special_input_src(codec); |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 2042 | |
| 2043 | if (spec->init_hook) |
| 2044 | spec->init_hook(codec); |
| 2045 | |
Takashi Iwai | 5870112 | 2011-01-13 15:41:45 +0100 | [diff] [blame] | 2046 | alc_apply_fixup(codec, ALC_FIXUP_ACT_INIT); |
| 2047 | |
Takashi Iwai | 9e5341b | 2010-09-21 09:57:06 +0200 | [diff] [blame] | 2048 | hda_call_check_power_status(codec, 0x01); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2049 | return 0; |
| 2050 | } |
| 2051 | |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 2052 | static void alc_unsol_event(struct hda_codec *codec, unsigned int res) |
| 2053 | { |
| 2054 | struct alc_spec *spec = codec->spec; |
| 2055 | |
| 2056 | if (spec->unsol_event) |
| 2057 | spec->unsol_event(codec, res); |
| 2058 | } |
| 2059 | |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 2060 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 2061 | static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid) |
| 2062 | { |
| 2063 | struct alc_spec *spec = codec->spec; |
| 2064 | return snd_hda_check_amp_list_power(codec, &spec->loopback, nid); |
| 2065 | } |
| 2066 | #endif |
| 2067 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2068 | /* |
| 2069 | * Analog playback callbacks |
| 2070 | */ |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2071 | static int alc_playback_pcm_open(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2072 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2073 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2074 | { |
| 2075 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 9a08160 | 2008-02-12 18:37:26 +0100 | [diff] [blame] | 2076 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, |
| 2077 | hinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2078 | } |
| 2079 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2080 | static int alc_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2081 | struct hda_codec *codec, |
| 2082 | unsigned int stream_tag, |
| 2083 | unsigned int format, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2084 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2085 | { |
| 2086 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 2087 | return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, |
| 2088 | stream_tag, format, substream); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2089 | } |
| 2090 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2091 | static int alc_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2092 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2093 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2094 | { |
| 2095 | struct alc_spec *spec = codec->spec; |
| 2096 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); |
| 2097 | } |
| 2098 | |
| 2099 | /* |
| 2100 | * Digital out |
| 2101 | */ |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2102 | static int alc_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2103 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2104 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2105 | { |
| 2106 | struct alc_spec *spec = codec->spec; |
| 2107 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); |
| 2108 | } |
| 2109 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2110 | static int alc_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
Takashi Iwai | 6b97eb4 | 2007-04-05 14:51:48 +0200 | [diff] [blame] | 2111 | struct hda_codec *codec, |
| 2112 | unsigned int stream_tag, |
| 2113 | unsigned int format, |
| 2114 | struct snd_pcm_substream *substream) |
| 2115 | { |
| 2116 | struct alc_spec *spec = codec->spec; |
| 2117 | return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, |
| 2118 | stream_tag, format, substream); |
| 2119 | } |
| 2120 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2121 | static int alc_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
Takashi Iwai | 9b5f12e | 2009-02-13 11:47:37 +0100 | [diff] [blame] | 2122 | struct hda_codec *codec, |
| 2123 | struct snd_pcm_substream *substream) |
| 2124 | { |
| 2125 | struct alc_spec *spec = codec->spec; |
| 2126 | return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout); |
| 2127 | } |
| 2128 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2129 | static int alc_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2130 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2131 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2132 | { |
| 2133 | struct alc_spec *spec = codec->spec; |
| 2134 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); |
| 2135 | } |
| 2136 | |
| 2137 | /* |
| 2138 | * Analog capture |
| 2139 | */ |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2140 | static int alc_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2141 | struct hda_codec *codec, |
| 2142 | unsigned int stream_tag, |
| 2143 | unsigned int format, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2144 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2145 | { |
| 2146 | struct alc_spec *spec = codec->spec; |
| 2147 | |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2148 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1], |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2149 | stream_tag, 0, format); |
| 2150 | return 0; |
| 2151 | } |
| 2152 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2153 | static int alc_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2154 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2155 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2156 | { |
| 2157 | struct alc_spec *spec = codec->spec; |
| 2158 | |
Takashi Iwai | 888afa1 | 2008-03-18 09:57:50 +0100 | [diff] [blame] | 2159 | snd_hda_codec_cleanup_stream(codec, |
| 2160 | spec->adc_nids[substream->number + 1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2161 | return 0; |
| 2162 | } |
| 2163 | |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 2164 | /* analog capture with dynamic dual-adc changes */ |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2165 | static int dyn_adc_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 2166 | struct hda_codec *codec, |
| 2167 | unsigned int stream_tag, |
| 2168 | unsigned int format, |
| 2169 | struct snd_pcm_substream *substream) |
| 2170 | { |
| 2171 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2172 | 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] | 2173 | spec->cur_adc_stream_tag = stream_tag; |
| 2174 | spec->cur_adc_format = format; |
| 2175 | snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format); |
| 2176 | return 0; |
| 2177 | } |
| 2178 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2179 | static int dyn_adc_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 2180 | struct hda_codec *codec, |
| 2181 | struct snd_pcm_substream *substream) |
| 2182 | { |
| 2183 | struct alc_spec *spec = codec->spec; |
| 2184 | snd_hda_codec_cleanup_stream(codec, spec->cur_adc); |
| 2185 | spec->cur_adc = 0; |
| 2186 | return 0; |
| 2187 | } |
| 2188 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2189 | static const struct hda_pcm_stream dyn_adc_pcm_analog_capture = { |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 2190 | .substreams = 1, |
| 2191 | .channels_min = 2, |
| 2192 | .channels_max = 2, |
| 2193 | .nid = 0, /* fill later */ |
| 2194 | .ops = { |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2195 | .prepare = dyn_adc_capture_pcm_prepare, |
| 2196 | .cleanup = dyn_adc_capture_pcm_cleanup |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 2197 | }, |
| 2198 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2199 | |
| 2200 | /* |
| 2201 | */ |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2202 | static const struct hda_pcm_stream alc_pcm_analog_playback = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2203 | .substreams = 1, |
| 2204 | .channels_min = 2, |
| 2205 | .channels_max = 8, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2206 | /* NID is set in alc_build_pcms */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2207 | .ops = { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2208 | .open = alc_playback_pcm_open, |
| 2209 | .prepare = alc_playback_pcm_prepare, |
| 2210 | .cleanup = alc_playback_pcm_cleanup |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2211 | }, |
| 2212 | }; |
| 2213 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2214 | static const struct hda_pcm_stream alc_pcm_analog_capture = { |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2215 | .substreams = 1, |
| 2216 | .channels_min = 2, |
| 2217 | .channels_max = 2, |
| 2218 | /* NID is set in alc_build_pcms */ |
| 2219 | }; |
| 2220 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2221 | static const struct hda_pcm_stream alc_pcm_analog_alt_playback = { |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2222 | .substreams = 1, |
| 2223 | .channels_min = 2, |
| 2224 | .channels_max = 2, |
| 2225 | /* NID is set in alc_build_pcms */ |
| 2226 | }; |
| 2227 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2228 | static const struct hda_pcm_stream alc_pcm_analog_alt_capture = { |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2229 | .substreams = 2, /* can be overridden */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2230 | .channels_min = 2, |
| 2231 | .channels_max = 2, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2232 | /* NID is set in alc_build_pcms */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2233 | .ops = { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2234 | .prepare = alc_alt_capture_pcm_prepare, |
| 2235 | .cleanup = alc_alt_capture_pcm_cleanup |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2236 | }, |
| 2237 | }; |
| 2238 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2239 | static const struct hda_pcm_stream alc_pcm_digital_playback = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2240 | .substreams = 1, |
| 2241 | .channels_min = 2, |
| 2242 | .channels_max = 2, |
| 2243 | /* NID is set in alc_build_pcms */ |
| 2244 | .ops = { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2245 | .open = alc_dig_playback_pcm_open, |
| 2246 | .close = alc_dig_playback_pcm_close, |
| 2247 | .prepare = alc_dig_playback_pcm_prepare, |
| 2248 | .cleanup = alc_dig_playback_pcm_cleanup |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2249 | }, |
| 2250 | }; |
| 2251 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2252 | static const struct hda_pcm_stream alc_pcm_digital_capture = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2253 | .substreams = 1, |
| 2254 | .channels_min = 2, |
| 2255 | .channels_max = 2, |
| 2256 | /* NID is set in alc_build_pcms */ |
| 2257 | }; |
| 2258 | |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 2259 | /* 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] | 2260 | static const struct hda_pcm_stream alc_pcm_null_stream = { |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 2261 | .substreams = 0, |
| 2262 | .channels_min = 0, |
| 2263 | .channels_max = 0, |
| 2264 | }; |
| 2265 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2266 | static int alc_build_pcms(struct hda_codec *codec) |
| 2267 | { |
| 2268 | struct alc_spec *spec = codec->spec; |
| 2269 | struct hda_pcm *info = spec->pcm_rec; |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2270 | const struct hda_pcm_stream *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2271 | int i; |
| 2272 | |
| 2273 | codec->num_pcms = 1; |
| 2274 | codec->pcm_info = info; |
| 2275 | |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 2276 | if (spec->no_analog) |
| 2277 | goto skip_analog; |
| 2278 | |
Takashi Iwai | 812a2cc | 2009-05-16 10:00:49 +0200 | [diff] [blame] | 2279 | snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog), |
| 2280 | "%s Analog", codec->chip_name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2281 | info->name = spec->stream_name_analog; |
Kailang Yang | 274693f | 2009-12-03 10:07:50 +0100 | [diff] [blame] | 2282 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2283 | if (spec->multiout.dac_nids > 0) { |
| 2284 | p = spec->stream_analog_playback; |
| 2285 | if (!p) |
| 2286 | p = &alc_pcm_analog_playback; |
| 2287 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *p; |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 2288 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0]; |
| 2289 | } |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2290 | if (spec->adc_nids) { |
| 2291 | p = spec->stream_analog_capture; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2292 | if (!p) { |
| 2293 | if (spec->dyn_adc_switch) |
| 2294 | p = &dyn_adc_pcm_analog_capture; |
| 2295 | else |
| 2296 | p = &alc_pcm_analog_capture; |
| 2297 | } |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2298 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *p; |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 2299 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; |
| 2300 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2301 | |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 2302 | if (spec->channel_mode) { |
| 2303 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0; |
| 2304 | for (i = 0; i < spec->num_channel_mode; i++) { |
| 2305 | if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) { |
| 2306 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels; |
| 2307 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2308 | } |
| 2309 | } |
| 2310 | |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 2311 | skip_analog: |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2312 | /* SPDIF for stream index #1 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2313 | if (spec->multiout.dig_out_nid || spec->dig_in_nid) { |
Takashi Iwai | 812a2cc | 2009-05-16 10:00:49 +0200 | [diff] [blame] | 2314 | snprintf(spec->stream_name_digital, |
| 2315 | sizeof(spec->stream_name_digital), |
| 2316 | "%s Digital", codec->chip_name); |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2317 | codec->num_pcms = 2; |
Wu Fengguang | b25c9da | 2009-02-06 15:02:27 +0800 | [diff] [blame] | 2318 | codec->slave_dig_outs = spec->multiout.slave_dig_outs; |
Takashi Iwai | c06134d | 2006-10-11 18:49:13 +0200 | [diff] [blame] | 2319 | info = spec->pcm_rec + 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2320 | info->name = spec->stream_name_digital; |
Takashi Iwai | 8c44198 | 2009-01-20 18:30:20 +0100 | [diff] [blame] | 2321 | if (spec->dig_out_type) |
| 2322 | info->pcm_type = spec->dig_out_type; |
| 2323 | else |
| 2324 | info->pcm_type = HDA_PCM_TYPE_SPDIF; |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2325 | if (spec->multiout.dig_out_nid) { |
| 2326 | p = spec->stream_digital_playback; |
| 2327 | if (!p) |
| 2328 | p = &alc_pcm_digital_playback; |
| 2329 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2330 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; |
| 2331 | } |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2332 | if (spec->dig_in_nid) { |
| 2333 | p = spec->stream_digital_capture; |
| 2334 | if (!p) |
| 2335 | p = &alc_pcm_digital_capture; |
| 2336 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2337 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; |
| 2338 | } |
Takashi Iwai | 963f803 | 2008-08-11 10:04:40 +0200 | [diff] [blame] | 2339 | /* FIXME: do we need this for all Realtek codec models? */ |
| 2340 | codec->spdif_status_reset = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2341 | } |
| 2342 | |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 2343 | if (spec->no_analog) |
| 2344 | return 0; |
| 2345 | |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2346 | /* If the use of more than one ADC is requested for the current |
| 2347 | * model, configure a second analog capture-only PCM. |
| 2348 | */ |
| 2349 | /* Additional Analaog capture for index #2 */ |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2350 | if (spec->alt_dac_nid || spec->num_adc_nids > 1) { |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2351 | codec->num_pcms = 3; |
Takashi Iwai | c06134d | 2006-10-11 18:49:13 +0200 | [diff] [blame] | 2352 | info = spec->pcm_rec + 2; |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2353 | info->name = spec->stream_name_analog; |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2354 | if (spec->alt_dac_nid) { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2355 | p = spec->stream_analog_alt_playback; |
| 2356 | if (!p) |
| 2357 | p = &alc_pcm_analog_alt_playback; |
| 2358 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *p; |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2359 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = |
| 2360 | spec->alt_dac_nid; |
| 2361 | } else { |
| 2362 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = |
| 2363 | alc_pcm_null_stream; |
| 2364 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0; |
| 2365 | } |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2366 | if (spec->num_adc_nids > 1) { |
| 2367 | p = spec->stream_analog_alt_capture; |
| 2368 | if (!p) |
| 2369 | p = &alc_pcm_analog_alt_capture; |
| 2370 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *p; |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2371 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = |
| 2372 | spec->adc_nids[1]; |
| 2373 | info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = |
| 2374 | spec->num_adc_nids - 1; |
| 2375 | } else { |
| 2376 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = |
| 2377 | alc_pcm_null_stream; |
| 2378 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0; |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2379 | } |
| 2380 | } |
| 2381 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2382 | return 0; |
| 2383 | } |
| 2384 | |
Takashi Iwai | a4e09aa | 2009-12-27 11:22:24 +0100 | [diff] [blame] | 2385 | static inline void alc_shutup(struct hda_codec *codec) |
| 2386 | { |
Takashi Iwai | 1c716153 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 2387 | struct alc_spec *spec = codec->spec; |
| 2388 | |
| 2389 | if (spec && spec->shutup) |
| 2390 | spec->shutup(codec); |
Takashi Iwai | a4e09aa | 2009-12-27 11:22:24 +0100 | [diff] [blame] | 2391 | snd_hda_shutup_pins(codec); |
| 2392 | } |
| 2393 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 2394 | static void alc_free_kctls(struct hda_codec *codec) |
| 2395 | { |
| 2396 | struct alc_spec *spec = codec->spec; |
| 2397 | |
| 2398 | if (spec->kctls.list) { |
| 2399 | struct snd_kcontrol_new *kctl = spec->kctls.list; |
| 2400 | int i; |
| 2401 | for (i = 0; i < spec->kctls.used; i++) |
| 2402 | kfree(kctl[i].name); |
| 2403 | } |
| 2404 | snd_array_free(&spec->kctls); |
| 2405 | } |
| 2406 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2407 | static void alc_free_bind_ctls(struct hda_codec *codec) |
| 2408 | { |
| 2409 | struct alc_spec *spec = codec->spec; |
| 2410 | if (spec->bind_ctls.list) { |
| 2411 | struct hda_bind_ctls **ctl = spec->bind_ctls.list; |
| 2412 | int i; |
| 2413 | for (i = 0; i < spec->bind_ctls.used; i++) |
| 2414 | kfree(ctl[i]); |
| 2415 | } |
| 2416 | snd_array_free(&spec->bind_ctls); |
| 2417 | } |
| 2418 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2419 | static void alc_free(struct hda_codec *codec) |
| 2420 | { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2421 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2422 | |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2423 | if (!spec) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2424 | return; |
| 2425 | |
Takashi Iwai | a4e09aa | 2009-12-27 11:22:24 +0100 | [diff] [blame] | 2426 | alc_shutup(codec); |
Takashi Iwai | cd372fb | 2011-03-03 14:40:14 +0100 | [diff] [blame] | 2427 | snd_hda_input_jack_free(codec); |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 2428 | alc_free_kctls(codec); |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2429 | alc_free_bind_ctls(codec); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2430 | kfree(spec); |
Kusanagi Kouichi | 680cd53 | 2009-02-05 00:00:58 +0900 | [diff] [blame] | 2431 | snd_hda_detach_beep_device(codec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2432 | } |
| 2433 | |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 2434 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 2435 | static void alc_power_eapd(struct hda_codec *codec) |
| 2436 | { |
Takashi Iwai | 691f1fc | 2011-04-07 10:31:43 +0200 | [diff] [blame] | 2437 | alc_auto_setup_eapd(codec, false); |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 2438 | } |
| 2439 | |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 2440 | static int alc_suspend(struct hda_codec *codec, pm_message_t state) |
| 2441 | { |
| 2442 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | a4e09aa | 2009-12-27 11:22:24 +0100 | [diff] [blame] | 2443 | alc_shutup(codec); |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 2444 | if (spec && spec->power_hook) |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 2445 | spec->power_hook(codec); |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 2446 | return 0; |
| 2447 | } |
| 2448 | #endif |
| 2449 | |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 2450 | #ifdef CONFIG_PM |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2451 | static int alc_resume(struct hda_codec *codec) |
| 2452 | { |
Takashi Iwai | 1c716153 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 2453 | msleep(150); /* to avoid pop noise */ |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2454 | codec->patch_ops.init(codec); |
| 2455 | snd_hda_codec_resume_amp(codec); |
| 2456 | snd_hda_codec_resume_cache(codec); |
Takashi Iwai | 9e5341b | 2010-09-21 09:57:06 +0200 | [diff] [blame] | 2457 | hda_call_check_power_status(codec, 0x01); |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2458 | return 0; |
| 2459 | } |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2460 | #endif |
| 2461 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2462 | /* |
| 2463 | */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 2464 | static const struct hda_codec_ops alc_patch_ops = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2465 | .build_controls = alc_build_controls, |
| 2466 | .build_pcms = alc_build_pcms, |
| 2467 | .init = alc_init, |
| 2468 | .free = alc_free, |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 2469 | .unsol_event = alc_unsol_event, |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 2470 | #ifdef CONFIG_PM |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2471 | .resume = alc_resume, |
| 2472 | #endif |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 2473 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 2474 | .suspend = alc_suspend, |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 2475 | .check_power_status = alc_check_power_status, |
| 2476 | #endif |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 2477 | .reboot_notify = alc_shutup, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2478 | }; |
| 2479 | |
Kailang Yang | c027ddc | 2010-03-19 11:33:06 +0100 | [diff] [blame] | 2480 | /* replace the codec chip_name with the given string */ |
| 2481 | static int alc_codec_rename(struct hda_codec *codec, const char *name) |
| 2482 | { |
| 2483 | kfree(codec->chip_name); |
| 2484 | codec->chip_name = kstrdup(name, GFP_KERNEL); |
| 2485 | if (!codec->chip_name) { |
| 2486 | alc_free(codec); |
| 2487 | return -ENOMEM; |
| 2488 | } |
| 2489 | return 0; |
| 2490 | } |
| 2491 | |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 2492 | /* |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 2493 | * Rename codecs appropriately from COEF value |
| 2494 | */ |
| 2495 | struct alc_codec_rename_table { |
| 2496 | unsigned int vendor_id; |
| 2497 | unsigned short coef_mask; |
| 2498 | unsigned short coef_bits; |
| 2499 | const char *name; |
| 2500 | }; |
| 2501 | |
| 2502 | static struct alc_codec_rename_table rename_tbl[] = { |
| 2503 | { 0x10ec0269, 0xfff0, 0x3010, "ALC277" }, |
| 2504 | { 0x10ec0269, 0xf0f0, 0x2010, "ALC259" }, |
| 2505 | { 0x10ec0269, 0xf0f0, 0x3010, "ALC258" }, |
| 2506 | { 0x10ec0269, 0x00f0, 0x0010, "ALC269VB" }, |
| 2507 | { 0x10ec0269, 0xffff, 0xa023, "ALC259" }, |
| 2508 | { 0x10ec0269, 0xffff, 0x6023, "ALC281X" }, |
| 2509 | { 0x10ec0269, 0x00f0, 0x0020, "ALC269VC" }, |
| 2510 | { 0x10ec0887, 0x00f0, 0x0030, "ALC887-VD" }, |
| 2511 | { 0x10ec0888, 0x00f0, 0x0030, "ALC888-VD" }, |
| 2512 | { 0x10ec0888, 0xf0f0, 0x3020, "ALC886" }, |
| 2513 | { 0x10ec0899, 0x2000, 0x2000, "ALC899" }, |
| 2514 | { 0x10ec0892, 0xffff, 0x8020, "ALC661" }, |
| 2515 | { 0x10ec0892, 0xffff, 0x8011, "ALC661" }, |
| 2516 | { 0x10ec0892, 0xffff, 0x4011, "ALC656" }, |
| 2517 | { } /* terminator */ |
| 2518 | }; |
| 2519 | |
| 2520 | static int alc_codec_rename_from_preset(struct hda_codec *codec) |
| 2521 | { |
| 2522 | const struct alc_codec_rename_table *p; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 2523 | |
| 2524 | for (p = rename_tbl; p->vendor_id; p++) { |
| 2525 | if (p->vendor_id != codec->vendor_id) |
| 2526 | continue; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 2527 | if ((alc_get_coef0(codec) & p->coef_mask) == p->coef_bits) |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 2528 | return alc_codec_rename(codec, p->name); |
| 2529 | } |
| 2530 | return 0; |
| 2531 | } |
| 2532 | |
| 2533 | /* |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2534 | * Automatic parse of I/O pins from the BIOS configuration |
| 2535 | */ |
| 2536 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2537 | enum { |
| 2538 | ALC_CTL_WIDGET_VOL, |
| 2539 | ALC_CTL_WIDGET_MUTE, |
| 2540 | ALC_CTL_BIND_MUTE, |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2541 | ALC_CTL_BIND_VOL, |
| 2542 | ALC_CTL_BIND_SW, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2543 | }; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 2544 | static const struct snd_kcontrol_new alc_control_templates[] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2545 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), |
| 2546 | HDA_CODEC_MUTE(NULL, 0, 0, 0), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 2547 | HDA_BIND_MUTE(NULL, 0, 0, 0), |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2548 | HDA_BIND_VOL(NULL, 0), |
| 2549 | HDA_BIND_SW(NULL, 0), |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2550 | }; |
| 2551 | |
| 2552 | /* add dynamic controls */ |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2553 | 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] | 2554 | int cidx, unsigned long val) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2555 | { |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2556 | struct snd_kcontrol_new *knew; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2557 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 2558 | knew = alc_kcontrol_new(spec); |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 2559 | if (!knew) |
| 2560 | return -ENOMEM; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 2561 | *knew = alc_control_templates[type]; |
Paulo Marques | 543537b | 2005-06-23 00:09:02 -0700 | [diff] [blame] | 2562 | knew->name = kstrdup(name, GFP_KERNEL); |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2563 | if (!knew->name) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2564 | return -ENOMEM; |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2565 | knew->index = cidx; |
Jaroslav Kysela | 4d02d1b | 2009-11-12 10:15:48 +0100 | [diff] [blame] | 2566 | if (get_amp_nid_(val)) |
Jaroslav Kysela | 5e26dfd | 2009-12-10 13:57:01 +0100 | [diff] [blame] | 2567 | knew->subdevice = HDA_SUBDEV_AMP_FLAG; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2568 | knew->private_value = val; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2569 | return 0; |
| 2570 | } |
| 2571 | |
Takashi Iwai | 0afe5f8 | 2009-10-02 09:20:00 +0200 | [diff] [blame] | 2572 | static int add_control_with_pfx(struct alc_spec *spec, int type, |
| 2573 | const char *pfx, const char *dir, |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2574 | const char *sfx, int cidx, unsigned long val) |
Takashi Iwai | 0afe5f8 | 2009-10-02 09:20:00 +0200 | [diff] [blame] | 2575 | { |
| 2576 | char name[32]; |
| 2577 | snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx); |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2578 | return add_control(spec, type, name, cidx, val); |
Takashi Iwai | 0afe5f8 | 2009-10-02 09:20:00 +0200 | [diff] [blame] | 2579 | } |
| 2580 | |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2581 | #define add_pb_vol_ctrl(spec, type, pfx, val) \ |
| 2582 | add_control_with_pfx(spec, type, pfx, "Playback", "Volume", 0, val) |
| 2583 | #define add_pb_sw_ctrl(spec, type, pfx, val) \ |
| 2584 | add_control_with_pfx(spec, type, pfx, "Playback", "Switch", 0, val) |
| 2585 | #define __add_pb_vol_ctrl(spec, type, pfx, cidx, val) \ |
| 2586 | add_control_with_pfx(spec, type, pfx, "Playback", "Volume", cidx, val) |
| 2587 | #define __add_pb_sw_ctrl(spec, type, pfx, cidx, val) \ |
| 2588 | add_control_with_pfx(spec, type, pfx, "Playback", "Switch", cidx, val) |
Takashi Iwai | 0afe5f8 | 2009-10-02 09:20:00 +0200 | [diff] [blame] | 2589 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2590 | static const char * const channel_name[4] = { |
| 2591 | "Front", "Surround", "CLFE", "Side" |
| 2592 | }; |
| 2593 | |
Takashi Iwai | 6843ca1 | 2011-06-24 11:03:58 +0200 | [diff] [blame] | 2594 | static const char *alc_get_line_out_pfx(struct alc_spec *spec, int ch, |
| 2595 | bool can_be_master, int *index) |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2596 | { |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 2597 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2598 | |
Takashi Iwai | 6843ca1 | 2011-06-24 11:03:58 +0200 | [diff] [blame] | 2599 | *index = 0; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 2600 | if (cfg->line_outs == 1 && !spec->multi_ios && |
| 2601 | !cfg->hp_outs && !cfg->speaker_outs && can_be_master) |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2602 | return "Master"; |
| 2603 | |
| 2604 | switch (cfg->line_out_type) { |
| 2605 | case AUTO_PIN_SPEAKER_OUT: |
David Henningsson | ebbeb3d | 2011-03-04 14:08:30 +0100 | [diff] [blame] | 2606 | if (cfg->line_outs == 1) |
| 2607 | return "Speaker"; |
| 2608 | break; |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2609 | case AUTO_PIN_HP_OUT: |
Takashi Iwai | 6843ca1 | 2011-06-24 11:03:58 +0200 | [diff] [blame] | 2610 | /* for multi-io case, only the primary out */ |
| 2611 | if (ch && spec->multi_ios) |
| 2612 | break; |
| 2613 | *index = ch; |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2614 | return "Headphone"; |
| 2615 | default: |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 2616 | if (cfg->line_outs == 1 && !spec->multi_ios) |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2617 | return "PCM"; |
| 2618 | break; |
| 2619 | } |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2620 | if (snd_BUG_ON(ch >= ARRAY_SIZE(channel_name))) |
| 2621 | return "PCM"; |
| 2622 | |
| 2623 | return channel_name[ch]; |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2624 | } |
| 2625 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2626 | /* create input playback/capture controls for the given pin */ |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2627 | static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2628 | const char *ctlname, int ctlidx, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2629 | int idx, hda_nid_t mix_nid) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2630 | { |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2631 | int err; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2632 | |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2633 | err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname, ctlidx, |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2634 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); |
| 2635 | if (err < 0) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2636 | return err; |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2637 | err = __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname, ctlidx, |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2638 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); |
| 2639 | if (err < 0) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2640 | return err; |
| 2641 | return 0; |
| 2642 | } |
| 2643 | |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2644 | 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] | 2645 | { |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2646 | unsigned int pincap = snd_hda_query_pin_caps(codec, nid); |
| 2647 | return (pincap & AC_PINCAP_IN) != 0; |
| 2648 | } |
| 2649 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 2650 | /* Parse the codec tree and retrieve ADCs and corresponding capsrc MUXs */ |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2651 | static int alc_auto_fill_adc_caps(struct hda_codec *codec) |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2652 | { |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2653 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2654 | hda_nid_t nid; |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2655 | hda_nid_t *adc_nids = spec->private_adc_nids; |
| 2656 | hda_nid_t *cap_nids = spec->private_capsrc_nids; |
| 2657 | int max_nums = ARRAY_SIZE(spec->private_adc_nids); |
| 2658 | bool indep_capsrc = false; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2659 | int i, nums = 0; |
| 2660 | |
| 2661 | nid = codec->start_nid; |
| 2662 | for (i = 0; i < codec->num_nodes; i++, nid++) { |
| 2663 | hda_nid_t src; |
| 2664 | const hda_nid_t *list; |
| 2665 | unsigned int caps = get_wcaps(codec, nid); |
| 2666 | int type = get_wcaps_type(caps); |
| 2667 | |
| 2668 | if (type != AC_WID_AUD_IN || (caps & AC_WCAP_DIGITAL)) |
| 2669 | continue; |
| 2670 | adc_nids[nums] = nid; |
| 2671 | cap_nids[nums] = nid; |
| 2672 | src = nid; |
| 2673 | for (;;) { |
| 2674 | int n; |
| 2675 | type = get_wcaps_type(get_wcaps(codec, src)); |
| 2676 | if (type == AC_WID_PIN) |
| 2677 | break; |
| 2678 | if (type == AC_WID_AUD_SEL) { |
| 2679 | cap_nids[nums] = src; |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2680 | indep_capsrc = true; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2681 | break; |
| 2682 | } |
| 2683 | n = snd_hda_get_conn_list(codec, src, &list); |
| 2684 | if (n > 1) { |
| 2685 | cap_nids[nums] = src; |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2686 | indep_capsrc = true; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2687 | break; |
| 2688 | } else if (n != 1) |
| 2689 | break; |
| 2690 | src = *list; |
| 2691 | } |
| 2692 | if (++nums >= max_nums) |
| 2693 | break; |
| 2694 | } |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2695 | spec->adc_nids = spec->private_adc_nids; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2696 | spec->capsrc_nids = spec->private_capsrc_nids; |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2697 | spec->num_adc_nids = nums; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2698 | return nums; |
| 2699 | } |
| 2700 | |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2701 | /* create playback/capture controls for input pins */ |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2702 | static int alc_auto_create_input_ctls(struct hda_codec *codec) |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2703 | { |
| 2704 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2705 | const struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2706 | hda_nid_t mixer = spec->mixer_nid; |
Herton Ronaldo Krzesinski | 61b9b9b | 2009-01-28 09:16:33 -0200 | [diff] [blame] | 2707 | struct hda_input_mux *imux = &spec->private_imux[0]; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2708 | int num_adcs; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2709 | int i, c, err, idx, type_idx = 0; |
David Henningsson | 5322bf2 | 2011-01-05 11:03:56 +0100 | [diff] [blame] | 2710 | const char *prev_label = NULL; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2711 | |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2712 | num_adcs = alc_auto_fill_adc_caps(codec); |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2713 | if (num_adcs < 0) |
| 2714 | return 0; |
| 2715 | |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2716 | for (i = 0; i < cfg->num_inputs; i++) { |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2717 | hda_nid_t pin; |
Takashi Iwai | 10a20af | 2010-09-09 16:28:02 +0200 | [diff] [blame] | 2718 | const char *label; |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2719 | |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2720 | pin = cfg->inputs[i].pin; |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2721 | if (!alc_is_input_pin(codec, pin)) |
| 2722 | continue; |
| 2723 | |
David Henningsson | 5322bf2 | 2011-01-05 11:03:56 +0100 | [diff] [blame] | 2724 | label = hda_get_autocfg_input_label(codec, cfg, i); |
| 2725 | if (prev_label && !strcmp(label, prev_label)) |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2726 | type_idx++; |
| 2727 | else |
| 2728 | type_idx = 0; |
David Henningsson | 5322bf2 | 2011-01-05 11:03:56 +0100 | [diff] [blame] | 2729 | prev_label = label; |
| 2730 | |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2731 | if (mixer) { |
| 2732 | idx = get_connection_index(codec, mixer, pin); |
| 2733 | if (idx >= 0) { |
| 2734 | err = new_analog_input(spec, pin, |
Takashi Iwai | 10a20af | 2010-09-09 16:28:02 +0200 | [diff] [blame] | 2735 | label, type_idx, |
| 2736 | idx, mixer); |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2737 | if (err < 0) |
| 2738 | return err; |
| 2739 | } |
| 2740 | } |
| 2741 | |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2742 | for (c = 0; c < num_adcs; c++) { |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2743 | hda_nid_t cap = spec->capsrc_nids ? |
| 2744 | spec->capsrc_nids[c] : spec->adc_nids[c]; |
| 2745 | idx = get_connection_index(codec, cap, pin); |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2746 | if (idx >= 0) { |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2747 | spec->imux_pins[imux->num_items] = pin; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2748 | snd_hda_add_imux_item(imux, label, idx, NULL); |
| 2749 | break; |
| 2750 | } |
| 2751 | } |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2752 | } |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2753 | |
| 2754 | spec->num_mux_defs = 1; |
| 2755 | spec->input_mux = imux; |
| 2756 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2757 | return 0; |
| 2758 | } |
| 2759 | |
Takashi Iwai | f6c7e54 | 2008-02-12 18:32:23 +0100 | [diff] [blame] | 2760 | static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid, |
| 2761 | unsigned int pin_type) |
| 2762 | { |
| 2763 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 2764 | pin_type); |
| 2765 | /* unmute pin */ |
Takashi Iwai | 44c0240 | 2011-07-08 15:14:19 +0200 | [diff] [blame] | 2766 | if (nid_has_mute(codec, nid, HDA_OUTPUT)) |
| 2767 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
Takashi Iwai | d260cdf | 2008-02-13 17:19:35 +0100 | [diff] [blame] | 2768 | AMP_OUT_UNMUTE); |
Takashi Iwai | f6c7e54 | 2008-02-12 18:32:23 +0100 | [diff] [blame] | 2769 | } |
| 2770 | |
Takashi Iwai | baba8ee | 2007-04-23 17:17:48 +0200 | [diff] [blame] | 2771 | static int get_pin_type(int line_out_type) |
| 2772 | { |
| 2773 | if (line_out_type == AUTO_PIN_HP_OUT) |
| 2774 | return PIN_HP; |
| 2775 | else |
| 2776 | return PIN_OUT; |
| 2777 | } |
| 2778 | |
Takashi Iwai | 0a7f532 | 2011-07-06 15:15:12 +0200 | [diff] [blame] | 2779 | static void alc_auto_init_analog_input(struct hda_codec *codec) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2780 | { |
| 2781 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2782 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2783 | int i; |
| 2784 | |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2785 | for (i = 0; i < cfg->num_inputs; i++) { |
| 2786 | hda_nid_t nid = cfg->inputs[i].pin; |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2787 | if (alc_is_input_pin(codec, nid)) { |
Takashi Iwai | 30ea098 | 2010-09-16 18:47:56 +0200 | [diff] [blame] | 2788 | alc_set_input_pin(codec, nid, cfg->inputs[i].type); |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 2789 | if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2790 | snd_hda_codec_write(codec, nid, 0, |
| 2791 | AC_VERB_SET_AMP_GAIN_MUTE, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2792 | AMP_OUT_MUTE); |
| 2793 | } |
| 2794 | } |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 2795 | |
| 2796 | /* mute all loopback inputs */ |
| 2797 | if (spec->mixer_nid) { |
| 2798 | int nums = snd_hda_get_conn_list(codec, spec->mixer_nid, NULL); |
| 2799 | for (i = 0; i < nums; i++) |
| 2800 | snd_hda_codec_write(codec, spec->mixer_nid, 0, |
| 2801 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 2802 | AMP_IN_MUTE(i)); |
| 2803 | } |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2804 | } |
| 2805 | |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2806 | /* convert from MIX nid to DAC */ |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2807 | static hda_nid_t alc_auto_mix_to_dac(struct hda_codec *codec, hda_nid_t nid) |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2808 | { |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2809 | hda_nid_t list[5]; |
Takashi Iwai | 1304ac8 | 2011-04-06 15:16:21 +0200 | [diff] [blame] | 2810 | int i, num; |
| 2811 | |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 2812 | if (get_wcaps_type(get_wcaps(codec, nid)) == AC_WID_AUD_OUT) |
| 2813 | return nid; |
Takashi Iwai | 1304ac8 | 2011-04-06 15:16:21 +0200 | [diff] [blame] | 2814 | num = snd_hda_get_connections(codec, nid, list, ARRAY_SIZE(list)); |
| 2815 | for (i = 0; i < num; i++) { |
| 2816 | if (get_wcaps_type(get_wcaps(codec, list[i])) == AC_WID_AUD_OUT) |
| 2817 | return list[i]; |
| 2818 | } |
| 2819 | return 0; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2820 | } |
| 2821 | |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2822 | /* go down to the selector widget before the mixer */ |
| 2823 | static hda_nid_t alc_go_down_to_selector(struct hda_codec *codec, hda_nid_t pin) |
| 2824 | { |
| 2825 | hda_nid_t srcs[5]; |
| 2826 | int num = snd_hda_get_connections(codec, pin, srcs, |
| 2827 | ARRAY_SIZE(srcs)); |
| 2828 | if (num != 1 || |
| 2829 | get_wcaps_type(get_wcaps(codec, srcs[0])) != AC_WID_AUD_SEL) |
| 2830 | return pin; |
| 2831 | return srcs[0]; |
| 2832 | } |
| 2833 | |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2834 | /* get MIX nid connected to the given pin targeted to DAC */ |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2835 | static hda_nid_t alc_auto_dac_to_mix(struct hda_codec *codec, hda_nid_t pin, |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2836 | hda_nid_t dac) |
| 2837 | { |
David Henningsson | cc1c452 | 2010-11-24 14:17:47 +0100 | [diff] [blame] | 2838 | hda_nid_t mix[5]; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2839 | int i, num; |
| 2840 | |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2841 | pin = alc_go_down_to_selector(codec, pin); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2842 | num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix)); |
| 2843 | for (i = 0; i < num; i++) { |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2844 | if (alc_auto_mix_to_dac(codec, mix[i]) == dac) |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2845 | return mix[i]; |
| 2846 | } |
| 2847 | return 0; |
| 2848 | } |
| 2849 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 2850 | /* select the connection from pin to DAC if needed */ |
| 2851 | static int alc_auto_select_dac(struct hda_codec *codec, hda_nid_t pin, |
| 2852 | hda_nid_t dac) |
| 2853 | { |
| 2854 | hda_nid_t mix[5]; |
| 2855 | int i, num; |
| 2856 | |
| 2857 | pin = alc_go_down_to_selector(codec, pin); |
| 2858 | num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix)); |
| 2859 | if (num < 2) |
| 2860 | return 0; |
| 2861 | for (i = 0; i < num; i++) { |
| 2862 | if (alc_auto_mix_to_dac(codec, mix[i]) == dac) { |
| 2863 | snd_hda_codec_update_cache(codec, pin, 0, |
| 2864 | AC_VERB_SET_CONNECT_SEL, i); |
| 2865 | return 0; |
| 2866 | } |
| 2867 | } |
| 2868 | return 0; |
| 2869 | } |
| 2870 | |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2871 | /* look for an empty DAC slot */ |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2872 | static hda_nid_t alc_auto_look_for_dac(struct hda_codec *codec, hda_nid_t pin) |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2873 | { |
| 2874 | struct alc_spec *spec = codec->spec; |
| 2875 | hda_nid_t srcs[5]; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 2876 | int i, num; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2877 | |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2878 | pin = alc_go_down_to_selector(codec, pin); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2879 | num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs)); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2880 | for (i = 0; i < num; i++) { |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2881 | hda_nid_t nid = alc_auto_mix_to_dac(codec, srcs[i]); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2882 | if (!nid) |
| 2883 | continue; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 2884 | if (found_in_nid_list(nid, spec->multiout.dac_nids, |
| 2885 | spec->multiout.num_dacs)) |
| 2886 | continue; |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 2887 | if (found_in_nid_list(nid, spec->multiout.hp_out_nid, |
| 2888 | ARRAY_SIZE(spec->multiout.hp_out_nid))) |
| 2889 | continue; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 2890 | if (found_in_nid_list(nid, spec->multiout.extra_out_nid, |
| 2891 | ARRAY_SIZE(spec->multiout.extra_out_nid))) |
| 2892 | continue; |
| 2893 | return nid; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2894 | } |
| 2895 | return 0; |
| 2896 | } |
| 2897 | |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 2898 | static hda_nid_t get_dac_if_single(struct hda_codec *codec, hda_nid_t pin) |
| 2899 | { |
| 2900 | hda_nid_t sel = alc_go_down_to_selector(codec, pin); |
| 2901 | if (snd_hda_get_conn_list(codec, sel, NULL) == 1) |
| 2902 | return alc_auto_look_for_dac(codec, pin); |
| 2903 | return 0; |
| 2904 | } |
| 2905 | |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 2906 | static int alc_auto_fill_extra_dacs(struct hda_codec *codec, int num_outs, |
| 2907 | const hda_nid_t *pins, hda_nid_t *dacs) |
| 2908 | { |
| 2909 | int i; |
| 2910 | |
| 2911 | if (num_outs && !dacs[0]) { |
| 2912 | dacs[0] = alc_auto_look_for_dac(codec, pins[0]); |
| 2913 | if (!dacs[0]) |
| 2914 | return 0; |
| 2915 | } |
| 2916 | |
| 2917 | for (i = 1; i < num_outs; i++) |
| 2918 | dacs[i] = get_dac_if_single(codec, pins[i]); |
| 2919 | for (i = 1; i < num_outs; i++) { |
| 2920 | if (!dacs[i]) |
| 2921 | dacs[i] = alc_auto_look_for_dac(codec, pins[i]); |
| 2922 | } |
| 2923 | return 0; |
| 2924 | } |
| 2925 | |
| 2926 | static int alc_auto_fill_multi_ios(struct hda_codec *codec, |
| 2927 | unsigned int location); |
| 2928 | |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2929 | /* fill in the dac_nids table from the parsed pin configuration */ |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 2930 | static int alc_auto_fill_dac_nids(struct hda_codec *codec) |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2931 | { |
| 2932 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | cb053a8 | 2011-06-27 11:32:07 +0200 | [diff] [blame] | 2933 | const struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | 350434e | 2011-06-30 21:29:12 +0200 | [diff] [blame] | 2934 | bool redone = false; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2935 | int i; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2936 | |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 2937 | again: |
Takashi Iwai | 8f398ae | 2011-07-23 18:57:11 +0200 | [diff] [blame] | 2938 | /* set num_dacs once to full for alc_auto_look_for_dac() */ |
| 2939 | spec->multiout.num_dacs = cfg->line_outs; |
Takashi Iwai | e23832a | 2011-08-23 18:16:56 +0200 | [diff] [blame] | 2940 | spec->multiout.hp_out_nid[0] = 0; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 2941 | spec->multiout.extra_out_nid[0] = 0; |
| 2942 | memset(spec->private_dac_nids, 0, sizeof(spec->private_dac_nids)); |
| 2943 | spec->multiout.dac_nids = spec->private_dac_nids; |
| 2944 | |
| 2945 | /* fill hard-wired DACs first */ |
| 2946 | if (!redone) { |
| 2947 | for (i = 0; i < cfg->line_outs; i++) |
| 2948 | spec->private_dac_nids[i] = |
| 2949 | get_dac_if_single(codec, cfg->line_out_pins[i]); |
| 2950 | if (cfg->hp_outs) |
Takashi Iwai | e23832a | 2011-08-23 18:16:56 +0200 | [diff] [blame] | 2951 | spec->multiout.hp_out_nid[0] = |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 2952 | get_dac_if_single(codec, cfg->hp_pins[0]); |
| 2953 | if (cfg->speaker_outs) |
| 2954 | spec->multiout.extra_out_nid[0] = |
| 2955 | get_dac_if_single(codec, cfg->speaker_pins[0]); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2956 | } |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 2957 | |
| 2958 | for (i = 0; i < cfg->line_outs; i++) { |
| 2959 | hda_nid_t pin = cfg->line_out_pins[i]; |
| 2960 | if (spec->private_dac_nids[i]) |
| 2961 | continue; |
| 2962 | spec->private_dac_nids[i] = alc_auto_look_for_dac(codec, pin); |
| 2963 | if (!spec->private_dac_nids[i] && !redone) { |
| 2964 | /* if we can't find primary DACs, re-probe without |
| 2965 | * checking the hard-wired DACs |
| 2966 | */ |
| 2967 | redone = true; |
| 2968 | goto again; |
| 2969 | } |
| 2970 | } |
| 2971 | |
Takashi Iwai | 8f398ae | 2011-07-23 18:57:11 +0200 | [diff] [blame] | 2972 | /* re-count num_dacs and squash invalid entries */ |
| 2973 | spec->multiout.num_dacs = 0; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 2974 | for (i = 0; i < cfg->line_outs; i++) { |
| 2975 | if (spec->private_dac_nids[i]) |
| 2976 | spec->multiout.num_dacs++; |
| 2977 | else |
| 2978 | memmove(spec->private_dac_nids + i, |
| 2979 | spec->private_dac_nids + i + 1, |
| 2980 | sizeof(hda_nid_t) * (cfg->line_outs - i - 1)); |
| 2981 | } |
| 2982 | |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 2983 | if (cfg->line_outs == 1 && cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { |
| 2984 | /* try to fill multi-io first */ |
| 2985 | unsigned int location, defcfg; |
| 2986 | int num_pins; |
Takashi Iwai | bb8bf4d | 2011-07-06 13:07:54 +0200 | [diff] [blame] | 2987 | |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 2988 | defcfg = snd_hda_codec_get_pincfg(codec, cfg->line_out_pins[0]); |
| 2989 | location = get_defcfg_location(defcfg); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2990 | |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 2991 | num_pins = alc_auto_fill_multi_ios(codec, location); |
| 2992 | if (num_pins > 0) { |
| 2993 | spec->multi_ios = num_pins; |
| 2994 | spec->ext_channel_count = 2; |
| 2995 | spec->multiout.num_dacs = num_pins + 1; |
| 2996 | } |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2997 | } |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 2998 | |
Takashi Iwai | 716eef0 | 2011-10-21 15:07:42 +0200 | [diff] [blame] | 2999 | if (cfg->line_out_type != AUTO_PIN_HP_OUT) |
| 3000 | alc_auto_fill_extra_dacs(codec, cfg->hp_outs, cfg->hp_pins, |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3001 | spec->multiout.hp_out_nid); |
Takashi Iwai | 716eef0 | 2011-10-21 15:07:42 +0200 | [diff] [blame] | 3002 | if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) |
| 3003 | alc_auto_fill_extra_dacs(codec, cfg->speaker_outs, cfg->speaker_pins, |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3004 | spec->multiout.extra_out_nid); |
| 3005 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3006 | return 0; |
| 3007 | } |
| 3008 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3009 | static int alc_auto_add_vol_ctl(struct hda_codec *codec, |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3010 | const char *pfx, int cidx, |
| 3011 | hda_nid_t nid, unsigned int chs) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3012 | { |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3013 | if (!nid) |
| 3014 | return 0; |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3015 | return __add_pb_vol_ctrl(codec->spec, ALC_CTL_WIDGET_VOL, pfx, cidx, |
| 3016 | HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT)); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3017 | } |
| 3018 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3019 | #define alc_auto_add_stereo_vol(codec, pfx, cidx, nid) \ |
| 3020 | alc_auto_add_vol_ctl(codec, pfx, cidx, nid, 3) |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3021 | |
| 3022 | /* create a mute-switch for the given mixer widget; |
| 3023 | * if it has multiple sources (e.g. DAC and loopback), create a bind-mute |
| 3024 | */ |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3025 | static int alc_auto_add_sw_ctl(struct hda_codec *codec, |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3026 | const char *pfx, int cidx, |
| 3027 | hda_nid_t nid, unsigned int chs) |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3028 | { |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3029 | int wid_type; |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3030 | int type; |
| 3031 | unsigned long val; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3032 | if (!nid) |
| 3033 | return 0; |
| 3034 | wid_type = get_wcaps_type(get_wcaps(codec, nid)); |
| 3035 | if (wid_type == AC_WID_PIN || wid_type == AC_WID_AUD_OUT) { |
| 3036 | type = ALC_CTL_WIDGET_MUTE; |
| 3037 | val = HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT); |
| 3038 | } else if (snd_hda_get_conn_list(codec, nid, NULL) == 1) { |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3039 | type = ALC_CTL_WIDGET_MUTE; |
| 3040 | val = HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT); |
| 3041 | } else { |
| 3042 | type = ALC_CTL_BIND_MUTE; |
| 3043 | val = HDA_COMPOSE_AMP_VAL(nid, chs, 2, HDA_INPUT); |
| 3044 | } |
| 3045 | return __add_pb_sw_ctrl(codec->spec, type, pfx, cidx, val); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3046 | } |
| 3047 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3048 | #define alc_auto_add_stereo_sw(codec, pfx, cidx, nid) \ |
| 3049 | alc_auto_add_sw_ctl(codec, pfx, cidx, nid, 3) |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3050 | |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3051 | static hda_nid_t alc_look_for_out_mute_nid(struct hda_codec *codec, |
| 3052 | hda_nid_t pin, hda_nid_t dac) |
| 3053 | { |
| 3054 | hda_nid_t mix = alc_auto_dac_to_mix(codec, pin, dac); |
| 3055 | if (nid_has_mute(codec, pin, HDA_OUTPUT)) |
| 3056 | return pin; |
| 3057 | else if (mix && nid_has_mute(codec, mix, HDA_INPUT)) |
| 3058 | return mix; |
| 3059 | else if (nid_has_mute(codec, dac, HDA_OUTPUT)) |
| 3060 | return dac; |
| 3061 | return 0; |
| 3062 | } |
| 3063 | |
| 3064 | static hda_nid_t alc_look_for_out_vol_nid(struct hda_codec *codec, |
| 3065 | hda_nid_t pin, hda_nid_t dac) |
| 3066 | { |
| 3067 | hda_nid_t mix = alc_auto_dac_to_mix(codec, pin, dac); |
| 3068 | if (nid_has_volume(codec, dac, HDA_OUTPUT)) |
| 3069 | return dac; |
| 3070 | else if (nid_has_volume(codec, mix, HDA_OUTPUT)) |
| 3071 | return mix; |
| 3072 | else if (nid_has_volume(codec, pin, HDA_OUTPUT)) |
| 3073 | return pin; |
| 3074 | return 0; |
| 3075 | } |
| 3076 | |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3077 | /* add playback controls from the parsed DAC table */ |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3078 | static int alc_auto_create_multi_out_ctls(struct hda_codec *codec, |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3079 | const struct auto_pin_cfg *cfg) |
| 3080 | { |
| 3081 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3082 | int i, err, noutputs; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3083 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3084 | noutputs = cfg->line_outs; |
| 3085 | if (spec->multi_ios > 0) |
| 3086 | noutputs += spec->multi_ios; |
| 3087 | |
| 3088 | for (i = 0; i < noutputs; i++) { |
Takashi Iwai | 6843ca1 | 2011-06-24 11:03:58 +0200 | [diff] [blame] | 3089 | const char *name; |
| 3090 | int index; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3091 | hda_nid_t dac, pin; |
| 3092 | hda_nid_t sw, vol; |
| 3093 | |
| 3094 | dac = spec->multiout.dac_nids[i]; |
| 3095 | if (!dac) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3096 | continue; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3097 | if (i >= cfg->line_outs) |
| 3098 | pin = spec->multi_io[i - 1].pin; |
| 3099 | else |
| 3100 | pin = cfg->line_out_pins[i]; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3101 | |
| 3102 | sw = alc_look_for_out_mute_nid(codec, pin, dac); |
| 3103 | vol = alc_look_for_out_vol_nid(codec, pin, dac); |
Takashi Iwai | 6843ca1 | 2011-06-24 11:03:58 +0200 | [diff] [blame] | 3104 | name = alc_get_line_out_pfx(spec, i, true, &index); |
Takashi Iwai | 9c4e84d | 2011-08-24 17:27:52 +0200 | [diff] [blame] | 3105 | if (!name || !strcmp(name, "CLFE")) { |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3106 | /* Center/LFE */ |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3107 | err = alc_auto_add_vol_ctl(codec, "Center", 0, vol, 1); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3108 | if (err < 0) |
| 3109 | return err; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3110 | err = alc_auto_add_vol_ctl(codec, "LFE", 0, vol, 2); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3111 | if (err < 0) |
| 3112 | return err; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3113 | err = alc_auto_add_sw_ctl(codec, "Center", 0, sw, 1); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3114 | if (err < 0) |
| 3115 | return err; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3116 | err = alc_auto_add_sw_ctl(codec, "LFE", 0, sw, 2); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3117 | if (err < 0) |
| 3118 | return err; |
| 3119 | } else { |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3120 | err = alc_auto_add_stereo_vol(codec, name, index, vol); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3121 | if (err < 0) |
| 3122 | return err; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3123 | err = alc_auto_add_stereo_sw(codec, name, index, sw); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3124 | if (err < 0) |
| 3125 | return err; |
| 3126 | } |
| 3127 | } |
| 3128 | return 0; |
| 3129 | } |
| 3130 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3131 | static int alc_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin, |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3132 | hda_nid_t dac, const char *pfx) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3133 | { |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3134 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3135 | hda_nid_t sw, vol; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3136 | int err; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3137 | |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3138 | if (!dac) { |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3139 | /* the corresponding DAC is already occupied */ |
| 3140 | if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP)) |
| 3141 | return 0; /* no way */ |
| 3142 | /* create a switch only */ |
Takashi Iwai | 0afe5f8 | 2009-10-02 09:20:00 +0200 | [diff] [blame] | 3143 | return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3144 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT)); |
| 3145 | } |
| 3146 | |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3147 | sw = alc_look_for_out_mute_nid(codec, pin, dac); |
| 3148 | vol = alc_look_for_out_vol_nid(codec, pin, dac); |
| 3149 | err = alc_auto_add_stereo_vol(codec, pfx, 0, vol); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3150 | if (err < 0) |
Takashi Iwai | 24fb917 | 2008-09-02 14:48:20 +0200 | [diff] [blame] | 3151 | return err; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3152 | err = alc_auto_add_stereo_sw(codec, pfx, 0, sw); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3153 | if (err < 0) |
| 3154 | return err; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3155 | return 0; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3156 | } |
| 3157 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3158 | static struct hda_bind_ctls *new_bind_ctl(struct hda_codec *codec, |
| 3159 | unsigned int nums, |
| 3160 | struct hda_ctl_ops *ops) |
| 3161 | { |
| 3162 | struct alc_spec *spec = codec->spec; |
| 3163 | struct hda_bind_ctls **ctlp, *ctl; |
| 3164 | snd_array_init(&spec->bind_ctls, sizeof(ctl), 8); |
| 3165 | ctlp = snd_array_new(&spec->bind_ctls); |
| 3166 | if (!ctlp) |
| 3167 | return NULL; |
| 3168 | ctl = kzalloc(sizeof(*ctl) + sizeof(long) * (nums + 1), GFP_KERNEL); |
| 3169 | *ctlp = ctl; |
| 3170 | if (ctl) |
| 3171 | ctl->ops = ops; |
| 3172 | return ctl; |
| 3173 | } |
| 3174 | |
| 3175 | /* add playback controls for speaker and HP outputs */ |
| 3176 | static int alc_auto_create_extra_outs(struct hda_codec *codec, int num_pins, |
| 3177 | const hda_nid_t *pins, |
| 3178 | const hda_nid_t *dacs, |
| 3179 | const char *pfx) |
| 3180 | { |
| 3181 | struct alc_spec *spec = codec->spec; |
| 3182 | struct hda_bind_ctls *ctl; |
| 3183 | char name[32]; |
| 3184 | int i, n, err; |
| 3185 | |
| 3186 | if (!num_pins || !pins[0]) |
| 3187 | return 0; |
| 3188 | |
| 3189 | if (num_pins == 1) |
| 3190 | return alc_auto_create_extra_out(codec, *pins, *dacs, pfx); |
| 3191 | |
| 3192 | if (dacs[num_pins - 1]) { |
| 3193 | /* OK, we have a multi-output system with individual volumes */ |
| 3194 | for (i = 0; i < num_pins; i++) { |
| 3195 | snprintf(name, sizeof(name), "%s %s", |
| 3196 | pfx, channel_name[i]); |
| 3197 | err = alc_auto_create_extra_out(codec, pins[i], dacs[i], |
| 3198 | name); |
| 3199 | if (err < 0) |
| 3200 | return err; |
| 3201 | } |
| 3202 | return 0; |
| 3203 | } |
| 3204 | |
| 3205 | /* Let's create a bind-controls */ |
| 3206 | ctl = new_bind_ctl(codec, num_pins, &snd_hda_bind_sw); |
| 3207 | if (!ctl) |
| 3208 | return -ENOMEM; |
| 3209 | n = 0; |
| 3210 | for (i = 0; i < num_pins; i++) { |
| 3211 | if (get_wcaps(codec, pins[i]) & AC_WCAP_OUT_AMP) |
| 3212 | ctl->values[n++] = |
| 3213 | HDA_COMPOSE_AMP_VAL(pins[i], 3, 0, HDA_OUTPUT); |
| 3214 | } |
| 3215 | if (n) { |
| 3216 | snprintf(name, sizeof(name), "%s Playback Switch", pfx); |
| 3217 | err = add_control(spec, ALC_CTL_BIND_SW, name, 0, (long)ctl); |
| 3218 | if (err < 0) |
| 3219 | return err; |
| 3220 | } |
| 3221 | |
| 3222 | ctl = new_bind_ctl(codec, num_pins, &snd_hda_bind_vol); |
| 3223 | if (!ctl) |
| 3224 | return -ENOMEM; |
| 3225 | n = 0; |
| 3226 | for (i = 0; i < num_pins; i++) { |
| 3227 | hda_nid_t vol; |
| 3228 | if (!pins[i] || !dacs[i]) |
| 3229 | continue; |
| 3230 | vol = alc_look_for_out_vol_nid(codec, pins[i], dacs[i]); |
| 3231 | if (vol) |
| 3232 | ctl->values[n++] = |
| 3233 | HDA_COMPOSE_AMP_VAL(vol, 3, 0, HDA_OUTPUT); |
| 3234 | } |
| 3235 | if (n) { |
| 3236 | snprintf(name, sizeof(name), "%s Playback Volume", pfx); |
| 3237 | err = add_control(spec, ALC_CTL_BIND_VOL, name, 0, (long)ctl); |
| 3238 | if (err < 0) |
| 3239 | return err; |
| 3240 | } |
| 3241 | return 0; |
| 3242 | } |
| 3243 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3244 | static int alc_auto_create_hp_out(struct hda_codec *codec) |
| 3245 | { |
| 3246 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | e23832a | 2011-08-23 18:16:56 +0200 | [diff] [blame] | 3247 | return alc_auto_create_extra_outs(codec, spec->autocfg.hp_outs, |
| 3248 | spec->autocfg.hp_pins, |
| 3249 | spec->multiout.hp_out_nid, |
| 3250 | "Headphone"); |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3251 | } |
| 3252 | |
| 3253 | static int alc_auto_create_speaker_out(struct hda_codec *codec) |
| 3254 | { |
| 3255 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3256 | return alc_auto_create_extra_outs(codec, spec->autocfg.speaker_outs, |
| 3257 | spec->autocfg.speaker_pins, |
| 3258 | spec->multiout.extra_out_nid, |
| 3259 | "Speaker"); |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3260 | } |
| 3261 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3262 | static void alc_auto_set_output_and_unmute(struct hda_codec *codec, |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3263 | hda_nid_t pin, int pin_type, |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3264 | hda_nid_t dac) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3265 | { |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3266 | int i, num; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3267 | hda_nid_t nid, mix = 0; |
Takashi Iwai | ce503f3 | 2010-07-30 10:37:29 +0200 | [diff] [blame] | 3268 | hda_nid_t srcs[HDA_MAX_CONNECTIONS]; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3269 | |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3270 | alc_set_pin_output(codec, pin, pin_type); |
| 3271 | nid = alc_go_down_to_selector(codec, pin); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3272 | num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs)); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3273 | for (i = 0; i < num; i++) { |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 3274 | if (alc_auto_mix_to_dac(codec, srcs[i]) != dac) |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3275 | continue; |
Takashi Iwai | cd51155 | 2011-07-06 13:10:42 +0200 | [diff] [blame] | 3276 | mix = srcs[i]; |
| 3277 | break; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3278 | } |
Takashi Iwai | cd51155 | 2011-07-06 13:10:42 +0200 | [diff] [blame] | 3279 | if (!mix) |
| 3280 | return; |
| 3281 | |
| 3282 | /* need the manual connection? */ |
| 3283 | if (num > 1) |
| 3284 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i); |
| 3285 | /* unmute mixer widget inputs */ |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3286 | if (nid_has_mute(codec, mix, HDA_INPUT)) { |
| 3287 | snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
Takashi Iwai | cd51155 | 2011-07-06 13:10:42 +0200 | [diff] [blame] | 3288 | AMP_IN_UNMUTE(0)); |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3289 | snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
Takashi Iwai | cd51155 | 2011-07-06 13:10:42 +0200 | [diff] [blame] | 3290 | AMP_IN_UNMUTE(1)); |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3291 | } |
Takashi Iwai | cd51155 | 2011-07-06 13:10:42 +0200 | [diff] [blame] | 3292 | /* initialize volume */ |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3293 | nid = alc_look_for_out_vol_nid(codec, pin, dac); |
| 3294 | if (nid) |
| 3295 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
| 3296 | AMP_OUT_ZERO); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3297 | } |
| 3298 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3299 | static void alc_auto_init_multi_out(struct hda_codec *codec) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3300 | { |
| 3301 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3302 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3303 | int i; |
| 3304 | |
| 3305 | for (i = 0; i <= HDA_SIDE; i++) { |
| 3306 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
| 3307 | if (nid) |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3308 | alc_auto_set_output_and_unmute(codec, nid, pin_type, |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3309 | spec->multiout.dac_nids[i]); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3310 | } |
| 3311 | } |
| 3312 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3313 | static void alc_auto_init_extra_out(struct hda_codec *codec) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3314 | { |
| 3315 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 8cd0775 | 2011-08-23 15:16:22 +0200 | [diff] [blame] | 3316 | int i; |
Takashi Iwai | 675c1aa | 2011-08-23 12:36:28 +0200 | [diff] [blame] | 3317 | hda_nid_t pin, dac; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3318 | |
David Henningsson | 636030e | 2011-10-12 19:26:03 +0200 | [diff] [blame] | 3319 | for (i = 0; i < spec->autocfg.hp_outs; i++) { |
Takashi Iwai | 716eef0 | 2011-10-21 15:07:42 +0200 | [diff] [blame] | 3320 | if (spec->autocfg.line_out_type == AUTO_PIN_HP_OUT) |
| 3321 | break; |
Takashi Iwai | e23832a | 2011-08-23 18:16:56 +0200 | [diff] [blame] | 3322 | pin = spec->autocfg.hp_pins[i]; |
| 3323 | if (!pin) |
| 3324 | break; |
| 3325 | dac = spec->multiout.hp_out_nid[i]; |
| 3326 | if (!dac) { |
| 3327 | if (i > 0 && spec->multiout.hp_out_nid[0]) |
| 3328 | dac = spec->multiout.hp_out_nid[0]; |
| 3329 | else |
| 3330 | dac = spec->multiout.dac_nids[0]; |
| 3331 | } |
Takashi Iwai | 675c1aa | 2011-08-23 12:36:28 +0200 | [diff] [blame] | 3332 | alc_auto_set_output_and_unmute(codec, pin, PIN_HP, dac); |
| 3333 | } |
Takashi Iwai | 8cd0775 | 2011-08-23 15:16:22 +0200 | [diff] [blame] | 3334 | for (i = 0; i < spec->autocfg.speaker_outs; i++) { |
Takashi Iwai | 716eef0 | 2011-10-21 15:07:42 +0200 | [diff] [blame] | 3335 | if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT) |
| 3336 | break; |
Takashi Iwai | 8cd0775 | 2011-08-23 15:16:22 +0200 | [diff] [blame] | 3337 | pin = spec->autocfg.speaker_pins[i]; |
| 3338 | if (!pin) |
| 3339 | break; |
| 3340 | dac = spec->multiout.extra_out_nid[i]; |
| 3341 | if (!dac) { |
| 3342 | if (i > 0 && spec->multiout.extra_out_nid[0]) |
| 3343 | dac = spec->multiout.extra_out_nid[0]; |
| 3344 | else |
| 3345 | dac = spec->multiout.dac_nids[0]; |
| 3346 | } |
Takashi Iwai | 675c1aa | 2011-08-23 12:36:28 +0200 | [diff] [blame] | 3347 | alc_auto_set_output_and_unmute(codec, pin, PIN_OUT, dac); |
| 3348 | } |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3349 | } |
| 3350 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3351 | /* |
| 3352 | * multi-io helper |
| 3353 | */ |
| 3354 | static int alc_auto_fill_multi_ios(struct hda_codec *codec, |
| 3355 | unsigned int location) |
| 3356 | { |
| 3357 | struct alc_spec *spec = codec->spec; |
| 3358 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3359 | hda_nid_t prime_dac = spec->private_dac_nids[0]; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3360 | int type, i, num_pins = 0; |
| 3361 | |
| 3362 | for (type = AUTO_PIN_LINE_IN; type >= AUTO_PIN_MIC; type--) { |
| 3363 | for (i = 0; i < cfg->num_inputs; i++) { |
| 3364 | hda_nid_t nid = cfg->inputs[i].pin; |
| 3365 | hda_nid_t dac; |
| 3366 | unsigned int defcfg, caps; |
| 3367 | if (cfg->inputs[i].type != type) |
| 3368 | continue; |
| 3369 | defcfg = snd_hda_codec_get_pincfg(codec, nid); |
| 3370 | if (get_defcfg_connect(defcfg) != AC_JACK_PORT_COMPLEX) |
| 3371 | continue; |
| 3372 | if (location && get_defcfg_location(defcfg) != location) |
| 3373 | continue; |
| 3374 | caps = snd_hda_query_pin_caps(codec, nid); |
| 3375 | if (!(caps & AC_PINCAP_OUT)) |
| 3376 | continue; |
| 3377 | dac = alc_auto_look_for_dac(codec, nid); |
| 3378 | if (!dac) |
| 3379 | continue; |
| 3380 | spec->multi_io[num_pins].pin = nid; |
| 3381 | spec->multi_io[num_pins].dac = dac; |
| 3382 | num_pins++; |
Takashi Iwai | dda1441 | 2011-05-02 11:29:30 +0200 | [diff] [blame] | 3383 | spec->private_dac_nids[spec->multiout.num_dacs++] = dac; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3384 | } |
| 3385 | } |
| 3386 | spec->multiout.num_dacs = 1; |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3387 | if (num_pins < 2) { |
| 3388 | /* clear up again */ |
| 3389 | memset(spec->private_dac_nids, 0, |
| 3390 | sizeof(spec->private_dac_nids)); |
| 3391 | spec->private_dac_nids[0] = prime_dac; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3392 | return 0; |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3393 | } |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3394 | return num_pins; |
| 3395 | } |
| 3396 | |
| 3397 | static int alc_auto_ch_mode_info(struct snd_kcontrol *kcontrol, |
| 3398 | struct snd_ctl_elem_info *uinfo) |
| 3399 | { |
| 3400 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3401 | struct alc_spec *spec = codec->spec; |
| 3402 | |
| 3403 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
| 3404 | uinfo->count = 1; |
| 3405 | uinfo->value.enumerated.items = spec->multi_ios + 1; |
| 3406 | if (uinfo->value.enumerated.item > spec->multi_ios) |
| 3407 | uinfo->value.enumerated.item = spec->multi_ios; |
| 3408 | sprintf(uinfo->value.enumerated.name, "%dch", |
| 3409 | (uinfo->value.enumerated.item + 1) * 2); |
| 3410 | return 0; |
| 3411 | } |
| 3412 | |
| 3413 | static int alc_auto_ch_mode_get(struct snd_kcontrol *kcontrol, |
| 3414 | struct snd_ctl_elem_value *ucontrol) |
| 3415 | { |
| 3416 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3417 | struct alc_spec *spec = codec->spec; |
| 3418 | ucontrol->value.enumerated.item[0] = (spec->ext_channel_count - 1) / 2; |
| 3419 | return 0; |
| 3420 | } |
| 3421 | |
| 3422 | static int alc_set_multi_io(struct hda_codec *codec, int idx, bool output) |
| 3423 | { |
| 3424 | struct alc_spec *spec = codec->spec; |
| 3425 | hda_nid_t nid = spec->multi_io[idx].pin; |
| 3426 | |
| 3427 | if (!spec->multi_io[idx].ctl_in) |
| 3428 | spec->multi_io[idx].ctl_in = |
| 3429 | snd_hda_codec_read(codec, nid, 0, |
| 3430 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 3431 | if (output) { |
| 3432 | snd_hda_codec_update_cache(codec, nid, 0, |
| 3433 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 3434 | PIN_OUT); |
| 3435 | if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) |
| 3436 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, |
| 3437 | HDA_AMP_MUTE, 0); |
| 3438 | alc_auto_select_dac(codec, nid, spec->multi_io[idx].dac); |
| 3439 | } else { |
| 3440 | if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) |
| 3441 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, |
| 3442 | HDA_AMP_MUTE, HDA_AMP_MUTE); |
| 3443 | snd_hda_codec_update_cache(codec, nid, 0, |
| 3444 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 3445 | spec->multi_io[idx].ctl_in); |
| 3446 | } |
| 3447 | return 0; |
| 3448 | } |
| 3449 | |
| 3450 | static int alc_auto_ch_mode_put(struct snd_kcontrol *kcontrol, |
| 3451 | struct snd_ctl_elem_value *ucontrol) |
| 3452 | { |
| 3453 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3454 | struct alc_spec *spec = codec->spec; |
| 3455 | int i, ch; |
| 3456 | |
| 3457 | ch = ucontrol->value.enumerated.item[0]; |
| 3458 | if (ch < 0 || ch > spec->multi_ios) |
| 3459 | return -EINVAL; |
| 3460 | if (ch == (spec->ext_channel_count - 1) / 2) |
| 3461 | return 0; |
| 3462 | spec->ext_channel_count = (ch + 1) * 2; |
| 3463 | for (i = 0; i < spec->multi_ios; i++) |
| 3464 | alc_set_multi_io(codec, i, i < ch); |
| 3465 | spec->multiout.max_channels = spec->ext_channel_count; |
Takashi Iwai | 7b1655f | 2011-07-14 15:31:21 +0200 | [diff] [blame] | 3466 | if (spec->need_dac_fix && !spec->const_channel_count) |
| 3467 | spec->multiout.num_dacs = spec->multiout.max_channels / 2; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3468 | return 1; |
| 3469 | } |
| 3470 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 3471 | static const struct snd_kcontrol_new alc_auto_channel_mode_enum = { |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3472 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 3473 | .name = "Channel Mode", |
| 3474 | .info = alc_auto_ch_mode_info, |
| 3475 | .get = alc_auto_ch_mode_get, |
| 3476 | .put = alc_auto_ch_mode_put, |
| 3477 | }; |
| 3478 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3479 | static int alc_auto_add_multi_channel_mode(struct hda_codec *codec) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3480 | { |
| 3481 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3482 | |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3483 | if (spec->multi_ios > 0) { |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3484 | struct snd_kcontrol_new *knew; |
| 3485 | |
| 3486 | knew = alc_kcontrol_new(spec); |
| 3487 | if (!knew) |
| 3488 | return -ENOMEM; |
| 3489 | *knew = alc_auto_channel_mode_enum; |
| 3490 | knew->name = kstrdup("Channel Mode", GFP_KERNEL); |
| 3491 | if (!knew->name) |
| 3492 | return -ENOMEM; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3493 | } |
| 3494 | return 0; |
| 3495 | } |
| 3496 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 3497 | /* filter out invalid adc_nids (and capsrc_nids) that don't give all |
| 3498 | * active input pins |
| 3499 | */ |
| 3500 | static void alc_remove_invalid_adc_nids(struct hda_codec *codec) |
| 3501 | { |
| 3502 | struct alc_spec *spec = codec->spec; |
| 3503 | const struct hda_input_mux *imux; |
| 3504 | hda_nid_t adc_nids[ARRAY_SIZE(spec->private_adc_nids)]; |
| 3505 | hda_nid_t capsrc_nids[ARRAY_SIZE(spec->private_adc_nids)]; |
| 3506 | int i, n, nums; |
| 3507 | |
| 3508 | imux = spec->input_mux; |
| 3509 | if (!imux) |
| 3510 | return; |
| 3511 | if (spec->dyn_adc_switch) |
| 3512 | return; |
| 3513 | |
| 3514 | nums = 0; |
| 3515 | for (n = 0; n < spec->num_adc_nids; n++) { |
| 3516 | hda_nid_t cap = spec->private_capsrc_nids[n]; |
| 3517 | int num_conns = snd_hda_get_conn_list(codec, cap, NULL); |
| 3518 | for (i = 0; i < imux->num_items; i++) { |
| 3519 | hda_nid_t pin = spec->imux_pins[i]; |
| 3520 | if (pin) { |
| 3521 | if (get_connection_index(codec, cap, pin) < 0) |
| 3522 | break; |
| 3523 | } else if (num_conns <= imux->items[i].index) |
| 3524 | break; |
| 3525 | } |
| 3526 | if (i >= imux->num_items) { |
| 3527 | adc_nids[nums] = spec->private_adc_nids[n]; |
| 3528 | capsrc_nids[nums++] = cap; |
| 3529 | } |
| 3530 | } |
| 3531 | if (!nums) { |
| 3532 | /* check whether ADC-switch is possible */ |
| 3533 | if (!alc_check_dyn_adc_switch(codec)) { |
| 3534 | printk(KERN_WARNING "hda_codec: %s: no valid ADC found;" |
| 3535 | " using fallback 0x%x\n", |
| 3536 | codec->chip_name, spec->private_adc_nids[0]); |
| 3537 | spec->num_adc_nids = 1; |
| 3538 | spec->auto_mic = 0; |
| 3539 | return; |
| 3540 | } |
| 3541 | } else if (nums != spec->num_adc_nids) { |
| 3542 | memcpy(spec->private_adc_nids, adc_nids, |
| 3543 | nums * sizeof(hda_nid_t)); |
| 3544 | memcpy(spec->private_capsrc_nids, capsrc_nids, |
| 3545 | nums * sizeof(hda_nid_t)); |
| 3546 | spec->num_adc_nids = nums; |
| 3547 | } |
| 3548 | |
| 3549 | if (spec->auto_mic) |
| 3550 | alc_auto_mic_check_imux(codec); /* check auto-mic setups */ |
| 3551 | else if (spec->input_mux->num_items == 1) |
| 3552 | spec->num_adc_nids = 1; /* reduce to a single ADC */ |
| 3553 | } |
| 3554 | |
| 3555 | /* |
| 3556 | * initialize ADC paths |
| 3557 | */ |
| 3558 | static void alc_auto_init_adc(struct hda_codec *codec, int adc_idx) |
| 3559 | { |
| 3560 | struct alc_spec *spec = codec->spec; |
| 3561 | hda_nid_t nid; |
| 3562 | |
| 3563 | nid = spec->adc_nids[adc_idx]; |
| 3564 | /* mute ADC */ |
Takashi Iwai | 44c0240 | 2011-07-08 15:14:19 +0200 | [diff] [blame] | 3565 | if (nid_has_mute(codec, nid, HDA_INPUT)) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 3566 | snd_hda_codec_write(codec, nid, 0, |
| 3567 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 3568 | AMP_IN_MUTE(0)); |
| 3569 | return; |
| 3570 | } |
| 3571 | if (!spec->capsrc_nids) |
| 3572 | return; |
| 3573 | nid = spec->capsrc_nids[adc_idx]; |
Takashi Iwai | 44c0240 | 2011-07-08 15:14:19 +0200 | [diff] [blame] | 3574 | if (nid_has_mute(codec, nid, HDA_OUTPUT)) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 3575 | snd_hda_codec_write(codec, nid, 0, |
| 3576 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 3577 | AMP_OUT_MUTE); |
| 3578 | } |
| 3579 | |
| 3580 | static void alc_auto_init_input_src(struct hda_codec *codec) |
| 3581 | { |
| 3582 | struct alc_spec *spec = codec->spec; |
| 3583 | int c, nums; |
| 3584 | |
| 3585 | for (c = 0; c < spec->num_adc_nids; c++) |
| 3586 | alc_auto_init_adc(codec, c); |
| 3587 | if (spec->dyn_adc_switch) |
| 3588 | nums = 1; |
| 3589 | else |
| 3590 | nums = spec->num_adc_nids; |
| 3591 | for (c = 0; c < nums; c++) |
| 3592 | alc_mux_select(codec, 0, spec->cur_mux[c], true); |
| 3593 | } |
| 3594 | |
| 3595 | /* add mic boosts if needed */ |
| 3596 | static int alc_auto_add_mic_boost(struct hda_codec *codec) |
| 3597 | { |
| 3598 | struct alc_spec *spec = codec->spec; |
| 3599 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 3600 | int i, err; |
| 3601 | int type_idx = 0; |
| 3602 | hda_nid_t nid; |
| 3603 | const char *prev_label = NULL; |
| 3604 | |
| 3605 | for (i = 0; i < cfg->num_inputs; i++) { |
| 3606 | if (cfg->inputs[i].type > AUTO_PIN_MIC) |
| 3607 | break; |
| 3608 | nid = cfg->inputs[i].pin; |
| 3609 | if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) { |
| 3610 | const char *label; |
| 3611 | char boost_label[32]; |
| 3612 | |
| 3613 | label = hda_get_autocfg_input_label(codec, cfg, i); |
| 3614 | if (prev_label && !strcmp(label, prev_label)) |
| 3615 | type_idx++; |
| 3616 | else |
| 3617 | type_idx = 0; |
| 3618 | prev_label = label; |
| 3619 | |
| 3620 | snprintf(boost_label, sizeof(boost_label), |
| 3621 | "%s Boost Volume", label); |
| 3622 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
| 3623 | boost_label, type_idx, |
| 3624 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); |
| 3625 | if (err < 0) |
| 3626 | return err; |
| 3627 | } |
| 3628 | } |
| 3629 | return 0; |
| 3630 | } |
| 3631 | |
| 3632 | /* select or unmute the given capsrc route */ |
| 3633 | static void select_or_unmute_capsrc(struct hda_codec *codec, hda_nid_t cap, |
| 3634 | int idx) |
| 3635 | { |
| 3636 | if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) { |
| 3637 | snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx, |
| 3638 | HDA_AMP_MUTE, 0); |
| 3639 | } else if (snd_hda_get_conn_list(codec, cap, NULL) > 1) { |
| 3640 | snd_hda_codec_write_cache(codec, cap, 0, |
| 3641 | AC_VERB_SET_CONNECT_SEL, idx); |
| 3642 | } |
| 3643 | } |
| 3644 | |
| 3645 | /* set the default connection to that pin */ |
| 3646 | static int init_capsrc_for_pin(struct hda_codec *codec, hda_nid_t pin) |
| 3647 | { |
| 3648 | struct alc_spec *spec = codec->spec; |
| 3649 | int i; |
| 3650 | |
| 3651 | if (!pin) |
| 3652 | return 0; |
| 3653 | for (i = 0; i < spec->num_adc_nids; i++) { |
| 3654 | hda_nid_t cap = spec->capsrc_nids ? |
| 3655 | spec->capsrc_nids[i] : spec->adc_nids[i]; |
| 3656 | int idx; |
| 3657 | |
| 3658 | idx = get_connection_index(codec, cap, pin); |
| 3659 | if (idx < 0) |
| 3660 | continue; |
| 3661 | select_or_unmute_capsrc(codec, cap, idx); |
| 3662 | return i; /* return the found index */ |
| 3663 | } |
| 3664 | return -1; /* not found */ |
| 3665 | } |
| 3666 | |
| 3667 | /* initialize some special cases for input sources */ |
| 3668 | static void alc_init_special_input_src(struct hda_codec *codec) |
| 3669 | { |
| 3670 | struct alc_spec *spec = codec->spec; |
| 3671 | int i; |
| 3672 | |
| 3673 | for (i = 0; i < spec->autocfg.num_inputs; i++) |
| 3674 | init_capsrc_for_pin(codec, spec->autocfg.inputs[i].pin); |
| 3675 | } |
| 3676 | |
| 3677 | /* assign appropriate capture mixers */ |
| 3678 | static void set_capture_mixer(struct hda_codec *codec) |
| 3679 | { |
| 3680 | struct alc_spec *spec = codec->spec; |
| 3681 | static const struct snd_kcontrol_new *caps[2][3] = { |
| 3682 | { alc_capture_mixer_nosrc1, |
| 3683 | alc_capture_mixer_nosrc2, |
| 3684 | alc_capture_mixer_nosrc3 }, |
| 3685 | { alc_capture_mixer1, |
| 3686 | alc_capture_mixer2, |
| 3687 | alc_capture_mixer3 }, |
| 3688 | }; |
| 3689 | |
| 3690 | /* check whether either of ADC or MUX has a volume control */ |
Takashi Iwai | 44c0240 | 2011-07-08 15:14:19 +0200 | [diff] [blame] | 3691 | if (!nid_has_volume(codec, spec->adc_nids[0], HDA_INPUT)) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 3692 | if (!spec->capsrc_nids) |
| 3693 | return; /* no volume */ |
Takashi Iwai | 44c0240 | 2011-07-08 15:14:19 +0200 | [diff] [blame] | 3694 | if (!nid_has_volume(codec, spec->capsrc_nids[0], HDA_OUTPUT)) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 3695 | return; /* no volume in capsrc, too */ |
| 3696 | spec->vol_in_capsrc = 1; |
| 3697 | } |
| 3698 | |
| 3699 | if (spec->num_adc_nids > 0) { |
| 3700 | int mux = 0; |
| 3701 | int num_adcs = 0; |
| 3702 | |
| 3703 | if (spec->input_mux && spec->input_mux->num_items > 1) |
| 3704 | mux = 1; |
| 3705 | if (spec->auto_mic) { |
| 3706 | num_adcs = 1; |
| 3707 | mux = 0; |
| 3708 | } else if (spec->dyn_adc_switch) |
| 3709 | num_adcs = 1; |
| 3710 | if (!num_adcs) { |
| 3711 | if (spec->num_adc_nids > 3) |
| 3712 | spec->num_adc_nids = 3; |
| 3713 | else if (!spec->num_adc_nids) |
| 3714 | return; |
| 3715 | num_adcs = spec->num_adc_nids; |
| 3716 | } |
| 3717 | spec->cap_mixer = caps[mux][num_adcs - 1]; |
| 3718 | } |
| 3719 | } |
| 3720 | |
| 3721 | /* |
Takashi Iwai | e477062 | 2011-07-08 11:11:35 +0200 | [diff] [blame] | 3722 | * standard auto-parser initializations |
| 3723 | */ |
| 3724 | static void alc_auto_init_std(struct hda_codec *codec) |
| 3725 | { |
| 3726 | struct alc_spec *spec = codec->spec; |
| 3727 | alc_auto_init_multi_out(codec); |
| 3728 | alc_auto_init_extra_out(codec); |
| 3729 | alc_auto_init_analog_input(codec); |
| 3730 | alc_auto_init_input_src(codec); |
| 3731 | alc_auto_init_digital(codec); |
| 3732 | if (spec->unsol_event) |
| 3733 | alc_inithook(codec); |
| 3734 | } |
| 3735 | |
| 3736 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 3737 | * Digital-beep handlers |
| 3738 | */ |
| 3739 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
| 3740 | #define set_beep_amp(spec, nid, idx, dir) \ |
| 3741 | ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir)) |
| 3742 | |
| 3743 | static const struct snd_pci_quirk beep_white_list[] = { |
| 3744 | SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1), |
| 3745 | SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1), |
| 3746 | SND_PCI_QUIRK(0x1043, 0x831a, "EeePC", 1), |
| 3747 | SND_PCI_QUIRK(0x1043, 0x834a, "EeePC", 1), |
| 3748 | SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1), |
| 3749 | {} |
| 3750 | }; |
| 3751 | |
| 3752 | static inline int has_cdefine_beep(struct hda_codec *codec) |
| 3753 | { |
| 3754 | struct alc_spec *spec = codec->spec; |
| 3755 | const struct snd_pci_quirk *q; |
| 3756 | q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list); |
| 3757 | if (q) |
| 3758 | return q->value; |
| 3759 | return spec->cdefine.enable_pcbeep; |
| 3760 | } |
| 3761 | #else |
| 3762 | #define set_beep_amp(spec, nid, idx, dir) /* NOP */ |
| 3763 | #define has_cdefine_beep(codec) 0 |
| 3764 | #endif |
| 3765 | |
| 3766 | /* parse the BIOS configuration and set up the alc_spec */ |
| 3767 | /* return 1 if successful, 0 if the proper config is not found, |
| 3768 | * or a negative error code |
| 3769 | */ |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 3770 | static int alc_parse_auto_config(struct hda_codec *codec, |
| 3771 | const hda_nid_t *ignore_nids, |
| 3772 | const hda_nid_t *ssid_nids) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 3773 | { |
| 3774 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3775 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 3776 | int err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 3777 | |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 3778 | err = snd_hda_parse_pin_defcfg(codec, cfg, ignore_nids, |
| 3779 | spec->parse_flags); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 3780 | if (err < 0) |
| 3781 | return err; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3782 | if (!cfg->line_outs) { |
| 3783 | if (cfg->dig_outs || cfg->dig_in_pin) { |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 3784 | spec->multiout.max_channels = 2; |
| 3785 | spec->no_analog = 1; |
| 3786 | goto dig_only; |
| 3787 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 3788 | return 0; /* can't find valid BIOS pin config */ |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 3789 | } |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3790 | |
Takashi Iwai | 0650367 | 2011-10-06 08:27:19 +0200 | [diff] [blame] | 3791 | if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT && |
| 3792 | cfg->line_outs <= cfg->hp_outs) { |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3793 | /* use HP as primary out */ |
| 3794 | cfg->speaker_outs = cfg->line_outs; |
| 3795 | memcpy(cfg->speaker_pins, cfg->line_out_pins, |
| 3796 | sizeof(cfg->speaker_pins)); |
| 3797 | cfg->line_outs = cfg->hp_outs; |
| 3798 | memcpy(cfg->line_out_pins, cfg->hp_pins, sizeof(cfg->hp_pins)); |
| 3799 | cfg->hp_outs = 0; |
| 3800 | memset(cfg->hp_pins, 0, sizeof(cfg->hp_pins)); |
| 3801 | cfg->line_out_type = AUTO_PIN_HP_OUT; |
| 3802 | } |
| 3803 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 3804 | err = alc_auto_fill_dac_nids(codec); |
| 3805 | if (err < 0) |
| 3806 | return err; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3807 | err = alc_auto_add_multi_channel_mode(codec); |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 3808 | if (err < 0) |
| 3809 | return err; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3810 | err = alc_auto_create_multi_out_ctls(codec, cfg); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 3811 | if (err < 0) |
| 3812 | return err; |
| 3813 | err = alc_auto_create_hp_out(codec); |
| 3814 | if (err < 0) |
| 3815 | return err; |
| 3816 | err = alc_auto_create_speaker_out(codec); |
| 3817 | if (err < 0) |
| 3818 | return err; |
| 3819 | err = alc_auto_create_input_ctls(codec); |
| 3820 | if (err < 0) |
| 3821 | return err; |
| 3822 | |
| 3823 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; |
| 3824 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 3825 | dig_only: |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 3826 | alc_auto_parse_digital(codec); |
| 3827 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 3828 | if (!spec->no_analog) |
| 3829 | alc_remove_invalid_adc_nids(codec); |
| 3830 | |
| 3831 | if (ssid_nids) |
| 3832 | alc_ssid_check(codec, ssid_nids); |
| 3833 | |
| 3834 | if (!spec->no_analog) { |
| 3835 | alc_auto_check_switches(codec); |
| 3836 | err = alc_auto_add_mic_boost(codec); |
| 3837 | if (err < 0) |
| 3838 | return err; |
| 3839 | } |
| 3840 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 3841 | if (spec->kctls.list) |
| 3842 | add_mixer(spec, spec->kctls.list); |
| 3843 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 3844 | return 1; |
| 3845 | } |
| 3846 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 3847 | static int alc880_parse_auto_config(struct hda_codec *codec) |
| 3848 | { |
| 3849 | static const hda_nid_t alc880_ignore[] = { 0x1d, 0 }; |
| 3850 | static const hda_nid_t alc880_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 3851 | return alc_parse_auto_config(codec, alc880_ignore, alc880_ssids); |
| 3852 | } |
| 3853 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 3854 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 3855 | static const struct hda_amp_list alc880_loopbacks[] = { |
| 3856 | { 0x0b, HDA_INPUT, 0 }, |
| 3857 | { 0x0b, HDA_INPUT, 1 }, |
| 3858 | { 0x0b, HDA_INPUT, 2 }, |
| 3859 | { 0x0b, HDA_INPUT, 3 }, |
| 3860 | { 0x0b, HDA_INPUT, 4 }, |
| 3861 | { } /* end */ |
| 3862 | }; |
| 3863 | #endif |
| 3864 | |
| 3865 | /* |
| 3866 | * board setups |
| 3867 | */ |
| 3868 | #ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS |
| 3869 | #define alc_board_config \ |
| 3870 | snd_hda_check_board_config |
| 3871 | #define alc_board_codec_sid_config \ |
| 3872 | snd_hda_check_board_codec_sid_config |
| 3873 | #include "alc_quirks.c" |
| 3874 | #else |
| 3875 | #define alc_board_config(codec, nums, models, tbl) -1 |
| 3876 | #define alc_board_codec_sid_config(codec, nums, models, tbl) -1 |
| 3877 | #define setup_preset(codec, x) /* NOP */ |
| 3878 | #endif |
| 3879 | |
| 3880 | /* |
| 3881 | * OK, here we have finally the patch for ALC880 |
| 3882 | */ |
| 3883 | #ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS |
| 3884 | #include "alc880_quirks.c" |
| 3885 | #endif |
| 3886 | |
| 3887 | static int patch_alc880(struct hda_codec *codec) |
| 3888 | { |
| 3889 | struct alc_spec *spec; |
| 3890 | int board_config; |
| 3891 | int err; |
| 3892 | |
| 3893 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 3894 | if (spec == NULL) |
| 3895 | return -ENOMEM; |
| 3896 | |
| 3897 | codec->spec = spec; |
| 3898 | |
| 3899 | spec->mixer_nid = 0x0b; |
Takashi Iwai | 7b1655f | 2011-07-14 15:31:21 +0200 | [diff] [blame] | 3900 | spec->need_dac_fix = 1; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 3901 | |
| 3902 | board_config = alc_board_config(codec, ALC880_MODEL_LAST, |
| 3903 | alc880_models, alc880_cfg_tbl); |
| 3904 | if (board_config < 0) { |
| 3905 | printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
| 3906 | codec->chip_name); |
| 3907 | board_config = ALC_MODEL_AUTO; |
| 3908 | } |
| 3909 | |
| 3910 | if (board_config == ALC_MODEL_AUTO) { |
| 3911 | /* automatic parse from the BIOS config */ |
| 3912 | err = alc880_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 3913 | if (err < 0) |
| 3914 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 3915 | #ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS |
| 3916 | else if (!err) { |
| 3917 | printk(KERN_INFO |
| 3918 | "hda_codec: Cannot set up configuration " |
| 3919 | "from BIOS. Using 3-stack mode...\n"); |
| 3920 | board_config = ALC880_3ST; |
| 3921 | } |
| 3922 | #endif |
| 3923 | } |
| 3924 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 3925 | if (board_config != ALC_MODEL_AUTO) |
| 3926 | setup_preset(codec, &alc880_presets[board_config]); |
| 3927 | |
Takashi Iwai | 60a6a84 | 2011-07-27 14:01:24 +0200 | [diff] [blame] | 3928 | if (!spec->no_analog && !spec->adc_nids) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 3929 | alc_auto_fill_adc_caps(codec); |
| 3930 | alc_rebuild_imux_for_auto_mic(codec); |
| 3931 | alc_remove_invalid_adc_nids(codec); |
| 3932 | } |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 3933 | |
| 3934 | if (!spec->no_analog && !spec->cap_mixer) |
| 3935 | set_capture_mixer(codec); |
| 3936 | |
| 3937 | if (!spec->no_analog) { |
| 3938 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 3939 | if (err < 0) |
| 3940 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 3941 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
| 3942 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 3943 | |
| 3944 | spec->vmaster_nid = 0x0c; |
| 3945 | |
| 3946 | codec->patch_ops = alc_patch_ops; |
| 3947 | if (board_config == ALC_MODEL_AUTO) |
Takashi Iwai | e477062 | 2011-07-08 11:11:35 +0200 | [diff] [blame] | 3948 | spec->init_hook = alc_auto_init_std; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 3949 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 3950 | if (!spec->loopback.amplist) |
| 3951 | spec->loopback.amplist = alc880_loopbacks; |
| 3952 | #endif |
| 3953 | |
| 3954 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 3955 | |
| 3956 | error: |
| 3957 | alc_free(codec); |
| 3958 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 3959 | } |
| 3960 | |
| 3961 | |
| 3962 | /* |
| 3963 | * ALC260 support |
| 3964 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 3965 | static int alc260_parse_auto_config(struct hda_codec *codec) |
| 3966 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 3967 | static const hda_nid_t alc260_ignore[] = { 0x17, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 3968 | static const hda_nid_t alc260_ssids[] = { 0x10, 0x15, 0x0f, 0 }; |
| 3969 | return alc_parse_auto_config(codec, alc260_ignore, alc260_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 3970 | } |
| 3971 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 3972 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 3973 | static const struct hda_amp_list alc260_loopbacks[] = { |
| 3974 | { 0x07, HDA_INPUT, 0 }, |
| 3975 | { 0x07, HDA_INPUT, 1 }, |
| 3976 | { 0x07, HDA_INPUT, 2 }, |
| 3977 | { 0x07, HDA_INPUT, 3 }, |
| 3978 | { 0x07, HDA_INPUT, 4 }, |
| 3979 | { } /* end */ |
| 3980 | }; |
| 3981 | #endif |
| 3982 | |
| 3983 | /* |
| 3984 | * Pin config fixes |
| 3985 | */ |
| 3986 | enum { |
| 3987 | PINFIX_HP_DC5750, |
| 3988 | }; |
| 3989 | |
| 3990 | static const struct alc_fixup alc260_fixups[] = { |
| 3991 | [PINFIX_HP_DC5750] = { |
| 3992 | .type = ALC_FIXUP_PINS, |
| 3993 | .v.pins = (const struct alc_pincfg[]) { |
| 3994 | { 0x11, 0x90130110 }, /* speaker */ |
| 3995 | { } |
| 3996 | } |
| 3997 | }, |
| 3998 | }; |
| 3999 | |
| 4000 | static const struct snd_pci_quirk alc260_fixup_tbl[] = { |
| 4001 | SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", PINFIX_HP_DC5750), |
| 4002 | {} |
| 4003 | }; |
| 4004 | |
| 4005 | /* |
| 4006 | */ |
| 4007 | #ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS |
| 4008 | #include "alc260_quirks.c" |
| 4009 | #endif |
| 4010 | |
| 4011 | static int patch_alc260(struct hda_codec *codec) |
| 4012 | { |
| 4013 | struct alc_spec *spec; |
| 4014 | int err, board_config; |
| 4015 | |
| 4016 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 4017 | if (spec == NULL) |
| 4018 | return -ENOMEM; |
| 4019 | |
| 4020 | codec->spec = spec; |
| 4021 | |
| 4022 | spec->mixer_nid = 0x07; |
| 4023 | |
| 4024 | board_config = alc_board_config(codec, ALC260_MODEL_LAST, |
| 4025 | alc260_models, alc260_cfg_tbl); |
| 4026 | if (board_config < 0) { |
| 4027 | snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
| 4028 | codec->chip_name); |
| 4029 | board_config = ALC_MODEL_AUTO; |
| 4030 | } |
| 4031 | |
| 4032 | if (board_config == ALC_MODEL_AUTO) { |
| 4033 | alc_pick_fixup(codec, NULL, alc260_fixup_tbl, alc260_fixups); |
| 4034 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
| 4035 | } |
| 4036 | |
| 4037 | if (board_config == ALC_MODEL_AUTO) { |
| 4038 | /* automatic parse from the BIOS config */ |
| 4039 | err = alc260_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 4040 | if (err < 0) |
| 4041 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4042 | #ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS |
| 4043 | else if (!err) { |
| 4044 | printk(KERN_INFO |
| 4045 | "hda_codec: Cannot set up configuration " |
| 4046 | "from BIOS. Using base mode...\n"); |
| 4047 | board_config = ALC260_BASIC; |
| 4048 | } |
| 4049 | #endif |
| 4050 | } |
| 4051 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4052 | if (board_config != ALC_MODEL_AUTO) |
| 4053 | setup_preset(codec, &alc260_presets[board_config]); |
| 4054 | |
Takashi Iwai | 60a6a84 | 2011-07-27 14:01:24 +0200 | [diff] [blame] | 4055 | if (!spec->no_analog && !spec->adc_nids) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4056 | alc_auto_fill_adc_caps(codec); |
| 4057 | alc_rebuild_imux_for_auto_mic(codec); |
| 4058 | alc_remove_invalid_adc_nids(codec); |
| 4059 | } |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4060 | |
| 4061 | if (!spec->no_analog && !spec->cap_mixer) |
| 4062 | set_capture_mixer(codec); |
| 4063 | |
| 4064 | if (!spec->no_analog) { |
| 4065 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 4066 | if (err < 0) |
| 4067 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4068 | set_beep_amp(spec, 0x07, 0x05, HDA_INPUT); |
| 4069 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4070 | |
| 4071 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 4072 | |
| 4073 | spec->vmaster_nid = 0x08; |
| 4074 | |
| 4075 | codec->patch_ops = alc_patch_ops; |
| 4076 | if (board_config == ALC_MODEL_AUTO) |
Takashi Iwai | 8452a98 | 2011-07-08 16:19:48 +0200 | [diff] [blame] | 4077 | spec->init_hook = alc_auto_init_std; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4078 | spec->shutup = alc_eapd_shutup; |
| 4079 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 4080 | if (!spec->loopback.amplist) |
| 4081 | spec->loopback.amplist = alc260_loopbacks; |
| 4082 | #endif |
| 4083 | |
| 4084 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 4085 | |
| 4086 | error: |
| 4087 | alc_free(codec); |
| 4088 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4089 | } |
| 4090 | |
| 4091 | |
| 4092 | /* |
| 4093 | * ALC882/883/885/888/889 support |
| 4094 | * |
| 4095 | * ALC882 is almost identical with ALC880 but has cleaner and more flexible |
| 4096 | * configuration. Each pin widget can choose any input DACs and a mixer. |
| 4097 | * Each ADC is connected from a mixer of all inputs. This makes possible |
| 4098 | * 6-channel independent captures. |
| 4099 | * |
| 4100 | * In addition, an independent DAC for the multi-playback (not used in this |
| 4101 | * driver yet). |
| 4102 | */ |
| 4103 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 4104 | #define alc882_loopbacks alc880_loopbacks |
| 4105 | #endif |
| 4106 | |
| 4107 | /* |
| 4108 | * Pin config fixes |
| 4109 | */ |
| 4110 | enum { |
| 4111 | PINFIX_ABIT_AW9D_MAX, |
| 4112 | PINFIX_LENOVO_Y530, |
| 4113 | PINFIX_PB_M5210, |
| 4114 | PINFIX_ACER_ASPIRE_7736, |
| 4115 | }; |
| 4116 | |
| 4117 | static const struct alc_fixup alc882_fixups[] = { |
| 4118 | [PINFIX_ABIT_AW9D_MAX] = { |
| 4119 | .type = ALC_FIXUP_PINS, |
| 4120 | .v.pins = (const struct alc_pincfg[]) { |
| 4121 | { 0x15, 0x01080104 }, /* side */ |
| 4122 | { 0x16, 0x01011012 }, /* rear */ |
| 4123 | { 0x17, 0x01016011 }, /* clfe */ |
| 4124 | { } |
| 4125 | } |
| 4126 | }, |
| 4127 | [PINFIX_LENOVO_Y530] = { |
| 4128 | .type = ALC_FIXUP_PINS, |
| 4129 | .v.pins = (const struct alc_pincfg[]) { |
| 4130 | { 0x15, 0x99130112 }, /* rear int speakers */ |
| 4131 | { 0x16, 0x99130111 }, /* subwoofer */ |
| 4132 | { } |
| 4133 | } |
| 4134 | }, |
| 4135 | [PINFIX_PB_M5210] = { |
| 4136 | .type = ALC_FIXUP_VERBS, |
| 4137 | .v.verbs = (const struct hda_verb[]) { |
| 4138 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 }, |
| 4139 | {} |
| 4140 | } |
| 4141 | }, |
| 4142 | [PINFIX_ACER_ASPIRE_7736] = { |
| 4143 | .type = ALC_FIXUP_SKU, |
| 4144 | .v.sku = ALC_FIXUP_SKU_IGNORE, |
| 4145 | }, |
| 4146 | }; |
| 4147 | |
| 4148 | static const struct snd_pci_quirk alc882_fixup_tbl[] = { |
| 4149 | SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", PINFIX_PB_M5210), |
| 4150 | SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", PINFIX_LENOVO_Y530), |
| 4151 | SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX), |
| 4152 | SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", PINFIX_ACER_ASPIRE_7736), |
| 4153 | {} |
| 4154 | }; |
| 4155 | |
| 4156 | /* |
| 4157 | * BIOS auto configuration |
| 4158 | */ |
| 4159 | /* almost identical with ALC880 parser... */ |
| 4160 | static int alc882_parse_auto_config(struct hda_codec *codec) |
| 4161 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4162 | static const hda_nid_t alc882_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4163 | static const hda_nid_t alc882_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 4164 | return alc_parse_auto_config(codec, alc882_ignore, alc882_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4165 | } |
| 4166 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4167 | /* |
| 4168 | */ |
| 4169 | #ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS |
| 4170 | #include "alc882_quirks.c" |
| 4171 | #endif |
| 4172 | |
| 4173 | static int patch_alc882(struct hda_codec *codec) |
| 4174 | { |
| 4175 | struct alc_spec *spec; |
| 4176 | int err, board_config; |
| 4177 | |
| 4178 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 4179 | if (spec == NULL) |
| 4180 | return -ENOMEM; |
| 4181 | |
| 4182 | codec->spec = spec; |
| 4183 | |
| 4184 | spec->mixer_nid = 0x0b; |
| 4185 | |
| 4186 | switch (codec->vendor_id) { |
| 4187 | case 0x10ec0882: |
| 4188 | case 0x10ec0885: |
| 4189 | break; |
| 4190 | default: |
| 4191 | /* ALC883 and variants */ |
| 4192 | alc_fix_pll_init(codec, 0x20, 0x0a, 10); |
| 4193 | break; |
| 4194 | } |
| 4195 | |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 4196 | err = alc_codec_rename_from_preset(codec); |
| 4197 | if (err < 0) |
| 4198 | goto error; |
| 4199 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4200 | board_config = alc_board_config(codec, ALC882_MODEL_LAST, |
| 4201 | alc882_models, alc882_cfg_tbl); |
| 4202 | |
| 4203 | if (board_config < 0) |
| 4204 | board_config = alc_board_codec_sid_config(codec, |
| 4205 | ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl); |
| 4206 | |
| 4207 | if (board_config < 0) { |
| 4208 | printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
| 4209 | codec->chip_name); |
| 4210 | board_config = ALC_MODEL_AUTO; |
| 4211 | } |
| 4212 | |
| 4213 | if (board_config == ALC_MODEL_AUTO) { |
| 4214 | alc_pick_fixup(codec, NULL, alc882_fixup_tbl, alc882_fixups); |
| 4215 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
| 4216 | } |
| 4217 | |
| 4218 | alc_auto_parse_customize_define(codec); |
| 4219 | |
| 4220 | if (board_config == ALC_MODEL_AUTO) { |
| 4221 | /* automatic parse from the BIOS config */ |
| 4222 | err = alc882_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 4223 | if (err < 0) |
| 4224 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4225 | #ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS |
| 4226 | else if (!err) { |
| 4227 | printk(KERN_INFO |
| 4228 | "hda_codec: Cannot set up configuration " |
| 4229 | "from BIOS. Using base mode...\n"); |
| 4230 | board_config = ALC882_3ST_DIG; |
| 4231 | } |
| 4232 | #endif |
| 4233 | } |
| 4234 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4235 | if (board_config != ALC_MODEL_AUTO) |
| 4236 | setup_preset(codec, &alc882_presets[board_config]); |
| 4237 | |
Takashi Iwai | 60a6a84 | 2011-07-27 14:01:24 +0200 | [diff] [blame] | 4238 | if (!spec->no_analog && !spec->adc_nids) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4239 | alc_auto_fill_adc_caps(codec); |
| 4240 | alc_rebuild_imux_for_auto_mic(codec); |
| 4241 | alc_remove_invalid_adc_nids(codec); |
| 4242 | } |
| 4243 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4244 | if (!spec->no_analog && !spec->cap_mixer) |
| 4245 | set_capture_mixer(codec); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4246 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4247 | if (!spec->no_analog && has_cdefine_beep(codec)) { |
| 4248 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 4249 | if (err < 0) |
| 4250 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4251 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4252 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4253 | |
| 4254 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 4255 | |
| 4256 | spec->vmaster_nid = 0x0c; |
| 4257 | |
| 4258 | codec->patch_ops = alc_patch_ops; |
| 4259 | if (board_config == ALC_MODEL_AUTO) |
Takashi Iwai | e477062 | 2011-07-08 11:11:35 +0200 | [diff] [blame] | 4260 | spec->init_hook = alc_auto_init_std; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4261 | |
| 4262 | alc_init_jacks(codec); |
| 4263 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 4264 | if (!spec->loopback.amplist) |
| 4265 | spec->loopback.amplist = alc882_loopbacks; |
| 4266 | #endif |
| 4267 | |
| 4268 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 4269 | |
| 4270 | error: |
| 4271 | alc_free(codec); |
| 4272 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4273 | } |
| 4274 | |
| 4275 | |
| 4276 | /* |
| 4277 | * ALC262 support |
| 4278 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4279 | static int alc262_parse_auto_config(struct hda_codec *codec) |
| 4280 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4281 | static const hda_nid_t alc262_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4282 | static const hda_nid_t alc262_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 4283 | return alc_parse_auto_config(codec, alc262_ignore, alc262_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4284 | } |
| 4285 | |
| 4286 | /* |
| 4287 | * Pin config fixes |
| 4288 | */ |
| 4289 | enum { |
| 4290 | PINFIX_FSC_H270, |
| 4291 | PINFIX_HP_Z200, |
| 4292 | }; |
| 4293 | |
| 4294 | static const struct alc_fixup alc262_fixups[] = { |
| 4295 | [PINFIX_FSC_H270] = { |
| 4296 | .type = ALC_FIXUP_PINS, |
| 4297 | .v.pins = (const struct alc_pincfg[]) { |
| 4298 | { 0x14, 0x99130110 }, /* speaker */ |
| 4299 | { 0x15, 0x0221142f }, /* front HP */ |
| 4300 | { 0x1b, 0x0121141f }, /* rear HP */ |
| 4301 | { } |
| 4302 | } |
| 4303 | }, |
| 4304 | [PINFIX_HP_Z200] = { |
| 4305 | .type = ALC_FIXUP_PINS, |
| 4306 | .v.pins = (const struct alc_pincfg[]) { |
| 4307 | { 0x16, 0x99130120 }, /* internal speaker */ |
| 4308 | { } |
| 4309 | } |
| 4310 | }, |
| 4311 | }; |
| 4312 | |
| 4313 | static const struct snd_pci_quirk alc262_fixup_tbl[] = { |
| 4314 | SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200", PINFIX_HP_Z200), |
| 4315 | SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", PINFIX_FSC_H270), |
| 4316 | {} |
| 4317 | }; |
| 4318 | |
| 4319 | |
| 4320 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 4321 | #define alc262_loopbacks alc880_loopbacks |
| 4322 | #endif |
| 4323 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4324 | /* |
| 4325 | */ |
| 4326 | #ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS |
| 4327 | #include "alc262_quirks.c" |
| 4328 | #endif |
| 4329 | |
| 4330 | static int patch_alc262(struct hda_codec *codec) |
| 4331 | { |
| 4332 | struct alc_spec *spec; |
| 4333 | int board_config; |
| 4334 | int err; |
| 4335 | |
| 4336 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 4337 | if (spec == NULL) |
| 4338 | return -ENOMEM; |
| 4339 | |
| 4340 | codec->spec = spec; |
| 4341 | |
| 4342 | spec->mixer_nid = 0x0b; |
| 4343 | |
| 4344 | #if 0 |
| 4345 | /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is |
| 4346 | * under-run |
| 4347 | */ |
| 4348 | { |
| 4349 | int tmp; |
| 4350 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); |
| 4351 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); |
| 4352 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); |
| 4353 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80); |
| 4354 | } |
| 4355 | #endif |
| 4356 | alc_auto_parse_customize_define(codec); |
| 4357 | |
| 4358 | alc_fix_pll_init(codec, 0x20, 0x0a, 10); |
| 4359 | |
| 4360 | board_config = alc_board_config(codec, ALC262_MODEL_LAST, |
| 4361 | alc262_models, alc262_cfg_tbl); |
| 4362 | |
| 4363 | if (board_config < 0) { |
| 4364 | printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
| 4365 | codec->chip_name); |
| 4366 | board_config = ALC_MODEL_AUTO; |
| 4367 | } |
| 4368 | |
| 4369 | if (board_config == ALC_MODEL_AUTO) { |
| 4370 | alc_pick_fixup(codec, NULL, alc262_fixup_tbl, alc262_fixups); |
| 4371 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
| 4372 | } |
| 4373 | |
| 4374 | if (board_config == ALC_MODEL_AUTO) { |
| 4375 | /* automatic parse from the BIOS config */ |
| 4376 | err = alc262_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 4377 | if (err < 0) |
| 4378 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4379 | #ifdef CONFIG_SND_HDA_ENABLE_REALTEK_QUIRKS |
| 4380 | else if (!err) { |
| 4381 | printk(KERN_INFO |
| 4382 | "hda_codec: Cannot set up configuration " |
| 4383 | "from BIOS. Using base mode...\n"); |
| 4384 | board_config = ALC262_BASIC; |
| 4385 | } |
| 4386 | #endif |
| 4387 | } |
| 4388 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4389 | if (board_config != ALC_MODEL_AUTO) |
| 4390 | setup_preset(codec, &alc262_presets[board_config]); |
| 4391 | |
Takashi Iwai | 60a6a84 | 2011-07-27 14:01:24 +0200 | [diff] [blame] | 4392 | if (!spec->no_analog && !spec->adc_nids) { |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4393 | alc_auto_fill_adc_caps(codec); |
| 4394 | alc_rebuild_imux_for_auto_mic(codec); |
| 4395 | alc_remove_invalid_adc_nids(codec); |
| 4396 | } |
| 4397 | |
| 4398 | if (!spec->no_analog && !spec->cap_mixer) |
| 4399 | set_capture_mixer(codec); |
| 4400 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4401 | if (!spec->no_analog && has_cdefine_beep(codec)) { |
| 4402 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 4403 | if (err < 0) |
| 4404 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4405 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4406 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4407 | |
| 4408 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 4409 | |
| 4410 | spec->vmaster_nid = 0x0c; |
| 4411 | |
| 4412 | codec->patch_ops = alc_patch_ops; |
| 4413 | if (board_config == ALC_MODEL_AUTO) |
Takashi Iwai | e477062 | 2011-07-08 11:11:35 +0200 | [diff] [blame] | 4414 | spec->init_hook = alc_auto_init_std; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4415 | spec->shutup = alc_eapd_shutup; |
| 4416 | |
| 4417 | alc_init_jacks(codec); |
| 4418 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 4419 | if (!spec->loopback.amplist) |
| 4420 | spec->loopback.amplist = alc262_loopbacks; |
| 4421 | #endif |
| 4422 | |
| 4423 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 4424 | |
| 4425 | error: |
| 4426 | alc_free(codec); |
| 4427 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4428 | } |
| 4429 | |
| 4430 | /* |
| 4431 | * ALC268 |
| 4432 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4433 | /* bind Beep switches of both NID 0x0f and 0x10 */ |
| 4434 | static const struct hda_bind_ctls alc268_bind_beep_sw = { |
| 4435 | .ops = &snd_hda_bind_sw, |
| 4436 | .values = { |
| 4437 | HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT), |
| 4438 | HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT), |
| 4439 | 0 |
| 4440 | }, |
| 4441 | }; |
| 4442 | |
| 4443 | static const struct snd_kcontrol_new alc268_beep_mixer[] = { |
| 4444 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT), |
| 4445 | HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw), |
| 4446 | { } |
| 4447 | }; |
| 4448 | |
| 4449 | /* set PCBEEP vol = 0, mute connections */ |
| 4450 | static const struct hda_verb alc268_beep_init_verbs[] = { |
| 4451 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 4452 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 4453 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 4454 | { } |
| 4455 | }; |
| 4456 | |
| 4457 | /* |
| 4458 | * BIOS auto configuration |
| 4459 | */ |
| 4460 | static int alc268_parse_auto_config(struct hda_codec *codec) |
| 4461 | { |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4462 | static const hda_nid_t alc268_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4463 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4464 | int err = alc_parse_auto_config(codec, NULL, alc268_ssids); |
| 4465 | if (err > 0) { |
| 4466 | if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d) { |
| 4467 | add_mixer(spec, alc268_beep_mixer); |
| 4468 | add_verb(spec, alc268_beep_init_verbs); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4469 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4470 | } |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4471 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4472 | } |
| 4473 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4474 | /* |
| 4475 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4476 | static int patch_alc268(struct hda_codec *codec) |
| 4477 | { |
| 4478 | struct alc_spec *spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4479 | int i, has_beep, err; |
| 4480 | |
| 4481 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 4482 | if (spec == NULL) |
| 4483 | return -ENOMEM; |
| 4484 | |
| 4485 | codec->spec = spec; |
| 4486 | |
| 4487 | /* ALC268 has no aa-loopback mixer */ |
| 4488 | |
Takashi Iwai | 6ebb805 | 2011-08-16 15:15:40 +0200 | [diff] [blame] | 4489 | /* automatic parse from the BIOS config */ |
| 4490 | err = alc268_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 4491 | if (err < 0) |
| 4492 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4493 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4494 | has_beep = 0; |
| 4495 | for (i = 0; i < spec->num_mixers; i++) { |
| 4496 | if (spec->mixers[i] == alc268_beep_mixer) { |
| 4497 | has_beep = 1; |
| 4498 | break; |
| 4499 | } |
| 4500 | } |
| 4501 | |
| 4502 | if (has_beep) { |
| 4503 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 4504 | if (err < 0) |
| 4505 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4506 | if (!query_amp_caps(codec, 0x1d, HDA_INPUT)) |
| 4507 | /* override the amp caps for beep generator */ |
| 4508 | snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT, |
| 4509 | (0x0c << AC_AMPCAP_OFFSET_SHIFT) | |
| 4510 | (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) | |
| 4511 | (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) | |
| 4512 | (0 << AC_AMPCAP_MUTE_SHIFT)); |
| 4513 | } |
| 4514 | |
Takashi Iwai | 60a6a84 | 2011-07-27 14:01:24 +0200 | [diff] [blame] | 4515 | if (!spec->no_analog && !spec->adc_nids) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4516 | alc_auto_fill_adc_caps(codec); |
| 4517 | alc_rebuild_imux_for_auto_mic(codec); |
| 4518 | alc_remove_invalid_adc_nids(codec); |
| 4519 | } |
| 4520 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4521 | if (!spec->no_analog && !spec->cap_mixer) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4522 | set_capture_mixer(codec); |
| 4523 | |
| 4524 | spec->vmaster_nid = 0x02; |
| 4525 | |
| 4526 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 6ebb805 | 2011-08-16 15:15:40 +0200 | [diff] [blame] | 4527 | spec->init_hook = alc_auto_init_std; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4528 | spec->shutup = alc_eapd_shutup; |
| 4529 | |
| 4530 | alc_init_jacks(codec); |
| 4531 | |
| 4532 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 4533 | |
| 4534 | error: |
| 4535 | alc_free(codec); |
| 4536 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4537 | } |
| 4538 | |
| 4539 | /* |
| 4540 | * ALC269 |
| 4541 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4542 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 4543 | #define alc269_loopbacks alc880_loopbacks |
| 4544 | #endif |
| 4545 | |
| 4546 | static const struct hda_pcm_stream alc269_44k_pcm_analog_playback = { |
| 4547 | .substreams = 1, |
| 4548 | .channels_min = 2, |
| 4549 | .channels_max = 8, |
| 4550 | .rates = SNDRV_PCM_RATE_44100, /* fixed rate */ |
| 4551 | /* NID is set in alc_build_pcms */ |
| 4552 | .ops = { |
| 4553 | .open = alc_playback_pcm_open, |
| 4554 | .prepare = alc_playback_pcm_prepare, |
| 4555 | .cleanup = alc_playback_pcm_cleanup |
| 4556 | }, |
| 4557 | }; |
| 4558 | |
| 4559 | static const struct hda_pcm_stream alc269_44k_pcm_analog_capture = { |
| 4560 | .substreams = 1, |
| 4561 | .channels_min = 2, |
| 4562 | .channels_max = 2, |
| 4563 | .rates = SNDRV_PCM_RATE_44100, /* fixed rate */ |
| 4564 | /* NID is set in alc_build_pcms */ |
| 4565 | }; |
| 4566 | |
| 4567 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 4568 | static int alc269_mic2_for_mute_led(struct hda_codec *codec) |
| 4569 | { |
| 4570 | switch (codec->subsystem_id) { |
| 4571 | case 0x103c1586: |
| 4572 | return 1; |
| 4573 | } |
| 4574 | return 0; |
| 4575 | } |
| 4576 | |
| 4577 | static int alc269_mic2_mute_check_ps(struct hda_codec *codec, hda_nid_t nid) |
| 4578 | { |
| 4579 | /* update mute-LED according to the speaker mute state */ |
| 4580 | if (nid == 0x01 || nid == 0x14) { |
| 4581 | int pinval; |
| 4582 | if (snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0) & |
| 4583 | HDA_AMP_MUTE) |
| 4584 | pinval = 0x24; |
| 4585 | else |
| 4586 | pinval = 0x20; |
| 4587 | /* mic2 vref pin is used for mute LED control */ |
| 4588 | snd_hda_codec_update_cache(codec, 0x19, 0, |
| 4589 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 4590 | pinval); |
| 4591 | } |
| 4592 | return alc_check_power_status(codec, nid); |
| 4593 | } |
| 4594 | #endif /* CONFIG_SND_HDA_POWER_SAVE */ |
| 4595 | |
| 4596 | /* different alc269-variants */ |
| 4597 | enum { |
| 4598 | ALC269_TYPE_ALC269VA, |
| 4599 | ALC269_TYPE_ALC269VB, |
| 4600 | ALC269_TYPE_ALC269VC, |
| 4601 | }; |
| 4602 | |
| 4603 | /* |
| 4604 | * BIOS auto configuration |
| 4605 | */ |
| 4606 | static int alc269_parse_auto_config(struct hda_codec *codec) |
| 4607 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4608 | static const hda_nid_t alc269_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4609 | static const hda_nid_t alc269_ssids[] = { 0, 0x1b, 0x14, 0x21 }; |
| 4610 | static const hda_nid_t alc269va_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 4611 | struct alc_spec *spec = codec->spec; |
| 4612 | const hda_nid_t *ssids = spec->codec_variant == ALC269_TYPE_ALC269VA ? |
| 4613 | alc269va_ssids : alc269_ssids; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4614 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4615 | return alc_parse_auto_config(codec, alc269_ignore, ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4616 | } |
| 4617 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4618 | static void alc269_toggle_power_output(struct hda_codec *codec, int power_up) |
| 4619 | { |
| 4620 | int val = alc_read_coef_idx(codec, 0x04); |
| 4621 | if (power_up) |
| 4622 | val |= 1 << 11; |
| 4623 | else |
| 4624 | val &= ~(1 << 11); |
| 4625 | alc_write_coef_idx(codec, 0x04, val); |
| 4626 | } |
| 4627 | |
| 4628 | static void alc269_shutup(struct hda_codec *codec) |
| 4629 | { |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 4630 | if ((alc_get_coef0(codec) & 0x00ff) == 0x017) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4631 | alc269_toggle_power_output(codec, 0); |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 4632 | if ((alc_get_coef0(codec) & 0x00ff) == 0x018) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4633 | alc269_toggle_power_output(codec, 0); |
| 4634 | msleep(150); |
| 4635 | } |
| 4636 | } |
| 4637 | |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 4638 | #ifdef CONFIG_PM |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4639 | static int alc269_resume(struct hda_codec *codec) |
| 4640 | { |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 4641 | if ((alc_get_coef0(codec) & 0x00ff) == 0x018) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4642 | alc269_toggle_power_output(codec, 0); |
| 4643 | msleep(150); |
| 4644 | } |
| 4645 | |
| 4646 | codec->patch_ops.init(codec); |
| 4647 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 4648 | if ((alc_get_coef0(codec) & 0x00ff) == 0x017) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4649 | alc269_toggle_power_output(codec, 1); |
| 4650 | msleep(200); |
| 4651 | } |
| 4652 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 4653 | if ((alc_get_coef0(codec) & 0x00ff) == 0x018) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4654 | alc269_toggle_power_output(codec, 1); |
| 4655 | |
| 4656 | snd_hda_codec_resume_amp(codec); |
| 4657 | snd_hda_codec_resume_cache(codec); |
| 4658 | hda_call_check_power_status(codec, 0x01); |
| 4659 | return 0; |
| 4660 | } |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 4661 | #endif /* CONFIG_PM */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4662 | |
| 4663 | static void alc269_fixup_hweq(struct hda_codec *codec, |
| 4664 | const struct alc_fixup *fix, int action) |
| 4665 | { |
| 4666 | int coef; |
| 4667 | |
| 4668 | if (action != ALC_FIXUP_ACT_INIT) |
| 4669 | return; |
| 4670 | coef = alc_read_coef_idx(codec, 0x1e); |
| 4671 | alc_write_coef_idx(codec, 0x1e, coef | 0x80); |
| 4672 | } |
| 4673 | |
| 4674 | static void alc271_fixup_dmic(struct hda_codec *codec, |
| 4675 | const struct alc_fixup *fix, int action) |
| 4676 | { |
| 4677 | static const struct hda_verb verbs[] = { |
| 4678 | {0x20, AC_VERB_SET_COEF_INDEX, 0x0d}, |
| 4679 | {0x20, AC_VERB_SET_PROC_COEF, 0x4000}, |
| 4680 | {} |
| 4681 | }; |
| 4682 | unsigned int cfg; |
| 4683 | |
| 4684 | if (strcmp(codec->chip_name, "ALC271X")) |
| 4685 | return; |
| 4686 | cfg = snd_hda_codec_get_pincfg(codec, 0x12); |
| 4687 | if (get_defcfg_connect(cfg) == AC_JACK_PORT_FIXED) |
| 4688 | snd_hda_sequence_write(codec, verbs); |
| 4689 | } |
| 4690 | |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 4691 | static void alc269_fixup_pcm_44k(struct hda_codec *codec, |
| 4692 | const struct alc_fixup *fix, int action) |
| 4693 | { |
| 4694 | struct alc_spec *spec = codec->spec; |
| 4695 | |
| 4696 | if (action != ALC_FIXUP_ACT_PROBE) |
| 4697 | return; |
| 4698 | |
| 4699 | /* Due to a hardware problem on Lenovo Ideadpad, we need to |
| 4700 | * fix the sample rate of analog I/O to 44.1kHz |
| 4701 | */ |
| 4702 | spec->stream_analog_playback = &alc269_44k_pcm_analog_playback; |
| 4703 | spec->stream_analog_capture = &alc269_44k_pcm_analog_capture; |
| 4704 | } |
| 4705 | |
Takashi Iwai | adabb3e | 2011-08-03 07:48:37 +0200 | [diff] [blame] | 4706 | static void alc269_fixup_stereo_dmic(struct hda_codec *codec, |
| 4707 | const struct alc_fixup *fix, int action) |
| 4708 | { |
| 4709 | int coef; |
| 4710 | |
| 4711 | if (action != ALC_FIXUP_ACT_INIT) |
| 4712 | return; |
| 4713 | /* The digital-mic unit sends PDM (differential signal) instead of |
| 4714 | * the standard PCM, thus you can't record a valid mono stream as is. |
| 4715 | * Below is a workaround specific to ALC269 to control the dmic |
| 4716 | * signal source as mono. |
| 4717 | */ |
| 4718 | coef = alc_read_coef_idx(codec, 0x07); |
| 4719 | alc_write_coef_idx(codec, 0x07, coef | 0x80); |
| 4720 | } |
| 4721 | |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 4722 | static void alc269_quanta_automute(struct hda_codec *codec) |
| 4723 | { |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 4724 | update_outputs(codec); |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 4725 | |
| 4726 | snd_hda_codec_write(codec, 0x20, 0, |
| 4727 | AC_VERB_SET_COEF_INDEX, 0x0c); |
| 4728 | snd_hda_codec_write(codec, 0x20, 0, |
| 4729 | AC_VERB_SET_PROC_COEF, 0x680); |
| 4730 | |
| 4731 | snd_hda_codec_write(codec, 0x20, 0, |
| 4732 | AC_VERB_SET_COEF_INDEX, 0x0c); |
| 4733 | snd_hda_codec_write(codec, 0x20, 0, |
| 4734 | AC_VERB_SET_PROC_COEF, 0x480); |
| 4735 | } |
| 4736 | |
| 4737 | static void alc269_fixup_quanta_mute(struct hda_codec *codec, |
| 4738 | const struct alc_fixup *fix, int action) |
| 4739 | { |
| 4740 | struct alc_spec *spec = codec->spec; |
| 4741 | if (action != ALC_FIXUP_ACT_PROBE) |
| 4742 | return; |
| 4743 | spec->automute_hook = alc269_quanta_automute; |
| 4744 | } |
| 4745 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4746 | enum { |
| 4747 | ALC269_FIXUP_SONY_VAIO, |
| 4748 | ALC275_FIXUP_SONY_VAIO_GPIO2, |
| 4749 | ALC269_FIXUP_DELL_M101Z, |
| 4750 | ALC269_FIXUP_SKU_IGNORE, |
| 4751 | ALC269_FIXUP_ASUS_G73JW, |
| 4752 | ALC269_FIXUP_LENOVO_EAPD, |
| 4753 | ALC275_FIXUP_SONY_HWEQ, |
| 4754 | ALC271_FIXUP_DMIC, |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 4755 | ALC269_FIXUP_PCM_44K, |
Takashi Iwai | adabb3e | 2011-08-03 07:48:37 +0200 | [diff] [blame] | 4756 | ALC269_FIXUP_STEREO_DMIC, |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 4757 | ALC269_FIXUP_QUANTA_MUTE, |
| 4758 | ALC269_FIXUP_LIFEBOOK, |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 4759 | ALC269_FIXUP_AMIC, |
| 4760 | ALC269_FIXUP_DMIC, |
| 4761 | ALC269VB_FIXUP_AMIC, |
| 4762 | ALC269VB_FIXUP_DMIC, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4763 | }; |
| 4764 | |
| 4765 | static const struct alc_fixup alc269_fixups[] = { |
| 4766 | [ALC269_FIXUP_SONY_VAIO] = { |
| 4767 | .type = ALC_FIXUP_VERBS, |
| 4768 | .v.verbs = (const struct hda_verb[]) { |
| 4769 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREFGRD}, |
| 4770 | {} |
| 4771 | } |
| 4772 | }, |
| 4773 | [ALC275_FIXUP_SONY_VAIO_GPIO2] = { |
| 4774 | .type = ALC_FIXUP_VERBS, |
| 4775 | .v.verbs = (const struct hda_verb[]) { |
| 4776 | {0x01, AC_VERB_SET_GPIO_MASK, 0x04}, |
| 4777 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04}, |
| 4778 | {0x01, AC_VERB_SET_GPIO_DATA, 0x00}, |
| 4779 | { } |
| 4780 | }, |
| 4781 | .chained = true, |
| 4782 | .chain_id = ALC269_FIXUP_SONY_VAIO |
| 4783 | }, |
| 4784 | [ALC269_FIXUP_DELL_M101Z] = { |
| 4785 | .type = ALC_FIXUP_VERBS, |
| 4786 | .v.verbs = (const struct hda_verb[]) { |
| 4787 | /* Enables internal speaker */ |
| 4788 | {0x20, AC_VERB_SET_COEF_INDEX, 13}, |
| 4789 | {0x20, AC_VERB_SET_PROC_COEF, 0x4040}, |
| 4790 | {} |
| 4791 | } |
| 4792 | }, |
| 4793 | [ALC269_FIXUP_SKU_IGNORE] = { |
| 4794 | .type = ALC_FIXUP_SKU, |
| 4795 | .v.sku = ALC_FIXUP_SKU_IGNORE, |
| 4796 | }, |
| 4797 | [ALC269_FIXUP_ASUS_G73JW] = { |
| 4798 | .type = ALC_FIXUP_PINS, |
| 4799 | .v.pins = (const struct alc_pincfg[]) { |
| 4800 | { 0x17, 0x99130111 }, /* subwoofer */ |
| 4801 | { } |
| 4802 | } |
| 4803 | }, |
| 4804 | [ALC269_FIXUP_LENOVO_EAPD] = { |
| 4805 | .type = ALC_FIXUP_VERBS, |
| 4806 | .v.verbs = (const struct hda_verb[]) { |
| 4807 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0}, |
| 4808 | {} |
| 4809 | } |
| 4810 | }, |
| 4811 | [ALC275_FIXUP_SONY_HWEQ] = { |
| 4812 | .type = ALC_FIXUP_FUNC, |
| 4813 | .v.func = alc269_fixup_hweq, |
| 4814 | .chained = true, |
| 4815 | .chain_id = ALC275_FIXUP_SONY_VAIO_GPIO2 |
| 4816 | }, |
| 4817 | [ALC271_FIXUP_DMIC] = { |
| 4818 | .type = ALC_FIXUP_FUNC, |
| 4819 | .v.func = alc271_fixup_dmic, |
| 4820 | }, |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 4821 | [ALC269_FIXUP_PCM_44K] = { |
| 4822 | .type = ALC_FIXUP_FUNC, |
| 4823 | .v.func = alc269_fixup_pcm_44k, |
| 4824 | }, |
Takashi Iwai | adabb3e | 2011-08-03 07:48:37 +0200 | [diff] [blame] | 4825 | [ALC269_FIXUP_STEREO_DMIC] = { |
| 4826 | .type = ALC_FIXUP_FUNC, |
| 4827 | .v.func = alc269_fixup_stereo_dmic, |
| 4828 | }, |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 4829 | [ALC269_FIXUP_QUANTA_MUTE] = { |
| 4830 | .type = ALC_FIXUP_FUNC, |
| 4831 | .v.func = alc269_fixup_quanta_mute, |
| 4832 | }, |
| 4833 | [ALC269_FIXUP_LIFEBOOK] = { |
| 4834 | .type = ALC_FIXUP_PINS, |
| 4835 | .v.pins = (const struct alc_pincfg[]) { |
| 4836 | { 0x1a, 0x2101103f }, /* dock line-out */ |
| 4837 | { 0x1b, 0x23a11040 }, /* dock mic-in */ |
| 4838 | { } |
| 4839 | }, |
| 4840 | .chained = true, |
| 4841 | .chain_id = ALC269_FIXUP_QUANTA_MUTE |
| 4842 | }, |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 4843 | [ALC269_FIXUP_AMIC] = { |
| 4844 | .type = ALC_FIXUP_PINS, |
| 4845 | .v.pins = (const struct alc_pincfg[]) { |
| 4846 | { 0x14, 0x99130110 }, /* speaker */ |
| 4847 | { 0x15, 0x0121401f }, /* HP out */ |
| 4848 | { 0x18, 0x01a19c20 }, /* mic */ |
| 4849 | { 0x19, 0x99a3092f }, /* int-mic */ |
| 4850 | { } |
| 4851 | }, |
| 4852 | }, |
| 4853 | [ALC269_FIXUP_DMIC] = { |
| 4854 | .type = ALC_FIXUP_PINS, |
| 4855 | .v.pins = (const struct alc_pincfg[]) { |
| 4856 | { 0x12, 0x99a3092f }, /* int-mic */ |
| 4857 | { 0x14, 0x99130110 }, /* speaker */ |
| 4858 | { 0x15, 0x0121401f }, /* HP out */ |
| 4859 | { 0x18, 0x01a19c20 }, /* mic */ |
| 4860 | { } |
| 4861 | }, |
| 4862 | }, |
| 4863 | [ALC269VB_FIXUP_AMIC] = { |
| 4864 | .type = ALC_FIXUP_PINS, |
| 4865 | .v.pins = (const struct alc_pincfg[]) { |
| 4866 | { 0x14, 0x99130110 }, /* speaker */ |
| 4867 | { 0x18, 0x01a19c20 }, /* mic */ |
| 4868 | { 0x19, 0x99a3092f }, /* int-mic */ |
| 4869 | { 0x21, 0x0121401f }, /* HP out */ |
| 4870 | { } |
| 4871 | }, |
| 4872 | }, |
| 4873 | [ALC269_FIXUP_DMIC] = { |
| 4874 | .type = ALC_FIXUP_PINS, |
| 4875 | .v.pins = (const struct alc_pincfg[]) { |
| 4876 | { 0x12, 0x99a3092f }, /* int-mic */ |
| 4877 | { 0x14, 0x99130110 }, /* speaker */ |
| 4878 | { 0x18, 0x01a19c20 }, /* mic */ |
| 4879 | { 0x21, 0x0121401f }, /* HP out */ |
| 4880 | { } |
| 4881 | }, |
| 4882 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4883 | }; |
| 4884 | |
| 4885 | static const struct snd_pci_quirk alc269_fixup_tbl[] = { |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 4886 | SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW), |
Takashi Iwai | adabb3e | 2011-08-03 07:48:37 +0200 | [diff] [blame] | 4887 | SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC), |
| 4888 | SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC), |
| 4889 | SND_PCI_QUIRK(0x1043, 0x834a, "ASUS S101", ALC269_FIXUP_STEREO_DMIC), |
| 4890 | SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC), |
| 4891 | SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4892 | SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2), |
| 4893 | SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ), |
| 4894 | SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ), |
| 4895 | SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO), |
| 4896 | SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z), |
| 4897 | SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC), |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 4898 | SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook", ALC269_FIXUP_LIFEBOOK), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4899 | SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE), |
| 4900 | SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE), |
| 4901 | SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE), |
| 4902 | SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE), |
| 4903 | SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE), |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 4904 | SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_QUANTA_MUTE), |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 4905 | SND_PCI_QUIRK(0x17aa, 0x3bf8, "Lenovo Ideapd", ALC269_FIXUP_PCM_44K), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4906 | SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD), |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 4907 | |
| 4908 | #if 1 |
| 4909 | /* Below is a quirk table taken from the old code. |
| 4910 | * Basically the device should work as is without the fixup table. |
| 4911 | * If BIOS doesn't give a proper info, enable the corresponding |
| 4912 | * fixup entry. |
| 4913 | */ |
| 4914 | SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A", |
| 4915 | ALC269_FIXUP_AMIC), |
| 4916 | SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269_FIXUP_AMIC), |
| 4917 | SND_PCI_QUIRK(0x1043, 0x1113, "ASUS N63Jn", ALC269_FIXUP_AMIC), |
| 4918 | SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269_FIXUP_AMIC), |
| 4919 | SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_FIXUP_AMIC), |
| 4920 | SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269_FIXUP_AMIC), |
| 4921 | SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269_FIXUP_AMIC), |
| 4922 | SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269_FIXUP_AMIC), |
| 4923 | SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269_FIXUP_AMIC), |
| 4924 | SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_FIXUP_AMIC), |
| 4925 | SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269_FIXUP_AMIC), |
| 4926 | SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_FIXUP_AMIC), |
| 4927 | SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_FIXUP_AMIC), |
| 4928 | SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_FIXUP_AMIC), |
| 4929 | SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_FIXUP_AMIC), |
| 4930 | SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_FIXUP_AMIC), |
| 4931 | SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_FIXUP_AMIC), |
| 4932 | SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_FIXUP_AMIC), |
| 4933 | SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_FIXUP_AMIC), |
| 4934 | SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_FIXUP_AMIC), |
| 4935 | SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_FIXUP_AMIC), |
| 4936 | SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_FIXUP_AMIC), |
| 4937 | SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_FIXUP_AMIC), |
| 4938 | SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_FIXUP_AMIC), |
| 4939 | SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_FIXUP_AMIC), |
| 4940 | SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_FIXUP_AMIC), |
| 4941 | SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_FIXUP_AMIC), |
| 4942 | SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_FIXUP_AMIC), |
| 4943 | SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_FIXUP_AMIC), |
| 4944 | SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_FIXUP_AMIC), |
| 4945 | SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_FIXUP_AMIC), |
| 4946 | SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_FIXUP_AMIC), |
| 4947 | SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_FIXUP_AMIC), |
| 4948 | SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_FIXUP_AMIC), |
| 4949 | SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_FIXUP_AMIC), |
| 4950 | SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_FIXUP_AMIC), |
| 4951 | SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_FIXUP_DMIC), |
| 4952 | SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_FIXUP_AMIC), |
| 4953 | SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_AMIC), |
| 4954 | SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_FIXUP_DMIC), |
| 4955 | SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_FIXUP_DMIC), |
| 4956 | #endif |
| 4957 | {} |
| 4958 | }; |
| 4959 | |
| 4960 | static const struct alc_model_fixup alc269_fixup_models[] = { |
| 4961 | {.id = ALC269_FIXUP_AMIC, .name = "laptop-amic"}, |
| 4962 | {.id = ALC269_FIXUP_DMIC, .name = "laptop-dmic"}, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4963 | {} |
| 4964 | }; |
| 4965 | |
| 4966 | |
| 4967 | static int alc269_fill_coef(struct hda_codec *codec) |
| 4968 | { |
| 4969 | int val; |
| 4970 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 4971 | if ((alc_get_coef0(codec) & 0x00ff) < 0x015) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4972 | alc_write_coef_idx(codec, 0xf, 0x960b); |
| 4973 | alc_write_coef_idx(codec, 0xe, 0x8817); |
| 4974 | } |
| 4975 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 4976 | if ((alc_get_coef0(codec) & 0x00ff) == 0x016) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4977 | alc_write_coef_idx(codec, 0xf, 0x960b); |
| 4978 | alc_write_coef_idx(codec, 0xe, 0x8814); |
| 4979 | } |
| 4980 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 4981 | if ((alc_get_coef0(codec) & 0x00ff) == 0x017) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4982 | val = alc_read_coef_idx(codec, 0x04); |
| 4983 | /* Power up output pin */ |
| 4984 | alc_write_coef_idx(codec, 0x04, val | (1<<11)); |
| 4985 | } |
| 4986 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 4987 | if ((alc_get_coef0(codec) & 0x00ff) == 0x018) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4988 | val = alc_read_coef_idx(codec, 0xd); |
| 4989 | if ((val & 0x0c00) >> 10 != 0x1) { |
| 4990 | /* Capless ramp up clock control */ |
| 4991 | alc_write_coef_idx(codec, 0xd, val | (1<<10)); |
| 4992 | } |
| 4993 | val = alc_read_coef_idx(codec, 0x17); |
| 4994 | if ((val & 0x01c0) >> 6 != 0x4) { |
| 4995 | /* Class D power on reset */ |
| 4996 | alc_write_coef_idx(codec, 0x17, val | (1<<7)); |
| 4997 | } |
| 4998 | } |
| 4999 | |
| 5000 | val = alc_read_coef_idx(codec, 0xd); /* Class D */ |
| 5001 | alc_write_coef_idx(codec, 0xd, val | (1<<14)); |
| 5002 | |
| 5003 | val = alc_read_coef_idx(codec, 0x4); /* HP */ |
| 5004 | alc_write_coef_idx(codec, 0x4, val | (1<<11)); |
| 5005 | |
| 5006 | return 0; |
| 5007 | } |
| 5008 | |
| 5009 | /* |
| 5010 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5011 | static int patch_alc269(struct hda_codec *codec) |
| 5012 | { |
| 5013 | struct alc_spec *spec; |
Takashi Iwai | 20ca0c3 | 2011-10-17 16:00:35 +0200 | [diff] [blame] | 5014 | int err = 0; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5015 | |
| 5016 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 5017 | if (spec == NULL) |
| 5018 | return -ENOMEM; |
| 5019 | |
| 5020 | codec->spec = spec; |
| 5021 | |
| 5022 | spec->mixer_nid = 0x0b; |
| 5023 | |
| 5024 | alc_auto_parse_customize_define(codec); |
| 5025 | |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5026 | err = alc_codec_rename_from_preset(codec); |
| 5027 | if (err < 0) |
| 5028 | goto error; |
| 5029 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5030 | if (codec->vendor_id == 0x10ec0269) { |
| 5031 | spec->codec_variant = ALC269_TYPE_ALC269VA; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 5032 | switch (alc_get_coef0(codec) & 0x00f0) { |
| 5033 | case 0x0010: |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5034 | if (codec->bus->pci->subsystem_vendor == 0x1025 && |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5035 | spec->cdefine.platform_type == 1) |
Takashi Iwai | 20ca0c3 | 2011-10-17 16:00:35 +0200 | [diff] [blame] | 5036 | err = alc_codec_rename(codec, "ALC271X"); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5037 | spec->codec_variant = ALC269_TYPE_ALC269VB; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 5038 | break; |
| 5039 | case 0x0020: |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5040 | if (codec->bus->pci->subsystem_vendor == 0x17aa && |
| 5041 | codec->bus->pci->subsystem_device == 0x21f3) |
Takashi Iwai | 20ca0c3 | 2011-10-17 16:00:35 +0200 | [diff] [blame] | 5042 | err = alc_codec_rename(codec, "ALC3202"); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5043 | spec->codec_variant = ALC269_TYPE_ALC269VC; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 5044 | break; |
| 5045 | default: |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5046 | alc_fix_pll_init(codec, 0x20, 0x04, 15); |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 5047 | } |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5048 | if (err < 0) |
| 5049 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5050 | alc269_fill_coef(codec); |
| 5051 | } |
| 5052 | |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 5053 | alc_pick_fixup(codec, alc269_fixup_models, |
| 5054 | alc269_fixup_tbl, alc269_fixups); |
| 5055 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5056 | |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 5057 | /* automatic parse from the BIOS config */ |
| 5058 | err = alc269_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5059 | if (err < 0) |
| 5060 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5061 | |
Takashi Iwai | 60a6a84 | 2011-07-27 14:01:24 +0200 | [diff] [blame] | 5062 | if (!spec->no_analog && !spec->adc_nids) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5063 | alc_auto_fill_adc_caps(codec); |
| 5064 | alc_rebuild_imux_for_auto_mic(codec); |
| 5065 | alc_remove_invalid_adc_nids(codec); |
| 5066 | } |
| 5067 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5068 | if (!spec->no_analog && !spec->cap_mixer) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5069 | set_capture_mixer(codec); |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5070 | |
| 5071 | if (!spec->no_analog && has_cdefine_beep(codec)) { |
| 5072 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5073 | if (err < 0) |
| 5074 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5075 | set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5076 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5077 | |
| 5078 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 5079 | |
| 5080 | spec->vmaster_nid = 0x02; |
| 5081 | |
| 5082 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 5083 | #ifdef CONFIG_PM |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5084 | codec->patch_ops.resume = alc269_resume; |
| 5085 | #endif |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 5086 | spec->init_hook = alc_auto_init_std; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5087 | spec->shutup = alc269_shutup; |
| 5088 | |
| 5089 | alc_init_jacks(codec); |
| 5090 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 5091 | if (!spec->loopback.amplist) |
| 5092 | spec->loopback.amplist = alc269_loopbacks; |
| 5093 | if (alc269_mic2_for_mute_led(codec)) |
| 5094 | codec->patch_ops.check_power_status = alc269_mic2_mute_check_ps; |
| 5095 | #endif |
| 5096 | |
| 5097 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5098 | |
| 5099 | error: |
| 5100 | alc_free(codec); |
| 5101 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5102 | } |
| 5103 | |
| 5104 | /* |
| 5105 | * ALC861 |
| 5106 | */ |
| 5107 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5108 | static int alc861_parse_auto_config(struct hda_codec *codec) |
| 5109 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5110 | static const hda_nid_t alc861_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5111 | static const hda_nid_t alc861_ssids[] = { 0x0e, 0x0f, 0x0b, 0 }; |
| 5112 | return alc_parse_auto_config(codec, alc861_ignore, alc861_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5113 | } |
| 5114 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5115 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 5116 | static const struct hda_amp_list alc861_loopbacks[] = { |
| 5117 | { 0x15, HDA_INPUT, 0 }, |
| 5118 | { 0x15, HDA_INPUT, 1 }, |
| 5119 | { 0x15, HDA_INPUT, 2 }, |
| 5120 | { 0x15, HDA_INPUT, 3 }, |
| 5121 | { } /* end */ |
| 5122 | }; |
| 5123 | #endif |
| 5124 | |
| 5125 | |
| 5126 | /* Pin config fixes */ |
| 5127 | enum { |
| 5128 | PINFIX_FSC_AMILO_PI1505, |
| 5129 | }; |
| 5130 | |
| 5131 | static const struct alc_fixup alc861_fixups[] = { |
| 5132 | [PINFIX_FSC_AMILO_PI1505] = { |
| 5133 | .type = ALC_FIXUP_PINS, |
| 5134 | .v.pins = (const struct alc_pincfg[]) { |
| 5135 | { 0x0b, 0x0221101f }, /* HP */ |
| 5136 | { 0x0f, 0x90170310 }, /* speaker */ |
| 5137 | { } |
| 5138 | } |
| 5139 | }, |
| 5140 | }; |
| 5141 | |
| 5142 | static const struct snd_pci_quirk alc861_fixup_tbl[] = { |
| 5143 | SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505), |
| 5144 | {} |
| 5145 | }; |
| 5146 | |
| 5147 | /* |
| 5148 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5149 | static int patch_alc861(struct hda_codec *codec) |
| 5150 | { |
| 5151 | struct alc_spec *spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5152 | int err; |
| 5153 | |
| 5154 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 5155 | if (spec == NULL) |
| 5156 | return -ENOMEM; |
| 5157 | |
| 5158 | codec->spec = spec; |
| 5159 | |
| 5160 | spec->mixer_nid = 0x15; |
| 5161 | |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 5162 | alc_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups); |
| 5163 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5164 | |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 5165 | /* automatic parse from the BIOS config */ |
| 5166 | err = alc861_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5167 | if (err < 0) |
| 5168 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5169 | |
Takashi Iwai | 60a6a84 | 2011-07-27 14:01:24 +0200 | [diff] [blame] | 5170 | if (!spec->no_analog && !spec->adc_nids) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5171 | alc_auto_fill_adc_caps(codec); |
| 5172 | alc_rebuild_imux_for_auto_mic(codec); |
| 5173 | alc_remove_invalid_adc_nids(codec); |
| 5174 | } |
| 5175 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5176 | if (!spec->no_analog && !spec->cap_mixer) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5177 | set_capture_mixer(codec); |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5178 | |
| 5179 | if (!spec->no_analog) { |
| 5180 | err = snd_hda_attach_beep_device(codec, 0x23); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5181 | if (err < 0) |
| 5182 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5183 | set_beep_amp(spec, 0x23, 0, HDA_OUTPUT); |
| 5184 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5185 | |
| 5186 | spec->vmaster_nid = 0x03; |
| 5187 | |
| 5188 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 5189 | |
| 5190 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 5191 | spec->init_hook = alc_auto_init_std; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5192 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 5193 | spec->power_hook = alc_power_eapd; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5194 | if (!spec->loopback.amplist) |
| 5195 | spec->loopback.amplist = alc861_loopbacks; |
| 5196 | #endif |
| 5197 | |
| 5198 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5199 | |
| 5200 | error: |
| 5201 | alc_free(codec); |
| 5202 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5203 | } |
| 5204 | |
| 5205 | /* |
| 5206 | * ALC861-VD support |
| 5207 | * |
| 5208 | * Based on ALC882 |
| 5209 | * |
| 5210 | * In addition, an independent DAC |
| 5211 | */ |
| 5212 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 5213 | #define alc861vd_loopbacks alc880_loopbacks |
| 5214 | #endif |
| 5215 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5216 | static int alc861vd_parse_auto_config(struct hda_codec *codec) |
| 5217 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5218 | static const hda_nid_t alc861vd_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5219 | static const hda_nid_t alc861vd_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 5220 | return alc_parse_auto_config(codec, alc861vd_ignore, alc861vd_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5221 | } |
| 5222 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5223 | enum { |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 5224 | ALC660VD_FIX_ASUS_GPIO1, |
| 5225 | ALC861VD_FIX_DALLAS, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5226 | }; |
| 5227 | |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 5228 | /* exclude VREF80 */ |
| 5229 | static void alc861vd_fixup_dallas(struct hda_codec *codec, |
| 5230 | const struct alc_fixup *fix, int action) |
| 5231 | { |
| 5232 | if (action == ALC_FIXUP_ACT_PRE_PROBE) { |
| 5233 | snd_hda_override_pin_caps(codec, 0x18, 0x00001714); |
| 5234 | snd_hda_override_pin_caps(codec, 0x19, 0x0000171c); |
| 5235 | } |
| 5236 | } |
| 5237 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5238 | static const struct alc_fixup alc861vd_fixups[] = { |
| 5239 | [ALC660VD_FIX_ASUS_GPIO1] = { |
| 5240 | .type = ALC_FIXUP_VERBS, |
| 5241 | .v.verbs = (const struct hda_verb[]) { |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 5242 | /* reset GPIO1 */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5243 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, |
| 5244 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, |
| 5245 | {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, |
| 5246 | { } |
| 5247 | } |
| 5248 | }, |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 5249 | [ALC861VD_FIX_DALLAS] = { |
| 5250 | .type = ALC_FIXUP_FUNC, |
| 5251 | .v.func = alc861vd_fixup_dallas, |
| 5252 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5253 | }; |
| 5254 | |
| 5255 | static const struct snd_pci_quirk alc861vd_fixup_tbl[] = { |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 5256 | SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_FIX_DALLAS), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5257 | SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1), |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 5258 | SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_FIX_DALLAS), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5259 | {} |
| 5260 | }; |
| 5261 | |
| 5262 | static const struct hda_verb alc660vd_eapd_verbs[] = { |
| 5263 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, |
| 5264 | {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2}, |
| 5265 | { } |
| 5266 | }; |
| 5267 | |
| 5268 | /* |
| 5269 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5270 | static int patch_alc861vd(struct hda_codec *codec) |
| 5271 | { |
| 5272 | struct alc_spec *spec; |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 5273 | int err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5274 | |
| 5275 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 5276 | if (spec == NULL) |
| 5277 | return -ENOMEM; |
| 5278 | |
| 5279 | codec->spec = spec; |
| 5280 | |
| 5281 | spec->mixer_nid = 0x0b; |
| 5282 | |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 5283 | alc_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups); |
| 5284 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5285 | |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 5286 | /* automatic parse from the BIOS config */ |
| 5287 | err = alc861vd_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5288 | if (err < 0) |
| 5289 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5290 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5291 | if (codec->vendor_id == 0x10ec0660) { |
| 5292 | /* always turn on EAPD */ |
| 5293 | add_verb(spec, alc660vd_eapd_verbs); |
| 5294 | } |
| 5295 | |
Takashi Iwai | 60a6a84 | 2011-07-27 14:01:24 +0200 | [diff] [blame] | 5296 | if (!spec->no_analog && !spec->adc_nids) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5297 | alc_auto_fill_adc_caps(codec); |
| 5298 | alc_rebuild_imux_for_auto_mic(codec); |
| 5299 | alc_remove_invalid_adc_nids(codec); |
| 5300 | } |
| 5301 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5302 | if (!spec->no_analog && !spec->cap_mixer) |
| 5303 | set_capture_mixer(codec); |
| 5304 | |
| 5305 | if (!spec->no_analog) { |
| 5306 | err = snd_hda_attach_beep_device(codec, 0x23); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5307 | if (err < 0) |
| 5308 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5309 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
| 5310 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5311 | |
| 5312 | spec->vmaster_nid = 0x02; |
| 5313 | |
| 5314 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 5315 | |
| 5316 | codec->patch_ops = alc_patch_ops; |
| 5317 | |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 5318 | spec->init_hook = alc_auto_init_std; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5319 | spec->shutup = alc_eapd_shutup; |
| 5320 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 5321 | if (!spec->loopback.amplist) |
| 5322 | spec->loopback.amplist = alc861vd_loopbacks; |
| 5323 | #endif |
| 5324 | |
| 5325 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5326 | |
| 5327 | error: |
| 5328 | alc_free(codec); |
| 5329 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5330 | } |
| 5331 | |
| 5332 | /* |
| 5333 | * ALC662 support |
| 5334 | * |
| 5335 | * ALC662 is almost identical with ALC880 but has cleaner and more flexible |
| 5336 | * configuration. Each pin widget can choose any input DACs and a mixer. |
| 5337 | * Each ADC is connected from a mixer of all inputs. This makes possible |
| 5338 | * 6-channel independent captures. |
| 5339 | * |
| 5340 | * In addition, an independent DAC for the multi-playback (not used in this |
| 5341 | * driver yet). |
| 5342 | */ |
| 5343 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 5344 | #define alc662_loopbacks alc880_loopbacks |
| 5345 | #endif |
| 5346 | |
| 5347 | /* |
| 5348 | * BIOS auto configuration |
| 5349 | */ |
| 5350 | |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 5351 | static int alc662_parse_auto_config(struct hda_codec *codec) |
| 5352 | { |
Takashi Iwai | 4c6d72d | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 5353 | static const hda_nid_t alc662_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5354 | static const hda_nid_t alc663_ssids[] = { 0x15, 0x1b, 0x14, 0x21 }; |
| 5355 | static const hda_nid_t alc662_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 5356 | const hda_nid_t *ssids; |
Takashi Iwai | ee979a14 | 2008-09-02 15:42:20 +0200 | [diff] [blame] | 5357 | |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 5358 | if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 || |
| 5359 | codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670) |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5360 | ssids = alc663_ssids; |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 5361 | else |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5362 | ssids = alc662_ssids; |
| 5363 | return alc_parse_auto_config(codec, alc662_ignore, ssids); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 5364 | } |
| 5365 | |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 5366 | static void alc272_fixup_mario(struct hda_codec *codec, |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 5367 | const struct alc_fixup *fix, int action) |
Takashi Iwai | 6fc398c | 2011-01-13 14:36:37 +0100 | [diff] [blame] | 5368 | { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 5369 | if (action != ALC_FIXUP_ACT_PROBE) |
Takashi Iwai | 6fc398c | 2011-01-13 14:36:37 +0100 | [diff] [blame] | 5370 | return; |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 5371 | if (snd_hda_override_amp_caps(codec, 0x2, HDA_OUTPUT, |
| 5372 | (0x3b << AC_AMPCAP_OFFSET_SHIFT) | |
| 5373 | (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT) | |
| 5374 | (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT) | |
| 5375 | (0 << AC_AMPCAP_MUTE_SHIFT))) |
| 5376 | printk(KERN_WARNING |
| 5377 | "hda_codec: failed to override amp caps for NID 0x2\n"); |
| 5378 | } |
| 5379 | |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 5380 | enum { |
Daniel T Chen | 2df0351 | 2010-10-10 22:39:28 -0400 | [diff] [blame] | 5381 | ALC662_FIXUP_ASPIRE, |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 5382 | ALC662_FIXUP_IDEAPAD, |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 5383 | ALC272_FIXUP_MARIO, |
Anisse Astier | d2ebd47 | 2011-01-20 12:36:21 +0100 | [diff] [blame] | 5384 | ALC662_FIXUP_CZC_P10T, |
David Henningsson | 94024cd | 2011-04-29 14:10:55 +0200 | [diff] [blame] | 5385 | ALC662_FIXUP_SKU_IGNORE, |
Takashi Iwai | e59ea3e | 2011-06-29 17:21:00 +0200 | [diff] [blame] | 5386 | ALC662_FIXUP_HP_RP5800, |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 5387 | ALC662_FIXUP_ASUS_MODE1, |
| 5388 | ALC662_FIXUP_ASUS_MODE2, |
| 5389 | ALC662_FIXUP_ASUS_MODE3, |
| 5390 | ALC662_FIXUP_ASUS_MODE4, |
| 5391 | ALC662_FIXUP_ASUS_MODE5, |
| 5392 | ALC662_FIXUP_ASUS_MODE6, |
| 5393 | ALC662_FIXUP_ASUS_MODE7, |
| 5394 | ALC662_FIXUP_ASUS_MODE8, |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 5395 | }; |
| 5396 | |
| 5397 | static const struct alc_fixup alc662_fixups[] = { |
Daniel T Chen | 2df0351 | 2010-10-10 22:39:28 -0400 | [diff] [blame] | 5398 | [ALC662_FIXUP_ASPIRE] = { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 5399 | .type = ALC_FIXUP_PINS, |
| 5400 | .v.pins = (const struct alc_pincfg[]) { |
Daniel T Chen | 2df0351 | 2010-10-10 22:39:28 -0400 | [diff] [blame] | 5401 | { 0x15, 0x99130112 }, /* subwoofer */ |
| 5402 | { } |
| 5403 | } |
| 5404 | }, |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 5405 | [ALC662_FIXUP_IDEAPAD] = { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 5406 | .type = ALC_FIXUP_PINS, |
| 5407 | .v.pins = (const struct alc_pincfg[]) { |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 5408 | { 0x17, 0x99130112 }, /* subwoofer */ |
| 5409 | { } |
| 5410 | } |
| 5411 | }, |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 5412 | [ALC272_FIXUP_MARIO] = { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 5413 | .type = ALC_FIXUP_FUNC, |
| 5414 | .v.func = alc272_fixup_mario, |
Anisse Astier | d2ebd47 | 2011-01-20 12:36:21 +0100 | [diff] [blame] | 5415 | }, |
| 5416 | [ALC662_FIXUP_CZC_P10T] = { |
| 5417 | .type = ALC_FIXUP_VERBS, |
| 5418 | .v.verbs = (const struct hda_verb[]) { |
| 5419 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0}, |
| 5420 | {} |
| 5421 | } |
| 5422 | }, |
David Henningsson | 94024cd | 2011-04-29 14:10:55 +0200 | [diff] [blame] | 5423 | [ALC662_FIXUP_SKU_IGNORE] = { |
| 5424 | .type = ALC_FIXUP_SKU, |
| 5425 | .v.sku = ALC_FIXUP_SKU_IGNORE, |
Takashi Iwai | c6b3587 | 2011-03-28 12:05:31 +0200 | [diff] [blame] | 5426 | }, |
Takashi Iwai | e59ea3e | 2011-06-29 17:21:00 +0200 | [diff] [blame] | 5427 | [ALC662_FIXUP_HP_RP5800] = { |
| 5428 | .type = ALC_FIXUP_PINS, |
| 5429 | .v.pins = (const struct alc_pincfg[]) { |
| 5430 | { 0x14, 0x0221201f }, /* HP out */ |
| 5431 | { } |
| 5432 | }, |
| 5433 | .chained = true, |
| 5434 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 5435 | }, |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 5436 | [ALC662_FIXUP_ASUS_MODE1] = { |
| 5437 | .type = ALC_FIXUP_PINS, |
| 5438 | .v.pins = (const struct alc_pincfg[]) { |
| 5439 | { 0x14, 0x99130110 }, /* speaker */ |
| 5440 | { 0x18, 0x01a19c20 }, /* mic */ |
| 5441 | { 0x19, 0x99a3092f }, /* int-mic */ |
| 5442 | { 0x21, 0x0121401f }, /* HP out */ |
| 5443 | { } |
| 5444 | }, |
| 5445 | .chained = true, |
| 5446 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 5447 | }, |
| 5448 | [ALC662_FIXUP_ASUS_MODE2] = { |
Takashi Iwai | 2996bdb | 2011-08-18 16:02:24 +0200 | [diff] [blame] | 5449 | .type = ALC_FIXUP_PINS, |
| 5450 | .v.pins = (const struct alc_pincfg[]) { |
| 5451 | { 0x14, 0x99130110 }, /* speaker */ |
| 5452 | { 0x18, 0x01a19820 }, /* mic */ |
| 5453 | { 0x19, 0x99a3092f }, /* int-mic */ |
| 5454 | { 0x1b, 0x0121401f }, /* HP out */ |
| 5455 | { } |
| 5456 | }, |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 5457 | .chained = true, |
| 5458 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 5459 | }, |
| 5460 | [ALC662_FIXUP_ASUS_MODE3] = { |
| 5461 | .type = ALC_FIXUP_PINS, |
| 5462 | .v.pins = (const struct alc_pincfg[]) { |
| 5463 | { 0x14, 0x99130110 }, /* speaker */ |
| 5464 | { 0x15, 0x0121441f }, /* HP */ |
| 5465 | { 0x18, 0x01a19840 }, /* mic */ |
| 5466 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 5467 | { 0x21, 0x01211420 }, /* HP2 */ |
| 5468 | { } |
| 5469 | }, |
| 5470 | .chained = true, |
| 5471 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 5472 | }, |
| 5473 | [ALC662_FIXUP_ASUS_MODE4] = { |
| 5474 | .type = ALC_FIXUP_PINS, |
| 5475 | .v.pins = (const struct alc_pincfg[]) { |
| 5476 | { 0x14, 0x99130110 }, /* speaker */ |
| 5477 | { 0x16, 0x99130111 }, /* speaker */ |
| 5478 | { 0x18, 0x01a19840 }, /* mic */ |
| 5479 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 5480 | { 0x21, 0x0121441f }, /* HP */ |
| 5481 | { } |
| 5482 | }, |
| 5483 | .chained = true, |
| 5484 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 5485 | }, |
| 5486 | [ALC662_FIXUP_ASUS_MODE5] = { |
| 5487 | .type = ALC_FIXUP_PINS, |
| 5488 | .v.pins = (const struct alc_pincfg[]) { |
| 5489 | { 0x14, 0x99130110 }, /* speaker */ |
| 5490 | { 0x15, 0x0121441f }, /* HP */ |
| 5491 | { 0x16, 0x99130111 }, /* speaker */ |
| 5492 | { 0x18, 0x01a19840 }, /* mic */ |
| 5493 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 5494 | { } |
| 5495 | }, |
| 5496 | .chained = true, |
| 5497 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 5498 | }, |
| 5499 | [ALC662_FIXUP_ASUS_MODE6] = { |
| 5500 | .type = ALC_FIXUP_PINS, |
| 5501 | .v.pins = (const struct alc_pincfg[]) { |
| 5502 | { 0x14, 0x99130110 }, /* speaker */ |
| 5503 | { 0x15, 0x01211420 }, /* HP2 */ |
| 5504 | { 0x18, 0x01a19840 }, /* mic */ |
| 5505 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 5506 | { 0x1b, 0x0121441f }, /* HP */ |
| 5507 | { } |
| 5508 | }, |
| 5509 | .chained = true, |
| 5510 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 5511 | }, |
| 5512 | [ALC662_FIXUP_ASUS_MODE7] = { |
| 5513 | .type = ALC_FIXUP_PINS, |
| 5514 | .v.pins = (const struct alc_pincfg[]) { |
| 5515 | { 0x14, 0x99130110 }, /* speaker */ |
| 5516 | { 0x17, 0x99130111 }, /* speaker */ |
| 5517 | { 0x18, 0x01a19840 }, /* mic */ |
| 5518 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 5519 | { 0x1b, 0x01214020 }, /* HP */ |
| 5520 | { 0x21, 0x0121401f }, /* HP */ |
| 5521 | { } |
| 5522 | }, |
| 5523 | .chained = true, |
| 5524 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 5525 | }, |
| 5526 | [ALC662_FIXUP_ASUS_MODE8] = { |
| 5527 | .type = ALC_FIXUP_PINS, |
| 5528 | .v.pins = (const struct alc_pincfg[]) { |
| 5529 | { 0x14, 0x99130110 }, /* speaker */ |
| 5530 | { 0x12, 0x99a30970 }, /* int-mic */ |
| 5531 | { 0x15, 0x01214020 }, /* HP */ |
| 5532 | { 0x17, 0x99130111 }, /* speaker */ |
| 5533 | { 0x18, 0x01a19840 }, /* mic */ |
| 5534 | { 0x21, 0x0121401f }, /* HP */ |
| 5535 | { } |
| 5536 | }, |
| 5537 | .chained = true, |
| 5538 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
Takashi Iwai | 2996bdb | 2011-08-18 16:02:24 +0200 | [diff] [blame] | 5539 | }, |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 5540 | }; |
| 5541 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 5542 | static const struct snd_pci_quirk alc662_fixup_tbl[] = { |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 5543 | SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_FIXUP_ASUS_MODE2), |
David Henningsson | a6c47a8 | 2011-02-10 15:39:19 +0100 | [diff] [blame] | 5544 | SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE), |
David Henningsson | 94024cd | 2011-04-29 14:10:55 +0200 | [diff] [blame] | 5545 | SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE), |
Daniel T Chen | 2df0351 | 2010-10-10 22:39:28 -0400 | [diff] [blame] | 5546 | SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE), |
Takashi Iwai | e59ea3e | 2011-06-29 17:21:00 +0200 | [diff] [blame] | 5547 | SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800), |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 5548 | SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2), |
Daniel T Chen | a0e90ac | 2010-11-20 10:20:35 -0500 | [diff] [blame] | 5549 | SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD), |
Valentine Sinitsyn | d411858 | 2010-10-01 22:24:08 +0600 | [diff] [blame] | 5550 | SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD), |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 5551 | SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD), |
Anisse Astier | d2ebd47 | 2011-01-20 12:36:21 +0100 | [diff] [blame] | 5552 | SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T), |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 5553 | |
| 5554 | #if 0 |
| 5555 | /* Below is a quirk table taken from the old code. |
| 5556 | * Basically the device should work as is without the fixup table. |
| 5557 | * If BIOS doesn't give a proper info, enable the corresponding |
| 5558 | * fixup entry. |
| 5559 | */ |
| 5560 | SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC662_FIXUP_ASUS_MODE1), |
| 5561 | SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC662_FIXUP_ASUS_MODE3), |
| 5562 | SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC662_FIXUP_ASUS_MODE1), |
| 5563 | SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC662_FIXUP_ASUS_MODE3), |
| 5564 | SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), |
| 5565 | SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 5566 | SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), |
| 5567 | SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC662_FIXUP_ASUS_MODE1), |
| 5568 | SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC662_FIXUP_ASUS_MODE1), |
| 5569 | SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 5570 | SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC662_FIXUP_ASUS_MODE7), |
| 5571 | SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC662_FIXUP_ASUS_MODE7), |
| 5572 | SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC662_FIXUP_ASUS_MODE8), |
| 5573 | SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC662_FIXUP_ASUS_MODE3), |
| 5574 | SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC662_FIXUP_ASUS_MODE1), |
| 5575 | SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 5576 | SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_FIXUP_ASUS_MODE2), |
| 5577 | SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC662_FIXUP_ASUS_MODE1), |
| 5578 | SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 5579 | SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC662_FIXUP_ASUS_MODE6), |
| 5580 | SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC662_FIXUP_ASUS_MODE6), |
| 5581 | SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 5582 | SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC662_FIXUP_ASUS_MODE1), |
| 5583 | SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC662_FIXUP_ASUS_MODE3), |
| 5584 | SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_FIXUP_ASUS_MODE2), |
| 5585 | SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 5586 | SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC662_FIXUP_ASUS_MODE5), |
| 5587 | SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC662_FIXUP_ASUS_MODE6), |
| 5588 | SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 5589 | SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC662_FIXUP_ASUS_MODE1), |
| 5590 | SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 5591 | SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 5592 | SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC662_FIXUP_ASUS_MODE3), |
| 5593 | SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC662_FIXUP_ASUS_MODE3), |
| 5594 | SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC662_FIXUP_ASUS_MODE1), |
| 5595 | SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC662_FIXUP_ASUS_MODE1), |
| 5596 | SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC662_FIXUP_ASUS_MODE1), |
| 5597 | SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC662_FIXUP_ASUS_MODE1), |
| 5598 | SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC662_FIXUP_ASUS_MODE1), |
| 5599 | SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 5600 | SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_FIXUP_ASUS_MODE2), |
| 5601 | SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC662_FIXUP_ASUS_MODE1), |
| 5602 | SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), |
| 5603 | SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC662_FIXUP_ASUS_MODE3), |
| 5604 | SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC662_FIXUP_ASUS_MODE1), |
| 5605 | SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC662_FIXUP_ASUS_MODE1), |
| 5606 | SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC662_FIXUP_ASUS_MODE1), |
| 5607 | SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_FIXUP_ASUS_MODE2), |
| 5608 | SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), |
| 5609 | SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE4), |
| 5610 | #endif |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 5611 | {} |
| 5612 | }; |
| 5613 | |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 5614 | static const struct alc_model_fixup alc662_fixup_models[] = { |
| 5615 | {.id = ALC272_FIXUP_MARIO, .name = "mario"}, |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 5616 | {.id = ALC662_FIXUP_ASUS_MODE1, .name = "asus-mode1"}, |
| 5617 | {.id = ALC662_FIXUP_ASUS_MODE2, .name = "asus-mode2"}, |
| 5618 | {.id = ALC662_FIXUP_ASUS_MODE3, .name = "asus-mode3"}, |
| 5619 | {.id = ALC662_FIXUP_ASUS_MODE4, .name = "asus-mode4"}, |
| 5620 | {.id = ALC662_FIXUP_ASUS_MODE5, .name = "asus-mode5"}, |
| 5621 | {.id = ALC662_FIXUP_ASUS_MODE6, .name = "asus-mode6"}, |
| 5622 | {.id = ALC662_FIXUP_ASUS_MODE7, .name = "asus-mode7"}, |
| 5623 | {.id = ALC662_FIXUP_ASUS_MODE8, .name = "asus-mode8"}, |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 5624 | {} |
| 5625 | }; |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 5626 | |
| 5627 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5628 | /* |
| 5629 | */ |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 5630 | static int patch_alc662(struct hda_codec *codec) |
| 5631 | { |
| 5632 | struct alc_spec *spec; |
Takashi Iwai | 20ca0c3 | 2011-10-17 16:00:35 +0200 | [diff] [blame] | 5633 | int err = 0; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 5634 | |
| 5635 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 5636 | if (!spec) |
| 5637 | return -ENOMEM; |
| 5638 | |
| 5639 | codec->spec = spec; |
| 5640 | |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 5641 | spec->mixer_nid = 0x0b; |
| 5642 | |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 5643 | /* handle multiple HPs as is */ |
| 5644 | spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP; |
| 5645 | |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 5646 | alc_auto_parse_customize_define(codec); |
| 5647 | |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 5648 | alc_fix_pll_init(codec, 0x20, 0x04, 15); |
| 5649 | |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5650 | err = alc_codec_rename_from_preset(codec); |
| 5651 | if (err < 0) |
| 5652 | goto error; |
| 5653 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 5654 | if ((alc_get_coef0(codec) & (1 << 14)) && |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5655 | codec->bus->pci->subsystem_vendor == 0x1025 && |
| 5656 | spec->cdefine.platform_type == 1) { |
| 5657 | if (alc_codec_rename(codec, "ALC272X") < 0) |
| 5658 | goto error; |
Takashi Iwai | 20ca0c3 | 2011-10-17 16:00:35 +0200 | [diff] [blame] | 5659 | } |
Kailang Yang | 274693f | 2009-12-03 10:07:50 +0100 | [diff] [blame] | 5660 | |
Takashi Iwai | b9c5106 | 2011-08-24 18:08:07 +0200 | [diff] [blame] | 5661 | alc_pick_fixup(codec, alc662_fixup_models, |
| 5662 | alc662_fixup_tbl, alc662_fixups); |
| 5663 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
| 5664 | /* automatic parse from the BIOS config */ |
| 5665 | err = alc662_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5666 | if (err < 0) |
| 5667 | goto error; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 5668 | |
Takashi Iwai | 60a6a84 | 2011-07-27 14:01:24 +0200 | [diff] [blame] | 5669 | if (!spec->no_analog && !spec->adc_nids) { |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 5670 | alc_auto_fill_adc_caps(codec); |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 5671 | alc_rebuild_imux_for_auto_mic(codec); |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 5672 | alc_remove_invalid_adc_nids(codec); |
Takashi Iwai | dd70469 | 2009-08-11 08:45:11 +0200 | [diff] [blame] | 5673 | } |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 5674 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5675 | if (!spec->no_analog && !spec->cap_mixer) |
Takashi Iwai | b59bdf3 | 2009-08-11 09:47:30 +0200 | [diff] [blame] | 5676 | set_capture_mixer(codec); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 5677 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5678 | if (!spec->no_analog && has_cdefine_beep(codec)) { |
| 5679 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5680 | if (err < 0) |
| 5681 | goto error; |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 5682 | switch (codec->vendor_id) { |
| 5683 | case 0x10ec0662: |
| 5684 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
| 5685 | break; |
| 5686 | case 0x10ec0272: |
| 5687 | case 0x10ec0663: |
| 5688 | case 0x10ec0665: |
| 5689 | set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); |
| 5690 | break; |
| 5691 | case 0x10ec0273: |
| 5692 | set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT); |
| 5693 | break; |
| 5694 | } |
Kailang Yang | cec27c8 | 2010-02-04 14:18:18 +0100 | [diff] [blame] | 5695 | } |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 5696 | spec->vmaster_nid = 0x02; |
| 5697 | |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 5698 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 5699 | |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 5700 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | b9c5106 | 2011-08-24 18:08:07 +0200 | [diff] [blame] | 5701 | spec->init_hook = alc_auto_init_std; |
Takashi Iwai | 1c716153 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 5702 | spec->shutup = alc_eapd_shutup; |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 5703 | |
Kailang Yang | bf1b022 | 2010-10-21 08:49:56 +0200 | [diff] [blame] | 5704 | alc_init_jacks(codec); |
| 5705 | |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 5706 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 5707 | if (!spec->loopback.amplist) |
| 5708 | spec->loopback.amplist = alc662_loopbacks; |
| 5709 | #endif |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 5710 | |
| 5711 | return 0; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 5712 | |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5713 | error: |
| 5714 | alc_free(codec); |
| 5715 | return err; |
Kailang Yang | b478b99 | 2011-05-18 11:51:15 +0200 | [diff] [blame] | 5716 | } |
| 5717 | |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 5718 | /* |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 5719 | * ALC680 support |
| 5720 | */ |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 5721 | |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 5722 | static int alc680_parse_auto_config(struct hda_codec *codec) |
| 5723 | { |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5724 | return alc_parse_auto_config(codec, NULL, NULL); |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 5725 | } |
| 5726 | |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 5727 | /* |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 5728 | */ |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 5729 | static int patch_alc680(struct hda_codec *codec) |
| 5730 | { |
| 5731 | struct alc_spec *spec; |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 5732 | int err; |
| 5733 | |
| 5734 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 5735 | if (spec == NULL) |
| 5736 | return -ENOMEM; |
| 5737 | |
| 5738 | codec->spec = spec; |
| 5739 | |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 5740 | /* ALC680 has no aa-loopback mixer */ |
| 5741 | |
Takashi Iwai | 1ebec5f | 2011-08-15 13:21:48 +0200 | [diff] [blame] | 5742 | /* automatic parse from the BIOS config */ |
| 5743 | err = alc680_parse_auto_config(codec); |
| 5744 | if (err < 0) { |
| 5745 | alc_free(codec); |
| 5746 | return err; |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 5747 | } |
| 5748 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5749 | if (!spec->no_analog && !spec->cap_mixer) |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 5750 | set_capture_mixer(codec); |
| 5751 | |
| 5752 | spec->vmaster_nid = 0x02; |
| 5753 | |
| 5754 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1ebec5f | 2011-08-15 13:21:48 +0200 | [diff] [blame] | 5755 | spec->init_hook = alc_auto_init_std; |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 5756 | |
| 5757 | return 0; |
| 5758 | } |
| 5759 | |
| 5760 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5761 | * patch entries |
| 5762 | */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 5763 | static const struct hda_codec_preset snd_hda_preset_realtek[] = { |
Kailang Yang | 296f033 | 2011-05-18 11:52:36 +0200 | [diff] [blame] | 5764 | { .id = 0x10ec0221, .name = "ALC221", .patch = patch_alc269 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5765 | { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 5766 | { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 }, |
Kailang Yang | f6a9224 | 2007-12-13 16:52:54 +0100 | [diff] [blame] | 5767 | { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 }, |
Kailang Yang | a361d84 | 2007-06-05 12:30:55 +0200 | [diff] [blame] | 5768 | { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 }, |
Kailang Yang | f6a9224 | 2007-12-13 16:52:54 +0100 | [diff] [blame] | 5769 | { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 }, |
Kailang Yang | ebb83ee | 2009-12-17 12:23:00 +0100 | [diff] [blame] | 5770 | { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 }, |
Kailang Yang | 01afd41 | 2008-10-15 11:22:09 +0200 | [diff] [blame] | 5771 | { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 }, |
Kailang Yang | ebb83ee | 2009-12-17 12:23:00 +0100 | [diff] [blame] | 5772 | { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 }, |
Kailang Yang | 296f033 | 2011-05-18 11:52:36 +0200 | [diff] [blame] | 5773 | { .id = 0x10ec0276, .name = "ALC276", .patch = patch_alc269 }, |
Jakub Schmidtke | f32610e | 2007-02-02 18:17:27 +0100 | [diff] [blame] | 5774 | { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660", |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 5775 | .patch = patch_alc861 }, |
Jakub Schmidtke | f32610e | 2007-02-02 18:17:27 +0100 | [diff] [blame] | 5776 | { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd }, |
| 5777 | { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 }, |
| 5778 | { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd }, |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 5779 | { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2", |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 5780 | .patch = patch_alc882 }, |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 5781 | { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1", |
| 5782 | .patch = patch_alc662 }, |
David Henningsson | cc667a7 | 2011-10-18 14:07:51 +0200 | [diff] [blame^] | 5783 | { .id = 0x10ec0662, .rev = 0x100300, .name = "ALC662 rev3", |
| 5784 | .patch = patch_alc662 }, |
Kailang Yang | 6dda9f4 | 2008-05-27 12:05:31 +0200 | [diff] [blame] | 5785 | { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 }, |
Kailang Yang | cec27c8 | 2010-02-04 14:18:18 +0100 | [diff] [blame] | 5786 | { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 }, |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 5787 | { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 }, |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 5788 | { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 }, |
Jakub Schmidtke | f32610e | 2007-02-02 18:17:27 +0100 | [diff] [blame] | 5789 | { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5790 | { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 }, |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 5791 | { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 }, |
Clive Messer | 669faba | 2008-09-30 15:49:13 +0200 | [diff] [blame] | 5792 | { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A", |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 5793 | .patch = patch_alc882 }, |
Takashi Iwai | cb308f9 | 2008-04-16 14:13:29 +0200 | [diff] [blame] | 5794 | { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A", |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 5795 | .patch = patch_alc882 }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 5796 | { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 }, |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5797 | { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 }, |
Kailang Yang | 4442608 | 2008-10-15 11:18:05 +0200 | [diff] [blame] | 5798 | { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200", |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 5799 | .patch = patch_alc882 }, |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5800 | { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc882 }, |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 5801 | { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 }, |
Kailang Yang | 274693f | 2009-12-03 10:07:50 +0100 | [diff] [blame] | 5802 | { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 }, |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5803 | { .id = 0x10ec0899, .name = "ALC898", .patch = patch_alc882 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5804 | {} /* terminator */ |
| 5805 | }; |
Takashi Iwai | 1289e9e | 2008-11-27 15:47:11 +0100 | [diff] [blame] | 5806 | |
| 5807 | MODULE_ALIAS("snd-hda-codec-id:10ec*"); |
| 5808 | |
| 5809 | MODULE_LICENSE("GPL"); |
| 5810 | MODULE_DESCRIPTION("Realtek HD-audio codec"); |
| 5811 | |
| 5812 | static struct hda_codec_preset_list realtek_list = { |
| 5813 | .preset = snd_hda_preset_realtek, |
| 5814 | .owner = THIS_MODULE, |
| 5815 | }; |
| 5816 | |
| 5817 | static int __init patch_realtek_init(void) |
| 5818 | { |
| 5819 | return snd_hda_add_codec_preset(&realtek_list); |
| 5820 | } |
| 5821 | |
| 5822 | static void __exit patch_realtek_exit(void) |
| 5823 | { |
| 5824 | snd_hda_delete_codec_preset(&realtek_list); |
| 5825 | } |
| 5826 | |
| 5827 | module_init(patch_realtek_init) |
| 5828 | module_exit(patch_realtek_exit) |